Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions lang/en/format_learningmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
$string['completionrequired'] = 'Completion tracking needs to be enabled to use this course format';
$string['error_nolearningmap'] = 'This course is not ready yet.';
$string['hidefromothers'] = 'hide';
$string['hidesecondarynavforstudents'] = 'Hide secondary navigation for students';
$string['hidesecondarynavforstudents_help'] = 'This will hide the navigation items above the activity content (e.g. "Grades") from the students.';
$string['mainlearningmap'] = 'Main learningmap';
$string['newsection'] = 'New section';
$string['nolearningmap'] = 'No learningmap in the course';
Expand Down
29 changes: 29 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ public function page_set_cm(moodle_page $page) {

parent::page_set_cm($page);

$options = $this->get_format_options();
if (
!empty($options['hidesecondarynavforstudents']) &&
!(has_capability('moodle/course:manageactivities', context_module::instance($page->cm->id)) ||
has_capability('moodle/course:manageactivities', context_course::instance($this->courseid)))
) {
$page->set_secondary_navigation(false);
}

if ($PAGE == $page && $PAGE->has_set_url()) {
$this->set_singleactivity_navigation($page);
}
Expand Down Expand Up @@ -251,6 +260,26 @@ public function supports_ajax() {
$ajaxsupport->capable = true;
return $ajaxsupport;
}

/**
* Defines the course format options.
*
* @param boolean $foreditform whether the options are for the course edit form
* @return array the list of options
*/
public function course_format_options($foreditform = false) {
$options = parent::course_format_options($foreditform);
$options['hidesecondarynavforstudents'] = [
'label' => new \lang_string('hidesecondarynavforstudents', 'format_learningmap'),
'type' => PARAM_BOOL,
'element_type' => 'advcheckbox',
'default' => 0,
'help' => 'hidesecondarynavforstudents',
'help_component' => 'format_learningmap',
];

return $options;
}
}

/**
Expand Down
Loading