Skip to main content
Chemistry LibreTexts

5.11: Adding WeBWorK Problems to LibreTexts

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

    Adding WeBWorK problems to check for student understanding at appropriate places in your LibreTexts can keep students engaged and help them work out the details of definitions, concepts, and theorems.

    Although Adapt can allow you to incorporate graded "summative" problems (WeBWorK, H5P, MyOpenMath, etc.) into your LibreTexts, this tutorial will focus on various ways to insert WeBWorK problems into LibreText pages for formative feedback, i.e., to help students check and refine their understanding.


    Browsing Available WeBWorK Problems

    Two methods to browse available WeBWorK problems are:

    1. Use the Library Browser in any WeBWorK course on a WeBWorK server
    2. Use the LibreTexts Query Library to locate WeBWorK problems

    Library Browser: Once logged into a WeBWorK course with appropriate permissions, you can use the Library Browser link to search the contents of this library for appropriate problems to insert in your LibreTexts.  Here you will need the OPL address to insert a WeBWorK problem into a LibreTexts page.  We'll discuss this more below.

    If you do not have access to a WeBWorK server, it is possible that you could use the LibreTexts WeBWorK server to explore the OPL in this way.  If you are interested in this possibility, please request access.

    You may find this page about the WeBWorK OPL (Open Problem Library) helpful: 

    Browsing Query:  First, you will need to access the LibreTexts Query WeBWorK library page.  Then you can use the topical folder names to dig through the contents of the OPL (Open Problem Library) that are housed in Query.  Note that what you'll need to insert a WeBWorK problem from Query is its page ID.  We'll discuss this more below.  Also note that you do NOT need to be logged in to Query to browse problems.

    One other thing to consider is that browsing Query may allow you to find other types of problems as well (not just WeBWorK).  And these can be inserted into LibreTexts pages using the same method as we show for a WeBWorK problem below.


    Inserting Formative WeBWorK Problems into a LibreTexts Page

    Even when used formatively, there are currently three methods to insert WeBWorK problems into your LibreTexts pages.  Each method has its advantages and the method you choose may depend to some degree on how much experience you have with WeBWorK.

    Inserting a WeBWorK Problem Using its OPL (Open Problem Library) Address

    This method is great for those who have access to WeBWorK and either know which problems they wish to use from their own assignments or can use the Library Browser in WeBWorK to locate appropriate problems and obtain their OPL address.

    Say we found a problem in the OPL with the following address that we want to insert.


    Select Elements > Templates > Template:QueryWebWork

    WeBWorK Template.png Figure \(\PageIndex{1}\): Selecting the WeBWorK template to use with an OPL address.

    Once the template is added to the page, all you have to do is change the address of the problem to the one you located in the previous step.  Note that you will need to click on the + sign on the DekiScript object to open the attributes for the template.  See Figures \(\PageIndex{2}\) and \(\PageIndex{3}\) below.

    WeBWorKtemplate-closed.png Figure \(\PageIndex{2}\): New QueryWeBWorK template  WeBWorKtemplate-open.png Figure \(\PageIndex{3}\): QueryWeBWorK template opened

    Replacing the default OPL address in the code with the OPL WeBWorK problem address we found above gives us:

    WeBWorKtemplate-updated.png Figure \(\PageIndex{4}\): QueryWeBWorK template with new OPL problem address

    Once the page is saved, this will render the problem as:

    Query \(\PageIndex{1}\)

    Note that this problem is labeled as a Query even though it did not come from the Query database.  This is intentional, as these types of interactive questions are being called Queries in LibreTexts.


    Inserting a WeBWorK Problem Using its Query ID

    This method may be easier for anyone who is not as familiar with WeBWorK and/or who does not have access to a WeBWorK course and the OPL Library Browser.  It uses the page ID for the corresponding problem in the LibreTexts Query problem database.

    As mentioned above, another advantage of this approach is that it can be used to insert problems of any type that you find in the Query problem database.  Just find the page ID and insert it in the template as we show below and the problem will render in your LibreTexts page.

    Now from the Query database, let's say we found the following problem:

    WWdiffeqProblemInQuery.png Figure \(\PageIndex{5}\): WeBWorK problem in Query

    Note the Page ID: 21088 just below the problem title.  We will need this number to identify this problem in the template.

    Now select Elements > Templates > Template:BoxQuery

    BoxQuery Template.png Figure \(\PageIndex{6}\): Selecting the BoxQuery template to use with a Page ID.

    Once the template is added to the page, all you have to do is change the Page ID of the problem to the one you located in the previous step.  Note that you will need to click on the + sign on the DekiScript object to open the attributes for the template.  See Figures \(\PageIndex{7}\) and \(\PageIndex{8}\) below.

    WeBWorKtemplate-closed.png Figure \(\PageIndex{7}\): New BoxQuery template  WeBWorKtemplate-open.png Figure \(\PageIndex{8}\): BoxQuery template opened

    Replacing the default Page ID in the code with the Page ID for the WeBWorK problem we found in the Query database (21088) above gives us:

    WeBWorKtemplate-updated.png Figure \(\PageIndex{9}\): BoxQuery template with new Page ID

    Once the page is saved, this will render the problem as:

    Query \(\PageIndex{2}\)

    Note that we can update the PageIndex appropriately as we insert new Query problems.


    Inserting a WeBWorK Problem from Your own WeBWorK Server

    This method is ideal for inserting your own created or customized problems in a LibreTexts page.  It is currently still the least polished in its presentation, although this should soon be standardized to look like the other two methods above, using a new Template.  This page will be updated once this is accomplished.

    At this point, there is not a template for this method.  We will be editing the HTML version of the page directly.

    While editing the LibreTexts page that you wish to add a WeBWorK problem to, click the </> HTML button in the upper-right corner.  This button toggles the editing mode between WYSIWYG and HTML.  We can accomplish most editing tasks in LibreTexts without worrying about the HTML, but for this WeBWorK problem option, we need it.

    You can copy-and-paste the following code to modify it appropriately to create your linked WeBWorK problem.  The base WeBWorK server URL has been formatted to show it is code, but the rest of it should copy-and-paste correctly.

    <div><iframe frameborder="1" height="250" src="
    &amp;outputformat=sticky" width="100%"></iframe></div>

    This code will generate the following WeBWorK problem, served up from an external WeBWorK server.  Although it is not really a custom problem, it could be.

    Note that you can specify your desired WeBWorK server and the path to the problem inside the course you set up for serving these problems.  The courseID is the course name, and you need to create a user named “daemon” with password “daemon” and permission set to “login_proctor” in that course.  Alternatively, you could use "anonymous" instead of "daemon".  Just be consistent.

    The path can be a Library problem too, although we recommend you use the QueryWebWork template described above unless you wish to use custom problems.

    You can use the Library Browser in the WeBWorK course you use to locate any problem available there, even in your local customized problem sets.


    Putting these WeBWorK Problems in a Query Box

    If you wish it to look more like the other problems, we can use the BoxQuery template for that, although there may soon be a custom template for this feature as well with appropriate parameters.

    Query \(\PageIndex{3}\)

    To get the problem inside of a Query Box, I added the BoxQuery template, then switched to HTML mode and replaced the code:

    <p class="mt-script-comment">Embed QUERY Assessment</p></br>
    <pre class="script"></br>


    with the HTML code for the desired WeBWorK problem.

    This page titled 5.11: Adding WeBWorK Problems to LibreTexts is shared under a CC BY 1.3 license and was authored, remixed, and/or curated by Delmar Larsen.

    • Was this article helpful?