version 1.125, 2003/12/11 23:39:54
|
version 1.127, 2004/02/05 21:04:24
|
Line 213 sub end_numericalresponse {
|
Line 213 sub end_numericalresponse {
|
my $partid=$Apache::inputtags::part; |
my $partid=$Apache::inputtags::part; |
my $id=$Apache::inputtags::response[-1]; |
my $id=$Apache::inputtags::response[-1]; |
my $number_of_bubbles = &Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.numbubbles'); |
my $number_of_bubbles = &Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.numbubbles'); |
|
if ($Apache::inputtags::params{'numbubbles'}) { |
|
$number_of_bubbles = $Apache::inputtags::params{'numbubbles'}; |
|
} |
if (!$number_of_bubbles) { $number_of_bubbles=8; } |
if (!$number_of_bubbles) { $number_of_bubbles=8; } |
|
|
my (@formats)=&Apache::lonxml::get_param_var('format',$parstack, |
my (@formats)=&Apache::lonxml::get_param_var('format',$parstack, |
$safeeval); |
$safeeval); |
my $unit=&Apache::lonxml::get_param_var('unit',$parstack, |
my $unit=&Apache::lonxml::get_param_var('unit',$parstack, |
Line 428 sub make_numerical_bubbles {
|
Line 432 sub make_numerical_bubbles {
|
my @oldseed=&Math::Random::random_get_seed(); |
my @oldseed=&Math::Random::random_get_seed(); |
if (defined($incorrect) && ref($incorrect)) { |
if (defined($incorrect) && ref($incorrect)) { |
&Apache::lonxml::debug("inside ".(scalar(@$incorrect)+1 gt $number_of_bubbles)); |
&Apache::lonxml::debug("inside ".(scalar(@$incorrect)+1 gt $number_of_bubbles)); |
if (scalar(@$incorrect)+1 >= $number_of_bubbles) { |
if (defined($$incorrect[0]) && |
|
scalar(@$incorrect)+1 >= $number_of_bubbles) { |
&Apache::lonxml::debug("inside ".(scalar(@$incorrect)+1).":$number_of_bubbles"); |
&Apache::lonxml::debug("inside ".(scalar(@$incorrect)+1).":$number_of_bubbles"); |
&Apache::response::setrandomnumber(); |
&Apache::response::setrandomnumber(); |
my @rand_inc=&Math::Random::random_permutation(@$incorrect); |
my @rand_inc=&Math::Random::random_permutation(@$incorrect); |
Line 438 sub make_numerical_bubbles {
|
Line 443 sub make_numerical_bubbles {
|
&Math::Random::random_set_seed(@oldseed); |
&Math::Random::random_set_seed(@oldseed); |
return @bubble_values; |
return @bubble_values; |
} |
} |
#FIXME what to do when not enough incorrects specified? |
if (defined($$incorrect[0]) && |
|
scalar(@$incorrect)+1 < $number_of_bubbles) { |
|
&Apache::lonxml::warning("Not enough incorrect answers were specified in the incorrect array, ignoring the specified incorrect answers and instead generating them."); |
|
} |
} |
} |
my @factors = (1.13,1.17,1.25,1.33,1.45); #default values of factors |
my @factors = (1.13,1.17,1.25,1.33,1.45); #default values of factors |
my @powers = (1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0); #default values for powers |
my @powers = (1..$number_of_bubbles); |
&Apache::response::setrandomnumber(); |
&Apache::response::setrandomnumber(); |
my $ind=&Math::Random::random_uniform_integer(1,0,$#powers); |
my $ind=&Math::Random::random_uniform_integer(1,0,$#powers); |
my $power = $powers[$ind]; |
my $power = $powers[$ind]; |