|
| __construct ($quizobj, $timenow) |
| 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 () |
| Return a brief summary of this rule, to show to users, if required.
|
|
| 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 | 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 | 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 {.
|
|
Base class for rules that restrict the ability to attempt a quiz.
Quiz access rule plugins must sublclass this one to form their main 'rule' class. Most of the methods are defined in a slightly unnatural way because we either want to say that access is allowed, or explain the reason why it is block. Therefore instead of is_access_allowed(...) we have prevent_access(...) that return false if access is permitted, or a string explanation (which is treated as true) if access should be blocked. Slighly unnatural, but actually the easiest way to implement this.
- Copyright
- 2009 Tim Hunt
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- Since
- Moodle 2.2
mod_quiz\local\access_rule_base::description |
( |
| ) |
|
Return a brief summary of this rule, to show to users, if required.
This information is show shown, for example, on the quiz view page, to explain this restriction. There is no obligation to return anything. If it is not appropriate to tell students about this rule, then just return ''.
- Return values
-
string | a message, or array of messages, explaining the restriction (may be '' if no message is appropriate). |
Reimplemented in quizaccess_numattempts, quizaccess_password, quizaccess_seb, and quizaccess_timelimit.
static mod_quiz\local\access_rule_base::get_settings_sql |
( |
| $quizid | ) |
|
|
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 {
- See also
- access_manager\load_settings()}.
If you have some settings that cannot be loaded in this way, then you can use the {
- See also
- get_extra_settings()} method instead, but that has performance implications.
- Parameters
-
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}.) |
- Return values
-
array | with three elements:
- fields: any fields to add to the select list. These should be alised if neccessary so that the field name starts the name of the plugin.
- joins: any joins (should probably be LEFT JOINS) with other tables that are needed.
- params: array of placeholder values that are needed by the SQL. You must used named placeholders, and the placeholder names should start with the plugin name, to avoid collisions.
|
Reimplemented in quizaccess_seb.
mod_quiz\local\access_rule_base::is_finished |
( |
| $numprevattempts, |
|
|
| $lastattempt ) |
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.
- Parameters
-
int | $numprevattempts | the number of previous attempts this user has made. |
stdClass | $lastattempt | information about the user's last completed attempt. |
- Return values
-
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.
mod_quiz\local\access_rule_base::validate_preflight_check |
( |
| $data, |
|
|
| $files, |
|
|
| $errors, |
|
|
| $attemptid ) |
Validate the pre-flight check form submission.
You should only do something here if {
- See also
- is_preflight_check_required()} returned true.
If the form validates, the user will be allowed to continue.
- Parameters
-
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. |
- Return values
-
array | the update $errors array; |
Reimplemented in quizaccess_offlineattempts, and quizaccess_password.