File:  [LON-CAPA] / loncom / interface / lonnavmaps.pm
Revision 1.27: download - view: text, annotated - select for diffs
Thu Feb 28 19:45:14 2002 UTC (22 years, 4 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- forgot to clean up all of the debug

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

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