Diff for /loncom/interface/lonnavmaps.pm between versions 1.32 and 1.48

version 1.32, 2002/03/16 08:56:53 version 1.48, 2002/09/05 19:47:29
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 338  sub followlinks () { Line 342  sub followlinks () {
 sub tracetable {  sub tracetable {
     my ($sofar,$rid,$beenhere,$showtypes,$indent,$linkid)=@_;      my ($sofar,$rid,$beenhere,$showtypes,$indent,$linkid)=@_;
     my $newshowtypes=$showtypes;      my $newshowtypes=$showtypes;
     my $newlinkid=$linkid;  
     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 355  sub tracetable { Line 358  sub tracetable {
  eq 'page') {   eq 'page') {
     $tprefix='j';      $tprefix='j';
     if ($indent) { $tprefix='i'.$indent.','.$tprefix; }      if ($indent) { $tprefix='i'.$indent.','.$tprefix; }
       if ($linkid) { $tprefix='l'.$linkid.','.$tprefix; }
     $newshowtypes='problems';      $newshowtypes='problems';
     $indent++;      $indent++;
     $newlinkid=$rid;      #if in a .page continue to link the encompising .page
       if (!$linkid) { $linkid=$rid; }
  }   }
  if (defined($rows[$sofar])) {   if (defined($rows[$sofar])) {
     $rows[$sofar].='&'.$tprefix.$rid;      $rows[$sofar].='&'.$tprefix.$rid;
Line 368  sub tracetable { Line 373  sub tracetable {
     (defined($hash{'map_finish_'.$hash{'src_'.$rid}}))) {      (defined($hash{'map_finish_'.$hash{'src_'.$rid}}))) {
     my $frid=$hash{'map_finish_'.$hash{'src_'.$rid}};      my $frid=$hash{'map_finish_'.$hash{'src_'.$rid}};
     $sofar=&tracetable($sofar,$hash{'map_start_'.$hash{'src_'.$rid}},      $sofar=&tracetable($sofar,$hash{'map_start_'.$hash{'src_'.$rid}},
        '&'.$frid.'&',$newshowtypes,$indent,$newlinkid);         '&'.$frid.'&',$newshowtypes,$indent,$linkid);
     &addresource($hash{'src_'.$frid},\$sofar,$frid,$newshowtypes,      &addresource($hash{'src_'.$frid},\$sofar,$frid,$newshowtypes,
  $indent,$newlinkid);   $indent,$linkid);
     if ($tprefix =~ /j$/) { $indent--; }      if ($tprefix =~ /j$/) { $indent--; $linkid=''; }
  }   }
     } else {      } else {
  &addresource($hash{'src_'.$rid},\$sofar,$rid,$showtypes,   &addresource($hash{'src_'.$rid},\$sofar,$rid,$showtypes,
Line 410  sub handler { Line 415  sub handler {
     if ($ENV{'request.course.fn'}) {      if ($ENV{'request.course.fn'}) {
  $fn=$ENV{'request.course.fn'};   $fn=$ENV{'request.course.fn'};
  if (-e "$fn.db") {   if (-e "$fn.db") {
     if ((tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER,0640)) &&      if ((tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER(),0640)) &&
  (tie(%parmhash,'GDBM_File',   (tie(%parmhash,'GDBM_File',
      $ENV{'request.course.fn'}.'_parms.db',       $ENV{'request.course.fn'}.'_parms.db',
      &GDBM_READER,0640))) {       &GDBM_READER(),0640))) {
  $hashtied=1;   $hashtied=1;
     }      }
  }   }
Line 433  sub handler { Line 438  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 455  sub handler { Line 462  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 465  sub handler { Line 472  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 488  sub handler { Line 500  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 566  sub handler { Line 572  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 584  sub handler { Line 593  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 607  sub handler { Line 625  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;
  my $rid=$colcont[$j];   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='<td>';   my $add='<td>';
  my $adde='</td>';   my $adde='</td>';
  my $hwk='<font color="#223322">';   my $hwk='<font color="#223322">';
Line 621  sub handler { Line 646  sub handler {
     $rid=$1;      $rid=$1;
     $add='<th bgcolor="#AAFF55"><a name="'.$rid.'">';      $add='<th bgcolor="#AAFF55"><a name="'.$rid.'">';
     $adde='</th>';      $adde='</th>';
                               if (($ENV{'user.adv'}) && 
    ($parmhash{$symb.'.0.parameter_randompick'})) {
                                  $adde=' (randomly select '.
      $parmhash{$symb.'.0.parameter_randompick'}.
                                      ')</th>';
                               }
  }   }
  if ($rid=~/^j(.+)/) { $rid=$1; }   if ($rid=~/^j(.+)/) { $rid=$1; }
  if ($rid=~/^p(\d)(\d)\"([\w\: \(\)\/\,]*)\"(.+)/) {   if ($rid=~/^p(\d)(\d)\"([\w\: \(\)\/\,]*)\"(.+)/) {
Line 629  sub handler { Line 660  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 659  sub handler { Line 707  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 ($hash{'src_'.$rid} eq $currenturl) {   if ($rid && $hash{'src_'.$rid} eq $currenturl) {
     $add=$add.'<a name="curloc"></a>'.      $add=$add.'<a name="curloc"></a>'.
  '<font color=red size=+2><b>&gt; </b></font>';   '<font color=red size=+2><b>&gt; </b></font>';
     $adde=      $adde=
  '<font color=red size=+2><b> &lt;</b></font>'.$adde;   '<font color=red size=+2><b> &lt;</b></font>'.$adde;
  }   }
  my $src=  
     &Apache::lonnet::declutter($hash{'src_'.$rid});  
  $rid=~/^(\d+)\.(\d+)$/;  
  my $symb=  
     &Apache::lonnet::declutter($hash{'map_id_'.$1}).'___'.$2.'___'.$src;  
  if ($discussiontimes{$symb}>$lastcheck) {   if ($discussiontimes{$symb}>$lastcheck) {
     $adde=      $adde=
  '<img border=0 src="/adm/lonMisc/chat.gif">'.   '<img border=0 src="/adm/lonMisc/chat.gif">'.
Line 703  sub handler { Line 750  sub handler {
     for(my $i=-1;$i<$indent;$i++) { $indentstr.=$is; }      for(my $i=-1;$i<$indent;$i++) { $indentstr.=$is; }
  }   }
  if (!$linkid) { $linkid=$rid; }   if (!$linkid) { $linkid=$rid; }
  $r->print($add.$indentstr.                          if ($hash{'randomout_'.$rid}) {
   '<a href="'.$hash{'src_'.$linkid}.'">'.$hwk.                              $adde=' <i>(hidden)</i>'.$adde;
   $hash{'title_'.$rid}.$hwke.'</a>'.$adde);                          }
    $r->print($add.$indentstr);
    if ($rid) {
       $r->print('<a href="'.$hash{'src_'.$linkid}.
                                         (($hash{'src_'.$linkid}=~/\?/)?'&':'?').
                                         'symb='.&Apache::lonnet::escape($symb)
                                          .'">'.
         $hwk.$hash{'title_'.$rid}.$hwke.'</a>');
    }
    $r->print($adde);
     }      }
     $r->print('</tr>');      $r->print('</tr>');
  }   }

Removed from v.1.32  
changed lines
  Added in v.1.48


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