MyOpenMath Help

Writing Questions

The MyOpenMath question format is based on PHP.

Question Parts

A question is formed in several parts:

Note: All control code can be placed in the "Common Control" box; the Question Control and Answer sections do not have to be used.

Basic Control Syntax

Lines of the common control, question control, and answer sections usually take the form of variable definition. In MyOpenMath, variables are identified with a dollarsign ($) prefix. For example, $a is the variable a. Most lines will take one of these forms:

Variable Types

There are a few types of variables:

Note that numbers are not in quotes, and strings are in quotes. When you use the double-quote mark (") to define a string, you can interpolate variables into the string. Example:

$a = 3
$b = 5
$str = "What is $a/$b"

In this example, $str now contains "What is 3/5".

Note that strings in single quotes will not interpolate variables

As a warning, strings are interpolated literally, so if you had $a = -4 and then defined $b = "$a^2" you would end up with "-4^2", which may not be what you intended. Use explicit parentheses in these cases.

Array assignment

In some cases you want to define several variables at once. There are two ways to do this:

In the first example, variables $a and $b each take on a single value. In the second example, the variable $ar is an array; the elements can be accessed as $ar[0] and $ar[1] (note that arrays are zero-indexed). If you use this approach, enclose the variable reference in parenthesis in calculations, like $new = ($ar[0])^2, and in curly brackets inside strings, like $string = "there were {$ar[0]} people".

You can also literally define an array using the "array" function. Examples: $ar = array(2,3,4,5), or $ar = array("red","green","blue")

You can also use a shorthand notation for an array, using square brackets. Example: $ar = [2,3,4,5].

Working with Strings

If needed, you can concatenate (combine) two strings using the . operator. Example:

$a = "string one "
$b = "string two"
$both = $a . $b

Here, $both now contains the string "string one string two"

If you have a long command to type, you can put a "&" at the end of a line to specify it continues on the next line. Example:

$questions = array("this is choice 1",&
"this is choice 2")

If defining a string for display, you can put a "&&" at the end of a line to specify it continues on the next line and insert an HTML line break. Example:

$showanswer = "Do this first. &&
Then do this."

will be interpreted as:

$showanswer = "Do this first. <br/>Then do this."

Comments

You can insert comments in your code by starting the comment with two forward slashes: //this is a comment. Typically it's best to put comments on their own line, but they can also be placed after a line of code.

Conditionals

Any assignment line can be followed by one of two conditional: "where" or "if".

"where" is used to repeat the previous assignment if the condition provided is not met. The "where" condition is almost exclusively used with array randomizers. Example: to select two different numbers that are not opposites:

$a,$b = diffrands(-5,5,2) where ($a+$b!=0)

Beware that the system will give up if it's unable to meet the specified conditions after 200 tries, so be sure your where condition has fairly high probability of success, ideally at least 10%. If it doesn't, you should consider where there are other ways to generate your values. Alternatively, you can specify a fallback value to use if the condition fails using else:

$a = rand(1,100) where (gcd($a,$b)==1) else ($a = 7)

"if" is used to make an assignment conditional. For example:

$a = rand(0,1)
$b = "sin(x)" if ($a==0)
$b = "cos(x)" if ($a==1)

Note the use of double equal signs (==) for testing equality. A single equal sign (=) will make an assignment (change the value of $a in this example) and return "true", which is probably not what you intended to do.

Comparison operators available for "if" and "where" statements:

To do compound conditionals, use || for "or", and && for "and". For example:

$a = nonzerorand(-9,9) where ($a!=1 && $a!=-1)

The "if" condition can also be used before or after a code block like this:

$a = rand(0,1)
if ($a==0) {
   $b = 1
   $c = 2
}

or

$a = rand(0,1)
{
   $b = 1
   $c = 2
} if ($a==0)

When "if" is used before a block of code, it can optionally be followed with "elseif" and/or an "else" statement, like this:

$a = rand(0,5)
if ($a==0) {
   $b = 1
} elseif ($a==2) {
   $b = 3
} else {
   $b = 2
}

"where" can also be applied to a block of code:

{
  $a = rand(-5,-1)
  $b = rand(1,5)
} where ($a+$b !==0)

or with a fallback

{
  $a = rand(-5,-1)
  $b = rand(1,5)
} where ($a+$b !==0) else {
  $a = -3
  $b = 5
}

Loops

There are several looping macros (such as calconarray) that can meet most needs. For more general use there is a "for" loop:

for ($i=a..b) { action }

Here a and b represent whole numbers, variables, or simple expressions.

Examples:

$f = 0
for ($i=1..5) { $f = $f + $i }

$a = rands(1,5,5)
$b = rands(1,5,5)
for ($i=0..4) {
  $c[$i] = $a[$i]*$b[$i]
}

For associative arrays (arrays with non-numeric or non-consecutive keys) you can use a "foreach" loop:

foreach ($arr as $k=>$v) { action }

Here $arr is the associative array, and as it loops the keys will be assigned to $k and the values to $v.

Example:

$arr = ['red' => 3, 'green' => 5, 'blue' => 2]

$str = ''
for ($arr as $color=>$num) {
  $str .= "There are $num balls that are $color. "
}

Conditions can be used inside a for loop, but not outside without explicit blocking

for ($i=1..5) {$a = $a+$i if ($i>2) }     WORKS
for ($i=1..5) {$a = $a+$i} if ($a>2)     DOES NOT WORK
{for ($i=1..5) {$a = $a+$i} } if ($a>2)    WORKS

Inside a for loop, break can be used to break out of the loop, and continue can be used to move on to the next iteration without executing any further code in the block.

Randomizers

Note on macros: The descriptions below explain macros available and the arguments the functions should be called with. Arguments in [square brackets] are optional arguments, and can be omitted.

For all randomizers, all bounds (min,max) are inclusive.

Single result randomizers:

Array randomizers (return multiple results):

Graph/Table Macros

The following macros create graphs or tables:

Format Macros

The following macros help with formatting values for display:

String Macros

These macros help with working with strings:

Array Macros

These macros are for working with arrays:

General Macros

These macros are fairly general purpose:

Math Macros

These macros are used for mathematical calculations:

Conditional Test Macros

These macros are used to test various conditions. They typically return true or false, depending on whether the desired condition is met.

Feedback Macros

These macros are used to select and format feedback messages to students. They return a string which can be placed in the question text.

Using Other Macros

If an MyOpenMath administrator has installed other Macro Libraries, you can load a macro library by entering the line loadlibrary("list of library names") at the beginning of the Common Control section.

Examples: loadlibrary("stats") or loadlibrary("stats,misc")

Click on the "Macro Library Help" link in the question editor to get a list of installed macro libraries and the macros available in each library

Math Entry

MyOpenMath uses ASCIIMath for math entry. In question text or inside strings that will be displayed in the question text, wrap expressions to be rendered in the backtick/grave symbol, like `x^2`. That key is usually located on the same keyboard button as the tilde.

For calculations, a limited subset is available:

SymbolMeaning
* / + -Multiply, divide, add, subtract
^Powers. 2^3 = 8.
e, piThe standard constants
%Modulus of integers (remainder after division. 5%2 = 1)
mod(p,n)Modulus of integers. This version gives positive results for modulus of negative numbers.
fmod(p,n)Modulus of decimal values. May give negative results from negative inputs.
!Factorial
sqrtSquare root
sin,cos,tan,cot,sinh,coshStandard trig function. Be sure to enter as sin(2), not sin 2
arcsin,arccos,arctan,arcsinh,arccoshInverse trig functions.
sin^-1, cos^-1, tan^-1Alternative entry for inverse trig functions. Use like sin^-1(0.5)
lnNatural Logarithm base e
logCommon Logarithm base 10
absAbsolute Value. Note that while abs() is used for calculations, you may prefer to use | brackets for display
round(n,d)round number n to d decimal places
roundsigfig(n,s)round number n to s significant digits. This is for calculations; if you need a value for display and want to ensure trailing 0's display, use prettysigfig
floor,ceilfloor/ceiling: integer below/above given number
min,maxmin or max of the passed values. Can be used as min($a,$b,$c) or min($arrayvariable).

For display only, the full ASCIIMath language is available (which includes support for a limited subset of LaTeX). For more info, see the ASCIIMath syntax.

Solver

While writing a question, it can be handy to quickly solve a formula for a variable. For example, if you're writing a question that asks students to solve y=($a x + $b)/($b x - $a) for x, where $a and $b are randomized variables. You might need to calculate the correct answer. The Solver tool can help solve or check the solution.

Solver Input

Tips:
  • Select your code from the Common Control box, then either drag-drop or copy-paste it to the box below, or
  • Highlight an expression in Common Control and press Ctrl-M to update the Solver code, or
  • Highlight an expression in your code before clicking Solver.
  • Select an operation to perform: Solve, Differentiate, Integrate, Plot.
  • You may need to change the colored Sage code below to solve for the correct variable or to adjust the plot window etc. See the help icon below for examples.

Solver: Sage Syntax

SageMath examples:
#create symbolic variables
x,y,a,b,c,d = var('x,y,a,b,c,d')
# solve the equation for x
solve( y==(a*x+b)/(c*x-d) , x )

x = var('x')
#Differentiate
diff( 3*x^4 , x )

x = var('x')
#Plot in a standard window
plot( -x^2+4 , (x,-10,10) )

x = var('x')
#Simplify
simplify( 5*x+7*(-3*x-4) )
Tips:
  • Declare any variables using var() as above. By default, x is a variable.
  • Use two equal signs for math equations.
  • With solve() diff() integral() give the independent variable after a comma.
  • With plot() a range for the independent variable must be specified, e.g. (x, -10, 10).
  • Select a new operation or click Go to calculate.

Solver Output

Tips:
  • Drag the result above to the Common Control box where you define the $answer or any other location, or
  • Click Insert in Common Control to append the result to the end of the Common Control, or
  • Click Insert as $answer to append $answer = result to the Common Control (not available if $answer is already defined).
  • Note: Touchscreens might not be supported by the drag operation.

Common options to all types

All question types can support these options:

Hints

For a single question (not multipart), to use hints, in the common control (or question control) section define the array $hints where:

$hints[attempt number] = "hint text"

For example:

$hints[0] = "This will show on first display"
$hints[1] = "This will show on second attempt (after 1 missed attempt)"
$hints[2] = "This will show on third and subsequent attempts, since no later values have been defined"

It is fine, for example, to not define $hints[0] if you want nothing to display initially.

Then in the question text, place the location of the hint using the variable $hintloc.

In multipart questions, you can follow the process above if you just want a single strand of hints for the entire problem. If you want per-part hints, define the $hints array as:

$hints[question part number][attempt number] = "hint text"

Then in question text, place each hint using $hintloc[question part number]

To have the hint to display based on a set of previous answers, you can use:

$hints[question part number][attempt number] = array("hint text", [part num1, part num 2])

This will display the hint after all the parts listed have had the required attempts or are correct.

To override the default Hint: text, set $hintlabel.

Help references

To provide help of some sort for a question (typically, links to videos, book references, etc), define $helptext in the common control section. Any text assigned to this variable will show at the bottom of the question. The display of this text is controlled by the same "show hints?" option that controls the display of hints described above.

Referencing Student Answers

To create multipart questions that are graded on consistency, or to create a set of lab-type problems that rely on student-provided data, you can reference students' previous answers in your question code. You will only be able to reference the student answer to some question types

Notes (important!):

1) If the student has not answered the question, then $stuanswers[N] === null, with the exception of drop-down select questions, where $stuanswers[N] == "NA" if no selection is made. If used in an equation, it will take on the value 0. To prevent divide-by-zero errors and to prevent students from exploiting this, it is highly recommended that you do something like:

$a = $stuanswers[$thisq][0]
$a = rand(1,100) if ($a===null)

Perhaps also include: $warning = "You MUST answer question 1 before this question" if ($a===null), then put $warning in the question text.

2) If you use $stuanswers in your $answer, $showanswer will generally not be defined. If you follow the advice in #1 above, then your $showanswer will reflect the random number assigned to $a. For this reason, it is highly recommended that you custom define the $showanswer.

3) If using the $stuanswers array in a string or in the Question Text, you must enclose it with curly brackets: Your answer was {$stuanswers[0][0]}. If using it directly in a calculation, enclose it in parentheses just to be safe.

4) $stuanswers[$thisq] is defined for question scoring, but may not be for question display.

5) You can use the function getstuans($stuanswers,N,P) to retrieve a student answer value. This method bypasses some strange things that happen when there is a multipart question with only one part, so is recommended.

6) You can use the function stuansready($stuanswers,$thisq,[p1,p2,...]) to determine if the parts have been answered, instead of checking for null.

Other Reference Variables

A few other special purpose variables can be referenced:

Reusing Code

You can import in the Common Control code from another question using

includecodefrom(questionid)

where questionid is the ID number of the question you want to import the code of. In the source question, the variable $included will automatically be set to true when the question has been included, so it can be used to determine if the question has been imported into another question, or is running independently.

For example, in the master/source question, you might use the code:

if (!$included) {
 $type = rand(0,4)
}
do stuff here

In a question using this code, you could limit to a specific type using:

$type = 0
includecodefrom(1234)

Question text can be also brought in from another question by using

includeqtextfrom(questionid)

somewhere in the Question Text portion of the question.

Teacher Notes

In the question text, you can add a note that will only be viewable by the teacher while grading. Do this by wrapping the teacher note in the [teachernote] shortcode like this: [teachernote]This is the note[/teachernote]

Hiding/Toggling content

If you need to hide content from view, you can wrap it in <div class="hidden"></div>. Be aware the content is still in the page, so a student can still view the hidden content using the browser inspector, so don't use this to hide secret info, but it can be helpful if you need to hide an answerbox that is being populated by some other means.

If you want to toggle a block of content, one option for shorter content is to use forminlinebutton. For longer content, you can wrap the content in a block using <div data-toggler="Title for button"></div>. That will hide the wrapped content, and add a button with the specified title for toggling the content. You can optionally add a data-toggler-hide attribute as well if you want a different button label once the content is showing.

Question Types

The question types available are:

Number

The student is asked to enter a number (integer, decimal, or scientific notation). The answer is compared to a given tolerance. Can also accept DNE, oo (Infinity), and -oo (Negative Infinity) as answers.

Required Variables

$answer = a number or calculation resulting in a number, like $answer = 5
Defines the answer. Define multiple acceptable answers in a string separated by or: $answer = "3 or 5 or 7". Alternatively, you can provide an interval notation range of acceptable answers, like $answer = "(2,5]". Providing a range will override any tolerances set. If $answerformat is set for list answers, then this should provide a list of correct answers, like $answer = "1,2,3".

Optional Variables

$reltolerance = a decimal value
Defines the largest relative error that will be accepted. If this is not set, a relative error of .001 (.1%) is used by default.
$abstolerance = a number
Defines the largest absolute error that will be accepted. This will override the use of $reltolerance
$reqdecimals = a number
Defines the minimum decimal accuracy required (ie 2 for two decimal places). This will put a message in the answer tips stating the decimals required. If neither $abstolerance or $reltolerance is set, this will set the tolerance, otherwise the provided tolerance will be used (even if it doesn't agree with the $reqdecimal setting).

$reqdecimals = "=2" can be used to require exactly 2 decimal places in the answer, regardless of how the value rounds (so 3.5 would get marked wrong when the answer is 3.50 if "=2" is used). If you use the "=2" form, it will also round your $answer if needed for the $showanswer.
When the "=2" form is used, it overrides both $reltolerance and $abstolerance, and by default tests that the student answer exactly matches the correct answer ($abstolerance=0). To override the tolerance use +- in the setting, like this:
$reqdecimals = "=2+-.01" checks for exactly 2 decimals, but allows the answer to have an absolute error of .01
$reqdecimals = "=2+-1%" checks for exactly 2 decimals, but allows the answer to have an relative error of 1% (equivalent to $reltolerance = .01)
$reqsigfigs = a number
Defines the significant figure accuracy required. Use $reqsigfigs = 2 for at least 2 sig fig accuracy, or $reqsigfigs = "=2" to require exactly 2 sig figs in the answer, or $reqsigfigs = "[2,3]" to require 2 or 3 sigfigs. This will put also a message in the answer tips stating the significant figures required. If you use the "=2" form, it will also round your $answer if needed for the $showanswer.
This setting overrides both $reltolerance and $abstolerance, and by default tests that the student answer rounded to the specified sigfigs matches the correct answer. To override the tolerance use +- in the setting, like this:
$reqsigfigs = "=2+-.01" checks for exactly 2 sigfigs, but allows the answer to have an absolute error of .01
$reqsigfigs = "=2+-1%" checks for exactly 2 sigfigs, but allows the answer to have an relative error of 1% (equivalent to $reltolerance = .01)
$answerformat = "list", "exactlist", "orderedlist", "set", "integer, "units", "nosoln", or "nosolninf"
  • Answerformats can be combined, like $answerformat = "nosoln,list"
  • $answerformat = "list", "exactlist", or "orderedlist" specifies that a list of answers is expected.
  • If $answerformat="list", then duplicate values are ignored.
  • If $answerformat="exactlist", then duplicate values are not ignored.
  • If $answerformat="orderedlist", the list must be in the same order and contain identical counts of values.
  • $answerformat = "set" behaves like "list", but expects the answer list to be wrapped in curly braces as a set.
  • $answerformat = "integer" changes the entry hint to only indicate integers, and rejects answers that contain decimals (except it does allow 2.0 instead of 2)
  • $answerformat = "units" adds unit checking. Supply the answer like $answer = "3 kg/m^2". The student's answer can be in other equivalent units, so "300 cm" is considered equivalent to "3 m". The answer must be in the format [decimal number]*[unit]^[power]*[unit]^[power].../[unit]^[power]*[unit]^[power]..., though multiplication can be implied. Also, 'per' may be used for division of units, and 'unit squared', 'square unit', 'unit cubed' and 'cubic unit' may be used. Note that the units do not require mathematically-proper parens around the denominator. The decimal number can include basic scientific notation in 3E5 or 3*10^5 formats. Examples: 4 cm, and 3.5E4 feet per second squared Note that tolerances are scaled to the unit, so $answer = "3m" with $abstolerance = .1 would mean .1 meters, so "310cm" would still be within tolerance. If $reqsigfigs is set, the specified number of sigfigs will need to be present in the student's answer, regardless of units.
  • $answerformat = "nosoln" or "nosolninf" adds a list radio buttons for "no solutions" and optionally "infinite solutions". $ansprompt can override the default statements like this: $ansprompt = "One value, x=;No values;Many values"
$partialcredit = array(number,score,[number,score,...])
Allows you to specify partial credit for other answers. The array should be given in the form array(number,score,number,score,...), where number is the value to compare to the student answer, and score is a proportion between 0 and 1 to award as partial credit. Note this currently only works for single number answers; "or" and list answers are not supported.
$ansprompt = string
A string that will be displayed in front of the input box. Example: $ansprompt="y="
$displayformat = "alignright"
Aligns the text in the answer box to the right side
$answerboxsize = number
Determines the number of characters space provided for entry of an answer. Defaults to 20.
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the question input box in that location
$showanswer
The answer to show to students (if option if available). Defaults to $answer. Use this to give a detailed answer, or a rounded off answer.
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

Calculated

A student is asked to enter a number or a calculation, like 2/3, 5^2, or sin(2). Can also accept DNE, oo (Infinity), and -oo (Negative Infinity) as answers.

Required Variables

$answer = a number or calculation resulting in a number
Defines the answer. Define multiple acceptable answers in a string separated by or: $answer = "3 or 5 or 7". Alternatively, you can provide an interval notation range of acceptable answers, like $answer = "(2,5]". Providing a range will override any tolerances set

To have the answer display as a rendered expression, provide the answer as a string. For example, if you want the answer to show as 24 then you'd specify $answer = "2^4". If you specified $answer = 2^4, the answer would display as 16.

Optional Variables

$answerformat = "fraction", or one of the other options below.
Specifies answer format options. Some can be combined in a list, like this: $answerformat="nodecimal,notrig".
  • Base format types: only use at most one of these at a time
    • fraction: requires the answer to be a single fraction (like 10/6, 1/3, or 5)
    • reducedfraction: a reduced fraction (like 5/3 or 5)
    • mixednumber: a reduced mixed number (like 2 1/2 or 2_1/2, or 2/3 or 5)
    • mixednumberorimproper: a reduced mixed number or improper fraction (like 2 1/2 or 5/2)
    • sloppymixednumber: a mixed number (will take 5/2, 2 1/2, even 1 3/2)
    • scinot: scientific notation (like 2.3*10^4)
    • scinotordec: scientific notation (like 2.3*10^4) or decimal value
    • fracordec: a single fraction or decimal value. Can be combined with "allowmixed" to also allow mixed numbers.
    • decimal: requires the answer to be an integer or decimal value
  • Mix-ins: You can add these as needed to modify what's allowed
    • allowunreduced: can be combined with "mixednumber" or "mixednumberorimproper" to allow unreduced fractional parts
    • allowxtimes: allows the use of x for multiplication (like 23x10^2 for 23*10^2), typically in combo with the "scinot" format
    • allowplusminus: allow use of +- in the answer. Will enable the 'list' option if not already included.
    • nodecimal: require an answer without decimals (also disallows 10^-2 and 3E-2)
    • notrig: require an answer without trig functions (sin,cos,tan,sec,csc,cot)
    • allowmixed: will enable support for mixed numbers (like 2 1/2) in answers
    • allowdegrees: will enable the use of the degree symbol to designate degrees, so sin(30degree)=1/2.
    • noval: tells the answer preview to not compute a decimal equivalent (deprecated - this option is now enabled by default)
    • showval: tells the answer preview to display a decimal equivalent
    • sameform: requires the student's answer be in the "same form" as the correct answer. This means exactly the same, except for commutation of addition and multiplication, multiplication by 1, implicit multiplication, and extra parentheses. Use with caution.
  • List options: only use at most one of these at a time
    • list: a list of answers is expected - ignores duplicate values (1,1,2 is equivalent to 1,2)
    • exactlist: a list of answers is expected - does not ignore duplicates
    • orderedlist: a list of answers is expected - order is important, and duplicates are not ignored
  • Special options:
    • nosoln: adds radio buttons for "no solutions". Use $answer="DNE" if the answer is no solutions.
    • nosolninf: adds radio buttons for "no solutions" and "infinite solutions". Use $answer="DNE" or $answer="oo" respectively if needed.
    • To override the default "no solutions" and "infinite solutions" wording, you can define $ansprompt as a list of semicolon-delimited strings to override the default wording. For example,
      $ansprompt = "One value, x=;No values;Many values"
$formatfeedbackon = true
Turns on "right answer, wrong format" feedback on the question
$reltolerance = a decimal value
Defines the largest relative error that will be accepted. If this is not set, a relative error of .001 (.1%) is used by default.
$abstolerance = a number
Defines the largest absolute error that will be accepted. This will override the use of $reltolerance
$reqdecimals = a number
Defines the decimal accuracy required (ie 2 for two decimal places). This will put a message in the answer tips stating the decimals required. If neither $abstolerance or $reltolerance is set, this will set the tolerance, otherwise the provided tolerance will be used (even if it doesn't agree with the $reqdecimal setting).
$reqsigfigs = a number
Defines the significant figure accuracy required. Only valid for "decimal", "scinot", and "scinotordec" $answerformat options. Use $reqsigfigs = 2 for at least 2 sig fig accuracy, or $reqsigfigs = "=2" to require exactly 2 sig figs in the answer, or $reqsigfigs = "[2,3]" to require 2 or 3 sigfigs. This will put also a message in the answer tips stating the significant figures required. If you use the "=2" form, it will also round your $answer if needed for the $showanswer.
This setting overrides both $reltolerance and $abstolerance, and by default tests that the student answer rounded to the specified sigfigs matches the correct answer. To override the tolerance use +- in the setting, like this:
$reqsigfigs = "=2+-.01" checks for exactly 2 sigfigs, but allows the answer to have an absolute error of .01
$reqsigfigs = "=2+-1%" checks for exactly 2 sigfigs, but allows the answer to have an relative error of 1% (equivalent to $reltolerance = .01)
$requiretimes = a list, like "^,=3,cos,<2"
Adds format checking to the student's answer. The list can include multiple checks, which come in pairs. The first is the symbol to look for. The second describes what is acceptable. For example, in the string shown above, the symbol "^" would be required to show up exactly 3 times, and "cos" would be required to show up less than 2 times.
Be aware that if you search for "5,=1", it will match both 5 and 15 and 2.5, since all three strings contain a 5. When searching for numbers, you can avoid this by putting a "#" before the number, like "#5,=1", which would match the 5 but not 15 or 0.5. Beware this type of search ignores signs.
You can use just "#" in the symbol location to match any number (including decimal values); 3.2^5 would match twice.
You can match either of two symbols by putting || between them, like ".5||1/2,>0"
You can use a regular expression by putting in the symbol location "regex:expression"
You can put "ignore_commas,true" at the beginning of the $requiretimes to ignore commas in the answer
You can put "ignore_spaces,true" at the beginning of the $requiretimes to ignore spaces in the answer
You can put "ignore_symbol,$" (or some symbol other than $) at the beginning of the $requiretimes to ignore that symbol in the answer
$requiretimeslistpart = a list, in the same format as $requiretimes
Similar to $requiretimes, but this check is applied to each element of the answer list when a list $answerformat is used, where $requiretimes would be applied to the entire list of answers. To apply different $requiretimes to each element of the $answer list, separate them with semicolons, like "pi,=1;/,=1;;"
$ansprompt = string
A string that will be displayed in front of the input box. Example: $ansprompt="y="
$answerboxsize = number
Determines the number of characters space provided for entry of an answer. Defaults to 20.
$hidepreview = true
Hides the Preview button. Could be useful in multipart questions, or if you're only asking for a simple response, like a fraction
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the question input box in that location
$showanswer
The answer to show to students (if option if available). Defaults to $answer. Use this to give a detailed answer, or a rounded off answer.
$previewloc (In Question Text)
Where you want the preview button to be located. Defaults to after the entry box if not placed in question text.
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

Multiple-Choice

A student is asked to select the correct answer from those given. The order of choices is automatically randomized.

Required Variables

$questions (or $choices) = an array of choices
Defines the choices. If you use $choices, don't define $questions
$answer = the index into $questions that contains the correct answer
Defines the answer. Remember that arrays are zero-indexed, so if $questions = array("correct","wrong","wrong"), then $answer=0. Define multiple acceptable answer indices in a string separated by or: $answer = "0 or 1".

Optional Variables

$displayformat = "horiz", "select", "2column, "3column", or "inline"
Will lay out the choices horizontally, as a select box, in multiple columns, or inline with text rather than using the default vertical layout
$noshuffle = "all" or "last" or "last2"
If $noshuffle="all", then the $questions array will not be randomized (shuffled). If $noshuffle = "last", then the $questions array will be randomized, except for the last element. This is for options like "None of the above". You can use "last2" or "last3" to randomize all but the last 2 or 3 elements.
$partialcredit = array(index,score,[index,score,...])
Allows you to specify partial credit for other answers. The array should be given in the form array(index,score,index,score,...), where index is the index in $questions, and score is a proportion between 0 and 1 to award as partial credit. For example, if $answer = 0 and $partialcredit = array(2,.3), then the student would get full credit for selecting the item corresponding with $questions[0], and 30% credit for selecting the item corresponding with $questions[2]. All other answers would receive 0 credit.
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$ansprompt = string
When $displayformat = "select" is used, this allows you to override the default "Select an answer" text that displays. Do not use this unless there's a really strong reason to.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the choice list in that location
$showanswer
The answer to show to students (if option if available). Defaults to the text of the correct answer. Use this to substitute a detailed answer.
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

Multiple-Answer

A student is asked to select all the choices given that are correct. The order of choices is automatically randomized.

Required Variables

$questions (or $choices)= an array of questions
Defines the choices. If you use $choices, don't define $questions
$answers = a list of the indexes into $questions that contain the correct answer
Defines the answers. Remember that arrays are zero-indexed, if $questions = array("correct","correct","wrong"), then $answers="0,1". Or there are more than one correct combination, separate with or, like $answers = "0,1 or 0,3"

Optional Variables

$scoremethod = "answers" or "allornothing" or "takeanything"
By default, the total points possible are divided by the number of questions, and partial credit is lost for each correct answer missed and each wrong answer selected. If $scoremethod="answers" is set, then the total points possible are divided by the number of answers (tougher grading scheme). If $scoremethod="allornothing", then the student will only get credit if every piece is correct (no partial credit). if $scoremethod="takeanything", full credit will be given for any response.
$displayformat = "horiz", "2column, "3column", or "inline"
Will lay out the choices horizontally, in multiple columns, or inline with text rather than using the default vertical layout
$noshuffle = "all" or "last"
If $noshuffle="all", then the $questions array will not be randomized (shuffled). If $noshuffle="last", then the last element of $questions will not be randomized (shuffled) but the others will.
$answerformat = "addnone"
Adds "None of these" to the options. This is added automatically if $answers="", and you can add "None of these" yourselv to $questions, but this provides another way to always include the "None of these" option.
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the choice list in that location
$showanswer
The answer to show to students (if option if available). Defaults to the text of the correct answers. Use this to substitute a detailed answer.
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

Matching

A student is asked to match answers with questions

Required Variables

$questions = an array of questions
Defines the questions - these will be on the left with entry boxes
$answers = an array of answers
Defines the answers - these will be on the right and lettered

Optional Variables

$matchlist = a list of the indexes into $answers that contain the match to each question.
Defines correct matches. By default, it is assumed that each element of $questions is matched one-to-one with the corresponding element of $answers (in other words, that $answers[0] is the answer to $questions[0]).
$matchlist allows you to define one-to-many matches. Example: if $questions=array("cat","dog","quartz") and $answers=array("animal","mineral"), then $matchlist = "0,0,1"
$questiontitle = string
Displays a title above the list of questions. For example, if $questions was a list of states, then $questiontitle="States" would be appropriate
$answertitle = string
Displays a title above the list of answers
$noshuffle = "questions" or "answers"
Retains original order of questions or answers, and only shuffles the other. By default, both lists are shuffled
$displayformat = "select" or "2columnselect"
Only displays the $questions, with select boxes next to each containing the $answers. This should only be used with pure text $answers.
$scoremethod = "allornothing"
Setting "allornothing" will mean no partial credit is given, and the student must match all parts correctly to get credit.
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place matching questions and answers in that location
$showanswer
The answer to show to students (if option if available). Defaults to the list of correct matches. Use this to substitute a detailed answer.
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

Function

A student is asked to enter a function

Required Variables

$answer = string
Defines the answer function, entered as a string. For example, $answer="2sin(x)". You can specify multiple acceptable answers by separating with "or", like $answer="x^2 or x^4"
Note: The system will accept any algebraically equivalent answer. To only allow answers of a specific format, you'll also need to define $requiretimes (see below).

Optional Variables

$variables = string
A list of all variables in the function (including letters representing constants). Defaults to "x". Can use "f()" to indicate a symbol represents a function.
$domain = "inputmin,inputmax"
Defines the domain on which to compare the given answer and correct answer functions. The same domain applies to all variables. An option third list element "integers" can be given, which limits the domain to integer values. The domain defaults to real numbers from -10 to 10. If using multiple variables, can extend domain to define domain for each variable separately. Example: $variables = "x,y"; $domain = "0,5,20,25"
$requiretimes = a list, like "^,=3,cos,<2"
Adds format checking to the student's answer. The list can include multiple checks, which come in pairs. The first is the symbol to look for. The second describes what is acceptable. For example, in the string shown above, the symbol "^" would be required to show up exactly 3 times, and "cos" would be required to show up less than 2 times. You can use "#" in the symbol location to match any number (including decimal values); 3.2x+42y would match twice.
You can use a regular expression by putting in the symbol location "regex:expression"
You can match either of two symbols by putting || between them, like "x^-3||/x^3,>0"
Include "ignore_case,false" to make the search case sensitive.
You can put "ignore_spaces,true" at the beginning of the $requiretimes to ignore spaces in the answer
Include "ignore_symbol,$" (or some symbol other than $) at the beginning of the $requiretimes to ignore that symbol in the answer
Note that commas are ignored by default with Function type, and a basic exponent like x^(-3) is converted to x^-3 before the check.
$answerformat = "equation" or "inequality" or "generalcomplex" or "toconst" or "scalarmult" or "nosoln" or "nosolninf" or "sameform" or "list" (can combine, like "equation,nosoln")
By default, the student answer is expected to be an expression, and be equivalent (at points) to the specified answer. This option changes this behavior.
"equation": Specifies that the answer expected is an equation rather than an expression. The given answer should also be an equation. Be sure to specify all variables in the equation in $variables. This may fail on equations that are near zero for most values of the input; this can often be overcome by changing the $domain
"inequality": Specifies that the answer is expected to be an inequality rather than an expression. The given answers should also be an inequality. Be sure to specify all variables in the equation in $variables. This may fail on equations that are near zero for most values of the input; this can often be overcome by changing the $domain
"generalcomplex": Specifies the answer is a complex function, involving i.
"list": Allow a list of expressions or equations to be entered. Does not ignore duplicates. You cannot use this in combination with $partialcredit. $requiretimes will apply to each element of the list.
"toconst": Specifies that the answer provided by the student is allowed to differ from the specified answer by a constant for all inputs. Appropriate for comparing antiderivatives. This may fail on expressions that evaluate to very large values or raise numbers to very large powers.
"scalarmult": Specifies that the answer provided by the student is allowed to differ from the specified answer by a scalar multiple.
"allowplusminus": allow use of +- in the answer. Will enable the 'list' option if not already included.
"nosoln" or "nosolninf" adds a list radio buttons for "no solutions" and optionally "infinite solutions". $ansprompt can override the default statements like this: $ansprompt = "One function, f(x)=;No such function exists"
"sameform": requires the student's answer be in the "same form" as the correct answer. This means exactly the same, except for commutation of addition and multiplication, multiplication by 1, implicit multiplication, and extra parentheses. (2x-3)(5-x) would be "sameform" as (-1x+5)(2*x-3), but 2/4x and 1/2x and 0.5x would not be "sameform". Use with caution.
$partialcredit = array(string,score,[string,score,...])
Allows you to specify partial credit for other answers. The array should be given in the form array(string,score,string,score,...), where string is the expression to compare to the student answer, and score is a proportion between 0 and 1 to award as partial credit. Note this currently only works for single expression answers; "or" answers are not supported.
$formatfeedbackon = true
Turns on "right answer, wrong format" feedback on the question
$reltolerance = a decimal value
Defines the largest relative error that will be accepted. If this is not set, a relative error of .001 (.1%) is used by default.
$abstolerance = a number
Defines the largest absolute error that will be accepted. This will override the use of $reltolerance
$ansprompt = string
A string that will be displayed in front of the input box. Example: $ansprompt="y="
$answerboxsize = number
Determines the number of characters space provided for entry of an answer. Defaults to 20.
$hidepreview = true
Hides the Preview button. Could be useful in multipart questions, but generally not recommended
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the question input box in that location
$showanswer
The answer to show to students (if option if available). Defaults to makeprettydisp($answer).
$previewloc (In Question Text)
Where you want the preview button to be located. Defaults to after the entry box if not placed in question text.
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

String

A student is asked to enter a string (a word or list of letters).

Required Variables

$answer = a string
Defines the answer. Multiple acceptable answers can be entered using "or". Example: $answer = "dog or cat"

Optional Variables

$strflags = string of flags, like "ignore_case=1,trim_whitespace=0"
Determines how the string will be compared. Set to 1 to turn on, 0 for off. Flags are:
  • ignore_case: ignores capitol/lowercase differences
  • trim_whitespace: trims leading and ending whitespace (spaces)
  • compress_whitespace: compresses multiple spaces to one space and trims
  • remove_whitespace: removes all whitespace (spaces)
  • ignore_order: treats ABC and CBA as equivalent
  • ignore_commas: removes commas
  • partial_credit: awards partial credit based on Levenshtein distance between strings
  • allow_diff=n: gives full credit for answers with Levenshtein distance between strings ≤ n
  • in_answer: gives credit if $answer is contained anywhere in the student answer
  • regex: interprets $answer as a regular expression (pattern) to evaluate the student's answer. For example, $answer="cost.*increas" will give credit if the word cost appears before increas in the student's answer. $answer="increas|ris" will accept any of the following: increasing, increases, rising, or risen etc.
  • special_or: use *or* for separating answers rather than or.
  • ignore_symbol=sym: Unlike the other flags, this is not an on/off flag. Set this equal to a symbol to ignore that symbol in student answers. This flag can be used multiple times with different symbols.
By default, compress_whitespace and ignore_case are On. Only one of partial_credit, allow_diff, in_answer or regex may be used at a time.
$scoremethod = "takeanything" or "takeanythingorblank" or "submitblank"
"takeanything" or "takeanythingorblank" sets the problem to give full credit for any answer. "takeanythingorblank" also counts blank answers as correct. "submitblank" will cause blank answers to get submitted for scoring (new system only).
$answerformat = "list" or "logic" or "setexp"
"list" specifies that a list of answers is expected. Renders ignore_commas unnecessary. Cannot be used with partial_credit flag. Duplicates are not ignored.

"logic" enables a separate grading algorithm for logic statements, ignoring $strflags. The $answer should be given using vv for or, ^^ for and, neg for not, xor for exclusive or, => for conditional, and <=> for biconditional. Parens are supported, but no other symbols. The variables used in the logic expression must be declared by defining $variables.

"setexp" enables a separate grading algorithm for set expression statements, ignoring $strflags. The $answer should be given using 'nn' for intersection, 'uu' for union, '-' for set difference, '^c' for set complement, and 'oplus' for symmetric difference.
$displayformat = "usepreview" or "typeahead" or "usepreviewnomq"
"usepreview" enables mathquill entry for mathematical answers.
"usepreviewnomq" adds a preview button for previewing mathematical answers in asciimath.
"typeahead" will enable an auto-suggest list of options once the student has typed at least two letters of the word. Provide the auto-suggest list in the variable $questions.
$variables
When $answerformat="logic" or "setexp" is used, define the $variables in the logic statement, like "p,q"
$requiretimes = a list, like "^,=3,cos,<2"
Adds format checking to the student's answer. Usually not needed for string questions, but can be useful when the "logic" or "setexp" answerformat is used. The list can include multiple checks, which come in pairs. The first is the symbol to look for. The second describes what is acceptable. For example, in the string shown above, the symbol "^" would be required to show up exactly 3 times, and "cos" would be required to show up less than 2 times.
$ansprompt = string
A string that will be displayed in front of the input box. Example: $ansprompt="type: "
$answerboxsize = number
Determines the number of characters space provided for entry of an answer. Defaults to 20.
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the answer entry box in that location
$showanswer
The answer to show to students (if option if available). Defaults to the text of the correct answer. Use this to substitute a detailed answer.
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

Essay

A student is asked to enter a free-response answer. The essay type is not automatically graded.

Required Variables

None - the essay type is not computer graded.

Optional Variables

$answerboxsize = "rows" or $answerboxsize = "rows,columns"
Determines size of space provided for entry of an answer. Defaults to 5 rows, 50 columns.
$displayformat = "editor" or "editornopaste" or "pre"
"editor" to use the rich text editor for the essay answer box, or "editornopaste" for the rich text editor with paste disabled.
"pre" to use standard text entry, and to display in gradebook as preformatted text.
$scoremethod = "takeanything" or "takeanythingorblank" or "nomanual"
The first two sets the problem to give full credit for any answer. The second also counts blank answers as correct. The "nomanual" option will give no credit for any answer, but doesn't mark the question as needing manual grading.
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the essay box in that location
$showanswer
The answer to show to students (if option if available). Defaults to the text of the correct answer. Use this to substitute a detailed answer.
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

Drawing

Drawing questions require the student to draw one or more lines/curves or dots. Dots are graded right/wrong. Lines/curves are graded based on the deviation of the drawn line from the correct line.

Required Variables

$answers = a string or array of strings describing the points or curves to be drawn
Curves: "f(x)" like "x^2+3".
Line segments or rays: "f(x),xmin,xmax", like "x+1,-3,2" or "x+1,-oo,3"
Dots: "x,y" for closed dots, "x,y,open" for open dots, like "2,3"
See below for additional entry formats for other curves when using "twopoint" drawing.
When using twopoint drawing, you can preface an answer with "optional", like "optional,2,3", to indicate that drawing element is not required, but shouldn't mark down the score if present.

Recommended Variables

$answerformat = "twopoint", "polygon", "inequality", "numberline", "freehand", or (for the older tools), "line,lineseg,dot,opendot"
Limits the drawing tools available to students. Defaults to the older drawing tools "line,dot,opendot".

$answerformat="twopoint" will use a different set of drawing tools for specific shapes that all use two control points to define the shape. It is strongly recommended you use these instead of the older tools.

  • $answerformat="twopoint" will use a default tool set of line, parabola, absolute value, circle, and dot tools
  • You can limit or expand the tools by specifying them: e.g. $answerformat = "twopoint,line,parab". Valid values are:
    • line (lines)
    • lineseg (line segment)
    • ray (rays)
    • parab (vertical parabolas)
    • horizparab (horizontal parabolas)
    • halfparab (half a vertical parabola)
    • cubic (a(x-h)^3+k style cubics)
    • abs (absolute value)
    • circle (circles)
    • dot (closed dots)
    • opendot (open dots)
    • sqrt (square root)
    • cuberoot (cube root)
    • trig (sin and cos)
    • vector (position or displacement vectors)
    • exp (exponential with horizontal asymptote at y=0)
    • genexp (exponential with any horizontal asymptote)
    • log (logarithm with vertical asymptote at x=0)
    • genlog (logarithm with any vertical asymptote)
    • rational (linear/linear rational)
    • ellipse (ellipses)
    • hyperbola (vertical or horizontal hyperbolas)
  • For lines, vertical parabolas, absolute values, square roots, cubics, cuberoots, sines, cosines, exponentials, logs, and rationals (linear/linear only) give $answers as a function of x, like "2(x-1)^2+3"
  • For line segments and rays, given $answers as a function with domain, like "2x+4,-oo,3", or for vertical line segments use x= and give the range, like "x=4,-2,3"
  • For dots give $answers as "x,y", or "x,y,open" for open dots
  • For circles, give $answers as "circle,x,y,radius", like "circle,2,-1,3"
  • For ellipses, give $answers as "ellipse,x,y,x_radius,y_radius", like "ellipse,1,2,4,2"
  • For hyperbolas of form (x-h)^2/a^2-(y-k)^2/b^2=1, give $answers as "horizhyperbola,h,k,a,b"
  • For hyperbolas of form (y-k)^2/a^2-(x-h)^2/b^2=1, give $answers as "verthyperbola,h,k,a,b"
  • For horizontal parabolas give $answers as "x=equation", like "x=2(y-1)^2-3".
  • For half parabolas give $answers as "equation,>xvertex", like "(x-1)^2-3,>1". Note only half parabolas are supported, not arbitrary segments.
  • For vertical lines give $answers as "x=number", like "x=3".
  • For vectors, give $answers as "vector, x_start, y_start, x_end, y_end" for position vectors, or "vector, dx, dy" for displacement vectors. Note you can use $scoremethod to change how vectors are scored.

$answerformat = "polygon" can be used for drawing a single polygon; give $answer as array of points in order joined with edges.

$answerformat = "closedpolygon" can be used for drawing a single polygon that is closed; the enclosed area will be shaded and the drawing terminate when the shape is closed. The format is the same as "polygon", except make sure the first and last entry of your $answers array are identical.

$answerformat="inequality" will use a set of drawing tools for graphing linear inequalities in two variables. Give $answers for non-vertical lines in form like ">=3x+4", "<5x+4", and "x<=3" for vertical lines.

$answerformat="inequality,parab" will use a set of drawing tools for graphing quadratic inequalities in two variables. Give $answers in form like ">=x^2-4", "<x^2+1". Use $answerformat="inequality,both" to turn on lines and parabolas.

$answerformat="inequality,abs" will use a set of drawing tools for graphing absolute value inequalities in two variables. Give $answers in form like ">=abs(x-3)+4", "<3abs(x)". Use $answerformat="inequality,line,abs,parab" or some combo to turn on multiple tools.

$answerformat="numberline" will use a set of drawing tools for graphing inequalities or points in one variable on a number line. Give $answers as dots and line segments, or use the intervalstodraw function from the interval macro library to form the $answers array.

$answerformat="freehand" will allow freehand drawing without any drawing tools. This mode can NOT be autograded, and should only be used for manually graded answers.

$answerformat can also be used to limit the older tools: $answerformat = "line", or $answerformat = "line,dot"

$snaptogrid = spacing
Turns on snapping, where points will jump to a grid. $snaptogrid = 1 will jump to the nearest integer. $snaptogrid = 0.5 will jump to the nearest .5. $snaptogrid = "2:4" will jump to the nearest 2 in the x and 4 in the y. Does not have to match the actual grid line spacing. Be aware that due to pixelation, the snapping may not land on exact values correctly. This is usually corrected for automatically, but it sometimes fails if the correction would be too large. In that case, use the getsnapwidthheight macro to compute an imagewidth and imageheight that will be pixel accurate.

Optional Variables

$grid = "xmin,xmax,ymin,ymax,xscl,yscl,imagewidth,imageheight"
Defines the grid to be drawn on. Defaults to "-5,5,-5,5,1,1,300,300". You can set all or just some of the values. For example, to just set the window, you could use "0,10,0,10"
If using $answerformat="numberline", set ymin and ymax to 0.
If desired, you can set separate label and grid spacing using "xmin,xmax,ymin,ymax,xlabelspacing:xgridspacing,ylabelspacing:ygridspacing,imagewidth,imageheight". You can specify axis labels using "xmin,xmax,ymin,ymax,xlabelspacing:xgridspacing:xaxislabel,ylabelspacing:ygridspacing:yaxislabel,imagewidth,imageheight". To create first quadrant graphs, use "0:-n" (for some value of n) for xmin and/or ymin to only have gridlines and labels after 0, while still using -n to adjust spacing.
$background = equation or array of equations, using the showplot macro format
Define a graph to display in the background, to be drawn on top of. Example: $background = "x^2,red".
You can also set $background a string of asciisvg commands prefaced with "draw:", like "draw:line([1,1],[3,3]);". Note that initPicture and axes will already have been called, so do not include them.
You can also set $background to "none" to remove axes and the grid.
$partweights = array or list of weights
Defines grading weight for each line or dot in $answers. Example: $partweights = ".5,.25,.25". Defaults to equal weights on each line or dot.
$reltolerance = tolerance scaling factor
Scales the grading tolerance. Defaults to 1. Set $reltolerance = 2 to make the grading twice as tolerant; $reltolerance = 0.5 to make grading half as forgiving
$abstolerance = grading cutoff
Sets all-or-nothing grading. If score < $abstolerance, the student receives 0 for the question (note: score is between 0 and 1). Otherwise the student will receive full credit. Not set by default.
$scoremethod = "takeanything", "direction", "relativelength", "ignoreoverlap"
When "takeanything" is used, this will give full credit for any non-blank answer. This might be of use with the freehand drawing option.
"direction" and "relativelength" are only used for vectors. "direction" will score the initial point and direction for position vectors, but not length, and will only score direction for displacement vectors. "relativelength" will score like "direction", but will also check that the drawn vectors have correct lengths relative to each other.
"ignoreoverlap" only works with $answerformat="line", and will not deduct for overlapped lines.
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the question input drawing tool in that location
$showanswer
The answer to show to students (if option if available). Defaults to the text of the correct answer. Use this to substitute a detailed answer.
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

N-Tuple

N-Tuple questions require the student to enter an n-tuple or list of n-tuples. This can be used for coordinate points, vectors, or any other n-tuple of numbers.

Required Variables

$answer = a string containing an n-tuple or list of n-tuples
Defines the answer n-tuple or list of n-tuples. N-tuples can be any dimension, but must be surrounded by any of: (), [], {}, <>. Examples: $answer = "(1,2)", $answer = "<2,3,4>,<1,5,7>", $answer = "(1,2) or (1,3)"

Optional Variables

$displayformat = "point", "pointlist", "vector", "vectorlist", "list", "set", "setlist"
Changes the answer entry tips (does NOT change how the question is graded). For points, entry like (2,3) is specified. For vectors, entry like <2,3> is specified.
$answerformat = "scalarmult", "anyorder", "nosoln", "nosolninf"
"scalarmult" will accept any answer that is a scalar multiple of the correct answer.
"anyorder" will accept elements in any order, so (2,1) would be treated equivalent to (1,2)
$answerformat = "nosoln" or "nosolninf" adds a list radio buttons for "no solutions" and optionally "infinite solutions". $ansprompt can override the default statements like this: $ansprompt = "One value, x=;No values;Many values"
$scoremethod = "byelement"
By default, the whole n-tuple must be correct to receive any credit. Set $scoremethod = "byelement" to give partial credit if only some elements of the n-tuple are correct.
$partweights = ".2,.8"
Can be used with $scoremethod = "byelement" to change the value of each part of the ntuple
$reltolerance = a decimal value
Defines the largest relative error that will be accepted. If this is not set, a relative error of .001 (.1%) is used by default.
$abstolerance = a number
Defines the largest absolute error that will be accepted. This will override the use of $reltolerance
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the question input drawing tool in that location
$showanswer
The answer to show to students (if option if available). Defaults to the text of the correct answer. Use this to substitute a detailed answer.
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

Calculated N-Tuple

Calculated N-Tuple questions require the student to enter an n-tuple or list of n-tuples. This can be used for coordinate points, vectors, or any other n-tuple of numbers. This is identical the the N-tuple answer type, but allows students to enter mathematical expressions rather than just numbers, such as (5/3, 2/3).

Required Variables

$answer = a string containing an n-tuple or list of n-tuples
Defines the answer n-tuple or list of n-tuples. N-tuples can be any dimension, but must be surrounded by any of: (), [], {}, <>. Examples: $answer = "(1/3,2)", $answer = "<2,3,4>,<1,5,7>", $answer = "(1,2) or (1,3)"

Optional Variables

$displayformat = "point", "pointlist", "vector", "vectorlist", "list", "set", "setlist"
Changes the answer entry tips (does NOT change how the question is graded). For points, entry like (2,3) is specified. For vectors, entry like <2,3> is specified.
$answerformat = "scalarmult", "anyorder", "fraction", "reducedfraction", "mixednumber", "scinot", "fracordec", "nodecimal", "notrig", "nosoln", "nosolninf", "sameform"
"scalarmult" will accept any answer that is a scalar multiple of the correct answer.
"anyorder" will accept elements in any order, so (2,1) would be treated equivalent to (1,2)
The other options require each component of the answer to be a single fraction (like 10/6), a reduced fraction (like 5/3), a reduced mixed number (like 2_1/2), scientific notation (like 2.3*10^4), a single fraction or decimal, an answer without decimals (also disallows 10^-2 and 3E-2), or an answer without trig functions (sin,cos,tan,sec,csc,cot). Multiple options can be specified like $answerformat="nodecimal,notrig".
$answerformat = "nosoln" or "nosolninf" adds a list radio buttons for "no solutions" and optionally "infinite solutions". $ansprompt can override the default statements like this: $ansprompt = "One value, x=;No values;Many values"
$scoremethod = "byelement"
By default, the whole n-tuple must be correct to receive any credit. Set $scoremethod = "byelement" to give partial credit if only some elements of the n-tuple are correct.
$partweights = ".2,.8"
Can be used with $scoremethod = "byelement" to change the value of each part of the ntuple
$reltolerance = a decimal value
Defines the largest relative error that will be accepted. If this is not set, a relative error of .001 (.1%) is used by default.
$abstolerance = a number
Defines the largest absolute error that will be accepted. This will override the use of $reltolerance
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the question input drawing tool in that location
$showanswer
The answer to show to students (if option if available). Defaults to the text of the correct answer. Use this to substitute a detailed answer.
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

Complex

Complex questions require the student to enter a complex number in a+bi form.

Required Variables

$answer = a string containing a complex number or list of complex numbers
Defines the answer. Example: $answer="3+2i"

Optional Variables

$answerformat = "list" or "allowjcomplex"
"list" Specifies that the answer will be a list of complex numbers. "allowjcomplex" allows 2+3j instead of 2+3i
$reltolerance = a decimal value
Defines the largest relative error that will be accepted. If this is not set, a relative error of .001 (.1%) is used by default.
$abstolerance = a number
Defines the largest absolute error that will be accepted. This will override the use of $reltolerance
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the question input drawing tool in that location
$showanswer
The answer to show to students (if option if available). Defaults to the text of the correct answer. Use this to substitute a detailed answer.
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

Calculated Complex

Calculated Complex questions require the student to enter a complex number in a+bi form. This is identical to the Complex answer type, but allows students to enter mathematical expressions rather than just numbers, such as 1/3+sqrt(2)i.

Required Variables

$answer = a string containing a complex number or list of complex numbers
Defines the answer. Example: $answer="3+2i", $answer="2/3+1/3i". The answer must be given in a + bi format (so 2+3isqrt(2) or 5/2+i/3 will not work) unless $answerformat="sloppycomplex" is used.

Optional Variables

$answerformat = "sloppycomplex", "generalcomplex", "allowjcomplex" "fraction", "reducedfraction", "mixednumber", "scinot", "fracordec", "nodecimal", "notrig", or "sameform"
Use "sloppycomplex" to allow the student to enter complex numbers in forms other than a+bi (allows 2+3isqrt(2) for example). Student answer must still only contain one i.
Use "generalcomplex" to allow students to enter complex expressions that may involve calculations.
"allowjcomplex" allows for use of j instead of i as the imaginary unit.
The other options requires the real and imaginary parts of the answer to be a single fraction (like 10/6), a reduced fraction (like 5/3), a reduced mixed number (like 2_1/2), scientific notation (like 2.3*10^4), a single fraction or decimal, an answer without decimals (also disallows 10^-2 and 3E-2), or an answer without trig functions (sin,cos,tan,sec,csc,cot). Multiple options can be specified like $answerformat="nodecimal,notrig".
$answerformat = "list" specifies that the answer will be a list of complex numbers.
allowplusminus allow use of +- in the answer. Will enable the 'list' option if not already included.
$answerformat = "nosoln" or "nosolninf" adds a list radio buttons for "no solutions" and optionally "infinite solutions". $ansprompt can override the default statements like this: $ansprompt = "One value, x=;No values;Many values"
$reltolerance = a decimal value
Defines the largest relative error that will be accepted. If this is not set, a relative error of .001 (.1%) is used by default.
$abstolerance = a number
Defines the largest absolute error that will be accepted. This will override the use of $reltolerance
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the question input drawing tool in that location
$showanswer
The answer to show to students (if option if available). Defaults to the text of the correct answer. Use this to substitute a detailed answer.
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

Numerical Matrix

The student is asked to enter a matrix of numbers (integer, decimal, or scientific notation). The entries are compared to a given tolerance.

Required Variables

$answer = string describing a matrix of numbers, or calculations leading to numbers
Defines the answer. Example: $answer = "[(1,2,3),(8/2,5,6)]" is a 2x3 matrix with first row: 1,2,3

Optional Variables

$answersize = "rows,cols"
Defines the size of the answer matrix. If this is supplied, the student will be provided with a grid of entry boxes in which to input the matrix. If this is not supplied, they will be required to enter the matrix using the ASCIIMath notation, like "[(1,2,3),(4,5,6)]"
$answerformat = "scalarmult" or "ref" or "rowequiv" or "anyroworder"
If "scalarmult" used, any scalar multiple of the correct matrix will be accepted.
If "ref" is used, any row echelon form matrix that is row equivalent will be accepted.
If "rowequiv" is used, any matrix that is row equivalent will be accepted.
If "anyroworder" is used, any matrix equivalent up to row interchanges will be accepted.
$reltolerance = a decimal value
Defines the largest relative error that will be accepted. If this is not set, a relative error of .001 (.1%) is used by default.
$abstolerance = a number
Defines the largest absolute error that will be accepted. This will override the use of $reltolerance
$scoremethod = "byelement"
By default, the whole matrix must be correct to receive any credit. Set $scoremethod = "byelement" to give partial credit if only some elements of the matrix are correct.
$displayformat = "det" or "inline"
When $answersize is used, by default square brackets are used around the entry array. Set $displayformat = "det" to use vertical bars instead.
Normally matrices with $answersize set are displayed on their own line. Set $displayformat = "inline" to display it inline with text.
$ansprompt = string
A string that will be displayed in front of the input box. Example: $ansprompt="y="
$answerboxsize = number
Determines the number of characters space provided for entry of an answer. Defaults to 20. Will only be used if $answersize is not supplied.
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the question input box in that location
$showanswer
The answer to show to students (if option if available). Defaults to $answer. Use this to substitute a detailed answer.
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

Calculated Matrix

The student is asked to enter a matrix of numbers or calculations, like 2/3 or 5^2. The entries are compared to a given tolerance.

Required Variables

$answer = string describing a matrix of numbers, or calculations leading to numbers
Defines the answer. Example: $answer = "[(1,2,3),(8/2,5,6)]" is a 2x3 matrix with first row: 1,2,3

Optional Variables

$answersize = "rows,cols"
Defines the size of the answer matrix. If this is supplied, the student will be provided with a grid of entry boxes in which to input the matrix. If this is not supplied, they will be required to enter the matrix using the ASCIIMath notation, like "[(1,2,3),(4,5,6)]"
$answerformat = "scalarmult","ref","rowequiv","anyroworder",fraction", "reducedfraction", "mixednumber", "scinot", "fracordec", "nodecimal", or "notrig"
Requires the entries of the answer to be a single fraction (like 10/6), a reduced fraction (like 5/3), a reduced mixed number (like 2_1/2), scientific notation (like 2.3*10^4), a single fraction or decimal, an answer without decimals (also disallows 10^-2 and 3E-2), or an answer without trig functions (sin,cos,tan,sec,csc,cot). Multiple options can be specified like $answerformat="nodecimal,notrig".
If "scalarmult" used, any scalar multiple of the correct matrix will be accepted.
If "ref" is used, any row echelon form matrix that is row equivalent will be accepted.
If "rowequiv" is used, any matrix that is row equivalent will be accepted.
If "anyroworder" is used, any matrix equivalent up to row interchanges will be accepted.
$reltolerance = a decimal value
Defines the largest relative error that will be accepted. If this is not set, a relative error of .001 (.1%) is used by default.
$abstolerance = a number
Defines the largest absolute error that will be accepted. This will override the use of $reltolerance
$scoremethod = "byelement"
By default, the whole matrix must be correct to receive any credit. Set $scoremethod = "byelement" to give partial credit if only some elements of the matrix are correct.
$displayformat = "det" or "inline"
When $answersize is used, by default square brackets are used around the entry array. Set $displayformat = "det" to use vertical bars instead.
Normally matrices with $answersize set are displayed on their own line. Set $displayformat = "inline" to display it inline with text.
$ansprompt = string
A string that will be displayed in front of the input box. Example: $ansprompt="y="
$answerboxsize = number
Determines the number of characters space provided for entry of an answer. Defaults to 20. Will only be used if $answersize is not supplied.
$hidepreview = true
Hides the Preview button. Could be useful in multipart questions, but generally not recommended
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the question input box in that location
$showanswer
The answer to show to students (if option if available). Defaults to $answer. Use this to substitute a detailed answer.
$previewloc (In Question Text)
Where you want the preview button to be located. Defaults to after the entry box if not placed in question text.
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

Interval

A student is asked to enter an interval notation answer. Example: (2,5]U(7,oo)

Required Variables

$answer = a string with the answer in interval notation
Defines the answer. Join multiple intervals with U for union. Example: $answer = "(-oo,4]U(3,oo)". Use DNE for empty set. Multiple acceptable answers can be entered using "or". Example: $answer = "(3,3) or [3,3]"

Optional Variables

$reltolerance = a decimal value
Defines the largest relative error that will be accepted. If this is not set, a relative error of .001 (.1%) is used by default.
$abstolerance = a number
Defines the largest absolute error that will be accepted. This will override the use of $reltolerance
$reqdecimals = a number
Defines the decimal accuracy required (ie 2 for two decimal places). This will put a message in the answer tips stating the decimals required. If neither $abstolerance or $reltolerance is set, this will set the tolerance, otherwise the provided tolerance will be used (even if it doesn't agree with the $reqdecimal setting).
$answerformat = "normalcurve" or "list" or "allowsloppyintervals"
"normalcurve" Changes the question to use a "shade the area under the normal curve" widget. Define $answer using the open interval that should be shaded. Note that the shading tool only allows selection of z-values to 1 decimal place.
"list" will accept a list of comma-separated intervals like $answer="[2,3),(5,7)"
"allowsloppyintervals" will accept unsimplified unions, so will count [2,5)U(3,7) as equivalent to [2,7)
$scoremethod = "partialcredit"
By default, interval answers will be marked all right or all wrong. Setting $scoremethod = "partialcredit" will changing the scoring mode to give partial credit. (new assessment system only).
$ansprompt = string
A string that will be displayed in front of the input box. Example: $ansprompt="`x in`"
$answerboxsize = number
Determines the number of characters space provided for entry of an answer. Defaults to 20.
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the entry box in that location
$showanswer
The answer to show to students (if option if available). Defaults to the text of the correct answer. Use this to substitute a detailed answer.
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

Calculated Interval

A student is asked to enter an interval notation answer. Example: (2,5]U(7,oo). Values can be entered as calculations rather than numbers, like [2/5,sqrt(8)]. Can use $answerformat="inequality" to require the student to use inequalities rather than interval notation.

Required Variables

$answer = a string with the answer in interval notation
Defines the answer. Join multiple intervals with U for union, and oo for infinity. Example: $answer = "(-oo,4]U(9/2,oo)". Use DNE for empty set. Multiple acceptable answers can be entered using "or". Example: $answer = "(3,3) or [3,3]".

Optional Variables

$answerformat = "fraction", "reducedfraction", "mixednumber", "scinot", "fracordec", "nodecimal", "notrig", "list", "allowsloppyintervals", or "inequality"
Requires the each value in the answer to be a single fraction (like 10/6), a reduced fraction (like 5/3), a reduced mixed number (like 2_1/2), scientific notation (like 2.3*10^4), a single fraction or decimal, an answer without decimals (also disallows 10^-2 and 3E-2), or an answer without trig functions (sin,cos,tan,sec,csc,cot). Multiple options can be specified like $answerformat="nodecimal,notrig".
$answerformat = "inequality" will require the student to enter an inequality rather than an interval. The instructor answer must still be given in interval notation (it will be reformatted to an inequality automatically for the Show Answer). Use $variables="y" to change the variable of the inequality.
"list" will accept a list of comma-separated intervals like $answer="[2,3),(5,7)". Does not work with "inequality".
"allowsloppyintervals" will accept unsimplified unions, so will count [2,5)U(3,7) as equivalent to [2,7)
$reltolerance = a decimal value
Defines the largest relative error that will be accepted. If this is not set, a relative error of .001 (.1%) is used by default.
$abstolerance = a number
Defines the largest absolute error that will be accepted. This will override the use of $reltolerance
$reqdecimals = a number
Defines the decimal accuracy required (ie 2 for two decimal places). This will put a message in the answer tips stating the decimals required. If neither $abstolerance or $reltolerance is set, this will set the tolerance, otherwise the provided tolerance will be used (even if it doesn't agree with the $reqdecimal setting).
$scoremethod = "partialcredit"
By default, interval answers will be marked all right or all wrong. Setting $scoremethod = "partialcredit" will changing the scoring mode to give partial credit. Note that answers not meeting $answerformat requirements will have deductions in addition to correctness checks. (new assessment system only).
$ansprompt = string
A string that will be displayed in front of the input box. Example: $ansprompt="`x in`"
$answerboxsize = number
Determines the number of characters space provided for entry of an answer. Defaults to 20.
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the entry box in that location
$showanswer
The answer to show to students (if option if available). Defaults to the text of the correct answer. Use this to substitute a detailed answer.
$previewloc (In Question Text)
Where you want the preview button to be located. Defaults to after the entry box if not placed in question text.
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

Chemical Equation

A student is asked to enter a chemical formula, or use $answerformat="reaction" to ask for a reaction equation.

Required Variables

$answer = a string with the answer
Defines the answer, like "H_2O". Spaces are ignored. For reactions, use -> for a right arrow, and <-> for an equilibrium arrow, like "2H+O->H_2O".

Optional Variables

$answerformat = "reaction"
Use "reaction" if you're asking for a reaction equation.
$variables = a list of atoms
Define this to populate the equation editor with the specified atoms.
$answerboxsize = number
Determines the number of characters space provided for entry of an answer. Defaults to 20.
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the entry box in that location
$showanswer
The answer to show to students (if option if available). Defaults to the text of the correct answer. Use this to substitute a detailed answer.

File Upload

A student is asked to upload a file. The file upload type is not automatically graded.

Required Variables

None - the file upload type is not computer graded.

Optional Variables

$scoremethod = "takeanything" or "takeanythingorblank"
Sets the problem to give full credit for any answer. The latter also counts blank answers as correct.
$answerformat = "images", "canpreview", or a list of file extensions
Set a list of preferred file formats for the file selector. "images" is a shorthand for .jpg,.gif,.png,.jpeg. "canpreview" is a shorthand for image files, office files, and pdfs, which can be previewed inline. If listing file extensions, provide a comma separated list with leading periods, like ".pdf,.docx,.doc"
$readerlabel = string
A string that will be used as a visually hidden label on the input box for screenreaders.
$answerbox (In Question Text)
Using the variable $answerbox in the Question Text will place the file upload box in that location
$showanswer
The answer to show to students (if option if available).
$hidetips = true
Hides the question entry tips that display by default. This should only be used when a question type is being used in an unintentional way, or if the question type gives away critical info to the student.

Multipart

This type of question can contain multiple parts, where each part is one of the previous question types.

Required Variables

$anstypes = an array or list of answer types
Defines the answer type for each part. Example: $anstypes = array("number","number","choices")
Refer to this list for the short names of each question type:
  • Number: "number"
  • Calculated: "calculated"
  • Multiple Choice: "choices"
  • Multiple Answer: "multans"
  • Matching: "matching"
  • Function/expression: "numfunc"
  • Drawing: "draw"
  • N-tuple: "ntuple"
  • Calculated N-tuple: "calcntuple"
  • Matrix: "matrix"
  • Calculated Matrix: "calcmatrix"
  • Complex: "complex"
  • Calculated Complex: "calccomplex"
  • Interval: "interval"
  • Calculated Interval: "calcinterval"
  • Chemical Equation: "chemeqn"
  • Essay: "essay"
  • File Upload: "file"
  • String: "string"
Question part variables
For each question part, you will need to define the variables (like $answer, $questions, etc.) you would normally need to define. However, you will need to suffix the variable with a part designator. For example, based on $anstypes above, the first answer is a number. Instead of $answer = 5, enter $answer[0] = 5. This designates that this answer belongs to the first element of $anstypes. Likewise, to set the variables for the "numfunc" type, you'd set $variables[5] = "x".
$answerbox[partnum] (In Question Text)
The array $answerbox will contain the entry boxes for each answer type. In the question text, you will need to position these boxes within the question. For example: "Enter a number: $answerbox[0]. Now a function: $answerbox[1]". Alternatively, you can use [AB#]: "Enter a number: [AB0]. Now a function: [AB1]"

Optional Variables

$answeights = an array or list of weights for each question
By default the points for a problem are divided evenly over the parts. Use this option if you wish to weight parts differently. Example: $answeights = array(.2,.3,.5). Best practice is to use percents, but if other values are used, they will be converted to percents.
$scoremethod = "singlescore" or "allornothing"
Instead of recording individual scores for each question part, these will cause a single score to be recorded for the question. "singlescore" totals the individual part scores, while "allornothing" will only give full credit or no credit. If you need to specify per-part indexed scoremethod values as well, you can define this as the array value $scoremethod['whole'] instead.
Question part options
You can define any optional variable for each question part. Like above, suffix the variable with the part designator.
$showanswer
You can either define $showanswer for individual question parts (ie, $showanswer[1]="`x^2`"), or you can set one $showanswer, which will be the only answer shown for the problem (ie, $showanswer = "x=$answer[0], y=$answer[1]")
$showanswerloc (In Question Text)
Optionally, you can use $showanswerloc to place a single $showanswer "Show Answer" button, or $showanswerloc[part] to place "Show Answer" buttons for each part. You can also use short tags of the form [SAB] or [SABn] (like [SAB2]). Note that if you use this to place one Show Answer button, you must place all of them, or else the remainder will not show. Use $showanswerstyle = 'inline' to allow Show Answer to be placed inline with text rather than on its own line.

Scaffolding

Scaffolded questions, also know as Sequential Multipart questions, allow you to break a question up into chunks, where the second chunk only shows after the first chunk is correctly answered or the student runs out of tries. This allows you to use the answer to the first chunk in the second without "giving away" the answer, and allows a student who gets stuck on the first chunk to move on to the rest of the question.

Note: scaffolding is only available in the new assessment interface. If you are using the old interface, the question will behave like a regular multipart question.

Scaffolded questions are an extension of Multipart questions. To turn a multipart question into a scaffolded question, just add an isolated line with three or more slashes in the Question Text where you want the chunks broken apart.

An example: (in the Question Text)

To simplify $a(x+$b) + $c, first we need to distribute:

$a(x+$b) = $answerbox[0]

///

Next, combine like terms:

$a x + $ab + $c = $answerbox[1]

Conditional

A variation on multipart questions, a conditional question can include multiple answer boxes, but assigns a single score. The score is based on applying some comparison or conditional test to the student answers, referenced through the $stuanswers array. This allows the question writer to essentially create their own question type.

Required Variables

$anstypes = an array or list of answer types
Defines the answer type for each part. Example: $anstypes = "number,number". See the Multipart help above for the list of short names
$answer = any of these:
  • A boolean (true/false) expression: Something that evaluates to true or false.
    Example: $answer = ($a>3)
    Example: $answer = comparefunctions($f,'x^2') && ($a!=0)
  • A single numerical value in the interval [0,1]: will award that percentage of the total possible points.
  • array('function',$a,$b): Will compare the functions $a and $b and mark the question correct if they are equivalent. Can set $variables, $reltolerance, $abstolerance, and $domain as needed, like with Function type questions
  • array('number',$a,$b): Will compare the numbers or numerical expressions $a and $b and mark the question correct if they are equivalent. Can set $reltolerance or $abstolerance as needed, like with Number/Calculated type questions
  • Multiple comparisons: You can mix the two types above by creating an array of comparisons. All must be true for the question to be marked correct.
    Example: $answer = array($a>3, array('function',$b,c), array('number',evalfunc($b,$a),5))
Question part variables
For each question part, you will need to define the variables (like $questions, etc.) you would normally need to define, except you should not define an $answer. However, you will need to suffix the variable with a part designator. For example, based on $anstypes above, the first answer is a number. Instead of $displayformat = "select", enter $displayformat[0] = "select". This designates that this setting belongs to the first element of $anstypes.
$answerbox[partnum] (In Question Text)
The array $answerbox will contain the entry boxes for each answer type. In the question text, you will need to position these boxes within the question. For example: "Enter a number: $answerbox[0]. Now a function: $answerbox[5]"

Optional Variables

Question part options
You can define any optional variable for each question part. Like above, suffix the variable with the part designator. Note that $variables, $domain, $reltolerance, and $abstolerance may be used for the comparison, and should not be set for individual parts.
$showanswer
By default the $showanswer for conditional types is "Answers may vary". Set $showanswer to override this.

Scaffolding

While not as simple as scaffolding multipart questions, you can add scaffolding to a Conditional question. As with multipart, put an isolated line with three slashes in the question text to indicate where the breaks occur. Then you will need to set $seqPartDone[pn] to true for each part index once that part should be considered completed. The scaffolding will move onto the next chunk when all parts in the previous chunk have $seqPartDone set to true.