MDL-73462 navigation: Leverage participants bar for category

This commit is contained in:
Peter Dias 2022-03-02 08:33:34 +08:00
parent 081b255ab0
commit 4d5a25ffde
7 changed files with 24 additions and 21 deletions

View File

@ -183,10 +183,7 @@ switch ($context->contextlevel) {
break;
}
// In a course category context we leverage overflow for the tertiary navigation
if ($context->contextlevel != CONTEXT_COURSECAT) {
$PAGE->set_navigation_overflow_state(false);
}
$PAGE->set_navigation_overflow_state(false);
// Within a course context we need to explicitly set active tab as there isn't a reference in the nav tree.
if ($context->contextlevel == CONTEXT_COURSE) {
@ -208,7 +205,7 @@ if ($roleid) {
if ($backurl) {
echo $OUTPUT->render(new single_button($backurl, get_string('back'), 'get'));
} else if ($context->contextlevel == CONTEXT_COURSE || $context->contextlevel == CONTEXT_MODULE) {
} else if (in_array($context->contextlevel, [CONTEXT_COURSE, CONTEXT_MODULE, CONTEXT_COURSECAT])) {
// The front page doesn't have an intermediate page 'other users' but needs similar tertiary nav like a standard course.
echo $OUTPUT->render_participants_tertiary_nav($course);
}

View File

@ -126,13 +126,10 @@ if (!is_null($reportuser)) {
$rolenames = role_get_names($context);
}
// In a course category context we leverage overflow for the tertiary navigation
if ($context->contextlevel != CONTEXT_COURSECAT) {
$PAGE->set_navigation_overflow_state(false);
}
$PAGE->set_navigation_overflow_state(false);
echo $OUTPUT->header();
if ($context->contextlevel == CONTEXT_COURSE || $context->contextlevel == CONTEXT_MODULE) {
if (in_array($context->contextlevel, [CONTEXT_COURSE, CONTEXT_MODULE, CONTEXT_COURSECAT])) {
echo $OUTPUT->render_participants_tertiary_nav($course);
}

View File

@ -204,13 +204,10 @@ if ($capability && ($allowoverrides || ($allowsafeoverrides && is_safe_capabilit
}
}
// When we are within a category context we leave it to the overflow state to display additional nav nodes.
if ($context->contextlevel != CONTEXT_COURSECAT) {
$PAGE->set_navigation_overflow_state(false);
}
$PAGE->set_navigation_overflow_state(false);
echo $OUTPUT->header();
if ($context->contextlevel == CONTEXT_COURSE || $context->contextlevel == CONTEXT_MODULE) {
if (in_array($context->contextlevel, [CONTEXT_COURSE, CONTEXT_MODULE, CONTEXT_COURSECAT])) {
echo $OUTPUT->render_participants_tertiary_nav($course);
}

View File

@ -81,6 +81,10 @@ course formats don't have their own renderer.
- Returns courses the user is enrolled in which contain at least one action event in the supplied time/text filtering parameters.
- Provides a similar response to get_enrolled_courses_by_timeline_classification, but omits courses which have no matching
action events.
* The following functions have been deprecated in favour the tertiary navigation constructs:
- management_heading
- course_search_form
- print_course_request_buttons
=== 3.11 ===
* A new callback xxx_coursemodule_definition_after_data that allows plugins to extend activity forms after the data is set.

View File

@ -142,7 +142,7 @@ class secondary extends view {
'edit' => 1,
'permissions' => 2,
'roles' => 2.1,
'checkpermissions' => 2.2,
'rolecheck' => 2.2,
]
];
}

View File

@ -47,7 +47,13 @@ class participants_action_bar implements \renderable {
public function __construct(object $course, moodle_page $page, ?string $renderedcontent) {
$this->course = $course;
$this->page = $page;
$node = $this->page->context->contextlevel == CONTEXT_MODULE ? 'modulesettings' : 'users';
$node = 'users';
if ($this->page->context->contextlevel == CONTEXT_MODULE) {
$node = 'modulesettings';
} else if ($this->page->context->contextlevel == CONTEXT_COURSECAT) {
$node = 'categorysettings';
}
$this->node = $this->page->settingsnav->find($node, null);
$this->renderedcontent = $renderedcontent;
}
@ -91,7 +97,8 @@ class participants_action_bar implements \renderable {
$formattedcontent = [];
$enrolmentsheading = get_string('enrolments', 'enrol');
if ($this->page->context->contextlevel != CONTEXT_MODULE) {
if ($this->page->context->contextlevel != CONTEXT_MODULE &&
$this->page->context->contextlevel != CONTEXT_COURSECAT) {
// Pre-populate the formatted tertiary nav items with the "Enrolled users" node if user can view the participants page.
$coursecontext = context_course::instance($this->course->id);
$canviewparticipants = course_can_view_participants($coursecontext);
@ -136,8 +143,9 @@ class participants_action_bar implements \renderable {
}
}
// If we are accessing a page from a module context additional nodes will not be visible.
if ($this->page->context->contextlevel != CONTEXT_MODULE) {
// If we are accessing a page from a module/category context additional nodes will not be visible.
if ($this->page->context->contextlevel != CONTEXT_MODULE &&
$this->page->context->contextlevel != CONTEXT_COURSECAT) {
// Need to do some funky code here to find out if we have added third party navigation nodes.
$thirdpartynodearray = $this->get_thirdparty_node_array() ?: [];
$formattedcontent = array_merge($formattedcontent, $thirdpartynodearray);

View File

@ -5447,7 +5447,7 @@ class settings_navigation extends navigation_node {
if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride',
'moodle/role:override', 'moodle/role:assign'), $catcontext)) {
$url = new moodle_url('/'.$CFG->admin.'/roles/check.php', array('contextid' => $catcontext->id));
$categorynode->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING, null, 'checkpermissions', new pix_icon('i/checkpermissions', ''));
$categorynode->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING, null, 'rolecheck', new pix_icon('i/checkpermissions', ''));
}
// Add the context locking node.