Friday, June 19, 2015

Using WeBWorK questions in Moodle quizzes -- the Moodle/WeBWorK question bridge

This is a copy of a post that I made to the Moodle forum on Quizzes.

I’m happy to announce a version of WeBWorK that can serve mathematics questions via a Moodle quiz.  This gives a tighter connection between Moodle and WeBWorK, allowing students to work exclusively with the Moodle quiz interface while WeBWorK produces the mathematics questions and processes the student answers in the background.  The result is similar to using STACK to produce and process mathematics questions.

This is a first attempt at realizing the question level WeBWorK-Moodle bridge which I proposed in this forum in my earlier post last January ( and on my blog ( )

It makes most of the 25K+ mathematics questions written for WeBWorK’s OpenProblemLibrary ( available for use in Moodle quizzes as well.  The OPL began with questions designed for single and multivariable calculus courses (and that is still the majority of the collection) but has expanded in both up and down to include questions for linear algebra and differential equations, complex variables, operations research, and statistics; as well as precalculus and developmental mathematics problems and many other math subjects.

To see this Moodle/WeBWorK connection in action,  view the Moodle course for linear algebra and differential equations at (  You will need to login as “visitor”, using the password “visitor” in order to view the quizzes. (Guests are not allowed to view Moodle quizzes.)

This is  a mockup of the matrix algebra/ODE course which I taught in 2009 using the Moodle/WeBWorK assignment connection (which presents an entire homework assignment using the WeBWorK interface).  In each week  you’ll see the original WeBWorK assignment that I used (the icon is a yellow spider web on blue background) and near it the Moodle Quiz version of the same assignment.  Try each of them to get a comparison between the WeBWorK/Moodle assignment bridge and the new WeBWorK/Moodle question bridge.

I have set the behavior of the Moodle Quiz so that it closely approximates the original WeBWorK assignment.  These assignments are meant primarily for homework/practice not for normative assessment.  The student can retry each question as often as she wishes and if there are several answer blanks then evaluation is given separately for each blank.

The Moodle portion of this bridge is built on the Opaque question type module implemented by Tim Hunt for interfacing with webservice test engines.  I am indebted to Tim for help and advice while I was implementing this Moodle/WeBWorK question interface.

Information for installing and configuring the Moodle Opaque question type is available on github at  Specifically you need the opaque qtype module: and the opaque behaviour module:

I’ll provide more detailed suggestions for creating your own Moodle/WeBWorK questions later but for those somewhat familiar with both WeBWorK and Moodle here is the short explanation.
1. You create a new Opaque engine pointing to the url: and set the question bank URL for the engine to .
2. For each question the questionID should be the same as the path of a WeBWorK problem in the OpenProblemLibrary with the following replacements.
The initial segment should be “library” instead of “Library”, each slash is replaced by two underscores, and each hyphen is replaced by three underscores. (This is required in order to conform to the Opaque client naming scheme.)
For example:
is obtained using the questionID:

For those who are really impatient the WeBWorK server function is provided by adding the project opaque_server along side a standard WeBWorK course. The Opaque Server can be found at ( along with minimal documentation for installing.  

This is the first version of the Moodle/WeBWorK question bridge so the behavior may change slightly in the future.  Because STACK and WeBWorK are already very similar I would be interested in creating a question type that was interchangeable between the two background mathematics engines.  Instructors would be able to mix STACK and WeBWorK questions in the same quiz in such a way that it was invisible (or nearly invisible) to students which engine was handling the question.

Your comments are welcome.

-- Mike Gage, University of Rochester, Rochester, NY

Tuesday, June 16, 2015

Embedding single WeBWorK problems in HTML pages

Whether writing a full text book or just an explanation and worksheet for a class it is often useful to include an active (even better an interactive example) within the text itself. You can always use a link to refer to a WeBWorK homework set but that doesn’t have the immediacy of a problem embedded in the page itself.  

Now you can use WeBWorK to do that -- there is a new mechanism that allows you to export the content of an individual problem without all of the buttons and navigation items that usually appear for a standard homework set. Here is an example.

Problem 1 -- interval notation

In many websites this problem is interactive, try it.   After the jump I have attached a link to an HTML page with many more examples which you can try out. You can also download the page and modify it to display other questions.  On the HTML page I have wrapped each example with a "knowl" slide down javaScript that allows you to slide open or to close each example question individually.

Monday, January 19, 2015

Connecting WeBWorK to Moodle 2.x's question type for use in Moodle quizzes.

This note was posted on moodle's quiz forum on January 7, 2015.

I am working on plugging WeBWorK in as a back end for analyzing mathematics questions in a way similar to STACK. I will be using the opaque question type as a starting place. 

I am just beginning this project and I expect to have questions for this forum as I proceed so I thought it a good idea to introduce myself.

I am Mike Gage, a math professor at the University of Rochester, (Rochester, NY, USA) and one of the originators of the open source online homework system WeBWorK. It was originally designed to deal with mathematics at the calculus level but it now has questions from middle school through ordinary differential equations, linear algebra and complex analysis.

It already interoperates with Moodle as an assignment module -- there is single sign-on between Moodle and WeBWorK and after the student finishes their WeBWorK homework assignment the grades are returned to the google grade book. My goal is to make WeBWorK work as a question type for Moodle2.x. We already have a question type version for Moodle1.9 

For those interested here is an example of a course using WeBWorK for assignments (search for the spiderweb icon and click on it).

For those interested in an example of WeBWorK being used to create question types in Moodle 1.9 (Created by Matt Leventi in 2007) 
(you can log in using the guest button). This version could use improvement but I don't plan to work on this further unless there is a large demand -- it seems better to put the effort into a Moodle2.x version. 

Finally for those interested in WeBWorK in its native form you can look at this link: (you can login using the guest button)

The home wiki for WeBWorK is

Thank you in advance for considering the questions I will have as I start on adapting
the opaque question type to WeBWorK. smile

Take care,