Skip to content

Commit

Permalink
MDL-78670 mod_quiz: Add offline atempt rule for sequential navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
rmady committed Nov 20, 2023
1 parent 94ad185 commit 3089485
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Expand Up @@ -27,10 +27,10 @@
$string['allowofflineattempts'] = 'Allow quiz to be attempted offline using the mobile app';
$string['allowofflineattempts_help'] = 'If enabled, a mobile app user can download the quiz and attempt it offline.
Note: It is not possible for a quiz to be attempted offline if it has a time limit, or requires a network address, or uses any question behaviour other than deferred feedback (with or without CBM).';
Note: It is not possible for a quiz to be attempted offline if it has a time limit, or requires a network address, or uses any question behaviour other than deferred feedback (with or without CBM), or uses sequential navigation.';
$string['confirmdatasaved'] = 'I confirm that I do not have any unsaved work on a mobile device.';
$string['mobileapp'] = 'Mobile app';
$string['offlineattemptserror'] = 'It is not possible for a quiz to be attempted offline if it has a time limit, or requires a network address, or uses any question behaviour other than deferred feedback (with or without CBM).';
$string['offlineattemptserror'] = 'It is not possible for a quiz to be attempted offline if it has a time limit, or requires a network address, or uses any question behaviour other than deferred feedback (with or without CBM), or uses sequential navigation.';
$string['offlinedatamessage'] = 'You have worked on this attempt using a mobile device. Data was last saved to this site {$a} ago.';
$string['pleaseconfirm'] = 'Please check and confirm that you do not have any unsaved work.';
$string['pluginname'] = 'Offline attempts access rule';
Expand Down
9 changes: 6 additions & 3 deletions mod/quiz/accessrule/offlineattempts/rule.php
Expand Up @@ -114,6 +114,7 @@ public static function add_settings_form_fields(
$mform->setAdvanced('allowofflineattempts');
$mform->disabledIf('allowofflineattempts', 'timelimit[number]', 'neq', 0);
$mform->disabledIf('allowofflineattempts', 'subnet', 'neq', '');
$mform->disabledIf('allowofflineattempts', 'navmethod', 'eq', 'sequential');
}
}

Expand All @@ -126,9 +127,11 @@ public static function validate_settings_form_fields(array $errors,
// - The quiz uses a timer.
// - The quiz is restricted by subnet.
// - The question behaviour is not deferred feedback or deferred feedback with CBM.
if (!empty($data['allowofflineattempts']) and
(!empty($data['timelimit']) or !empty($data['subnet']) or
($data['preferredbehaviour'] != 'deferredfeedback' and $data['preferredbehaviour'] != 'deferredcbm'))) {
// - The quiz uses the sequential navigation.
if (!empty($data['allowofflineattempts']) &&
(!empty($data['timelimit']) || !empty($data['subnet']) ||
$data['navmethod'] === 'sequential' ||
($data['preferredbehaviour'] != 'deferredfeedback' && $data['preferredbehaviour'] != 'deferredcbm'))) {

$errors['allowofflineattempts'] = get_string('offlineattemptserror', 'quizaccess_offlineattempts');
}
Expand Down

0 comments on commit 3089485

Please sign in to comment.