Annotation of rat/lonpage.pm, revision 1.111.2.9

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.