--- loncom/interface/lonnavmaps.pm 2006/03/16 20:48:30 1.371 +++ loncom/interface/lonnavmaps.pm 2006/04/29 17:57:29 1.379 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.371 2006/03/16 20:48:30 albertel Exp $ +# $Id: lonnavmaps.pm,v 1.379 2006/04/29 17:57:29 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -203,10 +203,13 @@ MENU ENDSUBM - $r->print(&Apache::lonxml::xmlbegin(). - &Apache::loncommon::head(undef,$js). - ''. - &Apache::loncommon::end_page(undef,$js)); + $r->print(&Apache::loncommon::start_page(undef,$js, + {'only_body' => 1, + 'bgcolor' => '#FFFFFF', + 'add_entries' => + {'onload' => + "submitthis()"}}). + &Apache::loncommon::end_page()); return OK; } @@ -243,8 +246,6 @@ MENU &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['register','sort','showOnlyHomework','postsymb']); # ----------------------------------------------------- Force menu registration - my $addentries=''; - my $more_unload; my $body_only=''; my $js; if ($env{'environment.remotenavmap'} eq 'on') { @@ -253,33 +254,23 @@ MENU this.document.location="/adm/navmaps?collapseExternal"; } '; -# FIXME need to be smarter to only catch window close events -# $more_unload="collapse()" $body_only=1; } - if ($env{'form.register'}) { - $addentries=' onLoad="'.&Apache::lonmenu::loadevents(). - '" onUnload="'.&Apache::lonmenu::unloadevents().';'. - $more_unload.'"'; - $r->print(&Apache::lonmenu::registerurl(1)); - } else { - $addentries=' onUnload="'.$more_unload.'"'; - } # Header - $r->print(&Apache::lonxml::xmlbegin(). - &Apache::loncommon::head('Navigate Course Contents',$js). - &Apache::loncommon::bodytag('Navigate Course Contents','', - $addentries,$body_only,'', - $env{'form.register'})); - $r->print(''); + $r->print(&Apache::loncommon::start_page('Navigate Course Contents',$js, + {'only_body' => $body_only, + 'force_register' => + $env{'form.register'},})); + $r->print(''); $r->rflush(); # Check that it's defined if (!($navmap->courseMapDefined())) { $r->print(&Apache::loncommon::help_open_menu('','Navigation Screen','Navigation_Screen','',undef,'RAT')); - $r->print('Coursemap undefined.' . + $r->print(''.&mt('Coursemap undefined.'). + '' . &Apache::loncommon::end_page()); return OK; } @@ -327,32 +318,38 @@ MENU "Close navigation window"); } - my $jumpToFirstHomework = 0; + # Check to see if the student is jumping to next open, do-able problem if ($ENV{QUERY_STRING} =~ /^jumpToFirstHomework/) { - $jumpToFirstHomework = 1; # Find the next homework problem that they can do. my $iterator = $navmap->getIterator(undef, undef, undef, 1); my $curRes; my $foundDoableProblem = 0; - my $problemRes; + my $minimumduedate; - while (($curRes = $iterator->next()) && !$foundDoableProblem) { + while ($curRes = $iterator->next()) { if (ref($curRes) && $curRes->is_problem()) { my $status = $curRes->status(); if ($curRes->completable()) { - $problemRes = $curRes; + my $thisduedate=$curRes->duedate(); + unless ($foundDoableProblem) { + $minimumduedate=$thisduedate; + } + $foundDoableProblem = 1; - # Pop open all previous maps - my $stack = $iterator->getStack(); - pop @$stack; # last resource in the stack is the problem - # itself, which we don't need in the map stack - my @mapPcs = map {$_->map_pc()} @$stack; - $env{'form.filter'} = join(',', @mapPcs); - - # Mark as both "here" and "jump" - $env{'form.postsymb'} = $curRes->symb(); + if ($thisduedate<=$minimumduedate) { + # Pop open all previous maps + my $stack = $iterator->getStack(); + pop @$stack; # last resource in the stack is the problem + # itself, which we don't need in the map stack + my @mapPcs = map {$_->map_pc()} @$stack; + $env{'form.filter'} = join(',', @mapPcs); + + # Mark as both "here" and "jump" + $env{'form.postsymb'} = $curRes->symb(); + $minimumduedate=$thisduedate; + } } } } @@ -364,7 +361,7 @@ MENU } else { &add_linkitem(\%toplinkitems,'firsthomework', 'location.href="navmaps?jumpToFirstHomework"', - "Show Me My First Homework Problem"); + "Show my first due problem"); } my $suppressEmptySequences = 0; @@ -381,8 +378,8 @@ MENU }; &add_linkitem(\%toplinkitems,'everything', 'location.href="navmaps?sort='.$env{'form.sort'}.'"', - "Show Everything"); - $r->print("

".&mt("Uncompleted Homework")."

"); + "Show everything"); + $r->print("

".&mt("Uncompleted Problems")."

"); $env{'form.filter'} = ''; $env{'form.condition'} = 1; $resource_no_folder_link = 1; @@ -390,7 +387,7 @@ MENU &add_linkitem(\%toplinkitems,'uncompleted', 'location.href="navmaps?sort='.$env{'form.sort'}. '&showOnlyHomework=1"', - "Show Only Uncompleted Homework"); + "Show only uncompleted problems"); } my %selected=($env{'form.sort'} => 'selected=on'); @@ -682,7 +679,7 @@ sub timeToHumanString { if($format ne '') { my $timeStr = strftime($format, localtime($time)); - return $timeStr.&Apache::lonlocal::gettimezone(); + return $timeStr.&Apache::lonlocal::gettimezone($time); } # Less then 5 days away, display day of the week and @@ -693,7 +690,7 @@ sub timeToHumanString { $timeStr =~ s/12:00 am/00:00/; $timeStr =~ s/12:00 pm/noon/; return ($inPast ? "last " : "this ") . - $timeStr.&Apache::lonlocal::gettimezone(); + $timeStr.&Apache::lonlocal::gettimezone($time); } my $conjunction='on'; @@ -708,14 +705,14 @@ sub timeToHumanString { my $timeStr = strftime("$conjunction %A, %b %e at %I:%M %P", localtime($time)); $timeStr =~ s/12:00 am/00:00/; $timeStr =~ s/12:00 pm/noon/; - return $timeStr.&Apache::lonlocal::gettimezone(); + return $timeStr.&Apache::lonlocal::gettimezone($time); } # Not this year, so show the year my $timeStr = strftime("$conjunction %A, %b %e %Y at %I:%M %P", localtime($time)); $timeStr =~ s/12:00 am/00:00/; $timeStr =~ s/12:00 pm/noon/; - return $timeStr.&Apache::lonlocal::gettimezone(); + return $timeStr.&Apache::lonlocal::gettimezone($time); } } @@ -1612,11 +1609,11 @@ sub render { if ($condition) { $link='"navmaps?condition=0&filter=&'.$queryString. '&here='.&Apache::lonnet::escape($here).'"'; - $text='Close All Folders'; + $text='Close all folders'; } else { $link='"navmaps?condition=1&filter=&'.$queryString. '&here='.&Apache::lonnet::escape($here).'"'; - $text='Open All Folders'; + $text='Open all folders'; } if ($args->{'caller'} eq 'navmapsdisplay') { &add_linkitem($args->{'linkitems'},'changefolder', @@ -2355,10 +2352,11 @@ sub unread_discussion { my $symb = shift; $self->get_discussion_data(); - - my $ressymb = $self->wrap_symb($symb); - my $version = $self->{DISCUSSION_DATA}{'version:'.$ressymb}; + my $ressymb = $self->wrap_symb($symb); + # keys used to store bulletinboard postings use 'unwrapped' symb. + my $discsymb = $self->unwrap_symb($ressymb); + my $version = $self->{DISCUSSION_DATA}{'version:'.$discsymb}; if (!$version) { return; } my $prevread = $self->{LAST_READ}{$ressymb}; @@ -2371,24 +2369,24 @@ sub unread_discussion { my %subjects; for (my $id=$version; $id>0; $id--) { - my $vkeys=$self->{DISCUSSION_DATA}{$id.':keys:'.$ressymb}; + my $vkeys=$self->{DISCUSSION_DATA}{$id.':keys:'.$discsymb}; my @keys=split(/:/,$vkeys); if (grep(/^hidden$/ ,@keys)) { if (!$hiddenflag) { - $hidden = $self->{DISCUSSION_DATA}{$id.':'.$ressymb.':hidden'}; + $hidden = $self->{DISCUSSION_DATA}{$id.':'.$discsymb.':hidden'}; $hiddenflag = 1; } } elsif (grep(/^deleted$/,@keys)) { if (!$deletedflag) { - $deleted = $self->{DISCUSSION_DATA}{$id.':'.$ressymb.':deleted'}; + $deleted = $self->{DISCUSSION_DATA}{$id.':'.$discsymb.':deleted'}; $deletedflag = 1; } } else { if (($hidden !~/\.$id\./) && ($deleted !~/\.$id\./) - && $prevread < $self->{DISCUSSION_DATA}{$id.':'.$ressymb.':timestamp'}) { + && $prevread < $self->{DISCUSSION_DATA}{$id.':'.$discsymb.':timestamp'}) { $unreadcount++; $subjects{$unreadcount}= - $id.': '.$self->{DISCUSSION_DATA}{$id.':'.$ressymb.':subject'}; + $id.': '.$self->{DISCUSSION_DATA}{$id.':'.$discsymb.':subject'}; } } } @@ -2401,7 +2399,7 @@ sub unread_discussion { sub wrap_symb { my $self = shift; my $symb = shift; - if ($symb =~ m-___(adm/\w+/\w+/)(\d+)(/bulletinboard)$-) { + if ($symb =~ m-___(adm/[^/]+/[^/]+/)(\d+)(/bulletinboard)$-) { unless ($symb =~ m|adm/wrapper/adm|) { $symb = 'bulletin___'.$2.'___adm/wrapper/'.$1.$2.$3; } @@ -2409,6 +2407,16 @@ sub wrap_symb { return $symb; } +sub unwrap_symb { + my $self = shift; + my $ressymb = shift; + my $discsymb = $ressymb; + if ($ressymb =~ m-^(bulletin___\d+___)adm/wrapper/(adm/[^/]+/[^/]+/\d+/bulletinboard)$-) { + $discsymb = $1.$2; + } + return $discsymb; +} + # Private method: Does the given resource (as a symb string) have # current feedback? Returns the string in the feedback hash, which # will be false if it does not exist. @@ -4377,9 +4385,9 @@ sub extractParts { # So we have to use our knowlege of part names to figure out # where the part names begin and end, and even then, it is possible # to construct ambiguous situations. - foreach (split /,/, $metadata) { - if ($_ =~ /^([a-zA-Z]+)response_(.*)/ - || $_ =~ /^(Task)_(.*)/) { + foreach my $data (split /,/, $metadata) { + if ($data =~ /^([a-zA-Z]+)response_(.*)/ + || $data =~ /^(Task)_(.*)/) { my $responseType = $1; my $partStuff = $2; my $partIdSoFar = ''; @@ -4391,8 +4399,15 @@ sub extractParts { if ($parts{$partIdSoFar}) { my @otherChunks = @partChunks[$i+1..$#partChunks]; my $responseId = join('_', @otherChunks); - push @{$responseIdHash{$partIdSoFar}}, $responseId; - push @{$responseTypeHash{$partIdSoFar}}, $responseType; + if ($self->is_task()) { + push(@{$responseIdHash{$partIdSoFar}}, + $partIdSoFar); + } else { + push(@{$responseIdHash{$partIdSoFar}}, + $responseId); + } + push(@{$responseTypeHash{$partIdSoFar}}, + $responseType); } } }