[LON-CAPA-cvs] cvs: rat / lonratparms.pm lonuserstate.pm

www lon-capa-cvs@mail.lon-capa.org
Tue, 25 Feb 2003 15:58:51 -0000


www		Tue Feb 25 10:58:51 2003 EDT

  Modified files:              
    /rat	lonratparms.pm lonuserstate.pm 
  Log:
  Introduces new "randomly pick random seed" parameter. However, just for the
  record: having the same sequence more than once within the same sequence
  does neither work for rids. Let's just say that this is a feature, not a
  bug.
  
  If you want the same randomization of the same sequence twice, you need to 
  have two different parent sequences, and use the same seed.
  
  
Index: rat/lonratparms.pm
diff -u rat/lonratparms.pm:1.12 rat/lonratparms.pm:1.13
--- rat/lonratparms.pm:1.12	Fri Jun 14 15:38:24 2002
+++ rat/lonratparms.pm	Tue Feb 25 10:58:51 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Set parameters inside of the RAT
 #
-# $Id: lonratparms.pm,v 1.12 2002/06/14 19:38:24 www Exp $
+# $Id: lonratparms.pm,v 1.13 2003/02/25 15:58:51 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -79,6 +79,11 @@
         $content{'parameter_randompick'}='';
         $type{'parameter_randompick'}='int_pos';
 	$display{'parameter_randompick'}='Randomly pick number of resources';
+        
+        $content{'parameter_randompickseed'}='';
+        $type{'parameter_randompickseed'}='int_pos';
+	$display{'parameter_randompickseed'}=
+ 'Random seed for randomly picking number of resources (optional, only set if you know what you are doing)';
     } else {
         $content{'parameter_mapalias'}='';
         $type{'parameter_mapalias'}='string';
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.50 rat/lonuserstate.pm:1.51
--- rat/lonuserstate.pm:1.50	Fri Feb 21 18:01:48 2003
+++ rat/lonuserstate.pm	Tue Feb 25 10:58:51 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construct and maintain state and binary representation of course for user
 #
-# $Id: lonuserstate.pm,v 1.50 2003/02/21 23:01:48 albertel Exp $
+# $Id: lonuserstate.pm,v 1.51 2003/02/25 15:58:51 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -67,6 +67,7 @@
 my $errtext; # variable with all errors
 my $retfurl; # variable with the very first URL in the course
 my %randompick; # randomly picked resources
+my %randompickseed; # optional seed for randomly picking resources
 my %actualversion; # version of resource as loaded now
 my %setversion; # forced version of resource
 my %lastversion; # version when CC came in last
@@ -239,6 +240,9 @@
                     if ($token->[2]->{'name'} eq 'parameter_randompick') {
 			$randompick{$referid}=$token->[2]->{'value'};
                     }
+                    if ($token->[2]->{'name'} eq 'parameter_randompickseed') {
+			$randompick{$referid}=$token->[2]->{'value'};
+                    }
                 } 
 
             }
@@ -432,6 +436,7 @@
         next if ($#currentrids<$rndpick);
 # -------------------------------- randomly eliminate the ones that should stay
 	my (undef,$id)=split(/\./,$rid);
+        if ($randompickseed{$rid}) { $id=$randompickseed{$rid}; }
 	my $rndseed=&Apache::lonnet::rndseed($id); # use id instead of symb
 	&Math::Random::random_set_seed_from_phrase($rndseed);
 	my @whichids=&Math::Random::random_permuted_index($#currentrids+1);