Annotation of rat/lonpage.pm, revision 1.95
1.1 www 1: # The LearningOnline Network with CAPA
2: # Page Handler
3: #
1.95 ! raeburn 4: # $Id: lonpage.pm,v 1.94 2010/07/13 00:16:23 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.21 www 39: use Apache::lonxml();
1.57 raeburn 40: use Apache::lonlocal;
1.49 www 41: use Apache::lonmenu;
1.6 www 42: use HTML::TokeParser;
1.1 www 43: use GDBM_File;
1.39 www 44: use Apache::lonsequence;
1.75 www 45: use lib '/home/httpd/lib/perl/';
46: use LONCAPA;
47:
1.1 www 48:
1.2 www 49: # -------------------------------------------------------------- Module Globals
50: my %hash;
51: my @rows;
1.6 www 52:
53: # ------------------------------------------------------------------ Euclid gcd
54:
55: sub euclid {
56: my ($e,$f)=@_;
57: my $a; my $b; my $r;
58: if ($e>$f) { $b=$e; $r=$f; } else { $r=$e; $b=$f; }
59: while ($r!=0) {
60: $a=$b; $b=$r;
61: $r=$a%$b;
62: }
63: return $b;
64: }
1.2 www 65:
66: # ------------------------------------------------------------ Build page table
67:
68: sub tracetable {
69: my ($sofar,$rid,$beenhere)=@_;
70: my $further=$sofar;
1.57 raeburn 71: my $randomout=0;
1.70 albertel 72: unless ($env{'request.role.adv'}) {
1.57 raeburn 73: $randomout = $hash{'randomout_'.$rid};
74: }
1.2 www 75: unless ($beenhere=~/\&$rid\&/) {
1.57 raeburn 76: $beenhere.=$rid.'&';
77: unless ($randomout) {
78: if (defined($hash{'is_map_'.$rid})) {
79: if ((defined($hash{'map_start_'.$hash{'src_'.$rid}})) &&
80: (defined($hash{'map_finish_'.$hash{'src_'.$rid}}))) {
81: my $frid=$hash{'map_finish_'.$hash{'src_'.$rid}};
82: $sofar=
83: &tracetable($sofar,$hash{'map_start_'.$hash{'src_'.$rid}},
1.87 albertel 84: '&'.$frid.$beenhere);
1.57 raeburn 85: $sofar++;
86: if ($hash{'src_'.$frid}) {
87: my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$frid});
88: if (($brepriv eq '2') || ($brepriv eq 'F')) {
89: if (defined($rows[$sofar])) {
90: $rows[$sofar].='&'.$frid;
91: } else {
92: $rows[$sofar]=$frid;
93: }
94: }
95: }
96: }
97: } else {
98: $sofar++;
99: if ($hash{'src_'.$rid}) {
100: my $brepriv=&Apache::lonnet::allowed('bre',$hash{'src_'.$rid});
101: if (($brepriv eq '2') || ($brepriv eq 'F')) {
102: if (defined($rows[$sofar])) {
103: $rows[$sofar].='&'.$rid;
104: } else {
105: $rows[$sofar]=$rid;
106: }
107: }
108: }
109: }
110: }
111:
112: if (defined($hash{'to_'.$rid})) {
113: my $mincond=1;
114: my $next='';
115: foreach (split(/\,/,$hash{'to_'.$rid})) {
116: my $thiscond=
1.11 www 117: &Apache::lonnet::directcondval($hash{'condid_'.$hash{'undercond_'.$_}});
1.57 raeburn 118: if ($thiscond>=$mincond) {
119: if ($next) {
120: $next.=','.$_.':'.$thiscond;
121: } else {
122: $next=$_.':'.$thiscond;
123: }
124: if ($thiscond>$mincond) { $mincond=$thiscond; }
125: }
126: }
127: foreach (split(/\,/,$next)) {
128: my ($linkid,$condval)=split(/\:/,$_);
129: if ($condval>=$mincond) {
130: my $now=&tracetable($sofar,$hash{'goesto_'.$linkid},$beenhere);
131: if ($now>$further) { $further=$now; }
132: }
133: }
134: }
1.2 www 135: }
136: return $further;
137: }
138:
1.1 www 139: # ================================================================ Main Handler
140:
141: sub handler {
142: my $r=shift;
143:
1.3 www 144: # ------------------------------------------- Set document type for header only
1.1 www 145:
1.3 www 146: if ($r->header_only) {
1.70 albertel 147: if ($env{'browser.mathml'}) {
1.53 www 148: &Apache::loncommon::content_type($r,'text/xml');
1.3 www 149: } else {
1.53 www 150: &Apache::loncommon::content_type($r,'text/html');
1.3 www 151: }
152: $r->send_http_header;
153: return OK;
154: }
1.43 sakharuk 155:
1.39 www 156: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
157: ['forceselect','launch']);
1.43 sakharuk 158: my $number_of_columns = 1;
1.37 sakharuk 159: my $requrl=$r->uri;
1.70 albertel 160: my $target = $env{'form.grade_target'};
1.94 raeburn 161:
162: # Short term solution: define target as 'tex_answer' when retrieving answers
163: # for resources in a .page when generating printouts.
164: # A better long-term fix would be to modify the way problem rendering, and
165: # answer rendering are retrieved for individual resources when printing a .page,
166: # so rendered problem and answer are sequential for individual resources in
167: # the .page
168: #
169: if ($target eq 'answer') {
170: if ($env{'form.answer_output_mode'} eq 'tex') {
171: $target = 'tex_answer';
172: }
173: }
1.55 www 174: # &Apache::lonnet::logthis("Got a target of $target");
1.54 albertel 175: if ($target eq 'meta') {
176: &Apache::loncommon::content_type($r,'text/html');
177: $r->send_http_header;
178: return OK;
179: }
1.1 www 180: # ----------------------------------------------------------------- Tie db file
1.70 albertel 181: if (($env{'request.course.fn'}) && (!$env{'form.forceselect'})) {
182: my $fn=$env{'request.course.fn'};
1.1 www 183: if (-e "$fn.db") {
1.44 albertel 184: if (tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER(),0640)) {
1.1 www 185: # ------------------------------------------------------------------- Hash tied
186: my $firstres=$hash{'map_start_'.$requrl};
187: my $lastres=$hash{'map_finish_'.$requrl};
188: if (($firstres) && ($lastres)) {
189: # ----------------------------------------------------------------- Render page
190:
1.3 www 191: @rows=();
1.2 www 192:
1.45 www 193: &tracetable(0,$firstres,'&');
1.2 www 194:
1.9 www 195: # ------------------------------------------------------------ Add to symb list
196:
1.2 www 197: my $i;
1.9 www 198: my %symbhash=();
199: for ($i=0;$i<=$#rows;$i++) {
200: if ($rows[$i]) {
201: my @colcont=split(/\&/,$rows[$i]);
1.73 albertel 202: foreach my $rid (@colcont) {
203: my ($mapid,$resid)=split(/\./,$rid);
204: $symbhash{$hash{'src_'.$rid}}=
205: [$hash{'src_'.$rid},$resid];
1.30 harris41 206: }
1.9 www 207: }
208: }
209: &Apache::lonnet::symblist($requrl,%symbhash);
210:
211: # ------------------------------------------------------------------ Page parms
212:
1.4 www 213: my $j;
1.6 www 214: my $lcm=1;
215: my $contents=0;
1.7 www 216: my $nforms=0;
1.6 www 217:
218: my %ssibody=();
219: my %ssibgcolor=();
220: my %ssitext=();
221: my %ssilink=();
222: my %ssivlink=();
223: my %ssialink=();
1.14 www 224:
1.6 www 225: my %cellemb=();
1.3 www 226:
1.7 www 227: my $allscript='';
228: my $allmeta='';
229:
230: my $isxml=0;
231: my $xmlheader='';
232: my $xmlbody='';
233:
1.3 www 234: # --------------------------------------------- Get SSI output, post parameters
235:
1.2 www 236: for ($i=0;$i<=$#rows;$i++) {
1.4 www 237: if ($rows[$i]) {
1.6 www 238: $contents++;
1.3 www 239: my @colcont=split(/\&/,$rows[$i]);
1.6 www 240: $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1));
1.30 harris41 241: foreach (@colcont) {
1.3 www 242: my $src=$hash{'src_'.$_};
1.61 albertel 243: my ($extension)=($src=~/\.(\w+)$/);
244: if ($hash{'encrypted_'.$_}) {
245: $src=&Apache::lonenc::encrypted($src);
246: }
247: $cellemb{$_}=
248: &Apache::loncommon::fileembstyle($extension);
1.3 www 249: if ($cellemb{$_} eq 'ssi') {
250: # --------------------------------------------------------- This is an SSI cell
1.64 albertel 251: my ($mapid,$resid)=split(/\./,$_);
252: my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$src);
253:
1.5 www 254: my $prefix=$_.'_';
1.64 albertel 255: my %posthash=('request.prefix' => $prefix,
1.71 albertel 256: 'LONCAPA_INTERNAL_no_discussion' => 'true',
1.64 albertel 257: 'symb' => $symb);
1.94 raeburn 258: if (($env{'form.grade_target'} eq 'tex') ||
259: ($env{'form.answer_output_mode'} eq 'tex')) {
1.70 albertel 260: $posthash{'grade_target'}=$env{'form.grade_target'};
261: $posthash{'textwidth'}=$env{'form.textwidth'};
262: $posthash{'problem_split'}=$env{'form.problem_split'};
263: $posthash{'latex_type'}=$env{'form.latex_type'};
264: $posthash{'rndseed'}=$env{'form.rndseed'};
1.94 raeburn 265: $posthash{'answer_output_mode'} = $env{'form.answer_output_mode'};
1.56 sakharuk 266: }
1.72 albertel 267: my $submitted=exists($env{'form.all_submit'});
268: if (!$submitted) {
269: foreach my $key (keys(%env)) {
270: if ($key=~/^form.\Q$prefix\Esubmit_/) {
271: $submitted=1;last;
272: }
273: }
274: }
275: if ($submitted) {
276: foreach my $key (keys(%env)) {
277: if ($key=~/^form.\Q$prefix\E/) {
278: my $name=$key;
279: $name=~s/^form.\Q$prefix\E//;
280: $posthash{$name}=$env{$key};
281: }
282: }
283: if (exists($env{'form.all_submit'})) {
284: $posthash{'all_submit'}='yes';
285: }
1.7 www 286: }
1.5 www 287: my $output=Apache::lonnet::ssi($src,%posthash);
1.77 albertel 288: $output=~s|//(\s*<!--)? BEGIN LON-CAPA Internal.+?// END LON-CAPA Internal\s*(-->)?\s||gs;
1.94 raeburn 289: if (($target eq 'tex') || ($target eq 'tex_answer')) {
1.46 sakharuk 290: $output =~ s/^([^&]+)\\begin{document}//;
291: $output =~ s/\\end{document}//;
1.92 foxr 292: # $output = '\parbox{\minipagewidth}{ '.$output.' }';
1.46 sakharuk 293: #some additional cleanup necessary for LateX (due to limitations of table environment
294: $output =~ s/(\\vskip\s*\d+mm)\s*(\\\\)+/$1/g;
295: }
1.6 www 296: my $parser=HTML::TokeParser->new(\$output);
297: my $token;
1.12 www 298: my $thisdir=$src;
1.6 www 299: my $bodydef=0;
1.7 www 300: my $thisxml=0;
1.12 www 301: my @rlinks=();
1.7 www 302: if ($output=~/\?xml/) {
303: $isxml=1;
304: $thisxml=1;
305: $output=~
306: /((?:\<(?:\?xml|\!DOC|html)[^\>]*(?:\>|\>\]\>)\s*)+)\<body[^\>]*\>/si;
307: $xmlheader=$1;
308: }
1.12 www 309: while ($token=$parser->get_token) {
310: if ($token->[0] eq 'S') {
311: if ($token->[1] eq 'a') {
312: if ($token->[2]->{'href'}) {
313: $rlinks[$#rlinks+1]=
314: $token->[2]->{'href'};
315: }
316: } elsif ($token->[1] eq 'img') {
317: $rlinks[$#rlinks+1]=
318: $token->[2]->{'src'};
319: } elsif ($token->[1] eq 'embed') {
320: $rlinks[$#rlinks+1]=
321: $token->[2]->{'src'};
322: } elsif ($token->[1] eq 'base') {
323: $thisdir=$token->[2]->{'href'};
324: } elsif ($token->[1] eq 'body') {
1.7 www 325: $bodydef=1;
326: $ssibgcolor{$_}=$token->[2]->{'bgcolor'};
327: $ssitext{$_}=$token->[2]->{'text'};
328: $ssilink{$_}=$token->[2]->{'link'};
329: $ssivlink{$_}=$token->[2]->{'vlink'};
330: $ssialink{$_}=$token->[2]->{'alink'};
331: if ($thisxml) {
332: $xmlbody=$token->[4];
333: }
1.12 www 334: } elsif ($token->[1] eq 'meta') {
1.28 albertel 335: if ($token->[4] !~ m:/>$:) {
1.7 www 336: $allmeta.="\n".$token->[4].'</meta>';
1.28 albertel 337: } else {
338: $allmeta.="\n".$token->[4];
339: }
1.12 www 340: } elsif (($token->[1] eq 'script') &&
341: ($bodydef==0)) {
1.7 www 342: $allscript.="\n\n"
343: .$parser->get_text('/script');
1.6 www 344: }
1.12 www 345: }
346: }
1.6 www 347: if ($output=~/\<body[^\>]*\>(.*)/si) {
348: $output=$1;
349: }
350: $output=~s/\<\/body\>.*//si;
1.7 www 351: if ($output=~/\<form/si) {
352: $nforms++;
353: $output=~s/\<form[^\>]*\>//gsi;
354: $output=~s/\<\/form[^\>]*\>//gsi;
1.17 www 355: $output=~
1.80 albertel 356: s/\<((?:input|select|button|textarea)[^\>]+)name\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\>]*)\>/\<$1 name="$prefix$2" $3\>/gsi;
1.95 ! raeburn 357: $output=~
! 358: s/\<((?:input|select)[^\>]+\Qjavascript:setSubmittedPart\E)\(\s*[\'\"]([^\'\"]+)[\'\"]*\s*\)/\<$1('$2','$prefix')/gsi;
1.7 www 359: }
1.12 www 360: $thisdir=~s/\/[^\/]*$//;
1.30 harris41 361: foreach (@rlinks) {
1.91 raeburn 362: unless (($_=~/^https?\:\/\//i) ||
1.31 albertel 363: ($_=~/^\//) ||
364: ($_=~/^javascript:/i) ||
365: ($_=~/^mailto:/i) ||
366: ($_=~/^\#/)) {
1.12 www 367: my $newlocation=
368: &Apache::lonnet::hreflocation($thisdir,$_);
369: $output=~s/(\"|\'|\=\s*)$_(\"|\'|\s|\>)/$1$newlocation$2/;
370: }
1.30 harris41 371: }
1.24 www 372: # -------------------------------------------------- Deal with Applet codebases
373: $output=~s/(\<applet[^\>]+)(codebase\=[^\S\>]+)*([^\>]*)\>/$1.($2?$2:' codebase="'.$thisdir.'"').$3.'>'/gei;
1.5 www 374: $ssibody{$_}=$output;
1.3 www 375: # ---------------------------------------------------------------- End SSI cell
376: }
1.30 harris41 377: }
1.4 www 378: }
1.2 www 379: }
1.6 www 380: unless ($contents) {
1.53 www 381: &Apache::loncommon::content_type($r,'text/html');
1.3 www 382: $r->send_http_header;
1.74 albertel 383: $r->print(&Apache::loncommon::start_page(undef,undef,
384: {'force_register' => 1,}));
1.59 raeburn 385: $r->print(&mt('This page is either empty or it only contains resources that are currently hidden').'. ');
1.74 albertel 386: $r->print('<br /><br />'.&mt('Please use the LON-CAPA navigation arrows to move to another item in the course').
387: &Apache::loncommon::end_page());
1.3 www 388: } else {
389: # ------------------------------------------------------------------ Build page
1.7 www 390:
391: # ---------------------------------------------------------------- Send headers
1.94 raeburn 392: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.37 sakharuk 393: if ($isxml) {
1.53 www 394: &Apache::loncommon::content_type($r,'text/xml');
1.37 sakharuk 395: } else {
1.53 www 396: &Apache::loncommon::content_type($r,'text/html');
1.37 sakharuk 397: }
1.74 albertel 398: $r->send_http_header;
1.7 www 399: # ------------------------------------------------------------------------ Head
1.37 sakharuk 400: if ($allscript) {
1.85 albertel 401: $allscript =
402: "\n".'<script type="text/javascript">'."\n".
403: $allscript.
404: "\n</script>\n";
1.37 sakharuk 405: }
1.7 www 406: # ------------------------------------------------------------------ Start body
1.85 albertel 407: $r->print(&Apache::loncommon::start_page(undef,$allscript,
1.74 albertel 408: {'force_register' => 1,
409: 'bgcolor' => '#ffffff',}));
1.7 www 410: # ------------------------------------------------------------------ Start form
1.37 sakharuk 411: if ($nforms) {
1.86 albertel 412: $r->print('<form name="lonhomework" method="post" enctype="multipart/form-data" action="'.
1.61 albertel 413: &Apache::lonenc::check_encrypt($requrl)
414: .'">');
1.40 sakharuk 415: }
1.94 raeburn 416: } elsif (($target eq 'tex') || ($target eq 'tex_answer')) {
1.92 foxr 417: # I think this is not needed as the header
418: # will be put in for each of the page parts
419: # by the londefdef.pm now that we are opening up
420: # the parts of a page.
421: #$r->print('\documentclass{article}
422: # \newcommand{\keephidden}[1]{}
423: # \usepackage[dvips]{graphicx}
424: # \usepackage{epsfig}
425: # \usepackage{calc}
426: # \usepackage{longtable}
427: # \begin{document}');
1.40 sakharuk 428: }
1.7 www 429: # ----------------------------------------------------------------- Start table
1.94 raeburn 430: if (($target eq 'tex') || ($target eq 'tex_answer')) {
1.92 foxr 431: # # $r->print('\begin{longtable}INSERTTHEHEADOFLONGTABLE\endfirsthead\endhead ');
1.43 sakharuk 432: if ($number_of_columns le $lcm) {$number_of_columns=$lcm;};
1.40 sakharuk 433: } else {
1.63 albertel 434: $r->print('<table width="100%" cols="'.$lcm.'" border="0">');
1.37 sakharuk 435: }
1.78 www 436: # generate rows
1.5 www 437: for ($i=0;$i<=$#rows;$i++) {
438: if ($rows[$i]) {
1.94 raeburn 439: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.37 sakharuk 440: $r->print("\n<tr>");
441: }
1.4 www 442: my @colcont=split(/\&/,$rows[$i]);
1.6 www 443: my $avespan=$lcm/($#colcont+1);
444: for ($j=0;$j<=$#colcont;$j++) {
445: my $rid=$colcont[$j];
1.83 albertel 446:
447: my $metainfo =&get_buttons(\%hash,$rid).'<br />';
1.94 raeburn 448: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.37 sakharuk 449: $r->print('<td colspan="'.$avespan.'"');
450: }
1.6 www 451: if ($cellemb{$rid} eq 'ssi') {
1.94 raeburn 452: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.37 sakharuk 453: if ($ssibgcolor{$rid}) {
454: $r->print(' bgcolor="'.
455: $ssibgcolor{$rid}.'"');
456: }
457: $r->print('>'.$metainfo.'<font');
458:
459: if ($ssitext{$rid}) {
460: $r->print(' text="'.$ssitext{$rid}.'"');
461: }
462: if ($ssilink{$rid}) {
463: $r->print(' link="'.$ssilink{$rid}.'"');
464: }
465: if ($ssitext{$rid}) {
466: $r->print(' vlink="'.$ssivlink{$rid}.'"');
467: }
468: if ($ssialink{$rid}) {
469: $r->print(' alink="'.$ssialink{$rid}.'"');
470: }
471: $r->print('>');
472: }
473: $r->print($ssibody{$rid});
1.94 raeburn 474: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.37 sakharuk 475: $r->print('</font>');
1.41 www 476: }
1.70 albertel 477: if ($env{'course.'.
478: $env{'request.course.id'}.
1.41 www 479: '.pageseparators'} eq 'yes') {
1.94 raeburn 480: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.41 www 481: $r->print('<hr />');
1.77 albertel 482: }
1.37 sakharuk 483: }
484: } elsif ($cellemb{$rid} eq 'img') {
1.14 www 485: $r->print('>'.$metainfo.'<img src="'.
1.77 albertel 486: $hash{'src_'.$rid}.'" />');
1.13 www 487: } elsif ($cellemb{$rid} eq 'emb') {
1.14 www 488: $r->print('>'.$metainfo.'<embed src="'.
1.13 www 489: $hash{'src_'.$rid}.'"></embed>');
1.60 raeburn 490: } elsif (&Apache::lonnet::declutter($hash{'src_'.$rid}) !~/\.(sequence|page)$/) {
491: $r->print($metainfo.'<b>'.$hash{'title_'.$rid}.'</b><br />'.
492: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.').'</p><p><table>'.
493: &Apache::londocs::entryline(0,&mt("Click to download or use your browser's Save Link function"),'/'.&Apache::lonnet::declutter($hash{'src_'.$rid})).'</table></p><br />');
1.13 www 494: }
1.94 raeburn 495: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.37 sakharuk 496: $r->print('</td>');
1.40 sakharuk 497: } else {
1.92 foxr 498: # for (my $incol=1;$incol<=$avespan;$incol++) {
499: # $r->print(' & ');
500: # }
1.37 sakharuk 501: }
1.4 www 502: }
1.94 raeburn 503: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.37 sakharuk 504: $r->print('</tr>');
1.40 sakharuk 505: } else {
1.92 foxr 506: # $r->print('REMOVETHEHEADOFLONGTABLE\\\\');
1.37 sakharuk 507: }
1.5 www 508: }
1.4 www 509: }
1.94 raeburn 510: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.37 sakharuk 511: $r->print("\n</table>");
1.40 sakharuk 512: } else {
1.92 foxr 513: # $r->print('\end{longtable}\strut');
1.37 sakharuk 514: }
1.7 www 515: # ---------------------------------------------------------------- Submit, etc.
516: if ($nforms) {
517: $r->print(
518: '<input name="all_submit" value="Submit All" type="'.
519: (($nforms>1)?'submit':'hidden').'"></input></form>');
520: }
1.94 raeburn 521: unless (($target eq 'tex') || ($target eq 'tex_answer')) {
1.76 albertel 522: $r->print(&Apache::loncommon::end_page({'discussion'
523: => 1,}));
1.40 sakharuk 524: } else {
525: $r->print('\end{document}'.$number_of_columns);
526: }
1.66 albertel 527: &Apache::lonnet::symblist($requrl,%symbhash);
1.69 albertel 528: my ($map,$id,$url)=&Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
529: &Apache::lonnet::symblist($map,'last_known'=>[$url,$id]);
1.3 www 530: # -------------------------------------------------------------------- End page
531: }
1.1 www 532: # ------------------------------------------------------------- End render page
533: } else {
1.67 albertel 534: &Apache::loncommon::content_type($r,'text/html');
1.3 www 535: $r->send_http_header;
1.39 www 536: &Apache::lonsequence::viewmap($r,$requrl);
1.1 www 537: }
538: # ------------------------------------------------------------------ Untie hash
539: unless (untie(%hash)) {
540: &Apache::lonnet::logthis("<font color=blue>WARNING: ".
541: "Could not untie coursemap $fn (browse).</font>");
542: }
543: # -------------------------------------------------------------------- All done
544: return OK;
545: # ----------------------------------------------- Errors, hash could no be tied
546: }
547: }
548: }
1.67 albertel 549: &Apache::loncommon::content_type($r,'text/html');
1.39 www 550: $r->send_http_header;
551: &Apache::lonsequence::viewmap($r,$requrl);
552: return OK;
1.1 www 553: }
554:
1.83 albertel 555: sub get_buttons {
556: my ($hash,$rid) = @_;
557:
558: my $metainfo = '';
559: my $esrc=&Apache::lonnet::declutter($hash->{'src_'.$rid});
560: my ($mapid,$resid)=split(/\./,$rid);
561: my $symb=&Apache::lonnet::encode_symb($hash->{'map_id_'.$mapid},
562: $resid,
563: $hash->{'src_'.$rid});
564: if ($hash->{'encrypted_'.$rid}) {
565: $symb=&Apache::lonenc::encrypted($symb);
566: $esrc=&Apache::lonenc::encrypted($esrc);
567: }
568: if ($hash->{'src_'.$rid} !~ m-^/uploaded/-
569: && !$env{'request.enc'}
570: && ($env{'request.role.adv'}
571: || !$hash->{'encrypted_'.$rid})) {
572: $metainfo .='<a name="'.&escape($symb).'" />'.
573: '<a href="'.$hash->{'src_'.$rid}.'.meta'.'" target="LONcatInfo">'.
1.93 droeschl 574: '<img src="/adm/lonMisc/cat_button.png" class="LC_icon" />'.
1.83 albertel 575: '</a>';
576: }
577: $metainfo .= '<a href="/adm/evaluate?postdata='.
578: &escape($esrc).
579: '" target="LONcatInfo">'.
1.93 droeschl 580: '<img src="/adm/lonMisc/eval_button.png" class="LC_icon" />'.
1.83 albertel 581: '</a>';
582: if (($hash->{'src_'.$rid}=~/\.(problem|exam|quiz|assess|survey|form)$/) &&
583: ($hash->{'src_'.$rid} !~ m-^/uploaded/-)) {
584:
585: if (&Apache::lonnet::allowed('mgr',$env{'request.course.id'})) {
586: $metainfo.=
587: '<a href="/adm/grades?symb='.&escape($symb).
588: # '&command=submission" target="LONcatInfo">'.
589: '&command=submission">'.
1.93 droeschl 590: '<img src="/adm/lonMisc/subm_button.png" class="LC_icon" />'.
1.83 albertel 591: '</a>'.
592: '<a href="/adm/grades?symb='.&escape($symb).
593: # '&command=gradingmenu" target="LONcatInfo">'.
594: '&command=gradingmenu">'.
1.93 droeschl 595: '<img src="/adm/lonMisc/pgrd_button.png" class="LC_icon" />'.
1.83 albertel 596: '</a>';
597: }
598: if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {
599: $metainfo.=
600: '<a href="/adm/parmset?symb='.&escape($symb).
601: # '" target="LONcatInfo">'.
602: '" >'.
1.93 droeschl 603: '<img src="/adm/lonMisc/pprm_button.png" class="LC_icon" />'.
1.83 albertel 604: '</a>';
605: }
606: }
607: return $metainfo;
608: }
609:
1.1 www 610: 1;
611: __END__
612:
613:
1.89 jms 614: =head1 NAME
615:
616: Apache::lonpage - Page Handler
617:
618: =head1 SYNOPSIS
619:
620: Invoked by /etc/httpd/conf/srm.conf:
621:
622: <LocationMatch "^/res/.*\.page$>
623: SetHandler perl-script
624: PerlHandler Apache::lonpage
625: </LocationMatch>
626:
627: =head1 INTRODUCTION
628:
629: This module renders a .page resource.
630:
631: This is part of the LearningOnline Network with CAPA project
632: described at http://www.lon-capa.org.
633:
634: =head1 HANDLER SUBROUTINE
635:
636: This routine is called by Apache and mod_perl.
637:
638: =over 4
639:
640: =item *
641:
642: set document type for header only
643:
644: =item *
645:
646: tie db file
647:
648: =item *
649:
650: render page
651:
652: =item *
653:
654: add to symb list
655:
656: =item *
657:
658: page parms
659:
660: =item *
661:
662: Get SSI output, post parameters
1.1 www 663:
1.89 jms 664: =item *
665:
666: SSI cell rendering
667:
668: =item *
669:
670: Deal with Applet codebases
671:
672: =item *
673:
674: Build page
675:
676: =item *
677:
678: send headers
679:
680: =item *
681:
682: start body
683:
684: =item *
685:
686: start form
687:
688: =item *
689:
690: start table
691:
692: =item *
693:
694: submit element, etc, render page, untie hash
695:
696: =back
697:
698: =head1 OTHER SUBROUTINES
699:
700: =over 4
701:
702: =item *
703:
704: euclid() : Euclid's method for determining the greatest common denominator.
705:
706: =item *
707:
708: tracetable() : Build page table.
709:
710: =back
711:
712: =cut
1.1 www 713:
714:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>