From b837d03eb09503fb9e2556f48eea34d6df3cee00 Mon Sep 17 00:00:00 2001 From: Gordon Bateson Date: Wed, 14 Jun 2017 08:30:37 +0900 Subject: [PATCH] MDL-79863 qtype_ordering: qtype_ordering restore functionality on Moodle 2.0 --- question/type/ordering/edit_ordering_form.php | 20 ++++++++++++++----- question/type/ordering/questiontype.php | 13 ++++++++++++ question/type/ordering/version.php | 6 +++--- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/question/type/ordering/edit_ordering_form.php b/question/type/ordering/edit_ordering_form.php index ad1d2e5a080..fb2a171f8ec 100644 --- a/question/type/ordering/edit_ordering_form.php +++ b/question/type/ordering/edit_ordering_form.php @@ -142,10 +142,14 @@ class qtype_ordering_edit_form extends question_edit_form { $this->adjust_html_editors($mform, $name, $repeats); // Adding feedback fields (=Combined feedback). - $this->add_combined_feedback_fields(false); + if (method_exists($this, 'add_combined_feedback_fields')) { + $this->add_combined_feedback_fields(false); + } // Adding interactive settings (=Multiple tries). - $this->add_interactive_settings(false, false); + if (method_exists($this, 'add_interactive_settings')) { + $this->add_interactive_settings(false, false); + } } /** @@ -282,11 +286,17 @@ class qtype_ordering_edit_form extends question_edit_form { public function data_preprocessing($question) { $question = parent::data_preprocessing($question); - $question = $this->data_preprocessing_answers($question, true); + if (method_exists($this, 'data_preprocessing_answers')) { + $question = $this->data_preprocessing_answers($question, true); + } // Preprocess feedback. - $question = $this->data_preprocessing_combined_feedback($question); - $question = $this->data_preprocessing_hints($question, false, false); + if (method_exists($this, 'data_preprocessing_combined_feedback')) { + $question = $this->data_preprocessing_combined_feedback($question); + } + if (method_exists($this, 'data_preprocessing_hints')) { + $question = $this->data_preprocessing_hints($question, false, false); + } // Preprocess answers and fractions. $question->answer = array(); diff --git a/question/type/ordering/questiontype.php b/question/type/ordering/questiontype.php index c9618f0a59c..8971a3226ed 100644 --- a/question/type/ordering/questiontype.php +++ b/question/type/ordering/questiontype.php @@ -24,6 +24,10 @@ defined('MOODLE_INTERNAL') || die(); +if (class_exists('default_questiontype')) { // Moodle 2.0 + require_once($CFG->dirroot.'/question/type/ordering/legacy/20.php'); +} + /** * The ordering question type. * @@ -807,3 +811,12 @@ class qtype_ordering extends question_type { $question->showgrading = $showgrading; } } + +if (function_exists('question_register_questiontype')) { // Moodle 2.0 + class qtype_ordering_options_qtype extends qtype_ordering { + function name() { + return 'ordering'; + } + } + question_register_questiontype(new qtype_ordering_options_qtype()); +} diff --git a/question/type/ordering/version.php b/question/type/ordering/version.php index c66be5c2b09..31689cb8f0c 100644 --- a/question/type/ordering/version.php +++ b/question/type/ordering/version.php @@ -28,6 +28,6 @@ defined('MOODLE_INTERNAL') || die(); $plugin->cron = 0; $plugin->component = 'qtype_ordering'; $plugin->maturity = MATURITY_STABLE; -$plugin->requires = 2011070100; // Moodle 2.1. -$plugin->version = 2017040658; -$plugin->release = '2017-04-26 (58)'; +$plugin->requires = 2010112400; // Moodle 2.0 +$plugin->version = 2017050859; +$plugin->release = '2017-05-08 (59)';