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

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 30 Apr 2003 21:23:45 -0000


albertel		Wed Apr 30 17:23:45 2003 EDT

  Modified files:              
    /loncom/homework	response.pm 
  Log:
  - response uses/understands new larger seed
  
  
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.73 loncom/homework/response.pm:1.74
--- loncom/homework/response.pm:1.73	Wed Apr 30 17:19:13 2003
+++ loncom/homework/response.pm	Wed Apr 30 17:23:45 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # various response type definitons response definition
 #
-# $Id: response.pm,v 1.73 2003/04/30 21:19:13 albertel Exp $
+# $Id: response.pm,v 1.74 2003/04/30 21:23:45 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -83,18 +83,23 @@
 	$rndseed=$ENV{'form.rndseed'};
 	if (!$rndseed) { $rndseed=time; }
     } else {
-	my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
-	$rndseed=&Apache::lonnet::rndseed($symb,$courseid,$domain,$name);
+	$rndseed=&Apache::lonnet::rndseed();
     }
     &Apache::lonxml::debug("randseed $rndseed");
     #  $rndseed=unpack("%32i",$rndseed);
-    $rndseed=$rndseed
-	+(&Apache::lonnet::numval($Apache::inputtags::part) << 10);
+    my $rndmod=(&Apache::lonnet::numval($Apache::inputtags::part) << 10);
     if (defined($Apache::inputtags::response['-1'])) {
-	$rndseed=$rndseed
-	    +&Apache::lonnet::numval($Apache::inputtags::response['-1']);
+       $rndmod+=&Apache::lonnet::numval($Apache::inputtags::response[-1]);
     }
-    &Math::Random::random_set_seed_from_phrase($rndseed);
+    if ($rndseed =~/,/) {
+	my ($num1,$num2)=split(/,/,$rndseed);
+	$num1+=$rndmod;
+	$num2+=$rndmod;
+	$rndseed="$num1,$num2";
+    } else {
+	$rndseed+=$rndmod;
+    }
+    &Apache::lonnet::setup_random_from_rndseed($rndseed);
     &Apache::lonxml::debug("randseed $rndseed");
     return '';
 }