Documentation:WeBWorK/Mechanics problem creation notes

From UBC Wiki

The OER Mechanics WeBWorK project is recording helpful notes during problem development.

Error Messages:

"The macro alias was unable to form a URL for the auxiliary file... used in this problem" -DK

Double-check the format of the file uploaded or the image that the code is trying to fetch.

If your computer saved the image as a capitalized .PNG rather than a .png, it will be uploaded to WeBWorK as .PNG.

When the code subsequently tries to fetch a .png file, it will fail to recognize .PNG as the same file even if they have the same name.

Fix this by renaming the image from .PNG to .png on WeBWorK in the File Manager. It will not work by changing the code to fetch .PNG instead of .png and leaving the image as .PNG on WeBWorK.

"Errors parsing PGML: Warning: unknown block type 'balance' in PGML::Format::html::format" -DK

Sorry pal, it looks like you used a single quotation mark ' instead of the grave accent ` somewhere in your code, most likely when you are trying to call for MathJax or Latex formatting.

Check all your square brackets and insert grave accents where needed.

Constant WeBWorK Error Page when Re-Uploading -DK

Try deleting the file and re-uploading, or simply turn on "Overwrite existing files silently". Be careful when overwriting however; make sure the file is in the right place and that only what you want is changed.

WeBWorK question uses the old image instead of new, updated one. - DY

This is due to the browser using the old cached image instead of the new image in the database. This is a localized issue and should not appear for anyone opening the question for the first time.

To fix this for yourself, there are two methods.

  1. Completely remove the image and load the question with the issue. Once loaded, upload the new image into the database. The question should use the new image now.
  2. Reset your browser's cache.

"There was an error rendering this problem!" - JL (ww version 2.16)

Some questions don't properly render when viewed from the Hmwk Sets Editor and from the Library Browser. Currently unknown what the exact cause is. It can be ignored for the most part since so many problems are affected. Possible solutions include:

  1. Make sure no older Latex commands are present (i.e., ww version 2.16 doesn't support "\:" for spacing)
  2. Going into File Manage, selecting and editing the .pg file and saving the edit (without any changes made).

Question Templates:

Here you will find relevant and easy to use question templates in PDF form with commented code for a variety of general uses.

File:GeneralQuestionTemplate.pdf

Eqn variable answers: -NW

Multiple Choice: -NW

How to upload images: - NW

General Math Formatting:

Contexts

In PGML, when doing calculations there are different 'contexts' that should be used.

Variables

Ex. $A = random(2, 5, 1);

'A' is the label of the variable, when addressing it throughout the code, it has to have a '$' in front of it in order to compute. The function random generates a number as 'random(low, high, step)'. In this case, the lowest number is 2, with the highest number being 5 with a step size of 1. This means the numbers could be 2,3,4 or 5. To set any variable '$' must be used or else the file will not compile

Ex. $ans = List($var1,$var2);

If you wish for a variable to be in a list or pair format, use the function List().

This code allows for the user to enter in two different numbers as the answer, disregarding order.

Math Rules

Ex. $answer = cos($A*pi)/2;

Computations follow similar rules to Perl. * is multiplication, / is division, + is addition, - is subtraction. Calling pi within computations and functions can be used as shown above. All computations are in radians, to use degrees within the written question, simply convert to radians before any computations.

Ex. $ans = exp(pi*$t); This gives the value e^(pi*$t)

To use the natural exponential function, you can not use it as you would pi. It must be in the function form exp(), with the value in the bracket being the exponent.

Uploading Archives (Multiple Problems) - BK

WeBWorK can only unpack .tgz or .tar.gz files. Instructions below work for the free archiving program 7zip.

  1. Select all your files that you want to upload.
  2. Right click, select 7zip > Add to archive…
  3. Pick "tar" from the Archive Format dropdown.
  4. Select the .tar file it creates, right click it and add it to archive again.
  5. This time, select gzip from the dropdown.
  6. Upload the .tar.gz file to WeBWorK, and it'll automatically unpack it.