Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
|
Implementation of the unit of work pattern for the question engine. More...
Public Member Functions | |
__construct (question_usage_by_activity $quba) | |
Constructor. | |
notify_attempt_added (question_attempt $qa) | |
Called when a new question attempt is added to this usage. | |
notify_attempt_modified (question_attempt $qa) | |
Called when the fields of a question attempt in this usage are modified. | |
notify_attempt_moved (question_attempt $qa, $oldslot) | |
Called when a question_attempt has been moved to a new slot. | |
notify_metadata_added (question_attempt $qa, $name) | |
Called when a new metadata variable is set on a question attempt in this usage. | |
notify_metadata_modified (question_attempt $qa, $name) | |
Called when a metadata variable on a question attempt in this usage is updated. | |
notify_modified () | |
Called when a field of the question_usage_by_activity is changed. | |
notify_step_added (question_attempt_step $step, question_attempt $qa, $seq) | |
Called when a new step is added to a question attempt in this usage. | |
notify_step_deleted (question_attempt_step $step, question_attempt $qa) | |
Called when a new step is updated in a question attempt in this usage. | |
notify_step_modified (question_attempt_step $step, question_attempt $qa, $seq) | |
Called when a new step is updated in a question attempt in this usage. | |
save (question_engine_data_mapper $dm) | |
Write all the changes we have recorded to the database. | |
Protected Member Functions | |
is_step_added (question_attempt_step $step) | |
Determine if a step is new. | |
is_step_deleted (question_attempt_step $step) | |
is_step_modified (question_attempt_step $step) | |
Determine if a step is modified. | |
Protected Attributes | |
question_attempt[] | $attemptsadded = array() |
list of slot => that have been added to the usage. | |
question_attempt[] | $attemptsdeleted = array() |
list of slot => that have been added to the usage. | |
question_attempt[] | $attemptsmodified = array() |
list of slot => that were already in the usage, and which have been modified. | |
array | $metadataadded = array() |
int slot => string name => question_attempt. | |
array | $metadatamodified = array() |
int slot => string name => question_attempt. | |
boolean | $modified = false |
whether any of the fields of the usage have been changed. | |
question_usage_by_activity | $quba |
the usage being tracked. | |
array | $stepsadded = array() |
of array(question_attempt_step, question_attempt id, seq number) of steps that have been added to question attempts in this usage. | |
question_attempt_step[] | $stepsdeleted = array() |
list of question_attempt_step.id => question_attempt_step of steps that were previously stored in the database, but which are no longer required. | |
array | $stepsmodified = array() |
of array(question_attempt_step, question_attempt id, seq number) of steps that have been modified in their attempt. | |
Implementation of the unit of work pattern for the question engine.
See http://martinfowler.com/eaaCatalog/unitOfWork.html. This tracks all the changes to a question_usage_by_activity, and its constituent parts, so that the changes can be saved to the database when save() is called.
question_engine_unit_of_work::__construct | ( | question_usage_by_activity | $quba | ) |
Constructor.
question_usage_by_activity | $quba | the usage to track. |
|
protected |
Determine if a step is new.
If so get its array key.
question_attempt_step | $step | a step |
int|false | if the step is in the list of steps to be added, return the key, otherwise return false. |
|
protected |
question_attempt_step | $step | a step |
bool | whether the step is in the list of steps to be deleted. |
|
protected |
Determine if a step is modified.
If so get its array key.
question_attempt_step | $step | a step |
int|false | if the step is in the list of steps to be modified, return the key, otherwise return false. |
question_engine_unit_of_work::notify_attempt_added | ( | question_attempt | $qa | ) |
Called when a new question attempt is added to this usage.
question_attempt | $qa | the newly added question attempt. |
Implements question_usage_observer.
question_engine_unit_of_work::notify_attempt_modified | ( | question_attempt | $qa | ) |
Called when the fields of a question attempt in this usage are modified.
question_attempt | $qa | the newly added question attempt. |
Implements question_usage_observer.
question_engine_unit_of_work::notify_attempt_moved | ( | question_attempt | $qa, |
$oldslot ) |
Called when a question_attempt has been moved to a new slot.
question_attempt | $qa | The question attempt that was moved. |
int | $oldslot | The previous slot number of that attempt. |
Implements question_usage_observer.
question_engine_unit_of_work::notify_metadata_added | ( | question_attempt | $qa, |
$name ) |
Called when a new metadata variable is set on a question attempt in this usage.
question_attempt | $qa | the question attempt the metadata is being added to. |
int | $name | the name of the metadata variable added. |
Implements question_usage_observer.
question_engine_unit_of_work::notify_metadata_modified | ( | question_attempt | $qa, |
$name ) |
Called when a metadata variable on a question attempt in this usage is updated.
question_attempt | $qa | the question attempt where the metadata is being modified. |
int | $name | the name of the metadata variable modified. |
Implements question_usage_observer.
question_engine_unit_of_work::notify_modified | ( | ) |
Called when a field of the question_usage_by_activity is changed.
Implements question_usage_observer.
question_engine_unit_of_work::notify_step_added | ( | question_attempt_step | $step, |
question_attempt | $qa, | ||
$seq ) |
Called when a new step is added to a question attempt in this usage.
question_attempt_step | $step | the new step. |
question_attempt | $qa | the usage it is being added to. |
int | $seq | the sequence number of the new step. |
Implements question_usage_observer.
question_engine_unit_of_work::notify_step_deleted | ( | question_attempt_step | $step, |
question_attempt | $qa ) |
Called when a new step is updated in a question attempt in this usage.
question_attempt_step | $step | the step to delete. |
question_attempt | $qa | the usage it is being added to. |
Implements question_usage_observer.
question_engine_unit_of_work::notify_step_modified | ( | question_attempt_step | $step, |
question_attempt | $qa, | ||
$seq ) |
Called when a new step is updated in a question attempt in this usage.
question_attempt_step | $step | the step that was updated. |
question_attempt | $qa | the usage it is being added to. |
int | $seq | the sequence number of the new step. |
Implements question_usage_observer.
question_engine_unit_of_work::save | ( | question_engine_data_mapper | $dm | ) |
Write all the changes we have recorded to the database.
question_engine_data_mapper | $dm | the mapper to use to update the database. |