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