Annotation of loncom/interface/lonnavmaps.pm, revision 1.26
1.2 www 1: # The LearningOnline Network with CAPA
2: # Navigate Maps Handler
1.1 www 3: #
1.26 ! harris41 4: # $Id: lonnavmaps.pm,v 1.25 2002/02/11 18:59:36 albertel Exp $
1.20 albertel 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: #
1.2 www 28: # (Page Handler
1.1 www 29: #
1.2 www 30: # (TeX Content Handler
1.1 www 31: #
1.2 www 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)
1.1 www 35: #
1.17 www 36: # 3/1/1,6/1,17/1,29/1,30/1,2/8,9/21,9/24,9/25 Gerd Kortemeyer
1.21 www 37: # YEAR=2002
38: # 1/1 Gerd Kortemeyer
39: #
1.2 www 40:
1.1 www 41: package Apache::lonnavmaps;
42:
43: use strict;
1.2 www 44: use Apache::Constants qw(:common :http);
45: use Apache::lonnet();
1.18 albertel 46: use Apache::loncommon();
1.2 www 47: use HTML::TokeParser;
48: use GDBM_File;
49:
50: # -------------------------------------------------------------- Module Globals
51: my %hash;
52: my @rows;
53:
1.10 www 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:
1.2 www 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:
1.10 www 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
1.24 albertel 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: }
1.10 www 128:
1.24 albertel 129: # ------------------------------------------------------- second, check course
130: if ($csec) {
131: if ($courseopt{$seclevelr}) { return $courseopt{$seclevelr}; }
1.25 albertel 132: if ($courseopt{$seclevelm}) { return $courseopt{$seclevelm}; }
1.10 www 133: if ($courseopt{$seclevel}) { return $courseopt{$seclevel}; }
1.24 albertel 134: }
1.10 www 135:
1.24 albertel 136: if ($courseopt{$courselevelr}) { return $courseopt{$courselevelr}; }
137: if ($courseopt{$courselevelm}) { return $courseopt{$courselevelm}; }
138: if ($courseopt{$courselevel}) { return $courseopt{$courselevel}; }
1.10 www 139:
1.24 albertel 140: # ----------------------------------------------------- third, check map parms
1.10 www 141:
1.24 albertel 142: my $thisparm=$parmhash{$symbparm};
143: if ($thisparm) { return $thisparm; }
1.10 www 144:
1.24 albertel 145: # ----------------------------------------------------- fourth , check default
1.10 www 146:
1.25 albertel 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 '';
1.10 www 165: }
166:
167:
168:
1.9 www 169: # ------------------------------------------------------------- Find out status
1.25 albertel 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.
1.9 www 182: sub astatus {
183: my $rid=shift;
184: my $code=1;
185: my $ctext='';
186: $rid=~/(\d+)\.(\d+)/;
1.10 www 187: my $symb=&Apache::lonnet::declutter($hash{'map_id_'.$1}).'___'.$2.'___'.
1.24 albertel 188: &Apache::lonnet::declutter($hash{'src_'.$rid});
1.25 albertel 189: $Apache::lonxml::debug=1;
1.15 www 190: my %duedate=();
191: my %opendate=();
192: my %answerdate=();
1.25 albertel 193: # need to always check part 0's open/due/answer status
194: foreach (sort(split(/\,/,&Apache::lonnet::metadata($hash{'src_'.$rid},'keys')))) {
1.15 www 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: }
1.25 albertel 201: }
1.11 www 202: my $now=time;
203: my $tcode=0;
1.16 www 204:
205: my %returnhash=&Apache::lonnet::restore($symb);
206:
1.25 albertel 207: foreach (sort(keys(%opendate))) {
1.24 albertel 208: my $duedate=$duedate{$_};
209: my $opendate=$opendate{$_};
210: my $answerdate=$answerdate{$_};
211: my $preface='';
212: unless ($_ eq '0') { $preface=' Part: '.$_.' '; }
213: if ($opendate) {
1.25 albertel 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; }
1.24 albertel 223: $ctext.=$preface.'Open: '.localtime($opendate);
224: }
1.25 albertel 225: if ($duedate && $duedate-$now<86400) {
1.24 albertel 226: $tcode=4;
227: $ctext.=$preface.'Due: '.localtime($duedate);
228: }
229: } else {
230: unless (($tcode==4) || ($tcode eq 2)) { $tcode=3; }
1.25 albertel 231: if ($now<$answerdate) {
1.24 albertel 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'};
1.25 albertel 240:
1.24 albertel 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'}?
1.25 albertel 251: $returnhash{'resource.'.$_.'.tries'}:'0');
252: my $numtries = &parmval($_.'.maxtries',$symb);
253: if ($numtries) { $ctext.='/'.$numtries.' tries'; }
254: $ctext.=')';
1.24 albertel 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: }
1.25 albertel 262: }
1.16 www 263:
1.11 www 264: return 'p'.$code.$tcode.'"'.$ctext.'"';
1.9 www 265: }
266:
1.2 www 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})) {
1.7 www 276: $sofar++;
277: my $tprefix='';
278: if ($hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$rid}}}
279: eq 'sequence') {
280: $tprefix='h';
281: }
1.6 www 282: if (defined($rows[$sofar])) {
1.7 www 283: $rows[$sofar].='&'.$tprefix.$rid;
1.6 www 284: } else {
1.7 www 285: $rows[$sofar]=$tprefix.$rid;
1.6 www 286: }
1.2 www 287: if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) &&
1.7 www 288: (defined($hash{'map_finish_'.$hash{'src_'.$rid}})) &&
289: ($tprefix eq 'h')) {
1.2 www 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')) {
1.7 www 298: my $pprefix='';
1.9 www 299: if ($hash{'src_'.$frid}=~
300: /\.(problem|exam|quiz|assess|survey|form)$/) {
301: $pprefix=&astatus($frid);
302:
1.7 www 303: }
1.2 www 304: if (defined($rows[$sofar])) {
1.7 www 305: $rows[$sofar].='&'.$pprefix.$frid;
1.2 www 306: } else {
1.7 www 307: $rows[$sofar]=$pprefix.$frid;
1.2 www 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')) {
1.7 www 317: my $pprefix='';
1.9 www 318: if ($hash{'src_'.$rid}=~
319: /\.(problem|exam|quiz|assess|survey|form)$/) {
320: $pprefix=&astatus($rid);
1.7 www 321: }
1.2 www 322: if (defined($rows[$sofar])) {
1.7 www 323: $rows[$sofar].='&'.$pprefix.$rid;
1.2 www 324: } else {
1.7 www 325: $rows[$sofar]=$pprefix.$rid;
1.2 www 326: }
327: }
328: }
329: }
330:
331: if (defined($hash{'to_'.$rid})) {
332: my $mincond=1;
333: my $next='';
1.26 ! harris41 334: foreach (split(/\,/,$hash{'to_'.$rid})) {
1.2 www 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: }
1.26 ! harris41 345: }
! 346: foreach (split(/\,/,$next)) {
1.2 www 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: }
1.26 ! harris41 352: }
1.2 www 353:
354: }
355: }
356: return $further;
357: }
358:
359: # ================================================================ Main Handler
1.1 www 360:
361: sub handler {
1.2 www 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") {
1.10 www 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))) {
1.2 www 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
1.10 www 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: }
1.26 ! harris41 416: foreach (split(/\&/,$courserdatas{$cid})) {
1.10 www 417: my ($name,$value)=split(/\=/,$_);
418: $courseopt{$userprefix.&Apache::lonnet::unescape($name)}=
419: &Apache::lonnet::unescape($value);
1.26 ! harris41 420: }
1.10 www 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: }
1.26 ! harris41 431: foreach (split(/\&/,$userrdatas{$uname.'___'.$udom})) {
1.10 www 432: my ($name,$value)=split(/\=/,$_);
433: $useropt{$userprefix.&Apache::lonnet::unescape($name)}=
434: &Apache::lonnet::unescape($value);
1.26 ! harris41 435: }
1.10 www 436: }
1.2 www 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;
1.5 www 452: my $i;
1.2 www 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: }
1.5 www 465:
1.2 www 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 {
1.10 www 472:
1.2 www 473: # ------------------------------------------------------------------ Build page
474:
1.13 www 475: my $currenturl=$ENV{'form.postdata'};
476: $currenturl=~s/^http\:\/\///;
477: $currenturl=~s/^[^\/]+//;
478:
1.2 www 479: # ---------------------------------------------------------------- Send headers
480:
481: $r->content_type('text/html');
1.19 albertel 482: &Apache::loncommon::no_cache($r);
1.2 www 483: $r->send_http_header;
1.21 www 484:
1.18 albertel 485: my $date=localtime;
1.21 www 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'});
1.22 www 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
1.2 www 530: $r->print(
1.19 albertel 531: '<html><head><title>Navigate LON-CAPA Maps</title></head>');
1.13 www 532: $r->print('<body bgcolor="#FFFFFF"');
1.14 www 533: if (($currenturl=~/^\/res/) &&
534: ($currenturl!~/^\/res\/adm/)) {
1.13 www 535: $r->print(' onLoad="window.location.hash='.
536: "'curloc'".'"');
537: }
538: $r->print('><script>window.focus();</script>'.
1.6 www 539: '<img align=right src=/adm/lonIcons/lonlogos.gif>'.
1.21 www 540: '<h1>Navigate Course Map</h1>'.
541: "<h3>$date</h3>");
1.13 www 542: $r->rflush();
1.23 www 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>');
1.14 www 547: if (($currenturl=~/^\/res/) &&
548: ($currenturl!~/^\/res\/adm/)) {
1.13 www 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: ' <a href="#'.$rid.'">'.$hash{'title_'.$rid}.'</a><br>');
562: }
563: }
564: }
565: }
1.2 www 566: # ----------------------------------------------------------------- Start table
1.14 www 567: $r->print('<hr><table cols="'.$lcm.'" border="0">');
1.2 www 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];
1.6 www 575: my $add='<td> ';
1.7 www 576: my $adde='</td>';
577: my $hwk='<font color="#223322">';
578: my $hwke='</font>';
1.6 www 579: if ($rid=~/^h(.+)/) {
580: $rid=$1;
1.13 www 581: $add=
582: '<th bgcolor="#AAFF55"><a name="'.$rid.'">';
1.7 www 583: $adde='</th>';
584: }
1.11 www 585: if ($rid=~/^p(\d)(\d)\"([\w\: \(\)\/\,]*)\"(.+)/) {
1.25 albertel 586: # sub astatus describes what code/tcode mean
1.7 www 587: my $code=$1;
1.11 www 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') {
1.25 albertel 602: $add='<td bgcolor="#FFFF33">';
603: $adde='</td>';
1.11 www 604: }
605: }
1.9 www 606: $hwk='<font color="#888811"><b>';
607: $hwke='</b></font>';
1.10 www 608: if ($code eq '1') {
609: $hwke='</b> ('.$ctext.')</font>';
610: }
1.7 www 611: if ($code eq '2') {
1.9 www 612: $hwk='<font color="#992222"><b>';
613: $hwke='</b> ('.$ctext.')</font>';
1.7 www 614: }
615: if ($code eq '3') {
1.9 www 616: $hwk='<font color="#229922"><b>';
617: $hwke='</b> ('.$ctext.')</font>';
1.7 www 618: }
1.6 www 619: }
1.13 www 620: if ($hash{'src_'.$rid} eq $currenturl) {
621: $add=$add.'<a name="curloc"></a>'.
1.21 www 622: '<font color=red size=+2><b>> </b></font>';
1.13 www 623: $adde=
1.21 www 624: '<font color=red size=+2><b> <</b></font>'.$adde;
625: }
1.22 www 626: my $src=
627: &Apache::lonnet::declutter($hash{'src_'.$rid});
1.21 www 628: $rid=~/^(\d+)\.(\d+)$/;
1.22 www 629: my $symb=
630: &Apache::lonnet::declutter($hash{'map_id_'.$1}).'___'.$2.'___'.$src;
1.21 www 631: if ($discussiontimes{$symb}>$lastcheck) {
632: $adde=
633: '<img border=0 src="/adm/lonMisc/chat.gif">'.
634: $adde;
1.22 www 635: }
636: if ($error{$src}) {
637: foreach (split(/\,/,$error{$src})) {
638: if ($_) {
639: $adde=
640: ' <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: ' <a href="/adm/email?display='.
652: &Apache::lonnet::escape($_).
653: '"><img src="/adm/lonMisc/feedback.gif" border=0></a>'
654: .$adde;
655: }
656: }
1.13 www 657: }
1.7 www 658: $r->print($add.'<a href="'.$hash{'src_'.$rid}.
659: '">'.$hwk.
660: $hash{'title_'.$rid}.$hwke.'</a>'.$adde);
1.2 www 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>");
1.10 www 679: }
680: unless (untie(%parmhash)) {
681: &Apache::lonnet::logthis("<font color=blue>WARNING: ".
682: "Could not untie parmhash (browse).</font>");
1.2 www 683: }
684: # -------------------------------------------------------------------- All done
685: return OK;
686: # ----------------------------------------------- Errors, hash could no be tied
687: }
688: }
689: }
1.3 www 690:
1.2 www 691: $ENV{'user.error.msg'}="$requrl:bre:0:0:Course not initialized";
692: return HTTP_NOT_ACCEPTABLE;
693: }
1.1 www 694:
695: 1;
696: __END__
1.2 www 697:
698:
699:
700:
701:
702:
703:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>