WeBWorK Main Forum

Creating a local copy of a problem that uses an image

Creating a local copy of a problem that uses an image

by Louis Zulli -
Number of replies: 8
Suppose an instructor wishes to modify a NPL problem that references an external file, say a .png. If she creates a local copy of the .pg file, what is the correct way to ensure that the new copy has an image file it can reference?
In reply to Louis Zulli

Re: Creating a local copy of a problem that uses an image

by Jason Aubrey -
Louis,

I think it is currently necessary to copy the image into the local directory in which you are saving the .pg file.

To obtain a copy of the image, you can simply view the original problem and right- (or command)-click on it, then "Save image as", save a copy to your desktop and then upload it to the file manager in the same dir as the pg file.

Maybe there is an easier way I don't know about, but this is one way.

Hope this helps,
Jason
In reply to Louis Zulli

Re: Creating a local copy of a problem that uses an image

by Arnold Pizer -
Take a look at the example
NationalProblemLibrary/Rochester/setSampleGraphs/c0s1p8/
The directory c0s1p8 contains the pg file c0s1p8.pg and all the images the problem uses.  Note the name of the directory is the same as the name of the problem without the .pg extension.  If you copy this directory to your course's /templates/local/ directory, you will see the problem in the Library Browser when you select "Local Problems" and then select local in the drop down list.  

Keeping the pg problem and all the associated images in a separate directory such as c0s1p8 is a good way to keep all the components of the problem together.
In reply to Arnold Pizer

Re: Creating a local copy of a problem that uses an image

by Louis Zulli -
But how would an instructor who does not have access to /opt/webwork/libraries/NationalProblemLibrary/Rochester/setSampleGraphs copy (or link to) that directory?

Since I have access to our WeBWorK server, I can easily copy (or link to) files. But what about a colleague who doesn't have such access? Jason's suggestion seems like the only option in that case.
In reply to Louis Zulli

Re: Creating a local copy of a problem that uses an image

by Jason Aubrey -
Louis,

That's currently the only option from within webwork, but I think Mike is working on improving that, so that exported or saved problems/sets come with their external resources.

Another option is to find the directory in the web interface to our version control system:

http://webwork.maa.org/viewvc/npl/trunk/NationalProblemLibrary/Rochester/setSampleGraphs/

You can download files there by clicking on the file name, then selecting the first (top) "download" link.

Of course, if your colleague can use svn, he or she can check out the directory (or the whole NPL) with svn directly to his local computer.

Hope this helps,
Jason
In reply to Louis Zulli

Re: Creating a local copy of a problem that uses an image

by Arnold Pizer -
Hi Louis,

This is easy.  Select the problem in NationalProblemLibrary/Rochester/setSampleGraphs and add it to your set using the library browser.  Then view the problem in your assignment and click edit this problem.  Then save a local copy. This will save the directory and all associated files in a separate directory.  And then if you want to send this to friends, you can do this with the file manager.

Arnie
In reply to Arnold Pizer

Re: Creating a local copy of a problem that uses an image

by Louis Zulli -
Thanks, Arnie.

So, if I understand correctly, it all comes down to how the .pg and associated files are "bundled" within the NPL. If they are bundled as in your example, then an instructor can edit a problem and save a local copy, and all associated files are carried along.
In reply to Louis Zulli

Re: Creating a local copy of a problem that uses an image

by Arnold Pizer -
Correct.  

Unfortunately not all authors know about or choose to use this convention so you will certainly fine examples where the .pg file and its associated graphic image files are not in a separate directory, but in a directory with a lot of other .pg files and graphic image files.  That makes it more difficult to keep everything associated with a single problem together.

Arnie
In reply to Arnold Pizer

Re: Creating a local copy of a problem that uses an image

by Louis Zulli -
Perhaps someone should bring this issue to the attention of the W.H. Freeman coding team. It was a quadric surfaces problem from the recently released Rogawski collection that prompted my original post.