Línea 65... |
Línea 65... |
65 |
$params = ['type' => $this->type];
|
65 |
$params = ['type' => $this->type];
|
66 |
if ($this->page->context->contextlevel == CONTEXT_COURSE) {
|
66 |
if ($this->page->context->contextlevel == CONTEXT_COURSE) {
|
67 |
$params['id'] = $this->page->context->instanceid;
|
67 |
$params['id'] = $this->page->context->instanceid;
|
68 |
}
|
68 |
}
|
69 |
$elements['button'] = new single_button(new moodle_url('/badges/index.php', $params), get_string('back'), 'get');
|
69 |
$elements['button'] = new single_button(new moodle_url('/badges/index.php', $params), get_string('back'), 'get');
|
- |
|
70 |
$badgenav = $this->generate_badge_navigation();
|
- |
|
71 |
if ($badgenav) {
|
70 |
$elements['urlselect'] = new url_select($this->generate_badge_navigation(), $this->page->url->out(false), null);
|
72 |
$badgenavselect = new url_select($badgenav, $this->page->url->out(false), null);
|
- |
|
73 |
$badgenavselect->set_label(get_string('badgesnavigation', 'badges'), ['class' => 'visually-hidden']);
|
- |
|
74 |
$elements['urlselect'] = $badgenavselect;
|
- |
|
75 |
}
|
71 |
foreach ($elements as $key => $element) {
|
76 |
foreach ($elements as $key => $element) {
|
72 |
$elements[$key] = $element->export_for_template($output);
|
77 |
$elements[$key] = $element->export_for_template($output);
|
73 |
}
|
78 |
}
|
74 |
$additional = $this->get_third_party_nav_action($output);
|
79 |
$additional = $this->get_third_party_nav_action($output);
|
75 |
$elements += $additional ?: [];
|
80 |
$elements += $additional ?: [];
|
Línea 130... |
Línea 135... |
130 |
*
|
135 |
*
|
131 |
* @return array
|
136 |
* @return array
|
132 |
*/
|
137 |
*/
|
133 |
protected function generate_badge_navigation(): array {
|
138 |
protected function generate_badge_navigation(): array {
|
134 |
global $DB;
|
139 |
global $DB;
|
- |
|
140 |
|
135 |
$params = ['id' => $this->badge->id];
|
141 |
$params = ['id' => $this->badge->id];
|
136 |
$options = [];
|
142 |
$options = [];
|
137 |
$construct = $this->get_badge_administration_mapping_construct();
|
143 |
$construct = $this->get_badge_administration_mapping_construct();
|
138 |
foreach ($construct as $stringidentifier => $checks) {
|
144 |
foreach ($construct as $stringidentifier => $checks) {
|
139 |
if ($checks['capability'] && !has_capability($checks['capability'], $this->page->context)) {
|
145 |
if ($checks['capability'] && !has_capability($checks['capability'], $this->page->context)) {
|
Línea 166... |
Línea 172... |
166 |
}
|
172 |
}
|
Línea 167... |
Línea 173... |
167 |
|
173 |
|
168 |
$url = new moodle_url($checks['url'], $params + ($checks['additionalparams'] ?? []));
|
174 |
$url = new moodle_url($checks['url'], $params + ($checks['additionalparams'] ?? []));
|
169 |
$options[get_string($stringidentifier, 'core_badges', $content)] = $url->out(false);
|
175 |
$options[get_string($stringidentifier, 'core_badges', $content)] = $url->out(false);
|
- |
|
176 |
}
|
- |
|
177 |
if (count($options) <= 1) {
|
- |
|
178 |
return [];
|
- |
|
179 |
}
|
170 |
}
|
180 |
|
171 |
return array_flip($options);
|
181 |
return array_flip($options);
|
172 |
}
|
182 |
}
|