| 1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
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/>.
|
|
|
16 |
|
| 1441 |
ariadna |
17 |
/**
|
|
|
18 |
*
|
|
|
19 |
* @package theme_universe
|
|
|
20 |
* @copyright 2025 onwards, Marcin Czaja (https://rosea.io)
|
|
|
21 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
22 |
*
|
|
|
23 |
*/
|
|
|
24 |
|
| 1 |
efrain |
25 |
defined('MOODLE_INTERNAL') || die();
|
|
|
26 |
|
|
|
27 |
require_once($CFG->dirroot . "/badges/renderer.php");
|
| 1441 |
ariadna |
28 |
|
|
|
29 |
/**
|
|
|
30 |
* Customization - Badge Renderer
|
|
|
31 |
* @package theme_universe
|
|
|
32 |
* @copyright 2025 onwards, Marcin Czaja (https://rosea.io)
|
|
|
33 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
34 |
*
|
|
|
35 |
*/
|
| 1 |
efrain |
36 |
class theme_universe_core_badges_renderer extends core_badges_renderer {
|
|
|
37 |
|
| 1441 |
ariadna |
38 |
/**
|
|
|
39 |
* Print Badges List
|
|
|
40 |
*
|
|
|
41 |
*/
|
| 1 |
efrain |
42 |
public function print_badges_list($badges, $userid, $profile = false, $external = false) {
|
|
|
43 |
global $USER, $CFG;
|
|
|
44 |
foreach ($badges as $badge) {
|
|
|
45 |
if (!$external) {
|
|
|
46 |
$context = ($badge->type == BADGE_TYPE_SITE) ?
|
|
|
47 |
context_system::instance() : context_course::instance($badge->courseid);
|
|
|
48 |
$bname = $badge->name;
|
|
|
49 |
$imageurl = moodle_url::make_pluginfile_url(
|
|
|
50 |
$context->id,
|
|
|
51 |
'badges',
|
|
|
52 |
'badgeimage',
|
|
|
53 |
$badge->id,
|
|
|
54 |
'/',
|
|
|
55 |
'f3',
|
|
|
56 |
false
|
|
|
57 |
);
|
|
|
58 |
} else {
|
|
|
59 |
$bname = '';
|
|
|
60 |
$imageurl = '';
|
|
|
61 |
if (!empty($badge->name)) {
|
|
|
62 |
$bname = s($badge->name);
|
|
|
63 |
}
|
|
|
64 |
if (!empty($badge->image)) {
|
|
|
65 |
if (is_object($badge->image)) {
|
|
|
66 |
if (!empty($badge->image->caption)) {
|
|
|
67 |
$badge->imagecaption = $badge->image->caption;
|
|
|
68 |
}
|
|
|
69 |
$imageurl = $badge->image->id;
|
|
|
70 |
} else {
|
|
|
71 |
$imageurl = $badge->image;
|
|
|
72 |
}
|
|
|
73 |
}
|
|
|
74 |
if (isset($badge->assertion->badge->name)) {
|
|
|
75 |
$bname = s($badge->assertion->badge->name);
|
|
|
76 |
}
|
|
|
77 |
if (isset($badge->imageUrl)) {
|
|
|
78 |
$imageurl = $badge->imageUrl;
|
|
|
79 |
}
|
|
|
80 |
}
|
|
|
81 |
|
| 1441 |
ariadna |
82 |
$name = html_writer::tag('span', $bname, ['class' => 'badge-name']);
|
| 1 |
efrain |
83 |
|
| 1441 |
ariadna |
84 |
$image = html_writer::empty_tag('img', ['src' => $imageurl, 'class' => 'badge-image']);
|
| 1 |
efrain |
85 |
if (!empty($badge->dateexpire) && $badge->dateexpire < time()) {
|
|
|
86 |
$image .= $this->output->pix_icon(
|
|
|
87 |
'i/expired',
|
|
|
88 |
get_string('expireddate', 'badges', userdate($badge->dateexpire)),
|
|
|
89 |
'moodle',
|
| 1441 |
ariadna |
90 |
['class' => 'expireimage']
|
| 1 |
efrain |
91 |
);
|
|
|
92 |
$name .= '(' . get_string('expired', 'badges') . ')';
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
$download = $status = $push = '';
|
|
|
96 |
if (($userid == $USER->id) && !$profile) {
|
| 1441 |
ariadna |
97 |
$params = [
|
| 1 |
efrain |
98 |
'download' => $badge->id,
|
|
|
99 |
'hash' => $badge->uniquehash,
|
| 1441 |
ariadna |
100 |
'sesskey' => sesskey(),
|
|
|
101 |
];
|
| 1 |
efrain |
102 |
$url = new moodle_url(
|
|
|
103 |
'mybadges.php',
|
|
|
104 |
$params
|
|
|
105 |
);
|
|
|
106 |
$notexpiredbadge = (empty($badge->dateexpire) || $badge->dateexpire > time());
|
|
|
107 |
$userbackpack = badges_get_user_backpack();
|
|
|
108 |
if (!empty($CFG->badges_allowexternalbackpack) && $notexpiredbadge && $userbackpack) {
|
| 1441 |
ariadna |
109 |
$assertion = new moodle_url('/badges/assertion.php', ['b' => $badge->uniquehash]);
|
| 1 |
efrain |
110 |
$icon = new pix_icon('t/backpack', get_string('addtobackpack', 'badges'));
|
|
|
111 |
if (badges_open_badges_backpack_api($userbackpack->id) == OPEN_BADGES_V2) {
|
| 1441 |
ariadna |
112 |
$addurl = new moodle_url('/badges/backpack-add.php', ['hash' => $badge->uniquehash]);
|
| 1 |
efrain |
113 |
$push = $this->output->action_icon($addurl, $icon);
|
|
|
114 |
} else if (badges_open_badges_backpack_api($userbackpack->id) == OPEN_BADGES_V2P1) {
|
| 1441 |
ariadna |
115 |
$addurl = new moodle_url('/badges/backpack-export.php', ['hash' => $badge->uniquehash]);
|
| 1 |
efrain |
116 |
$push = $this->output->action_icon($addurl, $icon);
|
|
|
117 |
}
|
|
|
118 |
}
|
|
|
119 |
|
| 1441 |
ariadna |
120 |
$downloadicon = '<svg width="22" height="22" fill="none" viewBox="0 0 24 24">
|
| 1 |
efrain |
121 |
<path stroke="currentColor"
|
|
|
122 |
stroke-linecap="round"
|
|
|
123 |
stroke-linejoin="round"
|
|
|
124 |
stroke-width="1.5"
|
|
|
125 |
d="M4.75 14.75V16.25C4.75 17.9069 6.09315 19.25 7.75 19.25H16.25C17.9069 19.25 19.25
|
|
|
126 |
17.9069 19.25 16.25V14.75"></path><path stroke="currentColor"
|
|
|
127 |
stroke-linecap="round"
|
|
|
128 |
stroke-linejoin="round"
|
|
|
129 |
stroke-width="1.5"
|
|
|
130 |
d="M12 14.25L12 4.75">
|
|
|
131 |
</path>
|
|
|
132 |
<path stroke="currentColor"
|
|
|
133 |
stroke-linecap="round"
|
|
|
134 |
stroke-linejoin="round"
|
|
|
135 |
stroke-width="1.5"
|
|
|
136 |
d="M8.75 10.75L12 14.25L15.25 10.75">
|
|
|
137 |
</path>
|
|
|
138 |
</svg>';
|
|
|
139 |
$download = '<a class="btn btn-icon btn-secondary" href="' . $url . '">' . $downloadicon . '</a>';
|
|
|
140 |
if ($badge->visible) {
|
| 1441 |
ariadna |
141 |
$url = new moodle_url('mybadges.php', ['hide' => $badge->issuedid, 'sesskey' => sesskey()]);
|
|
|
142 |
$hideicon = '<svg width="22" height="22" fill="none" viewBox="0 0 24 24">
|
| 1 |
efrain |
143 |
<path stroke="currentColor"
|
|
|
144 |
stroke-linecap="round"
|
|
|
145 |
stroke-linejoin="round"
|
|
|
146 |
stroke-width="1.5"
|
|
|
147 |
d="M18.6247 10C19.0646 10.8986 19.25 11.6745 19.25 12C19.25 13 17.5 18.25 12 18.25C11.2686
|
|
|
148 |
18.25 10.6035 18.1572 10 17.9938M7 16.2686C5.36209 14.6693 4.75 12.5914 4.75 12C4.75 11
|
|
|
149 |
6.5 5.75 12 5.75C13.7947 5.75 15.1901 6.30902 16.2558 7.09698"></path>
|
|
|
150 |
<path stroke="currentColor"
|
|
|
151 |
stroke-linecap="round"
|
|
|
152 |
stroke-linejoin="round"
|
|
|
153 |
stroke-width="1.5"
|
|
|
154 |
d="M19.25 4.75L4.75 19.25"></path>
|
|
|
155 |
<path stroke="currentColor"
|
|
|
156 |
stroke-linecap="round"
|
|
|
157 |
stroke-linejoin="round"
|
|
|
158 |
stroke-width="1.5"
|
|
|
159 |
d="M10.409 13.591C9.53033 12.7123 9.53033 11.2877 10.409 10.409C11.2877 9.5303
|
|
|
160 |
12.7123 9.5303 13.591 10.409"></path>
|
|
|
161 |
</svg>';
|
|
|
162 |
$status = '<a class="btn btn-icon btn-danger" href="' . $url . '" title="' .
|
|
|
163 |
get_string('makeprivate', 'badges') . '">' .
|
|
|
164 |
$hideicon .
|
|
|
165 |
'</a>';
|
|
|
166 |
} else {
|
| 1441 |
ariadna |
167 |
$url = new moodle_url('mybadges.php', ['show' => $badge->issuedid, 'sesskey' => sesskey()]);
|
|
|
168 |
$showicon = '<svg width="22" height="22"
|
| 1 |
efrain |
169 |
fill="none"
|
|
|
170 |
viewBox="0 0 24 24"><path stroke="currentColor"
|
|
|
171 |
stroke-linecap="round"
|
|
|
172 |
stroke-linejoin="round"
|
|
|
173 |
stroke-width="1.5"
|
|
|
174 |
d="M19.25 12C19.25 13 17.5 18.25 12 18.25C6.5 18.25 4.75 13 4.75 12C4.75 11 6.5
|
|
|
175 |
5.75 12 5.75C17.5 5.75 19.25 11 19.25 12Z"></path>
|
|
|
176 |
<circle cx="12" cy="12" r="2.25"
|
|
|
177 |
stroke="currentColor"
|
|
|
178 |
stroke-linecap="round"
|
|
|
179 |
stroke-linejoin="round"
|
|
|
180 |
stroke-width="1.5"></circle></svg>';
|
|
|
181 |
$status = '<a class="btn btn-icon btn-success" href="' . $url .
|
|
|
182 |
'" title="' . get_string('makepublic', 'badges') .
|
|
|
183 |
'">' .
|
|
|
184 |
$showicon .
|
|
|
185 |
'</a>';
|
|
|
186 |
}
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
if (!$profile) {
|
| 1441 |
ariadna |
190 |
$url = new moodle_url('badge.php', ['hash' => $badge->uniquehash]);
|
| 1 |
efrain |
191 |
} else {
|
|
|
192 |
if (!$external) {
|
| 1441 |
ariadna |
193 |
$url = new moodle_url('/badges/badge.php', ['hash' => $badge->uniquehash]);
|
| 1 |
efrain |
194 |
} else {
|
|
|
195 |
$hash = hash('md5', $badge->hostedUrl);
|
| 1441 |
ariadna |
196 |
$url = new moodle_url('/badges/external.php', ['hash' => $hash, 'user' => $userid]);
|
| 1 |
efrain |
197 |
}
|
|
|
198 |
}
|
| 1441 |
ariadna |
199 |
$actions = html_writer::tag('div', $push . $download . $status, ['class' => 'rui-badge-actions']);
|
|
|
200 |
$items[] = html_writer::link($url, $image . $name . $actions, ['title' => $bname]);
|
| 1 |
efrain |
201 |
}
|
|
|
202 |
|
| 1441 |
ariadna |
203 |
return html_writer::alist($items, ['class' => 'badges rui-list-group']);
|
| 1 |
efrain |
204 |
}
|
|
|
205 |
|
|
|
206 |
/**
|
|
|
207 |
* Render a collection of user badges.
|
|
|
208 |
*
|
|
|
209 |
* @param \core_badges\output\badge_user_collection $badges
|
|
|
210 |
* @return string
|
|
|
211 |
*/
|
|
|
212 |
protected function render_badge_user_collection(\core_badges\output\badge_user_collection $badges) {
|
|
|
213 |
global $CFG, $USER, $SITE;
|
|
|
214 |
$backpack = $badges->backpack;
|
|
|
215 |
$mybackpack = new moodle_url('/badges/mybackpack.php');
|
|
|
216 |
|
|
|
217 |
$paging = new paging_bar($badges->totalcount, $badges->page, $badges->perpage, $this->page->url, 'page');
|
|
|
218 |
$htmlpagingbar = $this->render($paging);
|
|
|
219 |
|
|
|
220 |
// Set backpack connection string.
|
|
|
221 |
$backpackconnect = '';
|
|
|
222 |
if (!empty($CFG->badges_allowexternalbackpack) && is_null($backpack)) {
|
|
|
223 |
$backpackconnect = $this->output->box(get_string('localconnectto', 'badges', $mybackpack->out()), 'noticebox');
|
|
|
224 |
}
|
|
|
225 |
// Search box.
|
|
|
226 |
$searchform = $this->output->container($this->helper_search_form($badges->search));
|
|
|
227 |
|
|
|
228 |
// Download all button.
|
|
|
229 |
$actionhtml = $this->output->single_button(
|
| 1441 |
ariadna |
230 |
new moodle_url('/badges/mybadges.php', ['downloadall' => true, 'sesskey' => sesskey()]),
|
| 1 |
efrain |
231 |
get_string('downloadall'),
|
|
|
232 |
'POST',
|
| 1441 |
ariadna |
233 |
['class' => 'activatebadge ml-auto']
|
| 1 |
efrain |
234 |
);
|
|
|
235 |
|
|
|
236 |
$downloadall = $this->output->container($actionhtml, 'rui-downloadall text-right');
|
|
|
237 |
$downloadall = $this->output->container($downloadall, 'rui-downloadall-wrapper mt-3');
|
|
|
238 |
|
|
|
239 |
// Local badges.
|
| 1441 |
ariadna |
240 |
$localhtml = html_writer::start_tag(
|
|
|
241 |
'div',
|
|
|
242 |
['id' => 'issued-badge-table', 'class' => 'wrapper-fw mb-5']
|
|
|
243 |
);
|
|
|
244 |
$sitename = format_string($SITE->fullname, true, ['context' => context_system::instance()]);
|
| 1 |
efrain |
245 |
$heading = get_string('localbadges', 'badges', $sitename);
|
|
|
246 |
$localhtml .= $this->output->heading_with_help($heading, 'localbadgesh', 'badges', '', '', 2, $classnames = 'mb-3');
|
|
|
247 |
if ($badges->badges) {
|
| 1441 |
ariadna |
248 |
$countmessage = '<hr /><svg class="me-2"
|
|
|
249 |
width="22"
|
|
|
250 |
height="22"
|
| 1 |
efrain |
251 |
fill="none"
|
|
|
252 |
viewBox="0 0 24 24">
|
|
|
253 |
<path stroke="currentColor"
|
|
|
254 |
stroke-linecap="round"
|
|
|
255 |
stroke-linejoin="round"
|
|
|
256 |
stroke-width="2"
|
|
|
257 |
d="M14.25 8.75L18.25 4.75H5.75L9.75 8.75"></path><circle cx="12" cy="14" r="5.25"
|
|
|
258 |
stroke="currentColor"
|
|
|
259 |
stroke-linecap="round"
|
|
|
260 |
stroke-linejoin="round"
|
|
|
261 |
stroke-width="2"></circle></svg>' .
|
| 1441 |
ariadna |
262 |
get_string('badgesearned', 'badges', $badges->totalcount) . '<hr />';
|
| 1 |
efrain |
263 |
|
|
|
264 |
$htmllist = $this->print_badges_list($badges->badges, $USER->id);
|
|
|
265 |
$localhtml .= $backpackconnect . $countmessage . $searchform;
|
|
|
266 |
$localhtml .= $htmlpagingbar . $htmllist . $htmlpagingbar . $downloadall;
|
|
|
267 |
} else {
|
|
|
268 |
$localhtml .= $searchform . $this->output->notification(get_string('nobadges', 'badges'));
|
|
|
269 |
}
|
|
|
270 |
$localhtml .= html_writer::end_tag('div');
|
|
|
271 |
|
|
|
272 |
// External badges.
|
|
|
273 |
$externalhtml = "";
|
|
|
274 |
if (!empty($CFG->badges_allowexternalbackpack)) {
|
| 1441 |
ariadna |
275 |
$externalhtml .= html_writer::start_tag('div', ['class' => 'wrapper-fw mt-4']);
|
|
|
276 |
$externalhtml .= $this->output->heading_with_help(
|
|
|
277 |
get_string('externalbadges', 'badges'),
|
|
|
278 |
'externalbadges',
|
|
|
279 |
'badges',
|
|
|
280 |
'',
|
|
|
281 |
'',
|
|
|
282 |
5,
|
|
|
283 |
'mb-3'
|
|
|
284 |
);
|
| 1 |
efrain |
285 |
if (!is_null($backpack)) {
|
|
|
286 |
if ($backpack->totalcollections == 0) {
|
|
|
287 |
$externalhtml .= get_string('nobackpackcollectionssummary', 'badges', $backpack);
|
|
|
288 |
} else {
|
|
|
289 |
if ($backpack->totalbadges == 0) {
|
|
|
290 |
$externalhtml .= get_string('nobackpackbadgessummary', 'badges', $backpack);
|
|
|
291 |
} else {
|
|
|
292 |
$externalhtml .= get_string('backpackbadgessummary', 'badges', $backpack);
|
| 1441 |
ariadna |
293 |
$externalhtml .= '<br/><br/>' . $this->print_badges_list(
|
|
|
294 |
$backpack->badges,
|
|
|
295 |
$USER->id,
|
|
|
296 |
true,
|
|
|
297 |
true
|
|
|
298 |
);
|
| 1 |
efrain |
299 |
}
|
|
|
300 |
}
|
|
|
301 |
} else {
|
|
|
302 |
$externalhtml .= get_string('externalconnectto', 'badges', $mybackpack->out());
|
|
|
303 |
}
|
|
|
304 |
|
|
|
305 |
$externalhtml .= html_writer::end_tag('div');
|
|
|
306 |
$attr = ['class' => 'btn btn-info'];
|
|
|
307 |
$label = get_string('backpackbadgessettings', 'badges');
|
|
|
308 |
$backpacksettings = html_writer::link(new moodle_url('/badges/mybackpack.php'), $label, $attr);
|
|
|
309 |
$actionshtml = $this->output->container($backpacksettings, 'rui-backpacksettings');
|
|
|
310 |
$actionshtml = $this->output->container($actionshtml, 'rui-backpacksettings-wrapper wrapper-fw mt-3');
|
|
|
311 |
$externalhtml .= $actionshtml;
|
|
|
312 |
}
|
|
|
313 |
|
|
|
314 |
return $localhtml . $externalhtml;
|
|
|
315 |
}
|
|
|
316 |
|
|
|
317 |
/**
|
|
|
318 |
* Render a collection of badges.
|
|
|
319 |
*
|
|
|
320 |
* @param \core_badges\output\badge_collection $badges
|
|
|
321 |
* @return string
|
|
|
322 |
*/
|
|
|
323 |
protected function render_badge_collection(\core_badges\output\badge_collection $badges) {
|
|
|
324 |
$output = '';
|
|
|
325 |
foreach ($badges->badges as $badge) {
|
|
|
326 |
$badgeimage = print_badge_image($badge, $this->page->context, 'large');
|
|
|
327 |
$name = $badge->name;
|
|
|
328 |
$description = $badge->description;
|
|
|
329 |
$criteria = self::print_badge_criteria($badge);
|
|
|
330 |
if ($badge->dateissued) {
|
| 1441 |
ariadna |
331 |
$iconcheck = '<svg class="me-2"
|
|
|
332 |
width="22"
|
|
|
333 |
height="22"
|
| 1 |
efrain |
334 |
fill="none"
|
|
|
335 |
viewBox="0 0 24 24">
|
|
|
336 |
<path stroke="currentColor"
|
|
|
337 |
stroke-linecap="round"
|
|
|
338 |
stroke-linejoin="round"
|
|
|
339 |
stroke-width="2"
|
|
|
340 |
d="M4.75 12C4.75 7.99594 7.99594 4.75 12 4.75V4.75C16.0041
|
|
|
341 |
4.75 19.25 7.99594 19.25 12V12C19.25 16.0041 16.0041 19.25
|
|
|
342 |
12 19.25V19.25C7.99594 19.25 4.75 16.0041 4.75 12V12Z">
|
|
|
343 |
</path>
|
|
|
344 |
<path stroke="currentColor"
|
|
|
345 |
stroke-linecap="round"
|
|
|
346 |
stroke-linejoin="round"
|
|
|
347 |
stroke-width="2"
|
|
|
348 |
d="M9.75 12.75L10.1837 13.6744C10.5275 14.407 11.5536
|
|
|
349 |
14.4492 11.9564 13.7473L14.25 9.75"></path></svg>';
|
| 1441 |
ariadna |
350 |
$criteriatxt = $iconcheck . get_string('dateearned', 'badges', userdate(
|
|
|
351 |
$badge->dateissued,
|
|
|
352 |
get_string('strftimedatefullshort', 'core_langconfig')
|
|
|
353 |
));
|
|
|
354 |
$badgeurl = new moodle_url('/badges/badge.php', ['hash' => $badge->uniquehash]);
|
| 1 |
efrain |
355 |
$awarded = '<a class="d-inline-flex align-items-center" href="' . $badgeurl . '">' . $criteriatxt . '</a>';
|
|
|
356 |
} else {
|
|
|
357 |
$awarded = "";
|
|
|
358 |
}
|
|
|
359 |
|
|
|
360 |
$output .= '<div class="m-0">';
|
|
|
361 |
$output .= '<div class="rui-badge-overview-wrapper
|
|
|
362 |
border rounded w-100 p-4 mt-2 mb-2 d-inline-flex align-items-start">';
|
| 1441 |
ariadna |
363 |
$output .= '<div class="border rounded p-4 me-6">' . $badgeimage . '</div>';
|
|
|
364 |
$output .= html_writer::start_tag('div', ['class' => 'rui-badge-overview']);
|
|
|
365 |
$output .= html_writer::start_tag('h4', ['class' => 'rui-badge-name mt-2']);
|
| 1 |
efrain |
366 |
$output .= $name;
|
|
|
367 |
$output .= html_writer::end_tag('h4');
|
| 1441 |
ariadna |
368 |
$output .= html_writer::start_tag(
|
|
|
369 |
'div',
|
|
|
370 |
['class' => 'rui-badge-desc mt-3']
|
|
|
371 |
);
|
|
|
372 |
$output .= html_writer::start_tag(
|
|
|
373 |
'h5',
|
|
|
374 |
['class' => 'd-inline-flex align-items-center w-100']
|
|
|
375 |
);
|
| 1 |
efrain |
376 |
$output .= get_string('description', 'badges');
|
|
|
377 |
$output .= html_writer::end_tag('h5');
|
|
|
378 |
$output .= $description;
|
|
|
379 |
|
| 1441 |
ariadna |
380 |
$output .= html_writer::start_tag(
|
|
|
381 |
'h5',
|
|
|
382 |
['class' => 'd-inline-flex align-items-center w-100 mt-4']
|
|
|
383 |
);
|
|
|
384 |
$output .= '<svg class="me-2" width="22"
|
|
|
385 |
height="22"
|
| 1 |
efrain |
386 |
viewBox="0 0 24 24"
|
|
|
387 |
fill="none"
|
|
|
388 |
xmlns="http://www.w3.org/2000/svg">
|
|
|
389 |
<path d="M10.75 13.25H6.75L13.25 4.75V10.75H17.25L10.75 19.25V13.25Z"
|
|
|
390 |
stroke="currentColor"
|
|
|
391 |
stroke-width="1.5"
|
|
|
392 |
stroke-linecap="round" stroke-linejoin="round"></path></svg>' .
|
|
|
393 |
get_string('bcriteria', 'badges');
|
|
|
394 |
$output .= html_writer::end_tag('h5');
|
| 1441 |
ariadna |
395 |
$output .= '<div class="ms-4">' . $criteria . '</div>';
|
| 1 |
efrain |
396 |
|
|
|
397 |
if (!empty($awarded)) {
|
| 1441 |
ariadna |
398 |
$output .= html_writer::start_tag('h5', ['class' => 'd-inline-flex align-items-center w-100 mt-4']);
|
|
|
399 |
$output .= '<svg class="me-2"
|
|
|
400 |
width="22"
|
|
|
401 |
height="22"
|
| 1 |
efrain |
402 |
viewBox="0 0 24 24"
|
|
|
403 |
fill="none"
|
|
|
404 |
xmlns="http://www.w3.org/2000/svg">
|
|
|
405 |
<path d="M17.25 10C17.25 12.8995 14.8995 15.25 12 15.25C9.10051 15.25 6.75
|
|
|
406 |
12.8995 6.75 10C6.75 7.10051 9.10051 4.75 12 4.75C14.8995 4.75 17.25
|
|
|
407 |
7.10051 17.25 10Z" stroke="currentColor"
|
|
|
408 |
stroke-width="1.5"
|
|
|
409 |
stroke-linecap="round"
|
|
|
410 |
stroke-linejoin="round"></path>
|
|
|
411 |
<path d="M8.75 14.75L7.75 19.25L12 17.75L16.25 19.25L15.25 14.75"
|
|
|
412 |
stroke="currentColor"
|
|
|
413 |
stroke-width="1.5"
|
|
|
414 |
stroke-linecap="round" stroke-linejoin="round"></path></svg>' .
|
|
|
415 |
get_string('awardedtoyou', 'badges');
|
|
|
416 |
$output .= html_writer::end_tag('h5');
|
| 1441 |
ariadna |
417 |
$output .= '<div class="ms-4">' . $awarded . '</div>';
|
| 1 |
efrain |
418 |
}
|
|
|
419 |
|
|
|
420 |
$output .= html_writer::end_tag('div');
|
|
|
421 |
$output .= html_writer::end_tag('div');
|
|
|
422 |
$output .= '</div>';
|
|
|
423 |
$output .= '</div>';
|
|
|
424 |
}
|
|
|
425 |
|
|
|
426 |
return $output;
|
|
|
427 |
}
|
|
|
428 |
|
|
|
429 |
/**
|
|
|
430 |
* Outputs list en badges.
|
|
|
431 |
*
|
|
|
432 |
* @param badge $badge Badge object.
|
|
|
433 |
* @return string $output content endorsement to output.
|
|
|
434 |
*/
|
|
|
435 |
protected function print_badge_endorsement(badge $badge) {
|
|
|
436 |
$output = '';
|
|
|
437 |
$endorsement = $badge->get_endorsement();
|
| 1441 |
ariadna |
438 |
$dl = [];
|
| 1 |
efrain |
439 |
|
| 1441 |
ariadna |
440 |
$output .= html_writer::start_tag('h5', ['class' => 'd-inline-flex align-items-center w-100']);
|
|
|
441 |
$output .= '<svg class="me-2"
|
|
|
442 |
width="22"
|
|
|
443 |
height="22"
|
| 1 |
efrain |
444 |
fill="none"
|
|
|
445 |
viewBox="0 0 24 24"><path stroke="currentColor"
|
|
|
446 |
stroke-linecap="round"
|
|
|
447 |
stroke-linejoin="round"
|
|
|
448 |
stroke-width="2"
|
|
|
449 |
d="M12 13V15"></path><circle cx="12"
|
|
|
450 |
cy="9"
|
|
|
451 |
r="1"
|
|
|
452 |
fill="currentColor"></circle><circle cx="12"
|
|
|
453 |
cy="12"
|
|
|
454 |
r="7.25"
|
|
|
455 |
stroke="currentColor"
|
|
|
456 |
stroke-linecap="round"
|
|
|
457 |
stroke-linejoin="round"
|
|
|
458 |
stroke-width="1.5"></circle></svg>' . get_string('endorsement', 'badges');
|
|
|
459 |
$output .= html_writer::end_tag('h5');
|
|
|
460 |
|
|
|
461 |
if (!empty($endorsement)) {
|
| 1441 |
ariadna |
462 |
$output .= html_writer::start_tag('div', ['class' => 'ms-4']);
|
| 1 |
efrain |
463 |
|
|
|
464 |
if (!empty(userdate($endorsement->dateissued))) {
|
| 1441 |
ariadna |
465 |
$output .= html_writer::start_tag('span', ['class' => 'badge badge-light']);
|
|
|
466 |
$output .= '<span class="me-1 font-weight-bold">' .
|
| 1 |
efrain |
467 |
get_string('dateawarded', 'badges') .
|
|
|
468 |
': </span>' .
|
|
|
469 |
userdate($endorsement->dateissued);
|
|
|
470 |
$output .= html_writer::end_tag('span');
|
|
|
471 |
}
|
|
|
472 |
|
| 1441 |
ariadna |
473 |
$output .= html_writer::start_tag(
|
|
|
474 |
'div',
|
|
|
475 |
['class' => 'rui-badge-comment w-100 rounded p-4 my-2']
|
|
|
476 |
);
|
| 1 |
efrain |
477 |
$output .= '<label>' . get_string('claimcomment', 'badges') . '</label>';
|
| 1441 |
ariadna |
478 |
$output .= html_writer::start_tag(
|
|
|
479 |
'p',
|
|
|
480 |
['class' => 'd-inline-flex align-items-center w-100 mb-0']
|
|
|
481 |
);
|
| 1 |
efrain |
482 |
$output .= $endorsement->claimcomment;
|
|
|
483 |
$output .= html_writer::end_tag('p');
|
|
|
484 |
$output .= html_writer::end_tag('div');
|
|
|
485 |
|
|
|
486 |
if (!empty($endorsement->issuername) || !empty($endorsement->issueremail)) {
|
| 1441 |
ariadna |
487 |
$output .= html_writer::start_tag('span', ['class' => 'alert alert-secondary d-block']);
|
| 1 |
efrain |
488 |
$output .= $endorsement->issuername .
|
| 1441 |
ariadna |
489 |
html_writer::tag(
|
|
|
490 |
'a',
|
|
|
491 |
$endorsement->issueremail,
|
|
|
492 |
['class' => 'ms-3'],
|
|
|
493 |
['href' => "mailto:{$endorsement->issueremail}"]
|
|
|
494 |
)
|
|
|
495 |
. html_writer::link(
|
| 1 |
efrain |
496 |
$endorsement->issuerurl,
|
| 1441 |
ariadna |
497 |
$endorsement->issuerurl,
|
|
|
498 |
['class' => 'ms-3'],
|
|
|
499 |
['target' => '_blank']
|
|
|
500 |
);
|
| 1 |
efrain |
501 |
$output .= html_writer::end_tag('span');
|
|
|
502 |
}
|
|
|
503 |
|
|
|
504 |
$output .= html_writer::end_tag('div');
|
|
|
505 |
} else {
|
| 1441 |
ariadna |
506 |
$output .= html_writer::start_tag('div', ['class' => 'ms-4']);
|
| 1 |
efrain |
507 |
$output .= get_string('noendorsement', 'badges');
|
|
|
508 |
$output .= html_writer::end_tag('div');
|
|
|
509 |
}
|
|
|
510 |
return $output;
|
|
|
511 |
}
|
|
|
512 |
|
|
|
513 |
/**
|
|
|
514 |
* Print list badges related.
|
|
|
515 |
*
|
|
|
516 |
* @param badge $badge Badge objects.
|
|
|
517 |
* @return string $output List related badges to output.
|
|
|
518 |
*/
|
|
|
519 |
protected function print_badge_related(badge $badge) {
|
|
|
520 |
$output = '';
|
|
|
521 |
$relatedbadges = $badge->get_related_badges();
|
| 1441 |
ariadna |
522 |
$output .= html_writer::start_tag('h5', ['class' => 'd-inline-flex align-items-center w-100']);
|
|
|
523 |
$output .= '<svg class="me-2"
|
|
|
524 |
width="22"
|
|
|
525 |
height="22"
|
| 1 |
efrain |
526 |
viewBox="0 0 24 24"
|
|
|
527 |
fill="none"
|
|
|
528 |
xmlns="http://www.w3.org/2000/svg"><path d="M17.25 10C17.25 12.8995
|
|
|
529 |
14.8995 15.25 12 15.25C9.10051 15.25 6.75 12.8995 6.75 10C6.75
|
|
|
530 |
7.10051 9.10051 4.75 12 4.75C14.8995 4.75 17.25 7.10051 17.25 10Z"
|
|
|
531 |
stroke="currentColor"
|
|
|
532 |
stroke-width="1.5"
|
|
|
533 |
stroke-linecap="round"
|
|
|
534 |
stroke-linejoin="round"></path><path d="M8.75 14.75L7.75 19.25L12
|
|
|
535 |
17.75L16.25 19.25L15.25 14.75"
|
|
|
536 |
stroke="currentColor"
|
|
|
537 |
stroke-width="1.5"
|
|
|
538 |
stroke-linecap="round"
|
|
|
539 |
stroke-linejoin="round"></path></svg>' . get_string('relatedbages', 'badges');
|
|
|
540 |
$output .= html_writer::end_tag('h5');
|
|
|
541 |
if (!empty($relatedbadges)) {
|
| 1441 |
ariadna |
542 |
$items = [];
|
| 1 |
efrain |
543 |
foreach ($relatedbadges as $related) {
|
| 1441 |
ariadna |
544 |
$relatedurl = new moodle_url('/badges/overview.php', ['id' => $related->id]);
|
|
|
545 |
$items[] = html_writer::link($relatedurl->out(), $related->name, ['target' => '_blank']);
|
| 1 |
efrain |
546 |
}
|
| 1441 |
ariadna |
547 |
$output .= html_writer::alist($items, [], 'ul');
|
| 1 |
efrain |
548 |
} else {
|
| 1441 |
ariadna |
549 |
$output .= html_writer::start_tag('div', ['class' => 'ms-4']);
|
| 1 |
efrain |
550 |
$output .= get_string('norelated', 'badges');
|
|
|
551 |
$output .= html_writer::end_tag('div');
|
|
|
552 |
}
|
|
|
553 |
return $output;
|
|
|
554 |
}
|
|
|
555 |
|
|
|
556 |
/**
|
|
|
557 |
* Print list badge alignments.
|
|
|
558 |
*
|
|
|
559 |
* @param badge $badge Badge objects.
|
|
|
560 |
* @return string $output List alignments to output.
|
|
|
561 |
*/
|
|
|
562 |
protected function print_badge_alignments(badge $badge) {
|
|
|
563 |
$output = '';
|
|
|
564 |
|
| 1441 |
ariadna |
565 |
$output .= html_writer::start_tag('h5', ['class' => 'd-inline-flex align-items-center w-100']);
|
|
|
566 |
$output .= '<svg class="me-2"
|
|
|
567 |
width="22"
|
|
|
568 |
height="22"
|
| 1 |
efrain |
569 |
viewBox="0 0 24 24"
|
|
|
570 |
fill="none"
|
|
|
571 |
xmlns="http://www.w3.org/2000/svg"><path d="M7.75 5.75H16.25"
|
|
|
572 |
stroke="currentColor"
|
|
|
573 |
stroke-width="1.5"
|
|
|
574 |
stroke-linecap="round"
|
|
|
575 |
stroke-linejoin="round"></path><path d="M7.75 18.25H16.25"
|
|
|
576 |
stroke="currentColor"
|
|
|
577 |
stroke-width="1.5"
|
|
|
578 |
stroke-linecap="round"
|
|
|
579 |
stroke-linejoin="round"></path>
|
|
|
580 |
<path d="M4.75 12H19.25"
|
|
|
581 |
stroke="currentColor"
|
|
|
582 |
stroke-width="1.5"
|
|
|
583 |
stroke-linecap="round"
|
|
|
584 |
stroke-linejoin="round"></path></svg>' . get_string('alignment', 'badges');
|
|
|
585 |
$output .= html_writer::end_tag('h5');
|
|
|
586 |
|
|
|
587 |
$alignments = $badge->get_alignments();
|
|
|
588 |
if (!empty($alignments)) {
|
| 1441 |
ariadna |
589 |
$items = [];
|
| 1 |
efrain |
590 |
foreach ($alignments as $alignment) {
|
|
|
591 |
$urlaligment = new moodle_url(
|
|
|
592 |
'alignment.php',
|
| 1441 |
ariadna |
593 |
['id' => $badge->id, 'alignmentid' => $alignment->id]
|
| 1 |
efrain |
594 |
);
|
| 1441 |
ariadna |
595 |
$items[] = html_writer::link($urlaligment, $alignment->targetname, ['target' => '_blank']);
|
| 1 |
efrain |
596 |
}
|
| 1441 |
ariadna |
597 |
$output .= html_writer::alist($items, ['class' => 'ms-4'], 'ul');
|
| 1 |
efrain |
598 |
} else {
|
| 1441 |
ariadna |
599 |
$output .= html_writer::start_tag('div', ['class' => 'ms-4']);
|
| 1 |
efrain |
600 |
$output .= get_string('noalignment', 'badges');
|
|
|
601 |
$output .= html_writer::end_tag('div');
|
|
|
602 |
}
|
|
|
603 |
return $output;
|
|
|
604 |
}
|
|
|
605 |
|
| 1441 |
ariadna |
606 |
/**
|
|
|
607 |
* Prints a badge overview infomation.
|
|
|
608 |
*
|
|
|
609 |
*/
|
| 1 |
efrain |
610 |
public function print_badge_overview($badge, $context) {
|
|
|
611 |
$languages = get_string_manager()->get_list_of_languages();
|
|
|
612 |
|
|
|
613 |
$output = '';
|
| 1441 |
ariadna |
614 |
$output .= html_writer::start_tag('div', ['class' => 'mt-4']);
|
| 1 |
efrain |
615 |
|
| 1441 |
ariadna |
616 |
$output .= html_writer::start_tag(
|
|
|
617 |
'div',
|
|
|
618 |
[
|
|
|
619 |
'class' => 'rui-badge-overview-wrapper
|
|
|
620 |
border rounded p-4 mt-0 mb-2 d-inline-flex flex-wrap align-items-start w-100',
|
|
|
621 |
]
|
|
|
622 |
);
|
|
|
623 |
$output .= '<div class="border rounded p-3 me-md-6 w-100 w-md-auto">' .
|
| 1 |
efrain |
624 |
print_badge_image($badge, $context, 'large') .
|
|
|
625 |
'</div>';
|
|
|
626 |
|
| 1441 |
ariadna |
627 |
$output .= html_writer::start_tag('div', ['class' => 'rui-badge-overview']);
|
| 1 |
efrain |
628 |
// Badge details.
|
|
|
629 |
|
|
|
630 |
if (!empty($badge->version)) {
|
| 1441 |
ariadna |
631 |
$output .= html_writer::start_tag('div', ['class' => 'pb-2 small']);
|
|
|
632 |
$output .= '<span class="me-1 font-weight-bold">' .
|
| 1 |
efrain |
633 |
get_string('version', 'badges') .
|
|
|
634 |
': </span>' .
|
|
|
635 |
$badge->version;
|
|
|
636 |
$output .= html_writer::end_tag('div');
|
|
|
637 |
}
|
|
|
638 |
|
|
|
639 |
if (!empty($languages[$badge->language])) {
|
| 1441 |
ariadna |
640 |
$output .= html_writer::start_tag('div', ['class' => 'pb-2 small']);
|
|
|
641 |
$output .= '<span class="me-1 font-weight-bold">' .
|
| 1 |
efrain |
642 |
get_string('language') .
|
|
|
643 |
': </span>' .
|
|
|
644 |
$languages[$badge->language];
|
|
|
645 |
$output .= html_writer::end_tag('div');
|
|
|
646 |
}
|
|
|
647 |
|
|
|
648 |
if (!empty(userdate($badge->timecreated))) {
|
| 1441 |
ariadna |
649 |
$output .= html_writer::start_tag('div', ['class' => 'pb-2 small']);
|
|
|
650 |
$output .= '<span class="me-1 font-weight-bold">' .
|
| 1 |
efrain |
651 |
get_string('createdon', 'search') .
|
|
|
652 |
': </span>' .
|
|
|
653 |
userdate($badge->timecreated);
|
|
|
654 |
$output .= html_writer::end_tag('div');
|
|
|
655 |
}
|
|
|
656 |
|
| 1441 |
ariadna |
657 |
$output .= html_writer::start_tag('h4', ['class' => 'rui-badge-name']);
|
| 1 |
efrain |
658 |
$output .= $badge->name;
|
|
|
659 |
$output .= html_writer::end_tag('h4');
|
|
|
660 |
|
|
|
661 |
// Issuance details if any.
|
|
|
662 |
if ($badge->can_expire()) {
|
|
|
663 |
if ($badge->expiredate) {
|
| 1441 |
ariadna |
664 |
$output .= html_writer::start_tag('span', ['class' => 'rui-badge-expires-info']);
|
|
|
665 |
$output .= '<svg class="me-2
|
| 1 |
efrain |
666 |
width="24
|
|
|
667 |
height="24
|
|
|
668 |
fill="none
|
|
|
669 |
viewBox="0 0 24 24"><path stroke="currentColor
|
|
|
670 |
stroke-linecap="round
|
|
|
671 |
stroke-linejoin="round
|
|
|
672 |
stroke-width="1.5
|
|
|
673 |
d="M4.9522 16.3536L10.2152 5.85658C10.9531 4.38481 13.0539
|
|
|
674 |
4.3852 13.7913 5.85723L19.0495 16.3543C19.7156 17.6841
|
|
|
675 |
18.7487 19.25 17.2613 19.25H6.74007C5.25234 19.25 4.2854
|
|
|
676 |
17.6835 4.9522 16.3536Z"></path><path stroke="currentColor
|
|
|
677 |
stroke-linecap="round
|
|
|
678 |
stroke-linejoin="round
|
|
|
679 |
stroke-width="2
|
|
|
680 |
d="M12 10V12"></path><circle cx="12
|
|
|
681 |
cy="16
|
|
|
682 |
r="1
|
|
|
683 |
fill="currentColor"></circle></svg>' . get_string('expiredate', 'badges', userdate($badge->expiredate));
|
|
|
684 |
$output .= html_writer::end_tag('span');
|
|
|
685 |
} else if ($badge->expireperiod) {
|
|
|
686 |
if ($badge->expireperiod < 60) {
|
| 1441 |
ariadna |
687 |
$output .= html_writer::start_tag('span', ['class' => 'rui-badge-expires-info']);
|
| 1 |
efrain |
688 |
$output .= get_string('expireperiods', 'badges', round($badge->expireperiod, 2));
|
|
|
689 |
$output .= html_writer::end_tag('span');
|
|
|
690 |
} else if ($badge->expireperiod < 60 * 60) {
|
| 1441 |
ariadna |
691 |
$output .= html_writer::start_tag('span', ['class' => 'rui-badge-expires-info']);
|
| 1 |
efrain |
692 |
$output .= get_string('expireperiodm', 'badges', round($badge->expireperiod / 60, 2));
|
|
|
693 |
$output .= html_writer::end_tag('span');
|
|
|
694 |
} else if ($badge->expireperiod < 60 * 60 * 24) {
|
| 1441 |
ariadna |
695 |
$output .= html_writer::start_tag('span', ['class' => 'rui-badge-expires-info']);
|
| 1 |
efrain |
696 |
$output .= get_string('expireperiodh', 'badges', round($badge->expireperiod / 60 / 60, 2));
|
|
|
697 |
$output .= html_writer::end_tag('span');
|
|
|
698 |
} else {
|
| 1441 |
ariadna |
699 |
$output .= html_writer::start_tag('span', ['class' => 'badge badge-danger']);
|
| 1 |
efrain |
700 |
$output .= get_string('expireperiod', 'badges', round($badge->expireperiod / 60 / 60 * 0.54, 2));
|
|
|
701 |
$output .= html_writer::end_tag('span');
|
|
|
702 |
}
|
|
|
703 |
}
|
|
|
704 |
} else {
|
| 1441 |
ariadna |
705 |
$output .= html_writer::start_tag('span', ['class' => 'badge badge-success']);
|
|
|
706 |
$output .= '<span class="me-1 font-weight-bold">' . get_string('noexpiry', 'badges') . '</span>';
|
| 1 |
efrain |
707 |
$output .= html_writer::end_tag('span');
|
|
|
708 |
}
|
|
|
709 |
|
| 1441 |
ariadna |
710 |
$output .= html_writer::start_tag('div', ['class' => 'rui-badge-desc mt-3']);
|
| 1 |
efrain |
711 |
|
| 1441 |
ariadna |
712 |
$output .= html_writer::start_tag('h5', ['class' => 'd-inline-flex align-items-center w-100']);
|
| 1 |
efrain |
713 |
$output .= get_string('description', 'badges');
|
|
|
714 |
$output .= html_writer::end_tag('h5');
|
|
|
715 |
|
|
|
716 |
$output .= $badge->description;
|
|
|
717 |
|
| 1441 |
ariadna |
718 |
$output .= html_writer::start_tag('ul', ['class' => 'rui-badge-desc-list mt-3 ms-3']);
|
| 1 |
efrain |
719 |
|
| 1441 |
ariadna |
720 |
if (!empty($badge->imageauthorname)) {
|
| 1 |
efrain |
721 |
$output .= html_writer::start_tag('li');
|
| 1441 |
ariadna |
722 |
$output .= '<span class="me-1 font-weight-bold">' .
|
| 1 |
efrain |
723 |
get_string('imageauthorname', 'badges') . ': </span>' . $badge->imageauthorname;
|
|
|
724 |
$output .= html_writer::end_tag('li');
|
|
|
725 |
}
|
|
|
726 |
|
| 1441 |
ariadna |
727 |
if (!empty($badge->imageauthoremail)) {
|
| 1 |
efrain |
728 |
$output .= html_writer::start_tag('li');
|
| 1441 |
ariadna |
729 |
$output .= '<span class="me-1 font-weight-bold">' .
|
| 1 |
efrain |
730 |
get_string('imageauthoremail', 'badges') .
|
|
|
731 |
': </span>' .
|
| 1441 |
ariadna |
732 |
html_writer::tag('a', $badge->imageauthoremail, ['href' => "mailto:{$badge->imageauthoremail}"]);
|
| 1 |
efrain |
733 |
$output .= html_writer::end_tag('li');
|
|
|
734 |
}
|
| 1441 |
ariadna |
735 |
if (!empty($badge->imageauthorurl)) {
|
| 1 |
efrain |
736 |
$output .= html_writer::start_tag('li');
|
| 1441 |
ariadna |
737 |
$output .= '<span class="me-1 font-weight-bold">' . get_string('imageauthorurl', 'badges') .
|
|
|
738 |
': </span>' . html_writer::link($badge->imageauthorurl, $badge->imageauthorurl, ['target' => '_blank']);
|
| 1 |
efrain |
739 |
$output .= html_writer::end_tag('li');
|
|
|
740 |
}
|
|
|
741 |
if (!empty($badge->imagecaption)) {
|
|
|
742 |
$output .= html_writer::start_tag('li');
|
| 1441 |
ariadna |
743 |
$output .= '<span class="me-1 font-weight-bold">' .
|
| 1 |
efrain |
744 |
get_string('imagecaption', 'badges') .
|
| 1441 |
ariadna |
745 |
': </span>' .
|
|
|
746 |
$badge->imagecaption;
|
| 1 |
efrain |
747 |
$output .= html_writer::end_tag('li');
|
|
|
748 |
}
|
|
|
749 |
$output .= html_writer::end_tag('div');
|
|
|
750 |
|
|
|
751 |
$output .= html_writer::end_tag('div'); // End rui-badge-desc.
|
|
|
752 |
$output .= html_writer::end_tag('div'); // End rui-badge-overview.
|
|
|
753 |
|
|
|
754 |
if (!empty($badge->issuername) || !empty($badge->issuercontact)) {
|
| 1441 |
ariadna |
755 |
$output .= html_writer::start_tag('span', ['class' => 'alert alert-secondary d-block']);
|
|
|
756 |
$output .= '<span class="me-1 font-weight-bold">' .
|
| 1 |
efrain |
757 |
get_string('issuername', 'badges') .
|
|
|
758 |
': </span>' .
|
|
|
759 |
$badge->issuername;
|
|
|
760 |
|
|
|
761 |
if (!empty($badge->issuername) || !empty($badge->issuercontact)) {
|
| 1441 |
ariadna |
762 |
$output .= html_writer::tag(
|
|
|
763 |
'a',
|
|
|
764 |
$badge->issuercontact,
|
|
|
765 |
['href' => "mailto:{$badge->issuercontact}"]
|
|
|
766 |
);
|
| 1 |
efrain |
767 |
}
|
|
|
768 |
|
|
|
769 |
$output .= html_writer::end_tag('span');
|
|
|
770 |
}
|
|
|
771 |
|
| 1441 |
ariadna |
772 |
$output .= html_writer::start_tag('div', ['class' => 'wrapper-fw']);
|
| 1 |
efrain |
773 |
|
|
|
774 |
// Criteria details if any.
|
| 1441 |
ariadna |
775 |
$output .= html_writer::start_tag('div', ['class' => 'rui-badge-criteria my-4']);
|
| 1 |
efrain |
776 |
|
| 1441 |
ariadna |
777 |
$output .= html_writer::start_tag('h5', ['class' => 'd-inline-flex align-items-center w-100']);
|
|
|
778 |
$output .= '<svg class="me-2"
|
|
|
779 |
width="22"
|
|
|
780 |
height="22"
|
| 1 |
efrain |
781 |
viewBox="0 0 24 24"
|
|
|
782 |
fill="none"
|
|
|
783 |
xmlns="http://www.w3.org/2000/svg">
|
|
|
784 |
<path d="M10.75 13.25H6.75L13.25 4.75V10.75H17.25L10.75
|
|
|
785 |
19.25V13.25Z"
|
|
|
786 |
stroke="currentColor"
|
|
|
787 |
stroke-width="1.5"
|
|
|
788 |
stroke-linecap="round"
|
|
|
789 |
stroke-linejoin="round"></path>
|
|
|
790 |
</svg>' . get_string('bcriteria', 'badges');
|
|
|
791 |
$output .= html_writer::end_tag('h5');
|
|
|
792 |
|
|
|
793 |
if ($badge->has_criteria()) {
|
| 1441 |
ariadna |
794 |
$output .= '<div class="ms-4">' . self::print_badge_criteria($badge) . '</div>';
|
| 1 |
efrain |
795 |
} else {
|
| 1441 |
ariadna |
796 |
$output .= '<p class="ms-4">' . get_string('nocriteria', 'badges') . '</p>';
|
| 1 |
efrain |
797 |
if (has_capability('moodle/badges:configurecriteria', $context)) {
|
|
|
798 |
$output .= $this->output->single_button(
|
| 1441 |
ariadna |
799 |
new moodle_url('/badges/criteria.php', ['id' => $badge->id]),
|
| 1 |
efrain |
800 |
get_string('addcriteria', 'badges'),
|
|
|
801 |
'POST',
|
| 1441 |
ariadna |
802 |
['class' => 'activatebadge ms-4']
|
| 1 |
efrain |
803 |
);
|
|
|
804 |
}
|
|
|
805 |
}
|
|
|
806 |
$output .= html_writer::end_tag('div');
|
|
|
807 |
|
|
|
808 |
// Awards details if any.
|
| 1441 |
ariadna |
809 |
$output .= html_writer::start_tag('div', ['class' => 'rui-badge-awards my-4']);
|
| 1 |
efrain |
810 |
if (has_capability('moodle/badges:viewawarded', $context)) {
|
| 1441 |
ariadna |
811 |
$output .= html_writer::start_tag('h5', ['class' => 'd-inline-flex align-items-center w-100']);
|
|
|
812 |
$output .= '<svg class="me-2"
|
|
|
813 |
width="22"
|
|
|
814 |
height="22"
|
| 1 |
efrain |
815 |
fill="none"
|
|
|
816 |
viewBox="0 0 24 24"><path stroke="currentColor"
|
|
|
817 |
stroke-linecap="round"
|
|
|
818 |
stroke-linejoin="round"
|
|
|
819 |
stroke-width="1.5"
|
|
|
820 |
d="M5.78168 19.25H13.2183C13.7828 19.25 14.227 18.7817 14.1145
|
|
|
821 |
18.2285C13.804 16.7012 12.7897 14 9.5 14C6.21031 14 5.19605
|
|
|
822 |
16.7012 4.88549 18.2285C4.773 18.7817 5.21718 19.25 5.78168
|
|
|
823 |
19.25Z"></path>
|
|
|
824 |
<path stroke="currentColor"
|
|
|
825 |
stroke-linecap="round"
|
|
|
826 |
stroke-linejoin="round"
|
|
|
827 |
stroke-width="1.5"
|
|
|
828 |
d="M15.75 14C17.8288 14 18.6802 16.1479 19.0239
|
|
|
829 |
17.696C19.2095 18.532 18.5333 19.25 17.6769
|
|
|
830 |
19.25H16.75">
|
|
|
831 |
</path>
|
|
|
832 |
<circle cx="9.5"
|
|
|
833 |
cy="7.5"
|
|
|
834 |
r="2.75"
|
|
|
835 |
stroke="currentColor"
|
|
|
836 |
stroke-linecap="round"
|
|
|
837 |
stroke-linejoin="round"
|
|
|
838 |
stroke-width="1.5"></circle>
|
|
|
839 |
<path stroke="currentColor"
|
|
|
840 |
stroke-linecap="round"
|
|
|
841 |
stroke-linejoin="round"
|
|
|
842 |
stroke-width="1.5"
|
|
|
843 |
d="M14.75 10.25C16.2688 10.25 17.25 9.01878 17.25
|
|
|
844 |
7.5C17.25 5.98122 16.2688 4.75 14.75 4.75"></path>
|
|
|
845 |
</svg>' .
|
| 1441 |
ariadna |
846 |
get_string('awards', 'badges');
|
| 1 |
efrain |
847 |
$output .= html_writer::end_tag('h5');
|
|
|
848 |
|
|
|
849 |
if ($badge->has_awards()) {
|
| 1441 |
ariadna |
850 |
$url = new moodle_url('/badges/recipients.php', ['id' => $badge->id]);
|
| 1 |
efrain |
851 |
$a = new stdClass();
|
| 1441 |
ariadna |
852 |
$a->badgename = $badge->name;
|
| 1 |
efrain |
853 |
$a->link = $url->out();
|
|
|
854 |
$a->count = count($badge->get_awards());
|
| 1441 |
ariadna |
855 |
$output .= html_writer::start_tag('div', ['class' => 'ms-4']);
|
| 1 |
efrain |
856 |
$output .= get_string('numawards', 'badges', $a);
|
| 1441 |
ariadna |
857 |
$output .= html_writer::end_tag('div');
|
| 1 |
efrain |
858 |
} else {
|
| 1441 |
ariadna |
859 |
$output .= html_writer::start_tag('div', ['class' => 'ms-4']);
|
| 1 |
efrain |
860 |
$output .= get_string('noawards', 'badges');
|
|
|
861 |
$output .= html_writer::end_tag('div');
|
|
|
862 |
}
|
|
|
863 |
|
|
|
864 |
if (
|
|
|
865 |
has_capability('moodle/badges:awardbadge', $context) &&
|
|
|
866 |
$badge->has_manual_award_criteria() &&
|
|
|
867 |
$badge->is_active()
|
|
|
868 |
) {
|
| 1441 |
ariadna |
869 |
$output .= html_writer::start_tag('div', ['class' => 'mt-3 ms-4']);
|
| 1 |
efrain |
870 |
$output .= $this->output->single_button(
|
| 1441 |
ariadna |
871 |
new moodle_url('/badges/award.php', ['id' => $badge->id]),
|
| 1 |
efrain |
872 |
get_string('award', 'badges'),
|
|
|
873 |
'POST',
|
| 1441 |
ariadna |
874 |
['class' => 'activatebadge ml-auto']
|
| 1 |
efrain |
875 |
);
|
|
|
876 |
$output .= html_writer::end_tag('div');
|
|
|
877 |
}
|
|
|
878 |
}
|
|
|
879 |
$output .= html_writer::end_tag('div');
|
|
|
880 |
|
| 1441 |
ariadna |
881 |
$output .= html_writer::start_tag('div', ['class' => 'rui-badge-endorsement my-4']);
|
| 1 |
efrain |
882 |
$output .= self::print_badge_endorsement($badge);
|
|
|
883 |
$output .= html_writer::end_tag('div');
|
|
|
884 |
|
| 1441 |
ariadna |
885 |
$output .= html_writer::start_tag('div', ['class' => 'rui-badge-related my-4']);
|
| 1 |
efrain |
886 |
$output .= self::print_badge_related($badge);
|
|
|
887 |
$output .= html_writer::end_tag('div');
|
|
|
888 |
|
| 1441 |
ariadna |
889 |
$output .= html_writer::start_tag('div', ['class' => 'rui-badge-alignments my-4']);
|
| 1 |
efrain |
890 |
$output .= self::print_badge_alignments($badge);
|
|
|
891 |
$output .= html_writer::end_tag('div');
|
|
|
892 |
|
|
|
893 |
$output .= html_writer::end_tag('div'); // End wrapper-fw.
|
|
|
894 |
|
|
|
895 |
$output .= html_writer::end_tag('div'); // End badge-ovrview-wrapper.
|
|
|
896 |
return $output;
|
|
|
897 |
}
|
|
|
898 |
|
|
|
899 |
/**
|
|
|
900 |
* Renders a search form
|
|
|
901 |
*
|
|
|
902 |
* @param string $search Search string
|
|
|
903 |
* @return string HTML
|
|
|
904 |
*/
|
|
|
905 |
protected function helper_search_form($search) {
|
|
|
906 |
global $CFG;
|
|
|
907 |
require_once($CFG->libdir . '/formslib.php');
|
|
|
908 |
|
|
|
909 |
$mform = new MoodleQuickForm('searchform', 'POST', $this->page->url);
|
|
|
910 |
|
|
|
911 |
$mform->addElement('hidden', 'sesskey', sesskey());
|
|
|
912 |
|
| 1441 |
ariadna |
913 |
$el[] = $mform->createElement('text', 'search', get_string('search'), ['size' => 30]);
|
| 1 |
efrain |
914 |
$mform->setDefault('search', $search);
|
|
|
915 |
$el[] = $mform->createElement('submit', 'submitsearch', get_string('search'));
|
|
|
916 |
$el[] = $mform->createElement('submit', 'clearsearch', get_string('clear'));
|
|
|
917 |
$mform->addGroup($el, 'searchgroup', ' ', ' ', false);
|
|
|
918 |
|
|
|
919 |
ob_start();
|
|
|
920 |
$mform->display();
|
|
|
921 |
$out = ob_get_clean();
|
|
|
922 |
|
|
|
923 |
return $out;
|
|
|
924 |
}
|
|
|
925 |
}
|