Note: You are currently viewing documentation for Moodle 3.3. Up-to-date documentation for the latest stable version of Moodle is probably available here: Answer box placeholders.

Answer box placeholders: Difference between revisions

From MoodleDocs
No edit summary
No edit summary
Line 106: Line 106:


[https://docs.moodle.org/33/en/Formulas_question_type < Formulas question type]
[https://docs.moodle.org/33/en/Formulas_question_type < Formulas question type]
[[Category:Formulas question type]]

Revision as of 16:48, 8 December 2017


Answer box placeholders provide a simple way to arrange the answer boxes in the part's text. It is particularly useful when the subquestion requires more than one answer. This flexibility allows you to arrange the answer boxes in the form of a matrix, coordinates, embedding into the question text or any other way you want.

There are two answer box types: the quantity box and the unit box. The placeholder names are _0 for the first quantity box, _1 for the second quantity box, etc, and _u for the unit box. The number of placeholder names that can be used is the same as the number of elements entered in the answer field, plus one if the unit is specified.

Example

A subquestion that has two elements in the answer field and a common unit:

Main question
  Question text*       A formulas question with answer box placeholders
Part 1
  Part's mark*         1
  Answer type          Number
  Answer*              [100, 200]
  Grading criteria*    Absolute error == 0
  Unit                 mm
  Part's text          What are the coordinates of point A?
                       (x,y) = ({_0}, {_1}) {_u}

The formulas question should look like this, where the correct answers are 100 in the first box, 200 in the second box and mm in the third box:

FormulasDocumentation03a.png


Each answer box placeholder can only be used once in a part. For example, none of the following will be accepted:

  Part's text          {_0}{_0}             Comment: {_0} can not be used twice

  Part's text          {_0}{_1}{_1}         Comment: {_1} can not be used twice

  Part's text          {_0}{_u}{_1}{_u}     Comment: {_u} can not be used twice

  Part's text          {_3}{_3}             Comment: {_3} can not be used twice


The placeholder names do not have to appear in any particular order such as the increasing order {_0}{_1}{_2}...{_u}. The order of the quantity boxes and the unit box correspond to the order of the placeholder names in the part's text. For example, the following:

Part 1
 Answer*              [0, 100, 200, 300]
 Unit                 mm
 Part's text          {_2}{_0}{_3}{_u}{_1}

gives

En29FormulasDocumentation04.png

Neither do the answers have to be in increasing order and we would get exactly the same as above with the following:

Answer*              [200, 0, 300, 100]
Unit                 mm
Part's text          {_0}{_1}{_2}{_u}{_3}

By default, all missing placeholder are automatically appended at the end. That is {_0}{_u} for one answer subquestion, and {_0}{_1}{_u} for two answers subquestion.

The box {_0} corresponds to the special variable _0 in the Grading variables.

Quantity and unit boxes side by side or merged

When the quantity placeholder {_0} and the unit placeholder {_u} are directly side by side, such as {_0}{_u}, the quantity box and the unit box merge into a longer single answer box in which both quantity and unit must be entered.

When the quantity placeholder and the unit placeholder are not directly side by side, i.e. when they are separated by a space or any other string of characters, the answer boxes do not merge and hence they are displayed side by side.

Example

Answer with both quantity and unit:

Main question
  Question text*       What is 2 mm + 3 mm?
Part 1
  Part's mark*         1
  Answer type          Number
  Answer*              5
  Grading criteria*    Absolute error == 0
  Unit                 mm
  Part's text          {_0} {_u}  Separate placeholders give separate quantity and unit boxes.
Part 2
  Part's mark*         1
  Answer type          Number
  Answer*              5
  Grading criteria*    Absolute error == 0
  Unit                 mm
  Part's text          {_0}{_u}  Attached placeholders give a merged quantity and unit box.

The formulas question should look like this:

En29FormulasDocumentation05.png


< Formulas question type