diff --git a/classes/output/combined/renderer.php b/classes/output/combined/renderer.php index a4ea22e..07d7622 100644 --- a/classes/output/combined/renderer.php +++ b/classes/output/combined/renderer.php @@ -36,9 +36,27 @@ defined('MOODLE_INTERNAL') || die(); -require_once($CFG->dirroot . '/question/type/combined/renderer.php'); -require_once($CFG->dirroot . '/question/type/combined/combinable/gapselect/renderer.php'); -require_once($CFG->dirroot . '/question/type/oumultiresponse/combinable/renderer.php'); +// Work-around when the class does not exist. +if (class_exists('\qtype_combined_renderer')) { + class_alias('\qtype_combined_renderer', '\qtype_combined_renderer_alias'); + require_once($CFG->dirroot . '/question/type/combined/renderer.php'); +} else { + class_alias('\qtype_renderer', '\qtype_combined_renderer_alias'); +} + +if (class_exists('\qtype_oumultiresponse_embedded_renderer')) { + class_alias('\qtype_oumultiresponse_embedded_renderer', '\qtype_oumultiresponse_embedded_renderer_alias'); + require_once($CFG->dirroot . '/question/type/oumultiresponse/combinable/renderer.php'); +} else { + class_alias('\qtype_renderer', '\qtype_oumultiresponse_embedded_renderer_alias'); +} + +if (class_exists('\qtype_combined_gapselect_embedded_renderer')) { + class_alias('\qtype_combined_gapselect_embedded_renderer', '\qtype_combined_gapselect_embedded_renderer_alias'); + require_once($CFG->dirroot . '/question/type/combined/combinable/gapselect/renderer.php'); +} else { + class_alias('\qtype_renderer', '\qtype_combined_gapselect_embedded_renderer_alias'); +} /** * The override qtype_combined_renderer for the quiz_answersheets module. @@ -46,7 +64,7 @@ * @copyright 2020 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class qtype_combined_override_renderer extends \qtype_combined_renderer { +class qtype_combined_override_renderer extends \qtype_combined_renderer_alias { /** * The code was copied from question/type/combined/renderer.php, with modifications. @@ -158,7 +176,7 @@ private function get_embedded_renderer(qtype_combined_combinable_type_base $ques * * @package quiz_answersheets\output\combined */ -class qtype_oumultiresponse_embedded_override_renderer extends \qtype_oumultiresponse_embedded_renderer { +class qtype_oumultiresponse_embedded_override_renderer extends \qtype_oumultiresponse_embedded_renderer_alias { /** * The code was copied from question/type/oumultiresponse/combinable/renderer.php, with modifications. @@ -261,7 +279,7 @@ public function subquestion(question_attempt $qa, question_display_options $opti * * @package quiz_answersheets\output\combined */ -class qtype_combined_gapselect_embedded_override_renderer extends \qtype_combined_gapselect_embedded_renderer { +class qtype_combined_gapselect_embedded_override_renderer extends \qtype_combined_gapselect_embedded_renderer_alias { /** * Render the sub question. diff --git a/classes/output/oumultiresponse/renderer.php b/classes/output/oumultiresponse/renderer.php index 473faf1..9af2a48 100644 --- a/classes/output/oumultiresponse/renderer.php +++ b/classes/output/oumultiresponse/renderer.php @@ -31,7 +31,13 @@ defined('MOODLE_INTERNAL') || die(); -require_once($CFG->dirroot . '/question/type/oumultiresponse/renderer.php'); +// Work-around when the class does not exist. +if (class_exists('\qtype_oumultiresponse_renderer')) { + class_alias('\qtype_oumultiresponse_renderer', '\qtype_oumultiresponse_renderer_alias'); + require_once($CFG->dirroot . '/question/type/oumultiresponse/renderer.php'); +} else { + class_alias('\qtype_renderer', '\qtype_oumultiresponse_renderer_alias'); +} /** * The override qtype_oumultiresponse_renderer for the quiz_answersheets module. @@ -39,7 +45,7 @@ * @copyright 2020 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class qtype_oumultiresponse_override_renderer extends \qtype_oumultiresponse_renderer { +class qtype_oumultiresponse_override_renderer extends \qtype_oumultiresponse_renderer_alias { /** * The code was copied from question/type/oumultiresponse/renderer.php, with modifications. diff --git a/classes/output/pmatch/renderer.php b/classes/output/pmatch/renderer.php index 963b327..aaff157 100644 --- a/classes/output/pmatch/renderer.php +++ b/classes/output/pmatch/renderer.php @@ -29,7 +29,13 @@ use qtype_pmatch_question; use question_display_options; -require_once($CFG->dirroot . '/question/type/pmatch/renderer.php'); +// Work-around when the class does not exist. +if (class_exists('\qtype_pmatch_renderer')) { + class_alias('\qtype_pmatch_renderer', '\qtype_pmatch_renderer_alias'); + require_once($CFG->dirroot . '/question/type/pmatch/renderer.php'); +} else { + class_alias('\qtype_renderer', '\qtype_pmatch_renderer_alias'); +} /** * The override qtype_pmatch_renderer for the quiz_answersheets module. @@ -37,7 +43,7 @@ * @copyright 2020 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class qtype_pmatch_override_renderer extends \qtype_pmatch_renderer { +class qtype_pmatch_override_renderer extends \qtype_pmatch_renderer_alias { public function question_tests_link(qtype_pmatch_question $question, question_display_options $options) { // Do not show the question test link. diff --git a/classes/output/recordrtc/renderer.php b/classes/output/recordrtc/renderer.php index 8ccf5b1..3f7a124 100644 --- a/classes/output/recordrtc/renderer.php +++ b/classes/output/recordrtc/renderer.php @@ -32,7 +32,13 @@ use question_attempt; use question_display_options; -require_once($CFG->dirroot . '/question/type/recordrtc/renderer.php'); +// Work-around when the class does not exist. +if (class_exists('\qtype_recordrtc_renderer')) { + class_alias('\qtype_recordrtc_renderer', '\qtype_recordrtc_renderer_alias'); + require_once($CFG->dirroot . '/question/type/recordrtc/renderer.php'); +} else { + class_alias('\qtype_renderer', '\qtype_recordrtc_renderer_alias'); +} /** * The override qtype_recordrtc_renderer for the quiz_answersheets module. @@ -41,7 +47,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class qtype_recordrtc_override_renderer extends \qtype_recordrtc_renderer { +class qtype_recordrtc_override_renderer extends \qtype_recordrtc_renderer_alias { protected function no_recording_message(): string { $output = ''; diff --git a/classes/output/stack/renderer.php b/classes/output/stack/renderer.php index 3693ada..62e852f 100644 --- a/classes/output/stack/renderer.php +++ b/classes/output/stack/renderer.php @@ -35,7 +35,13 @@ use stack_maths; use stack_utils; -require_once($CFG->dirroot . '/question/type/stack/renderer.php'); +// Work-around when the class does not exist. +if (class_exists('\qtype_stack_renderer')) { + class_alias('\qtype_stack_renderer', '\qtype_stack_renderer_alias'); + require_once($CFG->dirroot . '/question/type/stack/renderer.php'); +} else { + class_alias('\qtype_renderer', '\qtype_stack_renderer_alias'); +} /** * The override qtype_stack_renderer for the quiz_answersheets module. @@ -43,7 +49,7 @@ * @copyright 2020 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class qtype_stack_override_renderer extends \qtype_stack_renderer { +class qtype_stack_override_renderer extends \qtype_stack_renderer_alias { protected function question_tests_link(qtype_stack_question $question, question_display_options $options) { // Do not show the question test link.