Skip to content
Snippets Groups Projects
Commit fe3917f2 authored by Tim Hunt's avatar Tim Hunt
Browse files

Make stack questions work with more Moodle behaviours.

1. Unit tests and changes to make it work with deferred CBM.
2. Unit tests to prove that immediate feedback behaviour works.
3. No unit tests for immediate feedback with CBM, but I am pretty sure
that works too.

Sadly 1. means that stack now requires another qusetion behaviour to be
installed.
parent 6e0808cf
No related branches found
No related tags found
No related merge requests found
...@@ -49,9 +49,9 @@ At this point STACK will be "ready" for use with students, although not all feat ...@@ -49,9 +49,9 @@ At this point STACK will be "ready" for use with students, although not all feat
3. Make STACK respect all Moodle behaviours. 3. Make STACK respect all Moodle behaviours.
1. **DONE** Deferred feedback 1. **DONE** Deferred feedback
2. **DONE** Interactive 2. **DONE** Interactive
3. Deferred feedback with CBM 3. **DONE** Deferred feedback with CBM
4. Immediate feedback 4. **DONE** Immediate feedback
5. Immediate feedback with CBM 5. **DONE** Immediate feedback with CBM - no unit tests, but if the others work, this one must.
4. Add back in all input types, including dragmath/NUMBAS. 4. Add back in all input types, including dragmath/NUMBAS.
5. Add sample_questions, and update question banks for STACK 3.0. 5. Add sample_questions, and update question banks for STACK 3.0.
6. Link the STACK documentation to Moodle's help icons on the editing form, etc. 6. Link the STACK documentation to Moodle's help icons on the editing form, etc.
......
...@@ -15,11 +15,12 @@ Maxima can be [downloaded](http://maxima.sourceforge.net/download.html) as a sel ...@@ -15,11 +15,12 @@ Maxima can be [downloaded](http://maxima.sourceforge.net/download.html) as a sel
installer program for Windows, RPMs for Linux or as source for all platforms. Maxima and installer program for Windows, RPMs for Linux or as source for all platforms. Maxima and
GNUPlot will install themselves in suitable directories. GNUPlot will install themselves in suitable directories.
## 3. Add the Deferred feedback with explicit validation question behaviour question behaviour ## 3. Add some additional question behaviours
STACK uses this question behaviour. STACK requries these.
1. Obtain the code. Either [download the zip file](https://github.com/timhunt/moodle-qbehaviour_dfexplicitvaildate/zipball/master), unzip it, and place it in the directory `moodle\question\behaviour\dfexplicitvaildate`. (You will need to rename the directory `moodle-qbehaviour_dfexplicitvaildate -> dfexplicitvaildate`.) Alternatively, get the code using git by running the following command in the top level folder of your Moodle install: `git clone git://github.com/timhunt/moodle-qbehaviour_dfexplicitvaildate.git question/behaviour/dfexplicitvaildate`. 1. Obtain Deferred feedback with explicit validation behaviour code. Either [download the zip file](https://github.com/timhunt/moodle-qbehaviour_dfexplicitvaildate/zipball/master), unzip it, and place it in the directory `moodle\question\behaviour\dfexplicitvaildate`. (You will need to rename the directory `moodle-qbehaviour_dfexplicitvaildate -> dfexplicitvaildate`.) Alternatively, get the code using git by running the following command in the top level folder of your Moodle install: `git clone git://github.com/timhunt/moodle-qbehaviour_dfexplicitvaildate.git question/behaviour/dfexplicitvaildate`.
1. Obtain Deferred feedback with CBM and explicit validation behaviour code. Either [download the zip file](https://github.com/timhunt/moodle-qbehaviour_dfcbmexplicitvaildate/zipball/master), unzip it, and place it in the directory `moodle\question\behaviour\dfcbmexplicitvaildate`. (You will need to rename the directory `moodle-qbehaviour_dfcbmexplicitvaildate -> dfcbmexplicitvaildate`.) Alternatively, get the code using git by running the following command in the top level folder of your Moodle install: `git clone git://github.com/timhunt/moodle-qbehaviour_dfcbmexplicitvaildate.git question/behaviour/dfcbmexplicitvaildate`.
2. Login to Moodle as the admin user and click on Notifications in the Site Administration panel. 2. Login to Moodle as the admin user and click on Notifications in the Site Administration panel.
## 4. Add the STACK question type ## 4. Add the STACK question type
......
...@@ -179,6 +179,10 @@ class qtype_stack_question extends question_graded_automatically_with_countback ...@@ -179,6 +179,10 @@ class qtype_stack_question extends question_graded_automatically_with_countback
return question_engine::make_behaviour('dfexplicitvaildate', $qa, $preferredbehaviour); return question_engine::make_behaviour('dfexplicitvaildate', $qa, $preferredbehaviour);
} }
if ($preferredbehaviour == 'deferredcbm' && $this->any_inputs_require_validation()) {
return question_engine::make_behaviour('dfcbmexplicitvaildate', $qa, $preferredbehaviour);
}
return parent::make_behaviour($qa, $preferredbehaviour); return parent::make_behaviour($qa, $preferredbehaviour);
} }
......
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains tests that walk Stack questions through various sequences
* of student interaction with deferred feedback with CBM behaviour.
*
* @package qtype_stack
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->libdir . '/questionlib.php');
require_once(dirname(__FILE__) . '/test_base.php');
/**
* Unit tests for the Stack question type.
*
* Note that none of these tests include clicking the 'Check' button that
* dfexplicitvaldiation provies. That is because that button is simply @author tjh238
* way to trigger a save without navigating to a different page of the quiz.
*
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @group qtype_stack
*/
class qtype_stack_walkthrough_deferred_cbm_test extends qtype_stack_walkthrough_test_base {
public function test_test3_save_answers_to_all_parts_and_stubmit() {
// Create a stack question.
$q = test_question_maker::make_question('stack', 'test3');
$this->start_attempt_at_question($q, 'deferredcbm', 12);
// Check the right behaviour is used.
$this->assertEquals('dfcbmexplicitvaildate', $this->quba->get_question_attempt($this->slot)->get_behaviour_name());
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->render();
$this->check_output_contains_text_input('ans1');
$this->check_output_contains_text_input('ans2');
$this->check_output_contains_text_input('ans3');
$this->check_output_does_not_contain_input_validation();
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), '', true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
// Save a partially correct response. No certainty, so low will be assumed.
$this->process_submission(array('ans1' => 'x^3', 'ans2' => 'x^2', 'ans3' => 'x', 'ans4' => 'false'));
$this->check_current_state(question_state::$invalid);
$this->check_current_mark(null);
$this->render();
$this->check_output_contains_text_input('ans1', 'x^3');
$this->check_output_contains_text_input('ans2', 'x^2');
$this->check_output_contains_text_input('ans3', 'x');
$this->check_output_contains_input_validation('ans1');
$this->check_output_contains_input_validation('ans2');
$this->check_output_contains_input_validation('ans3');
$this->check_output_does_not_contain_input_validation('ans4');
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), 'false', true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
// Submit all and finish.
$this->quba->finish_all_questions();
$this->check_current_state(question_state::$gradedpartial);
$this->check_current_mark(2.5);
$this->render();
$this->check_output_contains_text_input('ans1', 'x^3', false);
$this->check_output_contains_text_input('ans2', 'x^2', false);
$this->check_output_contains_text_input('ans3', 'x', false);
$this->check_output_contains_input_validation('ans1');
$this->check_output_contains_input_validation('ans2');
$this->check_output_contains_input_validation('ans3');
$this->check_output_does_not_contain_input_validation('ans4');
$this->check_output_contains_prt_feedback('odd');
$this->check_output_contains_prt_feedback('even');
$this->check_output_contains_prt_feedback('oddeven');
$this->check_output_contains_prt_feedback('unique');
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), 'false', false),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
}
public function test_test3_save_answers_to_all_parts_confirm_valid_and_stubmit() {
// Create a stack question.
$q = test_question_maker::make_question('stack', 'test3');
$this->start_attempt_at_question($q, 'deferredfeedback', 12);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->render();
$this->check_output_contains_text_input('ans1');
$this->check_output_contains_text_input('ans2');
$this->check_output_contains_text_input('ans3');
$this->check_output_does_not_contain_input_validation();
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), '', true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
// Save a correct response, high certainty.
$this->process_submission(array('ans1' => 'x^3', 'ans2' => 'x^2', 'ans3' => '0', 'ans4' => 'true', '-certainty' => 3));
$this->check_current_state(question_state::$invalid);
$this->check_current_mark(null);
$this->render();
$this->check_output_contains_text_input('ans1', 'x^3');
$this->check_output_contains_text_input('ans2', 'x^2');
$this->check_output_contains_text_input('ans3', '0');
$this->check_output_contains_input_validation('ans1');
$this->check_output_contains_input_validation('ans2');
$this->check_output_contains_input_validation('ans3');
$this->check_output_does_not_contain_input_validation('ans4');
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), 'true', true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
// Save a confirmation this is valid.
$this->process_submission(array('ans1' => 'x^3', 'ans2' => 'x^2', 'ans3' => '0', 'ans4' => 'true',
'ans1_val' => 'x^3', 'ans2_val' => 'x^2', 'ans3_val' => '0', '-certainty' => 3));
$this->check_current_state(question_state::$complete);
$this->check_current_mark(null);
$this->render();
$this->check_output_contains_text_input('ans1', 'x^3');
$this->check_output_contains_text_input('ans2', 'x^2');
$this->check_output_contains_text_input('ans3', '0');
$this->check_output_contains_input_validation('ans1');
$this->check_output_contains_input_validation('ans2');
$this->check_output_contains_input_validation('ans3');
$this->check_output_does_not_contain_input_validation('ans4');
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), 'true', true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
// Submit all and finish.
$this->quba->finish_all_questions();
$this->check_current_state(question_state::$gradedright);
$this->check_current_mark(12);
$this->render();
$this->check_output_contains_text_input('ans1', 'x^3', false);
$this->check_output_contains_text_input('ans2', 'x^2', false);
$this->check_output_contains_text_input('ans3', '0', false);
$this->check_output_contains_input_validation('ans1');
$this->check_output_contains_input_validation('ans2');
$this->check_output_contains_input_validation('ans3');
$this->check_output_does_not_contain_input_validation('ans4');
$this->check_output_contains_prt_feedback('odd');
$this->check_output_contains_prt_feedback('even');
$this->check_output_contains_prt_feedback('oddeven');
$this->check_output_contains_prt_feedback('unique');
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), 'true', false),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
}
public function test_test3_save_partially_complete_and_partially_invalid_response_then_stubmit() {
// Create a stack question.
$q = test_question_maker::make_question('stack', 'test3');
$this->start_attempt_at_question($q, 'deferredfeedback', 4);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->render();
$this->check_output_contains_text_input('ans1');
$this->check_output_contains_text_input('ans2');
$this->check_output_contains_text_input('ans3');
$this->check_output_does_not_contain_input_validation();
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), '', true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
// Save a partially correct response.
$this->process_submission(array('ans1' => 'x^3', 'ans2' => '(x +', 'ans3' => '', 'ans4' => 'true'));
$this->check_current_state(question_state::$invalid);
$this->check_current_mark(null);
$this->render();
$this->check_output_contains_text_input('ans1', 'x^3');
$this->check_output_contains_text_input('ans2', '(x +');
$this->check_output_contains_text_input('ans3', '');
$this->check_output_contains_input_validation('ans1');
$this->check_output_contains_input_validation('ans2');
$this->check_output_does_not_contain_input_validation('ans3');
$this->check_output_does_not_contain_input_validation('ans4');
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), 'false', true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
// Submit all and finish.
$this->quba->finish_all_questions();
$this->check_current_state(question_state::$gradedpartial);
$this->check_current_mark(2);
$this->render();
$this->check_output_contains_text_input('ans1', 'x^3', false);
$this->check_output_contains_text_input('ans2', '(x +', false);
$this->check_output_contains_text_input('ans3', '', false);
$this->check_output_contains_input_validation('ans1');
$this->check_output_contains_input_validation('ans2');
$this->check_output_does_not_contain_input_validation('ans3');
$this->check_output_does_not_contain_input_validation('ans4');
$this->check_output_contains_prt_feedback('odd');
$this->check_output_does_not_contain_prt_feedback('even');
$this->check_output_does_not_contain_prt_feedback('oddeven');
$this->check_output_contains_prt_feedback('unique');
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), 'false', false),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
}
public function test_test3_save_completely_blank_response_then_stubmit() {
// Create a stack question.
$q = test_question_maker::make_question('stack', 'test3');
$this->start_attempt_at_question($q, 'deferredfeedback', 4);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->render();
$this->check_output_contains_text_input('ans1');
$this->check_output_contains_text_input('ans2');
$this->check_output_contains_text_input('ans3');
$this->check_output_does_not_contain_input_validation();
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), '', true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
// Try to save a blank response. This should not even create a new step..
$this->process_submission(array('ans1' => '', 'ans2' => '', 'ans3' => '', 'ans4' => ''));
$this->assertEquals(1, $this->quba->get_question_attempt($this->slot)->get_num_steps());
// Submit all and finish.
$this->quba->finish_all_questions();
$this->check_current_state(question_state::$gaveup);
$this->check_current_mark(null);
$this->render();
$this->check_output_contains_text_input('ans1', '', false);
$this->check_output_contains_text_input('ans2', '', false);
$this->check_output_contains_text_input('ans3', '', false);
$this->check_output_does_not_contain_input_validation();
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), '', false),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
}
public function test_test0_no_validation_required() {
// Create a stack question - we use test0, then replace the input with
// a dropdown, to get a question that does not require validation.
$q = test_question_maker::make_question('stack', 'test0');
$q->inputs['ans1'] = stack_input_factory::make(
'dropdown', 'ans1', '2', array('ddl_values' => '1,2'));
$this->start_attempt_at_question($q, 'deferredcbm', 3);
// Check the right behaviour is used.
$this->assertEquals('deferredcbm', $this->quba->get_question_attempt($this->slot)->get_behaviour_name());
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->render();
$this->check_output_does_not_contain_input_validation();
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans1', array('' => stack_string('notanswered'), '1' => '1', '2' => '2'), null, true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
// Save a correct response, medium certainty.
$this->process_submission(array('ans1' => '2', '-certainty' => 2));
$this->check_current_state(question_state::$complete);
$this->check_current_mark(null);
$this->render();
$this->check_output_does_not_contain_input_validation();
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans1', array('' => stack_string('notanswered'), '1' => '1', '2' => '2'), '2', true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
// Submit all and finish.
$this->quba->finish_all_questions();
$this->check_current_state(question_state::$gradedright);
$this->check_current_mark(2);
$this->render();
$this->check_output_does_not_contain_input_validation();
$this->check_output_contains_prt_feedback('firsttree');
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans1', array('' => stack_string('notanswered'), '1' => '1', '2' => '2'), '2', false),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
}
}
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
/** /**
* This file contains tests that walk Stack questions through various sequences * This file contains tests that walk Stack questions through various sequences
* of student interaction with different behaviours. * of student interaction with deferred feedback behaviour.
* *
* @package qtype_stack * @package qtype_stack
* @copyright 2012 The Open University * @copyright 2012 The Open University
......
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains tests that walk Stack questions through various sequences
* of student interaction using the immediate feedback behaviour.
*
* @package qtype_stack
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->libdir . '/questionlib.php');
require_once(dirname(__FILE__) . '/test_base.php');
/**
* Unit tests for the Stack question type with the immediate feedback behaviour.
*
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @group qtype_stack
*/
class qtype_stack_walkthrough_immediate_feedback_test extends qtype_stack_walkthrough_test_base {
public function test_test3_partially_right_the_right() {
// Create a stack question.
$q = test_question_maker::make_question('stack', 'test3');
$this->start_attempt_at_question($q, 'immediatefeedback', 4);
// Check the right behaviour is used.
$this->assertEquals('immediatefeedback', $this->quba->get_question_attempt($this->slot)->get_behaviour_name());
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->render();
$this->check_output_contains_text_input('ans1');
$this->check_output_contains_text_input('ans2');
$this->check_output_contains_text_input('ans3');
$this->check_output_does_not_contain_input_validation();
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), '', true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
// Save a partially correct response for validation.
$this->process_submission(array('ans1' => 'x^3', 'ans2' => 'x^2', 'ans3' => 'x', 'ans4' => 'false',
'-submit' => 1));
$this->check_current_state(question_state::$invalid);
$this->check_current_mark(null);
$this->render();
$this->check_output_contains_text_input('ans1', 'x^3');
$this->check_output_contains_text_input('ans2', 'x^2');
$this->check_output_contains_text_input('ans3', 'x');
$this->check_output_contains_input_validation('ans1');
$this->check_output_contains_input_validation('ans2');
$this->check_output_contains_input_validation('ans3');
$this->check_output_does_not_contain_input_validation('ans4');
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), 'false', true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
// Re-submit after validation validation.
$this->process_submission(array('ans1' => 'x^3', 'ans2' => 'x^2', 'ans3' => 'x', 'ans4' => 'false',
'ans1_val' => 'x^3', 'ans2_val' => 'x^2', 'ans3_val' => 'x', '-submit' => 1));
$this->check_current_state(question_state::$gradedpartial);
$this->check_current_mark(2.5);
$this->render();
$this->check_output_contains_text_input('ans1', 'x^3', false);
$this->check_output_contains_text_input('ans2', 'x^2', false);
$this->check_output_contains_text_input('ans3', 'x', false);
$this->check_output_contains_input_validation('ans1');
$this->check_output_contains_input_validation('ans2');
$this->check_output_contains_input_validation('ans3');
$this->check_output_does_not_contain_input_validation('ans4');
$this->check_output_contains_prt_feedback('odd');
$this->check_output_contains_prt_feedback('even');
$this->check_output_contains_prt_feedback('oddeven');
$this->check_output_contains_prt_feedback('unique');
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), 'false', false),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
}
public function test_test3_sumbit_and_finish_before_validating() {
// Create a stack question.
$q = test_question_maker::make_question('stack', 'test3');
$this->start_attempt_at_question($q, 'immediatefeedback', 4);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->render();
$this->check_output_contains_text_input('ans1');
$this->check_output_contains_text_input('ans2');
$this->check_output_contains_text_input('ans3');
$this->check_output_does_not_contain_input_validation();
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), '', true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
// Save a partially correct, partially complete response.
$this->process_submission(array('ans1' => 'x^3', 'ans2' => 'x^2', 'ans3' => 'x', 'ans4' => ''));
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->render();
$this->check_output_contains_text_input('ans1', 'x^3');
$this->check_output_contains_text_input('ans2', 'x^2');
$this->check_output_contains_text_input('ans3', 'x');
$this->check_output_contains_input_validation('ans1');
$this->check_output_contains_input_validation('ans2');
$this->check_output_contains_input_validation('ans3');
$this->check_output_does_not_contain_input_validation('ans4');
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), 'false', true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
// Submit all and finish before validating.
$this->quba->finish_all_questions();
$this->check_current_state(question_state::$gradedpartial);
$this->check_current_mark(2.5);
$this->render();
$this->check_output_contains_text_input('ans1', 'x^3', false);
$this->check_output_contains_text_input('ans2', 'x^2', false);
$this->check_output_contains_text_input('ans3', 'x', false);
$this->check_output_contains_input_validation('ans1');
$this->check_output_contains_input_validation('ans2');
$this->check_output_contains_input_validation('ans3');
$this->check_output_does_not_contain_input_validation('ans4');
$this->check_output_contains_prt_feedback('odd');
$this->check_output_contains_prt_feedback('even');
$this->check_output_contains_prt_feedback('oddeven');
$this->check_output_does_not_contain_prt_feedback('unique');
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), '', false),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
}
public function test_test3_save_invalid_response_correct_then_stubmit() {
// Create a stack question.
$q = test_question_maker::make_question('stack', 'test3');
$this->start_attempt_at_question($q, 'immediatefeedback', 4);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->render();
$this->check_output_contains_text_input('ans1');
$this->check_output_contains_text_input('ans2');
$this->check_output_contains_text_input('ans3');
$this->check_output_does_not_contain_input_validation();
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), '', true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
// Submit a partially correct response.
$this->process_submission(array('ans1' => 'x^3', 'ans2' => '(x +', 'ans3' => '0', 'ans4' => 'true', '-submit' => 1));
$this->check_current_state(question_state::$invalid);
$this->check_current_mark(null);
$this->render();
$this->check_output_contains_text_input('ans1', 'x^3');
$this->check_output_contains_text_input('ans2', '(x +');
$this->check_output_contains_text_input('ans3', '0');
$this->check_output_contains_input_validation('ans1');
$this->check_output_contains_input_validation('ans2');
$this->check_output_contains_input_validation('ans3');
$this->check_output_does_not_contain_input_validation('ans4');
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), 'false', true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
// Try to submit again without editing. Shoud not be accepted.
$this->process_submission(array('ans1' => 'x^3', 'ans2' => '(x +', 'ans3' => '0', 'ans4' => 'true',
'ans1_val' => 'x^3', 'ans3_val' => '0', '-submit' => 1));
$this->check_current_state(question_state::$invalid);
$this->check_current_mark(null);
$this->render();
$this->check_output_contains_text_input('ans1', 'x^3');
$this->check_output_contains_text_input('ans2', '(x +');
$this->check_output_contains_text_input('ans3', '0');
$this->check_output_contains_input_validation('ans1');
$this->check_output_contains_input_validation('ans2');
$this->check_output_contains_input_validation('ans3');
$this->check_output_does_not_contain_input_validation('ans4');
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), 'false', true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
// Now fix the resonse and submit. Should only be validated.
$this->process_submission(array('ans1' => 'x^3', 'ans2' => 'x^2', 'ans3' => '0', 'ans4' => 'true',
'ans1_val' => 'x^3', 'ans3_val' => '0', '-submit' => 1));
$this->check_current_state(question_state::$invalid);
$this->check_current_mark(null);
$this->render();
$this->check_output_contains_text_input('ans1', 'x^3');
$this->check_output_contains_text_input('ans2', 'x^2');
$this->check_output_contains_text_input('ans3', '0');
$this->check_output_contains_input_validation('ans1');
$this->check_output_contains_input_validation('ans2');
$this->check_output_contains_input_validation('ans3');
$this->check_output_does_not_contain_input_validation('ans4');
$this->check_output_does_not_contain_prt_feedback();
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), 'false', true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
//Submit again. Should now be graded.
$this->process_submission(array('ans1' => 'x^3', 'ans2' => 'x^2', 'ans3' => '0', 'ans4' => 'true',
'ans1_val' => 'x^3', 'ans2_val' => 'x^2', 'ans3_val' => '0', '-submit' => 1));
$this->check_current_state(question_state::$gradedright);
$this->check_current_mark(4);
$this->render();
$this->check_output_contains_text_input('ans1', 'x^3', false);
$this->check_output_contains_text_input('ans2', 'x^2', false);
$this->check_output_contains_text_input('ans3', '0', false);
$this->check_output_contains_input_validation('ans1');
$this->check_output_contains_input_validation('ans2');
$this->check_output_contains_input_validation('ans3');
$this->check_output_does_not_contain_input_validation('ans4');
$this->check_output_contains_prt_feedback('odd');
$this->check_output_contains_prt_feedback('even');
$this->check_output_contains_prt_feedback('oddeven');
$this->check_output_contains_prt_feedback('unique');
$this->check_output_does_not_contain_stray_placeholders();
$this->check_current_output(
$this->get_contains_select_expectation('ans4', stack_boolean_input::get_choices(), 'false', false),
$this->get_does_not_contain_num_parts_correct(),
$this->get_no_hint_visible_expectation()
);
}
}
...@@ -24,12 +24,13 @@ ...@@ -24,12 +24,13 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->version = 2012051600; $plugin->version = 2012051700;
$plugin->requires = 2012020200; $plugin->requires = 2012020200;
$plugin->cron = 0; $plugin->cron = 0;
$plugin->component = 'qtype_stack'; $plugin->component = 'qtype_stack';
$plugin->maturity = MATURITY_ALPHA; $plugin->maturity = MATURITY_ALPHA;
$plugin->dependencies = array( $plugin->dependencies = array(
'qbehaviour_dfexplicitvaildate' => 2012051600 'qbehaviour_dfexplicitvaildate' => 2012051600,
'qbehaviour_dfcbmexplicitvaildate' => 2012051600,
); );
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment