diff --git a/question/behaviour/informationitem/simpletest/testwalkthrough.php b/question/behaviour/informationitem/simpletest/testwalkthrough.php index 3b14ff8dc64..68b70867b78 100644 --- a/question/behaviour/informationitem/simpletest/testwalkthrough.php +++ b/question/behaviour/informationitem/simpletest/testwalkthrough.php @@ -41,7 +41,7 @@ class qbehaviour_informationitem_walkthrough_test extends qbehaviour_walkthrough public function test_informationitem_feedback_description() { // Create a true-false question with correct answer true. - $description = test_question_maker::make_a_description_question(); + $description = test_question_maker::make_question('description'); $this->start_attempt_at_question($description, 'deferredfeedback'); // Check the initial state. diff --git a/question/engine/simpletest/helpers.php b/question/engine/simpletest/helpers.php index 39fb6bf35b6..e771c00997f 100644 --- a/question/engine/simpletest/helpers.php +++ b/question/engine/simpletest/helpers.php @@ -297,24 +297,6 @@ class test_question_maker { return $essay; } - /** - * Makes a truefalse question with correct ansewer true, defaultmark 1. - * @return question_truefalse - */ - public static function make_a_description_question() { - question_bank::load_question_definition_classes('description'); - $description = new qtype_description_question(); - self::initialise_a_question($description); - $description->name = 'Description question'; - $description->questiontext = - 'This text tells you a bit about the next few questions in this quiz.'; - $description->generalfeedback = - 'This is what this section of the quiz should have taught you.'; - $description->qtype = question_bank::get_qtype('description'); - - return $description; - } - /** * Add some standard overall feedback to a question. You need to use these * specific feedback strings for the corresponding contains_..._feedback diff --git a/question/engine/simpletest/testquestionattempt.php b/question/engine/simpletest/testquestionattempt.php index 86d590e424f..13873368837 100644 --- a/question/engine/simpletest/testquestionattempt.php +++ b/question/engine/simpletest/testquestionattempt.php @@ -47,7 +47,7 @@ class question_attempt_test extends UnitTestCase { private $qa; public function setUp() { - $this->question = test_question_maker::make_a_description_question(); + $this->question = test_question_maker::make_question('description'); $this->question->defaultmark = 3; $this->usageid = 13; $this->qa = new question_attempt($this->question, $this->usageid); @@ -141,7 +141,7 @@ class question_attempt_with_steps_test extends UnitTestCase { private $qa; public function setUp() { - $this->question = test_question_maker::make_a_description_question(); + $this->question = test_question_maker::make_question('description'); $this->qa = new testable_question_attempt($this->question, 0, null, 2); for ($i = 0; $i < 3; $i++) { $step = new question_attempt_step(array('i' => $i)); diff --git a/question/engine/simpletest/testquestionattemptiterator.php b/question/engine/simpletest/testquestionattemptiterator.php index bf20264e50a..ca372056ef5 100644 --- a/question/engine/simpletest/testquestionattemptiterator.php +++ b/question/engine/simpletest/testquestionattemptiterator.php @@ -46,10 +46,10 @@ class question_attempt_iterator_test extends UnitTestCase { get_context_instance(CONTEXT_SYSTEM)); $this->quba->set_preferred_behaviour('deferredfeedback'); - $slot = $this->quba->add_question(test_question_maker::make_a_description_question()); + $slot = $this->quba->add_question(test_question_maker::make_question('description')); $this->qas[$slot] = $this->quba->get_question_attempt($slot); - $slot = $this->quba->add_question(test_question_maker::make_a_description_question()); + $slot = $this->quba->add_question(test_question_maker::make_question('description')); $this->qas[$slot] = $this->quba->get_question_attempt($slot); $this->iterator = $this->quba->get_attempt_iterator(); diff --git a/question/engine/simpletest/testquestionattemptstepiterator.php b/question/engine/simpletest/testquestionattemptstepiterator.php index 910476b862f..9a06348cedd 100644 --- a/question/engine/simpletest/testquestionattemptstepiterator.php +++ b/question/engine/simpletest/testquestionattemptstepiterator.php @@ -41,7 +41,7 @@ class question_attempt_step_iterator_test extends UnitTestCase { private $iterator; public function setUp() { - $question = test_question_maker::make_a_description_question(); + $question = test_question_maker::make_question('description'); $this->qa = new testable_question_attempt($question, 0); for ($i = 0; $i < 3; $i++) { $step = new question_attempt_step(array('i' => $i)); diff --git a/question/type/description/simpletest/helper.php b/question/type/description/simpletest/helper.php new file mode 100755 index 00000000000..d571b5d8119 --- /dev/null +++ b/question/type/description/simpletest/helper.php @@ -0,0 +1,93 @@ +. + +/** + * Test helper code for the description question type. + * + * @package qtype + * @subpackage description + * @copyright 2010 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + + +defined('MOODLE_INTERNAL') || die(); + + +/** + * Test helper class for the description question type. + * + * @copyright 2010 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class qtype_description_test_helper extends question_test_helper { + public function get_test_questions() { + return array('info'); + } + + /** + * @return qtype_description_question + */ + public static function make_description_question_info() { + question_bank::load_question_definition_classes('description'); + $q = new qtype_description_question(); + + test_question_maker::initialise_a_question($q); + $q->defaultmark = 0; + $q->penalty = 0; + $q->length = 0; + + $q->name = 'Description'; + $q->questiontext = 'Here is some information about the questions you are about to attempt.'; + $q->generalfeedback = 'And here is some more text shown only on the review page.'; + $q->qtype = question_bank::get_qtype('description'); + + return $q; + } + + /** + * Get the question data, as it would be loaded by get_question_options, for + * the question returned by {@link make_an_oumultiresponse_two_of_four()}. + * @return object + */ + public static function get_question_data() { + global $USER; + + $qdata = new stdClass(); + $qdata->id = 0; + $qdata->contextid = 0; + $qdata->category = 0; + $qdata->parent = 0; + $qdata->stamp = make_unique_id_code(); + $qdata->version = make_unique_id_code(); + $qdata->timecreated = time(); + $qdata->timemodified = time(); + $qdata->createdby = $USER->id; + $qdata->modifiedby = $USER->id; + $qdata->qtype = 'description'; + $qdata->name = 'Description'; + $qdata->questiontext = 'Here is some information about the questions you are about to attempt.'; + $qdata->questiontextformat = FORMAT_HTML; + $qdata->generalfeedback = 'And here is some more text shown only on the review page.'; + $qdata->generalfeedbackformat = FORMAT_HTML; + $qdata->defaultmark = 0; + $qdata->length = 0; + $qdata->penalty = 0; + $qdata->hidden = 0; + + return $qdata; + } +}