diff --git a/doc/en/Authoring/Multiple_choice_questions.md b/doc/en/Authoring/Multiple_choice_questions.md index 48f230b1513c0ce217d53e8a3514690108a3a59d..99c29a7d1d30fc78de3b943971f9b0daac5b7af2 100644 --- a/doc/en/Authoring/Multiple_choice_questions.md +++ b/doc/en/Authoring/Multiple_choice_questions.md @@ -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 diff --git a/doc/en/Developer/Parser.md b/doc/en/Developer/Parser.md index 61b8bdb7b409834efbf57cc30dd9e55b99f5bfeb..a994ccac92efc16313ba9920465f7b66db53485b 100644 --- a/doc/en/Developer/Parser.md +++ b/doc/en/Developer/Parser.md @@ -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. diff --git a/tests/input_checkbox_test.php b/tests/input_checkbox_test.php index 704c5c259a06202d6ba7565782169fb871352fee..fce294de001d14244a7fe4fb0fd811d1862b93c4 100644 --- a/tests/input_checkbox_test.php +++ b/tests/input_checkbox_test.php @@ -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)); + } }