Skip to content

Commit ba1e710

Browse files
committed
Merge branch 'iss1748' of https://github.com/maths/moodle-qtype_stack into iss1748
2 parents 08a0b37 + 57e2094 commit ba1e710

14 files changed

Lines changed: 96 additions & 12 deletions

File tree

doc/en/Authoring/Inputs/Input_options.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ min/max sf/dp | . | Y | Y | . | . | . | . | . |
2929
`consolidatesubscripts` | Y | . | Y | Y | Y | . | . | . | . | . | . | . | . | .
3030
`negpow` | . | . | Y | . | . | . | . | . | . | . | . | . | . | .
3131
`simp` | Y | Y | Y | Y | Y | . | . | . | . | Y | . | . | . | .
32-
`align` | Y | Y | Y | . | . | . | . | . | . | . | . | . | . | .
32+
`align` | Y | Y | Y | . | . | . | . | . | . | Y | Y | . | . | Y
3333
`nounits` | Y | Y | Y | Y | Y | Y | Y | Y | . | . | Y | . | . | .
3434
`checkvars` | Y | . | . | Y | Y | . | . | . | . | . | Y | . | . | .
3535
`validator` | Y | Y | Y | Y | Y | . | . | . | . | . | . | Y | . | Y
3636
`feedback` | Y | . | Y | Y | Y | . | . | . | . | . | . | . | . | .
37-
`monospace` | Y | Y | Y | . | Y | . | . | . | . | . | . | . | . | .
37+
`monospace` | Y | Y | Y | . | Y | . | . | . | . | Y | Y | . | . | Y
3838
`manualgraded` | Y | Y | Y | Y | Y | . | . | . | . | Y | Y | Y | Y | Y
3939

4040
For documentation about the various options not documented on this page look at the pages for the specific inputs in which each option is used.
@@ -149,7 +149,7 @@ Writing bespoke validators is an advanced feature, but offers two significant be
149149

150150
### Extra option: monospace ###
151151

152-
This option is available for algebraic, numerical, units and varmatrix inputs. It controls if the student's answer is displayed using monospace font. `monospace` and `monospace:true` will force the input to use monospace. `monospace:false` will force proportional font.
152+
This option is available for many inputs, including algebraic, numerical, units, varmatrix, textare, equiv and freetext. It controls if the student's answer is displayed using monospace font. `monospace` and `monospace:true` will force the input to use monospace. `monospace:false` will force proportional font.
153153

154154
If `monospace` is not specified, then the CURRENT system default for the given input type will be used when the question is displayed.
155155

doc/en/Developer/Development_track.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Issues with [github milestone 4.13.0](https://github.com/maths/moodle-qtype_stac
1414
3. Question tests can now test the whole route through a PRT, rather than just the final node. This is a significant improvement on the ability to test questions. This is back-compatible with older questions.
1515
4. Add in a new "free-text" input to allow student to input typed free-text proof.
1616
5. Allow most input types to use the extra option 'manualgraded'.
17+
6. Expand the use of "align" and "monospace" input options to textarea and equiv inputs.
1718

1819
## Better testing
1920

mobile.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,7 @@ table.HELM_table th:last-child {
11011101
.que.stack .equivinput,
11021102
.que.stack .varmatrixinput,
11031103
.que.stack .matrixtable,
1104+
.que.stack .freetextinput,
11041105
/* Question authoring form */
11051106
#page-question-type-stack textarea#id_questionvariables,
11061107
#page-question-type-stack input#id_variantsselectionseed,

samplequestions/stacklibrary/Features/input-type-sample-questions/Free-text_final_answer.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ ta2:4*sqrt(2*x^2+1)+1;
5555
<text>{@ta1@}</text>
5656
</questionnote>
5757
<questiondescription format="html">
58-
<text>[[todo]]Link ans2 automatically from the free-text input[[/todo]]</text>
58+
<text></text>
5959
</questiondescription>
6060
<questionsimplify>1</questionsimplify>
6161
<assumepositive>0</assumepositive>
@@ -95,7 +95,7 @@ ta2:4*sqrt(2*x^2+1)+1;
9595
<checkanswertype>0</checkanswertype>
9696
<mustverify>0</mustverify>
9797
<showvalidation>0</showvalidation>
98-
<options></options>
98+
<options>monospace:true</options>
9999
</input>
100100
<input>
101101
<name>ans2</name>

samplequestions/stacklibrary/Features/input-type-sample-questions/Free-text_input.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ The teacher's answer contains newline white space, ASCIImath, LaTeX, unicode etc
8585
<checkanswertype>0</checkanswertype>
8686
<mustverify>1</mustverify>
8787
<showvalidation>1</showvalidation>
88-
<options>manualgraded:true</options>
88+
<options>monospace:true</options>
8989
</input>
9090
<prt>
9191
<name>prt1</name>

stack/input/equiv/equiv.class.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class stack_equiv_input extends stack_input {
5454
'calculus' => false,
5555
'consolidatesubscripts' => false,
5656
'checkvars' => 0,
57+
'align' => 'left',
58+
'monospace' => false,
5759
'manualgraded' => false,
5860
];
5961

@@ -111,6 +113,13 @@ public function render(stack_input_state $state, $fieldname, $readonly, $tavalue
111113
'autocapitalize' => 'none',
112114
'spellcheck' => 'false',
113115
];
116+
if ($this->extraoptions['align'] === 'right') {
117+
$attributes['class'] .= ' algebraic-right';
118+
}
119+
if ($this->extraoptions['monospace']) {
120+
$attributes['class'] .= ' input-monospace';
121+
}
122+
114123
if ($placeholder) {
115124
$attributes['placeholder'] = $placeholder;
116125
}

stack/input/freetext/freetext.class.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class stack_freetext_input extends stack_string_input {
3333
'hideanswer' => false,
3434
'allowempty' => false,
3535
'validator' => false,
36+
'align' => 'left',
37+
'monospace' => false,
3638
'manualgraded' => true,
3739
];
3840

@@ -67,11 +69,18 @@ public function render(stack_input_state $state, $fieldname, $readonly, $tavalue
6769
// Note that at the moment, $this->boxHeight and $this->boxWidth are only
6870
// used as minimums. If the current input is bigger, the box is expanded.
6971
$attributes = [
72+
'class' => 'freetextinput',
7073
'name' => $fieldname,
7174
'id' => $fieldname,
7275
'autocapitalize' => 'none',
7376
'spellcheck' => 'false',
7477
];
78+
if ($this->extraoptions['align'] === 'right') {
79+
$attributes['class'] .= ' algebraic-right';
80+
}
81+
if ($this->extraoptions['monospace']) {
82+
$attributes['class'] .= ' input-monospace';
83+
}
7584

7685
$value = stack_utils::maxima_string_to_php_string($this->contents_to_maxima($state->contents));
7786
if ($this->is_blank_response($state->contents)) {
@@ -83,7 +92,7 @@ public function render(stack_input_state $state, $fieldname, $readonly, $tavalue
8392
}
8493

8594
// TODO: sort out size of text area.
86-
$attributes['rows'] = 3;
95+
$attributes['rows'] = 5;
8796
$attributes['cols'] = $this->parameters['boxWidth'];
8897

8998
if ($readonly) {

stack/input/textarea/textarea.class.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class stack_textarea_input extends stack_input {
3535
'nounits' => true,
3636
'simp' => false,
3737
'consolidatesubscripts' => false,
38+
'align' => 'left',
39+
'monospace' => false,
3840
'manualgraded' => false,
3941
];
4042

@@ -54,6 +56,12 @@ public function render(stack_input_state $state, $fieldname, $readonly, $tavalue
5456
'spellcheck' => 'false',
5557
'class' => 'maxima-list',
5658
];
59+
if ($this->extraoptions['align'] === 'right') {
60+
$attributes['class'] .= ' algebraic-right';
61+
}
62+
if ($this->extraoptions['monospace']) {
63+
$attributes['class'] .= ' input-monospace';
64+
}
5765

5866
if ($this->is_blank_response($state->contents)) {
5967
$current = $this->maxima_to_raw_input($this->parameters['syntaxHint']);

stack/options.class.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@ public static function get_monospace_options() {
386386
'1' => get_string('inputtypenumerical', 'qtype_stack'),
387387
'2' => get_string('inputtypeunits', 'qtype_stack'),
388388
'3' => get_string('inputtypevarmatrix', 'qtype_stack'),
389+
'4' => get_string('inputtypetextarea', 'qtype_stack'),
390+
'5' => get_string('inputtypeequiv', 'qtype_stack'),
391+
'6' => get_string('inputtypefreetext', 'qtype_stack'),
389392
];
390393
}
391394

@@ -405,6 +408,9 @@ public static function is_monospace($class) {
405408
'1' => 'numerical',
406409
'2' => 'units',
407410
'3' => 'varmatrix',
411+
'4' => 'textarea',
412+
'5' => 'equiv',
413+
'6' => 'freetext',
408414
];
409415
$optionkey = array_search(explode('_', $class)[1], $options);
410416
if ($optionkey === false) {

stack/prt.evaluatable.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public function get_answernotes($atnotes = true) {
273273
$i = 0;
274274
foreach ($path as $atresult) {
275275
if ($atnotes) {
276-
// Some answer test notes are non-empty whitespace string, e.g. " ";
276+
// Some answer test notes are a non-empty whitespace string, e.g. " ".
277277
$note = trim($atresult[2]);
278278
// Strip off "" and trim.
279279
$note = trim(substr($note, 1, strlen($note) - 2));

0 commit comments

Comments
 (0)