Skip to content
Snippets Groups Projects
Commit c436aa42 authored by Chris Sangwin's avatar Chris Sangwin
Browse files

Fix to issue #1057: syntax hint in matrix inputs.

parent 6df3a391
Branches
No related tags found
No related merge requests found
......@@ -159,7 +159,7 @@ class stack_matrix_input extends stack_input {
// @codingStandardsIgnoreEnd
$rows = $this->modinput_tokenizer(substr($t, 7, -1));
for ($i = 0; $i < count($rows); $i++) {
$row = $this->modinput_tokenizer(substr($rows[$i], 1, -1));
$row = $this->modinput_tokenizer(substr(trim($rows[$i]), 1, -1));
$tc[$i] = $row;
}
}
......
......@@ -120,6 +120,28 @@ class input_matrix_test extends qtype_stack_testcase {
'ans1', false, null));
}
public function test_render_syntax_hint_spaces() {
$options = new stack_options();
$el = stack_input_factory::make('matrix', 'ans1', 'M', $options);
$el->set_parameter('syntaxHint', 'matrix([a,b], [?,d])');
$el->adapt_to_model_answer('matrix([1,0],[0,1])');
$this->assertEquals('<div class="matrixsquarebrackets"><table class="matrixtable" id="ans1_container" ' .
'style="display:inline; vertical-align: middle;" cellpadding="1" cellspacing="0"><tbody><tr>' .
'<td style="padding-top: 0.5em">&nbsp;</td>' .
'<td><input type="text" id="ans1_sub_0_0" name="ans1_sub_0_0" value="a" size="5" ' .
'autocapitalize="none" spellcheck="false"></td>' .
'<td><input type="text" id="ans1_sub_0_1" name="ans1_sub_0_1" value="b" size="5" ' .
'autocapitalize="none" spellcheck="false"></td>' .
'<td style="padding-top: 0.5em">&nbsp;</td></tr><tr><td>&nbsp;</td>' .
'<td><input type="text" id="ans1_sub_1_0" name="ans1_sub_1_0" value="?" size="5" ' .
'autocapitalize="none" spellcheck="false"></td>' .
'<td><input type="text" id="ans1_sub_1_1" name="ans1_sub_1_1" value="d" size="5" ' .
'autocapitalize="none" spellcheck="false"></td>' .
'<td style="padding-bottom: 0.5em">&nbsp;</td></tr></tbody></table></div>',
$el->render(new stack_input_state(stack_input::VALID, array(), '', '', '', '', ''),
'ans1', false, null));
}
public function test_render_syntax_hint_round() {
$options = new stack_options();
$options->set_option('matrixparens', '(');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment