--- loncom/interface/lonnavmaps.pm 2009/05/04 16:45:57 1.434 +++ loncom/interface/lonnavmaps.pm 2010/12/30 21:32:17 1.444.2.3 @@ -1,7 +1,8 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.434 2009/05/04 16:45:57 bisitz Exp $ +# $Id: lonnavmaps.pm,v 1.444.2.3 2010/12/30 21:32:17 raeburn Exp $ + # # Copyright Michigan State University Board of Trustees # @@ -31,7 +32,7 @@ =head1 NAME -Apache::lonnavmaps.pm +Apache::lonnavmaps - Subroutines to handle and render the navigation =head1 SYNOPSIS @@ -477,6 +478,7 @@ use Apache::loncommon(); use Apache::lonenc(); use Apache::lonlocal; use Apache::lonnet; + use POSIX qw (floor strftime); use Time::HiRes qw( gettimeofday tv_interval ); use LONCAPA; @@ -491,7 +493,7 @@ sub NOTHING { return 3; } my $resObj = "Apache::lonnavmaps::resource"; -# Keep these mappings in sync with lonquickgrades, which uses the colors +# Keep these mappings in sync with lonquickgrades, which usesthe colors # instead of the icons. my %statusIconMap = ( @@ -504,10 +506,13 @@ my %statusIconMap = $resObj->ERROR => '' ); -my %iconAltTags = - ( 'navmap.correct.gif' => 'Correct', - 'navmap.wrong.gif' => 'Incorrect', - 'navmap.open.gif' => 'Open' ); +my %iconAltTags = #texthash does not work here + ( 'navmap.correct.gif' => 'Correct', + 'navmap.wrong.gif' => 'Incorrect', + 'navmap.open.gif' => 'Open', + 'navmap.partial.gif' => 'Partially Correct', + 'navmap.ellipsis.gif' => 'Attempted', + ); # Defines a status->color mapping, null string means don't color my %colormap = @@ -522,6 +527,7 @@ my %colormap = $resObj->INCORRECT => '', $resObj->OPEN => '', $resObj->NOTHING_SET => '', + $resObj->CREDIT_ATTEMPTED => '', $resObj->ATTEMPTED => '', $resObj->ANSWER_SUBMITTED => '', $resObj->PARTIALLY_CORRECT => '#006600' @@ -597,7 +603,7 @@ sub getLinkForResource { my ($map,$id,$src)=&Apache::lonnet::decode_symb($res->symb()); if ($map=~/\.page$/) { my $url=&Apache::lonnet::clutter($map); - $anchor=&escape($src->shown_symb()); + $anchor=&escape($res->shown_symb()); return ($url,$res->shown_symb(),$anchor); } } @@ -695,7 +701,16 @@ sub getDescription { return &mt("Excused by instructor"); } if ($status == $res->ATTEMPTED) { - return &mt("Answer submitted, not yet graded"); + if ($res->is_anonsurvey($part) || $res->is_survey($part)) { + return &mt("Survey submission recorded"); + } else { + return &mt("Answer submitted, not yet graded"); + } + } + if ($status == $res->CREDIT_ATTEMPTED) { + if ($res->is_anonsurvey($part) || $res->is_survey($part)) { + return &mt("Credit for survey submission"); + } } if ($status == $res->TRIES_LEFT) { my $tries = $res->tries($part); @@ -880,11 +895,6 @@ sub render_resource { my $link = $params->{"resourceLink"}; # The URL part is not escaped at this point, but the symb is... - # The stuff to the left of the ? must have ' replaced by \' since - # it will be quoted with ' in the href. - - my ($left,$right) = split(/\?/, $link); - $link = $left.'?'.$right; my $src = $resource->src(); my $it = $params->{"iterator"}; @@ -1038,7 +1048,7 @@ sub render_communication_status { my $location=&Apache::loncommon::lonhttpdurl("/adm/lonMisc"); if ($resource->hasDiscussion()) { $discussionHTML = $linkopen . - ''.&mt('New Discussion').'' . + ''.&mt('New Discussion').'' . $linkclose; } @@ -1048,7 +1058,7 @@ sub render_communication_status { if ($msgid) { $feedbackHTML .= ' ' - . ''.&mt('New E-mail').''; + . ''.&mt('New E-mail').''; } } } @@ -1062,7 +1072,7 @@ sub render_communication_status { $errorcount++; $errorHTML .= ' ' - . ''.&mt('New Error').''; + . ''.&mt('New Error').''; } } } @@ -1095,7 +1105,7 @@ sub render_quick_status { if ($icon) { my $location= &Apache::loncommon::lonhttpdurl("/adm/lonIcons/$icon"); - $result .= "$linkopen$alt$linkclose"; + $result .= $linkopen.''.&mt($alt).''.$linkclose; } else { $result .= " "; } @@ -1437,19 +1447,22 @@ sub render { if ($printCloseAll && !$args->{'resource_no_folder_link'}) { my ($link,$text); if ($condition) { - $link='"navmaps?condition=0&filter=&'.$queryString. - '&here='.&escape($here).'"'; + $link='navmaps?condition=0&filter=&'.$queryString. + '&here='.&escape($here); $text='Close all folders'; } else { - $link='"navmaps?condition=1&filter=&'.$queryString. - '&here='.&escape($here).'"'; + $link='navmaps?condition=1&filter=&'.$queryString. + '&here='.&escape($here); $text='Open all folders'; } + if ($env{'form.register'}) { + $link .= '&register='.$env{'form.register'}; + } if ($args->{'caller'} eq 'navmapsdisplay') { &add_linkitem($args->{'linkitems'},'changefolder', - 'location.href='.$link,$text); + "location.href='$link'",$text); } else { - $result.=''.&mt($text).''; + $result.= ''.&mt($text).''; } $result .= "\n"; } @@ -1465,6 +1478,9 @@ sub render { END + if ($env{'form.register'}) { + $result .= ''; + } if ($args->{'sort'} eq 'discussion') { my $totdisc = 0; my $haveDisc = ''; @@ -1486,26 +1502,22 @@ END $result.=''; } - if ($args->{'caller'} eq 'navmapsdisplay') { $result .= ''; - if ($env{'environment.remotenavmap'} ne 'on') { - $result .= ''; - } else { - $result .= ''; - } - $result.=""; - $result.=&show_linkitems_toolbar($args->{'linkitems'}); + &Apache::loncommon::help_open_menu('Navigation Screen','Navigation_Screen',undef,'RAT').''. + ''. + &show_linkitems_toolbar($args->{'linkitems'}); if ($args->{'sort_html'}) { if ($env{'environment.remotenavmap'} ne 'on') { - $result.=''. - ''; - } else { - $result.=''; - } - } + $result .= ''. + ''; + } else { + $result .= ''; + } + } else { + $result .= ''; + } $result .= '
'. - &Apache::loncommon::help_open_menu('Navigation Screen','Navigation_Screen',undef,'RAT').' 
".mt('Tools:')." '.&mt('Tools:').'   '.$args->{'sort_html'}.'

'. - $args->{'sort_html'}.'
   '.$args->{'sort_html'}.'

'. + $args->{'sort_html'}.'
'; } elsif ($args->{'sort_html'}) { $result.=$args->{'sort_html'}; @@ -1529,7 +1541,6 @@ END ( $res->NETWORK_FAILURE => 1, $res->NOTHING_SET => 1, $res->CORRECT => 1 ); - my @backgroundColors = ("LC_trEven", "LC_trOdd"); # Shared variables $args->{'counter'} = 0; # counts the rows @@ -1757,14 +1768,13 @@ END if (defined($anchor)) { $anchor='#'.$anchor; } my $srcHasQuestion = $src =~ /\?/; $args->{"resourceLink"} = $src. - ($srcHasQuestion?'&':'?') . + ($srcHasQuestion?'&':'?') . 'symb=' . &escape($symb).$anchor; } # Now, we've decided what parts to show. Loop through them and # show them. foreach my $part (@parts) { $rownum ++; - my $backgroundColor = $backgroundColors[$rownum % scalar(@backgroundColors)]; $result .= &Apache::loncommon::start_data_table_row(); @@ -1820,12 +1830,11 @@ END # it's quite likely this might fix other browsers, too, and # certainly won't hurt anything. if ($displayedJumpMarker) { - $result .= " -"; +"); } $result.=&Apache::loncommon::end_data_table(); @@ -1845,71 +1854,38 @@ sub add_linkitem { $$linkitems{$name}{'text'}=&mt($text); } -sub show_linkitems { - my ($linkitems)=@_; - my @linkorder = ("blank","launchnav","closenav","firsthomework", - "everything","uncompleted","changefolder","clearbubbles"); - - my $result .= (< - -
-   -
'."\n"; - - return $result; -} - sub show_linkitems_toolbar { my ($linkitems,$condition)=@_; - my @linkorder = ("blank","launchnav","closenav","firsthomework", + my @linkorder = ("launchnav","closenav","firsthomework", "everything","uncompleted","changefolder","clearbubbles"); - - my $result .=' - - '."\n'. + ''."\n"; return $result; } @@ -2380,7 +2356,7 @@ resource object. Based on the symb of the resource, get a resource object for that resource. This is one of the proper ways to get a resource object. -=item * B(map_pc): +=item * B(map_pc): Based on the map_pc of the resource, get a resource object for the given map. This is one of the proper ways to get a resource object. @@ -3535,7 +3511,11 @@ sub navHash { my $self = shift; my $param = shift; my $id = shift; - return $self->{NAV_MAP}->navhash($param . ($id?$self->{ID}:"")); + my $arg = $param . ($id?$self->{ID}:""); + if (defined($arg)) { + return $self->{NAV_MAP}->navhash($arg); + } + return; } =pod @@ -3778,6 +3758,35 @@ sub is_problem { } return 0; } +# +# The has below is the set of status that are considered 'incomplete' +# +my %incomplete_hash = +( + TRIES_LEFT() => 1, + OPEN() => 1, + ATTEMPTED() => 1 + + ); +# +# Return tru if a problem is incomplete... for now incomplete means that +# any part of the problem is incomplete. +# Note that if the resources is not a problem, 0 is returned. +# +sub is_incomplete { + my $self = shift; + if ($self->is_problem()) { + &Apache::lonnet::logthis('is problem'); + foreach my $part (@{$self->parts()}) { + &Apache::lonnet::logthis("$part status ".$self->status($part)); + if (exists($incomplete_hash{$self->status($part)})) { + return 1; + } + } + } + return 0; + +} sub is_raw_problem { my $self=shift; my $src = $self->src(); @@ -3813,7 +3822,7 @@ sub is_survey { my $self = shift(); my $part = shift(); my $type = $self->parmval('type',$part); - if ($type eq 'survey') { + if (($type eq 'survey') || ($type eq 'surveycred')) { return 1; } if ($self->src() =~ /\.(survey)$/) { @@ -3821,6 +3830,15 @@ sub is_survey { } return 0; } +sub is_anonsurvey { + my $self = shift(); + my $part = shift(); + my $type = $self->parmval('type',$part); + if (($type eq 'anonsurvey') || ($type eq 'anonsurveycred')) { + return 1; + } + return 0; +} sub is_task { my $self=shift; my $src = $self->src(); @@ -3874,6 +3892,12 @@ resource of the map. Returns a string with the type of the map in it. +=item *B: + +Returns a string with a comma-separated ordered list of map_pc IDs +for the hierarchy of maps containing a map, with the top level +map first, then descending to deeper levels, with the enclosing map last. + =back =cut @@ -3904,6 +3928,12 @@ sub map_type { my $pc = $self->map_pc(); return $self->navHash("map_type_$pc", 0); } +sub map_hierarchy { + my $self = shift; + my $pc = $self->map_pc(); + return $self->navHash("map_hierarchy_$pc", 0); +} + ##### # Property queries @@ -4659,6 +4689,10 @@ Information not available due to network Attempted, and not yet graded. +=item * B: + +Attempted, and credit received for attempt (survey and anonymous survey only). + =back =cut @@ -4670,6 +4704,7 @@ sub CORRECT { return 13; } sub CORRECT_BY_OVERRIDE { return 14; } sub EXCUSED { return 15; } sub ATTEMPTED { return 16; } +sub CREDIT_ATTEMPTED { return 17; } sub getCompletionStatus { my $self = shift; @@ -4688,6 +4723,13 @@ sub getCompletionStatus { if ($status eq 'incorrect_by_override') {return $self->INCORRECT_BY_OVERRIDE; } if ($status eq 'excused') {return $self->EXCUSED; } if ($status eq 'ungraded_attempted') {return $self->ATTEMPTED; } + if ($status eq 'credit_attempted') { + if ($self->is_anonsurvey($part) || $self->is_survey($part)) { + return $self->CREDIT_ATTEMPTED; + } else { + return $self->ATTEMPTED; + } + } return $self->NOT_ATTEMPTED; } @@ -4777,6 +4819,10 @@ The item is open and not yet tried. The problem has been attempted. +=item * B: + +The problem has been attempted, and credit given for the attempt (survey and anonymous survey only). + =item * B: An answer has been submitted, but the student should not see it. @@ -4850,6 +4896,10 @@ sub status { return ATTEMPTED; } + if ($completionStatus == CREDIT_ATTEMPTED) { + return CREDIT_ATTEMPTED; + } + # If it's EXCUSED, then return that no matter what if ($completionStatus == EXCUSED) { return EXCUSED; @@ -5042,6 +5092,7 @@ my %compositeToSimple = INCORRECT() => INCORRECT, OPEN() => OPEN, ATTEMPTED() => ATTEMPTED, + CREDIT_ATTEMPTED() => CORRECT, ANSWER_SUBMITTED() => ATTEMPTED ); @@ -5115,8 +5166,9 @@ sub completable { # "If any of the parts are open, or have tries left (implies open), # and it is not "attempted" (manually graded problem), it is # not "complete" - if ($self->getCompletionStatus($part) == ATTEMPTED() || - $status == ANSWER_SUBMITTED() ) { + if ($self->getCompletionStatus($part) == ATTEMPTED() || + $self->getCompletionStatus($part) == CREDIT_ATTEMPTED() || + $status == ANSWER_SUBMITTED() ) { # did this part already, as well as we can next; }