File:
[LON-CAPA] /
loncom /
interface /
lonnavmaps.pm
Revision
1.47:
download - view:
text,
annotated -
select for diffs
Tue Sep 3 20:46:30 2002 UTC (21 years, 9 months ago) by
bowersj2
Branches:
MAIN
CVS tags:
HEAD
Backed out previous yucky fix to 176, and this should ACTUALLY fix it.
If a network error occurs when grabbing the problem status for the
nav map, then make it a neutral gray color and say "status unavailable".
Also posts an error on the top of the screen saying the network is experiencing
problems and data may not be available.
1: # The LearningOnline Network with CAPA
2: # Navigate Maps Handler
3: #
4: # $Id: lonnavmaps.pm,v 1.47 2002/09/03 20:46:30 bowersj2 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: # This parameter keeps track of whether obtaining the user's information
71: # failed, which the colorizer in astatus can use
72: my $networkFailedFlag = 0;
73:
74: # ------------------------------------------------------------------ Euclid gcd
75:
76: sub euclid {
77: my ($e,$f)=@_;
78: my $a; my $b; my $r;
79: if ($e>$f) { $b=$e; $r=$f; } else { $r=$e; $b=$f; }
80: while ($r!=0) {
81: $a=$b; $b=$r;
82: $r=$a%$b;
83: }
84: return $b;
85: }
86:
87: # --------------------------------------------------------------------- Parmval
88:
89: # -------------------------------------------- Figure out a cascading parameter
90: #
91: # For this function to work
92: #
93: # * parmhash needs to be tied
94: # * courseopt and useropt need to be initialized for this user and course
95: #
96:
97: sub parmval {
98: my ($what,$symb)=@_;
99: my $cid=$ENV{'request.course.id'};
100: my $csec=$ENV{'request.course.sec'};
101: my $uname=$ENV{'user.name'};
102: my $udom=$ENV{'user.domain'};
103:
104: unless ($symb) { return ''; }
105: my $result='';
106:
107: my ($mapname,$id,$fn)=split(/\_\_\_/,$symb);
108:
109: # ----------------------------------------------------- Cascading lookup scheme
110: my $rwhat=$what;
111: $what=~s/^parameter\_//;
112: $what=~s/\_/\./;
113:
114: my $symbparm=$symb.'.'.$what;
115: my $mapparm=$mapname.'___(all).'.$what;
116: my $usercourseprefix=$uname.'_'.$udom.'_'.$cid;
117:
118: my $seclevel= $usercourseprefix.'.['.$csec.'].'.$what;
119: my $seclevelr=$usercourseprefix.'.['.$csec.'].'.$symbparm;
120: my $seclevelm=$usercourseprefix.'.['.$csec.'].'.$mapparm;
121:
122: my $courselevel= $usercourseprefix.'.'.$what;
123: my $courselevelr=$usercourseprefix.'.'.$symbparm;
124: my $courselevelm=$usercourseprefix.'.'.$mapparm;
125:
126: # ---------------------------------------------------------- first, check user
127: if ($uname) {
128: if ($useropt{$courselevelr}) { return $useropt{$courselevelr}; }
129: if ($useropt{$courselevelm}) { return $useropt{$courselevelm}; }
130: if ($useropt{$courselevel}) { return $useropt{$courselevel}; }
131: }
132:
133: # ------------------------------------------------------- second, check course
134: if ($csec) {
135: if ($courseopt{$seclevelr}) { return $courseopt{$seclevelr}; }
136: if ($courseopt{$seclevelm}) { return $courseopt{$seclevelm}; }
137: if ($courseopt{$seclevel}) { return $courseopt{$seclevel}; }
138: }
139:
140: if ($courseopt{$courselevelr}) { return $courseopt{$courselevelr}; }
141: if ($courseopt{$courselevelm}) { return $courseopt{$courselevelm}; }
142: if ($courseopt{$courselevel}) { return $courseopt{$courselevel}; }
143:
144: # ----------------------------------------------------- third, check map parms
145:
146: my $thisparm=$parmhash{$symbparm};
147: if ($thisparm) { return $thisparm; }
148:
149: # ----------------------------------------------------- fourth , check default
150:
151: my $default=&Apache::lonnet::metadata($fn,$rwhat.'.default');
152: if ($default) { return $default}
153:
154: # --------------------------------------------------- fifth , cascade up parts
155:
156: my ($space,@qualifier)=split(/\./,$rwhat);
157: my $qualifier=join('.',@qualifier);
158: unless ($space eq '0') {
159: my ($part,$id)=split(/\_/,$space);
160: if ($id) {
161: my $partgeneral=&parmval($part.".$qualifier",$symb);
162: if ($partgeneral) { return $partgeneral; }
163: } else {
164: my $resourcegeneral=&parmval("0.$qualifier",$symb);
165: if ($resourcegeneral) { return $resourcegeneral; }
166: }
167: }
168: return '';
169: }
170:
171:
172:
173: # ------------------------------------------------------------- Find out status
174: # return codes
175: # tcode (timecode)
176: # 1: will open later
177: # 2: is open and not past due yet
178: # 3: is past due date
179: # 4: due in the next 24 hours
180: #
181: # code (curent solved status)
182: # 1: not attempted
183: # 2: attempted but wrong, or incorrect by instructor
184: # 3: solved or correct by instructor
185: # 4: partially correct (one or more parts correct)
186: # "excused" needs to be supported, but is not yet.
187: sub astatus {
188: my $rid=shift;
189: my $code=0;
190: my $ctext='';
191: $rid=~/(\d+)\.(\d+)/;
192: my $symb=&Apache::lonnet::declutter($hash{'map_id_'.$1}).'___'.$2.'___'.
193: &Apache::lonnet::declutter($hash{'src_'.$rid});
194: my %duedate=();
195: my %opendate=();
196: my %answerdate=();
197: # need to always check part 0's open/due/answer status
198: foreach (sort(split(/\,/,&Apache::lonnet::metadata($hash{'src_'.$rid},'keys')))) {
199: if ($_=~/^parameter\_(.*)\_opendate$/) {
200: my $part=$1;
201: $duedate{$part}=&parmval($part.'.duedate',$symb);
202: $opendate{$part}=&parmval($part.'.opendate',$symb);
203: $answerdate{$part}=&parmval($part.'.answerdate',$symb);
204: }
205: }
206: my $now=time;
207: my $tcode=0;
208:
209: my %returnhash=&Apache::lonnet::restore($symb);
210:
211: foreach (sort(keys(%opendate))) {
212: my $duedate=$duedate{$_};
213: my $opendate=$opendate{$_};
214: my $answerdate=$answerdate{$_};
215: my $preface='';
216: unless ($_ eq '0') { $preface=' Part: '.$_.' '; }
217: if ($opendate) {
218: if ($now<$duedate || (!$duedate)) {
219: unless ($tcode==4) { $tcode=2; }
220: if ($duedate) {
221: $ctext.=$preface.'Due: '.localtime($duedate);
222: } else {
223: $ctext.=$preface.'No Due Date';
224: }
225: if ($now<$opendate) {
226: unless ($tcode) { $tcode=1; }
227: $ctext.=$preface.'Open: '.localtime($opendate);
228: }
229: if ($duedate && $duedate-$now<86400) {
230: $tcode=4;
231: $ctext.=$preface.'Due: '.localtime($duedate);
232: }
233: } else {
234: unless (($tcode==4) || ($tcode eq 2)) { $tcode=3; }
235: if ($now<$answerdate) {
236: $ctext.='Answer: '.localtime($duedate);
237: }
238: }
239: } else {
240: unless (($tcode==2) || ($tcode==4)) { $tcode=1; }
241: }
242:
243: my $status=$returnhash{'resource.'.$_.'.solved'};
244:
245: if ($status eq 'correct_by_student') {
246: if ($code==0||$code==3) { $code=3; } else { $code=4; }
247: $ctext.=' solved';
248: } elsif ($status eq 'correct_by_override') {
249: if ($code==0||$code==3) { $code=3; } else { $code=4; }
250: $ctext.=' override';
251: } elsif ($status eq 'incorrect_attempted') {
252: if ($code!=4 && $code!=3) { $code=2; }
253: if ($code==3) { $code=4; }
254: $ctext.=' ('.
255: ($returnhash{'resource.'.$_.'.tries'}?
256: $returnhash{'resource.'.$_.'.tries'}:'0');
257: my $numtries = &parmval($_.'.maxtries',$symb);
258: if ($numtries) { $ctext.='/'.$numtries.' tries'; }
259: $ctext.=')';
260: } elsif ($status eq 'incorrect_by_override') {
261: if ($code!=4 && $code!=3) { $code=2; }
262: if ($code==3) { $code=4; }
263: $ctext.=' override';
264: } elsif ($status eq 'excused') {
265: if ($code==0||$code==3) { $code=3; } else { $code=4; }
266: $ctext.=' excused';
267: } else {
268: if ($code==0) { $code=1; }
269: }
270: }
271:
272: return 'p'.$code.$tcode.'"'.$ctext.'"';
273: }
274:
275:
276: sub addresource {
277: my ($resource,$sofar,$rid,$showtypes,$indent,$linkid)=@_;
278: if ($showtypes eq 'problems') {
279: if ($resource!~/\.(problem|exam|quiz|assess|survey|form)$/) {
280: return;
281: }
282: }
283: my $brepriv=&Apache::lonnet::allowed('bre',$resource);
284: if ($hash{'src_'.$rid}) {
285: if (($brepriv eq '2') || ($brepriv eq 'F')) {
286: my $pprefix='';
287: if ($resource=~/\.(problem|exam|quiz|assess|survey|form)$/) {
288: $pprefix=&astatus($rid);
289: }
290: $$sofar++;
291: if ($indent) { $pprefix='i'.$indent.','.$pprefix; }
292: if ($linkid) { $pprefix='l'.$linkid.','.$pprefix; }
293: if (defined($rows[$$sofar])) {
294: $rows[$$sofar].='&'.$pprefix.$rid;
295: } else {
296: $rows[$$sofar]=$pprefix.$rid;
297: }
298: }
299: }
300: }
301:
302: sub followlinks () {
303: my ($rid,$sofar,$beenhere,$further,$showtypes,$indent,$linkid)=@_;
304: my $mincond=1;
305: my $next='';
306: foreach (split(/\,/,$hash{'to_'.$rid})) {
307: my $thiscond=
308: &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$_}});
309: if ($thiscond>=$mincond) {
310: if ($next) {
311: $next.=','.$_.':'.$thiscond;
312: } else {
313: $next=$_.':'.$thiscond;
314: }
315: if ($thiscond>$mincond) { $mincond=$thiscond; }
316: }
317: }
318: my $col=0;
319: &Apache::lonxml::debug("following links -$next-");
320: foreach (split(/\,/,$next)) {
321: my ($nextlinkid,$condval)=split(/\:/,$_);
322: if ($condval>=$mincond) {
323: my $now=&tracetable($sofar,$hash{'goesto_'.$nextlinkid},
324: $beenhere,$showtypes,$indent,$linkid);
325: if ($now>$further) {
326: if ($col>0) {
327: my $string;
328: for(my $i=0;$i<$col;$i++) { $string.='&'; }
329: for(my $i=$further+1;$now-1>$i;$i++) {
330: $rows[$i]=$string.$rows[$i];
331: }
332: }
333: $further=$now;
334: }
335: }
336: $col++;
337: }
338: return $further;
339: }
340: # ------------------------------------------------------------ Build page table
341:
342: sub tracetable {
343: my ($sofar,$rid,$beenhere,$showtypes,$indent,$linkid)=@_;
344: my $newshowtypes=$showtypes;
345: my $further=$sofar;
346: # $Apache::lonxml::debug=1;
347: &Apache::lonxml::debug("$rid ; $linkid ; $sofar ; $beenhere ; ".$hash{'src_'.$rid});
348: if ($beenhere=~/\&$rid\&/) { return $further; }
349: $beenhere.=$rid.'&';
350:
351: if (defined($hash{'is_map_'.$rid})) {
352: $sofar++;
353: my $tprefix='';
354: if ($hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$rid}}}
355: eq 'sequence') {
356: $tprefix='h';
357: } elsif ($hash{'map_type_'.$hash{'map_pc_'.$hash{'src_'.$rid}}}
358: eq 'page') {
359: $tprefix='j';
360: if ($indent) { $tprefix='i'.$indent.','.$tprefix; }
361: if ($linkid) { $tprefix='l'.$linkid.','.$tprefix; }
362: $newshowtypes='problems';
363: $indent++;
364: #if in a .page continue to link the encompising .page
365: if (!$linkid) { $linkid=$rid; }
366: }
367: if (defined($rows[$sofar])) {
368: $rows[$sofar].='&'.$tprefix.$rid;
369: } else {
370: $rows[$sofar]=$tprefix.$rid;
371: }
372: if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) &&
373: (defined($hash{'map_finish_'.$hash{'src_'.$rid}}))) {
374: my $frid=$hash{'map_finish_'.$hash{'src_'.$rid}};
375: $sofar=&tracetable($sofar,$hash{'map_start_'.$hash{'src_'.$rid}},
376: '&'.$frid.'&',$newshowtypes,$indent,$linkid);
377: &addresource($hash{'src_'.$frid},\$sofar,$frid,$newshowtypes,
378: $indent,$linkid);
379: if ($tprefix =~ /j$/) { $indent--; $linkid=''; }
380: }
381: } else {
382: &addresource($hash{'src_'.$rid},\$sofar,$rid,$showtypes,
383: $indent,$linkid);
384: }
385:
386: if (defined($hash{'to_'.$rid})) {
387: $further=&followlinks($rid,$sofar,$beenhere,$further,$showtypes,
388: $indent,$linkid);
389: }
390:
391: return $further;
392: }
393:
394: # ================================================================ Main Handler
395:
396: sub handler {
397: my $r=shift;
398:
399:
400: # ------------------------------------------- Set document type for header only
401:
402: if ($r->header_only) {
403: if ($ENV{'browser.mathml'}) {
404: $r->content_type('text/xml');
405: } else {
406: $r->content_type('text/html');
407: }
408: $r->send_http_header;
409: return OK;
410: }
411: my $requrl=$r->uri;
412: my $hashtied;
413: # ----------------------------------------------------------------- Tie db file
414: my $fn;
415: if ($ENV{'request.course.fn'}) {
416: $fn=$ENV{'request.course.fn'};
417: if (-e "$fn.db") {
418: if ((tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER(),0640)) &&
419: (tie(%parmhash,'GDBM_File',
420: $ENV{'request.course.fn'}.'_parms.db',
421: &GDBM_READER(),0640))) {
422: $hashtied=1;
423: }
424: }
425: }
426: if (!$hashtied) {
427: $ENV{'user.error.msg'}="$requrl:bre:0:0:Course not initialized";
428: return HTTP_NOT_ACCEPTABLE;
429: }
430:
431: # ------------------------------------------------------------------- Hash tied
432:
433: if ($ENV{'browser.mathml'}) {
434: $r->content_type('text/xml');
435: } else {
436: $r->content_type('text/html');
437: }
438: &Apache::loncommon::no_cache($r);
439: $r->send_http_header;
440:
441: my $firstres=$hash{'map_start_'.
442: &Apache::lonnet::clutter($ENV{'request.course.uri'})};
443: my $lastres=$hash{'map_finish_'.
444: &Apache::lonnet::clutter($ENV{'request.course.uri'})};
445: if (!(($firstres) && ($lastres))) {
446: $r->print('<html><body>Coursemap undefined.</body></html>');
447: } else {
448:
449: # ----------------------------------------------------------------- Render page
450: # -------------------------------------------------------------- Set parameters
451:
452:
453: # ---------------------------- initialize coursedata and userdata for this user
454: undef %courseopt;
455: undef %useropt;
456:
457: my $uname=$ENV{'user.name'};
458: my $udom=$ENV{'user.domain'};
459: my $uhome=$ENV{'user.home'};
460: my $cid=$ENV{'request.course.id'};
461: my $chome=$ENV{'course.'.$cid.'.home'};
462: my ($cdom,$cnum)=split(/\_/,$cid);
463:
464: my $userprefix=$uname.'_'.$udom.'_';
465:
466: unless ($uhome eq 'no_host') {
467: # -------------------------------------------------------------- Get coursedata
468: unless ((time-$courserdatas{$cid.'.last_cache'})<240) {
469: my $reply=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum.
470: ':resourcedata',$chome);
471: if ($reply!~/^error\:/) {
472: $courserdatas{$cid}=$reply;
473: $courserdatas{$cid.'.last_cache'}=time;
474: }
475: else
476: {
477: $networkFailedFlag = 1;
478: }
479: }
480: foreach (split(/\&/,$courserdatas{$cid})) {
481: my ($name,$value)=split(/\=/,$_);
482: $courseopt{$userprefix.&Apache::lonnet::unescape($name)}=
483: &Apache::lonnet::unescape($value);
484: }
485: # --------------------------------------------------- Get userdata (if present)
486: unless ((time-$userrdatas{$uname.'___'.$udom.'.last_cache'})<240) {
487: my $reply=&Apache::lonnet::reply('dump:'.$udom.':'.$uname.':resourcedata',$uhome);
488: if ($reply!~/^error\:/) {
489: $userrdatas{$uname.'___'.$udom}=$reply;
490: $userrdatas{$uname.'___'.$udom.'.last_cache'}=time;
491: }
492: }
493: foreach (split(/\&/,$userrdatas{$uname.'___'.$udom})) {
494: my ($name,$value)=split(/\=/,$_);
495: $useropt{$userprefix.&Apache::lonnet::unescape($name)}=
496: &Apache::lonnet::unescape($value);
497: }
498: }
499:
500: @rows=();
501:
502: &tracetable(0,$firstres,'&','',0);
503:
504: # ------------------------------------------------------------------ Page parms
505:
506: my $j;
507: my $i;
508: my $lcm=1;
509: my $contents=0;
510:
511: # ---------------------------------------------- Go through table to get layout
512:
513: for ($i=0;$i<=$#rows;$i++) {
514: if ($rows[$i]) {
515: &Apache::lonxml::debug("Row $i is:".$rows[$i]);
516: $contents++;
517: my @colcont=split(/\&/,$rows[$i]);
518: $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1));
519: }
520: }
521:
522:
523: unless ($contents) {
524: $r->print('<html><body>Empty Map.</body></html>');
525: } else {
526:
527: # ------------------------------------------------------------------ Build page
528:
529: my $currenturl=$ENV{'form.postdata'};
530: $currenturl=~s/^http\:\/\///;
531: $currenturl=~s/^[^\/]+//;
532:
533: # ---------------------------------------------------------------- Send headers
534:
535: my $date=localtime;
536: my $now=time;
537: # ----------------------------------------- Get email status and discussiontime
538:
539: my %emailstatus=&Apache::lonnet::dump('email_status');
540: my $logouttime=$emailstatus{'logout'};
541: my $courseleave=$emailstatus{'logout_'.$ENV{'request.course.id'}};
542: my $lastcheck=($courseleave>$logouttime?$courseleave:$logouttime);
543:
544: my %discussiontimes=&Apache::lonnet::dump('discussiontimes',
545: $cdom,$cnum);
546:
547: my %feedback=();
548: my %error=();
549: foreach my $msgid (split(/\&/,&Apache::lonnet::reply('keys:'.
550: $ENV{'user.domain'}.':'.
551: $ENV{'user.name'}.':nohist_email',
552: $ENV{'user.home'}))) {
553: $msgid=&Apache::lonnet::unescape($msgid);
554: my $plain=&Apache::lonnet::unescape(&Apache::lonnet::unescape($msgid));
555: if ($plain=~/(Error|Feedback) \[([^\]]+)\]/) {
556: my ($what,$url)=($1,$2);
557: my %status=
558: &Apache::lonnet::get('email_status',[$msgid]);
559: if ($status{$msgid}=~/^error\:/) {
560: $status{$msgid}='';
561: }
562:
563: if (($status{$msgid} eq 'new') ||
564: (!$status{$msgid})) {
565: if ($what eq 'Error') {
566: $error{$url}.=','.$msgid;
567: } else {
568: $feedback{$url}.=','.$msgid;
569: }
570: }
571: }
572: }
573: # ----------------------------------------------------------- Start Page Output
574: my $bodytagadd='';
575: $r->print(
576: '<html><head><title>Navigate Course Map</title></head>');
577: if (($currenturl=~/^\/res/) &&
578: ($currenturl!~/^\/res\/adm/)) {
579: $bodytagadd='onLoad="window.location.hash='."'curloc'".'"';
580: }
581: $r->print(&Apache::loncommon::bodytag('Navigate Course Map','',
582: $bodytagadd));
583: $r->print('<script>window.focus();</script>');
584: my $desc=$ENV{'course.'.$ENV{'request.course.id'}.'.description'};
585: if (defined($desc)) { $r->print("<h2>$desc</h2>\n"); }
586: $r->print("<h3>$date</h3>\n");
587: $r->rflush();
588: $r->print('<img src="/adm/lonMisc/chat.gif"> New discussion since '.
589: localtime($lastcheck).
590: '<br><img src="/adm/lonMisc/feedback.gif"> New message (click to open)<p>');
591: if (($currenturl=~/^\/res/) &&
592: ($currenturl!~/^\/res\/adm/)) {
593: $r->print('<a href="#curloc">Current Location</a><p>');
594: }
595:
596: # Handle a network error
597:
598: if ($networkFailedFlag)
599: {
600: $r->print('<H2>LON-CAPA network failure.</H2>'."\n");
601: $r->print("<p>LON-CAPA's network is having difficulties, some problem" .
602: " information, such as due dates, will not be available.");
603: }
604: # ----------------------------------------------------- The little content list
605: for ($i=0;$i<=$#rows;$i++) {
606: if ($rows[$i]) {
607: my @colcont=split(/\&/,$rows[$i]);
608: my $avespan=$lcm/($#colcont+1);
609: for ($j=0;$j<=$#colcont;$j++) {
610: my $rid=$colcont[$j];
611: if ($rid=~/^h(.+)/) {
612: $rid=$1;
613: $r->print(' <a href="#'.
614: $rid.'">'.$hash{'title_'.$rid}.
615: '</a><br>');
616: }
617: }
618: }
619: }
620: # ----------------------------------------------------------------- Start table
621: $r->print('<hr><table cols="'.$lcm.'" border="0">');
622: for ($i=0;$i<=$#rows;$i++) {
623: if ($rows[$i]) {
624: $r->print("\n<tr>");
625: my @colcont=split(/\&/,$rows[$i]);
626: my $avespan=$lcm/($#colcont+1);
627:
628: # for each item I wish to print on this row...
629: for ($j=0;$j<=$#colcont;$j++) {
630: my $indent;my $indentstr;
631: my $linkid;
632: my $rid=$colcont[$j];
633: $rid=~/(\d+)\.(\d+)$/;
634: my $src=
635: &Apache::lonnet::declutter($hash{'src_'.$1.'.'.$2});
636: my $symb=
637: &Apache::lonnet::declutter($hash{'map_id_'.$1}).'___'.$2.'___'.$src;
638: my $add='<td>';
639: my $adde='</td>';
640: my $hwk='<font color="#223322">';
641: my $hwke='</font>';
642: if ($rid=~/^l(\d+\.\d+),(.+)/) { $linkid=$1; $rid=$2; }
643: if ($rid=~/^i(\d+),(.+)/) { $indent=$1; $rid=$2; }
644: if ($rid=~/^h(.+)/) {
645: $rid=$1;
646: $add='<th bgcolor="#AAFF55"><a name="'.$rid.'">';
647: $adde='</th>';
648: if (($ENV{'user.adv'}) &&
649: ($parmhash{$symb.'.0.parameter_randompick'})) {
650: $adde=' (randomly select '.
651: $parmhash{$symb.'.0.parameter_randompick'}.
652: ')</th>';
653: }
654: }
655: if ($rid=~/^j(.+)/) { $rid=$1; }
656: if ($rid=~/^p(\d)(\d)\"([\w\: \(\)\/\,]*)\"(.+)/) {
657: # sub astatus describes what code/tcode mean
658: my $code=$1;
659: my $tcode=$2;
660: my $ctext=$3;
661: $rid=$4;
662:
663: # will open later
664: if ($tcode eq '1') {
665: $add='<td bgcolor="#AAAAAA">';
666: }
667:
668: # solved/correct
669: if ($code eq '3') {
670: $add='<td bgcolor="#AAFFAA">';
671: } elsif ($code eq '4') { # partially correct
672: $add='<td bgcolor="#E0FFAA">';
673: } else {
674: # not attempted
675:
676: # we end up here on network failure, so pick a neutral
677: # color if the network failed instead of bright red.
678: if ( $networkFailedFlag )
679: {
680: $add = '<td bgcolor="#AAAAAA">';
681: }
682: else
683: {
684: $add='<td bgcolor="#FFAAAA">';
685: }
686:
687: if ($tcode eq '2') { # open, not past due
688: $add='<td bgcolor="#FFFFAA">';
689: }
690:
691: if ($tcode eq '4') { # due in next 24 hours
692: $add='<td bgcolor="#FFFF33">';
693: $adde='</td>';
694: }
695: }
696: $hwk='<font color="#888811"><b>';
697: $hwke='</b></font>';
698: if ($code eq '1') {
699: $hwke='</b> ('.$ctext.')</font>';
700: }
701: if ($code eq '2' || $code eq '4') {
702: $hwk='<font color="#992222"><b>';
703: $hwke='</b> ('.$ctext.')</font>';
704: }
705: if ($code eq '3') {
706: $hwk='<font color="#229922"><b>';
707: $hwke='</b> ('.$ctext.')</font>';
708: }
709: if ($networkFailedFlag)
710: {
711: $hwke='</b> (status unavailable)</font>';
712: }
713: }
714: if ($rid && $hash{'src_'.$rid} eq $currenturl) {
715: $add=$add.'<a name="curloc"></a>'.
716: '<font color=red size=+2><b>> </b></font>';
717: $adde=
718: '<font color=red size=+2><b> <</b></font>'.$adde;
719: }
720: if ($discussiontimes{$symb}>$lastcheck) {
721: $adde=
722: '<img border=0 src="/adm/lonMisc/chat.gif">'.
723: $adde;
724: }
725: if ($error{$src}) {
726: foreach (split(/\,/,$error{$src})) {
727: if ($_) {
728: $adde=
729: ' <a href="/adm/email?display='.
730: &Apache::lonnet::escape($_).
731: '"><img src="/adm/lonMisc/bomb.gif" border=0></a>'
732: .$adde;
733: }
734: }
735: }
736: if ($feedback{$src}) {
737: foreach (split(/\,/,$feedback{$src})) {
738: if ($_) {
739: $adde=
740: ' <a href="/adm/email?display='.
741: &Apache::lonnet::escape($_).
742: '"><img src="/adm/lonMisc/feedback.gif" border=0></a>'
743: .$adde;
744: }
745: }
746: }
747: if ($indent) {
748: my $is=" ";
749: for(my $i=-1;$i<$indent;$i++) { $indentstr.=$is; }
750: }
751: if (!$linkid) { $linkid=$rid; }
752: if ($hash{'randomout_'.$rid}) {
753: $adde=' <i>(hidden)</i>'.$adde;
754: }
755: $r->print($add.$indentstr);
756: if ($rid) {
757: $r->print('<a href="'.$hash{'src_'.$linkid}.
758: (($hash{'src_'.$linkid}=~/\?/)?'&':'?').
759: 'symb='.&Apache::lonnet::escape($symb)
760: .'">'.
761: $hwk.$hash{'title_'.$rid}.$hwke.'</a>');
762: }
763: $r->print($adde);
764: }
765: $r->print('</tr>');
766: }
767: }
768: $r->print("\n</table>");
769: $r->print('</body></html>');
770: # -------------------------------------------------------------------- End page
771: }
772: # ------------------------------------------------------------- End render page
773: }
774: # ------------------------------------------------------------------ Untie hash
775: unless (untie(%hash)) {
776: &Apache::lonnet::logthis("<font color=blue>WARNING: ".
777: "Could not untie coursemap $fn (browse).</font>");
778: }
779: unless (untie(%parmhash)) {
780: &Apache::lonnet::logthis("<font color=blue>WARNING: ".
781: "Could not untie parmhash (browse).</font>");
782: }
783: return OK;
784: }
785:
786: 1;
787: __END__
788:
789:
790:
791:
792:
793:
794:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>