Skip to content

Commit

Permalink
Merge pull request #1 from TomoTsuyuki/fix-issue35
Browse files Browse the repository at this point in the history
Issue moodleou#35: Workaround when the class does not exist
  • Loading branch information
dmitriim authored Feb 21, 2024
2 parents 6fa807b + bb28b1c commit 1eb8440
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 14 deletions.
30 changes: 24 additions & 6 deletions classes/output/combined/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,35 @@

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.
*
* @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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 8 additions & 2 deletions classes/output/oumultiresponse/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,21 @@

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.
*
* @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.
Expand Down
10 changes: 8 additions & 2 deletions classes/output/pmatch/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,21 @@
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.
*
* @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.
Expand Down
10 changes: 8 additions & 2 deletions classes/output/recordrtc/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 = '';
Expand Down
10 changes: 8 additions & 2 deletions classes/output/stack/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,21 @@
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.
*
* @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.
Expand Down

0 comments on commit 1eb8440

Please sign in to comment.