| Línea 14... |
Línea 14... |
| 14 |
// You should have received a copy of the GNU General Public License
|
14 |
// You should have received a copy of the GNU General Public License
|
| 15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
| Línea 16... |
Línea 16... |
| 16 |
|
16 |
|
| Línea 17... |
Línea 17... |
| 17 |
namespace core\output;
|
17 |
namespace core\output;
|
| 18 |
|
18 |
|
| 19 |
use context_course;
|
19 |
use core\context\course as context_course;
|
| 20 |
use moodle_page;
|
20 |
use moodle_page;
|
| Línea 21... |
Línea 21... |
| 21 |
use navigation_node;
|
21 |
use navigation_node;
|
| Línea 26... |
Línea 26... |
| 26 |
*
|
26 |
*
|
| 27 |
* @package core
|
27 |
* @package core
|
| 28 |
* @copyright 2021 Peter Dias
|
28 |
* @copyright 2021 Peter Dias
|
| 29 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
29 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
| 30 |
*/
|
30 |
*/
|
| 31 |
class participants_action_bar implements \renderable {
|
31 |
class participants_action_bar implements renderable {
|
| 32 |
/** @var object $course The course we are dealing with. */
|
32 |
/** @var object $course The course we are dealing with. */
|
| 33 |
private $course;
|
33 |
private $course;
|
| 34 |
/** @var moodle_page $page The current page. */
|
34 |
/** @var moodle_page $page The current page. */
|
| 35 |
private $page;
|
35 |
private $page;
|
| 36 |
/** @var navigation_node $node The settings node for the participants page. */
|
36 |
/** @var navigation_node $node The settings node for the participants page. */
|
| Línea 70... |
Línea 70... |
| 70 |
'review',
|
70 |
'review',
|
| 71 |
'manageinstances',
|
71 |
'manageinstances',
|
| 72 |
'renameroles',
|
72 |
'renameroles',
|
| 73 |
],
|
73 |
],
|
| 74 |
'groups:group' => [
|
74 |
'groups:group' => [
|
| 75 |
'groups'
|
75 |
'groups',
|
| 76 |
],
|
76 |
],
|
| 77 |
'permissions:role' => [
|
77 |
'permissions:role' => [
|
| 78 |
'override',
|
78 |
'override',
|
| 79 |
'roles',
|
79 |
'roles',
|
| 80 |
'otherusers',
|
80 |
'otherusers',
|
| Línea 96... |
Línea 96... |
| 96 |
return [];
|
96 |
return [];
|
| 97 |
}
|
97 |
}
|
| Línea 98... |
Línea 98... |
| 98 |
|
98 |
|
| 99 |
$formattedcontent = [];
|
99 |
$formattedcontent = [];
|
| - |
|
100 |
$enrolmentsheading = get_string('enrolments', 'enrol');
|
| 100 |
$enrolmentsheading = get_string('enrolments', 'enrol');
|
101 |
if (
|
| 101 |
if ($this->page->context->contextlevel != CONTEXT_MODULE &&
|
102 |
$this->page->context->contextlevel != CONTEXT_MODULE &&
|
| - |
|
103 |
$this->page->context->contextlevel != CONTEXT_COURSECAT
|
| 102 |
$this->page->context->contextlevel != CONTEXT_COURSECAT) {
|
104 |
) {
|
| 103 |
// Pre-populate the formatted tertiary nav items with the "Enrolled users" node if user can view the participants page.
|
105 |
// Pre-populate the formatted tertiary nav items with the "Enrolled users" node if user can view the participants page.
|
| 104 |
$coursecontext = context_course::instance($this->course->id);
|
106 |
$coursecontext = context_course::instance($this->course->id);
|
| 105 |
$canviewparticipants = course_can_view_participants($coursecontext);
|
107 |
$canviewparticipants = course_can_view_participants($coursecontext);
|
| 106 |
if ($canviewparticipants) {
|
108 |
if ($canviewparticipants) {
|
| 107 |
$participantsurl = (new moodle_url('/user/index.php', ['id' => $this->course->id]))->out();
|
109 |
$participantsurl = (new moodle_url('/user/index.php', ['id' => $this->course->id]))->out();
|
| 108 |
$formattedcontent[] = [
|
110 |
$formattedcontent[] = [
|
| 109 |
$enrolmentsheading => [
|
111 |
$enrolmentsheading => [
|
| 110 |
$participantsurl => get_string('enrolledusers', 'enrol'),
|
112 |
$participantsurl => get_string('enrolledusers', 'enrol'),
|
| 111 |
]
|
113 |
],
|
| 112 |
];
|
114 |
];
|
| 113 |
}
|
115 |
}
|
| Línea 114... |
Línea 116... |
| 114 |
}
|
116 |
}
|
| 115 |
|
117 |
|
| 116 |
$nodes = $this->get_ordered_nodes();
|
118 |
$nodes = $this->get_ordered_nodes();
|
| 117 |
foreach ($nodes as $description => $content) {
|
119 |
foreach ($nodes as $description => $content) {
|
| 118 |
list($stringid, $location) = explode(':', $description);
|
120 |
[$stringid, $location] = explode(':', $description);
|
| 119 |
$heading = get_string($stringid, $location);
|
121 |
$heading = get_string($stringid, $location);
|
| 120 |
$items = [];
|
122 |
$items = [];
|
| 121 |
foreach ($content as $key) {
|
123 |
foreach ($content as $key) {
|
| Línea 127... |
Línea 129... |
| 127 |
// Additional items to be added.
|
129 |
// Additional items to be added.
|
| 128 |
if ($key === 'groups') {
|
130 |
if ($key === 'groups') {
|
| 129 |
$params = ['id' => $this->course->id];
|
131 |
$params = ['id' => $this->course->id];
|
| 130 |
$items += [
|
132 |
$items += [
|
| 131 |
(new moodle_url('/group/groupings.php', $params))->out() => get_string('groupings', 'group'),
|
133 |
(new moodle_url('/group/groupings.php', $params))->out() => get_string('groupings', 'group'),
|
| 132 |
(new moodle_url('/group/overview.php', $params))->out() => get_string('overview', 'group')
|
134 |
(new moodle_url('/group/overview.php', $params))->out() => get_string('overview', 'group'),
|
| 133 |
];
|
135 |
];
|
| 134 |
}
|
136 |
}
|
| 135 |
}
|
137 |
}
|
| 136 |
}
|
138 |
}
|
| 137 |
if ($items) {
|
139 |
if ($items) {
|
| Línea 143... |
Línea 145... |
| 143 |
}
|
145 |
}
|
| 144 |
}
|
146 |
}
|
| 145 |
}
|
147 |
}
|
| Línea 146... |
Línea 148... |
| 146 |
|
148 |
|
| - |
|
149 |
// If we are accessing a page from a module/category context additional nodes will not be visible.
|
| 147 |
// If we are accessing a page from a module/category context additional nodes will not be visible.
|
150 |
if (
|
| 148 |
if ($this->page->context->contextlevel != CONTEXT_MODULE &&
|
151 |
$this->page->context->contextlevel != CONTEXT_MODULE &&
|
| - |
|
152 |
$this->page->context->contextlevel != CONTEXT_COURSECAT
|
| 149 |
$this->page->context->contextlevel != CONTEXT_COURSECAT) {
|
153 |
) {
|
| 150 |
// Need to do some funky code here to find out if we have added third party navigation nodes.
|
154 |
// Need to do some funky code here to find out if we have added third party navigation nodes.
|
| 151 |
$thirdpartynodearray = $this->get_thirdparty_node_array() ?: [];
|
155 |
$thirdpartynodearray = $this->get_thirdparty_node_array() ?: [];
|
| 152 |
$formattedcontent = array_merge($formattedcontent, $thirdpartynodearray);
|
156 |
$formattedcontent = array_merge($formattedcontent, $thirdpartynodearray);
|
| 153 |
}
|
157 |
}
|
| Línea 201... |
Línea 205... |
| 201 |
if ($urlselectcontent = $this->get_content_for_select()) {
|
205 |
if ($urlselectcontent = $this->get_content_for_select()) {
|
| 202 |
$activeurl = $this->find_active_page($urlselectcontent);
|
206 |
$activeurl = $this->find_active_page($urlselectcontent);
|
| 203 |
$activeurl = $activeurl ?: $this->find_active_page($urlselectcontent, URL_MATCH_BASE);
|
207 |
$activeurl = $activeurl ?: $this->find_active_page($urlselectcontent, URL_MATCH_BASE);
|
| Línea 204... |
Línea 208... |
| 204 |
|
208 |
|
| 205 |
$selectmenu = new select_menu('participantsnavigation', $urlselectcontent, $activeurl);
|
209 |
$selectmenu = new select_menu('participantsnavigation', $urlselectcontent, $activeurl);
|
| Línea 206... |
Línea 210... |
| 206 |
$selectmenu->set_label(get_string('participantsnavigation', 'course'), ['class' => 'sr-only']);
|
210 |
$selectmenu->set_label(get_string('participantsnavigation', 'course'), ['class' => 'visually-hidden']);
|
| 207 |
|
211 |
|
| Línea 208... |
Línea 212... |
| 208 |
return $selectmenu->export_for_template($output);
|
212 |
return $selectmenu->export_for_template($output);
|