Merge branch 'MDL-70110-master' of https://github.com/septatrix/moodle
[moodle.git] / mod / assign / externallib.php
index 9c7bf14..86d81e3 100644 (file)
@@ -2376,8 +2376,8 @@ class mod_assign_external extends external_api {
         }
 
         // Retrieve the rest of the renderable objects.
-        $cansubmit = has_capability('mod/assign:submit', $context, $user, false);
-        if ($cansubmit || $assign->get_user_submission($user->id, false) !== false) {
+        if (has_capability('mod/assign:viewownsubmissionsummary', $context, $user, false)) {
+            // The user can view the submission summary.
             $lastattempt = $assign->get_assign_submission_status_renderable($user, true);
         }
 
@@ -2433,8 +2433,8 @@ class mod_assign_external extends external_api {
             }
 
             // Can edit its own submission?
-            $lastattempt->caneditowner = $cansubmit && $assign->submissions_open($user->id)
-                && $assign->is_any_submission_plugin_enabled();
+            $lastattempt->caneditowner = has_capability('mod/assign:submit', $context, $user, false)
+                && $assign->submissions_open($user->id) && $assign->is_any_submission_plugin_enabled();
 
             $result['lastattempt'] = $lastattempt;
         }