--- rat/lonpage.pm 2015/07/09 00:11:56 1.109 +++ rat/lonpage.pm 2015/07/17 19:00:47 1.110 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Page Handler # -# $Id: lonpage.pm,v 1.109 2015/07/09 00:11:56 raeburn Exp $ +# $Id: lonpage.pm,v 1.110 2015/07/17 19:00:47 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -216,6 +216,7 @@ sub handler { my $contents=0; my $nforms=0; my $nuploads=0; + my $ntimers=0; my %turninpaths; my %multiresps; my $turninparent; @@ -369,16 +370,26 @@ ENDEXT } $output=~s/\<\/body\>.*//si; if ($output=~/\
]*\>//gsi; $output=~s/\<\/form[^\>]*\>//gsi; if ($output=~/\]+name\s*=\s*[\'\"]*HWFILE/) { $nuploads++; } + if ($output=~/\]+name\s*=\s*[\'\"]*accessbutton/) { + $ntimers++; + $hastimer = 1; + } $output=~ s/\<((?:input|select|button|textarea)[^\>]+)name\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\>]*)\>/\<$1 name="$prefix$2" $3\>/gsi; $output=~ s/\<((?:input|select|button|textarea)[^\>]+)id\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\>]*)\>/\<$1 id="$idprefix$2" $3\>/gsi; + if ($hastimer) { + $output=~ + s/\<(input[^\>]+name=\Q"$prefix\Eaccessbutton"[^\>]+)(?:\Qdocument.markaccess.submit();\E)([^\>]*)\>/\<$1pageTimer(this.form,'$prefix')$2\>/gsi; + $output=~ s/\<(input[^\>]+name=\Q"$prefix\Emarkaccess"[^\>]+value=["'])(?:yes)(['"][^\>]*)\>/\<$1$2\>/gsi; + } if ($matheditor eq 'dragmath') { $output=~ s/(\Qjavascript:LC_mathedit_\E)(HWVAL_)([^'"]+?)(\(['"]*)(\QHWVAL_\E\3['"]\)\;void\(0\)\;)/$1$idprefix$2$3$4$idprefix$5/g; @@ -462,6 +473,16 @@ ENDEXT ); $allscript .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args); } + if ($ntimers) { + $allscript .= '\n"; + } # ------------------------------------------------------------------ Start body $r->print(&Apache::loncommon::start_page(undef,$allscript, {'force_register' => 1, @@ -593,6 +614,10 @@ ENDEXT my $class; if ($nforms > 1) { $class = ' class="LC_hwk_submit"'; + if ($ntimers) { + $nforms = 1; + $class = ''; + } } $r->print( '