Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a link to "Users grades" from the module settings menu #181

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,39 @@ function hvp_update_grades($hvp=null, $userid=0, $nullifnone=true) {
hvp_grade_item_update($hvp);
}
}

/**
* Hook function that is called when settings blocks are being built.
* And adds a link to "Users grades" from the module settings menu.
*
* @param settings_navigation $settings The settings navigation object
* @param navigation_node $navnode The node to add module settings to
* @throws coding_exception
*/
function hvp_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $navnode = null) {
global $PAGE;

if (has_capability('moodle/course:manageactivities', $PAGE->cm->context) &&
$PAGE->cm->context->contextlevel === CONTEXT_MODULE &&
$PAGE->course && $PAGE->course->id !== 1) {
// Only add this settings item on non-site course pages.

if ($settingnode = $settingsnav->find('modulesettings', \settings_navigation::TYPE_SETTING)) {
$strgrades = get_string('grades', 'grades');
$url = new \moodle_url('/mod/hvp/grade.php',
['id' => $PAGE->cm->context->instanceid]);
$hvpgradesnode = \navigation_node::create(
$strgrades,
$url,
\navigation_node::NODETYPE_LEAF,
'hvp',
'hvp',
new \pix_icon('i/grades', $strgrades)
);
if ($PAGE->url->compare($url, URL_MATCH_BASE)) {
$hvpgradesnode->make_active();
}
$settingnode->add_node($hvpgradesnode);
}
}
}