Annotation of rat/lonpage.pm, revision 1.119
1.1 www 1: # The LearningOnline Network with CAPA
2: # Page Handler
3: #
1.119 ! raeburn 4: # $Id: lonpage.pm,v 1.118 2016/08/09 23:43:51 raeburn Exp $
1.29 www 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.30 harris41 28: ###
1.1 www 29:
1.88 jms 30:
31:
32:
1.1 www 33: package Apache::lonpage;
34:
35: use strict;
36: use Apache::Constants qw(:common :http);
1.70 albertel 37: use Apache::lonnet;
1.30 harris41 38: use Apache::loncommon();
1.102 raeburn 39: use Apache::lonhtmlcommon;
1.21 www 40: use Apache::lonxml();
1.57 raeburn 41: use Apache::lonlocal;
1.49 www 42: use Apache::lonmenu;
1.111 raeburn 43: use Apache::lonhomework;
1.112 raeburn 44: use Apache::lonparmset;
1.6 www 45: use HTML::TokeParser;
1.1 www 46: use GDBM_File;
1.39 www 47: use Apache::lonsequence;
1.75 www 48: use lib '/home/httpd/lib/perl/';
49: use LONCAPA;
50:
1.1 www 51:
1.2 www 52: # -------------------------------------------------------------- Module Globals
53: my %hash;
54: my @rows;
1.6 www 55:
56: # ------------------------------------------------------------------ Euclid gcd
57:
58: sub euclid {
59: my ($e,$f)=@_;
60: my $a; my $b; my $r;
61: if ($e>$f) { $b=$e; $r=$f; } else { $r=$e; $b=$f; }
62: while ($r!=0) {
63: $a=$b; $b=$r;
64: $r=$a%$b;
65: }
66: return $b;
67: }
1.2 www 68:
69: # ------------------------------------------------------------ Build page table
70:
71: sub tracetable {
72: my ($sofar,$rid,$beenhere)=@_;
73: my $further=$sofar;
1.57 raeburn 74: my $randomout=0;
1.70 albertel 75: unless ($env{'request.role.adv'}) {
1.57 raeburn 76: $randomout = $hash{'randomout_'.$rid};
77: }
1.2 www 78: unless ($beenhere=~/\&$rid\&/) {
1.57 raeburn 79: $beenhere.=$rid.'&';
80: unless ($randomout) {
81: if (defined($hash{'is_map_'.$rid})) {
82: if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) &&
83: (defined($hash{'map_finish_'.$hash{'src_'.$rid}}))) {
84: my $frid=$hash{'map_finish_'.$hash{'src_'.$rid}};
85: $sofar=
86: &tracetable($sofar,$hash{'map_start_'.$hash{'src_'.$rid}},
1.87 albertel 87: '&'.$frid.$beenhere);
1.57 raeburn 88: $sofar++;
89: if ($hash{'src_'.$frid}) {
90: my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$frid});
91: if (($brepriv eq '2') || ($brepriv eq 'F')) {
92: if (defined($rows[$sofar])) {
93: $rows[$sofar].='&'.$frid;
94: } else {
95: $rows[$sofar]=$frid;
96: }
97: }
98: }
99: }
100: } else {
101: $sofar++;
102: if ($hash{'src_'.$rid}) {
103: my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$rid});
104: if (($brepriv eq '2') || ($brepriv eq 'F')) {
105: if (defined($rows[$sofar])) {
106: $rows[$sofar].='&'.$rid;
107: } else {
108: $rows[$sofar]=$rid;
109: }
110: }
111: }
112: }
113: }
114:
115: if (defined($hash{'to_'.$rid})) {
116: my $mincond=1;
117: my $next='';
118: foreach (split(/\,/,$hash{'to_'.$rid})) {
119: my $thiscond=
1.11 www 120: &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$_}});
1.57 raeburn 121: if ($thiscond>=$mincond) {
122: if ($next) {
123: $next.=','.$_.':'.$thiscond;
124: } else {
125: $next=$_.':'.$thiscond;
126: }
127: if ($thiscond>$mincond) { $mincond=$thiscond; }
128: }
129: }
130: foreach (split(/\,/,$next)) {
131: my ($linkid,$condval)=split(/\:/,$_);
132: if ($condval>=$mincond) {
133: my $now=&tracetable($sofar,$hash{'goesto_'.$linkid},$beenhere);
134: if ($now>$further) { $further=$now; }
135: }
136: }
137: }
1.2 www 138: }
139: return $further;
140: }
141:
1.1 www 142: # ================================================================ Main Handler
143:
144: sub handler {
145: my $r=shift;
146:
1.3 www 147: # ------------------------------------------- Set document type for header only
1.1 www 148:
1.3 www 149: if ($r->header_only) {
1.70 albertel 150: if ($env{'browser.mathml'}) {
1.53 www 151: &Apache::loncommon::content_type($r,'text/xml');
1.3 www 152: } else {
1.53 www 153: &Apache::loncommon::content_type($r,'text/html');
1.3 www 154: }
155: $r->send_http_header;
156: return OK;
157: }
1.43 sakharuk 158:
1.39 www 159: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
160: ['forceselect','launch']);
1.43 sakharuk 161: my $number_of_columns = 1;
1.37 sakharuk 162: my $requrl=$r->uri;
1.70 albertel 163: my $target = $env{'form.grade_target'};
1.94 raeburn 164:
165: # Short term solution: define target as 'tex_answer' when retrieving answers
166: # for resources in a .page when generating printouts.
167: # A better long-term fix would be to modify the way problem rendering, and
168: # answer rendering are retrieved for individual resources when printing a .page,
169: # so rendered problem and answer are sequential for individual resources in
170: # the .page
171: #
172: if ($target eq 'answer') {
173: if ($env{'form.answer_output_mode'} eq 'tex') {
174: $target = 'tex_answer';
175: }
176: }
1.55 www 177: # &Apache::lonnet::logthis("Got a target of $target");
1.54 albertel 178: if ($target eq 'meta') {
179: &Apache::loncommon::content_type($r,'text/html');
180: $r->send_http_header;
181: return OK;
182: }
1.1 www 183: # ----------------------------------------------------------------- Tie db file
1.70 albertel 184: if (($env{'request.course.fn'}) && (!$env{'form.forceselect'})) {
185: my $fn=$env{'request.course.fn'};
1.1 www 186: if (-e "$fn.db") {
1.119 ! raeburn 187: my %buttonshide;
1.44 albertel 188: if (tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER(),0640)) {
1.1 www 189: # ------------------------------------------------------------------- Hash tied
190: my $firstres=$hash{'map_start_'.$requrl};
191: my $lastres=$hash{'map_finish_'.$requrl};
192: if (($firstres) && ($lastres)) {
1.111 raeburn 193: # ------------------------------------------------------------- Countdown Timer
194: my $now = time;
1.112 raeburn 195: my ($pagefirstaccess,%hastimeleft,%countdowndisp,%donebutton,
1.114 raeburn 196: %donebtnextra,%buttonbytime,$donetime,$symbtosetdone);
1.111 raeburn 197: my ($pagesymb,$courseid,$domain,$name)=&Apache::lonnet::whichuser();
1.114 raeburn 198: unless ($pagesymb) {
199: $pagesymb=&Apache::lonnet::symbread($requrl);
200: }
1.113 musolffc 201: if ($pagesymb && ($courseid ne '') && ($domain ne '') && ($name ne '')) {
1.111 raeburn 202: my %times=&Apache::lonnet::get('firstaccesstimes',
203: [$courseid."\0".$pagesymb],
204: $domain,$name);
205: if ($times{$courseid."\0".$pagesymb} =~ /^\d+$/) {
206: $pagefirstaccess = $times{$courseid."\0".$pagesymb};
1.112 raeburn 207: if ($pagefirstaccess && $env{'form.LC_interval_done'} eq 'true') {
208: $donetime = $now - $pagefirstaccess;
209: }
1.111 raeburn 210: }
211: }
1.112 raeburn 212:
1.1 www 213: # ----------------------------------------------------------------- Render page
214:
1.3 www 215: @rows=();
1.2 www 216:
1.45 www 217: &tracetable(0,$firstres,'&');
1.2 www 218:
1.9 www 219: # ------------------------------------------------------------ Add to symb list
220:
1.2 www 221: my $i;
1.9 www 222: my %symbhash=();
223: for ($i=0;$i<=$#rows;$i++) {
224: if ($rows[$i]) {
225: my @colcont=split(/\&/,$rows[$i]);
1.73 albertel 226: foreach my $rid (@colcont) {
227: my ($mapid,$resid)=split(/\./,$rid);
228: $symbhash{$hash{'src_'.$rid}}=
229: [$hash{'src_'.$rid},$resid];
1.112 raeburn 230: if (($donetime) && ($symbtosetdone eq '')) {
231: my $src = $hash{'src_'.$rid};
232: if ($hash{'encrypted_'.$rid}) {
233: $src=&Apache::lonenc::encrypted($src);
234: }
235: my ($mapid,$resid)=split(/\./,$rid);
236: my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$src);
237: if ($src =~ /$LONCAPA::assess_re/) {
238: my @interval=&Apache::lonnet::EXT("resource.0.interval",$symb);
239: if (@interval > 1) {
1.114 raeburn 240: if (($interval[1] eq 'map') && ($pagefirstaccess)) {
241: my ($timelimit) = ($interval[0] =~ /^(\d+)/);
242: if ($timelimit) {
243: if ($pagefirstaccess + $timelimit > $now) {
244: $symbtosetdone = $symb;
245: }
1.112 raeburn 246: }
247: }
248: }
249: }
250: }
1.30 harris41 251: }
1.9 www 252: }
253: }
254: &Apache::lonnet::symblist($requrl,%symbhash);
255:
256: # ------------------------------------------------------------------ Page parms
257:
1.4 www 258: my $j;
1.6 www 259: my $lcm=1;
260: my $contents=0;
1.7 www 261: my $nforms=0;
1.96 raeburn 262: my $nuploads=0;
1.110 raeburn 263: my $ntimers=0;
1.96 raeburn 264: my %turninpaths;
265: my %multiresps;
266: my $turninparent;
1.6 www 267:
268: my %ssibody=();
269: my %ssibgcolor=();
270: my %ssitext=();
271: my %ssilink=();
272: my %ssivlink=();
273: my %ssialink=();
1.14 www 274:
1.6 www 275: my %cellemb=();
1.99 raeburn 276: my %cellexternal=();
1.3 www 277:
1.7 www 278: my $allscript='';
279: my $allmeta='';
280:
281: my $isxml=0;
282: my $xmlheader='';
283: my $xmlbody='';
284:
1.112 raeburn 285: # ---------------------------------------------------------- Handle Done button
286:
287: # Set the event timer to zero if the "done button" was clicked.
288: if ($donetime && $symbtosetdone) {
289: &Apache::lonparmset::storeparm_by_symb_inner($symbtosetdone,'0_interval',
290: 2,$donetime,'date_interval',
291: $name,$domain);
292: undef($env{'form.LC_interval_done'});
293: }
294:
1.3 www 295: # --------------------------------------------- Get SSI output, post parameters
296:
1.2 www 297: for ($i=0;$i<=$#rows;$i++) {
1.4 www 298: if ($rows[$i]) {
1.6 www 299: $contents++;
1.3 www 300: my @colcont=split(/\&/,$rows[$i]);
1.6 www 301: $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1));
1.30 harris41 302: foreach (@colcont) {
1.3 www 303: my $src=$hash{'src_'.$_};
1.99 raeburn 304: my ($extension)=($src=~/\.(\w+)$/);
305: $cellexternal{$_}=($hash{'ext_'.$_} eq 'true:');
1.61 albertel 306: if ($hash{'encrypted_'.$_}) {
307: $src=&Apache::lonenc::encrypted($src);
308: }
1.119 ! raeburn 309: my ($mapid,$resid)=split(/\./,$_);
! 310: my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$src);
! 311: unless ($env{'request.role.adv'}) {
! 312: $buttonshide{$symb} = &Apache::lonnet::EXT("resource.0.buttonshide",$symb);
! 313: }
1.61 albertel 314: $cellemb{$_}=
315: &Apache::loncommon::fileembstyle($extension);
1.99 raeburn 316: if ($cellexternal{$_}) {
317: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
318: $ssibody{$_} = <<ENDEXT;
319: <iframe src="$src" width="100%">No iframe support!</iframe>
320: ENDEXT
321: }
322: } elsif ($cellemb{$_} eq 'ssi') {
1.3 www 323: # --------------------------------------------------------- This is an SSI cell
1.5 www 324: my $prefix=$_.'_';
1.101 raeburn 325: my $idprefix= join('_',($mapid,$resid,''));
1.64 albertel 326: my %posthash=('request.prefix' => $prefix,
1.71 albertel 327: 'LONCAPA_INTERNAL_no_discussion' => 'true',
1.64 albertel 328: 'symb' => $symb);
1.94 raeburn 329: if (($env{'form.grade_target'} eq 'tex') ||
330: ($env{'form.answer_output_mode'} eq 'tex')) {
1.70 albertel 331: $posthash{'grade_target'}=$env{'form.grade_target'};
332: $posthash{'textwidth'}=$env{'form.textwidth'};
333: $posthash{'problem_split'}=$env{'form.problem_split'};
334: $posthash{'latex_type'}=$env{'form.latex_type'};
335: $posthash{'rndseed'}=$env{'form.rndseed'};
1.94 raeburn 336: $posthash{'answer_output_mode'} = $env{'form.answer_output_mode'};
1.56 sakharuk 337: }
1.72 albertel 338: my $submitted=exists($env{'form.all_submit'});
339: if (!$submitted) {
340: foreach my $key (keys(%env)) {
341: if ($key=~/^form.\Q$prefix\Esubmit_/) {
342: $submitted=1;last;
343: }
344: }
345: }
346: if ($submitted) {
347: foreach my $key (keys(%env)) {
348: if ($key=~/^form.\Q$prefix\E/) {
349: my $name=$key;
350: $name=~s/^form.\Q$prefix\E//;
351: $posthash{$name}=$env{$key};
352: }
353: }
354: if (exists($env{'form.all_submit'})) {
355: $posthash{'all_submit'}='yes';
356: }
1.7 www 357: }
1.5 www 358: my $output=Apache::lonnet::ssi($src,%posthash);
1.77 albertel 359: $output=~s|//(\s*<!--)? BEGIN LON-CAPA Internal.+?// END LON-CAPA Internal\s*(-->)?\s||gs;
1.94 raeburn 360: if (($target eq 'tex') || ($target eq 'tex_answer')) {
1.118 raeburn 361: $output =~ s/^([^&]+)\\begin\{document}//;
362: $output =~ s/\\end\{document}//;
1.92 foxr 363: # $output = '\parbox{\minipagewidth}{ '.$output.' }';
1.46 sakharuk 364: #some additional cleanup necessary for LateX (due to limitations of table environment
365: $output =~ s/(\\vskip\s*\d+mm)\s*(\\\\)+/$1/g;
366: }
1.107 raeburn 367: my $matheditor;
368: if ($output =~ /\Qjavascript:LC_mathedit_HWVAL_\E/) {
369: $matheditor = 'dragmath';
370: } elsif ($output =~ /LCmathField/) {
371: $matheditor = 'lcmath';
372: }
1.6 www 373: my $parser=HTML::TokeParser->new(\$output);
374: my $token;
1.12 www 375: my $thisdir=$src;
1.6 www 376: my $bodydef=0;
1.7 www 377: my $thisxml=0;
1.12 www 378: my @rlinks=();
1.7 www 379: if ($output=~/\?xml/) {
380: $isxml=1;
381: $thisxml=1;
382: $output=~
383: /((?:\<(?:\?xml|\!DOC|html)[^\>]*(?:\>|\>\]\>)\s*)+)\<body[^\>]*\>/si;
384: $xmlheader=$1;
385: }
1.12 www 386: while ($token=$parser->get_token) {
387: if ($token->[0] eq 'S') {
388: if ($token->[1] eq 'a') {
389: if ($token->[2]->{'href'}) {
390: $rlinks[$#rlinks+1]=
391: $token->[2]->{'href'};
392: }
393: } elsif ($token->[1] eq 'img') {
394: $rlinks[$#rlinks+1]=
395: $token->[2]->{'src'};
396: } elsif ($token->[1] eq 'embed') {
397: $rlinks[$#rlinks+1]=
398: $token->[2]->{'src'};
399: } elsif ($token->[1] eq 'base') {
400: $thisdir=$token->[2]->{'href'};
401: } elsif ($token->[1] eq 'body') {
1.7 www 402: $bodydef=1;
403: $ssibgcolor{$_}=$token->[2]->{'bgcolor'};
404: $ssitext{$_}=$token->[2]->{'text'};
405: $ssilink{$_}=$token->[2]->{'link'};
406: $ssivlink{$_}=$token->[2]->{'vlink'};
407: $ssialink{$_}=$token->[2]->{'alink'};
408: if ($thisxml) {
409: $xmlbody=$token->[4];
410: }
1.12 www 411: } elsif ($token->[1] eq 'meta') {
1.28 albertel 412: if ($token->[4] !~ m:/>$:) {
1.7 www 413: $allmeta.="\n".$token->[4].'</meta>';
1.28 albertel 414: } else {
415: $allmeta.="\n".$token->[4];
416: }
1.12 www 417: } elsif (($token->[1] eq 'script') &&
418: ($bodydef==0)) {
1.7 www 419: $allscript.="\n\n"
420: .$parser->get_text('/script');
1.6 www 421: }
1.12 www 422: }
423: }
1.6 www 424: if ($output=~/\<body[^\>]*\>(.*)/si) {
425: $output=$1;
426: }
427: $output=~s/\<\/body\>.*//si;
1.7 www 428: if ($output=~/\<form/si) {
1.110 raeburn 429: my $hastimer;
1.7 www 430: $nforms++;
431: $output=~s/\<form[^\>]*\>//gsi;
432: $output=~s/\<\/form[^\>]*\>//gsi;
1.96 raeburn 433: if ($output=~/\<input[^\>]+name\s*=\s*[\'\"]*HWFILE/) {
434: $nuploads++;
435: }
1.110 raeburn 436: if ($output=~/\<input[^\>]+name\s*=\s*[\'\"]*accessbutton/) {
437: $ntimers++;
438: $hastimer = 1;
439: }
1.17 www 440: $output=~
1.80 albertel 441: s/\<((?:input|select|button|textarea)[^\>]+)name\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\>]*)\>/\<$1 name="$prefix$2" $3\>/gsi;
1.101 raeburn 442: $output=~
443: s/\<((?:input|select|button|textarea)[^\>]+)id\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\>]*)\>/\<$1 id="$idprefix$2" $3\>/gsi;
1.110 raeburn 444: if ($hastimer) {
445: $output=~
446: s/\<(input[^\>]+name=\Q"$prefix\Eaccessbutton"[^\>]+)(?:\Qdocument.markaccess.submit();\E)([^\>]*)\>/\<$1pageTimer(this.form,'$prefix')$2\>/gsi;
447: $output=~ s/\<(input[^\>]+name=\Q"$prefix\Emarkaccess"[^\>]+value=["'])(?:yes)(['"][^\>]*)\>/\<$1$2\>/gsi;
448: }
1.107 raeburn 449: if ($matheditor eq 'dragmath') {
450: $output=~
451: s/(\Qjavascript:LC_mathedit_\E)(HWVAL_)([^'"]+?)(\(['"]*)(\QHWVAL_\E\3['"]\)\;void\(0\)\;)/$1$idprefix$2$3$4$idprefix$5/g;
452: $output=~
453: s/(function\s+LC_mathedit_)(HWVAL_)([^'"]+?)(\s+\(LCtextline\))/$1$idprefix$2$3$4/g;
454: } elsif ($matheditor eq 'lcmath') {
455: $output=~
456: s/(var\s+LCmathField\s+=\s+document\.getElementById\(['"])([^'"]+?)(['"]\)\;)/$1$idprefix$2$3/g;
457: }
1.105 raeburn 458: $output=~
459: s/(\Q<div id="msg_\E)(\Qsubmit_\E)([^"]*)(\Q" style="display:none">\E)/<input type="hidden" name="$prefix$2$3_pressed" id="$idprefix$2$3_pressed" value="" \/>$1$idprefix$2$3$4/g;
460: $output=~
461: s/(\Q<td class="LC_status_\E)(\Qsubmit_\E)([^\"]*)(\s*[^\"]*"\>)/$1$idprefix$2$3$4/g;
1.96 raeburn 462: if ($nuploads) {
463: $output=~
464: s/\<(input[^\>]+name=\"\Q$prefix\EHWFILE[^\>]+)\s*id\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\)]*)\>/\<$1 id="$prefix$2" $3\>/gsi;
465: ($turninpaths{$prefix},$multiresps{$prefix}) =
466: &Apache::loncommon::get_turnedin_filepath($symb,$env{'user.name'},$env{'user.domain'});
467: if ($turninparent eq '') {
468: $turninparent = $turninpaths{$prefix};
469: $turninparent =~ s{(/[^/]+)$}{};
470: }
471: }
1.95 raeburn 472: $output=~
473: s/\<((?:input|select)[^\>]+\Qjavascript:setSubmittedPart\E)\(\s*[\'\"]([^\'\"]+)[\'\"]*\s*\)/\<$1('$2','$prefix')/gsi;
1.108 raeburn 474: $output=~
475: s/\<(input[^\>]+\Qonfocus=\"javascript:disableAutoComplete\E)\(\'([^\']+)\'\)(;\")/\<$1('$idprefix$2')$3/gsi;
1.111 raeburn 476: unless ($hastimer) {
477: if ($src =~ /$LONCAPA::assess_re/) {
478: %Apache::lonhomework::history =
479: &Apache::lonnet::restore($symb,$courseid,$domain,$name);
480: my $type = 'problem';
481: if ($src =~ /\.task$/) {
482: $type = 'Task';
483: }
484: my ($status,$accessmsg,$slot_name,$slot) =
1.117 raeburn 485: &Apache::lonhomework::check_slot_access('0',$type,$symb);
1.111 raeburn 486: undef(%Apache::lonhomework::history);
487: my $probstatus = &Apache::lonnet::EXT("resource.0.problemstatus",$symb);
488: if (($status eq 'CAN_ANSWER') || (($status eq 'CANNOT_ANSWER') &&
1.114 raeburn 489: (($probstatus eq 'no') || ($probstatus eq 'no_feedback_ever'))) ||
490: (($status eq 'NOT_YET_VIEWED') && ($posthash{'markaccess'} eq 'yes'))) {
1.111 raeburn 491: my ($slothastime,$timerhastime);
492: if ($slot_name ne '') {
493: if (ref($slot) eq 'HASH') {
494: if (($slot->{'starttime'} < $now) &&
495: ($slot->{'endtime'} > $now)) {
496: $slothastime = $now - $slot->{'endtime'};
497: }
498: }
499: }
500: my $duedate = &Apache::lonnet::EXT("resource.0.duedate",$symb);
501: my @interval=&Apache::lonnet::EXT("resource.0.interval",$symb);
502: if (@interval > 1) {
1.114 raeburn 503: my $first_access;
1.115 raeburn 504: if ($interval[1] eq 'map') {
505: my $ignorecache;
506: if ($env{'form.'.$prefix.'markaccess'} eq 'yes') {
507: $ignorecache = 1;
1.114 raeburn 508: }
1.115 raeburn 509: $first_access=&Apache::lonnet::get_first_access($interval[1],undef,$pagesymb,$ignorecache);
510: if (($first_access) && (!$pagefirstaccess)) {
511: $pagefirstaccess = $first_access;
1.114 raeburn 512: }
1.115 raeburn 513: } else {
514: $first_access=&Apache::lonnet::get_first_access($interval[1],$symb);
515: }
516: if ($first_access > 0) {
1.114 raeburn 517: my ($timelimit) = ($interval[0] =~ /^(\d+)/);
1.115 raeburn 518: if ($timelimit) {
519: my $timeremains = $timelimit + $first_access - $now;
520: if ($timeremains > 0) {
521: $timerhastime = $timeremains;
522: }
1.111 raeburn 523: }
524: }
525: }
526: if (($duedate && $duedate > $now) ||
527: (!$duedate && $timerhastime > 0) ||
528: ($slot_name ne '' && $slothastime)) {
529: if ((@interval > 1 && $timerhastime) ||
530: ($type eq 'Task' && $slothastime)) {
531: $countdowndisp{$symb} = 'inline';
532: if ((@interval > 1) && ($timerhastime)) {
533: $hastimeleft{$symb} = $timerhastime;
1.112 raeburn 534: if ($pagefirstaccess) {
1.114 raeburn 535: my ($timelimit,$usesdone,$donebuttontext,$proctor,$secret);
536: ($timelimit,my $donesuffix) = split(/_/,$interval[0],2);
537: if ($donesuffix =~ /^done\:([^\:]+)\:(.*)$/) {
538: $usesdone = 'done';
539: $donebuttontext = $1;
540: (undef,$proctor,$secret) = split(/_/,$2);
541: } elsif ($donesuffix =~ /^done(|_.+)$/) {
542: $donebuttontext = &mt('Done');
543: ($usesdone,$proctor,$secret) = split(/_/,$donesuffix);
544: }
545: if ($usesdone eq 'done') {
546: $donebutton{$symb} = $timelimit;
547: push(@{$buttonbytime{$timelimit}},$symb);
548: $donebtnextra{$symb} = {
549: text => $donebuttontext,
550: proctor => $proctor,
551: secret => $secret,
552: type => $interval[1],
553: };
554: }
1.112 raeburn 555: }
1.111 raeburn 556: } else {
557: $hastimeleft{$symb} = $slothastime;
558: }
559: } else {
560: $hastimeleft{$symb} = $duedate - $now;
561: $countdowndisp{$symb} = 'none';
562: }
1.112 raeburn 563: unless ($donebutton{$symb}) {
1.114 raeburn 564: $donebutton{$symb} = 0;
1.112 raeburn 565: }
1.111 raeburn 566: }
567: }
568: }
569: }
1.7 www 570: }
1.12 www 571: $thisdir=~s/\/[^\/]*$//;
1.30 harris41 572: foreach (@rlinks) {
1.91 raeburn 573: unless (($_=~/^https?\:\/\//i) ||
1.31 albertel 574: ($_=~/^\//) ||
575: ($_=~/^javascript:/i) ||
576: ($_=~/^mailto:/i) ||
577: ($_=~/^\#/)) {
1.12 www 578: my $newlocation=
579: &Apache::lonnet::hreflocation($thisdir,$_);
580: $output=~s/(\"|\'|\=\s*)$_(\"|\'|\s|\>)/$1$newlocation$2/;
581: }
1.30 harris41 582: }
1.24 www 583: # -------------------------------------------------- Deal with Applet codebases
584: $output=~s/(\<applet[^\>]+)(codebase\=[^\S\>]+)*([^\>]*)\>/$1.($2?$2:' codebase="'.$thisdir.'"').$3.'>'/gei;
1.5 www 585: $ssibody{$_}=$output;
1.3 www 586: # ---------------------------------------------------------------- End SSI cell
587: }
1.30 harris41 588: }
1.4 www 589: }
1.2 www 590: }
1.6 www 591: unless ($contents) {
1.53 www 592: &Apache::loncommon::content_type($r,'text/html');
1.3 www 593: $r->send_http_header;
1.74 albertel 594: $r->print(&Apache::loncommon::start_page(undef,undef,
595: {'force_register' => 1,}));
1.59 raeburn 596: $r->print(&mt('This page is either empty or it only contains resources that are currently hidden').'. ');
1.74 albertel 597: $r->print('<br /><br />'.&mt('Please use the LON-CAPA navigation arrows to move to another item in the course').
598: &Apache::loncommon::end_page());
1.3 www 599: } else {
600: # ------------------------------------------------------------------ Build page
1.7 www 601:
602: # ---------------------------------------------------------------- Send headers
1.94 raeburn 603: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.37 sakharuk 604: if ($isxml) {
1.53 www 605: &Apache::loncommon::content_type($r,'text/xml');
1.37 sakharuk 606: } else {
1.53 www 607: &Apache::loncommon::content_type($r,'text/html');
1.37 sakharuk 608: }
1.74 albertel 609: $r->send_http_header;
1.7 www 610: # ------------------------------------------------------------------------ Head
1.37 sakharuk 611: if ($allscript) {
1.85 albertel 612: $allscript =
613: "\n".'<script type="text/javascript">'."\n".
614: $allscript.
615: "\n</script>\n";
1.37 sakharuk 616: }
1.96 raeburn 617: if (($nforms) && ($nuploads)) {
618: $allscript .= &Apache::lonhtmlcommon::file_submissionchk_js(\%turninpaths,\%multiresps);
619: }
1.101 raeburn 620: if (($nforms) && (&Apache::lonhtmlcommon::htmlareabrowser())) {
621: my %textarea_args = (
622: dragmath => 'math',
623: );
624: $allscript .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args);
625: }
1.110 raeburn 626: if ($ntimers) {
627: $allscript .= '<script type="text/javascript">'."\n".
628: '// <![CDATA['."\n".
629: 'function pageTimer(form,prefix) {'."\n".
630: " form.elements[prefix+'markaccess'].value = 'yes';\n".
631: " form.submit();\n".
632: '}'."\n".
633: '// ]]>'.
634: "\n</script>\n";
635: }
1.111 raeburn 636: if (keys(%hastimeleft)) {
637: my (%uniquetimes,%uniquedisplays);
638: foreach my $item (values(%hastimeleft)) {
639: if (exists($uniquetimes{$item})) {
640: $uniquetimes{$item} ++;
641: } else {
642: $uniquetimes{$item} = 1;
643: }
644: }
1.114 raeburn 645: if (scalar(keys(%uniquetimes)) == 1) {
646: my (%uniquedisplays,%uniquedones,$currdisp,$donebuttontime,
647: $donebuttonextras);
1.111 raeburn 648: if (keys(%countdowndisp)) {
649: foreach my $item (values(%countdowndisp)) {
650: if (exists($uniquedisplays{$item})) {
651: $uniquedisplays{$item} ++;
652: } else {
653: $uniquedisplays{$item} = 1;
654: }
655: }
656: my @countdowndisplay = keys(%uniquedisplays);
657: if (scalar(@countdowndisplay) == 1) {
658: $currdisp = $countdowndisplay[0];
659: }
660: }
1.112 raeburn 661: if (keys(%donebutton)) {
662: foreach my $item (values(%donebutton)) {
663: if (exists($uniquedones{$item})) {
664: $uniquedones{$item} ++;
665: } else {
666: $uniquedones{$item} = 1;
667: }
668: }
669: my @donebuttons = sort { $ <=> $b } (keys(%uniquedones));
670: if (scalar(@donebuttons) == 1) {
671: if ($donebuttons[0]) {
672: $donebuttontime = $donebuttons[0];
1.114 raeburn 673: if (ref($buttonbytime{$donebuttontime}) eq 'ARRAY') {
674: $donebuttonextras = $donebtnextra{$buttonbytime{$donebuttontime}->[0]};
675: }
1.112 raeburn 676: }
677: }
678: }
1.114 raeburn 679: &add_countdown_timer($currdisp,$donebuttontime,$donebuttonextras);
1.111 raeburn 680: }
681: }
1.119 ! raeburn 682: my $pagebuttonshide;
! 683: if (keys(%buttonshide)) {
! 684: my %uniquebuttonhide;
! 685: foreach my $item (values(%buttonshide)) {
! 686: if (exists($uniquebuttonhide{$item})) {
! 687: $uniquebuttonhide{$item} ++;
! 688: } else {
! 689: $uniquebuttonhide{$item} = 1;
! 690: }
! 691: }
! 692: if (keys(%uniquebuttonhide) == 1) {
! 693: if (lc((keys(%uniquebuttonhide))[0]) eq 'yes') {
! 694: $pagebuttonshide = 'yes';
! 695: }
! 696: }
! 697: }
1.7 www 698: # ------------------------------------------------------------------ Start body
1.85 albertel 699: $r->print(&Apache::loncommon::start_page(undef,$allscript,
1.74 albertel 700: {'force_register' => 1,
1.119 ! raeburn 701: 'bgcolor' => '#ffffff',
! 702: 'hide_buttons' => $pagebuttonshide}));
1.7 www 703: # ------------------------------------------------------------------ Start form
1.37 sakharuk 704: if ($nforms) {
1.96 raeburn 705: my $fmtag = '<form name="lonhomework" method="post" enctype="multipart/form-data"';
706: if ($nuploads) {
707: my $multi;
708: if ($nuploads > 1) {
709: $multi = 1;
710: }
711: $fmtag .= 'onsubmit="return file_submission_check(this,'."'$turninparent','$multi'".');"';
712: }
713: $fmtag .= ' action="'.
1.61 albertel 714: &Apache::lonenc::check_encrypt($requrl)
1.105 raeburn 715: .'" id="LC_page">';
1.96 raeburn 716: $r->print($fmtag);
1.40 sakharuk 717: }
1.94 raeburn 718: } elsif (($target eq 'tex') || ($target eq 'tex_answer')) {
1.92 foxr 719: # I think this is not needed as the header
720: # will be put in for each of the page parts
721: # by the londefdef.pm now that we are opening up
722: # the parts of a page.
723: #$r->print('\documentclass{article}
724: # \newcommand{\keephidden}[1]{}
725: # \usepackage[dvips]{graphicx}
726: # \usepackage{epsfig}
727: # \usepackage{calc}
728: # \usepackage{longtable}
729: # \begin{document}');
1.40 sakharuk 730: }
1.7 www 731: # ----------------------------------------------------------------- Start table
1.94 raeburn 732: if (($target eq 'tex') || ($target eq 'tex_answer')) {
1.92 foxr 733: # # $r->print('\begin{longtable}INSERTTHEHEADOFLONGTABLE\endfirsthead\endhead ');
1.43 sakharuk 734: if ($number_of_columns le $lcm) {$number_of_columns=$lcm;};
1.40 sakharuk 735: } else {
1.63 albertel 736: $r->print('<table width="100%" cols="'.$lcm.'" border="0">');
1.37 sakharuk 737: }
1.78 www 738: # generate rows
1.5 www 739: for ($i=0;$i<=$#rows;$i++) {
740: if ($rows[$i]) {
1.94 raeburn 741: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.37 sakharuk 742: $r->print("\n<tr>");
743: }
1.4 www 744: my @colcont=split(/\&/,$rows[$i]);
1.6 www 745: my $avespan=$lcm/($#colcont+1);
746: for ($j=0;$j<=$#colcont;$j++) {
747: my $rid=$colcont[$j];
1.119 ! raeburn 748: my $metainfo =&get_buttons(\%hash,$rid,\%buttonshide).'<br />';
1.94 raeburn 749: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.37 sakharuk 750: $r->print('<td colspan="'.$avespan.'"');
751: }
1.99 raeburn 752: if (($cellemb{$rid} eq 'ssi') || ($cellexternal{$rid})) {
1.94 raeburn 753: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.37 sakharuk 754: if ($ssibgcolor{$rid}) {
755: $r->print(' bgcolor="'.
756: $ssibgcolor{$rid}.'"');
757: }
758: $r->print('>'.$metainfo.'<font');
759:
760: if ($ssitext{$rid}) {
761: $r->print(' text="'.$ssitext{$rid}.'"');
762: }
763: if ($ssilink{$rid}) {
764: $r->print(' link="'.$ssilink{$rid}.'"');
765: }
766: if ($ssitext{$rid}) {
767: $r->print(' vlink="'.$ssivlink{$rid}.'"');
768: }
769: if ($ssialink{$rid}) {
770: $r->print(' alink="'.$ssialink{$rid}.'"');
771: }
772: $r->print('>');
773: }
1.99 raeburn 774: unless (($cellexternal{$rid}) &&
775: ($target eq 'tex') && ($target eq 'tex_answer')) {
776: $r->print($ssibody{$rid});
777: }
1.94 raeburn 778: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.37 sakharuk 779: $r->print('</font>');
1.41 www 780: }
1.70 albertel 781: if ($env{'course.'.
782: $env{'request.course.id'}.
1.41 www 783: '.pageseparators'} eq 'yes') {
1.94 raeburn 784: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.41 www 785: $r->print('<hr />');
1.77 albertel 786: }
1.37 sakharuk 787: }
788: } elsif ($cellemb{$rid} eq 'img') {
1.14 www 789: $r->print('>'.$metainfo.'<img src="'.
1.77 albertel 790: $hash{'src_'.$rid}.'" />');
1.13 www 791: } elsif ($cellemb{$rid} eq 'emb') {
1.14 www 792: $r->print('>'.$metainfo.'<embed src="'.
1.13 www 793: $hash{'src_'.$rid}.'"></embed>');
1.60 raeburn 794: } elsif (&Apache::lonnet::declutter($hash{'src_'.$rid}) !~/\.(sequence|page)$/) {
1.104 raeburn 795: $r->print($metainfo.'<b>'.$hash{'title_'.$rid}.'</b><br />');
796: unless ($cellemb{$rid} eq 'wrp') {
797: $r->print(&mt('It is recommended that you use an up-to-date virus scanner before handling this file.'));
798: }
799: $r->print('</p><p><table>'.
800: &Apache::londocs::entryline(0,
801: &mt("Click to download or use your browser's Save Link function"),
802: '/'.&Apache::lonnet::declutter($hash{'src_'.$rid})).
803: '</table></p><br />');
1.13 www 804: }
1.94 raeburn 805: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.37 sakharuk 806: $r->print('</td>');
1.40 sakharuk 807: } else {
1.92 foxr 808: # for (my $incol=1;$incol<=$avespan;$incol++) {
809: # $r->print(' & ');
810: # }
1.37 sakharuk 811: }
1.4 www 812: }
1.94 raeburn 813: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.37 sakharuk 814: $r->print('</tr>');
1.40 sakharuk 815: } else {
1.92 foxr 816: # $r->print('REMOVETHEHEADOFLONGTABLE\\\\');
1.37 sakharuk 817: }
1.5 www 818: }
1.4 www 819: }
1.94 raeburn 820: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.37 sakharuk 821: $r->print("\n</table>");
1.40 sakharuk 822: } else {
1.92 foxr 823: # $r->print('\end{longtable}\strut');
1.37 sakharuk 824: }
1.7 www 825: # ---------------------------------------------------------------- Submit, etc.
826: if ($nforms) {
1.106 raeburn 827: my $class;
828: if ($nforms > 1) {
829: $class = ' class="LC_hwk_submit"';
1.110 raeburn 830: if ($ntimers) {
831: $nforms = 1;
832: $class = '';
833: }
1.106 raeburn 834: }
1.7 www 835: $r->print(
1.103 bisitz 836: '<input name="all_submit" value="'.&mt('Submit All').'" type="'.
1.106 raeburn 837: (($nforms>1)?'submit':'hidden').'"'.$class.' id="all_submit" />'.
838: '<div id="msg_all_submit" style="display:none">'.
839: &mt('Processing your submission ...').'</div></form>');
1.7 www 840: }
1.94 raeburn 841: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.76 albertel 842: $r->print(&Apache::loncommon::end_page({'discussion'
843: => 1,}));
1.40 sakharuk 844: } else {
845: $r->print('\end{document}'.$number_of_columns);
846: }
1.66 albertel 847: &Apache::lonnet::symblist($requrl,%symbhash);
1.69 albertel 848: my ($map,$id,$url)=&Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
849: &Apache::lonnet::symblist($map,'last_known'=>[$url,$id]);
1.3 www 850: # -------------------------------------------------------------------- End page
851: }
1.1 www 852: # ------------------------------------------------------------- End render page
853: } else {
1.67 albertel 854: &Apache::loncommon::content_type($r,'text/html');
1.3 www 855: $r->send_http_header;
1.39 www 856: &Apache::lonsequence::viewmap($r,$requrl);
1.1 www 857: }
858: # ------------------------------------------------------------------ Untie hash
859: unless (untie(%hash)) {
860: &Apache::lonnet::logthis("<font color=blue>WARNING: ".
861: "Could not untie coursemap $fn (browse).</font>");
862: }
863: # -------------------------------------------------------------------- All done
864: return OK;
865: # ----------------------------------------------- Errors, hash could no be tied
866: }
867: }
868: }
1.67 albertel 869: &Apache::loncommon::content_type($r,'text/html');
1.39 www 870: $r->send_http_header;
871: &Apache::lonsequence::viewmap($r,$requrl);
872: return OK;
1.1 www 873: }
874:
1.83 albertel 875: sub get_buttons {
1.119 ! raeburn 876: my ($hash,$rid,$buttonshide) = @_;
1.83 albertel 877:
878: my $metainfo = '';
879: my $esrc=&Apache::lonnet::declutter($hash->{'src_'.$rid});
880: my ($mapid,$resid)=split(/\./,$rid);
881: my $symb=&Apache::lonnet::encode_symb($hash->{'map_id_'.$mapid},
882: $resid,
883: $hash->{'src_'.$rid});
1.109 raeburn 884: unless ($env{'request.role.adv'}) {
1.119 ! raeburn 885: if ($buttonshide->{$symb} eq 'yes') {
1.109 raeburn 886: return;
887: }
888: }
1.83 albertel 889: if ($hash->{'encrypted_'.$rid}) {
890: $symb=&Apache::lonenc::encrypted($symb);
891: $esrc=&Apache::lonenc::encrypted($esrc);
892: }
893: if ($hash->{'src_'.$rid} !~ m-^/uploaded/-
1.99 raeburn 894: && $hash->{'src_'.$rid} !~ m{^https?://}
1.83 albertel 895: && !$env{'request.enc'}
896: && ($env{'request.role.adv'}
897: || !$hash->{'encrypted_'.$rid})) {
898: $metainfo .='<a name="'.&escape($symb).'" />'.
899: '<a href="'.$hash->{'src_'.$rid}.'.meta'.'" target="LONcatInfo">'.
1.100 bisitz 900: '<img src="/res/adm/pages/catalog.png" class="LC_icon"'.
901: ' alt="'.&mt('Show Metadata').'"'.
902: ' title="'.&mt('Show Metadata').'" />'.
1.83 albertel 903: '</a>';
904: }
1.99 raeburn 905: if (($hash->{'src_'.$rid} !~ m{^/uploaded/}) &&
906: ($hash->{'src_'.$rid} !~ m{^https?://})) {
1.98 raeburn 907: $metainfo .= '<a href="/adm/evaluate?postdata='.
908: &escape($esrc).
909: '" target="LONcatInfo">'.
1.100 bisitz 910: '<img src="/res/adm/pages/eval.png" class="LC_icon"'.
911: ' alt="'.&mt('Provide my evaluation of this resource').'"'.
912: ' title="'.&mt('Provide my evaluation of this resource').'" />'.
1.98 raeburn 913: '</a>';
914: }
1.97 www 915: if (($hash->{'src_'.$rid}=~/$LONCAPA::assess_re/) &&
1.83 albertel 916: ($hash->{'src_'.$rid} !~ m-^/uploaded/-)) {
917:
918: if (&Apache::lonnet::allowed('mgr',$env{'request.course.id'})) {
919: $metainfo.=
920: '<a href="/adm/grades?symb='.&escape($symb).
921: # '&command=submission" target="LONcatInfo">'.
922: '&command=submission">'.
1.100 bisitz 923: '<img src="/adm/lonMisc/subm_button.png" class="LC_icon"'.
924: ' alt="'.&mt('View Submissions for a Student or a Group of Students').'"'.
925: ' title="'.&mt('View Submissions for a Student or a Group of Students').'" />'.
1.83 albertel 926: '</a>'.
927: '<a href="/adm/grades?symb='.&escape($symb).
928: # '&command=gradingmenu" target="LONcatInfo">'.
929: '&command=gradingmenu">'.
1.100 bisitz 930: '<img src="/res/adm/pages/pgrd.png" class="LC_icon"'.
931: ' alt="'.&mt('Content Grades').'"'.
932: ' title="'.&mt('Content Grades').'" />'.
1.83 albertel 933: '</a>';
934: }
935: if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {
936: $metainfo.=
937: '<a href="/adm/parmset?symb='.&escape($symb).
938: # '" target="LONcatInfo">'.
939: '" >'.
1.100 bisitz 940: '<img src="/adm/lonMisc/pprm_button.png" class="LC_icon"'.
941: ' alt="'.&mt('Content Settings').'"'.
942: ' title="'.&mt('Content Settings').'" />'.
1.83 albertel 943: '</a>';
944: }
945: }
1.102 raeburn 946: if (($env{'request.course.id'}) && (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) {
947: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
948: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
949: my $file=&Apache::lonnet::declutter($hash->{'src_'.$rid});
950: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
951: &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,$hash->{'src_'.$rid},$symb);
952: if ($cfile ne '') {
953: my $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
954: $forceedit,1,$symb,undef,
955: &escape($env{'form.title'}));
956: if ($jscall) {
957: my $icon = 'pcstr.png';
958: my $label = &mt('Edit');
959: my $title = &mt('Edit this resource');
960: my $pic = '<img src="'.&Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$icon).'"'.
961: ' class="LC_icon" alt="'.$label.'" title="'.$title.'" />';
962: $metainfo .= ' <a href="javascript:'.$jscall.';">'.$pic.'</a>';
963: }
964: }
965: }
1.83 albertel 966: return $metainfo;
967: }
968:
1.111 raeburn 969: sub add_countdown_timer {
1.114 raeburn 970: my ($currdisp,$donebuttontime,$donebuttonextras) = @_;
1.112 raeburn 971: my ($collapse,$expand,$alttxt,$title,$donebutton);
1.111 raeburn 972: if ($currdisp eq 'inline') {
973: $collapse = '► ';
974: } else {
975: $expand = '◄ ';
976: }
1.112 raeburn 977: if ($donebuttontime) {
1.114 raeburn 978: my ($type,$proctor,$donebuttontext);
979: if (ref($donebuttonextras) eq 'HASH') {
980: $proctor = $donebuttonextras->{'proctor'};
981: $donebuttontext = $donebuttonextras->{'text'};
982: $type = $donebuttonextras->{'type'};
983: } else {
984: $donebuttontext = &mt('Done');
1.116 raeburn 985: $type = 'map';
1.114 raeburn 986: }
987: $donebutton =
988: &Apache::lonmenu::done_button_js($type,'','',$proctor,$donebuttontext);
1.112 raeburn 989: }
1.111 raeburn 990: unless ($env{'environment.icons'} eq 'iconsonly') {
991: $alttxt = &mt('Timer');
992: $title = $alttxt.' ';
993: }
994: my $desc = &mt('Countdown to due date/time');
995: my $output = <<END;
1.112 raeburn 996: $donebutton
1.111 raeburn 997: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
998: <span id="ddcountcollapse" class="LC_menubuttons_inline_text">
999: $collapse
1000: </span></a>
1001: <span id="duedatecountdown" class="LC_menubuttons_inline_text" style="display: $currdisp;"></span>
1002: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
1003: <span id="ddcountexpand" class="LC_menubuttons_inline_text" >$expand</span>
1004: <img src="/res/adm/pages/timer.png" title="$desc" class="LC_icon" alt="$alttxt" /><span class="LC_menubuttons_inline_text">$title</span></a>
1005: END
1006: &Apache::lonhtmlcommon::clear_breadcrumb_tools();
1007: &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$output);
1008: return;
1009: }
1010:
1011:
1.1 www 1012: 1;
1013: __END__
1014:
1015:
1.89 jms 1016: =head1 NAME
1017:
1018: Apache::lonpage - Page Handler
1019:
1020: =head1 SYNOPSIS
1021:
1022: Invoked by /etc/httpd/conf/srm.conf:
1023:
1024: <LocationMatch "^/res/.*\.page$>
1025: SetHandler perl-script
1026: PerlHandler Apache::lonpage
1027: </LocationMatch>
1028:
1029: =head1 INTRODUCTION
1030:
1031: This module renders a .page resource.
1032:
1033: This is part of the LearningOnline Network with CAPA project
1034: described at http://www.lon-capa.org.
1035:
1036: =head1 HANDLER SUBROUTINE
1037:
1038: This routine is called by Apache and mod_perl.
1039:
1040: =over 4
1041:
1042: =item *
1043:
1044: set document type for header only
1045:
1046: =item *
1047:
1048: tie db file
1049:
1050: =item *
1051:
1052: render page
1053:
1054: =item *
1055:
1056: add to symb list
1057:
1058: =item *
1059:
1060: page parms
1061:
1062: =item *
1063:
1064: Get SSI output, post parameters
1.1 www 1065:
1.89 jms 1066: =item *
1067:
1068: SSI cell rendering
1069:
1070: =item *
1071:
1072: Deal with Applet codebases
1073:
1074: =item *
1075:
1076: Build page
1077:
1078: =item *
1079:
1080: send headers
1081:
1082: =item *
1083:
1084: start body
1085:
1086: =item *
1087:
1088: start form
1089:
1090: =item *
1091:
1092: start table
1093:
1094: =item *
1095:
1096: submit element, etc, render page, untie hash
1097:
1098: =back
1099:
1100: =head1 OTHER SUBROUTINES
1101:
1102: =over 4
1103:
1104: =item *
1105:
1106: euclid() : Euclid's method for determining the greatest common denominator.
1107:
1108: =item *
1109:
1110: tracetable() : Build page table.
1111:
1112: =back
1113:
1114: =cut
1.1 www 1115:
1116:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>