[LON-CAPA-cvs] cvs: loncom /homework default_homework.lcpm
www
lon-capa-cvs@mail.lon-capa.org
Fri, 30 Jun 2006 21:24:27 -0000
www Fri Jun 30 17:24:27 2006 EDT
Modified files:
/loncom/homework default_homework.lcpm
Log:
Partial bug #977: implicit multiplication in clear-cut places
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.107 loncom/homework/default_homework.lcpm:1.108
--- loncom/homework/default_homework.lcpm:1.107 Tue Jun 13 10:57:54 2006
+++ loncom/homework/default_homework.lcpm Fri Jun 30 17:24:27 2006
@@ -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.107 2006/06/13 14:57:54 albertel Exp $
+# $Id: default_homework.lcpm,v 1.108 2006/06/30 21:24:27 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -152,9 +152,9 @@
my $reterror="";
my $result;
if ($type eq '9') {
- $result = &maxima_check($response,$answer,\$reterror);
+ $result = &maxima_check(&maxima_cas_formula_fix($response),&maxima_cas_formula_fix($answer),\$reterror);
} else {
- $result = &caparesponse_capa_check_answer($response,$answer,$type,
+ $result = &caparesponse_capa_check_answer(&capa_formula_fix($response),&capa_formula_fix($answer),$type,
$tol_type,$tol,
$sig_lbound,$sig_ubound,
$ans_fmt,$unit,$calc,$id_list,
@@ -184,6 +184,23 @@
return ("$result:\nRetError $reterror:\nAnswer $answer:\nResponse $response:\n type-$type|$tol|$tol_type|$sig:$sig_lbound:$sig_ubound|$unit|\n$message",$reterror);
}
+sub maxima_cas_formula_fix {
+ my ($expression)=@_;
+ return &implicit_multiplication($expression);
+}
+
+sub capa_formula_fix {
+ my ($expression)=@_;
+ return &implicit_multiplication($expression);
+}
+
+sub implicit_multiplication {
+ my ($expression)=@_;
+ $expression=~s/\s+/\*/g;
+ $expression=~s/(\d)([a-zA-Z\(])/$1\*$2/g;
+ $expression=~s/\)(\w)/\)\*$1/g;
+ return $expression;
+}
sub caparesponse_check_list {
my $response=$LONCAPA::CAPAresponse_args{'response'};