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

raeburn raeburn at source.lon-capa.org
Fri Dec 4 17:19:19 EST 2020


raeburn		Fri Dec  4 22:19:19 2020 EDT

  Modified files:              
    /loncom/homework/caparesponse	caparesponse.pm 
  Log:
  - When generating values for bubbles for numericalresponse in exam mode,
    skip the computation when the bubble is for the correct answer.
    This avoids a "use fewer digits" issue in online exams on 64bit servers
    when the correct answer is >= 1e+16, and when the correct bubble is A.
  
  
Index: loncom/homework/caparesponse/caparesponse.pm
diff -u loncom/homework/caparesponse/caparesponse.pm:1.260 loncom/homework/caparesponse/caparesponse.pm:1.261
--- loncom/homework/caparesponse/caparesponse.pm:1.260	Fri Sep 14 02:51:39 2018
+++ loncom/homework/caparesponse/caparesponse.pm	Fri Dec  4 22:19:19 2020
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # caparesponse definition
 #
-# $Id: caparesponse.pm,v 1.260 2018/09/14 02:51:39 raeburn Exp $
+# $Id: caparesponse.pm,v 1.261 2020/12/04 22:19:19 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1065,7 +1065,12 @@
                      &Math::Random::random_uniform_integer(1,1,10);
     }
     for ($ind=0;$ind<$number_of_bubbles;$ind++) {
-	$bubble_values[$ind] = $answerfactor*($factor**($power-$powers[$#powers-$ind]));
+	my $exponent = $power-$powers[$#powers-$ind];
+	if ($exponent == 0) {
+	    $bubble_values[$ind] = $answerfactor;
+	} else { 
+	    $bubble_values[$ind] = $answerfactor*($factor**$exponent);
+	}
 	$bubble_display[$ind] = &format_number($bubble_values[$ind],
 					       $format,$target,$safeeval);
     }




More information about the LON-CAPA-cvs mailing list