version 1.60, 2003/03/25 23:05:03
|
version 1.63, 2003/06/07 03:52:39
|
Line 62 sub caparesponse_check {
|
Line 62 sub caparesponse_check {
|
$message .="no ws in :$response:\n"; |
$message .="no ws in :$response:\n"; |
} |
} |
|
|
|
if (length($response) > 500) { return "TOO_LONG: Answer too long"; } |
|
|
if ($type eq '' ) { |
if ($type eq '' ) { |
$message .= "Didn't find a type :$type:$expr: defaulting\n"; |
$message .= "Didn't find a type :$type:$expr: defaulting\n"; |
if ( $answer eq ($answer *1.0)) { $type = 2; |
if ( $answer eq ($answer *1.0)) { $type = 2; |
Line 82 sub caparesponse_check {
|
Line 84 sub caparesponse_check {
|
#formula type setup the sample points |
#formula type setup the sample points |
if ($type eq '8') { |
if ($type eq '8') { |
($id_list,$points)=split(/@/,$samples); |
($id_list,$points)=split(/@/,$samples); |
$message.="Found :$points: points\n"; |
$message.="Found :$id_list:$points: points in $samples\n"; |
} |
} |
if ($tol eq '') { |
if ($tol eq '') { |
$tol=0.0; |
$tol=0.0; |
Line 134 sub get_array_args {
|
Line 136 sub get_array_args {
|
my ($expr,$arg)=@_; |
my ($expr,$arg)=@_; |
# do these first, because who knows what varname the instructor might have used |
# do these first, because who knows what varname the instructor might have used |
# but it probably isn't $CAPARESPONSE_CHECK_LIST_answer |
# but it probably isn't $CAPARESPONSE_CHECK_LIST_answer |
my $CAPARESPONSE_CHECK_LIST_answer = eval $expr.';return $'.$arg; #' |
my $CAPARESPONSE_CHECK_LIST_answer = eval $expr.';return $'.$arg; #' stupid emacs |
my $GET_ARRAY_ARGS_result; |
my $GET_ARRAY_ARGS_result; |
my @GET_ARRAY_ARGS_list; |
my @GET_ARRAY_ARGS_list; |
if ($CAPARESPONSE_CHECK_LIST_answer =~ /^\s*[\$\@]/) { |
if ($CAPARESPONSE_CHECK_LIST_answer =~ /^\s*[\$\@]/) { |
Line 154 sub caparesponse_check_list {
|
Line 156 sub caparesponse_check_list {
|
$expr =~ s/\\/\\\\/g; |
$expr =~ s/\\/\\\\/g; |
$expr =~ s/\'/\\\'/g; |
$expr =~ s/\'/\\\'/g; |
my ($result,@list) = &get_array_args($expr,'answer'); |
my ($result,@list) = &get_array_args($expr,'answer'); |
|
$expr =~ s/\\\'/\'/g; |
|
$expr =~ s/\\\\/\\/g; |
my $aresult=''; |
my $aresult=''; |
my $current_answer; |
my $current_answer; |
my $answers=join(':',@list); |
my $answers=join(':',@list); |
Line 238 sub hinton {
|
Line 242 sub hinton {
|
} |
} |
|
|
sub random { |
sub random { |
my ($start,$end,$step)=@_; |
my ($start,$end,$step)=@_; |
if ( ! $hidden::RANDOMINIT ) { |
if ( ! $hidden::RANDOMINIT ) { |
if ($external::randomseed == 0) { $external::randomseed=1; } |
if ($external::randomseed == 0) { $external::randomseed=1; } |
&random_set_seed(1,int(abs($external::randomseed))); |
if ($external::randomseed =~/,/) { |
&math_random_uniform(); |
my ($num1,$num2)=split(/,/,$seed); |
$hidden::RANDOMINIT=1; |
&random_set_seed(abs($num1),abs($num2)); |
} |
} else { |
if (!defined($step)) { $step=1; } |
&random_set_seed(1,int(abs($external::randomseed))); |
my $num=1+int(($end-$start)/$step); |
} |
my $result=$start + int(&math_random_uniform() * $num)*$step; |
&math_random_uniform(); |
return $result; |
$hidden::RANDOMINIT=1; |
|
} |
|
if (!defined($step)) { $step=1; } |
|
my $num=1+int(($end-$start)/$step); |
|
my $result=$start + int(&math_random_uniform() * $num)*$step; |
|
return $result; |
} |
} |
|
|
sub random_normal { |
sub random_normal { |