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.

Manage the access to the quiz.

Author: Tim Hunt
Author: Luca Bösch <luca.boesch@bfh.ch>
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: 398 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: seb_access_manager  - X-Ref

Manage the access to the quiz.

__construct(quiz_settings $quiz)   X-Ref
The access_manager constructor.

param: quiz_settings $quiz The details of the quiz.

validate_browser_exam_key(?string $browserexamkey = null, ?string $url = null)   X-Ref
Validate browser exam key. It will validate a provided browser exam key if provided, then will fall back to checking
the header.

param: string|null $browserexamkey Optional. Can validate a provided key, or will fall back to checking header.
param: string|null $url Optionally provide URL of page to validate.
return: bool

validate_config_key(?string $configkey = null, ?string $url = null)   X-Ref
Validate a config key. It will check a provided config key if provided then will fall back to checking config
key in header.

param: string|null $configkey Optional. Can validate a provided key, or will fall back to checking header.
param: string|null $url URL of page to validate.
return: bool

seb_required()   X-Ref
Check if Safe Exam Browser is required to access quiz.
If quizsettings do not exist, then there is no requirement for using SEB.

return: bool If required.

validate_basic_header()   X-Ref
This is the basic check for the Safe Exam Browser previously used in the quizaccess_safebrowser plugin that
managed basic Moodle interactions with SEB.

return: bool

is_using_seb()   X-Ref
Check if using Safe Exam Browser.

return: bool

can_bypass_seb()   X-Ref
Check if user has any capability to bypass the Safe Exam Browser requirement.

return: bool True if user can bypass check.

get_this_page_url()   X-Ref
Return the full URL that was used to request the current page, which is
what we need for verifying the X-SafeExamBrowser-RequestHash header.


get_valid_config_key()   X-Ref
Return expected SEB config key.

return: string|null

get_quiz()   X-Ref
Getter for the quiz object.

return: \mod_quiz\quiz_settings

is_allowed_browser_examkeys_configured()   X-Ref
Check that at least one browser exam key exists in the quiz settings.

return: bool True if one or more keys are set in quiz settings.

check_browser_exam_keys(array $keys, string $header, ?string $url = null)   X-Ref
Check the hash from the request header against the permitted browser exam keys.

param: array $keys Allowed browser exam keys.
param: string $header The value of the X-SafeExamBrowser-RequestHash to check.
param: string|null $url URL of page to validate.
return: bool True if the hash matches.

check_key(string $validkey, string $key, ?string $url = null)   X-Ref
Check the hash from the request header against a single permitted key.

param: string $validkey An allowed key.
param: string $key The value of X-SafeExamBrowser-RequestHash, X-SafeExamBrowser-ConfigKeyHash or a provided key to check.
param: string|null $url URL of page to validate.
return: bool True if the hash matches.

get_received_config_key()   X-Ref
Returns Safe Exam Browser Config Key hash.

return: string|null

get_received_browser_exam_key()   X-Ref
Returns the Browser Exam Key hash.

return: string|null

get_seb_use_type()   X-Ref
Get type of SEB usage for the quiz.

return: int

should_validate_basic_header()   X-Ref
Should validate basic header?

return: bool

should_validate_config_key()   X-Ref
Should validate SEB config key?

return: bool

should_validate_browser_exam_key()   X-Ref
Should validate browser exam key?

return: bool

set_session_access(bool $accessallowed)   X-Ref
Set session access for quiz.

param: bool $accessallowed

validate_session_access()   X-Ref
Check session access for quiz if already set.

return: bool

clear_session_access()   X-Ref
Unset the global session access variable for this quiz.


redirect_to_seb_config_link()   X-Ref
Redirect to SEB config link. This will force Safe Exam Browser to be reconfigured.


should_redirect_to_seb_config_link()   X-Ref
Check if we need to redirect to SEB config link.

return: bool