Annotation of loncom/interface/lonnavmaps.pm, revision 1.27
1.2 www 1: # The LearningOnline Network with CAPA
2: # Navigate Maps Handler
1.1 www 3: #
1.27 ! albertel 4: # $Id: lonnavmaps.pm,v 1.26 2002/02/14 22:13:36 harris41 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.15 www 189: my %duedate=();
190: my %opendate=();
191: my %answerdate=();
1.25 albertel 192: # need to always check part 0's open/due/answer status
193: foreach (sort(split(/\,/,&Apache::lonnet::metadata($hash{'src_'.$rid},'keys')))) {
1.15 www 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: }
1.25 albertel 200: }
1.11 www 201: my $now=time;
202: my $tcode=0;
1.16 www 203:
204: my %returnhash=&Apache::lonnet::restore($symb);
205:
1.25 albertel 206: foreach (sort(keys(%opendate))) {
1.24 albertel 207: my $duedate=$duedate{$_};
208: my $opendate=$opendate{$_};
209: my $answerdate=$answerdate{$_};
210: my $preface='';
211: unless ($_ eq '0') { $preface=' Part: '.$_.' '; }
212: if ($opendate) {
1.25 albertel 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; }
1.24 albertel 222: $ctext.=$preface.'Open: '.localtime($opendate);
223: }
1.25 albertel 224: if ($duedate && $duedate-$now<86400) {
1.24 albertel 225: $tcode=4;
226: $ctext.=$preface.'Due: '.localtime($duedate);
227: }
228: } else {
229: unless (($tcode==4) || ($tcode eq 2)) { $tcode=3; }
1.25 albertel 230: if ($now<$answerdate) {
1.24 albertel 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'};
1.25 albertel 239:
1.24 albertel 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'}?
1.25 albertel 250: $returnhash{'resource.'.$_.'.tries'}:'0');
251: my $numtries = &parmval($_.'.maxtries',$symb);
252: if ($numtries) { $ctext.='/'.$numtries.' tries'; }
253: $ctext.=')';
1.24 albertel 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: }
1.25 albertel 261: }
1.16 www 262:
1.11 www 263: return 'p'.$code.$tcode.'"'.$ctext.'"';
1.9 www 264: }
265:
1.2 www 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})) {
1.7 www 275: $sofar++;
276: my $tprefix='';
277: if ($hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$rid}}}
278: eq 'sequence') {
279: $tprefix='h';
280: }
1.6 www 281: if (defined($rows[$sofar])) {
1.7 www 282: $rows[$sofar].='&'.$tprefix.$rid;
1.6 www 283: } else {
1.7 www 284: $rows[$sofar]=$tprefix.$rid;
1.6 www 285: }
1.2 www 286: if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) &&
1.7 www 287: (defined($hash{'map_finish_'.$hash{'src_'.$rid}})) &&
288: ($tprefix eq 'h')) {
1.2 www 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')) {
1.7 www 297: my $pprefix='';
1.9 www 298: if ($hash{'src_'.$frid}=~
299: /\.(problem|exam|quiz|assess|survey|form)$/) {
300: $pprefix=&astatus($frid);
301:
1.7 www 302: }
1.2 www 303: if (defined($rows[$sofar])) {
1.7 www 304: $rows[$sofar].='&'.$pprefix.$frid;
1.2 www 305: } else {
1.7 www 306: $rows[$sofar]=$pprefix.$frid;
1.2 www 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')) {
1.7 www 316: my $pprefix='';
1.9 www 317: if ($hash{'src_'.$rid}=~
318: /\.(problem|exam|quiz|assess|survey|form)$/) {
319: $pprefix=&astatus($rid);
1.7 www 320: }
1.2 www 321: if (defined($rows[$sofar])) {
1.7 www 322: $rows[$sofar].='&'.$pprefix.$rid;
1.2 www 323: } else {
1.7 www 324: $rows[$sofar]=$pprefix.$rid;
1.2 www 325: }
326: }
327: }
328: }
329:
330: if (defined($hash{'to_'.$rid})) {
331: my $mincond=1;
332: my $next='';
1.26 harris41 333: foreach (split(/\,/,$hash{'to_'.$rid})) {
1.2 www 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: }
1.26 harris41 344: }
345: foreach (split(/\,/,$next)) {
1.2 www 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: }
1.26 harris41 351: }
1.2 www 352:
353: }
354: }
355: return $further;
356: }
357:
358: # ================================================================ Main Handler
1.1 www 359:
360: sub handler {
1.2 www 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") {
1.10 www 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))) {
1.2 www 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
1.10 www 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: }
1.26 harris41 415: foreach (split(/\&/,$courserdatas{$cid})) {
1.10 www 416: my ($name,$value)=split(/\=/,$_);
417: $courseopt{$userprefix.&Apache::lonnet::unescape($name)}=
418: &Apache::lonnet::unescape($value);
1.26 harris41 419: }
1.10 www 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: }
1.26 harris41 430: foreach (split(/\&/,$userrdatas{$uname.'___'.$udom})) {
1.10 www 431: my ($name,$value)=split(/\=/,$_);
432: $useropt{$userprefix.&Apache::lonnet::unescape($name)}=
433: &Apache::lonnet::unescape($value);
1.26 harris41 434: }
1.10 www 435: }
1.2 www 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;
1.5 www 451: my $i;
1.2 www 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: }
1.5 www 464:
1.2 www 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 {
1.10 www 471:
1.2 www 472: # ------------------------------------------------------------------ Build page
473:
1.13 www 474: my $currenturl=$ENV{'form.postdata'};
475: $currenturl=~s/^http\:\/\///;
476: $currenturl=~s/^[^\/]+//;
477:
1.2 www 478: # ---------------------------------------------------------------- Send headers
479:
480: $r->content_type('text/html');
1.19 albertel 481: &Apache::loncommon::no_cache($r);
1.2 www 482: $r->send_http_header;
1.21 www 483:
1.18 albertel 484: my $date=localtime;
1.21 www 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'});
1.22 www 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
1.2 www 529: $r->print(
1.19 albertel 530: '<html><head><title>Navigate LON-CAPA Maps</title></head>');
1.13 www 531: $r->print('<body bgcolor="#FFFFFF"');
1.14 www 532: if (($currenturl=~/^\/res/) &&
533: ($currenturl!~/^\/res\/adm/)) {
1.13 www 534: $r->print(' onLoad="window.location.hash='.
535: "'curloc'".'"');
536: }
537: $r->print('><script>window.focus();</script>'.
1.6 www 538: '<img align=right src=/adm/lonIcons/lonlogos.gif>'.
1.21 www 539: '<h1>Navigate Course Map</h1>'.
540: "<h3>$date</h3>");
1.13 www 541: $r->rflush();
1.23 www 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>');
1.14 www 546: if (($currenturl=~/^\/res/) &&
547: ($currenturl!~/^\/res\/adm/)) {
1.13 www 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: ' <a href="#'.$rid.'">'.$hash{'title_'.$rid}.'</a><br>');
561: }
562: }
563: }
564: }
1.2 www 565: # ----------------------------------------------------------------- Start table
1.14 www 566: $r->print('<hr><table cols="'.$lcm.'" border="0">');
1.2 www 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];
1.6 www 574: my $add='<td> ';
1.7 www 575: my $adde='</td>';
576: my $hwk='<font color="#223322">';
577: my $hwke='</font>';
1.6 www 578: if ($rid=~/^h(.+)/) {
579: $rid=$1;
1.13 www 580: $add=
581: '<th bgcolor="#AAFF55"><a name="'.$rid.'">';
1.7 www 582: $adde='</th>';
583: }
1.11 www 584: if ($rid=~/^p(\d)(\d)\"([\w\: \(\)\/\,]*)\"(.+)/) {
1.25 albertel 585: # sub astatus describes what code/tcode mean
1.7 www 586: my $code=$1;
1.11 www 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') {
1.25 albertel 601: $add='<td bgcolor="#FFFF33">';
602: $adde='</td>';
1.11 www 603: }
604: }
1.9 www 605: $hwk='<font color="#888811"><b>';
606: $hwke='</b></font>';
1.10 www 607: if ($code eq '1') {
608: $hwke='</b> ('.$ctext.')</font>';
609: }
1.7 www 610: if ($code eq '2') {
1.9 www 611: $hwk='<font color="#992222"><b>';
612: $hwke='</b> ('.$ctext.')</font>';
1.7 www 613: }
614: if ($code eq '3') {
1.9 www 615: $hwk='<font color="#229922"><b>';
616: $hwke='</b> ('.$ctext.')</font>';
1.7 www 617: }
1.6 www 618: }
1.13 www 619: if ($hash{'src_'.$rid} eq $currenturl) {
620: $add=$add.'<a name="curloc"></a>'.
1.21 www 621: '<font color=red size=+2><b>> </b></font>';
1.13 www 622: $adde=
1.21 www 623: '<font color=red size=+2><b> <</b></font>'.$adde;
624: }
1.22 www 625: my $src=
626: &Apache::lonnet::declutter($hash{'src_'.$rid});
1.21 www 627: $rid=~/^(\d+)\.(\d+)$/;
1.22 www 628: my $symb=
629: &Apache::lonnet::declutter($hash{'map_id_'.$1}).'___'.$2.'___'.$src;
1.21 www 630: if ($discussiontimes{$symb}>$lastcheck) {
631: $adde=
632: '<img border=0 src="/adm/lonMisc/chat.gif">'.
633: $adde;
1.22 www 634: }
635: if ($error{$src}) {
636: foreach (split(/\,/,$error{$src})) {
637: if ($_) {
638: $adde=
639: ' <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: ' <a href="/adm/email?display='.
651: &Apache::lonnet::escape($_).
652: '"><img src="/adm/lonMisc/feedback.gif" border=0></a>'
653: .$adde;
654: }
655: }
1.13 www 656: }
1.7 www 657: $r->print($add.'<a href="'.$hash{'src_'.$rid}.
658: '">'.$hwk.
659: $hash{'title_'.$rid}.$hwke.'</a>'.$adde);
1.2 www 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>");
1.10 www 678: }
679: unless (untie(%parmhash)) {
680: &Apache::lonnet::logthis("<font color=blue>WARNING: ".
681: "Could not untie parmhash (browse).</font>");
1.2 www 682: }
683: # -------------------------------------------------------------------- All done
684: return OK;
685: # ----------------------------------------------- Errors, hash could no be tied
686: }
687: }
688: }
1.3 www 689:
1.2 www 690: $ENV{'user.error.msg'}="$requrl:bre:0:0:Course not initialized";
691: return HTTP_NOT_ACCEPTABLE;
692: }
1.1 www 693:
694: 1;
695: __END__
1.2 www 696:
697:
698:
699:
700:
701:
702:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>