:
+
+Useful for renderers: If this resource is currently the first resource
+of a new branch, this will be true. The Resource column (leftmost in the
+navmaps screen) uses this to display the "new branch" icon
+
+=back
+
+=cut
+
+sub resource { return 0; }
+sub communication_status { return 1; }
+sub quick_status { return 2; }
+sub long_status { return 3; }
+sub part_status_summary { return 4; }
+
+sub render_resource {
+ my ($resource, $part, $params) = @_;
+
+ my $nonLinkedText = ''; # stuff after resource title not in link
+
+ 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"};
+ my $filter = $it->{FILTER};
+
+ my $title = $resource->compTitle();
+
+ my $partLabel = "";
+ my $newBranchText = "";
+ my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons");
+ # If this is a new branch, label it so
+ if ($params->{'isNewBranch'}) {
+ $newBranchText = "
";
}
- my $col=0;
- &Apache::lonxml::debug("following links -$next-");
- foreach (split(/\,/,$next)) {
- my ($nextlinkid,$condval)=split(/\:/,$_);
- if ($condval>=$mincond) {
- my $now=&tracetable($sofar,$hash{'goesto_'.$nextlinkid},
- $beenhere,$showtypes,$indent,$linkid);
- if ($now>$further) {
- if ($col>0) {
- my $string;
- for(my $i=0;$i<$col;$i++) { $string.='&'; }
- for(my $i=$further+1;$now-1>$i;$i++) {
- $rows[$i]=$string.$rows[$i];
- }
- }
- $further=$now;
- }
+
+ # links to open and close the folder
+
+
+ my $linkopen = "";
+
+
+ my $linkclose = "";
+
+ # Default icon: unknown page
+ my $icon = "
";
+
+ if ($resource->is_problem()) {
+ if ($part eq '0' || $params->{'condensed'}) {
+ $icon ='
';
+ } else {
+ $icon = $params->{'indentString'};
}
- $col++;
+ } else {
+ $icon = "
";
}
- return $further;
-}
-# ------------------------------------------------------------ Build page table
-sub tracetable {
- my ($sofar,$rid,$beenhere,$showtypes,$indent,$linkid)=@_;
- my $newshowtypes=$showtypes;
- my $further=$sofar;
-# $Apache::lonxml::debug=1;
- &Apache::lonxml::debug("$rid ; $linkid ; $sofar ; $beenhere ; ".$hash{'src_'.$rid});
- if ($beenhere=~/\&$rid\&/) { return $further; }
- $beenhere.=$rid.'&';
-
- if (defined($hash{'is_map_'.$rid})) {
- $sofar++;
- my $tprefix='';
- if ($hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$rid}}}
- eq 'sequence') {
- $tprefix='h';
- } elsif ($hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$rid}}}
- eq 'page') {
- $tprefix='j';
- if ($indent) { $tprefix='i'.$indent.','.$tprefix; }
- if ($linkid) { $tprefix='l'.$linkid.','.$tprefix; }
- $newshowtypes='problems';
- $indent++;
- #if in a .page continue to link the encompising .page
- if (!$linkid) { $linkid=$rid; }
+ # Display the correct map icon to open or shut map
+ if ($resource->is_map()) {
+ my $mapId = $resource->map_pc();
+ my $nowOpen = !defined($filter->{$mapId});
+ if ($it->{CONDITION}) {
+ $nowOpen = !$nowOpen;
}
- if (defined($rows[$sofar])) {
- $rows[$sofar].='&'.$tprefix.$rid;
+
+ my $folderType = $resource->is_sequence() ? 'folder' : 'page';
+ my $title=$resource->title;
+ $title=~s/\"/\"/g;
+ if (!$params->{'resource_no_folder_link'}) {
+ $icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.gif';
+ $icon = "
";
+
+ $linkopen = "{'url'} . '?' .
+ $params->{'queryString'} . '&filter=';
+ $linkopen .= ($nowOpen xor $it->{CONDITION}) ?
+ addToFilter($filter, $mapId) :
+ removeFromFilter($filter, $mapId);
+ $linkopen .= "&condition=" . $it->{CONDITION} . '&hereType='
+ . $params->{'hereType'} . '&here=' .
+ &Apache::lonnet::escape($params->{'here'}) .
+ '&jump=' .
+ &Apache::lonnet::escape($resource->symb()) .
+ "&folderManip=1\">";
+
} else {
- $rows[$sofar]=$tprefix.$rid;
- }
- if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) &&
- (defined($hash{'map_finish_'.$hash{'src_'.$rid}}))) {
- my $frid=$hash{'map_finish_'.$hash{'src_'.$rid}};
- $sofar=&tracetable($sofar,$hash{'map_start_'.$hash{'src_'.$rid}},
- '&'.$frid.'&',$newshowtypes,$indent,$linkid);
- &addresource($hash{'src_'.$frid},\$sofar,$frid,$newshowtypes,
- $indent,$linkid);
- if ($tprefix =~ /j$/) { $indent--; $linkid=''; }
+ # Don't allow users to manipulate folder
+ $icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') .
+ '.nomanip.gif';
+ $icon = "
";
+
+ $linkopen = "";
+ $linkclose = "";
}
- } else {
- &addresource($hash{'src_'.$rid},\$sofar,$rid,$showtypes,
- $indent,$linkid);
}
- if (defined($hash{'to_'.$rid})) {
- $further=&followlinks($rid,$sofar,$beenhere,$further,$showtypes,
- $indent,$linkid);
+ if ($resource->randomout()) {
+ $nonLinkedText .= ' ('.&mt('hidden').') ';
+ }
+ if (!$resource->condval()) {
+ $nonLinkedText .= ' ('.&mt('conditionally hidden').') ';
}
+
+ # We're done preparing and finally ready to start the rendering
+ my $result = "";
- return $further;
-}
+ my $indentLevel = $params->{'indentLevel'};
+ if ($newBranchText) { $indentLevel--; }
-# ================================================================ Main Handler
+ # print indentation
+ for (my $i = 0; $i < $indentLevel; $i++) {
+ $result .= $params->{'indentString'};
+ }
-sub handler {
- my $r=shift;
+ # Decide what to display
- &Apache::loncommon::get_unprocessed_cgi($ENV{QUERY_STRING});
+ $result .= "$newBranchText$linkopen$icon$linkclose";
+
+ my $curMarkerBegin = '';
+ my $curMarkerEnd = '';
- if ($ENV{'form.jtest'} ne "1")
- {
- return new_handle($r);
+ # Is this the current resource?
+ if (!$params->{'displayedHereMarker'} &&
+ $resource->symb() eq $params->{'here'} ) {
+ $curMarkerBegin = '>';
+ $curMarkerEnd = '<';
+ $params->{'displayedHereMarker'} = 1;
}
-# ------------------------------------------- Set document type for header only
+ if ($resource->is_problem() && $part ne '0' &&
+ !$params->{'condensed'}) {
+ my $displaypart=$resource->part_display($part);
+ $partLabel = " (".&mt('Part: [_1]', $displaypart).")";
+ if ($link!~/\#/) { $link.='#'.&Apache::lonnet::escape($part); }
+ $title = "";
+ }
- if ($r->header_only) {
- if ($ENV{'browser.mathml'}) {
- $r->content_type('text/xml');
- } else {
- $r->content_type('text/html');
- }
- $r->send_http_header;
- return OK;
+ if ($params->{'condensed'} && $resource->countParts() > 1) {
+ $nonLinkedText .= ' ('.&mt('[_1] parts', $resource->countParts()).')';
}
- my $requrl=$r->uri;
- my $hashtied;
-# ----------------------------------------------------------------- Tie db file
- my $fn;
- if ($ENV{'request.course.fn'}) {
- $fn=$ENV{'request.course.fn'};
- if (-e "$fn.db") {
- if ((tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER(),0640)) &&
- (tie(%parmhash,'GDBM_File',
- $ENV{'request.course.fn'}.'_parms.db',
- &GDBM_READER(),0640))) {
- $hashtied=1;
- }
- }
+
+ my $target;
+ if ($env{'environment.remotenavmap'} eq 'on') {
+ $target=' target="loncapaclient" ';
}
- if (!$hashtied) {
- $ENV{'user.error.msg'}="$requrl:bre:0:0:Course not initialized";
- return HTTP_NOT_ACCEPTABLE;
+ if (!$params->{'resource_nolink'} && !$resource->is_sequence() && !$resource->is_empty_sequence) {
+ $result .= " $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText | ";
+ } else {
+ $result .= " $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText";
}
-# ------------------------------------------------------------------- Hash tied
+ return $result;
+}
- if ($ENV{'browser.mathml'}) {
- $r->content_type('text/xml');
- } else {
- $r->content_type('text/html');
- }
- &Apache::loncommon::no_cache($r);
- $r->send_http_header;
+sub render_communication_status {
+ my ($resource, $part, $params) = @_;
+ my $discussionHTML = ""; my $feedbackHTML = ""; my $errorHTML = "";
- my $firstres=$hash{'map_start_'.
- &Apache::lonnet::clutter($ENV{'request.course.uri'})};
- my $lastres=$hash{'map_finish_'.
- &Apache::lonnet::clutter($ENV{'request.course.uri'})};
- if (!(($firstres) && ($lastres))) {
- $r->print('Coursemap undefined.');
- } else {
+ my $link = $params->{"resourceLink"};
+ my $target;
+ if ($env{'environment.remotenavmap'} eq 'on') {
+ $target=' target="loncapaclient" ';
+ }
+ my $linkopen = "";
+ my $linkclose = "";
+ my $location=&Apache::loncommon::lonhttpdurl("/adm/lonMisc");
+ if ($resource->hasDiscussion()) {
+ $discussionHTML = $linkopen .
+ '
' .
+ $linkclose;
+ }
+
+ if ($resource->getFeedback()) {
+ my $feedback = $resource->getFeedback();
+ foreach (split(/\,/, $feedback)) {
+ if ($_) {
+ $feedbackHTML .= ' '
+ . '
';
+ }
+ }
+ }
+
+ if ($resource->getErrors()) {
+ my $errors = $resource->getErrors();
+ my $errorcount = 0;
+ foreach (split(/,/, $errors)) {
+ last if ($errorcount>=10); # Only output 10 bombs maximum
+ if ($_) {
+ $errorcount++;
+ $errorHTML .= ' '
+ . '
';
+ }
+ }
+ }
-# ----------------------------------------------------------------- Render page
-# -------------------------------------------------------------- Set parameters
+ if ($params->{'multipart'} && $part != '0') {
+ $discussionHTML = $feedbackHTML = $errorHTML = '';
+ }
+ return "$discussionHTML$feedbackHTML$errorHTML | ";
-# ---------------------------- initialize coursedata and userdata for this user
- undef %courseopt;
- undef %useropt;
-
- my $uname=$ENV{'user.name'};
- my $udom=$ENV{'user.domain'};
- my $uhome=$ENV{'user.home'};
- my $cid=$ENV{'request.course.id'};
- my $chome=$ENV{'course.'.$cid.'.home'};
- my ($cdom,$cnum)=split(/\_/,$cid);
+}
+sub render_quick_status {
+ my ($resource, $part, $params) = @_;
+ my $result = "";
+ my $firstDisplayed = !$params->{'condensed'} &&
+ $params->{'multipart'} && $part eq "0";
+
+ my $link = $params->{"resourceLink"};
+ my $target;
+ if ($env{'environment.remotenavmap'} eq 'on') {
+ $target=' target="loncapaclient" ';
+ }
+ my $linkopen = "";
+ my $linkclose = "";
+
+ 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 $linkclose | \n";
+ } else {
+ $result .= " | \n";
+ }
+ } else { # not problem, no icon
+ $result .= " | \n";
+ }
- my $userprefix=$uname.'_'.$udom.'_';
+ return $result;
+}
+sub render_long_status {
+ my ($resource, $part, $params) = @_;
+ my $result = "\n";
+ my $firstDisplayed = !$params->{'condensed'} &&
+ $params->{'multipart'} && $part eq "0";
+
+ my $color;
+ if ($resource->is_problem()) {
+ $color = $colormap{$resource->status};
- unless ($uhome eq 'no_host') {
-# ------------------------------------------------- Get coursedata (if present)
- unless ((time-$courserdatas{$cid.'.last_cache'})<240) {
- my $reply=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum.
- ':resourcedata',$chome);
- if ($reply!~/^error\:/) {
- $courserdatas{$cid}=$reply;
- $courserdatas{$cid.'.last_cache'}=time;
- }
- # check to see if network failed
- elsif ( $reply=~/no.such.host/i || $reply=~/con.*lost/i )
- {
- $networkFailedFlag = 1;
- }
- }
- foreach (split(/\&/,$courserdatas{$cid})) {
- my ($name,$value)=split(/\=/,$_);
- $courseopt{$userprefix.&Apache::lonnet::unescape($name)}=
- &Apache::lonnet::unescape($value);
- }
-# --------------------------------------------------- Get userdata (if present)
- unless ((time-$userrdatas{$uname.'___'.$udom.'.last_cache'})<240) {
- my $reply=&Apache::lonnet::reply('dump:'.$udom.':'.$uname.':resourcedata',$uhome);
- if ($reply!~/^error\:/) {
- $userrdatas{$uname.'___'.$udom}=$reply;
- $userrdatas{$uname.'___'.$udom.'.last_cache'}=time;
- }
- }
- foreach (split(/\&/,$userrdatas{$uname.'___'.$udom})) {
- my ($name,$value)=split(/\=/,$_);
- $useropt{$userprefix.&Apache::lonnet::unescape($name)}=
- &Apache::lonnet::unescape($value);
- }
+ if (dueInLessThan24Hours($resource, $part) ||
+ lastTry($resource, $part)) {
+ $color = $hurryUpColor;
}
+ }
+
+ if ($resource->kind() eq "res" &&
+ $resource->is_problem() &&
+ !$firstDisplayed) {
+ if ($color) {$result .= ""; }
+ $result .= getDescription($resource, $part);
+ if ($color) {$result .= ""; }
+ }
+ if ($resource->is_map() && advancedUser() && $resource->randompick()) {
+ $result .= '(randomly select ' . $resource->randompick() .')';
+ }
+
+ # Debugging code
+ #$result .= " " . $resource->awarded($part) . '/' . $resource->weight($part) .
+ # ' - Part: ' . $part;
- @rows=();
+ $result .= " | \n";
+
+ return $result;
+}
- &tracetable(0,$firstres,'&','',0);
+# Colors obtained by taking the icons, matching the colors, and
+# possibly reducing the Value (HSV) of the color, if it's too bright
+# for text, generally by one third or so.
+my %statusColors =
+ (
+ $resObj->CLOSED => '#000000',
+ $resObj->OPEN => '#998b13',
+ $resObj->CORRECT => '#26933f',
+ $resObj->INCORRECT => '#c48207',
+ $resObj->ATTEMPTED => '#a87510',
+ $resObj->ERROR => '#000000'
+ );
+my %statusStrings =
+ (
+ $resObj->CLOSED => 'Not yet open',
+ $resObj->OPEN => 'Open',
+ $resObj->CORRECT => 'Correct',
+ $resObj->INCORRECT => 'Incorrect',
+ $resObj->ATTEMPTED => 'Attempted',
+ $resObj->ERROR => 'Network Error'
+ );
+my @statuses = ($resObj->CORRECT, $resObj->ATTEMPTED, $resObj->INCORRECT, $resObj->OPEN, $resObj->CLOSED, $resObj->ERROR);
+
+use Data::Dumper;
+sub render_parts_summary_status {
+ my ($resource, $part, $params) = @_;
+ if (!$resource->is_problem() && !$resource->contains_problem) { return ' | '; }
+ if ($params->{showParts}) {
+ return ' | ';
+ }
+
+ my $td = "\n";
+ my $endtd = " | \n";
+ my @probs;
-# ------------------------------------------------------------------ Page parms
+ if ($resource->contains_problem) {
+ @probs=$resource->retrieveResources($resource,sub { $_[0]->is_problem() },1,0);
+ } else {
+ @probs=($resource);
+ }
+ my $return;
+ my %overallstatus;
+ my $totalParts;
+ foreach my $resource (@probs) {
+ # If there is a single part, just show the simple status
+ if ($resource->singlepart()) {
+ my $status = $resource->simpleStatus(${$resource->parts}[0]);
+ $overallstatus{$status}++;
+ $totalParts++;
+ next;
+ }
+ # Now we can be sure the $part doesn't really matter.
+ my $statusCount = $resource->simpleStatusCount();
+ my @counts;
+ foreach my $status (@statuses) {
+ # decouple display order from the simpleStatusCount order
+ my $slot = Apache::lonnavmaps::resource::statusToSlot($status);
+ if ($statusCount->[$slot]) {
+ $overallstatus{$status}+=$statusCount->[$slot];
+ $totalParts+=$statusCount->[$slot];
+ }
+ }
+ }
+ $return.= $td . $totalParts . ' parts: ';
+ foreach my $status (@statuses) {
+ if ($overallstatus{$status}) {
+ $return.="" . $overallstatus{$status} . ' '
+ . $statusStrings{$status} . "";
+ }
+ }
+ $return.= $endtd;
+ return $return;
+}
- my $j;
- my $i;
- my $lcm=1;
- my $contents=0;
+my @preparedColumns = (\&render_resource, \&render_communication_status,
+ \&render_quick_status, \&render_long_status,
+ \&render_parts_summary_status);
-# ---------------------------------------------- Go through table to get layout
+sub setDefault {
+ my ($val, $default) = @_;
+ if (!defined($val)) { return $default; }
+ return $val;
+}
- for ($i=0;$i<=$#rows;$i++) {
- if ($rows[$i]) {
- &Apache::lonxml::debug("Row $i is:".$rows[$i]);
- $contents++;
- my @colcont=split(/\&/,$rows[$i]);
- $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1));
- }
+sub cmp_title {
+ my ($atitle,$btitle) = (lc($_[0]->compTitle),lc($_[1]->compTitle));
+ $atitle=~s/^\s*//;
+ $btitle=~s/^\s*//;
+ return $atitle cmp $btitle;
+}
+
+sub render {
+ my $args = shift;
+ &Apache::loncommon::get_unprocessed_cgi($ENV{QUERY_STRING});
+ my $result = '';
+ # Configure the renderer.
+ my $cols = $args->{'cols'};
+ if (!defined($cols)) {
+ # no columns, no nav maps.
+ return '';
+ }
+ my $navmap;
+ if (defined($args->{'navmap'})) {
+ $navmap = $args->{'navmap'};
+ }
+
+ my $r = $args->{'r'};
+ my $queryString = $args->{'queryString'};
+ my $jump = $args->{'jump'};
+ my $here = $args->{'here'};
+ my $suppressNavmap = setDefault($args->{'suppressNavmap'}, 0);
+ my $closeAllPages = setDefault($args->{'closeAllPages'}, 0);
+ my $currentJumpDelta = 2; # change this to change how many resources are displayed
+ # before the current resource when using #current
+
+ # If we were passed 'here' information, we are not rendering
+ # after a folder manipulation, and we were not passed an
+ # iterator, make sure we open the folders to show the "here"
+ # marker
+ my $filterHash = {};
+ # Figure out what we're not displaying
+ foreach (split(/\,/, $env{"form.filter"})) {
+ if ($_) {
+ $filterHash->{$_} = "1";
}
+ }
+ # Filter: Remember filter function and add our own filter: Refuse
+ # to show hidden resources unless the user can see them.
+ my $userCanSeeHidden = advancedUser();
+ my $filterFunc = setDefault($args->{'filterFunc'},
+ sub {return 1;});
+ if (!$userCanSeeHidden) {
+ # Without renaming the filterfunc, the server seems to go into
+ # an infinite loop
+ my $oldFilterFunc = $filterFunc;
+ $filterFunc = sub { my $res = shift; return !$res->randomout() &&
+ &$oldFilterFunc($res);};
+ }
+
+ my $condition = 0;
+ if ($env{'form.condition'}) {
+ $condition = 1;
+ }
+
+ if (!$env{'form.folderManip'} && !defined($args->{'iterator'})) {
+ # Step 1: Check to see if we have a navmap
+ if (!defined($navmap)) {
+ $navmap = Apache::lonnavmaps::navmap->new();
+ if (!defined($navmap)) {
+ # no londer in course
+ return ''.&mt('No course selected').'
+ '.&mt('Select a course').'
';
+ }
+ }
- unless ($contents) {
- $r->print('Empty Map.');
- } else {
+ # Step two: Locate what kind of here marker is necessary
+ # Determine where the "here" marker is and where the screen jumps to.
-# ------------------------------------------------------------------ Build page
+ if ($env{'form.postsymb'} ne '') {
+ $here = $jump = &Apache::lonnet::symbclean($env{'form.postsymb'});
+ } elsif ($env{'form.postdata'} ne '') {
+ # couldn't find a symb, is there a URL?
+ my $currenturl = $env{'form.postdata'};
+ #$currenturl=~s/^http\:\/\///;
+ #$currenturl=~s/^[^\/]+//;
+
+ $here = $jump = &Apache::lonnet::symbread($currenturl);
+ }
+ if ($here eq '') {
+ my $last;
+ if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
+ &GDBM_READER(),0640)) {
+ $last=$hash{'last_known'};
+ untie(%hash);
+ }
+ if ($last) { $here = $jump = $last; }
+ }
- my $currenturl=$ENV{'form.postdata'};
- $currenturl=~s/^http\:\/\///;
- $currenturl=~s/^[^\/]+//;
-
-# ---------------------------------------------------------------- Send headers
-
- my $date=localtime;
- my $now=time;
-# ----------------------------------------- Get email status and discussiontime
-
- my %emailstatus=&Apache::lonnet::dump('email_status');
- my $logouttime=$emailstatus{'logout'};
- my $courseleave=$emailstatus{'logout_'.$ENV{'request.course.id'}};
- my $lastcheck=($courseleave>$logouttime?$courseleave:$logouttime);
-
- my %discussiontimes=&Apache::lonnet::dump('discussiontimes',
- $cdom,$cnum);
-
- my %feedback=();
- my %error=();
- foreach my $msgid (split(/\&/,&Apache::lonnet::reply('keys:'.
- $ENV{'user.domain'}.':'.
- $ENV{'user.name'}.':nohist_email',
- $ENV{'user.home'}))) {
- $msgid=&Apache::lonnet::unescape($msgid);
- my $plain=&Apache::lonnet::unescape(&Apache::lonnet::unescape($msgid));
- if ($plain=~/(Error|Feedback) \[([^\]]+)\]/) {
- my ($what,$url)=($1,$2);
- my %status=
- &Apache::lonnet::get('email_status',[$msgid]);
- if ($status{$msgid}=~/^error\:/) {
- $status{$msgid}='';
- }
-
- if (($status{$msgid} eq 'new') ||
- (!$status{$msgid})) {
- if ($what eq 'Error') {
- $error{$url}.=','.$msgid;
- } else {
- $feedback{$url}.=','.$msgid;
- }
+ # Step three: Ensure the folders are open
+ my $mapIterator = $navmap->getIterator(undef, undef, undef, 1);
+ my $curRes;
+ my $found = 0;
+
+ # We only need to do this if we need to open the maps to show the
+ # current position. This will change the counter so we can't count
+ # for the jump marker with this loop.
+ while ($here && ($curRes = $mapIterator->next()) && !$found) {
+ if (ref($curRes) && $curRes->symb() eq $here) {
+ my $mapStack = $mapIterator->getStack();
+
+ # Ensure the parent maps are open
+ for my $map (@{$mapStack}) {
+ if ($condition) {
+ undef $filterHash->{$map->map_pc()};
+ } else {
+ $filterHash->{$map->map_pc()} = 1;
}
}
+ $found = 1;
}
-# ----------------------------------------------------------- Start Page Output
- my $bodytagadd='';
- $r->print(
- 'Navigate Course Map');
- if (($currenturl=~/^\/res/) &&
- ($currenturl!~/^\/res\/adm/)) {
- $bodytagadd='onLoad="window.location.hash='."'curloc'".'"';
- }
- $r->print(&Apache::loncommon::bodytag('Navigate Course Map','',
- $bodytagadd));
- $r->print('');
- my $desc=$ENV{'course.'.$ENV{'request.course.id'}.'.description'};
- if (defined($desc)) { $r->print("$desc
\n"); }
- $r->print("$date
\n");
- $r->rflush();
- $r->print('
New discussion since '.
- localtime($lastcheck).
- '
New message (click to open)');
- if (($currenturl=~/^\/res/) &&
- ($currenturl!~/^\/res\/adm/)) {
- $r->print('Current Location
');
- }
+ }
+ }
- # Handle a network error
+ if ( !defined($args->{'iterator'}) && $env{'form.folderManip'} ) { # we came from a user's manipulation of the nav page
+ # If this is a click on a folder or something, we want to preserve the "here"
+ # from the querystring, and get the new "jump" marker
+ $here = $env{'form.here'};
+ $jump = $env{'form.jump'};
+ }
+
+ my $it = $args->{'iterator'};
+ if (!defined($it)) {
+ # Construct a default iterator based on $env{'form.'} information
+
+ # Step 1: Check to see if we have a navmap
+ if (!defined($navmap)) {
+ $navmap = Apache::lonnavmaps::navmap->new();
+ }
- if ($networkFailedFlag)
- {
- $r->print('
LON-CAPA network failure.
'."\n");
- $r->print("LON-CAPA's network is having difficulties, some problem" .
- " information, such as due dates, will not be available.");
- }
-# ----------------------------------------------------- The little content list
- for ($i=0;$i<=$#rows;$i++) {
- if ($rows[$i]) {
- my @colcont=split(/\&/,$rows[$i]);
- my $avespan=$lcm/($#colcont+1);
- for ($j=0;$j<=$#colcont;$j++) {
- my $rid=$colcont[$j];
- if ($rid=~/^h(.+)/) {
- $rid=$1;
- $r->print(' '.$hash{'title_'.$rid}.
- '
');
- }
- }
- }
- }
-# ----------------------------------------------------------------- Start table
- $r->print('
');
- for ($i=0;$i<=$#rows;$i++) {
- if ($rows[$i]) {
- $r->print("\n");
- my @colcont=split(/\&/,$rows[$i]);
- my $avespan=$lcm/($#colcont+1);
-
- # for each item I wish to print on this row...
- for ($j=0;$j<=$#colcont;$j++) {
- my $indent;my $indentstr;
- my $linkid;
- my $rid=$colcont[$j];
- $rid=~/(\d+)\.(\d+)$/;
- my $src=
- &Apache::lonnet::declutter($hash{'src_'.$1.'.'.$2});
- my $symb=
- &Apache::lonnet::declutter($hash{'map_id_'.$1}).'___'.$2.'___'.$src;
- my $add='';
- my $adde=' | ';
- my $hwk='';
- my $hwke='';
- if ($rid=~/^l(\d+\.\d+),(.+)/) { $linkid=$1; $rid=$2; }
- if ($rid=~/^i(\d+),(.+)/) { $indent=$1; $rid=$2; }
- if ($rid=~/^h(.+)/) {
- $rid=$1;
- $add='';
- $adde=' | ';
- if (($ENV{'user.adv'}) &&
- ($parmhash{$symb.'.0.parameter_randompick'})) {
- $adde=' (randomly select '.
- $parmhash{$symb.'.0.parameter_randompick'}.
- ')';
- }
- }
- if ($rid=~/^j(.+)/) { $rid=$1; }
- if ($rid=~/^p(\d)(\d)\"([\w\: \(\)\/\,]*)\"(.+)/) {
- # sub astatus describes what code/tcode mean
- my $code=$1;
- my $tcode=$2;
- my $ctext=$3;
- $rid=$4;
-
- # will open later
- if ($tcode eq '1') {
- $add='';
- }
-
- # solved/correct
- if ($code eq '3') {
- $add=' | ';
- } elsif ($code eq '4') { # partially correct
- $add=' | ';
- } else {
- # not attempted
-
- # we end up here on network failure, so pick a neutral
- # color if the network failed instead of bright red.
- if ( $networkFailedFlag )
- {
- $add = ' | ';
- }
- else
- {
- $add=' | ';
- }
-
- if ($tcode eq '2') { # open, not past due
- $add=' | ';
- }
-
- if ($tcode eq '4') { # due in next 24 hours
- $add=' | ';
- $adde=' | ';
- }
- }
- $hwk='';
- $hwke='';
- if ($code eq '1') {
- $hwke=' ('.$ctext.')';
- }
- if ($code eq '2' || $code eq '4') {
- $hwk='';
- $hwke=' ('.$ctext.')';
- }
- if ($code eq '3') {
- $hwk='';
- $hwke=' ('.$ctext.')';
- }
- if ($networkFailedFlag)
- {
- $hwke=' (status unavailable)';
- }
- }
- if ($rid && $hash{'src_'.$rid} eq $currenturl) {
- $add=$add.''.
- '> ';
- $adde=
- ' <'.$adde;
- }
- if ($discussiontimes{$symb}>$lastcheck) {
- $adde=
- '
'.
- $adde;
- }
- if ($error{$src}) {
- foreach (split(/\,/,$error{$src})) {
- if ($_) {
- $adde=
- '
'
- .$adde;
- }
- }
- }
- if ($feedback{$src}) {
- foreach (split(/\,/,$feedback{$src})) {
- if ($_) {
- $adde=
- '
'
- .$adde;
- }
- }
- }
- if ($indent) {
- my $is=" ";
- for(my $i=-1;$i<$indent;$i++) { $indentstr.=$is; }
- }
- if (!$linkid) { $linkid=$rid; }
- if ($hash{'randomout_'.$rid}) {
- $adde=' (hidden)'.$adde;
- }
- $r->print($add.$indentstr);
- if ($rid) {
- $r->print(''.
- $hwk.$hash{'title_'.$rid}.$hwke.'');
- }
- $r->print($adde);
- }
- $r->print('
');
- }
- }
- $r->print("\n
");
- $r->print('