version 1.27, 2001/06/13 20:00:07
|
version 1.30, 2001/07/13 14:49:28
|
Line 21 sub caparesponse_check {
|
Line 21 sub caparesponse_check {
|
my $sig_lbound=''; #done |
my $sig_lbound=''; #done |
my $sig_ubound=''; #done |
my $sig_ubound=''; #done |
my $ans_fmt=''; |
my $ans_fmt=''; |
my $units=''; #done |
my $unit=''; #done |
my $calc=''; |
my $calc=''; |
my ($response,$expr)=@_; |
my ($response,$expr)=@_; |
|
|
($answer,$type,$tol,$sig,$ans_fmt, |
($answer,$type,$tol,$sig,$ans_fmt, |
$units,$calc) = eval $expr.';return $answer,$type,$tol,$sig,$ans_fmt,$units,$calc'; |
$unit,$calc) = eval $expr.';return $answer,$type,$tol,$sig,$ans_fmt,$unit,$calc'; |
#type's definitons come from capaParser.h |
#type's definitons come from capaParser.h |
if ($type eq '' ) { |
if ($type eq '' ) { |
if ( $answer eq ($answer *1.0)) { $type = 2; |
if ( $answer eq ($answer *1.0)) { $type = 2; |
Line 61 sub caparesponse_check {
|
Line 61 sub caparesponse_check {
|
my $result = &caparesponse_capa_check_answer($response,$answer,$type, |
my $result = &caparesponse_capa_check_answer($response,$answer,$type, |
$tol_type,$tol, |
$tol_type,$tol, |
$sig_lbound,$sig_ubound, |
$sig_lbound,$sig_ubound, |
$ans_fmt,$units,$calc); |
$ans_fmt,$unit,$calc); |
|
|
if ($result == '1') { $result='EXACT_ANS'; } |
if ($result == '1') { $result='EXACT_ANS'; } |
elsif ($result == '2') { $result='APPROX_ANS'; } |
elsif ($result == '2') { $result='APPROX_ANS'; } |
Line 82 sub caparesponse_check {
|
Line 82 sub caparesponse_check {
|
|
|
sub caparesponse_check_list { |
sub caparesponse_check_list { |
my ($response,$expr)=@_; |
my ($response,$expr)=@_; |
|
# do these first, because who knows what varname the instructor might have used |
|
# but it probably isn't $CAPARESPONSE_CHECK_LIST_answer |
|
my $CAPARESPONSE_CHECK_LIST_answer = eval $expr.';return $answer'; |
|
my (@list) = eval $CAPARESPONSE_CHECK_LIST_answer; |
my $result=''; |
my $result=''; |
my $aresult=''; |
my $aresult=''; |
my $current_answer; |
my $current_answer; |
my $answer = eval $expr.';return $answer'; |
|
my (@list) = eval $answer; |
|
my (@responselist)=split /,/,$response; |
my (@responselist)=split /,/,$response; |
my $unit=''; |
my $unit=''; |
$result.="Final response :$responselist['-1']:<br />"; |
$result.="Final response :$responselist['-1']:<br />"; |
Line 371 sub map {
|
Line 373 sub map {
|
my ($phrase,$dest,$source)=@_; |
my ($phrase,$dest,$source)=@_; |
my @seed = &random_seed_from_phrase($phrase); |
my @seed = &random_seed_from_phrase($phrase); |
&random_set_seed(@seed); |
&random_set_seed(@seed); |
my $num = scalar(@$source); |
|
my $destct = scalar(@$dest); |
my $destct = scalar(@$dest); |
# print "Warning - Number of source elements and destination elements does not match.\n" if $destct != $num; |
if (!$source) { |
my @idx = &math_random_permuted_index($num); |
my @output; |
my $ctr = 0; |
my @idx = &math_random_permuted_index($destct); |
my $tot = $num; |
my $ctr = 0; |
$tot = $destct if $destct < $num; |
while ($ctr < $destct) { |
if (ref($$dest[0])) { |
$output[$ctr] = $$dest[$idx[$ctr]]; |
while ($ctr < $tot) { |
|
${$$dest[$ctr]} = $$source[$idx[$ctr]]; |
|
$ctr++; |
$ctr++; |
} |
} |
|
return @output; |
} else { |
} else { |
while ($ctr < $tot) { |
my $num = scalar(@$source); |
$$dest[$ctr] = $$source[$idx[$ctr]]; |
my @idx = &math_random_permuted_index($num); |
$ctr++; |
my $ctr = 0; |
} |
my $tot = $num; |
|
$tot = $destct if $destct < $num; |
|
if (ref($$dest[0])) { |
|
while ($ctr < $tot) { |
|
${$$dest[$ctr]} = $$source[$idx[$ctr]]; |
|
$ctr++; |
|
} |
|
} else { |
|
while ($ctr < $tot) { |
|
$$dest[$ctr] = $$source[$idx[$ctr]]; |
|
$ctr++; |
|
} |
|
} |
} |
} |
} |
} |
|
|
Line 395 sub rmap {
|
Line 407 sub rmap {
|
my ($phrase,$dest,$source)=@_; |
my ($phrase,$dest,$source)=@_; |
my @seed = &random_seed_from_phrase($phrase); |
my @seed = &random_seed_from_phrase($phrase); |
&random_set_seed(@seed); |
&random_set_seed(@seed); |
my $num = scalar(@$source); |
|
my $destct = scalar(@$dest); |
my $destct = scalar(@$dest); |
# print "Warning - Number of source elements and destination elements does not match.\n" if $destct != $num; |
if (!$source) { |
my @idx = &math_random_permuted_index($num); |
my @idx = &math_random_permuted_index($destct); |
my $ctr = 0; |
my $ctr = 0; |
my $tot = $num; |
my @r_idx; |
$tot = $destct if $destct < $num; |
while ($ctr < $destct) { |
my @r_idx; |
$r_idx[$idx[$ctr]] = $ctr; |
while ($ctr < $tot) { |
$ctr++; |
$r_idx[$idx[$ctr]] = $ctr; |
} |
$ctr++; |
my @output; |
} |
$ctr = 0; |
$ctr = 0; |
while ($ctr < $destct) { |
if (ref($$dest[0])) { |
$output[$ctr] = $$dest[$r_idx[$ctr]]; |
while ($ctr < $tot) { |
|
${$$dest[$ctr]} = $$source[$r_idx[$ctr]]; |
|
$ctr++; |
$ctr++; |
} |
} |
|
return @output; |
} else { |
} else { |
|
my $num = scalar(@$source); |
|
my @idx = &math_random_permuted_index($num); |
|
my $ctr = 0; |
|
my $tot = $num; |
|
$tot = $destct if $destct < $num; |
|
my @r_idx; |
while ($ctr < $tot) { |
while ($ctr < $tot) { |
$$dest[$ctr] = $$source[$r_idx[$ctr]]; |
$r_idx[$idx[$ctr]] = $ctr; |
$ctr++; |
$ctr++; |
} |
} |
|
$ctr = 0; |
|
if (ref($$dest[0])) { |
|
while ($ctr < $tot) { |
|
${$$dest[$ctr]} = $$source[$r_idx[$ctr]]; |
|
$ctr++; |
|
} |
|
} else { |
|
while ($ctr < $tot) { |
|
$$dest[$ctr] = $$source[$r_idx[$ctr]]; |
|
$ctr++; |
|
} |
|
} |
} |
} |
} |
} |
|
|
Line 495 sub array_moments {
|
Line 523 sub array_moments {
|
$output[0]=$N; |
$output[0]=$N; |
if ($N <= 1) { |
if ($N <= 1) { |
$output[1]=$input[0]; |
$output[1]=$input[0]; |
$output[1] = "Input array not defined" if ($N == 0); |
$output[1]="Input array not defined" if ($N == 0); |
$output[2]="variance undefined for N<=1"; |
$output[2]="variance undefined for N<=1"; |
$output[3]="skewness undefined for N<=1"; |
$output[3]="skewness undefined for N<=1"; |
$output[4]="kurtosis undefined for N<=1"; |
$output[4]="kurtosis undefined for N<=1"; |