Skip to content

Commit

Permalink
Merge pull request #23 from ucsf-education/DEF-3544
Browse files Browse the repository at this point in the history
Def 3544
  • Loading branch information
ojnadjarm authored Feb 14, 2025
2 parents 32dd268 + 6ec463f commit cdafffb
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ function local_quizanon_before_standard_top_of_body_html() {

$pagename = $PAGE->pagetype;
$coursemodule = $PAGE->cm;
$pluginenabled = get_config('local_quizanon', 'enablequizanon');
if (empty($coursemodule) || $coursemodule->modname !== 'quiz' || empty($pluginenabled)) {
if (empty($coursemodule) || $coursemodule->modname !== 'quiz') {
return;
}
$urlparams = $PAGE->url->params();
Expand All @@ -51,8 +50,9 @@ function local_quizanon_before_standard_top_of_body_html() {
}

$mode = !empty($urlparams['mode']) ? $urlparams['mode'] : '';
$pluginenabled = get_config('local_quizanon', 'enablequizanon');
$anonreportexists = is_readable($CFG->dirroot . '/local/quizanon/report/' . $mode . '/report.php');
$redirect = !empty($quizanonenabled) && !$userhasrole;
$redirect = !empty($quizanonenabled) && !$userhasrole && !empty($pluginenabled);
switch($pagename) {
case 'mod-quiz-report':
$url = '/local/quizanon/report.php';
Expand All @@ -69,24 +69,23 @@ function local_quizanon_before_standard_top_of_body_html() {
break;
case 'local-quizanon-report':
$url = '/mod/quiz/report.php';
$redirect = empty($quizanonenabled) || $userhasrole;
break;
case 'local-quizanon-review':
$url = '/mod/quiz/review.php';
$redirect = empty($quizanonenabled) || $userhasrole;
break;
case "local-quizanon-reviewquestion":
$url = '/mod/quiz/reviewquestion.php';
$redirect = empty($quizanonenabled) || $userhasrole;
break;
case "local-quizanon-comment":
$url = '/mod/quiz/comment.php';
$redirect = empty($quizanonenabled) || $userhasrole;
break;
default:
$redirect = false;
break;
}
if (substr($pagename, 0, 5) === 'local') {
$redirect = empty($quizanonenabled) || empty($pluginenabled) || $userhasrole;
}
if ($redirect) {
$moodleurl = new moodle_url($url, $urlparams);
redirect($moodleurl);
Expand All @@ -100,7 +99,11 @@ function local_quizanon_before_standard_top_of_body_html() {
* @param moodleform $mform
*/
function local_quizanon_coursemodule_standard_elements($formwrapper, $mform) {
global $COURSE, $DB;
global $COURSE, $DB, $PAGE;
$pluginenabled = get_config('local_quizanon', 'enablequizanon');
if (empty($pluginenabled)) {
return;
}
if ($formwrapper instanceof mod_quiz_mod_form) {
$cm = $formwrapper->get_coursemodule();
if (!empty($cm->id)) {
Expand Down

0 comments on commit cdafffb

Please sign in to comment.