Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
quizaccess_seb\settings_provider Class Reference

Helper class for providing quiz settings, to make setting up quiz form manageable. More...

Static Public Member Functions

static add_prefix (string $name)
 Add prefix to string.
 
static add_seb_settings_fields (\mod_quiz_mod_form $quizform, MoodleQuickForm $mform)
 Add setting fields.
 
static build_setting_capability_name (string $settingname)
 Build a capability name for the provided SEB setting.
 
static can_change_seb_allowedbrowserexamkeys (\context $context)
 Check if the current user can change Allowed Browser Exam Keys setting.
 
static can_change_seb_showsebdownloadlink (\context $context)
 Check if the current user can change Show Safe Exam Browser download button setting.
 
static can_configure_manually (\context $context)
 Check if the current user can config SEB manually.
 
static can_configure_seb (\context $context)
 Check if the current user can configure SEB.
 
static can_manage_seb_config_setting (string $settingname, context $context)
 Check if the current user can manage provided SEB setting.
 
static can_upload_seb_file (\context $context)
 Check if the current user can upload own SEB config file.
 
static can_use_seb_template (\context $context)
 Check if the current user can use preconfigured templates.
 
static delete_uploaded_config_file (string $cmid)
 Cleanup function to delete the saved config when it has not been specified.
 
static filter_plugin_settings (stdClass $settings)
 Filter quiz settings for this plugin only.
 
static get_current_user_draft_file (string $itemid)
 Try and get a file in the user draft filearea by itemid.
 
static get_filemanager_options ()
 Returns a list of options for the file manager element.
 
static get_module_context_sebconfig_file (string $cmid)
 Get the file that is stored in the course module file area.
 
static get_quiz_hideifs ()
 Get the conditions that an element should be hid in the form.
 
static get_requiresafeexambrowser_options (\context $context)
 Returns a list of all options of SEB usage.
 
static get_seb_config_element_defaults ()
 Get the default values of the quiz settings.
 
static get_seb_config_element_types ()
 Get the types of the quiz settings elements.
 
static get_seb_config_elements ()
 Get the type of element for each of the form elements in quiz settings.
 
static get_seb_settings_map ()
 Helper method to return a map of all settings.
 
static is_conflicting_permissions (\context $context)
 Check that we have conflicting permissions.
 
static is_seb_settings_locked ($quizid)
 Check if settings is locked.
 
static save_filemanager_sebconfigfile_draftarea (string $draftitemid, string $cmid)
 Saves filemanager_sebconfigfile files to the moodle storage backend.
 
static validate_draftarea_configfile ($itemid)
 Validate that if a file has been uploaded by current user, that it is a valid PLIST XML file.
 

Public Attributes

const USE_SEB_CLIENT_CONFIG = 4
 Use client config.
 
const USE_SEB_CONFIG_MANUALLY = 1
 Use SEB and configure it manually.
 
const USE_SEB_NO = 0
 No SEB should be used.
 
const USE_SEB_TEMPLATE = 2
 Use SEB config from pre configured template.
 
const USE_SEB_UPLOAD_CONFIG = 3
 Use SEB config from uploaded config file.
 

Static Protected Member Functions

static add_help_button (\mod_quiz_mod_form $quizform, MoodleQuickForm $mform, string $elementname)
 Add help button to the element.
 
static add_seb_allowedbrowserexamkeys (\mod_quiz_mod_form $quizform, MoodleQuickForm $mform)
 Add Allowed Browser Exam Keys setting.
 
static add_seb_config_elements (\mod_quiz_mod_form $quizform, MoodleQuickForm $mform)
 Add SEB config elements.
 
static add_seb_config_file (\mod_quiz_mod_form $quizform, MoodleQuickForm $mform)
 Add upload config file element.
 
static add_seb_header_element (\mod_quiz_mod_form $quizform, MoodleQuickForm $mform)
 Add SEB header element to the form.
 
static add_seb_show_download_link (\mod_quiz_mod_form $quizform, MoodleQuickForm $mform)
 Add Show Safe Exam Browser download button.
 
static add_seb_templates (\mod_quiz_mod_form $quizform, MoodleQuickForm $mform)
 Add Templates element.
 
static add_seb_usage_options (\mod_quiz_mod_form $quizform, MoodleQuickForm $mform)
 Add SEB usage element with all available options.
 
static build_config_capabilities_to_check (string $settingname, array $settings)
 Helper method to build a list of capabilities to check.
 
static freeze_element (\mod_quiz_mod_form $quizform, MoodleQuickForm $mform, string $elementname)
 Freeze form element.
 
static get_template_options ()
 Returns a list of templates.
 
static get_uploaded_seb_file_download_link (\mod_quiz_mod_form $quizform, MoodleQuickForm $mform)
 Return uploaded SEB config file link.
 
static hide_seb_elements (\mod_quiz_mod_form $quizform, MoodleQuickForm $mform)
 Hide SEB elements if required.
 
static insert_element (\mod_quiz_mod_form $quizform, MoodleQuickForm $mform, HTML_QuickForm_element $element, $before='security')
 Insert form element.
 
static lock_seb_elements (\mod_quiz_mod_form $quizform, MoodleQuickForm $mform)
 Lock SEB elements if required.
 
static remove_element (\mod_quiz_mod_form $quizform, MoodleQuickForm $mform, string $elementname)
 Remove element from the form.
 
static set_default (\mod_quiz_mod_form $quizform, MoodleQuickForm $mform, string $elementname, $value)
 Set default value for the element.
 
static set_type (\mod_quiz_mod_form $quizform, MoodleQuickForm $mform, string $elementname, string $type)
 Set element type.
 

Detailed Description

Helper class for providing quiz settings, to make setting up quiz form manageable.

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

Member Function Documentation

◆ add_help_button()

static quizaccess_seb\settings_provider::add_help_button ( \mod_quiz_mod_form $quizform,
MoodleQuickForm $mform,
string $elementname )
staticprotected

Add help button to the element.

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

◆ add_prefix()

static quizaccess_seb\settings_provider::add_prefix ( string $name)
static

Add prefix to string.

Parameters
string$nameString to add prefix to.
Return values
stringString with prefix.

◆ add_seb_allowedbrowserexamkeys()

static quizaccess_seb\settings_provider::add_seb_allowedbrowserexamkeys ( \mod_quiz_mod_form $quizform,
MoodleQuickForm $mform )
staticprotected

Add Allowed Browser Exam Keys setting.

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

◆ add_seb_config_elements()

static quizaccess_seb\settings_provider::add_seb_config_elements ( \mod_quiz_mod_form $quizform,
MoodleQuickForm $mform )
staticprotected

Add SEB config elements.

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

◆ add_seb_config_file()

static quizaccess_seb\settings_provider::add_seb_config_file ( \mod_quiz_mod_form $quizform,
MoodleQuickForm $mform )
staticprotected

Add upload config file element.

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

◆ add_seb_header_element()

static quizaccess_seb\settings_provider::add_seb_header_element ( \mod_quiz_mod_form $quizform,
MoodleQuickForm $mform )
staticprotected

Add SEB header element to the form.

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

◆ add_seb_settings_fields()

static quizaccess_seb\settings_provider::add_seb_settings_fields ( \mod_quiz_mod_form $quizform,
MoodleQuickForm $mform )
static

Add setting fields.

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

◆ add_seb_show_download_link()

static quizaccess_seb\settings_provider::add_seb_show_download_link ( \mod_quiz_mod_form $quizform,
MoodleQuickForm $mform )
staticprotected

Add Show Safe Exam Browser download button.

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

◆ add_seb_templates()

static quizaccess_seb\settings_provider::add_seb_templates ( \mod_quiz_mod_form $quizform,
MoodleQuickForm $mform )
staticprotected

Add Templates element.

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

◆ add_seb_usage_options()

static quizaccess_seb\settings_provider::add_seb_usage_options ( \mod_quiz_mod_form $quizform,
MoodleQuickForm $mform )
staticprotected

Add SEB usage element with all available options.

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

◆ build_config_capabilities_to_check()

static quizaccess_seb\settings_provider::build_config_capabilities_to_check ( string $settingname,
array $settings )
staticprotected

Helper method to build a list of capabilities to check.

Parameters
string$settingnameGiven setting name to build caps for.
array$settingsA list of settings to go through.
Return values
array

◆ build_setting_capability_name()

static quizaccess_seb\settings_provider::build_setting_capability_name ( string $settingname)
static

Build a capability name for the provided SEB setting.

Parameters
string$settingnameName of the setting.
Return values
string

◆ can_change_seb_allowedbrowserexamkeys()

static quizaccess_seb\settings_provider::can_change_seb_allowedbrowserexamkeys ( \context $context)
static

Check if the current user can change Allowed Browser Exam Keys setting.

Parameters
context$contextContext to check access in.
Return values
bool

◆ can_change_seb_showsebdownloadlink()

static quizaccess_seb\settings_provider::can_change_seb_showsebdownloadlink ( \context $context)
static

Check if the current user can change Show Safe Exam Browser download button setting.

Parameters
context$contextContext to check access in.
Return values
bool

◆ can_configure_manually()

static quizaccess_seb\settings_provider::can_configure_manually ( \context $context)
static

Check if the current user can config SEB manually.

Parameters
context$contextContext to check access in.
Return values
bool

◆ can_configure_seb()

static quizaccess_seb\settings_provider::can_configure_seb ( \context $context)
static

Check if the current user can configure SEB.

Parameters
context$contextContext to check access in.
Return values
bool

◆ can_manage_seb_config_setting()

static quizaccess_seb\settings_provider::can_manage_seb_config_setting ( string $settingname,
context $context )
static

Check if the current user can manage provided SEB setting.

Parameters
string$settingnameName of the setting.
context$contextContext to check access in.
Return values
bool

◆ can_upload_seb_file()

static quizaccess_seb\settings_provider::can_upload_seb_file ( \context $context)
static

Check if the current user can upload own SEB config file.

Parameters
context$contextContext to check access in.
Return values
bool

◆ can_use_seb_template()

static quizaccess_seb\settings_provider::can_use_seb_template ( \context $context)
static

Check if the current user can use preconfigured templates.

Parameters
context$contextContext to check access in.
Return values
bool

◆ delete_uploaded_config_file()

static quizaccess_seb\settings_provider::delete_uploaded_config_file ( string $cmid)
static

Cleanup function to delete the saved config when it has not been specified.

This will be called when settings_provider\USE_SEB_UPLOAD_CONFIG is not true.

Parameters
string$cmidThe cmid of for the quiz.
Return values
boolAlways true or exception if error occurred

◆ filter_plugin_settings()

static quizaccess_seb\settings_provider::filter_plugin_settings ( stdClass $settings)
static

Filter quiz settings for this plugin only.

Parameters
stdClass$settingsQuiz settings.
Return values
stdClassFiltered settings.

◆ freeze_element()

static quizaccess_seb\settings_provider::freeze_element ( \mod_quiz_mod_form $quizform,
MoodleQuickForm $mform,
string $elementname )
staticprotected

Freeze form element.

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

◆ get_current_user_draft_file()

static quizaccess_seb\settings_provider::get_current_user_draft_file ( string $itemid)
static

Try and get a file in the user draft filearea by itemid.

Parameters
string$itemidItem ID of the file.
Return values
stored_file|nullReturns null if no file is found.

◆ get_filemanager_options()

static quizaccess_seb\settings_provider::get_filemanager_options ( )
static

Returns a list of options for the file manager element.

Return values
array

◆ get_module_context_sebconfig_file()

static quizaccess_seb\settings_provider::get_module_context_sebconfig_file ( string $cmid)
static

Get the file that is stored in the course module file area.

Parameters
string$cmidThe course module id which is used as an itemid reference.
Return values
stored_file|nullReturns null if no file is found.

◆ get_quiz_hideifs()

static quizaccess_seb\settings_provider::get_quiz_hideifs ( )
static

Get the conditions that an element should be hid in the form.

Expects matching using 'eq'.

Array key is name of 'form element'/'database column (excluding prefix)'. Values are instances of hideif_rule class.

Return values
arrayList of rules per element.

◆ get_requiresafeexambrowser_options()

static quizaccess_seb\settings_provider::get_requiresafeexambrowser_options ( \context $context)
static

Returns a list of all options of SEB usage.

Parameters
context$contextContext used with capability checking selection options.
Return values
array

◆ get_seb_config_element_defaults()

static quizaccess_seb\settings_provider::get_seb_config_element_defaults ( )
static

Get the default values of the quiz settings.

Array key is name of 'form element'/'database column (excluding prefix)'.

Return values
arrayList of settings and their defaults.

◆ get_seb_config_element_types()

static quizaccess_seb\settings_provider::get_seb_config_element_types ( )
static

Get the types of the quiz settings elements.

Return values
arrayList of types for the setting elements.

◆ get_seb_config_elements()

static quizaccess_seb\settings_provider::get_seb_config_elements ( )
static

Get the type of element for each of the form elements in quiz settings.

Contains all setting elements. Array key is name of 'form element'/'database column (excluding prefix)'.

Return values
arrayAll quiz form elements to be added and their types.

◆ get_seb_settings_map()

static quizaccess_seb\settings_provider::get_seb_settings_map ( )
static

Helper method to return a map of all settings.

Return values
array

◆ get_template_options()

static quizaccess_seb\settings_provider::get_template_options ( )
staticprotected

Returns a list of templates.

Return values
array

◆ get_uploaded_seb_file_download_link()

static quizaccess_seb\settings_provider::get_uploaded_seb_file_download_link ( \mod_quiz_mod_form $quizform,
MoodleQuickForm $mform )
staticprotected

Return uploaded SEB config file link.

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

◆ hide_seb_elements()

static quizaccess_seb\settings_provider::hide_seb_elements ( \mod_quiz_mod_form $quizform,
MoodleQuickForm $mform )
staticprotected

Hide SEB elements if required.

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

◆ insert_element()

static quizaccess_seb\settings_provider::insert_element ( \mod_quiz_mod_form $quizform,
MoodleQuickForm $mform,
HTML_QuickForm_element $element,
$before = 'security' )
staticprotected

Insert form element.

Parameters
mod_quiz_mod_form$quizformthe quiz settings form that is being built.
MoodleQuickForm$mformthe wrapped MoodleQuickForm.
HTML_QuickForm_element$elementElement to insert.
string$beforeInsert element before.

◆ is_conflicting_permissions()

static quizaccess_seb\settings_provider::is_conflicting_permissions ( \context $context)
static

Check that we have conflicting permissions.

In Some point we can have settings save by the person who use specific type of SEB usage (e.g. use templates). But then another person who can't use template (but still can update other settings) edit the same quiz. This is conflict of permissions and we'd like to build the settings form having this in mind.

Parameters
context$contextContext used with capability checking.
Return values
bool

◆ is_seb_settings_locked()

static quizaccess_seb\settings_provider::is_seb_settings_locked ( $quizid)
static

Check if settings is locked.

Parameters
int$quizidQuiz ID.
Return values
bool

◆ lock_seb_elements()

static quizaccess_seb\settings_provider::lock_seb_elements ( \mod_quiz_mod_form $quizform,
MoodleQuickForm $mform )
staticprotected

Lock SEB elements if required.

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

◆ remove_element()

static quizaccess_seb\settings_provider::remove_element ( \mod_quiz_mod_form $quizform,
MoodleQuickForm $mform,
string $elementname )
staticprotected

Remove element from the form.

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

◆ save_filemanager_sebconfigfile_draftarea()

static quizaccess_seb\settings_provider::save_filemanager_sebconfigfile_draftarea ( string $draftitemid,
string $cmid )
static

Saves filemanager_sebconfigfile files to the moodle storage backend.

Parameters
string$draftitemidThe id of the draft area to use.
string$cmidThe cmid of for the quiz.
Return values
boolAlways true

◆ set_default()

static quizaccess_seb\settings_provider::set_default ( \mod_quiz_mod_form $quizform,
MoodleQuickForm $mform,
string $elementname,
$value )
staticprotected

Set default value for the element.

Parameters
mod_quiz_mod_form$quizformthe quiz settings form that is being built.
MoodleQuickForm$mformthe wrapped MoodleQuickForm.
string$elementnameElement name.
mixed$valueDefault value.

◆ set_type()

static quizaccess_seb\settings_provider::set_type ( \mod_quiz_mod_form $quizform,
MoodleQuickForm $mform,
string $elementname,
string $type )
staticprotected

Set element type.

Parameters
mod_quiz_mod_form$quizformthe quiz settings form that is being built.
MoodleQuickForm$mformthe wrapped MoodleQuickForm.
string$elementnameElement name.
string$typeType of the form element.

◆ validate_draftarea_configfile()

static quizaccess_seb\settings_provider::validate_draftarea_configfile ( $itemid)
static

Validate that if a file has been uploaded by current user, that it is a valid PLIST XML file.

This function is only called if requiresafeexambrowser == settings_provider\USE_SEB_UPLOAD_CONFIG.

Parameters
string$itemidItem ID of file in user draft file area.
Return values
void|lang_string

Member Data Documentation

◆ USE_SEB_CLIENT_CONFIG

const quizaccess_seb\settings_provider::USE_SEB_CLIENT_CONFIG = 4

Use client config.

Not SEB config is required.


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