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
You can download this HTML page, save it, and modify the contents to create your own collection
of displayed questions. You can adjust parameters of each iframe so as to display any problem in the OPL library. Here is the short script for the iframe element:
WeBWork problem in an iframe -- the contents above may not display from this blog due to changes in blog protocol. It should display however if you copy/paste this iframe snippet into an html document
<iframe height="600" src="https://demo.webwork.rochester.edu/webwork2/html2xml? &answersSubmitted=0 &sourceFilePath=Library/Rochester/setAlgebra01RealNumbers/lhp1_31-34_mo.pg &problemSeed=123567890 &displayMode=MathJax &courseID=daemon_course &userID=daemon &course_password=daemon &outputformat=simple" width="540"> </iframe>(warning -- don't put spaces around the equal sign or at the end of lines).
The question being displayed has the path Library/Rochester/setAlgebra01RealNumbers/lhp1_31-34_mo.pg . It is exactly the same as the path that is used in the library browser or which appears in the homework editor. You can adjust the display mode to either "MathJax" or "images". You can
change the problemSeed to get a different version of the problem.
The question is being rendered through the course "daemon_course" on the webwork site "https://hosted2.webwork.rochester.edu/webwork2". There is a user in the daemon_course named "daemon" who has "login_proctor" privileges (see addendum below) and whose password is "daemon". There are no "real" students in this course -- it's sole purpose is to serve stand alone questions.
The output format can be changed. The various output formats are defined on the server in the file webwork2/lib/WebworkClient.pm. The choices are "simple", "standard" which adds some additional warning message output, and "debug" which reveals all of the variables returned by the WeBWorK question renderer.
For those running WeBWorK 2.10 or later, you should be able to point the url of the iframe to a course at your webwork site and have the question rendered. The user needs to have at least TA privileges. For security's sake it is best to create a separate course with no "real" students if you plan to allow this capability to be public. The hosted2 server uses the newest "develop" branch so your output format may look slightly different since we are continuing to add small tweaks to the develop branch to improve the presentation. Once this is stable it will become part of the 2.11 release later this summer.
For a quick check of this feature you can use your own professor user login and password in any of your courses but you shouldn't make public any html that reveals your password.
It is also possible to encode the template of a PG problem with url and base64 encoding and then to insert the encoding directly into the html page. This version takes a bit more work at the moment but basic tools will be soon be available in the "develop" branch (webwork2/clients/urlbase64encode.pl ) once the pull requests have been vetted.
We are designing this feature so that examples can be placed in opensource textbooks. Specifically we will be working with Robert Beezer and his MBX system which will help to automate insertion of webwork problems in text (See http://buzzard.ups.edu/talks/beezer-2015-manitoba/beezer-2015-manitoba-mbx.html).
We expect that this embedding feature can be made useful for other purposes as well. Please share your examples and suggestions. (Signing up on the wiki http://webwork.maa.org/wiki and sharing your insights on the forum link in the left column is a good way to communicate to the WeBWorK community.