version 1.90, 2003/04/08 03:54:22
|
version 1.91, 2003/04/08 04:00:23
|
Line 187 sub end_numericalresponse {
|
Line 187 sub end_numericalresponse {
|
my $unit=&Apache::lonxml::get_param_var('unit',$parstack, |
my $unit=&Apache::lonxml::get_param_var('unit',$parstack, |
$safeeval); |
$safeeval); |
my @bubble_values=&make_numerical_bubbles($number_of_bubbles, |
my @bubble_values=&make_numerical_bubbles($number_of_bubbles, |
@answers); |
$target,$answers[0], |
|
$formats[0]); |
my @alphabet=('A'..'Z'); |
my @alphabet=('A'..'Z'); |
my $id=$Apache::inputtags::response[-1]; |
my $id=$Apache::inputtags::response[-1]; |
if ($target eq 'web') { |
if ($target eq 'web') { |
Line 195 sub end_numericalresponse {
|
Line 196 sub end_numericalresponse {
|
if ($unit=~/\S/) {$result.=' (in '.$unit.')<br /><br />';} |
if ($unit=~/\S/) {$result.=' (in '.$unit.')<br /><br />';} |
$result.= '<table border="1"><tr>'; |
$result.= '<table border="1"><tr>'; |
for (my $ind=0;$ind<$number_of_bubbles;$ind++) { |
for (my $ind=0;$ind<$number_of_bubbles;$ind++) { |
my $ans=&format_number($bubble_values[$ind], |
|
$formats[0]); |
|
$result.='<td><input type="radio" name="HWVAL_'.$id. |
$result.='<td><input type="radio" name="HWVAL_'.$id. |
'" value="'.$ans.'"><b>'.$alphabet[$ind]. |
'" value="'.$bubble_values[$ind].'"><b>'. |
'</b>: '.$ans.'</td>'; |
$alphabet[$ind].'</b>: '. |
|
$bubble_values[$ind].'</td>'; |
} |
} |
$result.='</tr></table>'; |
$result.='</tr></table>'; |
} elsif ($$tagstack[-1] eq 'formularesponse') { |
} elsif ($$tagstack[-1] eq 'formularesponse') { |
Line 224 sub end_numericalresponse {
|
Line 224 sub end_numericalresponse {
|
} |
} |
$result.='}'; |
$result.='}'; |
for (my $ind=$cou;$ind<$cou+$table_range[$j];$ind++) { |
for (my $ind=$cou;$ind<$cou+$table_range[$j];$ind++) { |
my $ans=&format_number($bubble_values[$ind], |
$result.='\hskip -3 mm {\small \textbf{'.$alphabet[$ind].'}}$\bigcirc$\hskip -2 mm & {\small '.$bubble_values[$ind].'} '; |
$formats[0],$target); |
|
$result.='\hskip -3 mm {\small \textbf{'.$alphabet[$ind].'}}$\bigcirc$\hskip -2 mm & {\small '.$ans.'} '; |
|
if ($ind != $cou+$table_range[$j]-1) {$result.=' & ';} |
if ($ind != $cou+$table_range[$j]-1) {$result.=' & ';} |
} |
} |
$cou += $table_range[$j]; |
$cou += $table_range[$j]; |
Line 392 sub format_number {
|
Line 390 sub format_number {
|
} |
} |
|
|
sub make_numerical_bubbles { |
sub make_numerical_bubbles { |
my ($number_of_bubbles,@answers) =@_; |
my ($number_of_bubbles,$target,$answer,$format) =@_; |
my @bubbles_values = (); |
my @bubble_values = (); |
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.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0); #default values for powers |
&Apache::response::setrandomnumber(); |
&Apache::response::setrandomnumber(); |
Line 402 sub make_numerical_bubbles {
|
Line 400 sub make_numerical_bubbles {
|
$ind=&Math::Random::random_uniform_integer(1,0,$#factors); |
$ind=&Math::Random::random_uniform_integer(1,0,$#factors); |
my $factor = $factors[$ind]; |
my $factor = $factors[$ind]; |
for ($ind=0;$ind<$number_of_bubbles;$ind++) { |
for ($ind=0;$ind<$number_of_bubbles;$ind++) { |
$bubbles_values[$ind] = $answers[0]*($factor**($power-$powers[$#powers-$ind])); |
$bubble_values[$ind] = $answer*($factor**($power-$powers[$#powers-$ind])); |
|
$bubble_values[$ind] = &format_number($bubble_values[$ind], |
|
$format,$target); |
|
|
} |
} |
return @bubbles_values; |
return @bubble_values; |
} |
} |
|
|
sub get_tolrange { |
sub get_tolrange { |