diff --git a/mod/lesson/format.php b/mod/lesson/format.php index 9eb2c1829b6..d75134026d1 100644 --- a/mod/lesson/format.php +++ b/mod/lesson/format.php @@ -387,14 +387,6 @@ class qformat_default { $newpage->contents = $question->questiontext; $newpage->contentsformat = isset($question->questionformat) ? $question->questionformat : FORMAT_HTML; - // Sometimes, questiontext is not a simple text, but one array - // containing both text and format, so we need to support here - // that case with the following dirty patch. MDL-35147 - if (is_array($question->questiontext)) { - $newpage->contents = isset($question->questiontext['text']) ? $question->questiontext['text'] : ''; - $newpage->contentsformat = isset($question->questiontext['format']) ? $question->questiontext['format'] : FORMAT_HTML; - } - // set up page links if ($pageid) { // the new page follows on from this page diff --git a/question/format.php b/question/format.php index 13c12329cc2..811e9bc58f3 100644 --- a/question/format.php +++ b/question/format.php @@ -413,20 +413,11 @@ class qformat_default { 'maxfiles' => -1, 'maxbytes' => 0, ); - if (is_array($question->questiontext)) { - // Importing images from draftfile. - $questiontext = $question->questiontext; - $question->questiontext = $questiontext['text']; - } - if (is_array($question->generalfeedback)) { - $generalfeedback = $question->generalfeedback; - $question->generalfeedback = $generalfeedback['text']; - } $question->id = $DB->insert_record('question', $question); - if (!empty($questiontext['itemid'])) { - $question->questiontext = file_save_draft_area_files($questiontext['itemid'], + if (isset($question->questiontextitemid)) { + $question->questiontext = file_save_draft_area_files($question->questiontextitemid, $this->importcontext->id, 'question', 'questiontext', $question->id, $fileoptions, $question->questiontext); } else if (isset($question->questiontextfiles)) { @@ -435,8 +426,8 @@ class qformat_default { $this->importcontext, 'question', 'questiontext', $question->id, $file); } } - if (!empty($generalfeedback['itemid'])) { - $question->generalfeedback = file_save_draft_area_files($generalfeedback['itemid'], + if (isset($question->generalfeedbackitemid)) { + $question->generalfeedback = file_save_draft_area_files($question->generalfeedbackitemid, $this->importcontext->id, 'question', 'generalfeedback', $question->id, $fileoptions, $question->generalfeedback); } else if (isset($question->generalfeedbackfiles)) { diff --git a/question/format/blackboard_six/formatbase.php b/question/format/blackboard_six/formatbase.php index da08e913551..4424f5f055e 100644 --- a/question/format/blackboard_six/formatbase.php +++ b/question/format/blackboard_six/formatbase.php @@ -148,16 +148,4 @@ class qformat_blackboard_six_base extends qformat_based_on_xml { public function cleaned_text_field($text) { return $this->text_field($this->cleaninput($text)); } - - /** - * Convert the question text to plain text. - * We need to overwrite this function because questiontext is an array. - */ - protected function format_question_text($question) { - global $DB; - $formatoptions = new stdClass(); - $formatoptions->noclean = true; - return html_to_text(format_text($question->questiontext['text'], - $question->questiontext['format'], $formatoptions), 0, false); - } } diff --git a/question/format/blackboard_six/formatpool.php b/question/format/blackboard_six/formatpool.php index a6c942c5212..7911305489b 100644 --- a/question/format/blackboard_six/formatpool.php +++ b/question/format/blackboard_six/formatpool.php @@ -88,12 +88,16 @@ class qformat_blackboard_six_pool extends qformat_blackboard_six_base { array('#', 'BODY', 0, '#', 'TEXT', 0, '#'), '', true, get_string('importnotext', 'qformat_blackboard_six')); - $question->questiontext = $this->cleaned_text_field($text); - $question->questiontextformat = FORMAT_HTML; // Needed because add_blank_combined_feedback uses it. + $questiontext = $this->cleaned_text_field($text); + $question->questiontext = $questiontext['text']; + $question->questiontextformat = $questiontext['format']; // Needed because add_blank_combined_feedback uses it. + if (isset($questiontext['itemid'])) { + $question->questiontextitemid = $questiontext['itemid']; + } // Put name in question object. We must ensure it is not empty and it is less than 250 chars. $id = $this->getpath($questiondata, array('@', 'id'), '', true); - $question->name = $this->create_default_question_name($question->questiontext['text'], + $question->name = $this->create_default_question_name($question->questiontext, get_string('defaultname', 'qformat_blackboard_six' , $id)); $question->generalfeedback = ''; @@ -453,7 +457,7 @@ class qformat_blackboard_six_pool extends qformat_blackboard_six_base { $subanswercount++; } if ($subquestioncount < 2 || $subanswercount < 3) { - $this->error(get_string('notenoughtsubans', 'qformat_blackboard_six', $question->questiontext['text'])); + $this->error(get_string('notenoughtsubans', 'qformat_blackboard_six', $question->questiontext)); } else { $questions[] = $question; } diff --git a/question/format/blackboard_six/formatqti.php b/question/format/blackboard_six/formatqti.php index 37545fd3020..6b9eddafbbf 100644 --- a/question/format/blackboard_six/formatqti.php +++ b/question/format/blackboard_six/formatqti.php @@ -506,11 +506,13 @@ class qformat_blackboard_six_qti extends qformat_blackboard_six_base { public function process_common($quest) { $question = $this->defaultquestion(); $text = $quest->QUESTION_BLOCK->text; - - $question->questiontext = $this->cleaned_text_field($text); - $question->questiontextformat = FORMAT_HTML; // Needed because add_blank_combined_feedback uses it. - - $question->name = $this->create_default_question_name($question->questiontext['text'], + $questiontext = $this->cleaned_text_field($text); + $question->questiontext = $questiontext['text']; + $question->questiontextformat = $questiontext['format']; // Needed because add_blank_combined_feedback uses it. + if (isset($questiontext['itemid'])) { + $question->questiontextitemid = $questiontext['itemid']; + } + $question->name = $this->create_default_question_name($question->questiontext, get_string('defaultname', 'qformat_blackboard_six' , $quest->id)); $question->generalfeedback = ''; $question->generalfeedbackformat = FORMAT_HTML; @@ -863,7 +865,7 @@ class qformat_blackboard_six_qti extends qformat_blackboard_six_base { $subanswercount++; } if ($subquestioncount < 2 || $subanswercount < 3) { - $this->error(get_string('notenoughtsubans', 'qformat_blackboard_six', $question->questiontext['text'])); + $this->error(get_string('notenoughtsubans', 'qformat_blackboard_six', $question->questiontext)); } else { $questions[] = $question; } diff --git a/question/format/blackboard_six/tests/blackboardformatpool_test.php b/question/format/blackboard_six/tests/blackboardformatpool_test.php index 22cadb73589..fdfa5e4687f 100644 --- a/question/format/blackboard_six/tests/blackboardformatpool_test.php +++ b/question/format/blackboard_six/tests/blackboardformatpool_test.php @@ -58,10 +58,7 @@ class qformat_blackboard_six_pool_test extends question_testcase { $expectedq = new stdClass(); $expectedq->qtype = 'match'; $expectedq->name = 'Classify the animals.'; - $expectedq->questiontext = array( - 'text' => 'Classify the animals.', - 'format' => FORMAT_HTML, - ); + $expectedq->questiontext = 'Classify the animals.'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->correctfeedback = array('text' => '', 'format' => FORMAT_HTML); @@ -98,10 +95,7 @@ class qformat_blackboard_six_pool_test extends question_testcase { $expectedq->qtype = 'multichoice'; $expectedq->single = 1; $expectedq->name = 'What\'s between orange and green in the spectrum?'; - $expectedq->questiontext = array( - 'text' =>'What\'s between orange and green in the spectrum?', - 'format' => FORMAT_HTML, - ); + $expectedq->questiontext = 'What\'s between orange and green in the spectrum?'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->correctfeedback = array('text' => 'You gave the right answer.', 'format' => FORMAT_HTML); @@ -161,10 +155,7 @@ class qformat_blackboard_six_pool_test extends question_testcase { $expectedq->qtype = 'multichoice'; $expectedq->single = 0; $expectedq->name = 'What\'s between orange and green in the spectrum?'; - $expectedq->questiontext = array( - 'text' => 'What\'s between orange and green in the spectrum?', - 'format' => FORMAT_HTML, - ); + $expectedq->questiontext = 'What\'s between orange and green in the spectrum?'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->correctfeedback = array( 'text' => 'You gave the right answer.', @@ -237,10 +228,7 @@ class qformat_blackboard_six_pool_test extends question_testcase { $expectedq = new stdClass(); $expectedq->qtype = 'truefalse'; $expectedq->name = '42 is the Absolute Answer to everything.'; - $expectedq->questiontext = array( - 'text' => '42 is the Absolute Answer to everything.', - 'format' => FORMAT_HTML, - ); + $expectedq->questiontext = '42 is the Absolute Answer to everything.'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->generalfeedback = ''; $expectedq->generalfeedbackformat = FORMAT_HTML; @@ -270,10 +258,7 @@ class qformat_blackboard_six_pool_test extends question_testcase { $expectedq = new stdClass(); $expectedq->qtype = 'shortanswer'; $expectedq->name = 'Name an amphibian: __________.'; - $expectedq->questiontext = array( - 'text' => 'Name an amphibian: __________.', - 'format' => FORMAT_HTML, - ); + $expectedq->questiontext = 'Name an amphibian: __________.'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->generalfeedback = ''; $expectedq->generalfeedbackformat = FORMAT_HTML; @@ -308,10 +293,7 @@ class qformat_blackboard_six_pool_test extends question_testcase { $expectedq = new stdClass(); $expectedq->qtype = 'essay'; $expectedq->name = 'How are you?'; - $expectedq->questiontext = array( - 'text' => 'How are you?', - 'format' => FORMAT_HTML, - ); + $expectedq->questiontext = 'How are you?'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->generalfeedback = ''; $expectedq->generalfeedbackformat = FORMAT_HTML; diff --git a/question/format/blackboard_six/tests/blackboardsixformatqti_test.php b/question/format/blackboard_six/tests/blackboardsixformatqti_test.php index 68df181bba3..9d80e9bdfe8 100644 --- a/question/format/blackboard_six/tests/blackboardsixformatqti_test.php +++ b/question/format/blackboard_six/tests/blackboardsixformatqti_test.php @@ -55,10 +55,7 @@ class qformat_blackboard_six_qti_test extends question_testcase { $expectedq = new stdClass(); $expectedq->qtype = 'match'; $expectedq->name = 'Classify the animals.'; - $expectedq->questiontext = array( - 'text' => 'Classify the animals.', - 'format' => FORMAT_HTML, - ); + $expectedq->questiontext = 'Classify the animals.'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->correctfeedback = array('text' => '', 'format' => FORMAT_HTML, 'files' => array()); @@ -94,10 +91,7 @@ class qformat_blackboard_six_qti_test extends question_testcase { $expectedq->qtype = 'multichoice'; $expectedq->single = 1; $expectedq->name = 'What\'s between orange and green in the spectrum?'; - $expectedq->questiontext = array( - 'text' => 'What\'s between orange and green in the spectrum?', - 'format' => FORMAT_HTML, - ); + $expectedq->questiontext = 'What\'s between orange and green in the spectrum?'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->correctfeedback = array('text' => '', 'format' => FORMAT_HTML, 'files' => array()); @@ -157,10 +151,7 @@ class qformat_blackboard_six_qti_test extends question_testcase { $expectedq->qtype = 'multichoice'; $expectedq->single = 0; $expectedq->name = 'What\'s between orange and green in the spectrum?'; - $expectedq->questiontext = array( - 'text' => 'What\'s between orange and green in the spectrum?', - 'format' => FORMAT_HTML, - ); + $expectedq->questiontext = 'What\'s between orange and green in the spectrum?'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->correctfeedback = array( 'text' => '', @@ -236,10 +227,7 @@ class qformat_blackboard_six_qti_test extends question_testcase { $expectedq = new stdClass(); $expectedq->qtype = 'truefalse'; $expectedq->name = '42 is the Absolute Answer to everything.'; - $expectedq->questiontext = array( - 'text' => '42 is the Absolute Answer to everything.', - 'format' => FORMAT_HTML, - ); + $expectedq->questiontext = '42 is the Absolute Answer to everything.'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->generalfeedback = ''; $expectedq->generalfeedbackformat = FORMAT_HTML; @@ -270,10 +258,7 @@ class qformat_blackboard_six_qti_test extends question_testcase { $expectedq = new stdClass(); $expectedq->qtype = 'shortanswer'; $expectedq->name = 'Name an amphibian: __________.'; - $expectedq->questiontext = array( - 'text' => 'Name an amphibian: __________.', - 'format' => FORMAT_HTML, - ); + $expectedq->questiontext = 'Name an amphibian: __________.'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->generalfeedback = ''; $expectedq->generalfeedbackformat = FORMAT_HTML; @@ -308,10 +293,7 @@ class qformat_blackboard_six_qti_test extends question_testcase { $expectedq = new stdClass(); $expectedq->qtype = 'essay'; $expectedq->name = 'How are you?'; - $expectedq->questiontext = array( - 'text' => 'How are you?', - 'format' => FORMAT_HTML - ); + $expectedq->questiontext = 'How are you?'; $expectedq->questiontextformat = FORMAT_HTML; $expectedq->generalfeedback = ''; $expectedq->generalfeedbackformat = FORMAT_HTML;