--- loncom/homework/default_homework.lcpm 2001/07/19 21:26:22 1.31
+++ loncom/homework/default_homework.lcpm 2001/08/22 22:21:46 1.35
@@ -25,10 +25,19 @@ sub caparesponse_check {
my $calc='';
my ($response,$expr)=@_;
+
($answer,$type,$tol,$sig,$ans_fmt,
$unit,$calc) = eval $expr.';return ($answer,$type,$tol,$sig,$ans_fmt,$unit,$calc);';
#type's definitons come from capaParser.h
my $message='';
+ #remove leading and trailing whitespace
+ if ($response=~ /^\s|\s$/) {
+ $response=~ s:^\s+|\s+$::g;
+ $message .="Removed ws now :$response:
";
+ } else {
+ $message .="no ws in :$response:
";
+ }
+
if ($type eq '' ) {
$message .= "Didn't find a type :$type:$expr: defaulting
";
if ( $answer eq ($answer *1.0)) { $type = 2;
@@ -99,6 +108,7 @@ sub caparesponse_check_list {
my $current_answer;
$result.="Got response :$CAPARESPONSE_CHECK_LIST_answer:$list[0]:
";
my @responselist;
+ my $type =eval $expr.';return $answer;';
if ($type ne '' && $#list > 0) {
(@responselist)=split /,/,$response;
} else {
@@ -258,16 +268,9 @@ sub random_noncentral_f {
}
sub random_multivariate_normal {
- my ($item_cnt,$seed,@mean) = @_;
- return "Number of deviates must be greater than 0" if $item_cnt <= 0;
- my (@covar,@retArray);
- my $ind = 0;
- while ($ind<$item_cnt) {
- push @covar, pop (@mean);
- $ind++;
- }
+ my ($item_cnt,$seed,$mean,$covar) = @_;
&random_set_seed_from_phrase($seed);
- @retArray=&math_random_multivariate_normal($item_cnt,@mean,@covar);
+ @retArray=&math_random_multivariate_normal($item_cnt,@$mean,@$covar);
return @retArray;
}