Annotation of loncom/interface/lonnavmaps.pm, revision 1.15

1.2       www         1: # The LearningOnline Network with CAPA
                      2: # Navigate Maps Handler
1.1       www         3: #
1.2       www         4: # (Page Handler
1.1       www         5: #
1.2       www         6: # (TeX Content Handler
1.1       www         7: #
1.2       www         8: # 05/29/00,05/30 Gerd Kortemeyer)
                      9: # 08/30,08/31,09/06,09/14,09/15,09/16,09/19,09/20,09/21,09/23,
                     10: # 10/02,10/10,10/14,10/16,10/18,10/19,10/31,11/6,11/14,11/16 Gerd Kortemeyer)
1.1       www        11: #
1.15    ! www        12: # 3/1/1,6/1,17/1,29/1,30/1,2/8,9/21 Gerd Kortemeyer
1.2       www        13: 
1.1       www        14: package Apache::lonnavmaps;
                     15: 
                     16: use strict;
1.2       www        17: use Apache::Constants qw(:common :http);
                     18: use Apache::lonnet();
                     19: use HTML::TokeParser;
                     20: use GDBM_File;
                     21: 
                     22: # -------------------------------------------------------------- Module Globals
                     23: my %hash;
                     24: my @rows;
                     25: 
1.10      www        26: #
                     27: # These cache hashes need to be independent of user, resource and course
                     28: # (user and course can/should be in the keys)
                     29: #
                     30: 
                     31: my %courserdatas;
                     32: my %userrdatas;
                     33: 
                     34: #
                     35: # These global hashes are dependent on user, course and resource, 
                     36: # and need to be initialized every time when a sheet is calculated
                     37: #
                     38: my %courseopt;
                     39: my %useropt;
                     40: my %parmhash;
                     41: 
                     42: 
1.2       www        43: # ------------------------------------------------------------------ Euclid gcd
                     44: 
                     45: sub euclid {
                     46:     my ($e,$f)=@_;
                     47:     my $a; my $b; my $r;
                     48:     if ($e>$f) { $b=$e; $r=$f; } else { $r=$e; $b=$f; }
                     49:     while ($r!=0) {
                     50: 	$a=$b; $b=$r;
                     51:         $r=$a%$b;
                     52:     }
                     53:     return $b;
                     54: }
                     55: 
1.10      www        56: # --------------------------------------------------------------------- Parmval
                     57: 
                     58: # -------------------------------------------- Figure out a cascading parameter
                     59: #
                     60: # For this function to work
                     61: #
                     62: # * parmhash needs to be tied
                     63: # * courseopt and useropt need to be initialized for this user and course
                     64: #
                     65: 
                     66: sub parmval {
                     67:     my ($what,$symb)=@_;
                     68:     my $cid=$ENV{'request.course.id'};
                     69:     my $csec=$ENV{'request.course.sec'};
                     70:     my $uname=$ENV{'user.name'};
                     71:     my $udom=$ENV{'user.domain'};
                     72: 
                     73:     unless ($symb) { return ''; }
                     74:     my $result='';
                     75: 
                     76:     my ($mapname,$id,$fn)=split(/\_\_\_/,$symb);
                     77: 
                     78: # ----------------------------------------------------- Cascading lookup scheme
                     79:        my $rwhat=$what;
                     80:        $what=~s/^parameter\_//;
                     81:        $what=~s/\_/\./;
                     82: 
                     83:        my $symbparm=$symb.'.'.$what;
                     84:        my $mapparm=$mapname.'___(all).'.$what;
                     85:        my $usercourseprefix=$uname.'_'.$udom.'_'.$cid;
                     86: 
                     87:        my $seclevel=
                     88:             $usercourseprefix.'.['.
                     89: 		$csec.'].'.$what;
                     90:        my $seclevelr=
                     91:             $usercourseprefix.'.['.
                     92: 		$csec.'].'.$symbparm;
                     93:        my $seclevelm=
                     94:             $usercourseprefix.'.['.
                     95: 		$csec.'].'.$mapparm;
                     96: 
                     97:        my $courselevel=
                     98:             $usercourseprefix.'.'.$what;
                     99:        my $courselevelr=
                    100:             $usercourseprefix.'.'.$symbparm;
                    101:        my $courselevelm=
                    102:             $usercourseprefix.'.'.$mapparm;
                    103: 
                    104: # ---------------------------------------------------------- fourth, check user
                    105:       
                    106:       if ($uname) { 
                    107: 
                    108:        if ($useropt{$courselevelr}) { return $useropt{$courselevelr}; }
                    109: 
                    110:        if ($useropt{$courselevelm}) { return $useropt{$courselevelm}; }
                    111: 
                    112:        if ($useropt{$courselevel}) { return $useropt{$courselevel}; }
                    113: 
                    114:       }
                    115: 
                    116: # --------------------------------------------------------- third, check course
                    117:      
                    118:        if ($csec) {
                    119:  
                    120:         if ($courseopt{$seclevelr}) { return $courseopt{$seclevelr}; }
                    121: 
                    122:         if ($courseopt{$seclevelm}) { return $courseopt{$seclevelm}; }  
                    123: 
                    124:         if ($courseopt{$seclevel}) { return $courseopt{$seclevel}; }
                    125:   
                    126:       }
                    127: 
                    128:        if ($courseopt{$courselevelr}) { return $courseopt{$courselevelr}; }
                    129: 
                    130:        if ($courseopt{$courselevelm}) { return $courseopt{$courselevelm}; }
                    131: 
                    132:        if ($courseopt{$courselevel}) { return $courseopt{$courselevel}; }
                    133: 
                    134: # ----------------------------------------------------- second, check map parms
                    135: 
                    136:        my $thisparm=$parmhash{$symbparm};
                    137:        if ($thisparm) { return $thisparm; }
                    138: 
                    139: # -------------------------------------------------------- first, check default
                    140: 
                    141:        return &Apache::lonnet::metadata($fn,$rwhat.'.default');
                    142:         
                    143: }
                    144: 
                    145: 
                    146: 
1.9       www       147: # ------------------------------------------------------------- Find out status
                    148: 
                    149: sub astatus {
                    150:     my $rid=shift;
                    151:     my $code=1;
                    152:     my $ctext='';
                    153:     $rid=~/(\d+)\.(\d+)/;
1.10      www       154:     my $symb=&Apache::lonnet::declutter($hash{'map_id_'.$1}).'___'.$2.'___'.
                    155: 	     &Apache::lonnet::declutter($hash{'src_'.$rid});
1.15    ! www       156: 
        !           157:     my %duedate=();
        !           158:     my %opendate=();
        !           159:     my %answerdate=();
        !           160:     map {
        !           161:         if ($_=~/^parameter\_(.*)\_opendate$/) {
        !           162: 	    my $part=$1;
        !           163:             $duedate{$part}=&parmval($part.'.duedate',$symb);
        !           164:             $opendate{$part}=&parmval($part.'.opendate',$symb);
        !           165:             $answerdate{$part}=&parmval($part.'.answerdate',$symb);
        !           166:         }
        !           167:     } sort split(/\,/,&Apache::lonnet::metadata($hash{'src_'.$rid},'keys'));
        !           168: 
1.10      www       169:     my $duedate=&parmval('0.duedate',$symb);
1.11      www       170:     my $opendate=&parmval('0.opendate',$symb);
                    171:     my $answerdate=&parmval('0.answerdate',$symb);
                    172:     my $now=time;
                    173:     my $tcode=0;
1.12      www       174:    if ($opendate) {
1.11      www       175:     if ($now<$duedate) {
                    176:         $tcode=2; 
                    177:         $ctext='Due: '.localtime($duedate);
                    178:         if ($now<$opendate) { 
                    179:           $tcode=1; 
                    180:           $ctext='Open: '.localtime($opendate);
                    181:         }
                    182:         if ($duedate-$now<86400) {
                    183: 	   $tcode=4;
                    184:            $ctext='Due: '.localtime($duedate);
                    185:         }
                    186:      } else {
                    187:        $tcode=3;
                    188:        if ($now<$answerdate) {  
                    189:           $ctext='Answer: '.localtime($duedate);
                    190:        }
1.10      www       191:     }
1.12      www       192:    } else {
                    193:     $tcode=1;
                    194:    }
1.9       www       195:     my $answer=&Apache::lonnet::reply(
                    196:               "restore:$ENV{'user.domain'}:$ENV{'user.name'}:".
1.10      www       197:               $ENV{'request.course.id'}.':'.
                    198:               &Apache::lonnet::escape($symb),
1.9       www       199:               "$ENV{'user.home'}");
                    200:     my %returnhash=();
                    201:     map {
                    202: 	my ($name,$value)=split(/\=/,$_);
                    203:         $returnhash{&Apache::lonnet::unescape($name)}=
                    204:                     &Apache::lonnet::unescape($value);
                    205:     } split(/\&/,$answer);
                    206:     if ($returnhash{'version'}) {
                    207:        my $version;
                    208:        for ($version=1;$version<=$returnhash{'version'};$version++) {
                    209:           map {
                    210:              $returnhash{$_}=$returnhash{$version.':'.$_};
                    211:           } split(/\:/,$returnhash{$version.':keys'});
                    212:        }
                    213:        map {
                    214:            if (($_=~/\.(\w+)\.solved$/) && ($_!~/^\d+\:/)) {
                    215:                my $part=$1;
1.10      www       216:                if ($ctext) { $ctext.=', '; }
                    217:                if ($part) {
                    218: 		   $ctext.='Part '.$part.': ';
                    219:                }
1.9       www       220: 	       if ($returnhash{$_} eq 'correct_by_student') {
                    221:                    unless ($code==2) { $code=3; }
1.10      www       222:                    $ctext.='solved';
1.9       www       223:                } elsif ($returnhash{$_} eq 'correct_by_override') {
                    224:                    unless ($code==2) { $code=3; }
1.10      www       225:                    $ctext.='override';
1.9       www       226:                } elsif ($returnhash{$_} eq 'incorrect_attempted') {
                    227:                    $code=2;
1.10      www       228:                    $ctext.=
1.11      www       229:                      $returnhash{'resource.'.$part.'.tries'}.'/'.
                    230:                      &parmval($part.'.maxtries',$symb).' tries';
1.9       www       231:                } elsif ($returnhash{$_} eq 'incorrect_by_override') {
                    232:                    $code=2;
1.10      www       233:                    $ctext.='override';
1.9       www       234:                } elsif ($returnhash{$_} eq 'excused') {
                    235:                    unless ($code==2) { $code=3; }
1.10      www       236:                    $ctext.='excused';
1.9       www       237:                }
                    238:            }
                    239:        } keys %returnhash;
                    240:     }
1.11      www       241:     return 'p'.$code.$tcode.'"'.$ctext.'"';
1.9       www       242: }
                    243: 
1.2       www       244: # ------------------------------------------------------------ Build page table
                    245: 
                    246: sub tracetable {
                    247:     my ($sofar,$rid,$beenhere)=@_;
                    248:     my $further=$sofar;
                    249:     unless ($beenhere=~/\&$rid\&/) {
                    250:        $beenhere.=$rid.'&';  
                    251: 
                    252:        if (defined($hash{'is_map_'.$rid})) {
1.7       www       253:            $sofar++;
                    254:            my $tprefix='';
                    255:            if ($hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$rid}}} 
                    256:             eq 'sequence') { 
                    257:                $tprefix='h'; 
                    258:            }
1.6       www       259:            if (defined($rows[$sofar])) {
1.7       www       260:               $rows[$sofar].='&'.$tprefix.$rid;
1.6       www       261:            } else {
1.7       www       262:               $rows[$sofar]=$tprefix.$rid;
1.6       www       263:            }
1.2       www       264:            if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) &&
1.7       www       265:                (defined($hash{'map_finish_'.$hash{'src_'.$rid}})) &&
                    266:                ($tprefix eq 'h')) {
1.2       www       267:               my $frid=$hash{'map_finish_'.$hash{'src_'.$rid}};
                    268: 	      $sofar=
                    269:                 &tracetable($sofar,$hash{'map_start_'.$hash{'src_'.$rid}},
                    270:                 '&'.$frid.'&');
                    271:               $sofar++;
                    272:               if ($hash{'src_'.$frid}) {
                    273:                my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$frid});
                    274:                if (($brepriv eq '2') || ($brepriv eq 'F')) {
1.7       www       275: 		 my $pprefix='';
1.9       www       276:                  if ($hash{'src_'.$frid}=~
                    277:                                  /\.(problem|exam|quiz|assess|survey|form)$/) {
                    278: 		     $pprefix=&astatus($frid);
                    279: 
1.7       www       280:                  }
1.2       www       281:                  if (defined($rows[$sofar])) {
1.7       www       282:                    $rows[$sofar].='&'.$pprefix.$frid;
1.2       www       283:                  } else {
1.7       www       284:                    $rows[$sofar]=$pprefix.$frid;
1.2       www       285:                  }
                    286: 	       }
                    287: 	      }
                    288: 	   }
                    289:        } else {
                    290:           $sofar++;
                    291:           if ($hash{'src_'.$rid}) {
                    292:            my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$rid});
                    293:            if (($brepriv eq '2') || ($brepriv eq 'F')) {
1.7       www       294: 	     my $pprefix='';
1.9       www       295:              if ($hash{'src_'.$rid}=~
                    296:                                  /\.(problem|exam|quiz|assess|survey|form)$/) {
                    297: 	         $pprefix=&astatus($rid);
1.7       www       298:              }
1.2       www       299:              if (defined($rows[$sofar])) {
1.7       www       300:                 $rows[$sofar].='&'.$pprefix.$rid;
1.2       www       301:              } else {
1.7       www       302:                $rows[$sofar]=$pprefix.$rid;
1.2       www       303:              }
                    304: 	   }
                    305:           }
                    306:        }
                    307: 
                    308:        if (defined($hash{'to_'.$rid})) {
                    309: 	  my $mincond=1;
                    310:           my $next='';
                    311:           map {
                    312:               my $thiscond=
                    313:       &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$_}});
                    314:               if ($thiscond>=$mincond) {
                    315: 		  if ($next) {
                    316: 		      $next.=','.$_.':'.$thiscond;
                    317:                   } else {
                    318:                       $next=$_.':'.$thiscond;
                    319: 		  }
                    320:                   if ($thiscond>$mincond) { $mincond=$thiscond; }
                    321: 	      }
                    322:           } split(/\,/,$hash{'to_'.$rid});
                    323:           map {
                    324:               my ($linkid,$condval)=split(/\:/,$_);
                    325:               if ($condval>=$mincond) {
                    326:                 my $now=&tracetable($sofar,$hash{'goesto_'.$linkid},$beenhere);
                    327:                 if ($now>$further) { $further=$now; }
                    328: 	      }
                    329:           } split(/\,/,$next);
                    330: 
                    331:        }
                    332:     }
                    333:     return $further;
                    334: }
                    335: 
                    336: # ================================================================ Main Handler
1.1       www       337: 
                    338: sub handler {
1.2       www       339:   my $r=shift;
                    340: 
                    341: 
                    342: # ------------------------------------------- Set document type for header only
                    343: 
                    344:   if ($r->header_only) {
                    345:        if ($ENV{'browser.mathml'}) {
                    346:            $r->content_type('text/xml');
                    347:        } else {
                    348:            $r->content_type('text/html');
                    349:        }
                    350:        $r->send_http_header;
                    351:        return OK;
                    352:    }
                    353: 
                    354:   my $requrl=$r->uri;
                    355: # ----------------------------------------------------------------- Tie db file
                    356:   if ($ENV{'request.course.fn'}) {
                    357:       my $fn=$ENV{'request.course.fn'};
                    358:       if (-e "$fn.db") {
1.10      www       359:           if ((tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER,0640)) &&
                    360:              (tie(%parmhash,'GDBM_File',
                    361:            $ENV{'request.course.fn'}.'_parms.db',&GDBM_READER,0640))) {
1.2       www       362: # ------------------------------------------------------------------- Hash tied
                    363:               my $firstres=$hash{'map_start_/res/'.$ENV{'request.course.uri'}};
                    364:               my $lastres=$hash{'map_finish_/res/'.$ENV{'request.course.uri'}};
                    365:               if (($firstres) && ($lastres)) {
                    366: # ----------------------------------------------------------------- Render page
1.10      www       367: # -------------------------------------------------------------- Set parameters
                    368: 
                    369: 
                    370: # ---------------------------- initialize coursedata and userdata for this user
                    371:     undef %courseopt;
                    372:     undef %useropt;
                    373: 
                    374:     my $uname=$ENV{'user.name'};
                    375:     my $udom=$ENV{'user.domain'};
                    376:     my $uhome=$ENV{'user.home'};
                    377:     my $cid=$ENV{'request.course.id'};
                    378:     my $chome=$ENV{'course.'.$cid.'.home'};
                    379:     my ($cdom,$cnum)=split(/\_/,$cid);
                    380: 
                    381:     my $userprefix=$uname.'_'.$udom.'_';
                    382: 
                    383:     unless ($uhome eq 'no_host') { 
                    384: # -------------------------------------------------------------- Get coursedata
                    385:       unless
                    386:         ((time-$courserdatas{$cid.'.last_cache'})<240) {
                    387:          my $reply=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum.
                    388:               ':resourcedata',$chome);
                    389:          if ($reply!~/^error\:/) {
                    390:             $courserdatas{$cid}=$reply;
                    391:             $courserdatas{$cid.'.last_cache'}=time;
                    392:          }
                    393:       }
                    394:       map {
                    395:          my ($name,$value)=split(/\=/,$_);
                    396:          $courseopt{$userprefix.&Apache::lonnet::unescape($name)}=
                    397:                     &Apache::lonnet::unescape($value);
                    398:       } split(/\&/,$courserdatas{$cid});
                    399: # --------------------------------------------------- Get userdata (if present)
                    400:       unless
                    401:         ((time-$userrdatas{$uname.'___'.$udom.'.last_cache'})<240) {
                    402:          my $reply=
                    403:        &Apache::lonnet::reply('dump:'.$udom.':'.$uname.':resourcedata',$uhome);
                    404:          if ($reply!~/^error\:/) {
                    405: 	     $userrdatas{$uname.'___'.$udom}=$reply;
                    406: 	     $userrdatas{$uname.'___'.$udom.'.last_cache'}=time;
                    407:          }
                    408:       }
                    409:       map {
                    410:          my ($name,$value)=split(/\=/,$_);
                    411:          $useropt{$userprefix.&Apache::lonnet::unescape($name)}=
                    412: 	          &Apache::lonnet::unescape($value);
                    413:       } split(/\&/,$userrdatas{$uname.'___'.$udom});
                    414:     }
1.2       www       415: 
                    416:                   @rows=();
                    417: 
                    418:                   &tracetable(0,$firstres,'&'.$lastres.'&');
                    419:                   if ($hash{'src_'.$lastres}) {
                    420:                      my $brepriv=
                    421:                         &Apache::lonnet::allowed('bre',$hash{'src_'.$lastres});
                    422:                      if (($brepriv eq '2') || ($brepriv eq 'F')) {
                    423:                         $rows[$#rows+1]=''.$lastres;
                    424: 		     }
                    425: 		  }
                    426: 
                    427: # ------------------------------------------------------------------ Page parms
                    428: 
                    429:                   my $j;
1.5       www       430:                   my $i;
1.2       www       431:                   my $lcm=1;
                    432:                   my $contents=0;
                    433: 
                    434: # ---------------------------------------------- Go through table to get layout
                    435: 
                    436:                   for ($i=0;$i<=$#rows;$i++) {
                    437: 		     if ($rows[$i]) {
                    438: 		      $contents++;
                    439:                       my @colcont=split(/\&/,$rows[$i]);
                    440:                       $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1));
                    441:                      } 
                    442:                   }
1.5       www       443: 
1.2       www       444: 
                    445:                   unless ($contents) {
                    446:                       $r->content_type('text/html');
                    447:                       $r->send_http_header;
                    448:                       $r->print('<html><body>Empty Map.</body></html>');
                    449:                   } else {
1.10      www       450: 
1.2       www       451: # ------------------------------------------------------------------ Build page
                    452: 
1.13      www       453: 		      my $currenturl=$ENV{'form.postdata'};
                    454:                       $currenturl=~s/^http\:\/\///;
                    455:                       $currenturl=~s/^[^\/]+//;
                    456: 
1.2       www       457: # ---------------------------------------------------------------- Send headers
                    458: 
                    459:                           $r->content_type('text/html');
                    460:                           $r->send_http_header;
                    461:                           $r->print(
                    462:                    '<html><head><title>Navigate LON-CAPA Maps</title></head>');
                    463: 
1.13      www       464: 			  $r->print('<body bgcolor="#FFFFFF"');
1.14      www       465:                           if (($currenturl=~/^\/res/) &&
                    466:                               ($currenturl!~/^\/res\/adm/)) {
1.13      www       467:                              $r->print(' onLoad="window.location.hash='.
                    468: 				       "'curloc'".'"');
                    469: 			  }
                    470:                           $r->print('><script>window.focus();</script>'.
1.6       www       471:                            '<img align=right src=/adm/lonIcons/lonlogos.gif>'.
1.2       www       472:                                     '<h1>Navigate Course Map</h1>');
1.13      www       473: 		      $r->rflush();
1.14      www       474:                       if (($currenturl=~/^\/res/) &&
                    475:                           ($currenturl!~/^\/res\/adm/)) {
1.13      www       476: 		       $r->print('<a href="#curloc">Current Location</a><p>');
                    477:                       }
                    478: # ----------------------------------------------------- The little content list
                    479:                       for ($i=0;$i<=$#rows;$i++) {
                    480: 			if ($rows[$i]) {
                    481:                           my @colcont=split(/\&/,$rows[$i]);
                    482:                           my $avespan=$lcm/($#colcont+1);
                    483:                           for ($j=0;$j<=$#colcont;$j++) {
                    484:                               my $rid=$colcont[$j];
                    485:                               if ($rid=~/^h(.+)/) {
                    486: 				  $rid=$1;
                    487:                                   $r->print(
                    488:      '&nbsp;&nbsp;&nbsp;<a href="#'.$rid.'">'.$hash{'title_'.$rid}.'</a><br>');
                    489:                               }
                    490:                           }
                    491: 		        }
                    492:                       }
1.2       www       493: # ----------------------------------------------------------------- Start table
1.14      www       494:                       $r->print('<hr><table cols="'.$lcm.'" border="0">');
1.2       www       495:                       for ($i=0;$i<=$#rows;$i++) {
                    496: 			if ($rows[$i]) {
                    497:                           $r->print("\n<tr>");
                    498:                           my @colcont=split(/\&/,$rows[$i]);
                    499:                           my $avespan=$lcm/($#colcont+1);
                    500:                           for ($j=0;$j<=$#colcont;$j++) {
                    501:                               my $rid=$colcont[$j];
1.6       www       502:                               my $add='<td>&nbsp;&nbsp;';
1.7       www       503:                               my $adde='</td>';
                    504:                               my $hwk='<font color="#223322">';
                    505:                               my $hwke='</font>';
1.6       www       506:                               if ($rid=~/^h(.+)/) {
                    507: 				  $rid=$1;
1.13      www       508:                                   $add=
                    509:                                    '<th bgcolor="#AAFF55"><a name="'.$rid.'">';
1.7       www       510:                                   $adde='</th>';
                    511:                               }
1.11      www       512:                             if ($rid=~/^p(\d)(\d)\"([\w\: \(\)\/\,]*)\"(.+)/) {
1.7       www       513:                                   my $code=$1;
1.11      www       514:                                   my $tcode=$2;
                    515:                                   my $ctext=$3;
                    516:                                   $rid=$4;
                    517:                                   if ($tcode eq '1') {
                    518:                                      $add='<td bgcolor="#AAAAAA">';
                    519:                                   }
                    520:                                   if ($code eq '3') {
                    521:                                      $add='<td bgcolor="#AAFFAA">';
                    522: 				  } else {
                    523:                                       $add='<td bgcolor="#FFAAAA">';
                    524: 				      if ($tcode eq '2') {
                    525:                                          $add='<td bgcolor="#FFFFAA">';
                    526:                                       }
                    527:                                       if ($tcode eq '4') {
                    528:                                          $add='<td bgcolor="#FFFF33"><blink>';
                    529:                                          $adde='</blink></td>';
                    530:                                       }
                    531:                                   }
1.9       www       532:                                   $hwk='<font color="#888811"><b>';
                    533:                                   $hwke='</b></font>';
1.10      www       534:                                   if ($code eq '1') {
                    535:                                      $hwke='</b> ('.$ctext.')</font>';
                    536:                                   }
1.7       www       537:                                   if ($code eq '2') {
1.9       www       538:                                      $hwk='<font color="#992222"><b>';
                    539:                                      $hwke='</b> ('.$ctext.')</font>';
1.7       www       540:                                   }
                    541:                                   if ($code eq '3') {
1.9       www       542:                                      $hwk='<font color="#229922"><b>';
                    543:                                      $hwke='</b> ('.$ctext.')</font>';
1.7       www       544:                                   }
1.6       www       545:                               }
1.13      www       546: 			      if ($hash{'src_'.$rid} eq $currenturl) {
                    547:                                   $add=$add.'<a name="curloc"></a>'.
                    548: 				      '<font color=red><b>-&gt; </b></font>';
                    549:                                   $adde=
                    550:                                 '<font color=red><b> &lt;-</b></font>'.$adde;
                    551:                               }
1.7       www       552:                               $r->print($add.'<a href="'.$hash{'src_'.$rid}.
                    553:                                 '">'.$hwk.
                    554:                                 $hash{'title_'.$rid}.$hwke.'</a>'.$adde);
1.2       www       555:                           }
                    556:                           $r->print('</tr>');
                    557: 		        }
                    558:                       }
                    559:                       $r->print("\n</table>");
                    560:                       $r->print('</body></html>');
                    561: # -------------------------------------------------------------------- End page
                    562:                   }                  
                    563: # ------------------------------------------------------------- End render page
                    564:               } else {
                    565:                   $r->content_type('text/html');
                    566:                   $r->send_http_header;
                    567: 		  $r->print('<html><body>Coursemap undefined.</body></html>');
                    568:               }
                    569: # ------------------------------------------------------------------ Untie hash
                    570:               unless (untie(%hash)) {
                    571:                    &Apache::lonnet::logthis("<font color=blue>WARNING: ".
                    572:                        "Could not untie coursemap $fn (browse).</font>"); 
1.10      www       573:               }
                    574:               unless (untie(%parmhash)) {
                    575:                    &Apache::lonnet::logthis("<font color=blue>WARNING: ".
                    576:                        "Could not untie parmhash (browse).</font>"); 
1.2       www       577:               }
                    578: # -------------------------------------------------------------------- All done
                    579: 	      return OK;
                    580: # ----------------------------------------------- Errors, hash could no be tied
                    581:           }
                    582:       } 
                    583:   }
1.3       www       584: 
1.2       www       585:   $ENV{'user.error.msg'}="$requrl:bre:0:0:Course not initialized";
                    586:   return HTTP_NOT_ACCEPTABLE; 
                    587: }
1.1       www       588: 
                    589: 1;
                    590: __END__
1.2       www       591: 
                    592: 
                    593: 
                    594: 
                    595: 
                    596: 
                    597: 

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