Skip to content

Commit

Permalink
MDL-72875 course: Introduce tertiary nav in participants
Browse files Browse the repository at this point in the history
- Introduce tertiary nav in the participants page
  • Loading branch information
Peter Dias committed Dec 2, 2021
1 parent d5698ac commit e0d7dbd
Show file tree
Hide file tree
Showing 18 changed files with 370 additions and 55 deletions.
34 changes: 24 additions & 10 deletions admin/roles/assign.php
Expand Up @@ -184,6 +184,25 @@

echo $OUTPUT->header();

$backurl = null;
// We are looking at a particular role. The page URL has been set correctly.
if ($roleid) {
$backurl = $pageurl;
} else if ($context->contextlevel == CONTEXT_COURSE && !$isfrontpage) {
// Return to the intermediary page when within the course context.
$backurl = new moodle_url('/enrol/otherusers.php', ['id' => $course->id]);
} else if ($returnurl) {
// Factor in for $returnurl being passed.
$backurl = new moodle_url($returnurl);
}

if ($backurl) {
echo $OUTPUT->render(new single_button($backurl, get_string('back'), 'get'));
} else if ($isfrontpage) {
// 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);
}

// Print heading.
echo $OUTPUT->heading_with_help($title, 'assignroles', 'core_role');

Expand Down Expand Up @@ -245,7 +264,6 @@
$select = new single_select($PAGE->url, 'roleid', $nameswithcounts, $roleid, null);
$select->label = get_string('assignanotherrole', 'core_role');
echo $OUTPUT->render($select);
echo '<p><a href="' . $url . '">' . get_string('backtoallroles', 'core_role') . '</a></p>';
echo '</div>';

} else if (empty($assignableroles)) {
Expand Down Expand Up @@ -314,17 +332,13 @@

echo html_writer::table($table);

if ($context->contextlevel > CONTEXT_USER) {

if ($returnurl) {
$url = new moodle_url($returnurl);
} else {
if (!$PAGE->has_secondary_navigation() && $context->contextlevel > CONTEXT_USER) {
if (!$returnurl) {
$url = $context->get_url();
echo html_writer::start_tag('div', array('class' => 'backlink'));
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href' => $url));
echo html_writer::end_tag('div');
}

echo html_writer::start_tag('div', array('class'=>'backlink'));
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href' => $url));
echo html_writer::end_tag('div');
}
}

Expand Down
6 changes: 5 additions & 1 deletion admin/roles/check.php
Expand Up @@ -126,6 +126,10 @@
}

echo $OUTPUT->header();
// Display the participants tertiary action bar if within a course context.
if ($course && $context->contextlevel == CONTEXT_COURSE) {
echo $OUTPUT->render_participants_tertiary_nav($course);
}

// Print heading.
echo $OUTPUT->heading($title);
Expand Down Expand Up @@ -180,7 +184,7 @@
echo $OUTPUT->box_end();

// Appropriate back link.
if ($context->contextlevel > CONTEXT_USER) {
if (!$PAGE->has_secondary_navigation() && $context->contextlevel > CONTEXT_USER) {
echo html_writer::start_tag('div', array('class'=>'backlink'));
if ($returnurl) {
$backurl = new moodle_url($returnurl);
Expand Down
3 changes: 3 additions & 0 deletions admin/roles/permissions.php
Expand Up @@ -204,6 +204,9 @@
}

echo $OUTPUT->header();
if ($context->contextlevel == CONTEXT_COURSE && $course) {
echo $OUTPUT->render_participants_tertiary_nav($course);
}
echo $OUTPUT->heading($title);

$adminurl = new moodle_url('/admin/');
Expand Down
115 changes: 115 additions & 0 deletions course/templates/participants_actionbar.mustache
@@ -0,0 +1,115 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core_course/participants_actionbar
Displays the tertiary nav for the participants page
Context variables required for this template:
* urlselect Object - The content to be rendered within the url_select
* renderedcontent String - Any additional content/actions to be displayed inline with the select box
Example context (json):
{
"urlselect" : {
"formid": "url_select_f61834256d7754158",
"classes": "urlselect",
"label": "",
"disabled": false,
"title":null,
"id":"url_select61834256d7754159",
"sesskey":"LWILINyZMH",
"action":"http:\/\/localhost\/stable_master\/course\/jumpto.php",
"showbutton":null,
"options": [
{
"name":"Enrolments",
"isgroup":true,
"options": [
{
"name":"Enrolled users",
"value":"\/user\/index.php?id=4",
"selected":true
},
{
"name":"Enrolment methods",
"value":"\/enrol\/instances.php?id=4",
"selected":false
}
]
},
{
"name":"Groups",
"isgroup":true,
"options": [
{
"name":"Groups",
"value":"\/group\/index.php?id=4",
"selected":false
},
{
"name":"Groupings",
"value":"\/group\/groupings.php?id=4",
"selected":false
},
{
"name":"Overview",
"value":"\/group\/overview.php?id=4",
"selected":false
}
]
},
{
"name":"Permissions",
"isgroup":true,
"options": [
{
"name":"Permissions",
"value":"\/admin\/roles\/permissions.php?contextid=279",
"selected":false
},
{
"name":"Other users",
"value":"\/enrol\/otherusers.php?id=4",
"selected":false
},
{
"name":"Check permissions",
"value":"\/admin\/roles\/check.php?contextid=279",
"selected":false
}
]
}
],
"labelattributes":[],
"helpicon":false,
"attributes":[]
},
"renderedcontent":"<div data-region=\"wrapper\" data-table-uniqueid=\"user-index-participants-4\"><\/div>"
}
}}
<div class="container-fluid pl-0 pb-2" id="action_bar">
<div class="row pl-0 ml-0">
{{#urlselect}}
<div class="col-xs-4 pr-1">
{{> core/url_select }}
</div>
{{/urlselect}}
{{#renderedcontent}}
<div class="col-xs-4 pr-1">
{{{renderedcontent}}}
</div>
{{/renderedcontent}}
</div>
</div>
1 change: 1 addition & 0 deletions enrol/instances.php
Expand Up @@ -186,6 +186,7 @@


echo $OUTPUT->header();
echo $OUTPUT->render_participants_tertiary_nav($course);
echo $OUTPUT->heading(get_string('enrolmentinstances', 'enrol'));

echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthnormal');
Expand Down
1 change: 1 addition & 0 deletions enrol/manual/lib.php
Expand Up @@ -218,6 +218,7 @@ public function get_manual_enrol_button(course_enrolment_manager $manager) {

$button = new enrol_user_button($link, get_string('enrolusers', 'enrol_manual'), 'get');
$button->class .= ' enrol_manual_plugin';
$button->primary = true;

$context = context_course::instance($instance->courseid);
$arguments = array('contextid' => $context->id);
Expand Down
3 changes: 3 additions & 0 deletions enrol/otherusers.php
Expand Up @@ -94,5 +94,8 @@
$PAGE->set_heading($PAGE->title);

echo $OUTPUT->header();
$searchbutton = $table->get_user_search_button();
$searchbutton->primary = true;
echo $OUTPUT->render_participants_tertiary_nav($course, $OUTPUT->render($searchbutton));
echo $renderer->render($table);
echo $OUTPUT->footer();
10 changes: 1 addition & 9 deletions enrol/renderer.php
Expand Up @@ -41,7 +41,7 @@ protected function render_enrol_user_button(enrol_user_button $button) {
'value' => $button->label,
'disabled' => $button->disabled ? 'disabled' : null,
'title' => $button->tooltip,
'class' => 'btn btn-secondary my-1');
'class' => 'btn ' . ($button->primary ? 'btn-primary' : 'btn-secondary'));

if ($button->actions) {
$id = html_writer::random_id('single_button');
Expand Down Expand Up @@ -96,18 +96,10 @@ protected function render_course_enrolment_other_users_table(course_enrolment_ot
$table->initialise_javascript();

$content = '';
$searchbutton = $table->get_user_search_button();
if ($searchbutton) {
$content .= $this->output->render($searchbutton);
}
$content .= html_writer::tag('div', get_string('otheruserdesc', 'enrol'), array('class'=>'otherusersdesc'));
$content .= $this->output->render($table->get_paging_bar());
$content .= html_writer::table($table);
$content .= $this->output->render($table->get_paging_bar());
$searchbutton = $table->get_user_search_button();
if ($searchbutton) {
$content .= $this->output->render($searchbutton);
}
return $content;
}

Expand Down
5 changes: 1 addition & 4 deletions group/groupings.php
Expand Up @@ -59,10 +59,7 @@
$PAGE->set_pagelayout('standard');
echo $OUTPUT->header();

// Add tabs
$currenttab = 'groupings';
require('tabs.php');

echo $OUTPUT->render_participants_tertiary_nav($course);
echo $OUTPUT->heading($strgroupings);

$data = array();
Expand Down
5 changes: 1 addition & 4 deletions group/index.php
Expand Up @@ -170,10 +170,7 @@
$PAGE->set_pagelayout('standard');
echo $OUTPUT->header();

// Add tabs
$currenttab = 'groups';
require('tabs.php');

echo $OUTPUT->render_participants_tertiary_nav($course);
echo $OUTPUT->heading(format_string($course->shortname, true, array('context' => $context)) .' '.$strgroups, 3);

$groups = groups_get_all_groups($courseid);
Expand Down
5 changes: 1 addition & 4 deletions group/overview.php
Expand Up @@ -195,10 +195,7 @@
$PAGE->set_pagelayout('standard');
echo $OUTPUT->header();

// Add tabs
$currenttab = 'overview';
require('tabs.php');

echo $OUTPUT->render_participants_tertiary_nav($course);
/// Print overview
echo $OUTPUT->heading(format_string($course->shortname, true, array('context' => $context)) .' '.$stroverview, 3);

Expand Down
1 change: 1 addition & 0 deletions lang/en/course.php
Expand Up @@ -97,6 +97,7 @@
<p>A number of students in {$a->coursename} have not accessed the course recently.</p>';
$string['noteachinginfomessage'] = 'Hi {$a->userfirstname},
<p>Courses with start dates in the next week have been identified as having no teacher or student enrolments.</p>';
$string['participantsnavigation'] = 'Participants tertiary navigation.';
$string['privacy:perpage'] = 'The number of courses to show per page.';
$string['privacy:completionpath'] = 'Course completion';
$string['privacy:favouritespath'] = 'Course starred information';
Expand Down
7 changes: 7 additions & 0 deletions lib/classes/navigation/views/secondary.php
Expand Up @@ -54,6 +54,13 @@ protected function get_default_course_mapping(): array {
],
self::TYPE_SETTING => [
'editsettings' => 0,
'review' => 1.1,
'manageinstances' => 1.2,
'groups' => 1.3,
'override' => 1.4,
'roles' => 1.5,
'permissions' => 1.6,
'otherusers' => 1.7,
'gradebooksetup' => 2.1,
'outcomes' => 2.2,
'coursecompletion' => 6,
Expand Down

0 comments on commit e0d7dbd

Please sign in to comment.