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

Fix to issue #1072: decimal separator in lists should respect decimals setting.

parent 62f4bb95
No related branches found
No related tags found
No related merge requests found
......@@ -1488,7 +1488,7 @@ class MP_List extends MP_Node {
return $indent . '[' . implode(', ', $ar) . ']';
}
return '[' . implode(',', $ar) . ']';
return '[' . implode($sep, $ar) . ']';
}
public function replace($node, $with) {
......
......@@ -1027,4 +1027,21 @@ class ast_container_test extends qtype_stack_testcase {
$this->assertEquals($t3['last-seen'], false);
}
public function test_teacher_answer_decimals() {
// This tests the functions which generate "The teacher's answer is".
$s = '{4.4,4}';
$at1 = stack_ast_container::make_from_teacher_source($s, '', new stack_cas_security());
$at1->set_nounify(0);
$this->assertTrue($at1->get_valid());
$this->assertEquals('', $at1->get_errors());
$this->assertEquals($at1->get_inputform(true, 0, true, ','), '{4,4;4}');
$s = '[4.4,4]';
$at1 = stack_ast_container::make_from_teacher_source($s, '', new stack_cas_security());
$at1->set_nounify(0);
$this->assertTrue($at1->get_valid());
$this->assertEquals('', $at1->get_errors());
$this->assertEquals($at1->get_inputform(true, 0, true, ','), '[4,4;4]');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment