Skip to main content

Section 35.1 Configuring a WeBWorK Course for PreTeXt

To make use of WeBWorK in your PreTeXt project, you need to use a WeBWorK server. If someone else is providing a WeBWorK server for you, like the AIM WeBWorK server at webwork-ptx.aimath.org, then we assume they have already configured a course for use with PreTeXt, and you may skip this section and move on to Section 35.3.

If you are configuring your own WeBWorK server to use with PreTeXt, we assume a mild familiarity with administrating a WeBWorK server. The version of WeBWorK needs to be 2.14 or later for use with PreTeXt. Using the admin course, create a course named anonymous. (You could name it something else, but we assume the name is anonymous in this guide.) In the course's Course Configuration menu, set all permissions to admin (or perhaps set some to the even more restrictive nobody). Except set “Allowed to login to the course” to login_proctor.

In the Classlist Editor, add a user named anonymous (again, you could use some other name), and set that user's permission level to login_proctor, the permission level one higher than student. Set that user's password to anonymous (again, you could use some other password). Note that because this is public information, anyone will be able to log into this course as this user. This is why setting the permissions earlier is very important. (Especially preventing this user from changing its own password.)

Add the following lines to the course.conf file (which lives in the parent folder of the templates/ folder.)

# Hide message about previewing hints and solutions for instructors
$pg{specialPGEnvironmentVars}{ALWAYS_SHOW_HINT_PERMISSION_LEVEL} = 100;
$pg{specialPGEnvironmentVars}{ALWAYS_SHOW_SOLUTION_PERMISSION_LEVEL} = 100;

In the templates/macros/ folder, edit PGcourse.pl (or create it if need be) and add the following lines.

#### Replace essay boxes with a message
sub essay_box {
  my $out = MODES(
    TeX => '',
    Latex2HTML => '',
    HTML => qq!<P>
      If you were logged into a WeBWorK course
      and this problem were assigned to you,
      you would be able to submit an essay answer
      that would be graded later by a human being.
    </P>!,
    PTX => '',
  );
  $out;
};

#### Suppress essay help link
sub essay_help {};

#### How many attempts until hint is available
$showHint = -1;
# May be a bug that WeBWorK requires -1 instead of 0
# for immediate access to hints

1;

Now PreTeXt will be able to communicate with this course to retrieve what is needed.