--- loncom/homework/default_homework.lcpm 2008/09/13 02:08:32 1.140 +++ loncom/homework/default_homework.lcpm 2009/04/17 01:00:15 1.144 @@ -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.140 2008/09/13 02:08:32 raeburn Exp $ +# $Id: default_homework.lcpm,v 1.144 2009/04/17 01:00:15 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -217,7 +217,13 @@ sub caparesponse_check { my $reterror=""; my $result; - if ((($type eq '9') || ($type eq '8')) && ($response=~/\=/)) { return ('BAD_FORMULA','Please submit just an expression, not an equation.'); } + if (($type eq '9') || ($type eq '8')) { + if ($response=~/\=/) { + return ('BAD_FORMULA','Please submit just an expression, not an equation.'); + } elsif ($response =~ /\,/ and $response !~ /^\s*\{.*\}\s*$/) { + return ('BAD_FORMULA'); + } + } if ($type eq '9') { $result = &maxima_check(&maxima_cas_formula_fix($response),&maxima_cas_formula_fix($answer),\$reterror); } else { @@ -320,7 +326,7 @@ sub caparesponse_check_list { $element =~ s/\s//g; } my $appendunit=$unit; - if ($unit=~/\%/) { + if (($unit=~/\%/) && ($answerunit ne '%')) { $element=$element/100; $appendunit=~s/\%//; } @@ -430,6 +436,8 @@ sub cas { my $output; if ($system eq 'maxima') { $output=&maxima_eval($input,$library); + } elsif ($system eq 'R') { + $output=&r_eval($input,$library); } else { $output='Error: unrecognized CAS'; }