[LON-CAPA-cvs] cvs: loncom /homework default_homework.lcpm /xml lonxml.pm

raeburn raeburn at source.lon-capa.org
Wed Sep 12 17:10:57 EDT 2018


raeburn		Wed Sep 12 21:10:57 2018 EDT

  Modified files:              
    /loncom/homework	default_homework.lcpm 
    /loncom/xml	lonxml.pm 
  Log:
  - Bug 6873 
    LONCAPA-prerequisites needs perl-Number-FormatEng.
  
  
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.173 loncom/homework/default_homework.lcpm:1.174
--- loncom/homework/default_homework.lcpm:1.173	Tue Feb  7 21:24:29 2017
+++ loncom/homework/default_homework.lcpm	Wed Sep 12 21:10:44 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run()
 #
-# $Id: default_homework.lcpm,v 1.173 2017/02/07 21:24:29 damieng Exp $
+# $Id: default_homework.lcpm,v 1.174 2018/09/12 21:10:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -976,6 +976,18 @@
     return &xmlparse($formula);
 }
 
+sub convert_engineer_format {
+    my ($ans,$baseunit)=@_;
+    my ($value,$answer,$unit);
+    $baseunit =~ s{[^\w/\-\.]}{}g; 
+    eval {
+           $value = &number_format_pref($ans);
+    };
+    my ($answer,$prefix) = ($value=~ /^(.+)(\w)$/);
+    my $unit = $prefix.$baseunit;
+    return($answer,$unit);
+} 
+
 sub prettyprint {
     my ($value,$fmt,$target)=@_;
     my $result;
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.559 loncom/xml/lonxml.pm:1.560
--- loncom/xml/lonxml.pm:1.559	Sun Nov 12 23:10:33 2017
+++ loncom/xml/lonxml.pm	Wed Sep 12 21:10:57 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.559 2017/11/12 23:10:33 raeburn Exp $
+# $Id: lonxml.pm,v 1.560 2018/09/12 21:10:57 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -70,6 +70,7 @@
 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 );
@@ -821,6 +822,8 @@
   $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');




More information about the LON-CAPA-cvs mailing list