MDL-59239 mod_workshop: Move submission event trigger
[moodle.git] / mod / workshop / submission.php
index 5acbd59..8985e04 100644 (file)
@@ -51,8 +51,6 @@ if ($edit) {
 
 if ($id) { // submission is specified
     $submission = $workshop->get_submission_by_id($id);
-    // Trigger submission viewed event.
-    $workshop->set_submission_viewed($submission);
 
 } else { // no submission specified
     if (!$submission = $workshop->get_submission_by_author($USER->id)) {
@@ -124,6 +122,11 @@ if ($submission->id and ($ownsubmission or $canviewall or $isreviewer)) {
     print_error('nopermissions', 'error', $workshop->view_url(), 'view or create submission');
 }
 
+if ($submission->id) {
+    // Trigger submission viewed event.
+    $workshop->set_submission_viewed($submission);
+}
+
 if ($assess and $submission->id and !$isreviewer and $canallocate and $workshop->assessing_allowed($USER->id)) {
     require_sesskey();
     $assessmentid = $workshop->add_allocation($submission, $USER->id);