Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 400] [Versions 311 and 401]

Entity model representing quiz settings for the seb plugin.

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

Defines 1 class


Class: quiz_settings  - X-Ref

Entity model representing quiz settings for the seb plugin.

define_properties()   X-Ref
Return the definition of the properties of this model.

return: array

get_by_quiz_id(int $quizid)   X-Ref
Return an instance by quiz id.

This method gets data from cache before doing any DB calls.

param: int $quizid Quiz id.
return: false|\quizaccess_seb\quiz_settings

get_config_by_quiz_id(int $quizid)   X-Ref
Return cached SEB config represented as a string by quiz ID.

param: int $quizid Quiz id.
return: string|null

get_config_key_by_quiz_id(int $quizid)   X-Ref
Return cached SEB config key by quiz ID.

param: int $quizid Quiz id.
return: string|null

get_config_key_cache()   X-Ref
Return SEB config key cache instance.

return: \cache_application

get_config_cache()   X-Ref
Return SEB config cache instance.

return: \cache_application

get_quiz_settings_cache()   X-Ref
Return quiz settings cache object,

return: \cache_application

after_create()   X-Ref
Adds the new record to the cache.


after_update($result)   X-Ref
Updates the cache record.

param: bool $result

after_save()   X-Ref
Helper method to execute common stuff after create and update.


before_delete()   X-Ref
Removes unnecessary stuff from db.


validate_allowedbrowserexamkeys($keys)   X-Ref
Validate the browser exam keys string.

param: string $keys Newline separated browser exam keys.
return: true|lang_string If there is an error, an error string is returned.

get_allowedbrowserexamkeys()   X-Ref
Get the browser exam keys as a pre-split array instead of just as a string.

return: array

before_update()   X-Ref
Hook to execute before an update.

Please note that at this stage the data has already been validated and therefore
any new data being set will not be validated before it is sent to the database.

before_create()   X-Ref
Hook to execute before a create.

Please note that at this stage the data has already been validated and therefore
any new data being set will not be validated before it is sent to the database.

before_save()   X-Ref
As there is no hook for before both create and update, this function is called by both hooks.


before_validate()   X-Ref
Before validate hook.


process_configs()   X-Ref
Create or update the config string based on the current quiz settings.


get_config_key()   X-Ref
Return SEB config key.

return: string|null

get_config()   X-Ref
Return string representation of the config.

return: string|null

process_seb_config_no()   X-Ref
Case for USE_SEB_NO.


process_seb_config_manually()   X-Ref
Case for USE_SEB_CONFIG_MANUALLY. This creates a plist and applies all settings from the posted form, along with
some defaults.


process_seb_template()   X-Ref
Case for USE_SEB_TEMPLATE. This creates a plist from the template uploaded, then applies the quit password
setting and some defaults.


process_seb_upload_config()   X-Ref
Case for USE_SEB_UPLOAD_CONFIG. This creates a plist from an uploaded configuration file, then applies the quiz
password settings and some defaults.


process_seb_client_config()   X-Ref
Case for USE_SEB_CLIENT_CONFIG. This creates an empty plist to remove the config stored.


process_required_enforced_settings()   X-Ref
Sets or updates some sensible default settings, these are the items 'startURL' and 'sendBrowserExamKey'.


process_bool_settings()   X-Ref
Use the boolean map to add Moodle boolean setting to config PList.


process_bool_setting(string $name)   X-Ref
Process provided single bool setting.

param: string $name Setting name matching one from self::get_bool_seb_setting_map.

process_quit_password_settings()   X-Ref
Turn hashed quit password and quit link into PList strings and add to config PList.


process_quit_url_from_settings()   X-Ref
Sets the quitURL if found in the quiz_settings.


process_quit_url_from_template_or_config()   X-Ref
Sets the quiz_setting's linkquitseb if a quitURL value was found in a template or uploaded config.


process_url_filters()   X-Ref
Turn return separated strings for URL filters into a PList array and add to config PList.


create_filter_rule(string $rulestring, bool $allowed, bool $isregex)   X-Ref
Create a CFDictionary represeting a URL filter rule.

param: string $rulestring The expression to filter with.
param: bool $allowed Allowed or blocked.
param: bool $isregex Regex or simple.
return: CFDictionary A PList dictionary.

get_bool_seb_setting_map()   X-Ref
Map the settings that are booleans to the Safe Exam Browser config keys.

return: array Moodle setting as key, SEB setting as value.

split_keys($keys)   X-Ref
This helper method takes list of browser exam keys in a string and splits it into an array of separate keys.

param: string|null $keys the allowed keys.
return: array of string, the separate keys.