Forums

Search results: 163

There is a minor mistake in that code.  It will work as is, but there really shouldn't be a "g" flag on that regular expression.

So change:

$fig[$j] = image(insertGraph($graph[$j]),width => 240,height => 180,tex_size => 200) =~ s/~~.png"/.png?timestamp=$timestamp"/gr;

to

$fig[$j] = image(insertGraph($graph[$j]),width => 240,height => 180,tex_size => 200) =~ s/~~.png"/.png?timestamp=$timestamp"/r;

Here is a bit of a hack that should work to do what you want without asking your students to clear the cache.

On the line before you start the for loop to generate the images add

$timestamp = time;

Then change the last line in the for loop from

$fig[$j] = image(insertGraph($graph[$j]),width => 240,height => 180,tex_size => 200);

to

$fig[$j] = image(insertGraph($graph[$j]),width => 240,height => 180,tex_size => 200) =~ s/~~.png"/.png?timestamp=$timestamp"/gr;

so you end up with:

$timestamp = time;

for my $j (0 .. 5) {
$graph[$j]->lb('reset');
$graph[$j]->lb(new Label(-.07,-1,-1,'black','right','middle'));
$graph[$j]->lb(new Label(-.07,1,1,'black','right','middle'));
for ($i = -3; $i <= 3; $i++) { if ($i != 0) {
$graph[$j]->lb(new Label(0.25*$i,-.2,0.25*$i,'black','center','top')) }};
$graph[$j]->lb(new Label(-.05,1.9,"y",'black','right','top'));
$graph[$j]->lb(new Label(0.95,0.1,"t",'black','right','bottom'));
plot_functions( $graph[$j], $g[$j]);
$fig[$j] = image(insertGraph($graph[$j]),width => 240,height => 180,tex_size => 200) =~ s/~~.png"/.png?timestamp=$timestamp"/gr;
};

The added url parameter "timestamp" makes the url different each time the problem is loaded, and so the browser will not try to load from cache. The server will ignore that parameter and still serve the same file.  Of course you have $refreshCachedImages = 1, so that file will be different than before if the "Get new version of this problem" button is clicked.
That is because in the PGcourse.pl file that you are/were using, the the two ocurences are in conditionals. The first is "if ($guest or $observe)" and the second is "if not ($guest or $observe)". $guest and $observe are set from the user permissions earlier in the file. As instructor $observe will be true for you. Since you added the line to the problem without those conditionals, it will apply to all users.

Also, since you put that line directly into the problem the "\n" will not work there.  It does in a macro file.  You will need to change that to "~~n".

interesting - I did not use the PGcourse. I commented it out and used #"PGcourse.pl",
  "problemRandomize.pl"  in the load macros for the problem.

I inserted the

ProblemRandomize( when => $when, onlyAfterDue => 0, style => "Button",label => "Clear Cache by typing ctrl/shift/delete \n before clicking this button to \n Get a new version of the problem" )

directly in the pg code

so there is only one occurrence.

It shows up for me and I"m the instructor/prof.

I mentioned that was the reason for wanting multiple lines - tell them to clear only cache and not history, etc.

I don't see another solution that can be implemented in a relatively short time. I'm coding these problems for other instructors and have limited time.

ProblemRandomize( when => $when, onlyAfterDue => 0, style => "Button",label => "Clear Cache by typing ctrl/shift/delete \n before clicking this button to \n Get a new version of the problem" )  didn't work.

You can add "\n" in the string where you want the line break.
For example, "Clear Cache typing ctrl/shift/delete before clicking\nthis button to Get a new version of the problem".

However, I should tell you that what you are doing is really bad practice.  Asking a user to clear the browser cache should only be done when there is something corrupted in the cache, or a one time occurrence to force a stale resource to be reloaded.  It shouldn't be used as a normal course of action.  If you are going to insist on this approach, then you should at least make sure to clarify to your students to only clear the browser cache and not all of the other things that can be cleared via ctrl-shift-delete like cookies, browsing history, passwords, etc.

That is very helpful. I'd still like the system to reset the seed for the problem graphs but I found a work around - I can change the text in the "get a new version" button to include instructions to tell the student to clear cache using ctrl/shift/delete

ProblemRandomize( when => $when, onlyAfterDue => 0, style => "Button",label => "Clear Cache typing ctrl/shift/delete before clicking this button to Get a new version of the problem" )
    if    not ($guest or $observe) ;

Is there a way to insert a line break to make the text multiple lines and thus a bigger button? I'd like to tell the student to clear only the cache and not the history, etc.

Is it possible for me to insert instructions in text around the button?

Thanks

The updated link to the problemRandomize.pl.html POD file is https://demo.webwork.rochester.edu/wwdocs/pg/macros/problemRandomize.pl.html.

The way that macro works is that is does not change the actual problem seed that is given to PG.  What it does is stores a new seed in a hidden input of the problem main form.  It retrieves the seed from there when problems are submitted.  Since the PGalias object is initialized (and determines unique file names for generated images using the PG problem seed and other factors) before the problemRandomize.pl macro is even loaded, the seed that the problemRandomize.pl macro is not used.

It is not that the images do not get the right name, it is that the name is not changed when problemRandomize.pl reseeds.

There certainly is not a way to force the browser to clear its cache from the page.  That would be a major security vulnerability, and browsers will not allow that.  There are ways to force the browser to not use its cache for the loading of a particular resources.  I am not certain how to make that work right off hand, but you could look into it.  This is usually done by adding an html url timestamp parameter.

Thanks - we're getting closer to speaking the same language. Your patience is appreciated.

I used the suggestion you made when coding several other problems in the same problem set, which was illustrating scaling and shifting of functions. Generate a collection of graphs and randomly choose a subset of them.

I really don't want recode this problem with that form with 30+ graphs. Neither do I want to get into the gory details of the code for ProblemRandomize. I have the description, but I don't know what actually happens when a student hits the "get a new version" button. I tried to find the details and found this link

https://webwork.math.ucdavis.edu/wiki/doku.php?id=how_to_allow_students_to_generate_new_versions_of_problems

which refers to another link

http://webwork.maa.org/pod/pg_TRUNK/macros/problemRandomize.pl.html contains extensive documentation on these options and how to change them.

but when I clicked on this link I got a 404 error. I found one more

http://webwork.maa.org/doc/cvs/pg_CURRENT/macros/problemRandomize.pl.html

but got the same result.

I'd like to have an idea of what happens. Does the problem restart execution with a new seed, or start from the middle, or restart with some modifications?

The problem I've coded works like I want EXCEPT for showing the new graphics. It generates the graphics but doesn't show them. From what you say, they don't get the right name.  Is there anything I can read on this that I might understand?

I can get the graphics to show by forcing the clearing of cache manually with ctrl/shift/delete. Is there anyway to execute this command from the *.pl file?

Thanks