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