Skip to content

Parameter types and constraints

Parameters make an EduBase question generate new values for every participant. This page lists the seven parameter types, the constraints that filter out unusable combinations, and the limits. For a walkthrough, see Give every participant different numbers.

Using a parameter

Write the parameter's name in curly brackets wherever the value should appear: What is {p}+{p}?. Parameters work in the question text, the answers, the options, hints, solutions and constraints, and in attachments.

In the question editor, parameters are under Parameters → Generated parameters → Manually defined. In an Excel or EDU upload and over the API, they go in one field, written as {name; TYPE; ...} and separated by &&&:

{a; INTEGER; 1; 5} &&& {b; INTEGER; -10; 10} &&& {d; FORMULA; {b}^2-4*{a}}

A parameter name starts with a letter and continues with letters, digits and underscores. Define a parameter before the parameters that use it.

Parameter types

Type Notation What it gives Example
FIX {name; FIX; value} A named constant, edited in one place. {g; FIX; 9.81}
INTEGER {name; INTEGER; min; max} A random whole number from min to max, inclusive. {n; INTEGER; 2; 10}
FLOAT {name; FLOAT; precision; min; max} A random decimal number with the given number of decimals (0 to 10). {m; FLOAT; 2; 0; 10}
FORMULA {name; FORMULA; formula; precision} A value calculated from other parameters. Precision is optional. {d; FORMULA; {b}^2-4*{a}*{c}}
LIST {name; LIST; value1; value2; ...} One value picked from the list. Values can be text. {metal; LIST; copper; iron; zinc}
PERMUTATION {name; PERMUTATION; value1; value2; ...} The values shuffled; {name_1}, {name_2} and so on give each position. {p; PERMUTATION; A; B; C; D}
FORMAT {name; FORMAT; parameter; type} Another parameter's value formatted for display. {r; FORMAT; n; ROMAN}

INTEGER and FLOAT ranges

Both types have a short and a full form:

Form INTEGER FLOAT
Any value {p; INTEGER} {p; FLOAT; 2}
Between min and max {p; INTEGER; 10; 20} {p; FLOAT; 2; 0; 1}
With inside and outside intervals {p; INTEGER; min; max; inside; outside} {p; FLOAT; precision; min; max; inside; outside}

Intervals are written as [from-to], several joined with |||. Use - for a field you leave out. {p; INTEGER; -; -; [10-20]; [12-14] ||| [16-18]} gives an integer from 10 to 20 that is not between 12 and 14 or between 16 and 18.

FORMAT types

Type Shows Example for 14
NUMBER The number, rounded to the decimals given as a fifth field {v; FORMAT; x; NUMBER; 1}
NUMBERTEXT The number written in words fourteen
ROMAN The number as a Roman numeral XIV

Synchronized LIST parameters

With Synchronize LIST set to Synchronize (parameters_sync=+ over the API), EduBase picks the same position from every LIST parameter. Each LIST must then have the same number of values.

Parameter Values
{animal; LIST; dog; penguin; snake} dog, penguin, snake
{legs; LIST; 4; 2; 0} 4, 2, 0

The question How many legs do {n} {animal}s have? with the answer {n}*{legs} always pairs the animal with its number of legs.

Inline formulas

A calculation between three tildes is evaluated without defining a parameter: ~~~{a}+{b}~~~ in the question text, an answer, an option, a hint or the solution shows the sum. The same formula used twice is calculated once.

A semicolon inside a value

Write \; for a semicolon that is part of a LIST or PERMUTATION value, so it is not read as a separator.

Constraints

Constraints are conditions every generated combination must meet. EduBase generates values until all constraints hold.

Under Constraints in the editor:

Option Effect
No constraints Values are used as generated.
Unique parameter values Every pair of parameters gets different values, except FORMULA parameters.
Manually defined Your own conditions, one per line.

Over the API and in uploads, constraints go in the constraints field, separated by &&&.

Write Meaning
<, <=, =, >=, >, <> The comparisons. \leq, \geq, \eq and \neq are accepted too.
{a}<{b}<{c} A chained comparison, read as two constraints.
+ - * / ^ and the functions of expression questions Calculations inside a constraint.

Examples:

  • {b}^2-4*{a}*{c}>0: the quadratic equation has two real roots.
  • {a}+{b}>{c} &&& {b}+{c}>{a} &&& {c}+{a}>{b}: the three sides form a triangle.
  • {x}<>{y}: two values differ.

When a question cannot be generated

EduBase tests a parameterized question automatically after it is saved. If generation fails in 10% of the attempts or more, because constraints are too tight or a formula cannot be evaluated, the question is marked INACTIVE with the note "The question could not be generated too many times during the automatic testing. Please check parameters and constraints." An inactive question is left out of the Quiz sets that contain it; the rest of the quiz works as before. Loosen the ranges or constraints and save again.

An upload with a parameter the parser cannot read (a wrong type name or the wrong number of fields) is rejected.

Limits

  • Up to 128 parameters per question; parameters beyond that are dropped.
  • Up to 64 values in a LIST or PERMUTATION parameter.
  • FLOAT, FORMULA and FORMAT precision: 0 to 10 decimals.
  • Complex functions in constraints slow generation down. Prefer narrowing a range to a constraint where both work.