--- loncom/interface/lonnavmaps.pm 2009/09/23 14:30:45 1.423.4.2 +++ loncom/interface/lonnavmaps.pm 2009/03/16 15:25:40 1.431 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.423.4.2 2009/09/23 14:30:45 gci Exp $ +# $Id: lonnavmaps.pm,v 1.431 2009/03/16 15:25:40 schulted Exp $ # # Copyright Michigan State University Board of Trustees # @@ -31,7 +31,7 @@ =head1 NAME -Apache::lonnavmaps - Subroutines to handle and render the navigation +Apache::lonnavmaps.pm =head1 SYNOPSIS @@ -530,9 +530,6 @@ my %colormap = # is not yet done and due in less than 24 hours my $hurryUpColor = "#FF0000"; -my $future_slots_checked = 0; -my $future_slots = 0; - sub close { if ($env{'environment.remotenavmap'} ne 'on') { return ''; } return(<OPEN_LATER) { return &mt("Open ") .timeToHumanString($open,'start'); } - if ($res->simpleStatus($part) == $res->OPEN) { - unless (&Apache::lonnet::allowed('mgr',$env{'request.course.id'})) { - my ($slot_status,$slot_time,$slot_name)=$res->check_for_slot($part); - if ($slot_status == $res->UNKNOWN) { - return &mt('Reservation status unknown'); - } elsif ($slot_status == $res->RESERVED) { - return &mt('Reserved - ends [_1]', - timeToHumanString($slot_time,'end')); - } elsif ($slot_status == $res->RESERVED_LOCATION) { - return &mt('Reserved - specific location(s) - ends [_1]', - timeToHumanString($slot_time,'end')); - } elsif ($slot_status == $res->RESERVED_LATER) { - return &mt('Reserved - next open [_1]', - timeToHumanString($slot_time,'start')); - } elsif ($slot_status == $res->RESERVABLE) { - return &mt('Reservable ending [_1]', - timeToHumanString($slot_time,'end')); - } elsif ($slot_status == $res->RESERVABLE_LATER) { - return &mt('Reservable starting [_1]', - timeToHumanString($slot_time,'start')); - } elsif ($slot_status == $res->NOT_IN_A_SLOT) { - return &mt('Reserve a time/place to work'); - } elsif ($slot_status == $res->NOTRESERVABLE) { - return &mt('Reservation not available'); - } elsif ($slot_status == $res->WAITING_FOR_GRADE) { - return &mt('Submission in grading queue'); - } - } - } if ($status == $res->OPEN) { if ($due) { if ($res->is_practice()) { @@ -695,11 +663,7 @@ sub getDescription { return &mt("Excused by instructor"); } if ($status == $res->ATTEMPTED) { - if ($res->src() eq '/res/gci/gci/internal/submission.problem') { - return &mt('Question(s) submitted for review'); - } else { - return &mt("Answer submitted, not yet graded"); - } + return &mt("Answer submitted, not yet graded"); } if ($status == $res->TRIES_LEFT) { my $tries = $res->tries($part); @@ -719,11 +683,7 @@ sub getDescription { } } if ($status == $res->ANSWER_SUBMITTED) { - if ($res->src() eq '/res/gci/gci/internal/submission.problem') { - return &mt('Question(s) submitted for review'); - } else { - return &mt('Answer submitted'); - } + return &mt('Answer submitted'); } } @@ -905,35 +865,32 @@ sub render_resource { my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons"); # If this is a new branch, label it so if ($params->{'isNewBranch'}) { - $newBranchText = ''.
-                         &mt('Branch').''; + $newBranchText = ".mt('Branch')."; } # links to open and close the folder - - my $linkopen = ""; - - + my $whitespace = $location.'/whitespace_21.gif'; + my $linkopen = "".""; my $linkclose = ""; # Default icon: unknown page - my $icon = ""; + my $icon = ""; if ($resource->is_problem()) { if ($part eq '0' || $params->{'condensed'}) { - $icon = ''.&mt('Task');
 	    } else {
 		$icon .= 'problem.gif'; + $icon .='" />'; } else { $icon = $params->{'indentString'}; } } else { - $icon = "  "; + $icon = ""; } # Display the correct map icon to open or shut map @@ -943,15 +900,15 @@ sub render_resource { if ($it->{CONDITION}) { $nowOpen = !$nowOpen; } - + my $folderType = $resource->is_sequence() ? 'folder' : 'page'; my $title=$resource->title; - $title=~s/\"/\"/g; + $title=~s/\"/\&qout;/g; if (!$params->{'resource_no_folder_link'}) { $icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.gif'; - $icon = "\""."; - + $icon = "" + ."\"""; $linkopen = "{'url'} . '?' . $params->{'queryString'} . '&filter='; $linkopen .= ($nowOpen xor $it->{CONDITION}) ? @@ -966,10 +923,8 @@ sub render_resource { } else { # Don't allow users to manipulate folder - $icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . - '.nomanip.gif'; - $icon = "\""."; + $icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.gif'; + $icon = ""."\"".($nowOpen"; $linkopen = ""; $linkclose = ""; @@ -985,10 +940,11 @@ sub render_resource { if (($resource->is_practice()) && ($resource->is_raw_problem())) { $nonLinkedText .=' '.&mt('not graded').''; } - - # We're done preparing and finally ready to start the rendering - my $result = ""; + # We're done preparing and finally ready to start the rendering + my $result = ''; + my $newfolderType = $resource->is_sequence() ? 'folder' : 'page'; + my $indentLevel = $params->{'indentLevel'}; if ($newBranchText) { $indentLevel--; } @@ -998,7 +954,6 @@ sub render_resource { } # Decide what to display - $result .= "$newBranchText$linkopen$icon$linkclose"; my $curMarkerBegin = ''; @@ -1007,9 +962,9 @@ sub render_resource { # Is this the current resource? if (!$params->{'displayedHereMarker'} && $resource->symb() eq $params->{'here'} ) { - $curMarkerBegin = '>'; - $curMarkerEnd = '<'; - $params->{'displayedHereMarker'} = 1; + $curMarkerBegin = ''; + $curMarkerEnd = ''; + $params->{'displayedHereMarker'} = 1; } if ($resource->is_problem() && $part ne '0' && @@ -1029,9 +984,9 @@ sub render_resource { $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$title$partLabel$curMarkerEnd $nonLinkedText"; + $result .= "$curMarkerBegin$linkopen$title$partLabel$curMarkerEnd$nonLinkedText"; } return $result; @@ -1051,7 +1006,7 @@ sub render_communication_status { my $location=&Apache::loncommon::lonhttpdurl("/adm/lonMisc"); if ($resource->hasDiscussion()) { $discussionHTML = $linkopen . - ''.&mt('New Discussion').'' . + ''.&mt('New Discussion').'' . $linkclose; } @@ -1061,8 +1016,7 @@ sub render_communication_status { if ($msgid) { $feedbackHTML .= ' ' - . ''.&mt('New E-mail').''; + . ''.&mt('New E-mail').''; } } } @@ -1076,8 +1030,7 @@ sub render_communication_status { $errorcount++; $errorHTML .= ' ' - . ''.&mt('New Error').''; + . ''.&mt('New Error').''; } } } @@ -1085,8 +1038,7 @@ sub render_communication_status { if ($params->{'multipart'} && $part != '0') { $discussionHTML = $feedbackHTML = $errorHTML = ''; } - - return "$discussionHTML$feedbackHTML$errorHTML "; + return "$discussionHTML$feedbackHTML$errorHTML "; } sub render_quick_status { @@ -1102,28 +1054,28 @@ sub render_quick_status { } my $linkopen = ""; my $linkclose = ""; - + + $result .= ''; if ($resource->is_problem() && !$firstDisplayed) { - my $icon = $statusIconMap{$resource->simpleStatus($part)}; my $alt = $iconAltTags{$icon}; if ($icon) { my $location= &Apache::loncommon::lonhttpdurl("/adm/lonIcons/$icon"); - $result .= "$linkopen$alt$linkclose\n"; + $result .= "$linkopen$alt$linkclose"; } else { - $result .= " \n"; + $result .= " "; } } else { # not problem, no icon - $result .= " \n"; + $result .= " "; } - + $result .= "\n"; return $result; } sub render_long_status { my ($resource, $part, $params) = @_; - my $result = "\n"; + my $result = ''; my $firstDisplayed = !$params->{'condensed'} && $params->{'multipart'} && $part eq "0"; @@ -1427,7 +1379,7 @@ sub render { my $printKey = $args->{'printKey'}; my $printCloseAll = $args->{'printCloseAll'}; if (!defined($printCloseAll)) { $printCloseAll = 1; } - + # Print key? if ($printKey) { $result .= ''; @@ -1435,15 +1387,15 @@ sub render { my $location=&Apache::loncommon::lonhttpdurl("/adm/lonMisc"); if ($navmap->{LAST_CHECK}) { $result .= - ' '.&mt('New discussion since').' '. + ' '.&mt('New discussion since').' '. strftime("%A, %b %e at %I:%M %P", localtime($navmap->{LAST_CHECK})). ''; } else { $result .= ''; } @@ -1502,6 +1454,7 @@ END $result.=''; } + if ($args->{'caller'} eq 'navmapsdisplay') { $result .= '
  '. - ' '.&mt('New message (click to open)').'

'. + ' '.&mt('New message (click to open)').'

'. '

  '. - ' '.&mt('Discussions').''. - '   '.&mt('New message (click to open)'). + ' '.&mt('Discussions').''. + '   '.&mt('New message (click to open)'). '
'; @@ -1510,7 +1463,8 @@ END } else { $result .= ''; } - $result.=&show_linkitems($args->{'linkitems'}); + $result.=""; + $result.=&show_linkitems_toolbar($args->{'linkitems'}); if ($args->{'sort_html'}) { if ($env{'environment.remotenavmap'} ne 'on') { $result.=''. @@ -1525,31 +1479,34 @@ END $result.=$args->{'sort_html'}; } - $result .= "
\n"; + #$result .= "
\n"; if ($r) { $r->print($result); $r->rflush(); $result = ""; } # End parameter setting - + + $result .= "
\n"; + # Data - $result .= '
'. &Apache::loncommon::help_open_menu('Navigation Screen','Navigation_Screen',undef,'RAT').'
".mt('Tools:')."   
' ."\n"; + $result.=&Apache::loncommon::start_data_table("LC_tableOfContent"); + my $res = "Apache::lonnavmaps::resource"; my %condenseStatuses = ( $res->NETWORK_FAILURE => 1, $res->NOTHING_SET => 1, $res->CORRECT => 1 ); - my @backgroundColors = ("#FFFFFF", "#F6F6F6"); + my @backgroundColors = ("LC_trEven", "LC_trOdd"); # Shared variables $args->{'counter'} = 0; # counts the rows $args->{'indentLevel'} = 0; $args->{'isNewBranch'} = 0; - $args->{'condensed'} = 0; - my $location= - &Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace1.gif"); - $args->{'indentString'} = setDefault($args->{'indentString'}, "  "); + $args->{'condensed'} = 0; + + my $location = &Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace_21.gif"); + $args->{'indentString'} = setDefault($args->{'indentString'}, ""); $args->{'displayedHereMarker'} = 0; # If we're suppressing empty sequences, look for them here. Use DFS for speed, @@ -1777,7 +1734,7 @@ END $rownum ++; my $backgroundColor = $backgroundColors[$rownum % scalar(@backgroundColors)]; - $result .= " \n"; + $result .= &Apache::loncommon::start_data_table_row(); # Set up some data about the parts that the cols might want my $filter = $it->{FILTER}; @@ -1803,7 +1760,7 @@ END } $result .= $colHTML . "\n"; } - $result .= " \n"; + $result .= &Apache::loncommon::end_data_table_row(); $args->{'isNewBranch'} = 0; } @@ -1839,8 +1796,8 @@ if (location.href.indexOf('#curloc')==-1 "; } - $result .= "
"; - + $result.=&Apache::loncommon::end_data_table(); + if ($r) { $r->print($result); $result = ""; @@ -1890,6 +1847,41 @@ ENDBLOCK return $result; } +sub show_linkitems_toolbar { + my ($linkitems,$condition)=@_; + my @linkorder = ("blank","launchnav","closenav","firsthomework", + "everything","uncompleted","changefolder","clearbubbles"); + + my $result .=' + + '."\n'; + $result .= ' '."\n"; + + return $result; +} + + 1; @@ -3783,7 +3775,7 @@ sub map_contains_problem { sub is_sequence { my $self=shift; return $self->navHash("is_map_", 1) && - $self->navHash("map_type_" . $self->map_pc()) eq 'sequence'; + $self->navHash("map_type_" . $self->map_pc()) eq 'sequence'; } sub is_survey { my $self = shift(); @@ -3985,35 +3977,6 @@ sub awarded { if (!defined($part)) { $part = '0'; } return $self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$part.'.awarded'}; } -sub taskversion { - my $self = shift; my $part = shift; - $self->{NAV_MAP}->get_user_data(); - if (!defined($part)) { $part = '0'; } - return $self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$part.'.version'}; -} -sub taskstatus { - my $self = shift; my $part = shift; - $self->{NAV_MAP}->get_user_data(); - if (!defined($part)) { $part = '0'; } - return $self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$self->taskversion($part).'.'.$part.'.status'}; -} -sub solved { - my $self = shift; my $part = shift; - $self->{NAV_MAP}->get_user_data(); - if (!defined($part)) { $part = '0'; } - return $self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$part.'.solved'}; -} -sub checkedin { - my $self = shift; my $part = shift; - $self->{NAV_MAP}->get_user_data(); - if (!defined($part)) { $part = '0'; } - if ($self->is_task()) { - my $version = $self->taskversion($part); - return ($self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$version .'.'.$part.'.checkedin'},$self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$version .'.'.$part.'.checkedin.slot'}); - } else { - return ($self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$part.'.checkedin'},$self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$part.'.checkedin.slot'}); - } -} # this should work exactly like the copy in lonhomework.pm sub duedate { (my $self, my $part) = @_; @@ -4109,14 +4072,6 @@ sub part_display { } return $display; } -sub slot_control { - my $self=shift(); my $part = shift(); - if (!defined($part)) { $part = '0'; } - my $useslots = $self->parmval("useslots", $part); - my $availablestudent = $self->parmval("availablestudent", $part); - my $available = $self->parmval("available", $part); - return ($useslots,$availablestudent,$available); -} # Multiple things need this sub getReturnHash { @@ -4765,17 +4720,6 @@ sub TRIES_LEFT { return 20; } sub ANSWER_SUBMITTED { return 21; } sub PARTIALLY_CORRECT{ return 22; } -sub RESERVED_LATER { return 30; } -sub RESERVED { return 31; } -sub RESERVED_LOCATION { return 32; } -sub RESERVABLE { return 33; } -sub RESERVABLE_LATER { return 34; } -sub NOTRESERVABLE { return 35; } -sub NOT_IN_A_SLOT { return 36; } -sub NEEDS_CHECKIN { return 37; } -sub WAITING_FOR_GRADE { return 38; } -sub UNKNOWN { return 39; } - sub status { my $self = shift; my $part = shift; @@ -4867,108 +4811,6 @@ sub status { return OPEN; } -sub check_for_slot { - my $self = shift; - my $part = shift; - my ($use_slots,$available,$availablestudent) = $self->slot_control($part); - if (($use_slots ne '') && ($use_slots !~ /^\s*no\s*$/i)) { - my @slots = (split(/:/,$availablestudent),split(/:/,$available)); - my $cid=$env{'request.course.id'}; - my $cdom=$env{'course.'.$cid.'.domain'}; - my $cnum=$env{'course.'.$cid.'.num'}; - my $now = time; - if (@slots > 0) { - my %slots=&Apache::lonnet::get('slots',[@slots],$cdom,$cnum); - if (&Apache::lonnet::error(%slots)) { - return (UNKNOWN); - } - my @sorted_slots = &Apache::loncommon::sorted_slots(\@slots,\%slots); - my ($checkedin,$checkedinslot); - foreach my $slot_name (@sorted_slots) { - next if (!defined($slots{$slot_name}) || - !ref($slots{$slot_name})); - my $end = $slots{$slot_name}->{'endtime'}; - my $start = $slots{$slot_name}->{'starttime'}; - my $ip = $slots{$slot_name}->{'ip'}; - if ($self->simpleStatus() == OPEN) { - my $startreserve = $slots{$slot_name}->{'startreserve'}; - my @proctors; - if ($slots{$slot_name}->{'proctor'} ne '') { - @proctors = split(',',$slots{$slot_name}->{'proctor'}); - } - if ($end > $now) { - ($checkedin,$checkedinslot) = $self->checkedin(); - if ($startreserve < $now) { - if ($start > $now) { - return (RESERVED_LATER,$start,$slot_name); - } else { - if ($ip ne '') { - if (!&Apache::loncommon::check_ip_acc($ip)) { - return (RESERVED_LOCATION,$ip,$slot_name); - } - } - if (@proctors > 0) { - unless ((grep(/^\Q$checkedin\E/,@proctors)) && - ($checkedinslot eq $slot_name)) { - return (NEEDS_CHECKIN,undef,$slot_name); - } - } - return (RESERVED,$end,$slot_name); - } - } else { - if ($start > $now) { - return (RESERVABLE,$startreserve,$slot_name); - } - } - } - } - } - my ($is_correct,$got_grade); - if ($self->is_task()) { - my $taskstatus = $self->taskstatus(); - $is_correct = (($taskstatus eq 'pass') || - ($self->solved() =~ /^correct_/)); - $got_grade = ($self->solved() =~ /^(?:pass|fail)$/); - } else { - $got_grade = 1; - $is_correct = ($self->solved() =~ /^correct_/); - } - ($checkedin,$checkedinslot) = $self->checkedin(); - if ($checkedin) { - if (!$got_grade) { - return (WAITING_FOR_GRADE); - } elsif ($is_correct) { - return (CORRECT); - } - } - return(NOT_IN_A_SLOT); - } else { - if (!$future_slots_checked) { - $future_slots = &get_future_slots($cdom,$cnum,$now); - $future_slots_checked = 1; - } - if ($future_slots) { - return(NOT_IN_A_SLOT); - } - return(NOTRESERVABLE); - } - } - return; -} - -sub get_future_slots { - my ($cdom,$cnum,$now) = @_; - my %slots=&Apache::lonnet::dump('slots',$cdom,$cnum); - my $future_slots = 0; - foreach my $slot (keys(%slots)) { - if (($slots{$slot}->{'starttime'} > $now) && - ($slots{$slot}->{'endtime'} > $now)) { - $future_slots ++; - } - } - return $future_slots; -} - sub CLOSED { return 23; } sub ERROR { return 24; }