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