WeBWorK Problems

Problem Numbers keep changing

Re: Problem Numbers keep changing

by Glenn Rice -
Number of replies: 0

The code is only run once to generate the problem on a given request.  However, each time the problem is requested the code is run again to generate the problem.  Images are cached for a given user and seed (since they don't change), but the result of the code is different with each request (depending on if answers were submitted, a preview is requested, etc).  The seed for the problem is cached, and from that the problem is generated.  The numbers don't change if the seed doesn't change.  That is how pseudo random number generators work.

The issue is that the order of the keys in a hash don't depend on the seed, but rather on how perl creates hashes, and the order of the keys in the hash will be different each time.  It is designed to be random access memory for efficiency reasons.