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