Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 402] [Versions 400 and 403]

Implementation of the quizaccess_seb plugin.

Author: Andrew Madden <andrewmadden@catalyst-au.net>
Author: Dmitrii Metelkin <dmitriim@catalyst-au.net>
Copyright: 2019 Catalyst IT
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 598 lines (23 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: quizaccess_seb  - X-Ref

Implementation of the quizaccess_seb plugin.

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

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

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

return: quiz_access_rule_base|null the rule, if applicable, else null.
param: quiz $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

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()}.

return: array $errors the updated $errors array.
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.

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: object $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: object $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 probalby to read the code of {@link 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.

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

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.

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

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.

return: string HTML code of the provided buttons.
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

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