Merge branch 'MDL-58983-master' of git://github.com/damyon/moodle
authorDavid Monllao <davidm@moodle.com>
Tue, 26 Dec 2017 13:00:48 +0000 (14:00 +0100)
committerDavid Monllao <davidm@moodle.com>
Wed, 27 Dec 2017 16:54:56 +0000 (17:54 +0100)
mod/assign/locallib.php
mod/assign/renderable.php
mod/assign/renderer.php

index 29eb08d..f528767 100644 (file)
@@ -5323,7 +5323,8 @@ class assign {
                                                   $this->get_course_module()->id,
                                                   $this->count_submissions_need_grading(),
                                                   $instance->teamsubmission,
-                                                  $warnofungroupedusers);
+                                                  $warnofungroupedusers,
+                                                  $this->can_grade());
         } else {
             // The active group has already been updated in groups_print_activity_menu().
             $countparticipants = $this->count_participants($activitygroup);
@@ -5337,7 +5338,8 @@ class assign {
                                                   $this->get_course_module()->id,
                                                   $this->count_submissions_need_grading(),
                                                   $instance->teamsubmission,
-                                                  false);
+                                                  false,
+                                                  $this->can_grade());
 
         }
 
index 8c6435e..06eb4be 100644 (file)
@@ -748,6 +748,8 @@ class assign_grading_summary implements renderable {
     public $teamsubmission = false;
     /** @var boolean warnofungroupedusers - Do we need to warn people that there are users without groups */
     public $warnofungroupedusers = false;
+    /** @var boolean cangrade - Can the current user grade students? */
+    public $cangrade = false;
 
     /**
      * constructor
@@ -762,6 +764,7 @@ class assign_grading_summary implements renderable {
      * @param int $coursemoduleid
      * @param int $submissionsneedgradingcount
      * @param bool $teamsubmission
+     * @param bool $cangrade
      */
     public function __construct($participantcount,
                                 $submissiondraftsenabled,
@@ -773,7 +776,8 @@ class assign_grading_summary implements renderable {
                                 $coursemoduleid,
                                 $submissionsneedgradingcount,
                                 $teamsubmission,
-                                $warnofungroupedusers) {
+                                $warnofungroupedusers,
+                                $cangrade = true) {
         $this->participantcount = $participantcount;
         $this->submissiondraftsenabled = $submissiondraftsenabled;
         $this->submissiondraftscount = $submissiondraftscount;
@@ -785,6 +789,7 @@ class assign_grading_summary implements renderable {
         $this->submissionsneedgradingcount = $submissionsneedgradingcount;
         $this->teamsubmission = $teamsubmission;
         $this->warnofungroupedusers = $warnofungroupedusers;
+        $this->cangrade = $cangrade;
     }
 }
 
index b3ba273..cb34eed 100644 (file)
@@ -339,9 +339,11 @@ class mod_assign_renderer extends plugin_renderer_base {
         $urlparams = array('id' => $summary->coursemoduleid, 'action' => 'grading');
         $url = new moodle_url('/mod/assign/view.php', $urlparams);
         $o .= '<a href="' . $url . '" class="btn btn-secondary">' . get_string('viewgrading', 'mod_assign') . '</a> ';
-        $urlparams = array('id' => $summary->coursemoduleid, 'action' => 'grader');
-        $url = new moodle_url('/mod/assign/view.php', $urlparams);
-        $o .= '<a href="' . $url . '" class="btn btn-primary">' . get_string('grade') . '</a>';
+        if ($summary->cangrade) {
+            $urlparams = array('id' => $summary->coursemoduleid, 'action' => 'grader');
+            $url = new moodle_url('/mod/assign/view.php', $urlparams);
+            $o .= '<a href="' . $url . '" class="btn btn-primary">' . get_string('grade') . '</a>';
+        }
         $o .= $this->output->container_end();
 
         // Close the container and insert a spacer.