File:  [LON-CAPA] / loncom / interface / lonnavmaps.pm
Revision 1.26: download - view: text, annotated - select for diffs
Thu Feb 14 22:13:36 2002 UTC (22 years, 3 months ago) by harris41
Branches: MAIN
CVS tags: HEAD
map to foreach

    1: # The LearningOnline Network with CAPA
    2: # Navigate Maps Handler
    3: #
    4: # $Id: lonnavmaps.pm,v 1.26 2002/02/14 22:13:36 harris41 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= $usercourseprefix.'.['.$csec.'].'.$what;
  115:     my $seclevelr=$usercourseprefix.'.['.$csec.'].'.$symbparm;
  116:     my $seclevelm=$usercourseprefix.'.['.$csec.'].'.$mapparm;
  117: 
  118:     my $courselevel= $usercourseprefix.'.'.$what;
  119:     my $courselevelr=$usercourseprefix.'.'.$symbparm;
  120:     my $courselevelm=$usercourseprefix.'.'.$mapparm;
  121: 
  122: # ---------------------------------------------------------- first, check user
  123:     if ($uname) {
  124: 	if ($useropt{$courselevelr}) { return $useropt{$courselevelr}; }
  125: 	if ($useropt{$courselevelm}) { return $useropt{$courselevelm}; }
  126: 	if ($useropt{$courselevel}) { return $useropt{$courselevel}; }
  127:     }
  128: 
  129: # ------------------------------------------------------- second, check course
  130:     if ($csec) {
  131: 	if ($courseopt{$seclevelr}) { return $courseopt{$seclevelr}; }
  132:         if ($courseopt{$seclevelm}) { return $courseopt{$seclevelm}; }
  133:         if ($courseopt{$seclevel}) { return $courseopt{$seclevel}; }
  134:     }
  135: 
  136:     if ($courseopt{$courselevelr}) { return $courseopt{$courselevelr}; }
  137:     if ($courseopt{$courselevelm}) { return $courseopt{$courselevelm}; }
  138:     if ($courseopt{$courselevel}) { return $courseopt{$courselevel}; }
  139: 
  140: # ----------------------------------------------------- third, check map parms
  141: 
  142:     my $thisparm=$parmhash{$symbparm};
  143:     if ($thisparm) { return $thisparm; }
  144: 
  145: # ----------------------------------------------------- fourth , check default
  146: 
  147:     my $default=&Apache::lonnet::metadata($fn,$rwhat.'.default');
  148:     if ($default) { return $default}
  149: 
  150: # --------------------------------------------------- fifth , cascade up parts
  151: 
  152:     my ($space,@qualifier)=split(/\./,$rwhat);
  153:     my $qualifier=join('.',@qualifier);
  154:     unless ($space eq '0') {
  155: 	my ($part,$id)=split(/\_/,$space);
  156: 	if ($id) {
  157: 	    my $partgeneral=&parmval($part.".$qualifier",$symb);
  158: 	    if ($partgeneral) { return $partgeneral; }
  159: 	} else {
  160: 	    my $resourcegeneral=&parmval("0.$qualifier",$symb);
  161: 	    if ($resourcegeneral) { return $resourcegeneral; }
  162: 	}
  163:     }
  164:     return '';
  165: }
  166: 
  167: 
  168: 
  169: # ------------------------------------------------------------- Find out status
  170: # return codes
  171: # tcode (timecode)
  172: # 1: will open later
  173: # 2: is open and not past due yet
  174: # 3: is past due date
  175: # 4: due in the next 24 hours
  176: #
  177: # code (curent solved status)
  178: # 1: not attempted
  179: # 2: attempted but wrong, or incorrect by instructor
  180: # 3: solved or correct by instructor
  181: # "excused" needs to be supported, but is not yet. Could be code=4.
  182: sub astatus {
  183:     my $rid=shift;
  184:     my $code=1;
  185:     my $ctext='';
  186:     $rid=~/(\d+)\.(\d+)/;
  187:     my $symb=&Apache::lonnet::declutter($hash{'map_id_'.$1}).'___'.$2.'___'.
  188: 	&Apache::lonnet::declutter($hash{'src_'.$rid});
  189:     $Apache::lonxml::debug=1;
  190:     my %duedate=();
  191:     my %opendate=();
  192:     my %answerdate=();
  193:     # need to always check part 0's open/due/answer status
  194:     foreach (sort(split(/\,/,&Apache::lonnet::metadata($hash{'src_'.$rid},'keys')))) {
  195:         if ($_=~/^parameter\_(.*)\_opendate$/) {
  196: 	    my $part=$1;
  197:             $duedate{$part}=&parmval($part.'.duedate',$symb);
  198:             $opendate{$part}=&parmval($part.'.opendate',$symb);
  199:             $answerdate{$part}=&parmval($part.'.answerdate',$symb);
  200:         }
  201:     }
  202:     my $now=time;
  203:     my $tcode=0;
  204: 
  205:     my %returnhash=&Apache::lonnet::restore($symb);
  206: 
  207:     foreach (sort(keys(%opendate))) {
  208: 	my $duedate=$duedate{$_};
  209: 	my $opendate=$opendate{$_};
  210: 	my $answerdate=$answerdate{$_};
  211: 	my $preface='';
  212: 	unless ($_ eq '0') { $preface=' Part: '.$_.' '; }
  213: 	if ($opendate) {
  214: 	    if ($now<$duedate || (!$duedate)) {
  215: 		unless ($tcode==4) { $tcode=2; }
  216: 		if ($duedate) {
  217: 		    $ctext.=$preface.'Due: '.localtime($duedate);
  218: 		} else {
  219: 		    $ctext.=$preface.'No Due Date';
  220: 		}
  221: 		if ($now<$opendate) {
  222: 		    unless ($tcode) { $tcode=1; }
  223: 		    $ctext.=$preface.'Open: '.localtime($opendate);
  224: 		}
  225: 		if ($duedate && $duedate-$now<86400) {
  226: 		    $tcode=4;
  227: 		    $ctext.=$preface.'Due: '.localtime($duedate);
  228: 		}
  229: 	    } else {
  230: 		unless (($tcode==4) || ($tcode eq 2)) { $tcode=3; }
  231: 		if ($now<$answerdate) {
  232: 		    $ctext.='Answer: '.localtime($duedate);
  233: 		}
  234: 	    }
  235: 	} else {
  236: 	    unless (($tcode==2) || ($tcode==4)) { $tcode=1; }
  237: 	}
  238: 	
  239: 	my $status=$returnhash{'resource.'.$_.'.solved'};
  240: 	
  241: 	if ($status eq 'correct_by_student') {
  242: 	    unless ($code==2) { $code=3; }
  243: 	    $ctext.=' solved';
  244: 	} elsif ($status eq 'correct_by_override') {
  245: 	    unless ($code==2) { $code=3; }
  246: 	    $ctext.=' override';
  247: 	} elsif ($status eq 'incorrect_attempted') {
  248: 	    $code=2;
  249: 	    $ctext.=' ('.
  250: 		($returnhash{'resource.'.$_.'.tries'}?
  251: 		 $returnhash{'resource.'.$_.'.tries'}:'0');
  252: 	    my $numtries = &parmval($_.'.maxtries',$symb);
  253: 	    if ($numtries) { $ctext.='/'.$numtries.' tries'; }
  254: 	    $ctext.=')';
  255: 	} elsif ($status eq 'incorrect_by_override') {
  256: 	    $code=2;
  257: 	    $ctext.=' override';
  258: 	} elsif ($status eq 'excused') {
  259: 	    unless ($code==2) { $code=3; }
  260: 	    $ctext.=' excused';
  261: 	}
  262:     }
  263: 
  264:     return 'p'.$code.$tcode.'"'.$ctext.'"';
  265: }
  266: 
  267: # ------------------------------------------------------------ Build page table
  268: 
  269: sub tracetable {
  270:     my ($sofar,$rid,$beenhere)=@_;
  271:     my $further=$sofar;
  272:     unless ($beenhere=~/\&$rid\&/) {
  273:        $beenhere.=$rid.'&';  
  274: 
  275:        if (defined($hash{'is_map_'.$rid})) {
  276:            $sofar++;
  277:            my $tprefix='';
  278:            if ($hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$rid}}} 
  279:             eq 'sequence') { 
  280:                $tprefix='h'; 
  281:            }
  282:            if (defined($rows[$sofar])) {
  283:               $rows[$sofar].='&'.$tprefix.$rid;
  284:            } else {
  285:               $rows[$sofar]=$tprefix.$rid;
  286:            }
  287:            if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) &&
  288:                (defined($hash{'map_finish_'.$hash{'src_'.$rid}})) &&
  289:                ($tprefix eq 'h')) {
  290:               my $frid=$hash{'map_finish_'.$hash{'src_'.$rid}};
  291: 	      $sofar=
  292:                 &tracetable($sofar,$hash{'map_start_'.$hash{'src_'.$rid}},
  293:                 '&'.$frid.'&');
  294:               $sofar++;
  295:               if ($hash{'src_'.$frid}) {
  296:                my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$frid});
  297:                if (($brepriv eq '2') || ($brepriv eq 'F')) {
  298: 		 my $pprefix='';
  299:                  if ($hash{'src_'.$frid}=~
  300:                                  /\.(problem|exam|quiz|assess|survey|form)$/) {
  301: 		     $pprefix=&astatus($frid);
  302: 
  303:                  }
  304:                  if (defined($rows[$sofar])) {
  305:                    $rows[$sofar].='&'.$pprefix.$frid;
  306:                  } else {
  307:                    $rows[$sofar]=$pprefix.$frid;
  308:                  }
  309: 	       }
  310: 	      }
  311: 	   }
  312:        } else {
  313:           $sofar++;
  314:           if ($hash{'src_'.$rid}) {
  315:            my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$rid});
  316:            if (($brepriv eq '2') || ($brepriv eq 'F')) {
  317: 	     my $pprefix='';
  318:              if ($hash{'src_'.$rid}=~
  319:                                  /\.(problem|exam|quiz|assess|survey|form)$/) {
  320: 	         $pprefix=&astatus($rid);
  321:              }
  322:              if (defined($rows[$sofar])) {
  323:                 $rows[$sofar].='&'.$pprefix.$rid;
  324:              } else {
  325:                $rows[$sofar]=$pprefix.$rid;
  326:              }
  327: 	   }
  328:           }
  329:        }
  330: 
  331:        if (defined($hash{'to_'.$rid})) {
  332: 	  my $mincond=1;
  333:           my $next='';
  334:           foreach (split(/\,/,$hash{'to_'.$rid})) {
  335:               my $thiscond=
  336:       &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$_}});
  337:               if ($thiscond>=$mincond) {
  338: 		  if ($next) {
  339: 		      $next.=','.$_.':'.$thiscond;
  340:                   } else {
  341:                       $next=$_.':'.$thiscond;
  342: 		  }
  343:                   if ($thiscond>$mincond) { $mincond=$thiscond; }
  344: 	      }
  345:           }
  346:           foreach (split(/\,/,$next)) {
  347:               my ($linkid,$condval)=split(/\:/,$_);
  348:               if ($condval>=$mincond) {
  349:                 my $now=&tracetable($sofar,$hash{'goesto_'.$linkid},$beenhere);
  350:                 if ($now>$further) { $further=$now; }
  351: 	      }
  352:           }
  353: 
  354:        }
  355:     }
  356:     return $further;
  357: }
  358: 
  359: # ================================================================ Main Handler
  360: 
  361: sub handler {
  362:   my $r=shift;
  363: 
  364: 
  365: # ------------------------------------------- Set document type for header only
  366: 
  367:   if ($r->header_only) {
  368:        if ($ENV{'browser.mathml'}) {
  369:            $r->content_type('text/xml');
  370:        } else {
  371:            $r->content_type('text/html');
  372:        }
  373:        $r->send_http_header;
  374:        return OK;
  375:    }
  376:   my $requrl=$r->uri;
  377: # ----------------------------------------------------------------- Tie db file
  378:   if ($ENV{'request.course.fn'}) {
  379:       my $fn=$ENV{'request.course.fn'};
  380:       if (-e "$fn.db") {
  381:           if ((tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER,0640)) &&
  382:              (tie(%parmhash,'GDBM_File',
  383:            $ENV{'request.course.fn'}.'_parms.db',&GDBM_READER,0640))) {
  384: # ------------------------------------------------------------------- Hash tied
  385:               my $firstres=$hash{'map_start_/res/'.$ENV{'request.course.uri'}};
  386:               my $lastres=$hash{'map_finish_/res/'.$ENV{'request.course.uri'}};
  387:               if (($firstres) && ($lastres)) {
  388: # ----------------------------------------------------------------- Render page
  389: # -------------------------------------------------------------- Set parameters
  390: 
  391: 
  392: # ---------------------------- initialize coursedata and userdata for this user
  393:     undef %courseopt;
  394:     undef %useropt;
  395: 
  396:     my $uname=$ENV{'user.name'};
  397:     my $udom=$ENV{'user.domain'};
  398:     my $uhome=$ENV{'user.home'};
  399:     my $cid=$ENV{'request.course.id'};
  400:     my $chome=$ENV{'course.'.$cid.'.home'};
  401:     my ($cdom,$cnum)=split(/\_/,$cid);
  402: 
  403:     my $userprefix=$uname.'_'.$udom.'_';
  404: 
  405:     unless ($uhome eq 'no_host') { 
  406: # -------------------------------------------------------------- Get coursedata
  407:       unless
  408:         ((time-$courserdatas{$cid.'.last_cache'})<240) {
  409:          my $reply=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum.
  410:               ':resourcedata',$chome);
  411:          if ($reply!~/^error\:/) {
  412:             $courserdatas{$cid}=$reply;
  413:             $courserdatas{$cid.'.last_cache'}=time;
  414:          }
  415:       }
  416:       foreach (split(/\&/,$courserdatas{$cid})) {
  417:          my ($name,$value)=split(/\=/,$_);
  418:          $courseopt{$userprefix.&Apache::lonnet::unescape($name)}=
  419:                     &Apache::lonnet::unescape($value);
  420:       }
  421: # --------------------------------------------------- Get userdata (if present)
  422:       unless
  423:         ((time-$userrdatas{$uname.'___'.$udom.'.last_cache'})<240) {
  424:          my $reply=
  425:        &Apache::lonnet::reply('dump:'.$udom.':'.$uname.':resourcedata',$uhome);
  426:          if ($reply!~/^error\:/) {
  427: 	     $userrdatas{$uname.'___'.$udom}=$reply;
  428: 	     $userrdatas{$uname.'___'.$udom.'.last_cache'}=time;
  429:          }
  430:       }
  431:       foreach (split(/\&/,$userrdatas{$uname.'___'.$udom})) {
  432:          my ($name,$value)=split(/\=/,$_);
  433:          $useropt{$userprefix.&Apache::lonnet::unescape($name)}=
  434: 	          &Apache::lonnet::unescape($value);
  435:       }
  436:     }
  437: 
  438:                   @rows=();
  439: 
  440:                   &tracetable(0,$firstres,'&'.$lastres.'&');
  441:                   if ($hash{'src_'.$lastres}) {
  442:                      my $brepriv=
  443:                         &Apache::lonnet::allowed('bre',$hash{'src_'.$lastres});
  444:                      if (($brepriv eq '2') || ($brepriv eq 'F')) {
  445:                         $rows[$#rows+1]=''.$lastres;
  446: 		     }
  447: 		  }
  448: 
  449: # ------------------------------------------------------------------ Page parms
  450: 
  451:                   my $j;
  452:                   my $i;
  453:                   my $lcm=1;
  454:                   my $contents=0;
  455: 
  456: # ---------------------------------------------- Go through table to get layout
  457: 
  458:                   for ($i=0;$i<=$#rows;$i++) {
  459: 		     if ($rows[$i]) {
  460: 		      $contents++;
  461:                       my @colcont=split(/\&/,$rows[$i]);
  462:                       $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1));
  463:                      } 
  464:                   }
  465: 
  466: 
  467:                   unless ($contents) {
  468:                       $r->content_type('text/html');
  469:                       $r->send_http_header;
  470:                       $r->print('<html><body>Empty Map.</body></html>');
  471:                   } else {
  472: 
  473: # ------------------------------------------------------------------ Build page
  474: 
  475: 		      my $currenturl=$ENV{'form.postdata'};
  476:                       $currenturl=~s/^http\:\/\///;
  477:                       $currenturl=~s/^[^\/]+//;
  478: 
  479: # ---------------------------------------------------------------- Send headers
  480: 
  481:                           $r->content_type('text/html');
  482:                           &Apache::loncommon::no_cache($r);
  483:                           $r->send_http_header;
  484: 
  485: 		          my $date=localtime;
  486: 		          my $now=time;
  487: # ----------------------------------------- Get email status and discussiontime
  488: 
  489: 		      my %emailstatus=&Apache::lonnet::dump('email_status');
  490:                       my $logouttime=$emailstatus{'logout'};
  491:                       my $courseleave=
  492:                          $emailstatus{'logout_'.$ENV{'request.course.id'}};
  493:                       my $lastcheck=
  494:                          ($courseleave>$logouttime?$courseleave:$logouttime);
  495: 
  496:                       my %discussiontimes=&Apache::lonnet::dump(
  497:                          'discussiontimes',
  498:                          $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  499:  		         $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
  500:                        
  501:                       my %feedback=();
  502:                       my %error=();
  503:                       foreach my $msgid (
  504:                                      split(/\&/,&Apache::lonnet::reply('keys:'.
  505: 					$ENV{'user.domain'}.':'.
  506:                                         $ENV{'user.name'}.':nohist_email',
  507:                                         $ENV{'user.home'}))) {
  508:                           $msgid=&Apache::lonnet::unescape($msgid);
  509:                           my $plain=&Apache::lonnet::unescape(
  510:                                     &Apache::lonnet::unescape($msgid));
  511: 			  if ($plain=~/(Error|Feedback) \[([^\]]+)\]/) {
  512: 			      my ($what,$url)=($1,$2);
  513:                               my %status=
  514:                                  &Apache::lonnet::get('email_status',[$msgid]);
  515:                               if ($status{$msgid}=~/^error\:/) { 
  516:                                  $status{$msgid}=''; 
  517:                               }
  518: 
  519: 			      if (($status{$msgid} eq 'new') || 
  520:                                   (!$status{$msgid})) { 
  521:                                   if ($what eq 'Error') {
  522:                                      $error{$url}.=','.$msgid; 
  523: 				  } else {
  524: 				      $feedback{$url}.=','.$msgid;
  525:                                   }
  526:                               }
  527: 			  }
  528: 		      }
  529: # ----------------------------------------------------------- Start Page Output
  530:                           $r->print(
  531: 		   '<html><head><title>Navigate LON-CAPA Maps</title></head>');
  532: 			  $r->print('<body bgcolor="#FFFFFF"');
  533:                           if (($currenturl=~/^\/res/) &&
  534:                               ($currenturl!~/^\/res\/adm/)) {
  535:                              $r->print(' onLoad="window.location.hash='.
  536: 				       "'curloc'".'"');
  537: 			  }
  538:                           $r->print('><script>window.focus();</script>'.
  539:                            '<img align=right src=/adm/lonIcons/lonlogos.gif>'.
  540:                                     '<h1>Navigate Course Map</h1>'.
  541:                                     "<h3>$date</h3>");
  542: 		      $r->rflush();
  543:                       $r->print(
  544:  '<img src="/adm/lonMisc/chat.gif"> New discussion since '.
  545:  localtime($lastcheck).
  546:  '<br><img src="/adm/lonMisc/feedback.gif"> New message (click to open)<p>'); 
  547:                       if (($currenturl=~/^\/res/) &&
  548:                           ($currenturl!~/^\/res\/adm/)) {
  549: 		       $r->print('<a href="#curloc">Current Location</a><p>');
  550:                       }
  551: # ----------------------------------------------------- The little content list
  552:                       for ($i=0;$i<=$#rows;$i++) {
  553: 			if ($rows[$i]) {
  554:                           my @colcont=split(/\&/,$rows[$i]);
  555:                           my $avespan=$lcm/($#colcont+1);
  556:                           for ($j=0;$j<=$#colcont;$j++) {
  557:                               my $rid=$colcont[$j];
  558:                               if ($rid=~/^h(.+)/) {
  559: 				  $rid=$1;
  560:                                   $r->print(
  561:      '&nbsp;&nbsp;&nbsp;<a href="#'.$rid.'">'.$hash{'title_'.$rid}.'</a><br>');
  562:                               }
  563:                           }
  564: 		        }
  565:                       }
  566: # ----------------------------------------------------------------- Start table
  567:                       $r->print('<hr><table cols="'.$lcm.'" border="0">');
  568:                       for ($i=0;$i<=$#rows;$i++) {
  569: 			if ($rows[$i]) {
  570:                           $r->print("\n<tr>");
  571:                           my @colcont=split(/\&/,$rows[$i]);
  572:                           my $avespan=$lcm/($#colcont+1);
  573:                           for ($j=0;$j<=$#colcont;$j++) {
  574:                               my $rid=$colcont[$j];
  575:                               my $add='<td>&nbsp;&nbsp;';
  576:                               my $adde='</td>';
  577:                               my $hwk='<font color="#223322">';
  578:                               my $hwke='</font>';
  579:                               if ($rid=~/^h(.+)/) {
  580: 				  $rid=$1;
  581:                                   $add=
  582:                                    '<th bgcolor="#AAFF55"><a name="'.$rid.'">';
  583:                                   $adde='</th>';
  584:                               }
  585:                             if ($rid=~/^p(\d)(\d)\"([\w\: \(\)\/\,]*)\"(.+)/) {
  586: 				# sub astatus describes what code/tcode mean
  587:                                   my $code=$1;
  588:                                   my $tcode=$2;
  589:                                   my $ctext=$3;
  590:                                   $rid=$4;
  591:                                   if ($tcode eq '1') {
  592:                                      $add='<td bgcolor="#AAAAAA">';
  593:                                   }
  594:                                   if ($code eq '3') {
  595:                                      $add='<td bgcolor="#AAFFAA">';
  596: 				  } else {
  597:                                       $add='<td bgcolor="#FFAAAA">';
  598: 				      if ($tcode eq '2') {
  599:                                          $add='<td bgcolor="#FFFFAA">';
  600:                                       }
  601:                                       if ($tcode eq '4') {
  602:                                          $add='<td bgcolor="#FFFF33">';
  603:                                          $adde='</td>';
  604:                                       }
  605:                                   }
  606:                                   $hwk='<font color="#888811"><b>';
  607:                                   $hwke='</b></font>';
  608:                                   if ($code eq '1') {
  609:                                      $hwke='</b> ('.$ctext.')</font>';
  610:                                   }
  611:                                   if ($code eq '2') {
  612:                                      $hwk='<font color="#992222"><b>';
  613:                                      $hwke='</b> ('.$ctext.')</font>';
  614:                                   }
  615:                                   if ($code eq '3') {
  616:                                      $hwk='<font color="#229922"><b>';
  617:                                      $hwke='</b> ('.$ctext.')</font>';
  618:                                   }
  619:                               }
  620: 			      if ($hash{'src_'.$rid} eq $currenturl) {
  621:                                   $add=$add.'<a name="curloc"></a>'.
  622: 			  '<font color=red size=+2><b>&gt; </b></font>';
  623:                                   $adde=
  624:                           '<font color=red size=+2><b> &lt;</b></font>'.$adde;
  625:                               }
  626:                               my $src=
  627:                                 &Apache::lonnet::declutter($hash{'src_'.$rid});
  628:                               $rid=~/^(\d+)\.(\d+)$/;
  629: 			      my $symb=
  630:            &Apache::lonnet::declutter($hash{'map_id_'.$1}).'___'.$2.'___'.$src;
  631:                               if ($discussiontimes{$symb}>$lastcheck) {
  632:                                  $adde=
  633:                                  '<img border=0 src="/adm/lonMisc/chat.gif">'.
  634: 				     $adde;
  635:                               }
  636:                               if ($error{$src}) {
  637: 				  foreach (split(/\,/,$error{$src})) {
  638: 			             if ($_) {
  639:                                         $adde=
  640: 			 '&nbsp;<a href="/adm/email?display='.
  641:                          &Apache::lonnet::escape($_).
  642:                          '"><img src="/adm/lonMisc/bomb.gif" border=0></a>'
  643:                                         .$adde;
  644:                                      }
  645: 			          }
  646:                               }
  647:                               if ($feedback{$src}) {
  648: 				  foreach (split(/\,/,$feedback{$src})) {
  649: 			             if ($_) {
  650:                                         $adde=
  651: 			 '&nbsp;<a href="/adm/email?display='.
  652:                          &Apache::lonnet::escape($_).
  653:                          '"><img src="/adm/lonMisc/feedback.gif" border=0></a>'
  654:                                         .$adde;
  655:                                      }
  656: 			          }
  657:                               }
  658:                               $r->print($add.'<a href="'.$hash{'src_'.$rid}.
  659:                                 '">'.$hwk.
  660:                                 $hash{'title_'.$rid}.$hwke.'</a>'.$adde);
  661:                           }
  662:                           $r->print('</tr>');
  663: 		        }
  664:                       }
  665:                       $r->print("\n</table>");
  666:                       $r->print('</body></html>');
  667: # -------------------------------------------------------------------- End page
  668:                   }                  
  669: # ------------------------------------------------------------- End render page
  670:               } else {
  671:                   $r->content_type('text/html');
  672:                   $r->send_http_header;
  673: 		  $r->print('<html><body>Coursemap undefined.</body></html>');
  674:               }
  675: # ------------------------------------------------------------------ Untie hash
  676:               unless (untie(%hash)) {
  677:                    &Apache::lonnet::logthis("<font color=blue>WARNING: ".
  678:                        "Could not untie coursemap $fn (browse).</font>"); 
  679:               }
  680:               unless (untie(%parmhash)) {
  681:                    &Apache::lonnet::logthis("<font color=blue>WARNING: ".
  682:                        "Could not untie parmhash (browse).</font>"); 
  683:               }
  684: # -------------------------------------------------------------------- All done
  685: 	      return OK;
  686: # ----------------------------------------------- Errors, hash could no be tied
  687:           }
  688:       } 
  689:   }
  690: 
  691:   $ENV{'user.error.msg'}="$requrl:bre:0:0:Course not initialized";
  692:   return HTTP_NOT_ACCEPTABLE; 
  693: }
  694: 
  695: 1;
  696: __END__
  697: 
  698: 
  699: 
  700: 
  701: 
  702: 
  703: 

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