[LON-CAPA-cvs] cvs: loncom /homework default_homework.lcpm

raeburn raeburn at source.lon-capa.org
Wed Apr 3 17:37:11 EDT 2019


raeburn		Wed Apr  3 21:37:11 2019 EDT

  Modified files:              
    /loncom/homework	default_homework.lcpm 
  Log:
  - Bug 6903. Args passed to &Math::Random::random_set_seed() need to be 
    within bounds, otherwise use &Math::Random::random_set_seed_from_phrase()
  
  
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.175 loncom/homework/default_homework.lcpm:1.176
--- loncom/homework/default_homework.lcpm:1.175	Wed Sep 12 22:00:31 2018
+++ loncom/homework/default_homework.lcpm	Wed Apr  3 21:37:11 2019
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run()
 #
-# $Id: default_homework.lcpm,v 1.175 2018/09/12 22:00:31 raeburn Exp $
+# $Id: default_homework.lcpm,v 1.176 2019/04/03 21:37:11 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -656,16 +656,29 @@
 sub random {
     my ($start,$end,$step)=@_;
     if ( ! $hidden::RANDOMINIT ) {
-	if ($external::randomseed == 0) { $external::randomseed=1; }
-	if ($external::randomseed =~/,/) {
-	    my ($num1,$num2)=split(/,/,$external::randomseed);
-	    &random_set_seed(1,abs($num1));
-	} elsif ($external::randomseed =~/:/) {
-	    my ($num1,$num2)=split(/:/,$external::randomseed);
-	    &random_set_seed(abs($num1),abs($num2));
-	} else {
-	    &random_set_seed(1,int(abs($external::randomseed)));
-	}
+        if ($external::randomseed == 0) { $external::randomseed=1; }
+        if ($external::randomseed =~/,/) {
+            my ($num1,$num2) = map { abs($_); } split(/,/,$external::randomseed);
+            if ((!$num1) || ($num1 > 2147483398)) {
+                &random_set_seed_from_phrase($external::randomseed);
+            } else {
+                &random_set_seed(1,$num1);
+            }
+        } elsif ($external::randomseed =~/:/) {
+            my ($num1,$num2) = map { abs($_); } split(/:/,$external::randomseed);
+            if ((!$num1) || (!$num2) || ($num1 > 2147483562) || ($num2 > 2147483398)) {
+                &random_set_seed_from_phrase($external::randomseed);
+            } else {
+                &random_set_seed($num1,$num2);
+            }
+        } else {
+            my $num1 = int(abs($external::randomseed));
+            if ((!$num1) || ($num1 > 2147483398)) {
+                &random_set_seed_from_phrase($external::randomseed);
+            } else {
+                &random_set_seed(1,$num1);
+            }
+        }
 	&math_random_uniform();
 	$hidden::RANDOMINIT=1;
     }




More information about the LON-CAPA-cvs mailing list