File:  [LON-CAPA] / loncom / interface / lonnavmaps.pm
Revision 1.31: download - view: text, annotated - select for diffs
Fri Mar 15 23:39:41 2002 UTC (22 years, 2 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- trying to add in problem resources on a .page into the listing.

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

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