From raeburn at source.lon-capa.org Fri Dec 4 17:19:19 2020 From: raeburn at source.lon-capa.org (raeburn) Date: Fri, 04 Dec 2020 22:19:19 -0000 Subject: [LON-CAPA-cvs] cvs: loncom /homework/caparesponse caparesponse.pm Message-ID: 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); } From raeburn at source.lon-capa.org Sat Dec 5 00:01:18 2020 From: raeburn at source.lon-capa.org (raeburn) Date: Sat, 05 Dec 2020 05:01:18 -0000 Subject: [LON-CAPA-cvs] cvs: loncom /homework/caparesponse caparesponse.pm Message-ID: raeburn Sat Dec 5 05:01:18 2020 EDT Modified files: /loncom/homework/caparesponse caparesponse.pm Log: - When generating values for bubbles for numericalresponse in exam mode, avoid 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.261 loncom/homework/caparesponse/caparesponse.pm:1.262 --- loncom/homework/caparesponse/caparesponse.pm:1.261 Fri Dec 4 22:19:19 2020 +++ loncom/homework/caparesponse/caparesponse.pm Sat Dec 5 05:01:18 2020 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # caparesponse definition # -# $Id: caparesponse.pm,v 1.261 2020/12/04 22:19:19 raeburn Exp $ +# $Id: caparesponse.pm,v 1.262 2020/12/05 05:01:18 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1066,11 +1066,22 @@ } for ($ind=0;$ind<$number_of_bubbles;$ind++) { my $exponent = $power-$powers[$#powers-$ind]; + $bubble_values[$ind] = $answerfactor*($factor**$exponent); + + # If bubble is for correct answer (i.e., exponent = 0), and value + # of $answerfactor * factor**$exponent is an integer with more than + # 15 digits, assign $answerfactor itself as bubble value. + # This prevents a "use fewer digits" issue on 64bit servers + # when correct answer is >= 1e+16, and when correct bubble is A. + if ($exponent == 0) { - $bubble_values[$ind] = $answerfactor; - } else { - $bubble_values[$ind] = $answerfactor*($factor**$exponent); + if ($bubble_values[$ind] =~ /^-?(\d+)$/) { + if (length($1) > 15) { + $bubble_values[$ind] = $answerfactor; + } + } } + $bubble_display[$ind] = &format_number($bubble_values[$ind], $format,$target,$safeeval); }