diff --git a/report.php b/report.php index e50f915..6047556 100644 --- a/report.php +++ b/report.php @@ -31,14 +31,12 @@ // This work-around is required until Moodle 4.2 is the lowest version we support. if (class_exists('\mod_quiz\local\reports\attempts_report')) { class_alias('\mod_quiz\local\reports\attempts_report', '\quiz_essaydownload_report_parent_alias'); -} else { - require_once($CFG->dirroot . '/mod/quiz/report/attemptsreport.php'); - class_alias('\quiz_attempts_report', '\quiz_essaydownload_report_parent_alias'); -} -if (class_exists('\mod_quiz\quiz_attempt')) { class_alias('\mod_quiz\quiz_attempt', '\quiz_essaydownload_quiz_attempt_alias'); } else { + require_once($CFG->dirroot . '/mod/quiz/report/default.php'); + require_once($CFG->dirroot . '/mod/quiz/report/attemptsreport.php'); require_once($CFG->dirroot . '/mod/quiz/attemptlib.php'); + class_alias('\quiz_attempts_report', '\quiz_essaydownload_report_parent_alias'); class_alias('\quiz_attempt', '\quiz_essaydownload_quiz_attempt_alias'); } diff --git a/tests/helper.php b/tests/helper.php index f9ebb44..51d0bd0 100644 --- a/tests/helper.php +++ b/tests/helper.php @@ -26,8 +26,16 @@ namespace quiz_essaydownload; use advanced_testcase; -use mod_quiz\quiz_attempt; -use mod_quiz\quiz_settings; + +defined('MOODLE_INTERNAL') || die(); + +// This work-around is required until Moodle 4.2 is the lowest version we support. +if (class_exists('\mod_quiz\quiz_settings')) { + class_alias('\mod_quiz\quiz_settings', '\quiz_essaydownload_quiz_settings_alias'); +} else { + require_once($CFG->dirroot . '/mod/quiz/classes/plugininfo/quiz.php'); + class_alias('\quiz', '\quiz_essaydownload_quiz_settings_alias'); +} /** * Helper class providing some useful methods for Essay responses downloader plugin unit @@ -87,7 +95,7 @@ public static function add_random_nonessay_question($questiongenerator, \stdClas $questiongenerator->create_question('shortanswer', null, ['category' => $cat->id]); $questiongenerator->create_question('shortanswer', null, ['category' => $cat->id]); - $quizobj = quiz_settings::create($quiz->id); + $quizobj = quiz_essaydownload_quiz_settings_alias::create($quiz->id); $structure = $quizobj->get_structure(); $filtercondition = [ 'filter' => [ @@ -114,7 +122,7 @@ public static function add_random_essay_question($questiongenerator, \stdClass $ $questiongenerator->create_question('essay', null, ['category' => $cat->id]); $questiongenerator->create_question('essay', null, ['category' => $cat->id]); - $quizobj = quiz_settings::create($quiz->id); + $quizobj = quiz_essaydownload_quiz_settings_alias::create($quiz->id); $structure = $quizobj->get_structure(); $filtercondition = [ 'filter' => [ @@ -162,7 +170,7 @@ public static function start_attempt_at_quiz(\stdClass $quiz, \stdClass $user, $ advanced_testcase::setUser($user); $starttime = time(); - $quizobj = quiz_settings::create($quiz->id, $user->id); + $quizobj = quiz_essaydownload_quiz_settings_alias::create($quiz->id, $user->id); $quba = \question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj->get_context()); $quba->set_preferred_behaviour($quizobj->get_quiz()->preferredbehaviour); @@ -171,7 +179,7 @@ public static function start_attempt_at_quiz(\stdClass $quiz, \stdClass $user, $ $attempt = quiz_create_attempt($quizobj, $attemptnumber, null, $starttime, false, $user->id); quiz_start_new_attempt($quizobj, $quba, $attempt, $attemptnumber, $starttime); quiz_attempt_save_started($quizobj, $quba, $attempt); - $attemptobj = quiz_attempt::create($attempt->id); + $attemptobj = quiz_essaydownload_quiz_attempt_alias::create($attempt->id); advanced_testcase::setUser();