Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
mod_quiz\local\override_manager Class Reference

Public Member Functions

 __construct (protected stdClass readonly stdClass $quiz, public context_module readonly context_module $context)
 Create override manager.
 
 delete_all_overrides (bool $shouldlog=true)
 Deletes all the overrides for the linked quiz.
 
 delete_overrides (array $overrides, bool $shouldlog=true)
 Deletes the given overrides in the quiz linked to the override manager.
 
 delete_overrides_by_id (array $ids, bool $shouldlog=true)
 Deletes overrides given just their ID.
 
 get_all_overrides ()
 Returns all overrides for the linked quiz.
 
 parse_formdata (array $formdata)
 Parses the formdata by finding only the OVERRIDEABLE_QUIZ_SETTINGS, clearing any values that match the existing quiz, and re-adds the user or group id.
 
 require_manage_capability ()
 Requires the user has the override management capability.
 
 require_read_capability ()
 Requires the user has the override viewing capability.
 
 save_override (array $formdata)
 Saves the given override.
 
 validate_data (array $formdata)
 Validates the data, usually from a moodleform or a webservice call.
 

Static Public Member Functions

static delete_orphaned_group_overrides_in_course (int $courseid)
 Deletes orphaned group overrides in a given course.
 

Constructor & Destructor Documentation

◆ __construct()

mod_quiz\local\override_manager::__construct ( protected stdClass readonly stdClass $quiz,
public context_module readonly context_module $context )

Create override manager.

Parameters
stdClass$quizThe quiz to link the manager to.
context_module$contextContext being operated in
Parameters
$quizThe quiz linked to this manager instance *
$contextThe context being operated in *

Member Function Documentation

◆ delete_all_overrides()

mod_quiz\local\override_manager::delete_all_overrides ( bool $shouldlog = true)

Deletes all the overrides for the linked quiz.

Parameters
bool$shouldlogIf true, will log a override_deleted event

◆ delete_orphaned_group_overrides_in_course()

static mod_quiz\local\override_manager::delete_orphaned_group_overrides_in_course ( int $courseid)
static

Deletes orphaned group overrides in a given course.

Note - permissions are not checked and events are not logged for performance reasons.

Parameters
int$courseidID of course to delete orphaned group overrides in
Return values
arrayarray of quizzes that had orphaned group overrides.

◆ delete_overrides()

mod_quiz\local\override_manager::delete_overrides ( array $overrides,
bool $shouldlog = true )

Deletes the given overrides in the quiz linked to the override manager.

Note - capabilities are not checked, {

See also
require_manage_capability()}
Parameters
array$overridesoverride to delete. Must specify an id, quizid, and either a userid or groupid.
bool$shouldlogIf true, will log a override_deleted event

◆ delete_overrides_by_id()

mod_quiz\local\override_manager::delete_overrides_by_id ( array $ids,
bool $shouldlog = true )

Deletes overrides given just their ID.

Note, the given IDs must exist otherwise an exception will be thrown. Also note, capabilities are not checked, {

See also
require_manage_capability()}
Parameters
array$idsIDs of overrides to delete
bool$shouldlogIf true, will log a override_deleted event

◆ get_all_overrides()

mod_quiz\local\override_manager::get_all_overrides ( )

Returns all overrides for the linked quiz.

Return values
arrayof quiz_override records

◆ parse_formdata()

mod_quiz\local\override_manager::parse_formdata ( array $formdata)

Parses the formdata by finding only the OVERRIDEABLE_QUIZ_SETTINGS, clearing any values that match the existing quiz, and re-adds the user or group id.

Parameters
array$formdatadata usually from moodleform or webservice call.
Return values
arrayarray containing parsed formdata, with keys as the properties and values as the values. Any values set the same as the existing quiz are set to null.

◆ save_override()

mod_quiz\local\override_manager::save_override ( array $formdata)

Saves the given override.

If an id is given, it updates, otherwise it creates a new one. Note, capabilities are not checked, {

See also
require_manage_capability()}
Parameters
array$formdatadata usually from moodleform or webservice call.
Return values
intupdated/inserted record id

◆ validate_data()

mod_quiz\local\override_manager::validate_data ( array $formdata)

Validates the data, usually from a moodleform or a webservice call.

If it contains an 'id' property, additional validation is performed against the existing record.

Parameters
array$formdatadata from moodleform or webservice call.
Return values
arrayarray where the keys are error elements, and the values are lists of errors for each element.

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