Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Class: quizaccess_seb  - X-Ref

Implementation of the quizaccess_seb plugin.

__construct(\mod_quiz\quiz_settings $quizobj, int $timenow, seb_access_manager $accessmanager)   X-Ref
Create an instance of this rule for a particular quiz.

param: \mod_quiz\quiz_settings $quizobj information about the quiz in question.
param: int $timenow the time that should be considered as 'now'.
param: seb_access_manager $accessmanager the quiz accessmanager.

make(\mod_quiz\quiz_settings $quizobj, $timenow, $canignoretimelimits)   X-Ref
Return an appropriately configured instance of this rule, if it is applicable
to the given quiz, otherwise return null.

param: \mod_quiz\quiz_settings $quizobj information about the quiz in question.
param: int $timenow the time that should be considered as 'now'.
param: bool $canignoretimelimits whether the current user is exempt from
return: access_rule_base|null the rule, if applicable, else null.

add_settings_form_fields(mod_quiz_mod_form $quizform, MoodleQuickForm $mform)   X-Ref
Add any fields that this rule requires to the quiz settings form. This
method is called from {@link mod_quiz_mod_form::definition()}, while the
security section is being built.

param: mod_quiz_mod_form $quizform the quiz settings form that is being built.
param: MoodleQuickForm $mform the wrapped MoodleQuickForm.

validate_settings_form_fields(array $errors,array $data, $files, mod_quiz_mod_form $quizform)   X-Ref
Validate the data from any form fields added using {@link add_settings_form_fields()}.

param: array $errors the errors found so far.
param: array $data the submitted form data.
param: array $files information about any uploaded files.
param: mod_quiz_mod_form $quizform the quiz form object.
return: array $errors the updated $errors array.

save_settings($quiz)   X-Ref
Save any submitted settings when the quiz settings form is submitted. This
is called from {@link quiz_after_add_or_update()} in lib.php.

param: stdClass $quiz the data from the quiz form, including $quiz->id

delete_settings($quiz)   X-Ref
Delete any rule-specific settings when the quiz is deleted. This is called
from {@link quiz_delete_instance()} in lib.php.

param: stdClass $quiz the data from the database, including $quiz->id

get_settings_sql($quizid)   X-Ref
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 \mod_quiz\access_manager::load_settings()}.

If you have some settings that cannot be loaded in this way, then you can
use the {@link get_extra_settings()} method instead, but that has
performance implications.

param: int $quizid the id of the quiz we are loading settings for. This
return: array with three elements:

prevent_access()   X-Ref
Whether the user should be blocked from starting a new attempt or continuing
an attempt now.

return: string false if access should be allowed, a message explaining the

get_user_finished_attempts()   X-Ref
Returns a list of finished attempts for the current user.

return: array

prevent_display_blocks()   X-Ref
Prevent block displaying as configured.


get_reason_text(string $identifier)   X-Ref
Returns reason for access prevention as a text.

param: string $identifier Reason string identifier.
return: string

get_invalid_key_error_message()   X-Ref
Return error message when a SEB key is not valid.

return: string

get_require_seb_error_message()   X-Ref
Return error message when a SEB browser is not used.

return: string

get_quit_button()   X-Ref
Helper function to display an Exit Safe Exam Browser button if configured to do so and attempts are > 0.

return: string empty or a button which has the configured seb quit link.

description()   X-Ref
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: mixed a message, or array of messages, explaining the restriction

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

param: moodle_page $page the page object to initialise.

current_attempt_finished()   X-Ref
This is called when the current attempt at the quiz is finished.


display_buttons(string $buttonshtml, $class = '', array $attributes = null)   X-Ref
Prepare buttons HTML code for being displayed on the screen.

param: string $buttonshtml Html string of the buttons.
param: string $class Optional CSS class (or classes as space-separated list)
param: array $attributes Optional other attributes as array
return: string HTML code of the provided buttons.

get_action_buttons()   X-Ref
Get buttons to prompt user to download SEB or config file or launch SEB.

return: string Html block of all action buttons.

get_download_seb_button()   X-Ref
Get a button to download SEB.

return: string A link to download SafeExam Browser.

get_launch_seb_button()   X-Ref
Get a button to launch Safe Exam Browser.

return: string A link to launch Safe Exam Browser.

get_download_config_button()   X-Ref
Get a button to download Safe Exam Browser config.

return: string A link to launch Safe Exam Browser.

get_seb_download_url()   X-Ref
Returns SEB download URL.

return: string

should_display_download_seb_link()   X-Ref
Check if we should display a link to download Safe Exam Browser.

return: bool