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: Formulas: Answer boxes.

Formulas: Answer boxes: Difference between revisions

From MoodleDocs
(Redirected page to Formulas question type)
 
Line 1: Line 1:
{{Formulas question type}}
#REDIRECT [[Formulas_question_type]]
 
=Note=
With the Formulas question, there are four types of answers: '''number''', '''numeric''', '''numerical formula''' and '''algebraic formula'''. The discussion below deals with the '''number''' answer, but also applies to other three types of answers. See [[Formulas:_Answers_and_marking|'''Answers and marking''']] for more details on the other types of answers.
 
The '''Number''' type answer allows students to input quantities. « The value of a quantity is generally expressed as the product of a number and a unit. » ([https://www.bipm.org/en/publications/si-brochure/download.html The International System of Units (SI), 8th edition, clause 1.1]). Hence, the '''Number''' type answer has two answer boxes: the number box and the unit box. If the quantity is dimensionless, the '''Number''' type answer has only the number box.
 
=Answer box placeholders=
 
Answer box placeholders provide a simple way to arrange the answer boxes in the part's text. It is particularly useful when the part 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.
 
For the '''Number''' type answer, there are two types of answer boxes: the ''number box'' and the ''unit box''. The placeholder names are <span style="font-family:monospace;font-size:113%;">_0</span> for the first number box, <span style="font-family:monospace;font-size:113%;">_1</span> for the second number box, etc, and <span style="font-family:monospace;font-size:113%;">_u</span> for the unit box. The number of placeholders that can be used is the same as the number of elements specified in the answer field, plus one if the unit is specified.
 
<div style="border:1px solid #bce8f1;border-radius:4px;padding: 0px 15px 0px; margin:20px 0 25px;">
<div style="font-family:Lucida Sans Unicode;font-size:150%;color:#f98012;margin:10px 0 10px;>Example</div>
 
A part that has two elements in the answer field and a common unit:
 
<pre style="font-size:113%;width: 97%;">
General
  Question name !      Two number and one unit answer boxes
Main question
  Question text !      Using answer box placeholders
                      Given: Point A is at position x = 100 mm and y = 200 mm.
Part 1
  Part's mark*        1
  Answer type          Number
  Answer*              [100, 200]
  Grading criteria*    Absolute error == 0
  Unit                mm
  Part's text          Question: What are the coordinates of point A? The answer must be given as follows: '(x,y) unit'.
                      A(x,y) = ({_0},{_1}) {_u}
</pre>
 
The formulas question should look like this:
 
[[File:FormulasDocumentation03a.png|680px]]
 
<div style="margin:20px 0 20px;">
<span style="background-color:#f98012;box-shadow: 0 5px 10px #cbcbcb;border: none;color:white;padding: 8px 16px;text-align:center;text-decoration: none;cursor:pointer;">[http://35.193.77.29/mod/quiz/view.php?id=143 <span style="color:white;">Play it </span>]</span>   [[Formulas_question_type#Examples|Login info]]  ''(Open in new tab: Ctrl+Shift+Click)''
</div>
 
</div>
 
''Each answer box placeholder can only be used once in a part.'' For example, none of the following will be accepted:
 
<pre style="font-size:113%;width: 97%;">
  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
</pre>
 
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 number boxes and the unit box correspond to the order of the placeholder names in the part's text. For example, the following:
 
<pre style="font-size:113%;width: 97%;">
Part 1
Answer*              [0, 100, 200, 300]
Unit                mm
Part's text          {_2}{_0}{_3}{_u}{_1}
</pre>
 
gives
 
[[File:En29FormulasDocumentation04.png|680px]]
 
Neither do the number answers have to be in increasing order, of course, and we would get exactly the same as above with the following:
 
<pre style="font-size:113%;width: 97%;">
Answer*              [200, 0, 300, 100]
Unit                mm
Part's text          {_0}{_1}{_2}{_u}{_3}
</pre>
 
By default, all missing placeholders are automatically appended at the end. For example, <span style="font-family:monospace;font-size:113%;">{_0}{_u}</span> for a one answer part and <span style="font-family:monospace;font-size:113%;">{_0}{_1}{_u}</span> for a two answer part.
 
The box <span style="font-family:monospace;font-size:113%;">{_0}</span> corresponds to the special variable <span style="font-family:monospace;font-size:113%;">_0</span> in the Grading variables.
 
=Quantity and unit boxes side by side or merged=
 
When the quantity placeholder <span style="font-family:monospace;font-size:113%;">{_0}</span> and the unit placeholder <span style="font-family:monospace;font-size:113%;">{_u}</span> are directly side by side, such as <span style="font-family:monospace;font-size:113%;">{_0}{_u}</span>, 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.
 
<div style="border:1px solid #bce8f1;border-radius:4px;padding: 0px 15px 0px; margin:20px 0 25px;">
<div style="font-family:Lucida Sans Unicode;font-size:150%;color:#f98012;margin:10px 0 10px;>Example</div>
 
Answer with both quantity and unit:
 
<pre style="font-size:113%;width: 97%;">
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.
</pre>
 
The formulas question should look like this:
 
[[File:En29FormulasDocumentation05.png|680px]]
 
<div style="margin:20px 0 20px;">
<span style="background-color:#f98012;box-shadow: 0 5px 10px #cbcbcb;border: none;color:white;padding: 8px 16px;text-align:center;text-decoration: none;cursor:pointer;">[http://35.193.77.29/mod/quiz/view.php?id=145 <span style="color:white;">Play it </span>]</span>   [[Formulas_question_type#Examples|Login info]]  ''(Open in new tab: Ctrl+Shift+Click)''
</div>
 
</div>
 
Note that the unit box can only be merged with the '''last''' quantity box of a part (if the part has several quantity boxes, of course). For example, {_0}{u} {_1} is invalid.
 
=Width of answer boxes=
 
The width of the number and unit boxes, both separate and merged, can be adjusted by modifying the width parameters in the <span style="font-family:monospace;font-size:113%;">styles.css</span> file for the Formulas question as shown below. This change can readily be done by your Moodle site administrator.
 
<code css>
 
/* Set the width of the unit box to 150px: */
input.formulas_unit {
    margin: 0.em 0 0 0;
    width : 150px;
}
 
/* Set the width of the quantity box to 130px: */
input.formulas_number {
    margin: 0.em 0 0 0;
    width : 130px;
}
 
/* Set the width of the box for merged quantity-unit to 250px: */
input.formulas_number_unit {
    margin: 0.em 0 0 0;
    width : 250px;
}
</code>
 
 
[[#top|Back to top of page]]
 
[https://docs.moodle.org/33/en/Formulas_question_type < Formulas question type]
 
=In other languages=
[https://docs.moodle.org/all/es/F%C3%B3rmulas:_Cajas_de_entrada Español]<br>
[https://docs.moodle.org/3x/fr/Formules:_Cases_de_réponse Français]

Latest revision as of 00:57, 1 February 2018