Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
quizaccess_delaybetweenattempts Class Reference

A rule imposing the delay between attempts settings. More...

Inheritance diagram for quizaccess_delaybetweenattempts:
quiz_access_rule_base

Public Member Functions

 add_preflight_check_form_fields (mod_quiz_preflight_check_form $quizform, MoodleQuickForm $mform, $attemptid)
 Add any field you want to pre-flight check form. More...
 
 attempt_must_be_in_popup ()
 
 current_attempt_finished ()
 This is called when the current attempt at the quiz is finished. More...
 
 description ()
 Information, such as might be shown on the quiz view page, relating to this restriction. More...
 
 end_time ($attempt)
 If, because of this rule, the user has to finish their attempt by a certain time, you should override this method to return the attempt end time. More...
 
 get_popup_options ()
 
 get_superceded_rules ()
 It is possible for one rule to override other rules. More...
 
 is_finished ($numprevattempts, $lastattempt)
 If this rule can determine that this user will never be allowed another attempt at this quiz, then return true. More...
 
 is_preflight_check_required ($attemptid)
 
 notify_preflight_check_passed ($attemptid)
 The pre-flight check has passed. More...
 
 prevent_access ()
 Whether the user should be blocked from starting a new attempt or continuing an attempt now. More...
 
 prevent_new_attempt ($numprevattempts, $lastattempt)
 Whether or not a user should be allowed to start a new attempt at this quiz now. More...
 
 setup_attempt_page ($page)
 Sets up the attempt (review or summary) page with any special extra properties required by this rule. More...
 
 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. More...
 
 validate_preflight_check ($data, $files, $errors, $attemptid)
 Validate the pre-flight check form submission. More...
 

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. More...
 
static delete_settings ($quiz)
 Delete any rule-specific settings when the quiz is deleted. More...
 
static get_browser_security_choices ()
 
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(). More...
 
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. More...
 
static make (quiz $quizobj, $timenow, $canignoretimelimits)
 Return an appropriately configured instance of this rule, if it is applicable to the given quiz, otherwise return null. More...
 
static save_settings ($quiz)
 Save any submitted settings when the quiz settings form is submitted. More...
 
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(). More...
 

Protected Member Functions

 compute_next_start_time ($numprevattempts, $lastattempt)
 Compute the next time a student would be allowed to start an attempt, according to this rule. More...
 

Protected Attributes

stdClass $quiz
 the quiz settings.
 
quiz $quizobj
 the quiz object.
 
int $timenow
 the time to use as 'now'.
 

Detailed Description

A rule imposing the delay between attempts settings.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ add_preflight_check_form_fields()

quiz_access_rule_base::add_preflight_check_form_fields ( mod_quiz_preflight_check_form  $quizform,
MoodleQuickForm  $mform,
  $attemptid 
)
inherited

Add any field you want to pre-flight check form.

You should only do something here if is_preflight_check_required() returned true.

Parameters
mod_quiz_preflight_check_form$quizformthe form being built.
MoodleQuickForm$mformThe wrapped MoodleQuickForm.
int | null$attemptidthe id of the current attempt, if there is one, otherwise null.

Reimplemented in quizaccess_timelimit, quizaccess_password, and quizaccess_offlineattempts.

◆ add_settings_form_fields()

static quiz_access_rule_base::add_settings_form_fields ( mod_quiz_mod_form  $quizform,
MoodleQuickForm  $mform 
)
staticinherited

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 seciton is being built.

Parameters
mod_quiz_mod_form$quizformthe quiz settings form that is being built.
MoodleQuickForm$mformthe wrapped MoodleQuickForm.

Reimplemented in quizaccess_offlineattempts.

◆ attempt_must_be_in_popup()

quiz_access_rule_base::attempt_must_be_in_popup ( )
inherited
Return values
booleanwhether this rule requires that the attemp (and review) pages must be displayed in a pop-up window.

Reimplemented in quizaccess_securewindow.

◆ compute_next_start_time()

quizaccess_delaybetweenattempts::compute_next_start_time (   $numprevattempts,
  $lastattempt 
)
protected

Compute the next time a student would be allowed to start an attempt, according to this rule.

Parameters
int$numprevattemptsnumber of previous attempts.
object$lastattemptinformation about the previous attempt.
Return values
numberthe time.

◆ current_attempt_finished()

quiz_access_rule_base::current_attempt_finished ( )
inherited

This is called when the current attempt at the quiz is finished.

This is used, for example by the password rule, to clear the flag in the session.

Reimplemented in quizaccess_password, and quizaccess_offlineattempts.

◆ delete_settings()

static quiz_access_rule_base::delete_settings (   $quiz)
staticinherited

Delete any rule-specific settings when the quiz is deleted.

This is called from quiz_delete_instance() in lib.php.

Parameters
object$quizthe data from the database, including $quiz->id which is the id of the quiz being deleted.
Since
Moodle 2.7.1, 2.6.4, 2.5.7

◆ description()

quiz_access_rule_base::description ( )
inherited

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 ''.

Return values
mixeda message, or array of messages, explaining the restriction (may be '' if no message is appropriate).

Reimplemented in quizaccess_timelimit, quizaccess_safebrowser, quizaccess_password, quizaccess_openclosedate, and quizaccess_numattempts.

◆ end_time()

quiz_access_rule_base::end_time (   $attempt)
inherited

If, because of this rule, the user has to finish their attempt by a certain time, you should override this method to return the attempt end time.

Parameters
object$attemptthe current attempt
Return values
mixedthe attempt close time, or false if there is no close time.

Reimplemented in quizaccess_timelimit, and quizaccess_openclosedate.

◆ get_browser_security_choices()

static quiz_access_rule_base::get_browser_security_choices ( )
staticinherited
Return values
arraykey => lang string any choices to add to the quiz Browser security settings menu.

Reimplemented in quizaccess_securewindow, and quizaccess_safebrowser.

◆ get_extra_settings()

static quiz_access_rule_base::get_extra_settings (   $quizid)
staticinherited

You can use this method to load any extra settings your plugin has that cannot be loaded efficiently with get_settings_sql().

Parameters
int$quizidthe quiz id.
Return values
arraysetting value name => value. The value names should all start with the name of your plugin to avoid collisions.

◆ get_popup_options()

quiz_access_rule_base::get_popup_options ( )
inherited
Return values
arrayany options that are required for showing the attempt page in a popup window.

Reimplemented in quizaccess_securewindow.

◆ get_settings_sql()

static quiz_access_rule_base::get_settings_sql (   $quizid)
staticinherited

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 probalby to read the code of quiz_access_manager::load_settings().

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.

Parameters
int$quizidthe 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
arraywith three elements:
  1. 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.
  2. joins: any joins (should probably be LEFT JOINS) with other tables that are needed.
  3. 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.

◆ get_superceded_rules()

quiz_access_rule_base::get_superceded_rules ( )
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.

Return values
arrayplugin names of other rules that this one replaces. For example array('ipaddress', 'password').

◆ is_finished()

quizaccess_delaybetweenattempts::is_finished (   $numprevattempts,
  $lastattempt 
)

If this rule can determine that this user will never be allowed another attempt at this quiz, then return true.

This is used so we can 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$numattemptsthe number of previous attempts this user has made.
object$lastattemptinformation about the user's last completed attempt.
Return values
booltrue if this rule means that this user will never be allowed another attempt at this quiz.

Reimplemented from quiz_access_rule_base.

◆ is_preflight_check_required()

quiz_access_rule_base::is_preflight_check_required (   $attemptid)
inherited
Parameters
int | null$attemptidthe id of the current attempt, if there is one, otherwise null.
Return values
boolwhether a check is required before the user starts/continues their attempt.

Reimplemented in quizaccess_timelimit, quizaccess_password, and quizaccess_offlineattempts.

◆ make()

static quizaccess_delaybetweenattempts::make ( quiz  $quizobj,
  $timenow,
  $canignoretimelimits 
)
static

Return an appropriately configured instance of this rule, if it is applicable to the given quiz, otherwise return null.

Parameters
quiz$quizobjinformation about the quiz in question.
int$timenowthe time that should be considered as 'now'.
bool$canignoretimelimitswhether the current user is exempt from time limits by the mod/quiz:ignoretimelimits capability.
Return values
quiz_access_rule_base|nullthe rule, if applicable, else null.

Reimplemented from quiz_access_rule_base.

◆ notify_preflight_check_passed()

quiz_access_rule_base::notify_preflight_check_passed (   $attemptid)
inherited

The pre-flight check has passed.

This is a chance to record that fact in some way.

Parameters
int | null$attemptidthe id of the current attempt, if there is one, otherwise null.

Reimplemented in quizaccess_password, and quizaccess_offlineattempts.

◆ prevent_access()

quiz_access_rule_base::prevent_access ( )
inherited

Whether the user should be blocked from starting a new attempt or continuing an attempt now.

Return values
stringfalse if access should be allowed, a message explaining the reason if access should be prevented.

Reimplemented in quizaccess_safebrowser, quizaccess_openclosedate, and quizaccess_ipaddress.

◆ prevent_new_attempt()

quizaccess_delaybetweenattempts::prevent_new_attempt (   $numprevattempts,
  $lastattempt 
)

Whether or not a user should be allowed to start a new attempt at this quiz now.

Parameters
int$numattemptsthe number of previous attempts this user has made.
object$lastattemptinformation about the user's last completed attempt.
Return values
stringfalse if access should be allowed, a message explaining the reason if access should be prevented.

Reimplemented from quiz_access_rule_base.

◆ save_settings()

static quiz_access_rule_base::save_settings (   $quiz)
staticinherited

Save any submitted settings when the quiz settings form is submitted.

This is called from quiz_after_add_or_update() in lib.php.

Parameters
object$quizthe data from the quiz form, including $quiz->id which is the id of the quiz being saved.

◆ setup_attempt_page()

quiz_access_rule_base::setup_attempt_page (   $page)
inherited

Sets up the attempt (review or summary) page with any special extra properties required by this rule.

securewindow rule is an example of where this is used.

Parameters
moodle_page$pagethe page object to initialise.

Reimplemented in quizaccess_securewindow, and quizaccess_safebrowser.

◆ time_left_display()

quiz_access_rule_base::time_left_display (   $attempt,
  $timenow 
)
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.

Parameters
object$attemptthe current attempt
int$timenowthe time now. We don't use $this->timenow, so we can give the user a more accurate indication of how much time is left.
Return values
mixedthe time left in seconds (can be negative) or false if there is no limit.

Reimplemented in quizaccess_timelimit, and quizaccess_openclosedate.

◆ validate_preflight_check()

quiz_access_rule_base::validate_preflight_check (   $data,
  $files,
  $errors,
  $attemptid 
)
inherited

Validate the pre-flight check form submission.

You should only do something here if is_preflight_check_required() returned true.

If the form validates, the user will be allowed to continue.

Parameters
array$datathe submitted form data.
array$filesany files in the submission.
array$errorsthe list of validation errors that is being built up.
int | null$attemptidthe id of the current attempt, if there is one, otherwise null.
Return values
arraythe update $errors array;

Reimplemented in quizaccess_password, and quizaccess_offlineattempts.

◆ validate_settings_form_fields()

static quiz_access_rule_base::validate_settings_form_fields ( array  $errors,
array  $data,
  $files,
mod_quiz_mod_form  $quizform 
)
staticinherited

Validate the data from any form fields added using add_settings_form_fields().

Parameters
array$errorsthe errors found so far.
array$datathe submitted form data.
array$filesinformation about any uploaded files.
mod_quiz_mod_form$quizformthe quiz form object.
Return values
array::$errorsthe updated $errors array.

Reimplemented in quizaccess_offlineattempts.


The documentation for this class was generated from the following file: