--- loncom/interface/lonnavmaps.pm 2012/07/09 18:43:03 1.444.2.8 +++ loncom/interface/lonnavmaps.pm 2010/03/16 19:55:49 1.445 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.444.2.8 2012/07/09 18:43:03 raeburn Exp $ +# $Id: lonnavmaps.pm,v 1.445 2010/03/16 19:55:49 droeschl Exp $ # # Copyright Michigan State University Board of Trustees @@ -509,7 +509,7 @@ my %statusIconMap = my %iconAltTags = #texthash does not work here ( 'navmap.correct.gif' => 'Correct', 'navmap.wrong.gif' => 'Incorrect', - 'navmap.open.gif' => 'Is Open', + 'navmap.open.gif' => 'Open', 'navmap.partial.gif' => 'Partially Correct', 'navmap.ellipsis.gif' => 'Attempted', ); @@ -527,7 +527,6 @@ my %colormap = $resObj->INCORRECT => '', $resObj->OPEN => '', $resObj->NOTHING_SET => '', - $resObj->CREDIT_ATTEMPTED => '', $resObj->ATTEMPTED => '', $resObj->ANSWER_SUBMITTED => '', $resObj->PARTIALLY_CORRECT => '#006600' @@ -539,35 +538,6 @@ my $hurryUpColor = "#FF0000"; my $future_slots_checked = 0; my $future_slots = 0; -sub close { - if ($env{'environment.remotenavmap'} ne 'on') { return ''; } - return(< -window.status='Accessing Nav Control'; -menu=window.open("/adm/rat/empty.html","loncapanav", - "height=600,width=400,scrollbars=1"); -window.status='Closing Nav Control'; -menu.close(); -window.status='Done.'; - -ENDCLOSE -} - -sub update { - if ($env{'environment.remotenavmap'} ne 'on') { return ''; } - if (!$env{'request.course.id'}) { return ''; } - if ($ENV{'REQUEST_URI'}=~m|^/adm/navmaps|) { return ''; } - return(< - -ENDUPDATE -} - - sub addToFilter { my $hashIn = shift; my $addition = shift; @@ -641,7 +611,7 @@ sub getDescription { return &mt("Not currently assigned."); } if ($status == $res->OPEN_LATER) { - return &mt("Open [_1]",&timeToHumanString($open,'start')); + return &mt("Open ") .timeToHumanString($open,'start'); } if ($res->simpleStatus($part) == $res->OPEN) { unless (&Apache::lonnet::allowed('mgr',$env{'request.course.id'})) { @@ -675,22 +645,22 @@ sub getDescription { if ($status == $res->OPEN) { if ($due) { if ($res->is_practice()) { - return &mt("Closes [_1]",&timeToHumanString($due,'start')); + return &mt("Closes ")." " .timeToHumanString($due,'start'); } else { - return &mt("Due [_1]",&timeToHumanString($due,'end')); + return &mt("Due")." " .timeToHumanString($due,'end'); } } else { return &mt("Open, no due date"); } } if ($status == $res->PAST_DUE_ANSWER_LATER) { - return &mt("Answer open [_1]",&timeToHumanString($answer,'start')); + return &mt("Answer open")." " .timeToHumanString($answer,'start'); } if ($status == $res->PAST_DUE_NO_ANSWER) { if ($res->is_practice()) { - return &mt("Closed [_1]",&timeToHumanString($due,'start')); + return &mt("Closed")." " . timeToHumanString($due,'start'); } else { - return &mt("Was due [_1]",&timeToHumanString($due,'end')); + return &mt("Was due")." " . timeToHumanString($due,'end'); } } if (($status == $res->ANSWER_OPEN || $status == $res->PARTIALLY_CORRECT) @@ -707,11 +677,6 @@ sub getDescription { 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); my $maxtries = $res->maxtries($part); @@ -723,7 +688,7 @@ sub getDescription { } } if ($due) { - return &mt("Due [_1]",&timeToHumanString($due,'end')) . + return &mt("Due")." " . timeToHumanString($due,'end') . " $triesString"; } else { return &mt("No due date")." $triesString"; @@ -808,31 +773,14 @@ sub timeToHumanString { # Less than an hour if ( $delta < $hour ) { - # If so, use minutes; or minutes, seconds (if format requires) + # If so, use minutes my $minutes = floor($delta / 60); - if (($format ne '') && ($format =~ /\%(T|S)/)) { - my $display; - if ($minutes == 1) { - $display = "${prefix}1 minute"; - } else { - $display = "$prefix$minutes minutes"; - } - my $seconds = $delta % $minute; - if ($seconds == 0) { - $display .= $tense; - } elsif ($seconds == 1) { - $display .= ", 1 second$tense"; - } else { - $display .= ", $seconds seconds$tense"; - } - return $display; - } if ($minutes == 1) { return "${prefix}1 minute$tense"; } return "$prefix$minutes minutes$tense"; } # Is it less than 24 hours away? If so, - # display hours + minutes, (and + seconds, if format specified it) + # display hours + minutes if ( $delta < $hour * 24) { my $hours = floor($delta / $hour); my $minutes = floor(($delta % $hour) / $minute); @@ -847,30 +795,15 @@ sub timeToHumanString { if ($minutes == 0) { $minuteString = ""; } - if (($format ne '') && ($format =~ /\%(T|S)/)) { - my $display = "$prefix$hourString$minuteString"; - my $seconds = $delta-(($hours * $hour)+($minutes * $minute)); - if ($seconds == 0) { - $display .= $tense; - } elsif ($seconds == 1) { - $display .= ", 1 second$tense"; - } else { - $display .= ", $seconds seconds$tense"; - } - return $display; - } return "$prefix$hourString$minuteString$tense"; } - # Date/time is more than 24 hours away - my $dt = DateTime->from_epoch(epoch => $time) ->set_time_zone(&Apache::lonlocal::gettimezone()); - # If there's a caller supplied format, use it, unless it only displays - # H:M:S or H:M. + # If there's a caller supplied format, use it. - if (($format ne '') && ($format ne '%T') && ($format ne '%R')) { + if ($format ne '') { my $timeStr = $dt->strftime($format); return $timeStr.' ('.$dt->time_zone_short_name().')'; } @@ -1006,10 +939,10 @@ sub render_resource { } if ($resource->randomout()) { - $nonLinkedText .= ' ('.&mt('hidden').') '; + $nonLinkedText .= ' ('.&mt('hidden').') '; } if (!$resource->condval()) { - $nonLinkedText .= ' ('.&mt('conditionally hidden').') '; + $nonLinkedText .= ' ('.&mt('conditionally hidden').') '; } if (($resource->is_practice()) && ($resource->is_raw_problem())) { $nonLinkedText .=' '.&mt('not graded').''; @@ -1053,12 +986,8 @@ sub render_resource { $nonLinkedText .= ' ('.&mt('[_1] parts', $resource->countParts()).')'; } - my $target; - if ($env{'environment.remotenavmap'} eq 'on') { - $target=' target="loncapaclient" '; - } if (!$params->{'resource_nolink'} && !$resource->is_sequence() && !$resource->is_empty_sequence) { - $result .= "$curMarkerBegin$title$partLabel$curMarkerEnd$nonLinkedText"; + $result .= "$curMarkerBegin$title$partLabel$curMarkerEnd$nonLinkedText"; } else { $result .= "$curMarkerBegin$linkopen$title$partLabel$curMarkerEnd$nonLinkedText"; } @@ -1071,11 +1000,7 @@ sub render_communication_status { my $discussionHTML = ""; my $feedbackHTML = ""; my $errorHTML = ""; my $link = $params->{"resourceLink"}; - my $target; - if ($env{'environment.remotenavmap'} eq 'on') { - $target=' target="loncapaclient" '; - } - my $linkopen = ""; + my $linkopen = ""; my $linkclose = ""; my $location=&Apache::loncommon::lonhttpdurl("/adm/lonMisc"); if ($resource->hasDiscussion()) { @@ -1088,7 +1013,7 @@ sub render_communication_status { my $feedback = $resource->getFeedback(); foreach my $msgid (split(/\,/, $feedback)) { if ($msgid) { - $feedbackHTML .= ' ' . ''.&mt('New E-mail').''; } @@ -1102,7 +1027,7 @@ sub render_communication_status { last if ($errorcount>=10); # Only output 10 bombs maximum if ($msgid) { $errorcount++; - $errorHTML .= ' ' . ''.&mt('New Error').''; } @@ -1122,11 +1047,7 @@ sub render_quick_status { $params->{'multipart'} && $part eq "0"; my $link = $params->{"resourceLink"}; - my $target; - if ($env{'environment.remotenavmap'} eq 'on') { - $target=' target="loncapaclient" '; - } - my $linkopen = ""; + my $linkopen = ""; my $linkclose = ""; $result .= ''; @@ -1164,7 +1085,7 @@ sub render_long_status { } if ($resource->kind() eq "res" && - $resource->is_raw_problem() && + ($resource->is_problem() || $resource->is_practice()) && !$firstDisplayed) { if ($color) {$result .= ""; } $result .= getDescription($resource, $part); @@ -1479,22 +1400,19 @@ 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"; } @@ -1510,9 +1428,6 @@ sub render { END - if ($env{'form.register'}) { - $result .= ''; - } if ($args->{'sort'} eq 'discussion') { my $totdisc = 0; my $haveDisc = ''; @@ -1534,21 +1449,16 @@ END $result.=''; } + if ($args->{'caller'} eq 'navmapsdisplay') { $result .= ''. - ''. - &show_linkitems_toolbar($args->{'linkitems'}); + &Apache::loncommon::help_open_menu('Navigation Screen','Navigation_Screen',undef,'RAT').''; + $result .= ''; + $result.=""; + $result.=&show_linkitems_toolbar($args->{'linkitems'}); if ($args->{'sort_html'}) { - if ($env{'environment.remotenavmap'} ne 'on') { - $result .= ''. - ''; - } else { - $result .= ''; - } - } else { - $result .= ''; + $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'}.'
'; } elsif ($args->{'sort_html'}) { @@ -1800,7 +1710,7 @@ 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 @@ -1862,11 +1772,12 @@ END # it's quite likely this might fix other browsers, too, and # certainly won't hurt anything. if ($displayedJumpMarker) { - $result .= &Apache::lonhtmlcommon::scripttag(" + $result .= " +"; } $result.=&Apache::loncommon::end_data_table(); @@ -1886,38 +1797,71 @@ 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 = ("launchnav","closenav","firsthomework", + my @linkorder = ("blank","launchnav","closenav","firsthomework", "everything","uncompleted","changefolder","clearbubbles"); - my $result .=''."\n". - ''."\n". - '
    '; - foreach my $link (@linkorder) { - my $link_id = 'LC_content_toolbar_'.$link; - if (defined($linkitems->{$link})) { - if ($linkitems->{$link}{'text'} ne '') { - $linkitems->{$link}{'cmd'}=~s/"/'/g; - if ($linkitems->{$link}{'cmd'}) { - if ($link eq 'changefolder') { - if ($condition) { - $link_id='LC_content_toolbar_changefolder_toggled'; - } else { - $link_id='LC_content_toolbar_changefolder'; - } - } - $result .= '
  • '. - '
  • '."\n"; - } - } - } + + my $result .=' + + '."\n
      "; + foreach my $link (@linkorder) { + my $link_id = "LC_content_toolbar_".$link; + if (defined($linkitems->{$link})) { + if ($linkitems->{$link}{'text'} ne '') { + $linkitems->{$link}{'cmd'}=~s/"/'/g; + if($linkitems->{$link}{'cmd'}){ + if($link eq 'changefolder'){ + if($condition){$link_id='LC_content_toolbar_changefolder_toggled'} + else{$link_id='LC_content_toolbar_changefolder'} + } + $result .= '
    • '."\n"; + } + + } + } } - $result .= '
    '. - '
    '."\n"; + $result .= '
'; + $result .= '
'."\n"; + return $result; } @@ -2388,7 +2332,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. @@ -3526,8 +3470,6 @@ sub new { $self->{NAV_MAP}->{RESOURCE_CACHE}->{$self->{ID}} = $self; $self->{RESOURCE_ERROR} = 0; - $self->{DUEDATE_CACHE} = undef; - # A hash that can be used by two-pass algorithms to store data # about this resource in. Not used by the resource object # directly. @@ -3926,12 +3868,6 @@ 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 @@ -3962,12 +3898,6 @@ 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 @@ -4105,9 +4035,6 @@ sub checkedin { # this should work exactly like the copy in lonhomework.pm sub duedate { (my $self, my $part) = @_; - if (defined ($self->{DUEDATE_CACHE}->{$part})) { - return $self->{DUEDATE_CACHE}->{$part}; - } my $date; my @interval=$self->parmval("interval", $part); my $due_date=$self->parmval("duedate", $part); @@ -4124,7 +4051,6 @@ sub duedate { } else { $date = $due_date; } - $self->{DUEDATE_CACHE}->{$part} = $date; return $date; } sub handgrade { @@ -4727,10 +4653,6 @@ 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 @@ -4742,7 +4664,6 @@ 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; @@ -4761,13 +4682,6 @@ 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; } @@ -4857,10 +4771,6 @@ 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. @@ -4934,10 +4844,6 @@ 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; @@ -5040,7 +4946,7 @@ sub check_for_slot { my $taskstatus = $self->taskstatus(); $is_correct = (($taskstatus eq 'pass') || ($self->solved() =~ /^correct_/)); - $got_grade = ($taskstatus =~ /^(?:pass|fail)$/); + $got_grade = ($self->solved() =~ /^(?:pass|fail)$/); } else { $got_grade = 1; $is_correct = ($self->solved() =~ /^correct_/); @@ -5130,7 +5036,6 @@ my %compositeToSimple = INCORRECT() => INCORRECT, OPEN() => OPEN, ATTEMPTED() => ATTEMPTED, - CREDIT_ATTEMPTED() => CORRECT, ANSWER_SUBMITTED() => ATTEMPTED ); @@ -5204,9 +5109,8 @@ 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() || - $self->getCompletionStatus($part) == CREDIT_ATTEMPTED() || - $status == ANSWER_SUBMITTED() ) { + if ($self->getCompletionStatus($part) == ATTEMPTED() || + $status == ANSWER_SUBMITTED() ) { # did this part already, as well as we can next; }