diff --git a/question/engine/bank.php b/question/engine/bank.php index c239388d59194..5f01a2ece02e5 100644 --- a/question/engine/bank.php +++ b/question/engine/bank.php @@ -264,7 +264,6 @@ public static function load_question_data($questionid) { * @return question_definition loaded from the database. */ public static function load_question($questionid, $allowshuffle = true) { - global $DB; if (self::$testmode) { // Evil, test code in production, but no way round it. diff --git a/question/type/ddwtos/tests/helper.php b/question/type/ddwtos/tests/helper.php index ade05700c5f20..3ccd35bfd507e 100644 --- a/question/type/ddwtos/tests/helper.php +++ b/question/type/ddwtos/tests/helper.php @@ -34,7 +34,7 @@ */ class qtype_ddwtos_test_helper extends question_test_helper { public function get_test_questions() { - return array('fox', 'maths', 'oddgroups'); + return array('fox', 'maths', 'oddgroups', 'missingchoiceno'); } /** @@ -128,6 +128,31 @@ public function get_ddwtos_question_form_data_oddgroups() { return $fromform; } + /** + * Get data required to save a drag-drop into text question where the author + * missed out one of the group numbers. + * + * @return stdClass data to create a ddwtos question. + */ + public function get_ddwtos_question_form_data_missingchoiceno() { + $fromform = new stdClass(); + + $fromform->name = 'Drag-drop into text question with one index missing'; + $fromform->questiontext = ['text' => 'The [[1]] sat on the [[3]].', 'format' => FORMAT_HTML]; + $fromform->defaultmark = 1.0; + $fromform->generalfeedback = array('text' => 'The right answer is: "The cat sat on the mat."', 'format' => FORMAT_HTML); + $fromform->choices = array( + array('answer' => 'cat', 'choicegroup' => '1'), + array('answer' => '', 'choicegroup' => '1'), + array('answer' => 'mat', 'choicegroup' => '1'), + ); + test_question_maker::set_standard_combined_feedback_form_data($fromform); + $fromform->shownumcorrect = 0; + $fromform->penalty = 0.3333333; + + return $fromform; + } + /** * @return qtype_ddwtos_question */ diff --git a/question/type/ddwtos/tests/questiontype_test.php b/question/type/ddwtos/tests/questiontype_test.php index ded8ebef09451..ca7f562f0bd5e 100644 --- a/question/type/ddwtos/tests/questiontype_test.php +++ b/question/type/ddwtos/tests/questiontype_test.php @@ -117,6 +117,31 @@ public function test_can_analyse_responses() { $this->assertTrue($this->qtype->can_analyse_responses()); } + public function test_save_question() { + $this->resetAfterTest(); + + $syscontext = context_system::instance(); + /** @var core_question_generator $generator */ + $generator = $this->getDataGenerator()->get_plugin_generator('core_question'); + $category = $generator->create_question_category(['contextid' => $syscontext->id]); + + $fromform = test_question_maker::get_question_form_data('ddwtos', 'missingchoiceno'); + $fromform->category = $category->id . ',' . $syscontext->id; + + $question = new stdClass(); + $question->category = $category->id; + $question->qtype = 'ddwtos'; + $question->createdby = 0; + + $this->qtype->save_question($question, $fromform); + $q = question_bank::load_question($question->id); + // We just want to verify that this does not cause errors, + // but also verify some of the outcome. + $this->assertEquals('The [[1]] sat on the [[2]].', $q->questiontext); + $this->assertEquals([1 => 1, 2 => 1], $q->places); + $this->assertEquals([1 => 1, 2 => 2], $q->rightchoices); + } + public function test_initialise_question_instance() { $qdata = $this->get_test_question_data(); diff --git a/question/type/gapselect/questiontypebase.php b/question/type/gapselect/questiontypebase.php index de9f1493e74d1..86f4a3d5c1465 100644 --- a/question/type/gapselect/questiontypebase.php +++ b/question/type/gapselect/questiontypebase.php @@ -49,7 +49,35 @@ protected abstract function choice_options_to_feedback($choice); public function save_question_options($question) { global $DB; $context = $question->context; - $result = new stdClass(); + + // This question type needs the choices to be consecutively numbered, but + // there is no reason why the question author should have done that, + // so renumber if necessary. + // Insert all the new answers. + $nonblankchoices = []; + $questiontext = $question->questiontext; + $newkey = 0; + foreach ($question->choices as $key => $choice) { + if (trim($choice['answer']) == '') { + continue; + } + + $nonblankchoices[] = $choice; + if ($newkey != $key) { + // Safe to do this in this order, because we will always be replacing + // a bigger number with a smaller number that is not present. + // Numbers in the question text always one bigger than the array index. + $questiontext = str_replace('[[' . ($key + 1) . ']]', '[[' . ($newkey + 1) . ']]', + $questiontext); + } + $newkey += 1; + } + $question->choices = $nonblankchoices; + if ($questiontext !== $question->questiontext) { + $DB->set_field('question', 'questiontext', $questiontext, + ['id' => $question->id]); + $question->questiontext = $questiontext; + } $oldanswers = $DB->get_records('question_answers', array('question' => $question->id), 'id ASC'); @@ -57,14 +85,12 @@ public function save_question_options($question) { // Insert all the new answers. foreach ($question->choices as $key => $choice) { - if (trim($choice['answer']) == '') { - continue; - } + // Answer guaranteed to be non-blank. See above. $feedback = $this->choice_options_to_feedback($choice); if ($answer = array_shift($oldanswers)) { - $answer->answer = $choice['answer']; + $answer->answer = trim($choice['answer']); $answer->feedback = $feedback; $DB->update_record('question_answers', $answer); diff --git a/question/type/gapselect/tests/helper.php b/question/type/gapselect/tests/helper.php index faa98ebe07dbd..5907cc122c81e 100644 --- a/question/type/gapselect/tests/helper.php +++ b/question/type/gapselect/tests/helper.php @@ -32,12 +32,91 @@ * @copyright 2011 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class qtype_gapselect_test_helper { +class qtype_gapselect_test_helper extends question_test_helper { + + public function get_test_questions() { + return array('fox', 'maths', 'currency', 'multilang', 'missingchoiceno'); + } + + /** + * Get data you would get by loading a typical select missing words question. + * + * @return stdClass as returned by question_bank::load_question_data for this qtype. + */ + public static function get_gapselect_question_data_fox() { + global $USER; + + $gapselect = new stdClass(); + $gapselect->id = 0; + $gapselect->category = 0; + $gapselect->contextid = 0; + $gapselect->parent = 0; + $gapselect->questiontextformat = FORMAT_HTML; + $gapselect->generalfeedbackformat = FORMAT_HTML; + $gapselect->defaultmark = 1; + $gapselect->penalty = 0.3333333; + $gapselect->length = 1; + $gapselect->stamp = make_unique_id_code(); + $gapselect->version = make_unique_id_code(); + $gapselect->hidden = 0; + $gapselect->idnumber = null; + $gapselect->timecreated = time(); + $gapselect->timemodified = time(); + $gapselect->createdby = $USER->id; + $gapselect->modifiedby = $USER->id; + + $gapselect->name = 'Selection from drop down list question'; + $gapselect->questiontext = 'The [[1]] brown [[2]] jumped over the [[3]] dog.'; + $gapselect->generalfeedback = 'This sentence uses each letter of the alphabet.'; + $gapselect->qtype = 'gapselect'; + + $gapselect->options = new stdClass(); + $gapselect->options->shuffleanswers = true; + + test_question_maker::set_standard_combined_feedback_fields($gapselect->options); + + $gapselect->options->answers = array( + (object) array('answer' => 'quick', 'feedback' => '1'), + (object) array('answer' => 'fox', 'feedback' => '2'), + (object) array('answer' => 'lazy', 'feedback' => '3'), + (object) array('answer' => 'assiduous', 'feedback' => '3'), + (object) array('answer' => 'dog', 'feedback' => '2'), + (object) array('answer' => 'slow', 'feedback' => '1'), + ); + + return $gapselect; + } + + /** + * Get data required to save a select missing words question where + * the author missed out one of the group numbers. + * + * @return stdClass data to create a gapselect question. + */ + public function get_gapselect_question_form_data_missingchoiceno() { + $fromform = new stdClass(); + + $fromform->name = 'Select missing words question'; + $fromform->questiontext = ['text' => 'The [[1]] sat on the [[3]].', 'format' => FORMAT_HTML]; + $fromform->defaultmark = 1.0; + $fromform->generalfeedback = ['text' => 'The right answer is: "The cat sat on the mat."', 'format' => FORMAT_HTML]; + $fromform->choices = [ + ['answer' => 'cat', 'choicegroup' => '1'], + ['answer' => '', 'choicegroup' => '1'], + ['answer' => 'mat', 'choicegroup' => '1'], + ]; + test_question_maker::set_standard_combined_feedback_form_data($fromform); + $fromform->shownumcorrect = 0; + $fromform->penalty = 0.3333333; + + return $fromform; + } + /** * Get an example gapselect question to use for testing. This examples has one of each item. * @return qtype_gapselect_question */ - public static function make_a_gapselect_question() { + public static function make_gapselect_question_fox() { question_bank::load_question_definition_classes('gapselect'); $gapselect = new qtype_gapselect_question(); @@ -75,7 +154,7 @@ public static function make_a_gapselect_question() { * Get an example gapselect question to use for testing. This exmples had unlimited items. * @return qtype_gapselect_question */ - public static function make_a_maths_gapselect_question() { + public static function make_gapselect_question_maths() { question_bank::load_question_definition_classes('gapselect'); $gapselect = new qtype_gapselect_question(); @@ -93,10 +172,10 @@ public static function make_a_maths_gapselect_question() { $gapselect->choices = array( 1 => array( - 1 => new qtype_gapselect_choice('+', 1, true), - 2 => new qtype_gapselect_choice('-', 1, true), - 3 => new qtype_gapselect_choice('*', 1, true), - 4 => new qtype_gapselect_choice('/', 1, true), + 1 => new qtype_gapselect_choice('+', 1), + 2 => new qtype_gapselect_choice('-', 1), + 3 => new qtype_gapselect_choice('*', 1), + 4 => new qtype_gapselect_choice('/', 1), )); $gapselect->places = array(1 => 1, 2 => 1, 3 => 1, 4 => 1); @@ -110,7 +189,7 @@ public static function make_a_maths_gapselect_question() { * Get an example gapselect question with multilang entries to use for testing. * @return qtype_gapselect_question */ - public static function make_a_multilang_gapselect_question() { + public static function make_gapselect_question_multilang() { question_bank::load_question_definition_classes('gapselect'); $gapselect = new qtype_gapselect_question(); @@ -129,14 +208,14 @@ public static function make_a_multilang_gapselect_question() { $gapselect->choices = array( 1 => array( 1 => new qtype_gapselect_choice('catкошка', 1, true), + 'class="multilang">кошка', 1), 2 => new qtype_gapselect_choice('dogпес', 1, true)), + 'class="multilang">пес', 1)), 2 => array( 1 => new qtype_gapselect_choice('matковрике', 2, true), + 'class="multilang">коврике', 2), 2 => new qtype_gapselect_choice('batбита', 2, true)) + 'class="multilang">бита', 2)) ); $gapselect->places = array(1 => 1, 2 => 2); @@ -151,7 +230,7 @@ public static function make_a_multilang_gapselect_question() { * This examples includes choices with currency like options. * @return qtype_gapselect_question */ - public static function make_a_currency_gapselect_question() { + public static function make_gapselect_question_currency() { question_bank::load_question_definition_classes('gapselect'); $gapselect = new qtype_gapselect_question(); @@ -181,4 +260,48 @@ public static function make_a_currency_gapselect_question() { return $gapselect; } + + /** + * Just for backwards compatibility. + * + * @return qtype_gapselect_question + */ + public static function make_a_gapselect_question() { + debugging('qtype_gapselect_test_helper::make_a_gapselect_question is deprecated. ' . + "Please use test_question_maker::make_question('gapselect') instead."); + return self::make_gapselect_question_fox(); + } + + /** + * Just for backwards compatibility. + * + * @return qtype_gapselect_question + */ + public static function make_a_maths_gapselect_question() { + debugging('qtype_gapselect_test_helper::make_a_maths_gapselect_question is deprecated. ' . + "Please use test_question_maker::make_question('gapselect', 'maths') instead."); + return self::make_gapselect_question_maths(); + } + + /** + * Just for backwards compatibility. + * + * @return qtype_gapselect_question + */ + public static function make_a_currency_gapselect_question() { + debugging('qtype_gapselect_test_helper::make_a_currency_gapselect_question is deprecated. ' . + "Please use test_question_maker::make_question('gapselect', 'currency') instead."); + return self::make_gapselect_question_currency(); + } + + /** + * Just for backwards compatibility. + * + * @return qtype_gapselect_question + */ + public static function make_a_multilang_gapselect_question() { + debugging('qtype_gapselect_test_helper::make_a_multilang_gapselect_question is deprecated. ' . + "Please use test_question_maker::make_question('gapselect', 'multilang') instead."); + return self::make_gapselect_question_multilang(); + } } diff --git a/question/type/gapselect/tests/question_test.php b/question/type/gapselect/tests/question_test.php index a4377825c6036..4bfdfd6554fdb 100644 --- a/question/type/gapselect/tests/question_test.php +++ b/question/type/gapselect/tests/question_test.php @@ -39,21 +39,21 @@ class qtype_gapselect_question_test extends basic_testcase { public function test_get_question_summary() { - $gapselect = qtype_gapselect_test_helper::make_a_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect'); $this->assertEquals('The [[1]] brown [[2]] jumped over the [[3]] dog.; ' . '[[1]] -> {quick / slow}; [[2]] -> {fox / dog}; [[3]] -> {lazy / assiduous}', $gapselect->get_question_summary()); } public function test_get_question_summary_maths() { - $gapselect = qtype_gapselect_test_helper::make_a_maths_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect', 'maths'); $this->assertEquals('Fill in the operators to make this equation work: ' . '7 [[1]] 11 [[2]] 13 [[1]] 17 [[2]] 19 = 3; [[1]] -> {+ / - / * / /}', $gapselect->get_question_summary()); } public function test_summarise_response() { - $gapselect = qtype_gapselect_test_helper::make_a_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -62,7 +62,7 @@ public function test_summarise_response() { } public function test_summarise_response_maths() { - $gapselect = qtype_gapselect_test_helper::make_a_maths_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect', 'maths'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -71,17 +71,17 @@ public function test_summarise_response_maths() { } public function test_get_random_guess_score() { - $gapselect = qtype_gapselect_test_helper::make_a_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect'); $this->assertEquals(0.5, $gapselect->get_random_guess_score()); } public function test_get_random_guess_score_maths() { - $gapselect = qtype_gapselect_test_helper::make_a_maths_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect', 'maths'); $this->assertEquals(0.25, $gapselect->get_random_guess_score()); } public function test_get_right_choice_for() { - $gapselect = qtype_gapselect_test_helper::make_a_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -90,7 +90,7 @@ public function test_get_right_choice_for() { } public function test_get_right_choice_for_maths() { - $gapselect = qtype_gapselect_test_helper::make_a_maths_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect', 'maths'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -99,7 +99,7 @@ public function test_get_right_choice_for_maths() { } public function test_clear_wrong_from_response() { - $gapselect = qtype_gapselect_test_helper::make_a_maths_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect', 'maths'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -109,7 +109,7 @@ public function test_clear_wrong_from_response() { } public function test_get_num_parts_right() { - $gapselect = qtype_gapselect_test_helper::make_a_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -120,7 +120,7 @@ public function test_get_num_parts_right() { } public function test_get_num_parts_right_maths() { - $gapselect = qtype_gapselect_test_helper::make_a_maths_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect', 'maths'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -129,7 +129,7 @@ public function test_get_num_parts_right_maths() { } public function test_get_expected_data() { - $gapselect = qtype_gapselect_test_helper::make_a_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect'); $gapselect->start_attempt(new question_attempt_step(), 1); $this->assertEquals(array('p1' => PARAM_INT, 'p2' => PARAM_INT, 'p3' => PARAM_INT), @@ -137,7 +137,7 @@ public function test_get_expected_data() { } public function test_get_correct_response() { - $gapselect = qtype_gapselect_test_helper::make_a_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -146,7 +146,7 @@ public function test_get_correct_response() { } public function test_get_correct_response_maths() { - $gapselect = qtype_gapselect_test_helper::make_a_maths_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect', 'maths'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -155,7 +155,7 @@ public function test_get_correct_response_maths() { } public function test_is_same_response() { - $gapselect = qtype_gapselect_test_helper::make_a_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect'); $gapselect->start_attempt(new question_attempt_step(), 1); $this->assertTrue($gapselect->is_same_response( @@ -179,7 +179,7 @@ public function test_is_same_response() { array('p1' => '1', 'p2' => '2', 'p3' => '2'))); } public function test_is_complete_response() { - $gapselect = qtype_gapselect_test_helper::make_a_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect'); $gapselect->start_attempt(new question_attempt_step(), 1); $this->assertFalse($gapselect->is_complete_response(array())); @@ -191,7 +191,7 @@ public function test_is_complete_response() { } public function test_is_gradable_response() { - $gapselect = qtype_gapselect_test_helper::make_a_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect'); $gapselect->start_attempt(new question_attempt_step(), 1); $this->assertFalse($gapselect->is_gradable_response(array())); @@ -205,7 +205,7 @@ public function test_is_gradable_response() { } public function test_grading() { - $gapselect = qtype_gapselect_test_helper::make_a_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -218,7 +218,7 @@ public function test_grading() { } public function test_grading_maths() { - $gapselect = qtype_gapselect_test_helper::make_a_maths_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect', 'maths'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); @@ -231,7 +231,7 @@ public function test_grading_maths() { } public function test_classify_response() { - $gapselect = qtype_gapselect_test_helper::make_a_gapselect_question(); + $gapselect = test_question_maker::make_question('gapselect'); $gapselect->shufflechoices = false; $gapselect->start_attempt(new question_attempt_step(), 1); diff --git a/question/type/gapselect/tests/questiontype_test.php b/question/type/gapselect/tests/questiontype_test.php index 6eea6cbdfa320..88ccadf28af63 100644 --- a/question/type/gapselect/tests/questiontype_test.php +++ b/question/type/gapselect/tests/questiontype_test.php @@ -27,7 +27,6 @@ global $CFG; require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); -require_once($CFG->dirroot . '/question/type/gapselect/tests/helper.php'); /** @@ -41,7 +40,7 @@ class qtype_gapselect_test extends question_testcase { protected $qtype; protected function setUp() { - $this->qtype = question_bank::get_qtype('gapselect');; + $this->qtype = question_bank::get_qtype('gapselect'); } protected function tearDown() { @@ -50,61 +49,47 @@ protected function tearDown() { /** * Asserts that two strings containing XML are the same ignoring the line-endings. - * @param unknown $expectedxml - * @param unknown $xml + * + * @param string $expectedxml + * @param string $xml */ public function assert_same_xml($expectedxml, $xml) { $this->assertEquals(str_replace("\r\n", "\n", $expectedxml), str_replace("\r\n", "\n", $xml)); } + public function test_save_question() { + $this->resetAfterTest(); + + $syscontext = context_system::instance(); + /** @var core_question_generator $generator */ + $generator = $this->getDataGenerator()->get_plugin_generator('core_question'); + $category = $generator->create_question_category(['contextid' => $syscontext->id]); + + $fromform = test_question_maker::get_question_form_data('gapselect', 'missingchoiceno'); + $fromform->category = $category->id . ',' . $syscontext->id; + + $question = new stdClass(); + $question->category = $category->id; + $question->qtype = 'gapselect'; + $question->createdby = 0; + + $this->qtype->save_question($question, $fromform); + $q = question_bank::load_question($question->id); + // We just want to verify that this does not cause errors, + // but also verify some of the outcome. + $this->assertEquals('The [[1]] sat on the [[2]].', $q->questiontext); + $this->assertEquals([1 => 1, 2 => 1], $q->places); + $this->assertEquals([1 => 1, 2 => 2], $q->rightchoices); + } + /** * Get some test question data. * @return object the data to construct a question like - * {@link qtype_gapselect_test_helper::make_a_gapselect_question()}. + * {@link test_question_maker::make_question('gapselect')}. */ protected function get_test_question_data() { - global $USER; - - $gapselect = new stdClass(); - $gapselect->id = 0; - $gapselect->category = 0; - $gapselect->contextid = 0; - $gapselect->parent = 0; - $gapselect->questiontextformat = FORMAT_HTML; - $gapselect->generalfeedbackformat = FORMAT_HTML; - $gapselect->defaultmark = 1; - $gapselect->penalty = 0.3333333; - $gapselect->length = 1; - $gapselect->stamp = make_unique_id_code(); - $gapselect->version = make_unique_id_code(); - $gapselect->hidden = 0; - $gapselect->idnumber = null; - $gapselect->timecreated = time(); - $gapselect->timemodified = time(); - $gapselect->createdby = $USER->id; - $gapselect->modifiedby = $USER->id; - - $gapselect->name = 'Selection from drop down list question'; - $gapselect->questiontext = 'The [[1]] brown [[2]] jumped over the [[3]] dog.'; - $gapselect->generalfeedback = 'This sentence uses each letter of the alphabet.'; - $gapselect->qtype = 'gapselect'; - - $gapselect->options = new stdClass(); - $gapselect->options->shuffleanswers = true; - - test_question_maker::set_standard_combined_feedback_fields($gapselect->options); - - $gapselect->options->answers = array( - (object) array('answer' => 'quick', 'feedback' => '1'), - (object) array('answer' => 'fox', 'feedback' => '2'), - (object) array('answer' => 'lazy', 'feedback' => '3'), - (object) array('answer' => 'assiduous', 'feedback' => '3'), - (object) array('answer' => 'dog', 'feedback' => '2'), - (object) array('answer' => 'slow', 'feedback' => '1'), - ); - - return $gapselect; + return test_question_maker::get_question_data('gapselect'); } public function test_name() { @@ -118,7 +103,7 @@ public function test_can_analyse_responses() { public function test_initialise_question_instance() { $qdata = $this->get_test_question_data(); - $expected = qtype_gapselect_test_helper::make_a_gapselect_question(); + $expected = test_question_maker::make_question('gapselect'); $expected->stamp = $qdata->stamp; $expected->version = $qdata->version; diff --git a/question/type/gapselect/tests/walkthrough_test.php b/question/type/gapselect/tests/walkthrough_test.php index ba9ea8ed7abcb..89e2fa8589b1d 100644 --- a/question/type/gapselect/tests/walkthrough_test.php +++ b/question/type/gapselect/tests/walkthrough_test.php @@ -40,7 +40,7 @@ class qtype_gapselect_walkthrough_test extends qbehaviour_walkthrough_test_base public function test_interactive_behaviour() { // Create a gapselect question. - $q = qtype_gapselect_test_helper::make_a_gapselect_question(); + $q = test_question_maker::make_question('gapselect'); $q->hints = array( new question_hint_with_parts(1, 'This is the first hint.', FORMAT_HTML, false, false), new question_hint_with_parts(2, 'This is the second hint.', FORMAT_HTML, true, true), @@ -160,7 +160,7 @@ public function test_multilang_behaviour() { $filtermanager->reset_caches(); // Create a multilang gapselect question. - $q = qtype_gapselect_test_helper::make_a_multilang_gapselect_question(); + $q = test_question_maker::make_question('gapselect', 'multilang'); $q->shufflechoices = false; $this->start_attempt_at_question($q, 'interactive', 3); @@ -177,7 +177,7 @@ public function test_multilang_behaviour() { public function test_choices_containing_dollars() { // Choices with a currency like entry (e.g. $3) should display. - $q = qtype_gapselect_test_helper::make_a_currency_gapselect_question(); + $q = test_question_maker::make_question('gapselect', 'currency'); $q->shufflechoices = false; $this->start_attempt_at_question($q, 'interactive', 1); diff --git a/question/type/questiontypebase.php b/question/type/questiontypebase.php index 5c353f87b9104..21c00ecc812c2 100644 --- a/question/type/questiontypebase.php +++ b/question/type/questiontypebase.php @@ -323,9 +323,9 @@ public function set_default_options($questiondata) { * is accurate any more.) */ public function save_question($question, $form) { - global $USER, $DB, $OUTPUT; + global $USER, $DB; - // The actuall update/insert done with multiple DB access, so we do it in a transaction. + // The actual update/insert done with multiple DB access, so we do it in a transaction. $transaction = $DB->start_delegated_transaction (); list($question->category) = explode(',', $form->category);