Merge branch 'MDL-37153_master' of https://github.com/pauln/moodle
[moodle.git] / mod / assign / locallib.php
index ad92865..aa51367 100644 (file)
@@ -3231,12 +3231,12 @@ class assign {
     public function can_view_group_submission($groupid) {
         global $USER;
 
-        if (!is_enrolled($this->get_course_context(), $USER->id)) {
-            return false;
-        }
         if (has_capability('mod/assign:grade', $this->context)) {
             return true;
         }
+        if (!is_enrolled($this->get_course_context(), $USER->id)) {
+            return false;
+        }
         $members = $this->get_submission_group_members($groupid, true);
         foreach ($members as $member) {
             if ($member->id == $USER->id) {
@@ -3255,19 +3255,16 @@ class assign {
     public function can_view_submission($userid) {
         global $USER;
 
-        if (is_siteadmin()) {
-            return true;
-        }
-        if (!is_enrolled($this->get_course_context(), $userid)) {
+        if (!$this->is_active_user($userid) && !has_capability('moodle/course:viewsuspendedusers', $this->context)) {
             return false;
         }
-        if ($userid == $USER->id && has_capability('mod/assign:submit', $this->context)) {
+        if (has_capability('mod/assign:grade', $this->context)) {
             return true;
         }
-        if (!$this->is_active_user($userid) && !has_capability('moodle/course:viewsuspendedusers', $this->context)) {
+        if (!is_enrolled($this->get_course_context(), $userid)) {
             return false;
         }
-        if (has_capability('mod/assign:grade', $this->context)) {
+        if ($userid == $USER->id && has_capability('mod/assign:submit', $this->context)) {
             return true;
         }
         return false;