--- rat/lonpage.pm 2011/07/28 02:53:33 1.95 +++ rat/lonpage.pm 2011/07/28 03:14:09 1.96 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Page Handler # -# $Id: lonpage.pm,v 1.95 2011/07/28 02:53:33 raeburn Exp $ +# $Id: lonpage.pm,v 1.96 2011/07/28 03:14:09 raeburn 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=(); @@ -352,8 +356,21 @@ 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; } @@ -403,15 +420,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