mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-75423 gradereport_singleview: switch to the new group selector
This commit is contained in:
parent
e2d389c37e
commit
56a454149b
@ -130,55 +130,9 @@ class singleview extends grade_report {
|
||||
* @return string
|
||||
*/
|
||||
protected static function groups_course_menu(stdClass $course, moodle_url $urlroot) {
|
||||
global $USER, $OUTPUT;
|
||||
global $PAGE;
|
||||
|
||||
$groupmode = $course->groupmode;
|
||||
if (!$groupmode) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$context = context_course::instance($course->id);
|
||||
$aag = has_capability('moodle/site:accessallgroups', $context);
|
||||
|
||||
$usergroups = [];
|
||||
if ($groupmode == VISIBLEGROUPS or $aag) {
|
||||
$allowedgroups = groups_get_all_groups($course->id, 0, $course->defaultgroupingid);
|
||||
// Get user's own groups and put to the top.
|
||||
$usergroups = groups_get_all_groups($course->id, $USER->id, $course->defaultgroupingid);
|
||||
} else {
|
||||
$allowedgroups = groups_get_all_groups($course->id, $USER->id, $course->defaultgroupingid);
|
||||
}
|
||||
|
||||
$activegroup = groups_get_course_group($course, true, $allowedgroups);
|
||||
|
||||
$groupsmenu = [];
|
||||
if (!$allowedgroups or $groupmode == VISIBLEGROUPS or $aag) {
|
||||
$groupsmenu[0] = get_string('allparticipants');
|
||||
}
|
||||
|
||||
$groupsmenu += groups_sort_menu_options($allowedgroups, $usergroups);
|
||||
|
||||
if ($groupmode == VISIBLEGROUPS) {
|
||||
$grouplabel = get_string('groupsvisible');
|
||||
} else {
|
||||
$grouplabel = get_string('groupsseparate');
|
||||
}
|
||||
|
||||
if ($aag and $course->defaultgroupingid) {
|
||||
if ($grouping = groups_get_grouping($course->defaultgroupingid)) {
|
||||
$grouplabel = $grouplabel . ' (' . format_string($grouping->name) . ')';
|
||||
}
|
||||
}
|
||||
|
||||
if (count($groupsmenu) == 1) {
|
||||
$groupname = reset($groupsmenu);
|
||||
$output = $grouplabel.': '.$groupname;
|
||||
} else {
|
||||
$select = new \core\output\select_menu('group', $groupsmenu, $activegroup);
|
||||
$select->set_label($grouplabel);
|
||||
$output = $OUTPUT->render($select);
|
||||
}
|
||||
|
||||
return $output;
|
||||
$renderer = $PAGE->get_renderer('core_grades');
|
||||
return $renderer->group_selector($course, $urlroot->out());
|
||||
}
|
||||
}
|
||||
|
@ -28,13 +28,6 @@
|
||||
<div class="navitem">
|
||||
{{{.}}}
|
||||
</div>
|
||||
{{#js}}
|
||||
document.querySelector('.tertiary-navigation [name="group"]').addEventListener('change', function(e) {
|
||||
var url = new URL("{{{pbarurl}}}");
|
||||
url.searchParams.set('group', e.target.value);
|
||||
window.location.href = url;
|
||||
});
|
||||
{{/js}}
|
||||
{{/groupselector}}
|
||||
{{#gradeitemselector}}
|
||||
<div class="navitem">
|
||||
|
@ -28,13 +28,6 @@
|
||||
<div class="navitem">
|
||||
{{{.}}}
|
||||
</div>
|
||||
{{#js}}
|
||||
document.querySelector('.tertiary-navigation [name="group"]').addEventListener('change', function(e) {
|
||||
var url = new URL("{{{pbarurl}}}");
|
||||
url.searchParams.set('group', e.target.value);
|
||||
window.location.href = url;
|
||||
});
|
||||
{{/js}}
|
||||
{{/groupselector}}
|
||||
{{#userselector}}
|
||||
<div class="navitem">
|
||||
|
Loading…
x
Reference in New Issue
Block a user