Merge branch 'master_MDL-65116' of https://github.com/yao9394/moodle
[moodle.git] / mod / assign / locallib.php
index aad0975..7211b0d 100644 (file)
@@ -5592,7 +5592,7 @@ class assign {
                 $this->is_any_submission_plugin_enabled(),
                 $this->count_submissions_with_status($submitted, $activitygroup),
                 $instance->cutoffdate,
-                $instance->duedate,
+                $this->get_duedate($activitygroup),
                 $this->get_course_module()->id,
                 $this->count_submissions_need_grading($activitygroup),
                 $instance->teamsubmission,
@@ -5612,7 +5612,7 @@ class assign {
                 $this->is_any_submission_plugin_enabled(),
                 $this->count_submissions_with_status($submitted, $activitygroup),
                 $instance->cutoffdate,
-                $instance->duedate,
+                $this->get_duedate($activitygroup),
                 $this->get_course_module()->id,
                 $this->count_submissions_need_grading($activitygroup),
                 $instance->teamsubmission,
@@ -5627,6 +5627,28 @@ class assign {
         return $summary;
     }
 
+    /**
+     * Return group override duedate.
+     *
+     * @param int $activitygroup Activity active group
+     * @return int $duedate
+     */
+    private function  get_duedate($activitygroup = null) {
+        global $DB;
+
+        if ($activitygroup === null) {
+            $activitygroup = groups_get_activity_group($this->get_course_module());
+        }
+        if ($this->can_view_grades()) {
+            $params = array('groupid' => $activitygroup, 'assignid' => $this->get_instance()->id);
+            $groupoverride = $DB->get_record('assign_overrides', $params);
+            if (!empty($groupoverride->duedate)) {
+                return $groupoverride->duedate;
+            }
+        }
+        return $this->get_instance()->duedate;
+    }
+
     /**
      * View submissions page (contains details of current submission).
      *