[LON-CAPA-cvs] cvs: loncom /homework/caparesponse caparesponse.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 05 Feb 2004 18:41:06 -0000


albertel		Thu Feb  5 13:41:06 2004 EDT

  Modified files:              
    /loncom/homework/caparesponse	caparesponse.pm 
  Log:
  - Fixes BUG#2686, wasn't handling the case of default bubble generation with fewer than 8 bubbles correctly (or more than 8), hadnles both correctly now
  - Fixes extra breakage that occured when num_bubbles set to 2 or 1
   
  
  
Index: loncom/homework/caparesponse/caparesponse.pm
diff -u loncom/homework/caparesponse/caparesponse.pm:1.125 loncom/homework/caparesponse/caparesponse.pm:1.126
--- loncom/homework/caparesponse/caparesponse.pm:1.125	Thu Dec 11 18:39:54 2003
+++ loncom/homework/caparesponse/caparesponse.pm	Thu Feb  5 13:41:06 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # caparesponse definition
 #
-# $Id: caparesponse.pm,v 1.125 2003/12/11 23:39:54 albertel Exp $
+# $Id: caparesponse.pm,v 1.126 2004/02/05 18:41:06 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -213,7 +213,11 @@
 	    my $partid=$Apache::inputtags::part;
 	    my $id=$Apache::inputtags::response[-1];
 	    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; }
+	    
 	    my (@formats)=&Apache::lonxml::get_param_var('format',$parstack,
 							 $safeeval);
 	    my $unit=&Apache::lonxml::get_param_var('unit',$parstack,
@@ -428,7 +432,8 @@
     my @oldseed=&Math::Random::random_get_seed();
     if (defined($incorrect) && ref($incorrect)) {
 	&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::response::setrandomnumber();
 	    my @rand_inc=&Math::Random::random_permutation(@$incorrect);
@@ -441,7 +446,7 @@
 	#FIXME what to do when not enough incorrects specified?
     }
     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();
     my $ind=&Math::Random::random_uniform_integer(1,0,$#powers);
     my $power = $powers[$ind];