File:  [LON-CAPA] / loncom / interface / lonnavmaps.pm
Revision 1.21: download - view: text, annotated - select for diffs
Tue Jan 1 16:02:28 2002 UTC (22 years, 5 months ago) by www
Branches: MAIN
CVS tags: HEAD
Discussion check

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

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