diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 763d590aca4..a76da5319ab 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -5542,6 +5542,13 @@ class assign { $submission->status = ASSIGN_SUBMISSION_STATUS_DRAFT; $this->update_submission($submission, $userid, true, $this->get_instance()->teamsubmission); + // Give each submission plugin a chance to process the reverting to draft. + $plugins = $this->get_submission_plugins(); + foreach ($plugins as $plugin) { + if ($plugin->is_enabled() && $plugin->is_visible()) { + $plugin->revert_to_draft($submission); + } + } // Update the modified time on the grade (grader modified). $grade = $this->get_user_grade($userid, true); $grade->grader = $USER->id; @@ -5578,6 +5585,15 @@ class assign { $userid = required_param('userid', PARAM_INT); } + // Give each submission plugin a chance to process the locking. + $plugins = $this->get_submission_plugins(); + $submission = $this->get_user_submission($userid, false); + foreach ($plugins as $plugin) { + if ($plugin->is_enabled() && $plugin->is_visible()) { + $plugin->lock($submission); + } + } + $flags = $this->get_user_flags($userid, true); $flags->locked = 1; $this->update_user_flags($flags); @@ -5695,6 +5711,14 @@ class assign { if (!$userid) { $userid = required_param('userid', PARAM_INT); } + // Give each submission plugin a chance to process the unlocking. + $plugins = $this->get_submission_plugins(); + $submission = $this->get_user_submission($userid, false); + foreach ($plugins as $plugin) { + if ($plugin->is_enabled() && $plugin->is_visible()) { + $plugin->unlock($submission); + } + } $flags = $this->get_user_flags($userid, true); $flags->locked = 0; diff --git a/mod/assign/submissionplugin.php b/mod/assign/submissionplugin.php index 68a3da32f22..5b48a38f5b9 100644 --- a/mod/assign/submissionplugin.php +++ b/mod/assign/submissionplugin.php @@ -84,4 +84,32 @@ abstract class assign_submission_plugin extends assign_plugin { public function copy_submission( stdClass $oldsubmission, stdClass $submission) { return true; } + + /* + * Carry out any extra processing required when the work is locked. + * + * @param stdClass $submission - assign_submission data + * @return void + */ + public function lock(stdClass $submission) { + } + + /** + * Carry out any extra processing required when the work is unlocked. + * + * @param stdClass $submission - assign_submission data + * @return void + */ + public function unlock(stdClass $submission) { + } + + /** + * Carry out any extra processing required when the work reverted to draft. + * + * @param stdClass $submission - assign_submission data + * @return void + */ + public function revert_to_draft(stdClass $submission) { + } + }