Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-39760: mod_assign: Add few more callback methods.

Adds lock, unlock and release_to_draft. All of them accept single parameter -
an assign_submission record.
  • Loading branch information...
commit e2d5b6cbc822f2f0d826086567304c5fcd385a43 1 parent d3cf194
@kabalin kabalin authored
Showing with 52 additions and 0 deletions.
  1. +24 −0 mod/assign/locallib.php
  2. +28 −0 mod/assign/submissionplugin.php
View
24 mod/assign/locallib.php
@@ -5262,6 +5262,13 @@ protected function process_revert_to_draft($userid = 0) {
$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;
@@ -5298,6 +5305,15 @@ protected function process_lock($userid = 0) {
$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);
@@ -5326,6 +5342,14 @@ protected function process_unlock($userid = 0) {
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;
View
28 mod/assign/submissionplugin.php
@@ -84,4 +84,32 @@ public function submit_for_grading($submission) {
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) {
+ }
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.