LinkingProblems

From WeBWorK_wiki
Jump to navigation Jump to search
This article has been retained as a historical document. It is not up-to-date and the formatting may be lacking. Use the information herein with caution.

The technique in this problem is no longer supported.

Linking Successive Problems

This is the PG code to result in a problem having a predictable set of variable values, so that one can link successive problems in a set "knowing" what the previous problem included.

Problem Techniques Index

PG problem file Explanation
SRAND($psvn);
$a = random(1,3,1);
$b = random(1,3,1);

Setup: To make the random values that show up in a problem be consistent between problems, two things need to happen: we need to set the random seed for the problems so that they are the same, and we need the sequence of calls to the random number generator to be the same in each of the problems.

We can do the first of these by calling SRAND; a value that is consistent for all problems in a set is the value of the psvn (Problem Set Version Number). Here we've set the seed for the random number generator to be the PSVN.

Then we just include all of the random calls that have been used in the preceding problems that have the same seed in the same order. Here we have the variables $a and $b.

BEGIN_TEXT
In the previous problem you found
the value of \($a^2\).  Now find
$BR
\( $a^2 - $b = \) \{ ans_rule(5) \}

END_TEXT

Main Text: In the text section of the problem we proceed as expected.

ANS( Compute("$a*$a - $b")->cmp() ); 

ENDDOCUMENT();

Answer evaluation: And the answer and solution section of the file is straightforward.

Problem Techniques Index