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