--- loncom/xml/lonxml.pm 2017/11/16 23:54:43 1.531.2.22.2.1
+++ loncom/xml/lonxml.pm 2024/07/07 21:43:24 1.531.2.26
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.531.2.22.2.1 2017/11/16 23:54:43 raeburn Exp $
+# $Id: lonxml.pm,v 1.531.2.26 2024/07/07 21:43:24 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -69,6 +69,8 @@ use Safe();
use Safe::Hole();
use Math::Cephes();
use Math::Random();
+use Math::Calculus::Expression();
+use Number::FormatEng();
use Opcode();
use POSIX qw(strftime);
use Time::HiRes qw( gettimeofday tv_interval );
@@ -440,7 +442,7 @@ sub latex_special_symbols {
} else {
$string=~s/\\/\\ensuremath{\\backslash}/g;
$string=~s/\\\%|\%/\\\%/g;
- $string=~s/\\\{|{/\\{/g;
+ $string=~s/\\\{|\{/\\{/g;
$string=~s/\\}|}/\\}/g;
$string=~s/\\ensuremath\\\{\\backslash\\}/\\ensuremath{\\backslash}/g;
$string=~s/\\\$|\$/\\\$/g;
@@ -914,6 +916,9 @@ sub init_safespace {
$safehole->wrap(\&Apache::functionplotresponse::fpr_objectcoords,$safeeval,'&fpr_objectcoords');
$safehole->wrap(\&Apache::functionplotresponse::fpr_vectorlength,$safeeval,'&fpr_vectorlength');
$safehole->wrap(\&Apache::functionplotresponse::fpr_vectorangle,$safeeval,'&fpr_vectorangle');
+ $safehole->wrap(\&Math::Calculus::Expression::math_calculus_expression,$safeeval,'&math_calculus_expression');
+ $safehole->wrap(\&Number::FormatEng::format_eng,$safeeval,'&number_format_eng');
+ $safehole->wrap(\&Number::FormatEng::format_pref,$safeeval,'&number_format_pref');
# use Data::Dumper;
# $safehole->wrap(\&Data::Dumper::Dumper,$safeeval,'&LONCAPA_INTERNAL_Dumper');
@@ -1086,7 +1091,7 @@ sub decreasedepth {
sub get_id {
my ($parstack,$safeeval)=@_;
my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
- if ($env{'request.state'} eq 'construct' && $id =~ /([._]|[^\w\d\s[:punct:]])/) {
+ if ($env{'request.state'} eq 'construct' && $id =~ /([._]|[^\w\s\-])/) {
&error(&mt('ID [_1] contains invalid characters. IDs are only allowed to contain letters, numbers, spaces and -','"'.$id.'"'));
}
if ($id =~ /^\s*$/) { $id = $Apache::lonxml::curdepth; }
@@ -1628,6 +1633,21 @@ sub renderingoptions {
return $output;
}
+sub setmode_javascript {
+ return <<"ENDSCRIPT";
+
+ENDSCRIPT
+}
+
sub inserteditinfo {
my ($filecontents,$filetype,$filename,$symb,$itemtitle,$folderpath,$uri,$action) = @_;
$filecontents = &HTML::Entities::encode($filecontents,'<>&"');
@@ -1712,7 +1732,7 @@ FULLPAGE
if ($filetype eq 'html') {
$htmlerror=&verify_html($filecontents);
if ($htmlerror) {
- $htmlerror=''.$htmlerror.'';
+ $htmlerror=(' 'x3).' '.$htmlerror.'';
}
if (&Apache::lonhtmlcommon::htmlareabrowser()) {
unless ($textareaclass) {
@@ -1720,14 +1740,23 @@ FULLPAGE
}
}
}
- my $undo;
+ my ($undo,%onclick);
+ foreach my $item ('discard','undo') {
+ $onclick{$item} = 'onclick="still_ask=true;setmode(this.form,'."'$item'".')"';
+ }
+ foreach my $item ('saveedit','saveview') {
+ $onclick{$item} = 'onclick="is_submit=true;setmode(this.form,'."'$item'".')"';
+ }
unless ($uri =~ m{^/uploaded/}) {
- $undo = ''."\n";
+ $undo = ''."\n";
}
+ $initialize .= &setmode_javascript();
my $editfooter=(<