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

version 1.31, 2002/03/15 23:39:41 version 1.32, 2002/03/16 08:56:53
Line 270  sub astatus { Line 270  sub astatus {
   
   
 sub addresource {  sub addresource {
     my ($resource,$sofar,$rid,$showtypes)=@_;      my ($resource,$sofar,$rid,$showtypes,$indent,$linkid)=@_;
     &Apache::lonxml::debug("Adding $resource allowing $showtypes");  
     if ($showtypes eq 'problems') {      if ($showtypes eq 'problems') {
  if ($resource!~/\.(problem|exam|quiz|assess|survey|form)$/) {   if ($resource!~/\.(problem|exam|quiz|assess|survey|form)$/) {
     &Apache::lonxml::debug("Returning early");  
     return;      return;
  }    }
     }      }
     my $brepriv=&Apache::lonnet::allowed('bre',$resource);      my $brepriv=&Apache::lonnet::allowed('bre',$resource);
     if ($hash{'src_'.$rid}) {      if ($hash{'src_'.$rid}) {
Line 285  sub addresource { Line 283  sub addresource {
     if ($resource=~/\.(problem|exam|quiz|assess|survey|form)$/) {      if ($resource=~/\.(problem|exam|quiz|assess|survey|form)$/) {
  $pprefix=&astatus($rid);   $pprefix=&astatus($rid);
     }      }
     if (defined($rows[$sofar])) {      $$sofar++;
  $rows[$sofar].='&'.$pprefix.$rid;      if ($indent) { $pprefix='i'.$indent.','.$pprefix; }
       if ($linkid) { $pprefix='l'.$linkid.','.$pprefix; }
       if (defined($rows[$$sofar])) {
    $rows[$$sofar].='&'.$pprefix.$rid;
     } else {      } else {
  $rows[$sofar]=$pprefix.$rid;   $rows[$$sofar]=$pprefix.$rid;
     }      }
  }   }
     }      }
 }  }
   
 sub followlinks () {  sub followlinks () {
     my ($rid,$sofar,$beenhere,$further,$showtypes)=@_;      my ($rid,$sofar,$beenhere,$further,$showtypes,$indent,$linkid)=@_;
     my $mincond=1;      my $mincond=1;
     my $next='';      my $next='';
     foreach (split(/\,/,$hash{'to_'.$rid})) {      foreach (split(/\,/,$hash{'to_'.$rid})) {
Line 310  sub followlinks () { Line 311  sub followlinks () {
     if ($thiscond>$mincond) { $mincond=$thiscond; }      if ($thiscond>$mincond) { $mincond=$thiscond; }
  }   }
     }      }
       my $col=0;
       &Apache::lonxml::debug("following links -$next-");
     foreach (split(/\,/,$next)) {      foreach (split(/\,/,$next)) {
  my ($linkid,$condval)=split(/\:/,$_);   my ($nextlinkid,$condval)=split(/\:/,$_);
  if ($condval>=$mincond) {   if ($condval>=$mincond) {
     &Apache::lonxml::debug("following link $linkid");      my $now=&tracetable($sofar,$hash{'goesto_'.$nextlinkid},
     my $now=&tracetable($sofar,$hash{'goesto_'.$linkid},   $beenhere,$showtypes,$indent,$linkid);
  $beenhere,$showtypes);      if ($now>$further) {
     if ($now>$further) { $further=$now; }   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;
       }
  }   }
    $col++;
     }      }
     return $further;      return $further;
 }  }
 # ------------------------------------------------------------ Build page table  # ------------------------------------------------------------ Build page table
   
 sub tracetable {  sub tracetable {
     my ($sofar,$rid,$beenhere,$showtypes)=@_;      my ($sofar,$rid,$beenhere,$showtypes,$indent,$linkid)=@_;
       my $newshowtypes=$showtypes;
       my $newlinkid=$linkid;
     my $further=$sofar;      my $further=$sofar;
     #$Apache::lonxml::debug=1;      #$Apache::lonxml::debug=1;
     &Apache::lonxml::debug("$rid ; $sofar ; $beenhere");      &Apache::lonxml::debug("$rid ; $linkid ; $sofar ; $beenhere ; ".$hash{'src_'.$rid});
     if ($beenhere=~/\&$rid\&/) {      if ($beenhere=~/\&$rid\&/) { return $further; }
  return $further;      $beenhere.=$rid.'&';
     }  
     $beenhere.=$rid.'&';    
   
     if (defined($hash{'is_map_'.$rid})) {      if (defined($hash{'is_map_'.$rid})) {
  $sofar++;   $sofar++;
Line 341  sub tracetable { Line 353  sub tracetable {
     $tprefix='h';      $tprefix='h';
  } elsif ($hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$rid}}}   } elsif ($hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$rid}}}
  eq 'page') {   eq 'page') {
     $tprefix='i';      $tprefix='j';
     $showtypes='problems';      if ($indent) { $tprefix='i'.$indent.','.$tprefix; }
       $newshowtypes='problems';
       $indent++;
       $newlinkid=$rid;
  }   }
  if (defined($rows[$sofar])) {   if (defined($rows[$sofar])) {
     $rows[$sofar].='&'.$tprefix.$rid;      $rows[$sofar].='&'.$tprefix.$rid;
Line 352  sub tracetable { Line 367  sub tracetable {
  if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) &&   if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) &&
     (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,      $sofar=&tracetable($sofar,$hash{'map_start_'.$hash{'src_'.$rid}},
        $hash{'map_start_'.$hash{'src_'.$rid}},         '&'.$frid.'&',$newshowtypes,$indent,$newlinkid);
        '&'.$frid.'&',$showtypes);      &addresource($hash{'src_'.$frid},\$sofar,$frid,$newshowtypes,
     $sofar++;   $indent,$newlinkid);
     &addresource($hash{'src_'.$frid},$sofar,$frid,$showtypes);      if ($tprefix =~ /j$/) { $indent--; }
     if ($tprefix eq 'i') { $showtypes=''; }  
  }   }
     } else {      } else {
  $sofar++;   &addresource($hash{'src_'.$rid},\$sofar,$rid,$showtypes,
  &addresource($hash{'src_'.$rid},$sofar,$rid,$showtypes);       $indent,$linkid);
     }      }
   
     if (defined($hash{'to_'.$rid})) {      if (defined($hash{'to_'.$rid})) {
  $further=&followlinks($rid,$sofar,$beenhere,$further,$showtypes);   $further=&followlinks($rid,$sofar,$beenhere,$further,$showtypes,
         $indent,$linkid);
     }      }
   
     return $further;      return $further;
Line 473  sub handler { Line 488  sub handler {
   
  @rows=();   @rows=();
   
  &tracetable(0,$firstres,'&'.$lastres.'&');   &tracetable(0,$firstres,'&'.$lastres.'&','',0);
  if ($hash{'src_'.$lastres}) {   if ($hash{'src_'.$lastres}) {
     my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$lastres});      my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$lastres});
     if (($brepriv eq '2') || ($brepriv eq 'F')) {      if (($brepriv eq '2') || ($brepriv eq 'F')) {
Line 492  sub handler { Line 507  sub handler {
   
  for ($i=0;$i<=$#rows;$i++) {   for ($i=0;$i<=$#rows;$i++) {
     if ($rows[$i]) {      if ($rows[$i]) {
  &Apache::lonxml::debug($rows[$i]);   &Apache::lonxml::debug("Row $i is:".$rows[$i]);
  $contents++;   $contents++;
  my @colcont=split(/\&/,$rows[$i]);   my @colcont=split(/\&/,$rows[$i]);
  $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1));   $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1));
Line 593  sub handler { Line 608  sub handler {
     my @colcont=split(/\&/,$rows[$i]);      my @colcont=split(/\&/,$rows[$i]);
     my $avespan=$lcm/($#colcont+1);      my $avespan=$lcm/($#colcont+1);
     for ($j=0;$j<=$#colcont;$j++) {      for ($j=0;$j<=$#colcont;$j++) {
    my $indent;my $indentstr;
    my $linkid;
  my $rid=$colcont[$j];   my $rid=$colcont[$j];
  my $add='<td>&nbsp;&nbsp;';   my $add='<td>';
  my $adde='</td>';   my $adde='</td>';
  my $hwk='<font color="#223322">';   my $hwk='<font color="#223322">';
  my $hwke='</font>';   my $hwke='</font>';
    if ($rid=~/^l(\d+\.\d+),(.+)/) { $linkid=$1; $rid=$2; }
    if ($rid=~/^i(\d+),(.+)/) { $indent=$1; $rid=$2; }
  if ($rid=~/^h(.+)/) {   if ($rid=~/^h(.+)/) {
     $rid=$1;      $rid=$1;
     $add='<th bgcolor="#AAFF55"><a name="'.$rid.'">';      $add='<th bgcolor="#AAFF55"><a name="'.$rid.'">';
     $adde='</th>';      $adde='</th>';
  }   }
  if ($rid=~/^i(.+)/) { $rid=$1; }   if ($rid=~/^j(.+)/) { $rid=$1; }
  if ($rid=~/^p(\d)(\d)\"([\w\: \(\)\/\,]*)\"(.+)/) {   if ($rid=~/^p(\d)(\d)\"([\w\: \(\)\/\,]*)\"(.+)/) {
     # sub astatus describes what code/tcode mean      # sub astatus describes what code/tcode mean
     my $code=$1;      my $code=$1;
Line 679  sub handler { Line 698  sub handler {
  }   }
     }      }
  }   }
  $r->print($add.'<a href="'.$hash{'src_'.$rid}.   if ($indent) {
   '">'.$hwk.      my $is="&nbsp;&nbsp;";
       for(my $i=-1;$i<$indent;$i++) { $indentstr.=$is; }
    }
    if (!$linkid) { $linkid=$rid; }
    $r->print($add.$indentstr.
     '<a href="'.$hash{'src_'.$linkid}.'">'.$hwk.
   $hash{'title_'.$rid}.$hwke.'</a>'.$adde);    $hash{'title_'.$rid}.$hwke.'</a>'.$adde);
     }      }
     $r->print('</tr>');      $r->print('</tr>');

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


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