Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.2 compatibility done otherwise. #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,27 @@

// This work-around is required until Moodle 4.2 is the lowest version we support.
if (class_exists('\mod_quiz\local\access_rule_base')) {
class_alias('\mod_quiz\local\access_rule_base', '\quizaccess_honestycheck_parent_class_alias');
class_alias('\mod_quiz\form\preflight_check_form', '\quizaccess_honestycheck_preflight_form_alias');
class_alias('\mod_quiz\quiz_settings', '\quizaccess_honestycheck_quiz_settings_class_alias');
// Use aliases at class_loader level to maintain compatibility.
\class_alias(mod_quiz\local\access_rule_base::class, quiz_access_rule_base::class);
\class_alias(mod_quiz\form\preflight_check_form::class, mod_quiz_preflight_check_form::class);
\class_alias(mod_quiz\quiz_settings::class, quiz::class);
} else {
require_once($CFG->dirroot . '/mod/quiz/accessrule/accessrulebase.php');
class_alias('\quiz_access_rule_base', '\quizaccess_honestycheck_parent_class_alias');
class_alias('\mod_quiz_preflight_check_form', '\quizaccess_honestycheck_preflight_form_alias');
class_alias('\quiz', '\quizaccess_honestycheck_quiz_settings_class_alias');
}



/**
* A rule requiring the student to promise not to cheat.
*
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class quizaccess_honestycheck extends quizaccess_honestycheck_parent_class_alias {
class quizaccess_honestycheck extends quiz_access_rule_base {

public function is_preflight_check_required($attemptid) {
return empty($attemptid);
}

public function add_preflight_check_form_fields(quizaccess_honestycheck_preflight_form_alias $quizform,
public function add_preflight_check_form_fields(mod_quiz_preflight_check_form $quizform,
MoodleQuickForm $mform, $attemptid) {

$mform->addElement('header', 'honestycheckheader',
Expand All @@ -69,7 +65,7 @@ public function validate_preflight_check($data, $files, $errors, $attemptid) {
return $errors;
}

public static function make(quizaccess_honestycheck_quiz_settings_class_alias $quizobj, $timenow, $canignoretimelimits) {
public static function make(quiz $quizobj, $timenow, $canignoretimelimits) {

if (empty($quizobj->get_quiz()->honestycheckrequired)) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion tests/rule_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function test_honestycheck_rule() {
$quiz->questions = '';
$cm = new stdClass();
$cm->id = 0;
$quizobj = new \quizaccess_honestycheck_quiz_settings_class_alias($quiz, $cm, null);
$quizobj = new \quiz($quiz, $cm, null);
$rule = quizaccess_honestycheck::make($quizobj, 0, false);
$this->assertNull($rule);

Expand Down