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

Add test-case related to issue #1189.

parent 4acf3596
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,13 @@ When STACK displays the "teacher's answer", e.g. after a quiz is due, this will
If you need "none of these" you must include this as an explicit option, and not rely on the student not checking any boxes in the checkbox type. Indeed, it would be impossible to distinguish the active selection of "none of these" from a passive failure to respond to the question.
If one of the responses is \(x=1 \text{ or } x=2\) then it is probably best to use `nounor` which is commutative and associative. Do not use `or` which always simplifies its arguments. In this example `x=1 or x=2` evaluates to `false`.
## Model answer: nouns ##
If one of the responses is \(x=1 \text{ or } x=2\) then use `nounor` which is commutative and associative. Do not use `or` which always simplifies its arguments. In this example `x=1 or x=2` evaluates to `false`.
Functions `diff` and `int` will evaluate, so you don't have displayed calculus operation. If one of the responses is a _displayed_ derivative or integral then construct your answer with Maxima's inert forms `'diff` and `'int`.
## Model answer: LaTeX display in dropdowns ##
HTML dropdowns cannot display LaTeX within the options. This is a restriction of HTML/MathJax (not of STACK). You can use HTML-entities within a string field. For example
......
......@@ -53,9 +53,7 @@ We give each parser rule a name, numbered in the approximate appropriate order i
There are two separate classes of expressions which need to be protected as "nouns".
1. The Maxima Boolean functions do not respect `simp:false`. So, we have parallel operators such as `A nounand B`. These should always be used when connecting to Maxima. Evaluation/simplification of Boolean expressions such as `true and false` is done on the Maxima side. Teachers and students should use `and`, etc. and these are always translated into an evaluation form.
2. With `simp:false` we still have evaluation of expressions such as `diff(x^3,x)` to `3*x^2`. To protect student's answers ("Your last answer was..") we have parallel noun forms such as `noundiff` and `nounint`. Note, some of these also change the display of expressions.
3. Maxima uses the apostophie to create noun forms, e.g. `'diff(x^3,x)`. From STACK 4.3, teachers are able to use this.
2. Maxima uses the apostophie to create noun forms, e.g. `'diff(x^3,x)`. Teachers are able to use this, and it is the preferred route.
3. We retain parallel noun forms such as `noundiff` and `nounint` for back-compatibility. Note, some of these also change the display of expressions.
......@@ -490,4 +490,30 @@ class input_checkbox_test extends qtype_stack_testcase {
'\left( 2,\, 3\right)\)</span></span></li></ul>';
$this->assertEquals($expected, $el->get_teacher_answer_display(false, false));
}
public function test_noundiff() {
$options = new stack_options();
$ta = '[[noundiff(f,x),true],[nounint(f,t),false]]';
$el = stack_input_factory::make('checkbox', 'ans1', $ta, null, array('options' => ''));
$expected = '<div class="answer"><div class="option"><input type="checkbox" name="stack1__ans1_1" ' .
'value="1" id="stack1__ans1_1" checked="checked" /><label for="stack1__ans1_1"><span ' .
'class="filter_mathjaxloader_equation"><span class="nolink">\(\frac{\mathrm{d} f}{\mathrm{d} x}\)' .
'</span></span></label></div><div class="option"><input type="checkbox" name="stack1__ans1_2" ' .
'value="2" id="stack1__ans1_2" /><label for="stack1__ans1_2"><span class="filter_mathjaxloader_equation">' .
'<span class="nolink">\(\int {f}{\;\mathrm{d}t}\)</span></span></label></div></div>';
$this->assertEquals($expected, $el->render(new stack_input_state(
stack_input::SCORE, array('1'), '', '', '', '', ''), 'stack1__ans1', false, array()));
$state = $el->validate_student_response(array('ans1_1' => '1'),
$options, $ta, new stack_cas_security());
$this->assertEquals(stack_input::SCORE, $state->status);
$this->assertEquals(array('1'), $state->contents);
$this->assertEquals('[noundiff(f,x)]', $state->contentsmodified);
$this->assertEquals($ta, $el->get_teacher_answer());
$el->adapt_to_model_answer($ta);
$expected = 'A correct answer is: <ul><li><span class="filter_mathjaxloader_equation"><span class="nolink">' .
'\(\frac{\mathrm{d} f}{\mathrm{d} x}\)</span></span></li></ul>';
$this->assertEquals($expected, $el->get_teacher_answer_display(false, false));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment