[LON-CAPA-cvs] cvs: rat / lonpage.pm
raeburn
raeburn at source.lon-capa.org
Fri Jul 17 15:00:47 EDT 2015
raeburn Fri Jul 17 19:00:47 2015 EDT
Modified files:
/rat lonpage.pm
Log:
- Bug 6788.
Support clicking of "Show Resource" button in resources within a
composite page (i.e., where interval parameter is set).
Index: rat/lonpage.pm
diff -u rat/lonpage.pm:1.109 rat/lonpage.pm:1.110
--- rat/lonpage.pm:1.109 Thu Jul 9 00:11:56 2015
+++ rat/lonpage.pm Fri Jul 17 19:00:47 2015
@@ -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 @@
my $contents=0;
my $nforms=0;
my $nuploads=0;
+ my $ntimers=0;
my %turninpaths;
my %multiresps;
my $turninparent;
@@ -369,16 +370,26 @@
}
$output=~s/\<\/body\>.*//si;
if ($output=~/\<form/si) {
+ my $hastimer;
$nforms++;
$output=~s/\<form[^\>]*\>//gsi;
$output=~s/\<\/form[^\>]*\>//gsi;
if ($output=~/\<input[^\>]+name\s*=\s*[\'\"]*HWFILE/) {
$nuploads++;
}
+ if ($output=~/\<input[^\>]+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 @@
);
$allscript .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args);
}
+ if ($ntimers) {
+ $allscript .= '<script type="text/javascript">'."\n".
+ '// <![CDATA['."\n".
+ 'function pageTimer(form,prefix) {'."\n".
+ " form.elements[prefix+'markaccess'].value = 'yes';\n".
+ " form.submit();\n".
+ '}'."\n".
+ '// ]]>'.
+ "\n</script>\n";
+ }
# ------------------------------------------------------------------ Start body
$r->print(&Apache::loncommon::start_page(undef,$allscript,
{'force_register' => 1,
@@ -593,6 +614,10 @@
my $class;
if ($nforms > 1) {
$class = ' class="LC_hwk_submit"';
+ if ($ntimers) {
+ $nforms = 1;
+ $class = '';
+ }
}
$r->print(
'<input name="all_submit" value="'.&mt('Submit All').'" type="'.
More information about the LON-CAPA-cvs
mailing list