--- loncom/lonnet/perl/lonnet.pm 2001/08/20 19:41:54 1.154 +++ loncom/lonnet/perl/lonnet.pm 2001/08/20 23:28:43 1.155 @@ -72,7 +72,12 @@ # EXT(name) : value of a variable # symblist(map,hash) : Updates symbolic storage links # symbread([filename]) : returns the data handle (filename optional) -# rndseed() : returns a random seed +# rndseed([symb,courseid,domain,uname]) +# : returns a random seed, all arguments are optional, +# if they aren't sent it use the environment to derive +# them +# Note: if symb isn't sent and it can't get one from +# &symbread it will use the current time as it's return # receipt() : returns a receipt to be given out to users # getfile(filename) : returns the contents of filename, or a -1 if it can't # be found, replicates and subscribes to the file @@ -2144,16 +2149,21 @@ sub numval { } sub rndseed { - my $symb; - unless ($symb=&symbread()) { return time; } - { + my ($symb,$courseid,$domain,$username)=@_; + if (!$symb) { + unless ($symb=&symbread()) { return time; } + } + if (!$courseid) { $courseid=$ENV{'request.course.id'};} + if (!$domain) {$domain=$ENV{'user.domain'};} + if (!$username) {$username=$ENV{'user.name'};} + { use integer; my $symbchck=unpack("%32C*",$symb) << 27; my $symbseed=numval($symb) << 22; - my $namechck=unpack("%32C*",$ENV{'user.name'}) << 17; - my $nameseed=numval($ENV{'user.name'}) << 12; - my $domainseed=unpack("%32C*",$ENV{'user.domain'}) << 7; - my $courseseed=unpack("%32C*",$ENV{'request.course.id'}); + my $namechck=unpack("%32C*",$username) << 17; + my $nameseed=numval($username) << 12; + my $domainseed=unpack("%32C*",$domain) << 7; + my $courseseed=unpack("%32C*",$courseid); my $num=$symbseed+$nameseed+$domainseed+$courseseed+$namechck+$symbchck; #uncommenting these lines can break things! #&Apache::lonxml::debug("$symbseed:$nameseed;$domainseed|$courseseed;$namechck:$symbchck");