version 1.13, 2007/04/19 17:40:43
|
version 1.18, 2007/08/03 20:55:10
|
Line 60 sub maximareply {
|
Line 60 sub maximareply {
|
|
|
sub blacklisted { |
sub blacklisted { |
my ($cmd)=@_; |
my ($cmd)=@_; |
foreach my $forbidden ('save','load','plot','lisp','includ','compil','file','batch','stringout','translat','stout','stin','block','system') { |
foreach my $forbidden ('save','plot','lisp','includ','compil', |
|
'file','batch','stringout','translat','stout', |
|
'stin','block','system','concat') { |
if ($cmd=~/$forbidden/s) { return 1; } |
if ($cmd=~/$forbidden/s) { return 1; } |
} |
} |
return 0; |
return 0; |
Line 75 sub runscript {
|
Line 77 sub runscript {
|
if ($line=~/\w/) { $reply=&maximareply($socket,$line.";\n"); } |
if ($line=~/\w/) { $reply=&maximareply($socket,$line.";\n"); } |
if ($reply=~/^Error\:/) { return $reply; } |
if ($reply=~/^Error\:/) { return $reply; } |
} |
} |
$reply=~s/\W//gs; |
$reply=~s/^\s*//gs; |
|
$reply=~s/\s*$//gs; |
|
&Apache::lonxml::debug("maxima $fullscript \n reply $reply"); |
return $reply; |
return $reply; |
} |
} |
|
|
Line 117 sub maxima_eval {
|
Line 121 sub maxima_eval {
|
|
|
sub compareterms { |
sub compareterms { |
my ($socket,$terma,$termb)=@_; |
my ($socket,$terma,$termb)=@_; |
my $difference=$terma.'-'.$termb; |
my $difference=$terma.'-('.$termb.')'; |
if (&blacklisted($difference)) { return 'Error: blacklisted'; } |
if (&blacklisted($difference)) { return 'Error: blacklisted'; } |
my $reply=&maximareply($socket,'trigsimp(trigreduce('.$difference.'));'); |
my $reply=&maximareply($socket,'trigsimp(trigreduce('.$difference.'));'); |
if ($reply=~/^\s*0\s*$/) { return 'true'; } |
if ($reply=~/^\s*0\s*$/) { return 'true'; } |
Line 130 sub maxima_check {
|
Line 134 sub maxima_check {
|
my $socket=&connect(); |
my $socket=&connect(); |
my $reply=&compareterms($socket,$response,$answer); |
my $reply=&compareterms($socket,$response,$answer); |
&disconnect($socket); |
&disconnect($socket); |
|
# integer to string mappings come from capaParser.h |
|
# 1 maps to 'EXACT_ANS' |
if ($reply eq 'true') { return 1; } |
if ($reply eq 'true') { return 1; } |
|
# 7 maps to 'INCORRECT' |
return 7; |
return 7; |
} |
} |
|
|