6.25 Tutorial: Maple-based Algorithmic Question Authoring - Maple T.A. 2016 Help
Maple T.A. Online Help

Select your version: Maple T.A. 2017 | Maple T.A. 2016 | Maple T.A. 10

6.25 Tutorial: Maple-based Algorithmic Question Authoring

Algorithmically generated variables are used to generate random numbers in questions and create multiple permutations of questions from a single template.

You can use either Maple T.A. or Maple to generate algorithmic variables. You can use either (or both) types of variables in any question type.

The syntax for a Maple-based variable definition is:


Using a Text or HTML Editor

To define an algorithmic variable in the plain-text script file, specify variable definitions (or other variable control sequences) in the algorithm field.


Using the Question Editor

In the Question Editor, define variables by directly entering Maple-based variable definitions on the algorithm screen or using the Algorithm Designer.

Tutorial 1

The following tutorial shows how to convert a static Maple Formula question to an algorithmically generated question by using variables assigned values by Maple commands.

Maple-graded Question

Consider the following plain-text script question definition, which asks a student to enter an anti-derivative of x^3.

qu.1.1.question=Enter an anti-derivative of x^3.@
qu.1.1.name=Maple AntiDerivative@
qu.1.1.comment=Any function of the form x^4/4 + C, where C is a constant, is an anti-derivative of x^3.@


  1. This question uses Maple to verify that the derivative of the student response is equal to x^3. This is recommended in place of comparing the student response, which can have an additive constant, with the integral of x^3, that is evalb($RESPONSE=int(x^3,x)).
  1. If the student enters an incorrect response, the system display the value in the comment field. In Maple-graded questions, if there is no comment field, the system returns the message Comment: No feedback is provided with this question.

To change this question to an algorithmic question, use the following plain-text script question definition.

qu.1.2.question=Enter an anti-derivative of x^$exponent + ${coeff}x.@
qu.1.2.name=Maple AntiDerivative@
qu.1.2.comment=Any function of the form $answer + C, where C is a constant, is an anti-derivative of x^$exponent + ${coeff}x.@


  1. You must follow the variable naming conventions.
  1. For a list of the guidelines for Maple commands in Maple-based variables, see The Algorithm Designer.
  1. The variable $exponent is assigned a value calculated by Maple using the rand function. rand() returns a random 12-digit positive integer rand(a)() returns a random integer in the range 0 ... a-1 (inclusive) rand(a..b)() returns a random integer in the range a ... b (inclusive) For information on other Maple commands, see your Maple documentation.
  1. The Maple command: randomize(): is included so that a different value is generated for each question instantiation. You must include the randomize(): command in every Maple-based variable definition. That is, it is required in the definition of $exponent and $coeff.
  1. The Maple command: int(x^$exponent,x) calculates the correct answer, which is displayed using the comment statement if the student response is incorrect.
  1. The examples in Tutorial 1 can be converted to Maple Syntax questions by changing the type field value from formula to maple, and changing allow2d to 0 for text-entry mode. For Maple Syntax questions, it is recommended that you attempt to prevent a student from calculating the correct answer using Maple commands. For more information, see Using Maple Code to Prevent Cheating in Maple Syntax Questions.

For an example plain-text script that defines a Maple question with Maple plotting of the student response, see Plotting a Student Response.

Tutorial 2

You can also use Maple-based algorithmic variables in other question types.

Formula Question

The following plain-text script defines a Formula question that uses Maple-based variables.

qu.1.3.question=What is the sum of $a and $b?@
qu.1.3.name=Maple-based Variables in Formula@


  1. This question uses both Maple-based (for $a) and Maple T.A. random variables (for $b).
  1. When referencing negative, random variables in a maple variable definition, be sure to place the negative variable in parentheses, otherwise an error message will return. $c=maple("$a + ($b)");

See Also:

Maple-graded Question Type - Overview

Maple Plots