WeBWorK Problems

rerandomization and dynamically generated graphs

rerandomization and dynamically generated graphs

by D. Brian Walton -
Number of replies: 3
Is there a problem with using problemRandomize.pl and dynamically generated graphs? I seem to have an image cache problem.

The first time I open a problem (after saving the .pg file), the graph for my quadratic with random coefficients is correct. After answering the question and then asking for a new random example of the problem, the formula updates but the graph is the same as the original problem.

If there is a cache mechanism so that the graphs are not generated each time the problem is opened, is there a way to flush the cache for a particular problem?

Thanks,

D. Brian Walton
James Madison University


In reply to D. Brian Walton

Re: rerandomization and dynamically generated graphs

by Darwyn Cook -

Brian,
   Sorry for the late reply, didn't see your question until just now. The work around that I know of involves changing the name of the graph each time it its created. I wrote an epsilon-delta problem that requires students to guess the value of delta from a graph with a given value of epsilon. To do the problem they have to change the dimensions on the axes, which generates a new graph. I appended a time code to the end of the graph file name so that there isn't any caching issues:

$in=time();
$gr->gifName($gr->gifName()."$in");

Hope that helps.

In reply to D. Brian Walton

Re: rerandomization and dynamically generated graphs

by Alexander Basyrov -
Brian,

There seems to be an issue with reseeding the problems with dynamically generated graphs. I've just run into the issue with some of my classes.

It looks like the name of the file name of the graph image is generated by the line
my $imageName = "$studentLogin-$main::problemSeed-set${setName}prob${main::probNum}";
in the init_graph(...) from the PGgraphmacros.pl

The $main::problemSeed seems to refer to the initial problem seed, not the re-randomized problem seed. If there is a way to change that, the problem we have should go away.

It looks like there is a way to prohibit the use of cached images by setting the
$refreshCachedImages=1;
since the insertGraph(...) checks that variable. The issue with this ``solution'' is that the problem would not use the image cache at all.
In reply to Alexander Basyrov

Re: rerandomization and dynamically generated graphs

by Davide Cervone -
You are correct, the issue is that problemRandomize.pl wasn't setting the $main::problemSeed when it changed the seed (it just changed it in the problems random generator), and so the new seed wasn't propagating to image names, as you point out.

I've fixed the problemRandomize.pl file so if you get the current HEAD version, it should clear up the image problem.

Davide