MDL-52566 mod/assign: Fix group submission draft records
authorClement Smith <cdsmith@umn.edu>
Fri, 22 Jan 2016 16:03:11 +0000 (10:03 -0600)
committerClement Smith <cdsmith@umn.edu>
Mon, 25 Jan 2016 16:06:45 +0000 (10:06 -0600)
When group assignments are submitted by the first student in a group,
the logic that saves the submission is not creating a draft
assignment record in mdl_assign_submission. This leads to problems
when other functions are used that depend on these records, such as
marking workflow. This fixes the issue and correctly creates
draft assignment submission records for the non-submitting students
in the group.

mod/assign/locallib.php

index f353948..6ce551d 100644 (file)
@@ -5986,6 +5986,17 @@ class assign {
 
         $this->update_submission($submission, $userid, true, $instance->teamsubmission);
 
+        if ($instance->teamsubmission && !$instance->requireallteammemberssubmit) {
+            $team = $this->get_submission_group_members($submission->groupid, true);
+
+            foreach ($team as $member) {
+                if ($member->id != $userid) {
+                    $membersubmission = clone($submission);
+                    $this->update_submission($membersubmission, $member->id, true, $instance->teamsubmission);
+                }
+            }
+        }
+
         // Logging.
         if (isset($data->submissionstatement) && ($userid == $USER->id)) {
             \mod_assign\event\statement_accepted::create_from_submission($this, $submission)->trigger();