Installation

Reloading dynamic graphics after an edit

Reloading dynamic graphics after an edit

by Robin Cruz -
Number of replies: 9
Hi,
I've recently upgraded our system to the 2.5 *dev version. I've set up our system to save image files to /var/www/wwtmp. I am trying to modify a problem that uses a dynamic graph and am having a difficulty I did not have before the upgrade. I am trying to edit a problem that uses a dynamic graph. When the problem is accessed, it creates the image file of the dynamic graph in the folder as expected. When the problem is edited and saved, the graph should change when the problem is reloaded but it does not. A new image file is not created over the original one--I can see that from the time stamp on the image file. I have tried Ctrl-R, Ctrl-Shift-R, Ctrl-F5 and many permutations of trying to force a reload. Before the upgrade, I only had to hit the reload button on the browser a few times to get the new graph to show.
Thanks - rac
In reply to Robin Cruz

Re: Reloading dynamic graphics after an edit

by Dick Lane -
Is this behavior happening even if
        $refreshCachedImages = 1;
is used in the problem's code?
In reply to Dick Lane

Re: Reloading dynamic graphics after an edit

by Robin Cruz -
Thanks, Dick,
I added the refresh cache line you mentioned to the problem's code and now it is refreshing the image. It's odd that I didn't need to do this before??
--rac
In reply to Robin Cruz

Re: Reloading dynamic graphics after an edit

by Arnold Pizer -
Hi Robin,

This may be a bug.  Does your problem use insertGraph?  That's defined in PGcore.pm and contains the code 

if( not -e $filePath # does it exist?
 or ((stat "$templateDirectory"."$main::envir{fileName}")[9] > (stat $filePath)[9]) # source has changed
 or $graph->imageName =~ /Undefined_Set/ # problems from SetMaker and its ilk should always be redone
 or $refreshCachedImages

which "should" refresh the image in your case.

Arnie
In reply to Arnold Pizer

Re: Reloading dynamic graphics after an edit

by Robin Cruz -

Arnie,

Yes, it does.  Here is the code I'm using:

$graph = init_graph_no_labels($xmin,$ymin,$xmax,$ymax);
add_functions( $graph,"$f for x in $interval[$n] using color:$rc and weight:3" );
$graph->lb(new Label($xmin+2,$ymax-.5, "y = h(x)",'black','center'));

And then in-between BEGIN_TEXT and END_TEXT:

\{ image(insertGraph($graph),width=>400, height=>400, tex_size=>600) \}

Here are the macros loaded by the problem:

loadMacros(
  "PGstandard.pl",
  "PGchoicemacros.pl",
  "MathObjects.pl",
  "contextInequalitiesAllowStrings.pl",
  "answerHints.pl",
  "PGgraphmacros.pl"
);

Thanks --rac

In reply to Robin Cruz

Re: Reloading dynamic graphics after an edit

by Arnold Pizer -
Hi Robin,

This is strange.  Looking at the code, setting $refreshCachedImages = 1; in the problem code or just editing the problem (which changes its creation date) should both force the images to be recreated.  It strange that setting $refreshCachedImages = 1; in the problem code worked but just editing the problem didn't.

Could it be possible that this is a caching issue?  If you have time, could you try this by viewing the problem in one browser, editing the problem and then viewing it an another (or some other procedure to be sure that your browser it not caching the old image).

Arnie
In reply to Arnold Pizer

Re: Reloading dynamic graphics after an edit

by Jason Aubrey -
Hi Robin and Arnie,

We use ProblemRerandomization here a lot, and one thing we've learned is that Internet Explorer does not display regenerated graphs without forcing it with CTRL-R.  Are you using IE?  We haven't had any such problem with other browsers.  If it is IE, it also wouldn't surpise me to learn it worked in older versions of IE and not in new versions.

Jason
In reply to Jason Aubrey

Re: Reloading dynamic graphics after an edit

by Robin Cruz -

Arnie and Jason,

When I take out the refresh cache line in the problem's code and change the graph, it will not update the image--the file for the graph in the var/www/wwtmp/gif folder is not updated. I tried it in IE and Chrome. I edited the file from IE and looked at the problem in Chrome--it was the first time I'd logged into the course using Chrome.

--rac

In reply to Robin Cruz

Re: Reloading dynamic graphics after an edit

by Hedley Pinsent -
I think something like this happened to me; I ended up reassigning the problem so that the images get refreshed.

Perhaps it matters if you are editing via an assigned homework problem as opposed to editing via the library browser.

Cached images for assigned problems may need to be "flushed".

hp


In reply to Hedley Pinsent

Re: Reloading dynamic graphics after an edit

by Hedley Pinsent -

Ooops! perhaps I spoke too soon.

I am also finding a "stubborness" there (in refreshing the graphic) that I cannot explain.

I am working with the file I recently referred to in the "problems" forum.

The $refreshCachedImages = 1; does help a lot.

hp