## WeBWorK Problems

### Nonrandom and random values for seed in same problem?

by Nathan Wodarz -
Number of replies: 0
For an assignment in a linear algebra unit, I've done the following: Give students 10 problems, 5 of which have unique answers, 3 of which have infinitely many answers, and 2 of which have no answers. For reasons dealing with the student population of the class, I've set these up as 10 separate problems. I don't want all students to have the same results: i.e., I don't want the answer to #7 to be "none" for every student.

I've use the following code:

# Give student same seed for every problem (code from forum)
$seed = 0; map {$seed += ord($_)} split(//,$studentID);
SRAND($seed); @rr = (0,0,0,0,0,1,1,2,2,2); # 0 represents unique answer # 1 represents no answer # 2 represents dependent system # Shuffle @rr # I know there are more efficient methods here... for$i (0..9) {
$j = random(0,9);$tmp = $rr[$i];
$rr[$i] = $rr[$j];
$rr[$j] = $tmp; } # Choose problem type$r = $rr[$prob]; # $prob runs between 0 and 9, assigned earlier$seed += 1421177; # Converted chapter/section/prob. num to octal
SRAND(\$seed);

This certainly works. I would, however, like to make things a little nicer, and give them a random seed at the end, rather than one based on their ID and the problem number. Is there a good way to do this?

Nathan