Skip to main content

The PreTeXt Guide

Section 38.2 Configuring a webwork2 Server for PreTeXt

Note that the default webwork2 server for PreTeXt is webwork-ptx.aimath.org, and this server is already configured. If you are configuring your own WeBWorK server, read on.
We assume a mild familiarity with administrating a WeBWorK server. The version of WeBWorK needs to be 2.16 or later for use with PreTeXt.
The only thing you need to do at the serverlevel is set the web server to use certain headers on content that is fetched. These headers tell a web browser that you are authorizing it to display content from this web server as embedded content inside pages from another web server (in particular, where you are hosting you PreTeXt book).

WeBWorK 2.16 or 2.17.

In webwork2/conf/ there should be the apache configuration file webwork-apache2.4-config. This file needs to include the lines:
<IfModule mod_headers.c>
    <Location /webwork2/html2xml>
        Header set Access-Control-Allow-Origin "*"
    </Location>
    <Location /webwork2_files>
        Header set Access-Control-Allow-Origin "*"
    </Location>
</IfModule>
Note there is the distribution file webwork-apache2.4-config.dist, which has these lines (or similar lines) commented out.
You may also need to enable headers by executing something like sudo a2enmod headers from the command line.

WeBWorK 2.18.

Edit webwork2/conf/webwork2.mojolicious.yml and uncomment these lines:
extra_headers:
#  /webwork2/render_rpc:
#    Access-Control-Allow-Origin: '*'
   /webwork2/html2xml:
     Access-Control-Allow-Origin: '*'
   /webwork2_files:
     Access-Control-Allow-Origin: '*'
   /pg_files:
     Access-Control-Allow-Origin: '*'
Note the render_rpc lines can remain commented out, unless you have some other reason to uncomment them.
You will need to restart the webwork2 service.

WeBWorK 2.19.

Edit webwork2/conf/webwork2.mojolicious.yml and uncomment these lines:
extra_headers:
   /webwork2/render_rpc:
     Access-Control-Allow-Origin: '*'
#  /webwork2/html2xml:
#    Access-Control-Allow-Origin: '*'
   /webwork2_files:
     Access-Control-Allow-Origin: '*'
   /pg_files:
     Access-Control-Allow-Origin: '*'
Note the html2xml lines can remain commented out, unless you have some other reason to uncomment them.
Also in this same file, set allow_unsecured_rpc: 1. You will need to restart the webwork2 service.