Skip to content

Commit d241dde

Browse files
authored
Added a hook in validate.php for diagnostic assessment redirects. (#273)
This allows for defining a custom function to determine if a user should be redirected to a diagnostic assessment.
1 parent 90ce348 commit d241dde

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

hooks.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ Called when checking if LTI user can access the requested page
133133
return an array of base filenames that are allowed to be accessed by a user
134134
accessing an assessment via LTI. This is merged with the default list.
135135

136+
Called to determine if a user should be redirected to a diagnostic assessment
137+
`isDiagnostic()`
138+
136139
## util/batchcreateinstr
137140

138141
Include via `$CFG['hooks']['util/batchcreateinstr']`

validate.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,12 @@
465465
if (isset($_GET['graphdisp'])) {
466466
$_SESSION['graphdisp'] = $_GET['graphdisp'];
467467
}
468-
if (isset($_SESSION['isdiag'])) { // && strpos(basename($_SERVER['PHP_SELF']),'showtest.php')===false) {
468+
if (!function_exists('isDiagnostic')) {
469+
function isDiagnostic() {
470+
return isset($_SESSION['isdiag']); // && strpos(basename($_SERVER['PHP_SELF']),'showtest.php')===false) {
471+
}
472+
}
473+
if (isDiagnostic()) {
469474
$urlparts = parse_url($_SERVER['PHP_SELF']);
470475
if ($_SESSION['diag_aver'][0] == 1 &&
471476
!in_array(basename($urlparts['path']), array('showtest.php', 'ltiuserprefs.php'))

0 commit comments

Comments
 (0)