Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
|
Implementation of the quizaccess_seb plugin. More...
Public Member Functions | |
__construct (\mod_quiz\quiz_settings $quizobj, int $timenow, seb_access_manager $accessmanager) | |
Create an instance of this rule for a particular quiz. | |
add_preflight_check_form_fields (preflight_check_form $quizform, MoodleQuickForm $mform, $attemptid) | |
Add any field you want to pre-flight check form. | |
attempt_must_be_in_popup () | |
Does this rule requires the attempt (and review) to be displayed in a pop-up window? | |
current_attempt_finished () | |
This is called when the current attempt at the quiz is finished. | |
description () | |
Information, such as might be shown on the quiz view page, relating to this restriction. | |
end_time ($attempt) | |
Time by which, according to this rule, the user has to finish their attempt. | |
get_popup_options () | |
Any options required when showing the attempt in a pop-up. | |
get_superceded_rules () | |
It is possible for one rule to override other rules. | |
is_finished ($numprevattempts, $lastattempt) | |
Is the current user unable to start any more attempts in future, because of this rule? | |
is_preflight_check_required ($attemptid) | |
Does this rule require a UI check with the user before an attempt is started? | |
notify_preflight_check_passed ($attemptid) | |
The pre-flight check has passed. | |
prevent_access () | |
Whether the user should be blocked from starting a new attempt or continuing an attempt now. | |
prevent_new_attempt ($numprevattempts, $lastattempt) | |
Whether a user should be allowed to start a new attempt at this quiz now. | |
setup_attempt_page ($page) | |
Sets up the attempt (review or summary) page with any special extra properties required by this rule. | |
time_left_display ($attempt, $timenow) | |
If the user should be shown a different amount of time than $timenow - $this->end_time(), then override this method. | |
validate_preflight_check ($data, $files, $errors, $attemptid) | |
Validate the pre-flight check form submission. | |
Static Public Member Functions | |
static | add_settings_form_fields (mod_quiz_mod_form $quizform, MoodleQuickForm $mform) |
Add any fields that this rule requires to the quiz settings form. | |
static | delete_settings ($quiz) |
Delete any rule-specific settings when the quiz is deleted. | |
static | get_browser_security_choices () |
Get any options this rule adds to the 'Browser security' quiz setting. | |
static | get_extra_settings ($quizid) |
You can use this method to load any extra settings your plugin has that cannot be loaded efficiently with get_settings_sql(). | |
static | get_settings_sql ($quizid) |
Return the bits of SQL needed to load all the settings from all the access plugins in one DB query. | |
static | make (quiz_settings $quizobj, $timenow, $canignoretimelimits) |
Return an appropriately configured instance of this rule, if it is applicable to the given quiz, otherwise return null. | |
static | make (\mod_quiz\quiz_settings $quizobj, $timenow, $canignoretimelimits) |
Return an appropriately configured instance of this rule, if it is applicable to the given quiz, otherwise return null. | |
static | save_settings ($quiz) |
Save any submitted settings when the quiz settings form is submitted. | |
static | validate_settings_form_fields (array $errors, array $data, $files, mod_quiz_mod_form $quizform) |
Validate the data from any form fields added using add_settings_form_fields(). | |
Protected Attributes | |
stdClass | $quiz |
the quiz settings. | |
quiz_settings | $quizobj |
the quiz object. | |
int | $timenow |
the time to use as 'now'. | |
Implementation of the quizaccess_seb plugin.
quizaccess_seb::__construct | ( | \mod_quiz\quiz_settings | $quizobj, |
int | $timenow, | ||
seb_access_manager | $accessmanager ) |
Create an instance of this rule for a particular quiz.
mod_quiz\quiz_settings | $quizobj | information about the quiz in question. |
int | $timenow | the time that should be considered as 'now'. |
seb_access_manager | $accessmanager | the quiz accessmanager. |
|
inherited |
Add any field you want to pre-flight check form.
You should only do something here if {
preflight_check_form | $quizform | the form being built. |
MoodleQuickForm | $mform | The wrapped MoodleQuickForm. |
int | null | $attemptid | the id of the current attempt, if there is one, otherwise null. |
Reimplemented in quizaccess_offlineattempts, quizaccess_password, and quizaccess_timelimit.
|
static |
Add any fields that this rule requires to the quiz settings form.
This method is called from mod_quiz_mod_form::definition(), while the security section is being built.
mod_quiz_mod_form | $quizform | the quiz settings form that is being built. |
MoodleQuickForm | $mform | the wrapped MoodleQuickForm. |
Reimplemented from mod_quiz\local\access_rule_base.
|
inherited |
Does this rule requires the attempt (and review) to be displayed in a pop-up window?
bool | true if it does. |
Reimplemented in quizaccess_securewindow.
quizaccess_seb::current_attempt_finished | ( | ) |
This is called when the current attempt at the quiz is finished.
Reimplemented from mod_quiz\local\access_rule_base.
|
static |
Delete any rule-specific settings when the quiz is deleted.
This is called from quiz_delete_instance() in lib.php.
stdClass | $quiz | the data from the database, including $quiz->id which is the id of the quiz being deleted. |
Reimplemented from mod_quiz\local\access_rule_base.
quizaccess_seb::description | ( | ) |
Information, such as might be shown on the quiz view page, relating to this restriction.
There is no obligation to return anything. If it is not appropriate to tell students about this rule, then just return ''.
mixed | a message, or array of messages, explaining the restriction (may be '' if no message is appropriate). |
Reimplemented from mod_quiz\local\access_rule_base.
|
inherited |
Time by which, according to this rule, the user has to finish their attempt.
stdClass | $attempt | the current attempt |
int|false | the attempt close time, or false if there is no close time. |
Reimplemented in quizaccess_openclosedate, and quizaccess_timelimit.
|
staticinherited |
Get any options this rule adds to the 'Browser security' quiz setting.
array | key => lang string any choices to add to the quiz Browser security settings menu. |
Reimplemented in quizaccess_securewindow.
|
staticinherited |
You can use this method to load any extra settings your plugin has that cannot be loaded efficiently with get_settings_sql().
int | $quizid | the quiz id. |
array | setting value name => value. The value names should all start with the name of your plugin to avoid collisions. |
|
inherited |
Any options required when showing the attempt in a pop-up.
array | any options that are required for showing the attempt page in a popup window. |
Reimplemented in quizaccess_securewindow.
|
static |
Return the bits of SQL needed to load all the settings from all the access plugins in one DB query.
The easiest way to understand what you need to do here is probably to read the code of {
If you have some settings that cannot be loaded in this way, then you can use the get_extra_settings() method instead, but that has performance implications.
int | $quizid | the id of the quiz we are loading settings for. This can also be accessed as quiz.id in the SQL. (quiz is a table alisas for {quiz}.) |
array | with three elements:
|
Reimplemented from mod_quiz\local\access_rule_base.
|
inherited |
It is possible for one rule to override other rules.
The aim is that third-party rules should be able to replace sandard rules if they want. See, for example MDL-13592.
array | plugin names of other rules that this one replaces. For example ['ipaddress', 'password']. |
|
inherited |
Is the current user unable to start any more attempts in future, because of this rule?
If this rule can determine that this user will never be allowed another attempt at this quiz, for example because the last possible start time is past, or all attempts have been used up, then return true. This is used to know whether to display a final grade on the view page. This will only be called if there is not a currently active attempt for this user.
int | $numprevattempts | the number of previous attempts this user has made. |
stdClass | $lastattempt | information about the user's last completed attempt. |
bool | true if this rule means that this user will never be allowed another attempt at this quiz. |
Reimplemented in quizaccess_delaybetweenattempts, quizaccess_numattempts, and quizaccess_openclosedate.
|
inherited |
Does this rule require a UI check with the user before an attempt is started?
int | null | $attemptid | the id of the current attempt, if there is one, otherwise null. |
bool | whether a check is required before the user starts/continues their attempt. |
Reimplemented in quizaccess_offlineattempts, quizaccess_password, and quizaccess_timelimit.
|
staticinherited |
Return an appropriately configured instance of this rule, if it is applicable to the given quiz, otherwise return null.
quiz_settings | $quizobj | information about the quiz in question. |
int | $timenow | the time that should be considered as 'now'. |
bool | $canignoretimelimits | whether the current user is exempt from time limits by the mod/quiz:ignoretimelimits capability. |
self|null | the rule, if applicable, else null. |
Reimplemented in quizaccess_delaybetweenattempts, quizaccess_ipaddress, quizaccess_numattempts, quizaccess_offlineattempts, quizaccess_openclosedate, quizaccess_password, quizaccess_securewindow, and quizaccess_timelimit.
|
static |
Return an appropriately configured instance of this rule, if it is applicable to the given quiz, otherwise return null.
mod_quiz\quiz_settings | $quizobj | information about the quiz in question. |
int | $timenow | the time that should be considered as 'now'. |
bool | $canignoretimelimits | whether the current user is exempt from time limits by the mod/quiz:ignoretimelimits capability. |
access_rule_base|null | the rule, if applicable, else null. |
|
inherited |
The pre-flight check has passed.
This is a chance to record that fact in some way.
int | null | $attemptid | the id of the current attempt, if there is one, otherwise null. |
Reimplemented in quizaccess_offlineattempts, and quizaccess_password.
quizaccess_seb::prevent_access | ( | ) |
Whether the user should be blocked from starting a new attempt or continuing an attempt now.
string | false if access should be allowed, a message explaining the reason if access should be prevented. |
Reimplemented from mod_quiz\local\access_rule_base.
|
inherited |
Whether a user should be allowed to start a new attempt at this quiz now.
int | $numprevattempts | the number of previous attempts this user has made. |
stdClass | $lastattempt | information about the user's last completed attempt. |
string | false if access should be allowed, a message explaining the reason if access should be prevented. |
Reimplemented in quizaccess_delaybetweenattempts, and quizaccess_numattempts.
|
static |
Save any submitted settings when the quiz settings form is submitted.
This is called from quiz_after_add_or_update() in lib.php.
stdClass | $quiz | the data from the quiz form, including $quiz->id which is the id of the quiz being saved. |
Reimplemented from mod_quiz\local\access_rule_base.
quizaccess_seb::setup_attempt_page | ( | $page | ) |
Sets up the attempt (review or summary) page with any special extra properties required by this rule.
moodle_page | $page | the page object to initialise. |
Reimplemented from mod_quiz\local\access_rule_base.
|
inherited |
If the user should be shown a different amount of time than $timenow - $this->end_time(), then override this method.
This is useful if the time remaining is large enough to be omitted.
stdClass | $attempt | the current attempt |
int | $timenow | the time now. We don't use $this->timenow, so we can give the user a more accurate indication of how much time is left. |
mixed | the time left in seconds (can be negative) or false if there is no limit. |
Reimplemented in quizaccess_openclosedate, and quizaccess_timelimit.
|
inherited |
Validate the pre-flight check form submission.
You should only do something here if {
If the form validates, the user will be allowed to continue.
array | $data | the submitted form data. |
array | $files | any files in the submission. |
array | $errors | the list of validation errors that is being built up. |
int | null | $attemptid | the id of the current attempt, if there is one, otherwise null. |
array | the update $errors array; |
Reimplemented in quizaccess_offlineattempts, and quizaccess_password.
|
static |
Validate the data from any form fields added using add_settings_form_fields().
array | $errors | the errors found so far. |
array | $data | the submitted form data. |
array | $files | information about any uploaded files. |
mod_quiz_mod_form | $quizform | the quiz form object. |
array\$errors | the updated $errors array. |
Reimplemented from mod_quiz\local\access_rule_base.