WeBWorK Problems

passing problem variables between sets

passing problem variables between sets

by Darwyn Cook -
Number of replies: 1
I would like to write two related problems in two different sets - one set is on numerically approximating the derivative, the other set concentrates more on algebraically simplifying the difference quotient and then taking the limit.
In the first set students complete a table where they estimate the derivative at a given point for a given function, both of which are randomly generated. In the next set I would like them to simplify the difference quotient using the same point and function, and then have them notice that they could have used this simple equation to fill out their table in the previous set.
To do this I have to get the random variable information from one set to another. Looking through past posts it was hinted that this would be easier with the new database approach to storing problems, but I could not find the solution.
In reply to Darwyn Cook

Re: passing problem variables between sets

by Davide Cervone -
One way to do this would be to force both problems to use the same random number seed, but have that seed be dependent on the student it is assigned to.

Here's a way to do that. Use the following line somewhere before you create any random numbers:

    $seed = 0; map {$seed += ord($_)} split(//,$studentID); SRAND($seed);
This reseeds the problem using a number that is created from the students ID (it turns each letter in the name into its ASCII value and then adds them up). This means each student (probably) has a different seed value, but any problems that start this way will have the SAME seed for each student.

If you use this at the top of both problems, and create the random variables in the same order in each problem, then each student should have the same random numbers in both problems.

Hope that does it for you.