WeBWorK Problems

Where to put Custom Problems

Where to put Custom Problems

by Paul Hermans -
Number of replies: 3
I need to develop a few problems (not sure how many yet) that will get used by more than one course. We are hosting WW on our own server, and I know that I can create problems in a specific course.

Is there a way to make a "local Library" of problems that can easily be searched etc?

Thanks in advance
In reply to Paul Hermans

Re: Where to put Custom Problems

by Alex Jordan -
Hi Paul,

Here is what I have done. On the server, in
/opt/webwork/libraries/

I have added a folder called PCC. It has several subfolders, including BasicMath and BasicAlgebra. Within these folders we have lots of problems organized in more subfolders which were originally written in a course just as you are used to.

Then, inside /opt/webwork/webwork2/conf/localOverrides.conf, there is a hash:

$courseFiles{problibs} = {
Library => "OPL Directory",
...
}



I've added things like:
BasicMath => "Basic Math",
BasicAlgebra => "Basic Algebra",


This has the effect of making buttons appear in the Library Browser named "Basic Math" and "Basic Algebra". The buttons are referencing folders in a course's templates folder that would be named BasicMath or BasicAlgebra. But there is still one thing to do, because no such folders exist in a course's templates folder.

So the last thing is to make it so that each course has a symlink called, say, BasicMath, which links to /opt/webwork/libraries/PCC/BasicMath. In a course's templates folder, to create such a link, run something like:

ln -s /opt/webwork/libraries/PCC/BasicMath BasicMath

To do this in all of your courses:

for each in /opt/webwork/courses/*/templates
do ( cd $each; ln -s /opt/webwork/libraries/PCC/BasicMath BasicMath )
done


And also for any courses in the courses.dist folder that come with the distribution, which you might clone to make other courses:

for each in /opt/webwork/webwork2/courses.dist/*/templates
do ( cd $each; ln -s /opt/webwork/libraries/PCC/BasicMath BasicMath )
done



Once all this is done, your faculty can view problems from whatever library you have set up. From their perspective it will just be more buttons alongside the OPL button. (However your library will not be curated and searchable in the same way the OPL is.)



In reply to Alex Jordan

Re: Where to put Custom Problems

by Paul Hermans -
Wow, a little overwhelmed.....but I think it makes sense.
Part of my trouble is that I can not find an explanation about what structure exists on the server and what / how all the folders are used.

I don't really understand what the opt directory contains, or what the difference between the webwork and webwork2 folders are.

Is the opt/webwork folder a folder you created or does that already exist on the server? If already existing, what is its stated purpose? I understand how to create the additional folders underneath this.

Glad you knew about that localOverrides.conf file....and adding the libraries makes sense the way you explained it but how you know that is beyond me based on what documentation I've found so far.

Where I get a little lost is on creating a "symlink"...I am still pretty new to unix but it seems like it is a "pointer" to another location/file. so I interpret the ln -s... line as creating a symlink that points to the BasicMath directory and is called BasicMath. But where is this link being created? I assume in the current folder. If that is right then it makes sense that I do this in each course's template directory as you suggested with the loops.

Are the loops you specified done on a command line or somewhere else? I didn't know I could enter 3 lines like that and have it do something.

It appears that the loops would work for existing courses that we have created, as well as the distribution courses, but as new courses are added the symlink would need to be created manually....is this right?

Thanks.


In reply to Paul Hermans

Re: Where to put Custom Problems

by Alex Jordan -
> Wow, a little overwhelmed.....but I think it makes sense.
> Part of my trouble is that I can not find an explanation about what structure exists on the server and what / how all the folders are used.

Yes, sorry, but I'm not sure this level of customization is explained anywhere. I sort of figured it out after having to get involved with troubleshooting our server's initial installation. Nothing like getting your hands dirty like that to learn how things really work.

> I don't really understand what the opt directory contains, or what the difference between the webwork and webwork2 folders are.
> Is the opt/webwork folder a folder you created or does that already exist on the server? If already existing, what is its stated purpose? I understand how to create the additional folders underneath this.

I think `/opt` is just a standard folder on Linux-based systems. It is a place for programs like WeBWorK (which fall in a certain technical category) to be installed. When WeBWorK was installed on your server, that's when `/opt/webwork` was created. It is just a folder for holding at least four WeBWorK components that work together. One of these three is `webwork2`, the core engine for the web interface and interacting with the database. It is "2" because this is all WeBWorK version 2. Other folders in `/opt/webwork` include `pg` (the engine for processing problem code), `mathjax` (for rendering math on the web), and `libraries` (where problem libraries are stored). Right now, your `libraries` folder probably only has the OPL, which lives in a subfolder called `webwork-open-problem-library`. But the last post discussed adding a new library inside `libraries`.

> Glad you knew about that localOverrides.conf file....and adding the libraries makes sense the way you explained it but how you know that is beyond me based on what documentation I've found so far.

Yes, I sympathize. I guess most users have been content not to customize this much. The few who know what to do have found it difficult to maintain comprehensive documentation. In the meantime, I/we try to help in the forums like this.

We did try to get funding several times recently to commit someone to putting together solid documentation for WeBWorK. But no bites. Maybe we are still trying.

> Where I get a little lost is on creating a "symlink"...I am still pretty new to unix but it seems like it is a "pointer" to another location/file. so I interpret the ln -s... line as creating a symlink that points to the BasicMath directory and is called BasicMath. But where is this link being created? I assume in the current folder. If that is right then it makes sense that I do this in each course's template directory as you suggested with the loops.

Sounds like you got it. What you are creating sort of looks like a file called "BasicMath" (or whatever). Except it behaves more like a folder. You can "cd" (change directories) into it. But you aren't really stepping into a folder. You are going to the target of the symlink.

> Are the loops you specified done on a command line or somewhere else? I didn't know I could enter 3 lines like that and have it do something.

Command line. With typical commands, hitting Enter causes them to execute. But in that example, the `for each` is waiting for the `done` before anything happens. I am *not* a Linux shell script expert by any means. I just lifted this from here: http://webwork.maa.org/wiki/CVS_Access_to_Problem_Libraries#How_do_I_connect_a_problem_library_to_an_existing_WeBWorK_course.3F

> It appears that the loops would work for existing courses that we have created, as well as the distribution courses, but as new courses are added the symlink would need to be created manually....is this right?

Whenever I create a new course, there is some already-existing course whose templates folder gets copied. (I'm actually not aware of any other way to create new course, although I wouldn't be surprised if there is a way.) So the new courses get the symlinks because they were there in whatever course you are cloning. Maybe you are cloning the model course that comes with the distribution. What we have done here is to create bare bones course shells for the various classes we run, and those is what I clone to give someone a new course shell.

> Thanks.

No problem, happy to help and pay it forward.