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