--- rat/lonpage.pm 2014/02/11 15:56:47 1.103
+++ rat/lonpage.pm 2015/07/09 00:11:56 1.109
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Page Handler
#
-# $Id: lonpage.pm,v 1.103 2014/02/11 15:56:47 bisitz Exp $
+# $Id: lonpage.pm,v 1.109 2015/07/09 00:11:56 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -307,6 +307,12 @@ ENDEXT
#some additional cleanup necessary for LateX (due to limitations of table environment
$output =~ s/(\\vskip\s*\d+mm)\s*(\\\\)+/$1/g;
}
+ my $matheditor;
+ if ($output =~ /\Qjavascript:LC_mathedit_HWVAL_\E/) {
+ $matheditor = 'dragmath';
+ } elsif ($output =~ /LCmathField/) {
+ $matheditor = 'lcmath';
+ }
my $parser=HTML::TokeParser->new(\$output);
my $token;
my $thisdir=$src;
@@ -373,6 +379,19 @@ ENDEXT
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 ($matheditor eq 'dragmath') {
+ $output=~
+ s/(\Qjavascript:LC_mathedit_\E)(HWVAL_)([^'"]+?)(\(['"]*)(\QHWVAL_\E\3['"]\)\;void\(0\)\;)/$1$idprefix$2$3$4$idprefix$5/g;
+ $output=~
+ s/(function\s+LC_mathedit_)(HWVAL_)([^'"]+?)(\s+\(LCtextline\))/$1$idprefix$2$3$4/g;
+ } elsif ($matheditor eq 'lcmath') {
+ $output=~
+ s/(var\s+LCmathField\s+=\s+document\.getElementById\(['"])([^'"]+?)(['"]\)\;)/$1$idprefix$2$3/g;
+ }
+ $output=~
+ s/(\Q
\E)/
$1$idprefix$2$3$4/g;
+ $output=~
+ s/(\Q
)/$1$idprefix$2$3$4/g;
if ($nuploads) {
$output=~
s/\<(input[^\>]+name=\"\Q$prefix\EHWFILE[^\>]+)\s*id\s*\=\s*[\'\"]*([^\'\"]+)[\'\"]*([^\)]*)\>/\<$1 id="$prefix$2" $3\>/gsi;
@@ -385,6 +404,8 @@ ENDEXT
}
$output=~
s/\<((?:input|select)[^\>]+\Qjavascript:setSubmittedPart\E)\(\s*[\'\"]([^\'\"]+)[\'\"]*\s*\)/\<$1('$2','$prefix')/gsi;
+ $output=~
+ s/\<(input[^\>]+\Qonfocus=\"javascript:disableAutoComplete\E)\(\'([^\']+)\'\)(;\")/\<$1('$idprefix$2')$3/gsi;
}
$thisdir=~s/\/[^\/]*$//;
foreach (@rlinks) {
@@ -457,7 +478,7 @@ ENDEXT
}
$fmtag .= ' action="'.
&Apache::lonenc::check_encrypt($requrl)
- .'">';
+ .'" id="LC_page">';
$r->print($fmtag);
}
} elsif (($target eq 'tex') || ($target eq 'tex_answer')) {
@@ -537,9 +558,15 @@ ENDEXT
$r->print('>'.$metainfo.' ');
} elsif (&Apache::lonnet::declutter($hash{'src_'.$rid}) !~/\.(sequence|page)$/) {
- $r->print($metainfo.''.$hash{'title_'.$rid}.' '.
- &mt('It is recommended that you use an up-to-date virus scanner before handling this file.').'
'.
- &Apache::londocs::entryline(0,&mt("Click to download or use your browser's Save Link function"),'/'.&Apache::lonnet::declutter($hash{'src_'.$rid})).'
');
+ $r->print($metainfo.''.$hash{'title_'.$rid}.' ');
+ unless ($cellemb{$rid} eq 'wrp') {
+ $r->print(&mt('It is recommended that you use an up-to-date virus scanner before handling this file.'));
+ }
+ $r->print('
'.
+ &Apache::londocs::entryline(0,
+ &mt("Click to download or use your browser's Save Link function"),
+ '/'.&Apache::lonnet::declutter($hash{'src_'.$rid})).
+ '
');
}
unless (($target eq 'tex') || ($target eq 'tex_answer')) {
$r->print(' ');
@@ -563,9 +590,15 @@ ENDEXT
}
# ---------------------------------------------------------------- Submit, etc.
if ($nforms) {
+ my $class;
+ if ($nforms > 1) {
+ $class = ' class="LC_hwk_submit"';
+ }
$r->print(
'
');
+ (($nforms>1)?'submit':'hidden').'"'.$class.' id="all_submit" />'.
+ '
'.
+ &mt('Processing your submission ...').'
');
}
unless (($target eq 'tex') || ($target eq 'tex_answer')) {
$r->print(&Apache::loncommon::end_page({'discussion'
@@ -610,6 +643,11 @@ sub get_buttons {
my $symb=&Apache::lonnet::encode_symb($hash->{'map_id_'.$mapid},
$resid,
$hash->{'src_'.$rid});
+ unless ($env{'request.role.adv'}) {
+ if (&Apache::lonnet::EXT('resource.0.buttonshide',$symb)) {
+ return;
+ }
+ }
if ($hash->{'encrypted_'.$rid}) {
$symb=&Apache::lonenc::encrypted($symb);
$esrc=&Apache::lonenc::encrypted($esrc);