MDL-82611 mod_assign: capability check before exporting grade link.

This commit is contained in:
Paul Holden
2024-07-26 21:19:55 +01:00
parent 1a33da6637
commit dc03f9d4c9
2 changed files with 11 additions and 13 deletions
+9 -13
View File
@@ -14,14 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Output the actionbar for this activity.
*
* @package mod_assign
* @copyright 2021 Adrian Greeve <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\output;
use templatable;
@@ -56,10 +48,14 @@ class actionmenu implements templatable, renderable {
* @return array Data to be used for a template.
*/
public function export_for_template(\renderer_base $output): array {
return [
'submissionlink' => (new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'grading']))->out(false),
'gradelink' => (new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'grader']))->out(false)
];
}
$submissionlink = new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'grading']);
$return = ['submissionlink' => $submissionlink->out(false)];
if (has_capability('mod/assign:grade', \context_module::instance($this->cmid))) {
$gradelink = new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'grader']);
$return['gradelink'] = $gradelink->out(false);
}
return $return;
}
}
@@ -37,8 +37,10 @@
<div class="navitem">
<a class="btn btn-secondary mr-1" href="{{submissionlink}}">{{#str}}viewgrading, mod_assign{{/str}}</a>
</div>
{{#gradelink}}
<div class="navitem">
<a class="btn btn-primary" href="{{gradelink}}">{{#str}}gradeverb, core{{/str}}</a>
</div>
{{/gradelink}}
</div>
</div>