--- rat/lonpage.pm 2010/07/30 22:40:53 1.94.2.1 +++ rat/lonpage.pm 2013/01/15 14:14:31 1.100 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Page Handler # -# $Id: lonpage.pm,v 1.94.2.1 2010/07/30 22:40:53 raeburn Exp $ +# $Id: lonpage.pm,v 1.100 2013/01/15 14:14:31 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -214,6 +214,10 @@ sub handler { my $lcm=1; my $contents=0; my $nforms=0; + my $nuploads=0; + my %turninpaths; + my %multiresps; + my $turninparent; my %ssibody=(); my %ssibgcolor=(); @@ -223,6 +227,7 @@ sub handler { my %ssialink=(); my %cellemb=(); + my %cellexternal=(); my $allscript=''; my $allmeta=''; @@ -240,13 +245,20 @@ sub handler { $lcm*=($#colcont+1)/euclid($lcm,($#colcont+1)); foreach (@colcont) { my $src=$hash{'src_'.$_}; - my ($extension)=($src=~/\.(\w+)$/); + my ($extension)=($src=~/\.(\w+)$/); + $cellexternal{$_}=($hash{'ext_'.$_} eq 'true:'); if ($hash{'encrypted_'.$_}) { $src=&Apache::lonenc::encrypted($src); } $cellemb{$_}= &Apache::loncommon::fileembstyle($extension); - if ($cellemb{$_} eq 'ssi') { + if ($cellexternal{$_}) { + unless (($target eq 'tex') || ($target eq 'tex_answer')) { + $ssibody{$_} = <No iframe support! +ENDEXT + } + } elsif ($cellemb{$_} eq 'ssi') { # --------------------------------------------------------- This is an SSI cell my ($mapid,$resid)=split(/\./,$_); my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$src); @@ -352,8 +364,23 @@ sub handler { $nforms++; $output=~s/\]*\>//gsi; $output=~s/\<\/form[^\>]*\>//gsi; + if ($output=~/\]+name\s*=\s*[\'\"]*HWFILE/) { + $nuploads++; + } $output=~ s/\<((?:input|select|button|textarea)[^\>]+)name\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\>]*)\>/\<$1 name="$prefix$2" $3\>/gsi; + if ($nuploads) { + $output=~ + s/\<(input[^\>]+name=\"\Q$prefix\EHWFILE[^\>]+)\s*id\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\)]*)\>/\<$1 id="$prefix$2" $3\>/gsi; + ($turninpaths{$prefix},$multiresps{$prefix}) = + &Apache::loncommon::get_turnedin_filepath($symb,$env{'user.name'},$env{'user.domain'}); + if ($turninparent eq '') { + $turninparent = $turninpaths{$prefix}; + $turninparent =~ s{(/[^/]+)$}{}; + } + } + $output=~ + s/\<((?:input|select)[^\>]+\Qjavascript:setSubmittedPart\E)\(\s*[\'\"]([^\'\"]+)[\'\"]*\s*\)/\<$1('$2','$prefix')/gsi; } $thisdir=~s/\/[^\/]*$//; foreach (@rlinks) { @@ -401,15 +428,27 @@ sub handler { $allscript. "\n\n"; } + if (($nforms) && ($nuploads)) { + $allscript .= &Apache::lonhtmlcommon::file_submissionchk_js(\%turninpaths,\%multiresps); + } # ------------------------------------------------------------------ Start body $r->print(&Apache::loncommon::start_page(undef,$allscript, {'force_register' => 1, 'bgcolor' => '#ffffff',})); # ------------------------------------------------------------------ Start form if ($nforms) { - $r->print('
1) { + $multi = 1; + } + $fmtag .= 'onsubmit="return file_submission_check(this,'."'$turninparent','$multi'".');"'; + } + $fmtag .= ' action="'. &Apache::lonenc::check_encrypt($requrl) - .'">'); + .'">'; + $r->print($fmtag); } } elsif (($target eq 'tex') || ($target eq 'tex_answer')) { # I think this is not needed as the header @@ -446,7 +485,7 @@ sub handler { unless (($target eq 'tex') || ($target eq 'tex_answer')) { $r->print('print(' bgcolor="'. @@ -468,7 +507,10 @@ sub handler { } $r->print('>'); } - $r->print($ssibody{$rid}); + unless (($cellexternal{$rid}) && + ($target eq 'tex') && ($target eq 'tex_answer')) { + $r->print($ssibody{$rid}); + } unless (($target eq 'tex') || ($target eq 'tex_answer')) { $r->print(''); } @@ -553,10 +595,6 @@ sub handler { sub get_buttons { my ($hash,$rid) = @_; - # which icons do we use? - my $extension='png'; - if ($env{'environment.icons'} eq 'classic') { $extension='gif'; } - my $metainfo = ''; my $esrc=&Apache::lonnet::declutter($hash->{'src_'.$rid}); my ($mapid,$resid)=split(/\./,$rid); @@ -568,20 +606,28 @@ sub get_buttons { $esrc=&Apache::lonenc::encrypted($esrc); } if ($hash->{'src_'.$rid} !~ m-^/uploaded/- + && $hash->{'src_'.$rid} !~ m{^https?://} && !$env{'request.enc'} && ($env{'request.role.adv'} || !$hash->{'encrypted_'.$rid})) { $metainfo .=''. ''. - ''. + ''.&mt('Show Metadata').''. + ''; + } + if (($hash->{'src_'.$rid} !~ m{^/uploaded/}) && + ($hash->{'src_'.$rid} !~ m{^https?://})) { + $metainfo .= ''. + ''.&mt('Provide my evaluation of this resource').''. ''; } - $metainfo .= ''. - ''. - ''; - if (($hash->{'src_'.$rid}=~/\.(problem|exam|quiz|assess|survey|form)$/) && + if (($hash->{'src_'.$rid}=~/$LONCAPA::assess_re/) && ($hash->{'src_'.$rid} !~ m-^/uploaded/-)) { if (&Apache::lonnet::allowed('mgr',$env{'request.course.id'})) { @@ -589,12 +635,16 @@ sub get_buttons { ''. '&command=submission">'. - ''. + ''.&mt('View Submissions for a Student or a Group of Students').''. ''. ''. '&command=gradingmenu">'. - ''. + ''.&mt('Content Grades').''. ''; } if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) { @@ -602,7 +652,9 @@ sub get_buttons { ''. '" >'. - ''. + ''.&mt('Content Settings').''. ''; } }