Diff for /loncom/interface/lonnavmaps.pm between versions 1.40 and 1.49

version 1.40, 2002/08/12 18:21:42 version 1.49, 2002/09/09 16:40:01
Line 67  my %courseopt; Line 67  my %courseopt;
 my %useropt;  my %useropt;
 my %parmhash;  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  # ------------------------------------------------------------------ Euclid gcd
   
 sub euclid {  sub euclid {
Line 191  sub astatus { Line 195  sub astatus {
     my %opendate=();      my %opendate=();
     my %answerdate=();      my %answerdate=();
     # need to always check part 0's open/due/answer status      # 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$/) {          if ($_=~/^parameter\_(.*)\_opendate$/) {
     my $part=$1;      my $part=$1;
             $duedate{$part}=&parmval($part.'.duedate',$symb);              $duedate{$part}=&parmval($part.'.duedate',$symb);
             $opendate{$part}=&parmval($part.'.opendate',$symb);              $opendate{$part}=&parmval($part.'.opendate',$symb);
             $answerdate{$part}=&parmval($part.'.answerdate',$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;      my $now=time;
Line 339  sub tracetable { Line 349  sub tracetable {
     my ($sofar,$rid,$beenhere,$showtypes,$indent,$linkid)=@_;      my ($sofar,$rid,$beenhere,$showtypes,$indent,$linkid)=@_;
     my $newshowtypes=$showtypes;      my $newshowtypes=$showtypes;
     my $further=$sofar;      my $further=$sofar;
     #$Apache::lonxml::debug=1;  # $Apache::lonxml::debug=1;
     &Apache::lonxml::debug("$rid ; $linkid ; $sofar ; $beenhere ; ".$hash{'src_'.$rid});      &Apache::lonxml::debug("$rid ; $linkid ; $sofar ; $beenhere ; ".$hash{'src_'.$rid});
     if ($beenhere=~/\&$rid\&/) { return $further; }      if ($beenhere=~/\&$rid\&/) { return $further; }
     $beenhere.=$rid.'&';      $beenhere.=$rid.'&';
Line 434  sub handler { Line 444  sub handler {
     &Apache::loncommon::no_cache($r);      &Apache::loncommon::no_cache($r);
     $r->send_http_header;      $r->send_http_header;
   
     my $firstres=$hash{'map_start_/res/'.$ENV{'request.course.uri'}};      my $firstres=$hash{'map_start_'.
     my $lastres=$hash{'map_finish_/res/'.$ENV{'request.course.uri'}};             &Apache::lonnet::clutter($ENV{'request.course.uri'})};
       my $lastres=$hash{'map_finish_'.
              &Apache::lonnet::clutter($ENV{'request.course.uri'})};
     if (!(($firstres) && ($lastres))) {      if (!(($firstres) && ($lastres))) {
  $r->print('<html><body>Coursemap undefined.</body></html>');   $r->print('<html><body>Coursemap undefined.</body></html>');
     } else {      } else {
Line 456  sub handler { Line 468  sub handler {
  my ($cdom,$cnum)=split(/\_/,$cid);   my ($cdom,$cnum)=split(/\_/,$cid);
   
  my $userprefix=$uname.'_'.$udom.'_';   my $userprefix=$uname.'_'.$udom.'_';
   
  unless ($uhome eq 'no_host') {    unless ($uhome eq 'no_host') { 
 # -------------------------------------------------------------- Get coursedata  # ------------------------------------------------- Get coursedata (if present)
     unless ((time-$courserdatas{$cid.'.last_cache'})<240) {      unless ((time-$courserdatas{$cid.'.last_cache'})<240) {
  my $reply=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum.   my $reply=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum.
  ':resourcedata',$chome);   ':resourcedata',$chome);
Line 466  sub handler { Line 478  sub handler {
     $courserdatas{$cid}=$reply;      $courserdatas{$cid}=$reply;
     $courserdatas{$cid.'.last_cache'}=time;      $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})) {      foreach (split(/\&/,$courserdatas{$cid})) {
  my ($name,$value)=split(/\=/,$_);   my ($name,$value)=split(/\=/,$_);
Line 489  sub handler { Line 506  sub handler {
   
  @rows=();   @rows=();
   
  &tracetable(0,$firstres,'&'.$lastres.'&','',0);   &tracetable(0,$firstres,'&','',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;  
     }  
  }  
   
 # ------------------------------------------------------------------ Page parms  # ------------------------------------------------------------------ Page parms
   
Line 567  sub handler { Line 578  sub handler {
  }   }
     }      }
 # ----------------------------------------------------------- Start Page Output  # ----------------------------------------------------------- Start Page Output
     $r->print('<html><head><title>Navigate LON-CAPA Maps</title></head>');              my $bodytagadd='';
     $r->print('<body bgcolor="#FFFFFF"');      $r->print(
                      '<html><head><title>Navigate Course Map</title></head>');
     if (($currenturl=~/^\/res/) &&      if (($currenturl=~/^\/res/) &&
  ($currenturl!~/^\/res\/adm/)) {   ($currenturl!~/^\/res\/adm/)) {
  $r->print(' onLoad="window.location.hash='."'curloc'".'"');   $bodytagadd='onLoad="window.location.hash='."'curloc'".'"';
     }      }
     $r->print('><script>window.focus();</script>'.      $r->print(&Apache::loncommon::bodytag('Navigate Course Map','',
       '<img align=right src=/adm/lonIcons/lonlogos.gif>'.                                                    $bodytagadd));
       '<h1>Navigate Course Map</h1>'.      $r->print('<script>window.focus();</script>');
       "<h3>$date</h3>");      my $desc=$ENV{'course.'.$ENV{'request.course.id'}.'.description'};
       if (defined($desc)) { $r->print("<h2>$desc</h2>\n"); }
       $r->print("<h3>$date</h3>\n");
     $r->rflush();      $r->rflush();
     $r->print('<img src="/adm/lonMisc/chat.gif"> New discussion since '.      $r->print('<img src="/adm/lonMisc/chat.gif"> New discussion since '.
       localtime($lastcheck).        localtime($lastcheck).
Line 585  sub handler { Line 599  sub handler {
  ($currenturl!~/^\/res\/adm/)) {   ($currenturl!~/^\/res\/adm/)) {
  $r->print('<a href="#curloc">Current Location</a><p>');   $r->print('<a href="#curloc">Current Location</a><p>');
     }      }
   
       # Handle a network error
   
       if ($networkFailedFlag)
       {
    $r->print('<H2>LON-CAPA network failure.</H2>'."\n");
    $r->print("<p>LON-CAPA's network is having difficulties, some problem" .
     " information, such as due dates, will not be available.");
       }
 # ----------------------------------------------------- The little content list  # ----------------------------------------------------- The little content list
     for ($i=0;$i<=$#rows;$i++) {      for ($i=0;$i<=$#rows;$i++) {
  if ($rows[$i]) {   if ($rows[$i]) {
Line 608  sub handler { Line 631  sub handler {
     $r->print("\n<tr>");      $r->print("\n<tr>");
     my @colcont=split(/\&/,$rows[$i]);      my @colcont=split(/\&/,$rows[$i]);
     my $avespan=$lcm/($#colcont+1);      my $avespan=$lcm/($#colcont+1);
   
       # for each item I wish to print on this row...
     for ($j=0;$j<=$#colcont;$j++) {      for ($j=0;$j<=$#colcont;$j++) {
  my $indent;my $indentstr;   my $indent;my $indentstr;
  my $linkid;   my $linkid;
Line 641  sub handler { Line 666  sub handler {
     my $tcode=$2;      my $tcode=$2;
     my $ctext=$3;      my $ctext=$3;
     $rid=$4;      $rid=$4;
     if ($tcode eq '1') {      
       # will open later
       if ($tcode eq '1') { 
  $add='<td bgcolor="#AAAAAA">';   $add='<td bgcolor="#AAAAAA">';
     }      }
   
       # solved/correct
     if ($code eq '3') {      if ($code eq '3') {
  $add='<td bgcolor="#AAFFAA">';   $add='<td bgcolor="#AAFFAA">';
     } elsif ($code eq '4') {      } elsif ($code eq '4') { # partially correct
  $add='<td bgcolor="#E0FFAA">';   $add='<td bgcolor="#E0FFAA">';
     } else {      } else {
  $add='<td bgcolor="#FFAAAA">';   # not attempted
  if ($tcode eq '2') {  
    # we end up here on network failure, so pick a neutral
    # color if the network failed instead of bright red.
    if ( $networkFailedFlag )
    {
       $add = '<td bgcolor="#AAAAAA">';
    }
    else
    {
       $add='<td bgcolor="#FFAAAA">';
    }
   
    if ($tcode eq '2') { # open, not past due
     $add='<td bgcolor="#FFFFAA">';      $add='<td bgcolor="#FFFFAA">';
  }   }
  if ($tcode eq '4') {  
    if ($tcode eq '4') { # due in next 24 hours
     $add='<td bgcolor="#FFFF33">';      $add='<td bgcolor="#FFFF33">';
     $adde='</td>';      $adde='</td>';
  }   }
Line 671  sub handler { Line 713  sub handler {
  $hwk='<font color="#229922"><b>';   $hwk='<font color="#229922"><b>';
  $hwke='</b> ('.$ctext.')</font>';   $hwke='</b> ('.$ctext.')</font>';
     }      }
       if ($networkFailedFlag) 
       {
    $hwke='</b> (status unavailable)</font>';
       }
  }   }
  if ($rid && $hash{'src_'.$rid} eq $currenturl) {   if ($rid && $hash{'src_'.$rid} eq $currenturl) {
     $add=$add.'<a name="curloc"></a>'.      $add=$add.'<a name="curloc"></a>'.

Removed from v.1.40  
changed lines
  Added in v.1.49


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>