[LON-CAPA-cvs] cvs: loncom /homework response.pm /homework/caparesponse caparesponse.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Thu, 23 Dec 2004 22:53:41 -0000
albertel Thu Dec 23 17:53:41 2004 EDT
Modified files:
/loncom/homework response.pm
/loncom/homework/caparesponse caparesponse.pm
Log:
- make response:setrandomseed more randomish
- fix BUG#3760, numerical response exam mode borked when submitting response since I changed it to start using prettyprint, &make_numerical_bubbles now submits back typeset and un typset bvalue
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.111 loncom/homework/response.pm:1.112
--- loncom/homework/response.pm:1.111 Tue Dec 7 18:23:34 2004
+++ loncom/homework/response.pm Thu Dec 23 17:53:41 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# various response type definitons response definition
#
-# $Id: response.pm,v 1.111 2004/12/07 23:23:34 albertel Exp $
+# $Id: response.pm,v 1.112 2004/12/23 22:53:41 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -130,9 +130,9 @@
$rndmod+=&Apache::lonnet::numval2($Apache::inputtags::response[-1]);
}
} else {
- $rndmod=(&Apache::lonnet::numval3($Apache::inputtags::part) << 10);
+ my $shift=(4*scalar(@Apache::inputtags::responselist))%30;
+ $rndmod=(&Apache::lonnet::numval3($Apache::inputtags::part) << (($shift+15)%30));
if (defined($Apache::inputtags::response[-1])) {
- my $shift=(4*scalar(@Apache::inputtags::response))%20;
$rndmod+=(&Apache::lonnet::numval3($Apache::inputtags::response[-1]) << $shift );
}
}
Index: loncom/homework/caparesponse/caparesponse.pm
diff -u loncom/homework/caparesponse/caparesponse.pm:1.157 loncom/homework/caparesponse/caparesponse.pm:1.158
--- loncom/homework/caparesponse/caparesponse.pm:1.157 Wed Oct 20 23:24:23 2004
+++ loncom/homework/caparesponse/caparesponse.pm Thu Dec 23 17:53:41 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# caparesponse definition
#
-# $Id: caparesponse.pm,v 1.157 2004/10/21 03:24:23 albertel Exp $
+# $Id: caparesponse.pm,v 1.158 2004/12/23 22:53:41 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -160,8 +160,8 @@
my (@formats)=&Apache::lonxml::get_param_var('format',$parstack,$safeeval);
my (@answers)=&Apache::lonxml::get_param_var('answer',$parstack,$safeeval);
my (@incorrect)=&Apache::lonxml::get_param_var('incorrect',$parstack,$safeeval);
- my @values=&make_numerical_bubbles($number_of_bubbles,$target,$answers[0],$formats[0],\@incorrect,$safeeval);
- $response=$values[$response];
+ my ($values,$display)=&make_numerical_bubbles($number_of_bubbles,$target,$answers[0],$formats[0],\@incorrect,$safeeval);
+ $response=$values->[$response];
}
$Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response;
my $args_ref= \%{$safeeval->varglob('LONCAPA::CAPAresponse_args')};
@@ -238,9 +238,10 @@
my $unit=&Apache::lonxml::get_param_var('unit',$parstack,
$safeeval);
my (@incorrect)=&Apache::lonxml::get_param_var('incorrect',$parstack,$safeeval);
- my @bubble_values=&make_numerical_bubbles($number_of_bubbles,
- $target,$answers[0],
- $formats[0],\@incorrect,$safeeval);
+ my ($bubble_values,$bubble_display)=
+ &make_numerical_bubbles($number_of_bubbles,
+ $target,$answers[0],
+ $formats[0],\@incorrect,$safeeval);
my @alphabet=('A'..'Z');
if ($target eq 'web') {
if ($tag eq 'numericalresponse') {
@@ -249,13 +250,13 @@
my $previous=$Apache::lonhomework::history{"resource.$Apache::inputtags::part.$id.submission"};
for (my $ind=0;$ind<$number_of_bubbles;$ind++) {
my $checked='';
- if ($previous eq $bubble_values[$ind]) {
+ if ($previous eq $bubble_values->[$ind]) {
$checked=" checked='on' ";
}
$result.='<td><input type="radio" name="HWVAL_'.$id.
- '" value="'.$bubble_values[$ind].'" '.$checked
+ '" value="'.$bubble_values->[$ind].'" '.$checked
.' /><b>'.$alphabet[$ind].'</b>: '.
- $bubble_values[$ind].'</td>';
+ $bubble_display->[$ind].'</td>';
}
$result.='</tr></table>';
} elsif ($tag eq 'formularesponse') {
@@ -269,7 +270,7 @@
}
if ($tag eq 'numericalresponse') {
my ($celllength,$number_of_tables,@table_range)=
- &get_table_sizes($number_of_bubbles,\@bubble_values);
+ &get_table_sizes($number_of_bubbles,$bubble_values);
my $j=0;
my $cou=0;
$result.='\vskip -1 mm \noindent \begin{enumerate}\item[\textbf{'.$Apache::lonxml::counter.'}.]';
@@ -280,7 +281,7 @@
}
$result.='}';
for (my $ind=$cou;$ind<$cou+$table_range[$j];$ind++) {
- $result.='\hskip -4 mm {\small \textbf{'.$alphabet[$ind].'}}$\bigcirc$ & \hskip -3 mm {\small '.$bubble_values[$ind].'} ';
+ $result.='\hskip -4 mm {\small \textbf{'.$alphabet[$ind].'}}$\bigcirc$ & \hskip -3 mm {\small '.$bubble_values->[$ind].'} ';
if ($ind != $cou+$table_range[$j]-1) {$result.=' & ';}
}
$cou += $table_range[$j];
@@ -458,7 +459,7 @@
sub make_numerical_bubbles {
my ($number_of_bubbles,$target,$answer,$format,$incorrect,$safeeval) =@_;
- my @bubble_values = ();
+ my @bubble_values=();
&Apache::lonxml::debug("answer is $answer incorrect is $incorrect");
my @oldseed=&Math::Random::random_get_seed();
if (defined($incorrect) && ref($incorrect)) {
@@ -473,11 +474,15 @@
&Apache::lonxml::debug("Answer was :$answer: returning :".$#bubble_values.": whih are :".join(':',@bubble_values));
&Math::Random::random_set_seed(@oldseed);
if (defined($format) && $format ne '') {
+ my @bubble_display;
foreach my $value (@bubble_values) {
- $value=&format_number($value,$format,$target,$safeeval);
+ push(@bubble_display,
+ &format_number($value,$format,$target,$safeeval));
}
+ return (\@bubble_values,\@bubble_display);
+ } else {
+ return (\@bubble_values,\@bubble_values);
}
- return @bubble_values;
}
if (defined($$incorrect[0]) &&
scalar(@$incorrect)+1 < $number_of_bubbles) {
@@ -491,14 +496,15 @@
my $power = $powers[$ind];
$ind=&Math::Random::random_uniform_integer(1,0,$#factors);
my $factor = $factors[$ind];
+ my @bubble_display;
for ($ind=0;$ind<$number_of_bubbles;$ind++) {
$bubble_values[$ind] = $answer*($factor**($power-$powers[$#powers-$ind]));
- $bubble_values[$ind] = &format_number($bubble_values[$ind],
+ $bubble_display[$ind] = &format_number($bubble_values[$ind],
$format,$target,$safeeval);
}
&Math::Random::random_set_seed(@oldseed);
- return @bubble_values;
+ return (\@bubble_values,\@bubble_display);
}
sub get_tolrange {