Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 1
CRAP
n/a
0 / 0
local_doublemark_extend_settings_navigation
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 1
72
1<?php
2// This file is part of Moodle - https://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle.  If not, see <https://www.gnu.org/licenses/>.
16
17/**
18 * Navigation.
19 *
20 * @package    local_doublemark
21 * @copyright  2026 DevLMS <contact@devlms.com>
22 * @license    https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25/**
26 * Add "Double marking" to an assignment's menu: the lead's page for managers, the marking list for markers.
27 *
28 * @param settings_navigation $nav
29 * @param context $context
30 */
31function local_doublemark_extend_settings_navigation(settings_navigation $nav, context $context) {
32    global $DB, $PAGE;
33    if ($context->contextlevel != CONTEXT_MODULE || !$PAGE->cm || $PAGE->cm->modname !== 'assign') {
34        return;
35    }
36    $node = $nav->find('modulesettings', navigation_node::TYPE_SETTING);
37    if (!$node) {
38        return;
39    }
40    $cmid = (int) $PAGE->cm->id;
41    if (has_capability('local/doublemark:manage', $context)) {
42        $url = new moodle_url('/local/doublemark/manage.php', ['cmid' => $cmid]);
43    } else if (
44        has_capability('local/doublemark:mark', $context)
45            && $DB->record_exists('local_doublemark_config', ['cmid' => $cmid])
46    ) {
47        $url = new moodle_url('/local/doublemark/mark.php', ['cmid' => $cmid]);
48    } else {
49        return;
50    }
51    $node->add(
52        get_string('pluginname', 'local_doublemark'),
53        $url,
54        navigation_node::TYPE_SETTING,
55        null,
56        'local_doublemark',
57        new pix_icon('i/grades', '')
58    );
59}