--- rat/lonpage.pm 2012/11/30 18:16:53 1.98 +++ rat/lonpage.pm 2014/12/30 20:03:19 1.107 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Page Handler # -# $Id: lonpage.pm,v 1.98 2012/11/30 18:16:53 raeburn Exp $ +# $Id: lonpage.pm,v 1.107 2014/12/30 20:03:19 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,6 +36,7 @@ use strict; use Apache::Constants qw(:common :http); use Apache::lonnet; use Apache::loncommon(); +use Apache::lonhtmlcommon; use Apache::lonxml(); use Apache::lonlocal; use Apache::lonmenu; @@ -227,6 +228,7 @@ sub handler { my %ssialink=(); my %cellemb=(); + my %cellexternal=(); my $allscript=''; my $allmeta=''; @@ -244,18 +246,26 @@ 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); my $prefix=$_.'_'; + my $idprefix= join('_',($mapid,$resid,'')); my %posthash=('request.prefix' => $prefix, 'LONCAPA_INTERNAL_no_discussion' => 'true', 'symb' => $symb); @@ -297,6 +307,12 @@ sub handler { #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; @@ -361,6 +377,21 @@ sub handler { } $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 ($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