--- loncom/interface/lonnavmaps.pm 2002/08/21 17:18:08 1.43 +++ loncom/interface/lonnavmaps.pm 2002/09/09 17:20:14 1.50 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.43 2002/08/21 17:18:08 www Exp $ +# $Id: lonnavmaps.pm,v 1.50 2002/09/09 17:20:14 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -67,6 +67,10 @@ my %courseopt; my %useropt; my %parmhash; +# This parameter keeps track of whether obtaining the user's information +# failed, which the colorizer in astatus can use +my $networkFailedFlag = 0; + # ------------------------------------------------------------------ Euclid gcd sub euclid { @@ -191,12 +195,18 @@ sub astatus { my %opendate=(); my %answerdate=(); # need to always check part 0's open/due/answer status - foreach (sort(split(/\,/,&Apache::lonnet::metadata($hash{'src_'.$rid},'keys')))) { + foreach (sort(split(/\,/,&Apache::lonnet::metadata($hash{'src_'.$rid},'allpossiblekeys')))) { if ($_=~/^parameter\_(.*)\_opendate$/) { my $part=$1; $duedate{$part}=&parmval($part.'.duedate',$symb); $opendate{$part}=&parmval($part.'.opendate',$symb); $answerdate{$part}=&parmval($part.'.answerdate',$symb); + if (&parmval($part.'.opendate.type',$symb) eq 'date_interval') { + $opendate{$part}=$duedate{$part}-$opendate{$part}; + } + if (&parmval($part.'.answerdate.type',$symb) eq 'date_interval') { + $answerdate{$part}=$duedate{$part}+$answerdate{$part}; + } } } my $now=time; @@ -339,7 +349,7 @@ sub tracetable { my ($sofar,$rid,$beenhere,$showtypes,$indent,$linkid)=@_; my $newshowtypes=$showtypes; my $further=$sofar; - #$Apache::lonxml::debug=1; +# $Apache::lonxml::debug=1; &Apache::lonxml::debug("$rid ; $linkid ; $sofar ; $beenhere ; ".$hash{'src_'.$rid}); if ($beenhere=~/\&$rid\&/) { return $further; } $beenhere.=$rid.'&'; @@ -458,9 +468,9 @@ sub handler { my ($cdom,$cnum)=split(/\_/,$cid); my $userprefix=$uname.'_'.$udom.'_'; - + unless ($uhome eq 'no_host') { -# -------------------------------------------------------------- Get coursedata +# ------------------------------------------------- Get coursedata (if present) unless ((time-$courserdatas{$cid.'.last_cache'})<240) { my $reply=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum. ':resourcedata',$chome); @@ -468,6 +478,11 @@ sub handler { $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(/\=/,$_); @@ -491,13 +506,7 @@ sub handler { @rows=(); - &tracetable(0,$firstres,'&'.$lastres.'&','',0); - if ($hash{'src_'.$lastres}) { - my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$lastres}); - if (($brepriv eq '2') || ($brepriv eq 'F')) { - $rows[$#rows+1]=''.$lastres; - } - } + &tracetable(0,$firstres,'&','',0); # ------------------------------------------------------------------ Page parms @@ -590,6 +599,15 @@ sub handler { ($currenturl!~/^\/res\/adm/)) { $r->print('Current Location

'); } + + # Handle a network error + + 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]) { @@ -613,6 +631,8 @@ sub handler { $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; @@ -646,19 +666,36 @@ sub handler { my $tcode=$2; my $ctext=$3; $rid=$4; - if ($tcode eq '1') { + + # will open later + if ($tcode eq '1') { $add=''; } + + # solved/correct if ($code eq '3') { $add=''; - } elsif ($code eq '4') { + } elsif ($code eq '4') { # partially correct $add=''; } else { - $add=''; - if ($tcode eq '2') { + # 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') { + + if ($tcode eq '4') { # due in next 24 hours $add=''; $adde=''; } @@ -676,6 +713,10 @@ sub handler { $hwk=''; $hwke=' ('.$ctext.')'; } + if ($networkFailedFlag) + { + $hwke=' (status unavailable)'; + } } if ($rid && $hash{'src_'.$rid} eq $currenturl) { $add=$add.''.