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 |
|
|
|
17 |
defined('MOODLE_INTERNAL') || die();
|
|
|
18 |
|
|
|
19 |
// Badges.
|
|
|
20 |
require_once($CFG->dirroot . "/badges/renderer.php");
|
|
|
21 |
class theme_monocolor_core_badges_renderer extends core_badges_renderer {
|
|
|
22 |
|
|
|
23 |
// Outputs badges list.
|
|
|
24 |
public function print_badges_list($badges, $userid, $profile = false, $external = false) {
|
|
|
25 |
global $USER, $CFG;
|
|
|
26 |
foreach ($badges as $badge) {
|
|
|
27 |
if (!$external) {
|
|
|
28 |
$context = ($badge->type == BADGE_TYPE_SITE) ?
|
|
|
29 |
context_system::instance() : context_course::instance($badge->courseid);
|
|
|
30 |
$bname = $badge->name;
|
|
|
31 |
$imageurl = moodle_url::make_pluginfile_url(
|
|
|
32 |
$context->id,
|
|
|
33 |
'badges',
|
|
|
34 |
'badgeimage',
|
|
|
35 |
$badge->id,
|
|
|
36 |
'/',
|
|
|
37 |
'f3',
|
|
|
38 |
false
|
|
|
39 |
);
|
|
|
40 |
} else {
|
|
|
41 |
$bname = '';
|
|
|
42 |
$imageurl = '';
|
|
|
43 |
if (!empty($badge->name)) {
|
|
|
44 |
$bname = s($badge->name);
|
|
|
45 |
}
|
|
|
46 |
if (!empty($badge->image)) {
|
|
|
47 |
if (is_object($badge->image)) {
|
|
|
48 |
if (!empty($badge->image->caption)) {
|
|
|
49 |
$badge->imagecaption = $badge->image->caption;
|
|
|
50 |
}
|
|
|
51 |
$imageurl = $badge->image->id;
|
|
|
52 |
} else {
|
|
|
53 |
$imageurl = $badge->image;
|
|
|
54 |
}
|
|
|
55 |
}
|
|
|
56 |
if (isset($badge->assertion->badge->name)) {
|
|
|
57 |
$bname = s($badge->assertion->badge->name);
|
|
|
58 |
}
|
|
|
59 |
if (isset($badge->imageUrl)) {
|
|
|
60 |
$imageurl = $badge->imageUrl;
|
|
|
61 |
}
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
$name = html_writer::tag('span', $bname, array('class' => 'badge-name'));
|
|
|
65 |
|
|
|
66 |
$image = html_writer::empty_tag('img', array('src' => $imageurl, 'class' => 'badge-image'));
|
|
|
67 |
if (!empty($badge->dateexpire) && $badge->dateexpire < time()) {
|
|
|
68 |
$image .= $this->output->pix_icon(
|
|
|
69 |
'i/expired',
|
|
|
70 |
get_string('expireddate', 'badges', userdate($badge->dateexpire)),
|
|
|
71 |
'moodle',
|
|
|
72 |
array('class' => 'expireimage')
|
|
|
73 |
);
|
|
|
74 |
$name .= '(' . get_string('expired', 'badges') . ')';
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
$download = $status = $push = '';
|
|
|
78 |
if (($userid == $USER->id) && !$profile) {
|
|
|
79 |
$params = array(
|
|
|
80 |
'download' => $badge->id,
|
|
|
81 |
'hash' => $badge->uniquehash,
|
|
|
82 |
'sesskey' => sesskey()
|
|
|
83 |
);
|
|
|
84 |
$url = new moodle_url(
|
|
|
85 |
'mybadges.php',
|
|
|
86 |
$params
|
|
|
87 |
);
|
|
|
88 |
$notexpiredbadge = (empty($badge->dateexpire) || $badge->dateexpire > time());
|
|
|
89 |
$userbackpack = badges_get_user_backpack();
|
|
|
90 |
if (!empty($CFG->badges_allowexternalbackpack) && $notexpiredbadge && $userbackpack) {
|
|
|
91 |
$assertion = new moodle_url('/badges/assertion.php', array('b' => $badge->uniquehash));
|
|
|
92 |
$icon = new pix_icon('t/backpack', get_string('addtobackpack', 'badges'));
|
|
|
93 |
if (badges_open_badges_backpack_api($userbackpack->id) == OPEN_BADGES_V2) {
|
|
|
94 |
$addurl = new moodle_url('/badges/backpack-add.php', array('hash' => $badge->uniquehash));
|
|
|
95 |
$push = $this->output->action_icon($addurl, $icon);
|
|
|
96 |
} else if (badges_open_badges_backpack_api($userbackpack->id) == OPEN_BADGES_V2P1) {
|
|
|
97 |
$addurl = new moodle_url('/badges/backpack-export.php', array('hash' => $badge->uniquehash));
|
|
|
98 |
$push = $this->output->action_icon($addurl, $icon);
|
|
|
99 |
}
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
$downloadicon = '<svg width="24" height="24" fill="none" viewBox="0 0 24 24">
|
|
|
103 |
<path stroke="currentColor"
|
|
|
104 |
stroke-linecap="round"
|
|
|
105 |
stroke-linejoin="round"
|
|
|
106 |
stroke-width="1.5"
|
|
|
107 |
d="M4.75 14.75V16.25C4.75 17.9069 6.09315 19.25 7.75 19.25H16.25C17.9069 19.25 19.25
|
|
|
108 |
17.9069 19.25 16.25V14.75"></path><path stroke="currentColor"
|
|
|
109 |
stroke-linecap="round"
|
|
|
110 |
stroke-linejoin="round"
|
|
|
111 |
stroke-width="1.5"
|
|
|
112 |
d="M12 14.25L12 4.75">
|
|
|
113 |
</path>
|
|
|
114 |
<path stroke="currentColor"
|
|
|
115 |
stroke-linecap="round"
|
|
|
116 |
stroke-linejoin="round"
|
|
|
117 |
stroke-width="1.5"
|
|
|
118 |
d="M8.75 10.75L12 14.25L15.25 10.75">
|
|
|
119 |
</path>
|
|
|
120 |
</svg>';
|
|
|
121 |
$download = '<a class="btn btn-icon btn-secondary" href="' . $url . '">' . $downloadicon . '</a>';
|
|
|
122 |
if ($badge->visible) {
|
|
|
123 |
$url = new moodle_url('mybadges.php', array('hide' => $badge->issuedid, 'sesskey' => sesskey()));
|
|
|
124 |
$hideicon = '<svg width="24" height="24" fill="none" viewBox="0 0 24 24">
|
|
|
125 |
<path stroke="currentColor"
|
|
|
126 |
stroke-linecap="round"
|
|
|
127 |
stroke-linejoin="round"
|
|
|
128 |
stroke-width="1.5"
|
|
|
129 |
d="M18.6247 10C19.0646 10.8986 19.25 11.6745 19.25 12C19.25 13 17.5 18.25 12 18.25C11.2686
|
|
|
130 |
18.25 10.6035 18.1572 10 17.9938M7 16.2686C5.36209 14.6693 4.75 12.5914 4.75 12C4.75 11
|
|
|
131 |
6.5 5.75 12 5.75C13.7947 5.75 15.1901 6.30902 16.2558 7.09698"></path>
|
|
|
132 |
<path stroke="currentColor"
|
|
|
133 |
stroke-linecap="round"
|
|
|
134 |
stroke-linejoin="round"
|
|
|
135 |
stroke-width="1.5"
|
|
|
136 |
d="M19.25 4.75L4.75 19.25"></path>
|
|
|
137 |
<path stroke="currentColor"
|
|
|
138 |
stroke-linecap="round"
|
|
|
139 |
stroke-linejoin="round"
|
|
|
140 |
stroke-width="1.5"
|
|
|
141 |
d="M10.409 13.591C9.53033 12.7123 9.53033 11.2877 10.409 10.409C11.2877 9.5303
|
|
|
142 |
12.7123 9.5303 13.591 10.409"></path>
|
|
|
143 |
</svg>';
|
|
|
144 |
$status = '<a class="btn btn-icon btn-danger" href="' . $url . '" title="' .
|
|
|
145 |
get_string('makeprivate', 'badges') . '">' .
|
|
|
146 |
$hideicon .
|
|
|
147 |
'</a>';
|
|
|
148 |
} else {
|
|
|
149 |
$url = new moodle_url('mybadges.php', array('show' => $badge->issuedid, 'sesskey' => sesskey()));
|
|
|
150 |
$showicon = '<svg width="24" height="24"
|
|
|
151 |
fill="none"
|
|
|
152 |
viewBox="0 0 24 24"><path stroke="currentColor"
|
|
|
153 |
stroke-linecap="round"
|
|
|
154 |
stroke-linejoin="round"
|
|
|
155 |
stroke-width="1.5"
|
|
|
156 |
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
|
|
|
157 |
5.75 12 5.75C17.5 5.75 19.25 11 19.25 12Z"></path>
|
|
|
158 |
<circle cx="12" cy="12" r="2.25"
|
|
|
159 |
stroke="currentColor"
|
|
|
160 |
stroke-linecap="round"
|
|
|
161 |
stroke-linejoin="round"
|
|
|
162 |
stroke-width="1.5"></circle></svg>';
|
|
|
163 |
$status = '<a class="btn btn-icon btn-success" href="' . $url .
|
|
|
164 |
'" title="' . get_string('makepublic', 'badges') .
|
|
|
165 |
'">' .
|
|
|
166 |
$showicon .
|
|
|
167 |
'</a>';
|
|
|
168 |
}
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
if (!$profile) {
|
|
|
172 |
$url = new moodle_url('badge.php', array('hash' => $badge->uniquehash));
|
|
|
173 |
} else {
|
|
|
174 |
if (!$external) {
|
|
|
175 |
$url = new moodle_url('/badges/badge.php', array('hash' => $badge->uniquehash));
|
|
|
176 |
} else {
|
|
|
177 |
$hash = hash('md5', $badge->hostedUrl);
|
|
|
178 |
$url = new moodle_url('/badges/external.php', array('hash' => $hash, 'user' => $userid));
|
|
|
179 |
}
|
|
|
180 |
}
|
|
|
181 |
$actions = html_writer::tag('div', $push . $download . $status, array('class' => 'rui-badge-actions'));
|
|
|
182 |
$items[] = html_writer::link($url, $image . $name . $actions, array('title' => $bname));
|
|
|
183 |
}
|
|
|
184 |
|
|
|
185 |
return html_writer::alist($items, array('class' => 'badges rui-list-group'));
|
|
|
186 |
}
|
|
|
187 |
|
|
|
188 |
// Prints action icons for the badge.
|
|
|
189 |
public function print_badge_table_actions($badge, $context) {
|
|
|
190 |
$actions = "";
|
|
|
191 |
|
|
|
192 |
if (has_capability('moodle/badges:configuredetails', $context) && $badge->has_criteria()) {
|
|
|
193 |
// Activate/deactivate badge.
|
|
|
194 |
if ($badge->status == BADGE_STATUS_INACTIVE || $badge->status == BADGE_STATUS_INACTIVE_LOCKED) {
|
|
|
195 |
// Activate will go to another page and ask for confirmation.
|
|
|
196 |
$url = new moodle_url('/badges/action.php');
|
|
|
197 |
$url->param('id', $badge->id);
|
|
|
198 |
$url->param('activate', true);
|
|
|
199 |
$url->param('sesskey', sesskey());
|
|
|
200 |
$return = new moodle_url(qualified_me());
|
|
|
201 |
$url->param('return', $return->out_as_local_url(false));
|
|
|
202 |
$actions .= '<a class="btn btn-icon btn-outline-secondary mr-1" href="' .
|
|
|
203 |
$url .
|
|
|
204 |
'" title="' .
|
|
|
205 |
get_string('activate', 'badges') .
|
|
|
206 |
'">
|
|
|
207 |
<svg width="18" height="18" fill="none" viewBox="0 0 24 24">
|
|
|
208 |
<path stroke="currentColor"
|
|
|
209 |
stroke-linecap="round"
|
|
|
210 |
stroke-linejoin="round"
|
|
|
211 |
stroke-width="1.5"
|
|
|
212 |
d="M19.25 12C19.25 13 17.5 18.25 12 18.25C6.5 18.25 4.75
|
|
|
213 |
13 4.75 12C4.75 11 6.5 5.75 12 5.75C17.5 5.75 19.25 11
|
|
|
214 |
19.25 12Z"></path>
|
|
|
215 |
<circle cx="12" cy="12" r="2.25"
|
|
|
216 |
stroke="currentColor"
|
|
|
217 |
stroke-linecap="round"
|
|
|
218 |
stroke-linejoin="round"
|
|
|
219 |
stroke-width="1.5"></circle>
|
|
|
220 |
</svg>
|
|
|
221 |
</a>';
|
|
|
222 |
} else {
|
|
|
223 |
$url = new moodle_url(qualified_me());
|
|
|
224 |
$url->param('lock', $badge->id);
|
|
|
225 |
$url->param('sesskey', sesskey());
|
|
|
226 |
$actions .= '<a class="btn btn-icon btn-outline-secondary mr-1" href="' .
|
|
|
227 |
$url .
|
|
|
228 |
'" title="' .
|
|
|
229 |
get_string('deactivate', 'badges') .
|
|
|
230 |
'">
|
|
|
231 |
<svg width="18" height="18" fill="none" viewBox="0 0 24 24">
|
|
|
232 |
<path stroke="currentColor"
|
|
|
233 |
stroke-linecap="round"
|
|
|
234 |
stroke-linejoin="round"
|
|
|
235 |
stroke-width="1.5"
|
|
|
236 |
d="M18.6247 10C19.0646 10.8986 19.25 11.6745 19.25 12C19.25
|
|
|
237 |
13 17.5 18.25 12 18.25C11.2686 18.25 10.6035 18.1572 10
|
|
|
238 |
17.9938M7 16.2686C5.36209 14.6693 4.75
|
|
|
239 |
12.5914 4.75 12C4.75 11 6.5 5.75 12 5.75C13.7947 5.75
|
|
|
240 |
15.1901 6.30902 16.2558 7.09698"></path>
|
|
|
241 |
<path stroke="currentColor"
|
|
|
242 |
stroke-linecap="round"
|
|
|
243 |
stroke-linejoin="round"
|
|
|
244 |
stroke-width="1.5"
|
|
|
245 |
d="M19.25 4.75L4.75 19.25"></path>
|
|
|
246 |
<path stroke="currentColor"
|
|
|
247 |
stroke-linecap="round"
|
|
|
248 |
stroke-linejoin="round"
|
|
|
249 |
stroke-width="1.5"
|
|
|
250 |
d="M10.409 13.591C9.53033 12.7123 9.53033 11.2877 10.409
|
|
|
251 |
10.409C11.2877 9.5303 12.7123 9.5303 13.591 10.409"></path>
|
|
|
252 |
</svg>
|
|
|
253 |
</a>';
|
|
|
254 |
}
|
|
|
255 |
}
|
|
|
256 |
|
|
|
257 |
// Award badge manually.
|
|
|
258 |
if (
|
|
|
259 |
$badge->has_manual_award_criteria() &&
|
|
|
260 |
has_capability('moodle/badges:awardbadge', $context) &&
|
|
|
261 |
$badge->is_active()
|
|
|
262 |
) {
|
|
|
263 |
$url = new moodle_url('/badges/award.php', array('id' => $badge->id));
|
|
|
264 |
$actions .= '<a class="btn btn-icon btn-outline-secondary mr-1" href="' .
|
|
|
265 |
$url .
|
|
|
266 |
'" title="' .
|
|
|
267 |
get_string('award', 'badges') .
|
|
|
268 |
'">
|
|
|
269 |
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
|
270 |
<path d="M17.25 10C17.25 12.8995 14.8995 15.25 12 15.25C9.10051
|
|
|
271 |
15.25 6.75 12.8995 6.75 10C6.75 7.10051 9.10051
|
|
|
272 |
4.75 12 4.75C14.8995 4.75 17.25 7.10051 17.25 10Z"
|
|
|
273 |
stroke="currentColor"
|
|
|
274 |
stroke-width="1.5"
|
|
|
275 |
stroke-linecap="round"
|
|
|
276 |
stroke-linejoin="round"></path>
|
|
|
277 |
<path d="M8.75 14.75L7.75 19.25L12 17.75L16.25 19.25L15.25 14.75"
|
|
|
278 |
stroke="currentColor"
|
|
|
279 |
stroke-width="1.5"
|
|
|
280 |
stroke-linecap="round" stroke-linejoin="round"></path>
|
|
|
281 |
</svg>
|
|
|
282 |
</a>';
|
|
|
283 |
}
|
|
|
284 |
|
|
|
285 |
// Edit badge.
|
|
|
286 |
if (has_capability('moodle/badges:configuredetails', $context)) {
|
|
|
287 |
$url = new moodle_url('/badges/edit.php', array('id' => $badge->id, 'action' => 'badge'));
|
|
|
288 |
$actions .= '<a class="btn btn-icon btn-outline-secondary mr-1" href="' .
|
|
|
289 |
$url .
|
|
|
290 |
'" title="' .
|
|
|
291 |
get_string('edit') .
|
|
|
292 |
'">
|
|
|
293 |
<svg width="18" height="18" fill="none" viewBox="0 0 24 24">
|
|
|
294 |
<path stroke="currentColor"
|
|
|
295 |
stroke-linecap="round"
|
|
|
296 |
stroke-linejoin="round"
|
|
|
297 |
stroke-width="1.5"
|
|
|
298 |
d="M4.75 19.25L9 18.25L18.2929 8.95711C18.6834 8.56658 18.6834
|
|
|
299 |
7.93342 18.2929 7.54289L16.4571
|
|
|
300 |
5.70711C16.0666 5.31658 15.4334 5.31658 15.0429 5.70711L5.75
|
|
|
301 |
15L4.75 19.25Z"></path>
|
|
|
302 |
<path stroke="currentColor"
|
|
|
303 |
stroke-linecap="round"
|
|
|
304 |
stroke-linejoin="round"
|
|
|
305 |
stroke-width="1.5"
|
|
|
306 |
d="M19.25 19.25H13.75"></path>
|
|
|
307 |
</svg>
|
|
|
308 |
</a>';
|
|
|
309 |
}
|
|
|
310 |
|
|
|
311 |
// Duplicate badge.
|
|
|
312 |
if (has_capability('moodle/badges:createbadge', $context)) {
|
|
|
313 |
$url = new moodle_url('/badges/action.php',
|
|
|
314 |
array('copy' => '1', 'id' => $badge->id, 'sesskey' => sesskey()));
|
|
|
315 |
$actions .= '<a class="btn btn-icon btn-outline-secondary mr-1" href="' .
|
|
|
316 |
$url .
|
|
|
317 |
'" title="' . get_string('copy') . '">
|
|
|
318 |
<svg width="18" height="18" fill="none" viewBox="0 0 24 24">
|
|
|
319 |
<path stroke="currentColor"
|
|
|
320 |
stroke-linecap="round"
|
|
|
321 |
stroke-linejoin="round"
|
|
|
322 |
stroke-width="1.5"
|
|
|
323 |
d="M6.5 15.25V15.25C5.5335 15.25 4.75 14.4665 4.75 13.5V6.75C4.75 5.64543 5.64543 4.75
|
|
|
324 |
6.75 4.75H13.5C14.4665 4.75 15.25 5.5335 15.25 6.5V6.5"></path>
|
|
|
325 |
<rect width="10.5"
|
|
|
326 |
height="10.5"
|
|
|
327 |
x="8.75"
|
|
|
328 |
y="8.75"
|
|
|
329 |
stroke="currentColor"
|
|
|
330 |
stroke-linecap="round"
|
|
|
331 |
stroke-linejoin="round"
|
|
|
332 |
stroke-width="1.5"
|
|
|
333 |
rx="1.5"></rect>
|
|
|
334 |
</svg>
|
|
|
335 |
</a>';
|
|
|
336 |
}
|
|
|
337 |
|
|
|
338 |
// Delete badge.
|
|
|
339 |
if (has_capability('moodle/badges:deletebadge', $context)) {
|
|
|
340 |
$url = new moodle_url(qualified_me());
|
|
|
341 |
$url->param('delete', $badge->id);
|
|
|
342 |
$actions .= '<a class="btn btn-icon btn-outline-danger mr-1" href="' . $url . '"
|
|
|
343 |
title="' . get_string('delete') . '">
|
|
|
344 |
<svg width="18" height="18" fill="none" viewBox="0 0 24 24">
|
|
|
345 |
<path stroke="currentColor"
|
|
|
346 |
stroke-linecap="round"
|
|
|
347 |
stroke-linejoin="round"
|
|
|
348 |
stroke-width="1.5"
|
|
|
349 |
d="M6.75 7.75L7.59115 17.4233C7.68102 18.4568 8.54622 19.25 9.58363
|
|
|
350 |
19.25H14.4164C15.4538 19.25 16.319 18.4568 16.4088 17.4233L17.25 7.75"></path>
|
|
|
351 |
<path stroke="currentColor"
|
|
|
352 |
stroke-linecap="round"
|
|
|
353 |
stroke-linejoin="round"
|
|
|
354 |
stroke-width="1.5"
|
|
|
355 |
d="M9.75 7.5V6.75C9.75 5.64543 10.6454 4.75 11.75 4.75H12.25C13.3546
|
|
|
356 |
4.75 14.25 5.64543 14.25 6.75V7.5"></path>
|
|
|
357 |
<path stroke="currentColor"
|
|
|
358 |
stroke-linecap="round"
|
|
|
359 |
stroke-linejoin="round"
|
|
|
360 |
stroke-width="1.5"
|
|
|
361 |
d="M5 7.75H19"></path>
|
|
|
362 |
</svg></a>';
|
|
|
363 |
}
|
|
|
364 |
|
|
|
365 |
return $actions;
|
|
|
366 |
}
|
|
|
367 |
|
|
|
368 |
/**
|
|
|
369 |
* Render a collection of user badges.
|
|
|
370 |
*
|
|
|
371 |
* @param \core_badges\output\badge_user_collection $badges
|
|
|
372 |
* @return string
|
|
|
373 |
*/
|
|
|
374 |
protected function render_badge_user_collection(\core_badges\output\badge_user_collection $badges) {
|
|
|
375 |
global $CFG, $USER, $SITE;
|
|
|
376 |
$backpack = $badges->backpack;
|
|
|
377 |
$mybackpack = new moodle_url('/badges/mybackpack.php');
|
|
|
378 |
|
|
|
379 |
$paging = new paging_bar($badges->totalcount, $badges->page, $badges->perpage, $this->page->url, 'page');
|
|
|
380 |
$htmlpagingbar = $this->render($paging);
|
|
|
381 |
|
|
|
382 |
// Set backpack connection string.
|
|
|
383 |
$backpackconnect = '';
|
|
|
384 |
if (!empty($CFG->badges_allowexternalbackpack) && is_null($backpack)) {
|
|
|
385 |
$backpackconnect = $this->output->box(get_string('localconnectto', 'badges', $mybackpack->out()), 'noticebox');
|
|
|
386 |
}
|
|
|
387 |
// Search box.
|
|
|
388 |
$searchform = $this->output->container($this->helper_search_form($badges->search));
|
|
|
389 |
|
|
|
390 |
// Download all button.
|
|
|
391 |
$actionhtml = $this->output->single_button(
|
|
|
392 |
new moodle_url('/badges/mybadges.php', array('downloadall' => true, 'sesskey' => sesskey())),
|
|
|
393 |
get_string('downloadall'),
|
|
|
394 |
'POST',
|
|
|
395 |
array('class' => 'activatebadge ml-auto')
|
|
|
396 |
);
|
|
|
397 |
|
|
|
398 |
$downloadall = $this->output->container($actionhtml, 'rui-downloadall text-right');
|
|
|
399 |
$downloadall = $this->output->container($downloadall, 'rui-downloadall-wrapper mt-3');
|
|
|
400 |
|
|
|
401 |
// Local badges.
|
|
|
402 |
$localhtml = html_writer::start_tag('div',
|
|
|
403 |
array('id' => 'issued-badge-table', 'class' => 'wrapper-fw mb-5'));
|
|
|
404 |
$sitename = format_string($SITE->fullname, true, array('context' => context_system::instance()));
|
|
|
405 |
$heading = get_string('localbadges', 'badges', $sitename);
|
|
|
406 |
$localhtml .= $this->output->heading_with_help($heading, 'localbadgesh', 'badges', '', '', 2, $classnames = 'mb-3');
|
|
|
407 |
if ($badges->badges) {
|
|
|
408 |
$countmessage = '<hr /><svg class="mr-2"
|
|
|
409 |
width="24"
|
|
|
410 |
height="24"
|
|
|
411 |
fill="none"
|
|
|
412 |
viewBox="0 0 24 24">
|
|
|
413 |
<path stroke="currentColor"
|
|
|
414 |
stroke-linecap="round"
|
|
|
415 |
stroke-linejoin="round"
|
|
|
416 |
stroke-width="2"
|
|
|
417 |
d="M14.25 8.75L18.25 4.75H5.75L9.75 8.75"></path><circle cx="12" cy="14" r="5.25"
|
|
|
418 |
stroke="currentColor"
|
|
|
419 |
stroke-linecap="round"
|
|
|
420 |
stroke-linejoin="round"
|
|
|
421 |
stroke-width="2"></circle></svg>' .
|
|
|
422 |
get_string('badgesearned', 'badges', $badges->totalcount) . '<hr />';
|
|
|
423 |
|
|
|
424 |
$htmllist = $this->print_badges_list($badges->badges, $USER->id);
|
|
|
425 |
$localhtml .= $backpackconnect . $countmessage . $searchform;
|
|
|
426 |
$localhtml .= $htmlpagingbar . $htmllist . $htmlpagingbar . $downloadall;
|
|
|
427 |
} else {
|
|
|
428 |
$localhtml .= $searchform . $this->output->notification(get_string('nobadges', 'badges'));
|
|
|
429 |
}
|
|
|
430 |
$localhtml .= html_writer::end_tag('div');
|
|
|
431 |
|
|
|
432 |
// External badges.
|
|
|
433 |
$externalhtml = "";
|
|
|
434 |
if (!empty($CFG->badges_allowexternalbackpack)) {
|
|
|
435 |
$externalhtml .= html_writer::start_tag('div', array('class' => 'wrapper-fw mt-4'));
|
|
|
436 |
$externalhtml .= $this->output->heading_with_help(get_string('externalbadges', 'badges'),
|
|
|
437 |
'externalbadges', 'badges', '', '', 5, 'mb-3');
|
|
|
438 |
if (!is_null($backpack)) {
|
|
|
439 |
if ($backpack->totalcollections == 0) {
|
|
|
440 |
$externalhtml .= get_string('nobackpackcollectionssummary', 'badges', $backpack);
|
|
|
441 |
} else {
|
|
|
442 |
if ($backpack->totalbadges == 0) {
|
|
|
443 |
$externalhtml .= get_string('nobackpackbadgessummary', 'badges', $backpack);
|
|
|
444 |
} else {
|
|
|
445 |
$externalhtml .= get_string('backpackbadgessummary', 'badges', $backpack);
|
|
|
446 |
$externalhtml .= '<br/><br/>' . $this->print_badges_list($backpack->badges,
|
|
|
447 |
$USER->id, true, true);
|
|
|
448 |
}
|
|
|
449 |
}
|
|
|
450 |
} else {
|
|
|
451 |
$externalhtml .= get_string('externalconnectto', 'badges', $mybackpack->out());
|
|
|
452 |
}
|
|
|
453 |
|
|
|
454 |
$externalhtml .= html_writer::end_tag('div');
|
|
|
455 |
$attr = ['class' => 'btn btn-info'];
|
|
|
456 |
$label = get_string('backpackbadgessettings', 'badges');
|
|
|
457 |
$backpacksettings = html_writer::link(new moodle_url('/badges/mybackpack.php'), $label, $attr);
|
|
|
458 |
$actionshtml = $this->output->container($backpacksettings, 'rui-backpacksettings');
|
|
|
459 |
$actionshtml = $this->output->container($actionshtml, 'rui-backpacksettings-wrapper wrapper-fw mt-3');
|
|
|
460 |
$externalhtml .= $actionshtml;
|
|
|
461 |
}
|
|
|
462 |
|
|
|
463 |
return $localhtml . $externalhtml;
|
|
|
464 |
}
|
|
|
465 |
|
|
|
466 |
/**
|
|
|
467 |
* Render a collection of badges.
|
|
|
468 |
*
|
|
|
469 |
* @param \core_badges\output\badge_collection $badges
|
|
|
470 |
* @return string
|
|
|
471 |
*/
|
|
|
472 |
protected function render_badge_collection(\core_badges\output\badge_collection $badges) {
|
|
|
473 |
$output = '';
|
|
|
474 |
foreach ($badges->badges as $badge) {
|
|
|
475 |
$badgeimage = print_badge_image($badge, $this->page->context, 'large');
|
|
|
476 |
$name = $badge->name;
|
|
|
477 |
$description = $badge->description;
|
|
|
478 |
$criteria = self::print_badge_criteria($badge);
|
|
|
479 |
if ($badge->dateissued) {
|
|
|
480 |
$iconcheck = '<svg class="mr-2"
|
|
|
481 |
width="24"
|
|
|
482 |
height="24"
|
|
|
483 |
fill="none"
|
|
|
484 |
viewBox="0 0 24 24">
|
|
|
485 |
<path stroke="currentColor"
|
|
|
486 |
stroke-linecap="round"
|
|
|
487 |
stroke-linejoin="round"
|
|
|
488 |
stroke-width="2"
|
|
|
489 |
d="M4.75 12C4.75 7.99594 7.99594 4.75 12 4.75V4.75C16.0041
|
|
|
490 |
4.75 19.25 7.99594 19.25 12V12C19.25 16.0041 16.0041 19.25
|
|
|
491 |
12 19.25V19.25C7.99594 19.25 4.75 16.0041 4.75 12V12Z">
|
|
|
492 |
</path>
|
|
|
493 |
<path stroke="currentColor"
|
|
|
494 |
stroke-linecap="round"
|
|
|
495 |
stroke-linejoin="round"
|
|
|
496 |
stroke-width="2"
|
|
|
497 |
d="M9.75 12.75L10.1837 13.6744C10.5275 14.407 11.5536
|
|
|
498 |
14.4492 11.9564 13.7473L14.25 9.75"></path></svg>';
|
|
|
499 |
$criteriatxt = $iconcheck . get_string('dateearned', 'badges', userdate($badge->dateissued,
|
|
|
500 |
get_string('strftimedatefullshort', 'core_langconfig')));
|
|
|
501 |
$badgeurl = new moodle_url('/badges/badge.php', array('hash' => $badge->uniquehash));
|
|
|
502 |
$awarded = '<a class="d-inline-flex align-items-center" href="' . $badgeurl . '">' . $criteriatxt . '</a>';
|
|
|
503 |
} else {
|
|
|
504 |
$awarded = "";
|
|
|
505 |
}
|
|
|
506 |
|
|
|
507 |
$output .= '<div class="m-0">';
|
|
|
508 |
$output .= '<div class="rui-badge-overview-wrapper
|
|
|
509 |
border rounded w-100 p-4 mt-2 mb-2 d-inline-flex align-items-start">';
|
|
|
510 |
$output .= '<div class="border rounded p-4 mr-6">' . $badgeimage . '</div>';
|
|
|
511 |
$output .= html_writer::start_tag('div', array('class' => 'rui-badge-overview'));
|
|
|
512 |
$output .= html_writer::start_tag('h4', array('class' => 'rui-badge-name mt-2'));
|
|
|
513 |
$output .= $name;
|
|
|
514 |
$output .= html_writer::end_tag('h4');
|
|
|
515 |
$output .= html_writer::start_tag('div',
|
|
|
516 |
array('class' => 'rui-badge-desc mt-3'));
|
|
|
517 |
$output .= html_writer::start_tag('h5',
|
|
|
518 |
array('class' => 'd-inline-flex align-items-center w-100'));
|
|
|
519 |
$output .= get_string('description', 'badges');
|
|
|
520 |
$output .= html_writer::end_tag('h5');
|
|
|
521 |
$output .= $description;
|
|
|
522 |
|
|
|
523 |
$output .= html_writer::start_tag('h5',
|
|
|
524 |
array('class' => 'd-inline-flex align-items-center w-100 mt-4'));
|
|
|
525 |
$output .= '<svg class="mr-2" width="24"
|
|
|
526 |
height="24"
|
|
|
527 |
viewBox="0 0 24 24"
|
|
|
528 |
fill="none"
|
|
|
529 |
xmlns="http://www.w3.org/2000/svg">
|
|
|
530 |
<path d="M10.75 13.25H6.75L13.25 4.75V10.75H17.25L10.75 19.25V13.25Z"
|
|
|
531 |
stroke="currentColor"
|
|
|
532 |
stroke-width="1.5"
|
|
|
533 |
stroke-linecap="round" stroke-linejoin="round"></path></svg>' .
|
|
|
534 |
get_string('bcriteria', 'badges');
|
|
|
535 |
$output .= html_writer::end_tag('h5');
|
|
|
536 |
$output .= '<div class="ml-4">' . $criteria . '</div>';
|
|
|
537 |
|
|
|
538 |
if (!empty($awarded)) {
|
|
|
539 |
$output .= html_writer::start_tag('h5', array('class' => 'd-inline-flex align-items-center w-100 mt-4'));
|
|
|
540 |
$output .= '<svg class="mr-2"
|
|
|
541 |
width="24"
|
|
|
542 |
height="24"
|
|
|
543 |
viewBox="0 0 24 24"
|
|
|
544 |
fill="none"
|
|
|
545 |
xmlns="http://www.w3.org/2000/svg">
|
|
|
546 |
<path d="M17.25 10C17.25 12.8995 14.8995 15.25 12 15.25C9.10051 15.25 6.75
|
|
|
547 |
12.8995 6.75 10C6.75 7.10051 9.10051 4.75 12 4.75C14.8995 4.75 17.25
|
|
|
548 |
7.10051 17.25 10Z" stroke="currentColor"
|
|
|
549 |
stroke-width="1.5"
|
|
|
550 |
stroke-linecap="round"
|
|
|
551 |
stroke-linejoin="round"></path>
|
|
|
552 |
<path d="M8.75 14.75L7.75 19.25L12 17.75L16.25 19.25L15.25 14.75"
|
|
|
553 |
stroke="currentColor"
|
|
|
554 |
stroke-width="1.5"
|
|
|
555 |
stroke-linecap="round" stroke-linejoin="round"></path></svg>' .
|
|
|
556 |
get_string('awardedtoyou', 'badges');
|
|
|
557 |
$output .= html_writer::end_tag('h5');
|
|
|
558 |
$output .= '<div class="ml-4">' . $awarded . '</div>';
|
|
|
559 |
}
|
|
|
560 |
|
|
|
561 |
$output .= html_writer::end_tag('div');
|
|
|
562 |
$output .= html_writer::end_tag('div');
|
|
|
563 |
$output .= '</div>';
|
|
|
564 |
$output .= '</div>';
|
|
|
565 |
}
|
|
|
566 |
|
|
|
567 |
return $output;
|
|
|
568 |
}
|
|
|
569 |
|
|
|
570 |
/**
|
|
|
571 |
* Render a table of badges.
|
|
|
572 |
*
|
|
|
573 |
* @param \core_badges\output\badge_management $badges
|
|
|
574 |
* @return string
|
|
|
575 |
*/
|
|
|
576 |
protected function render_badge_management(\core_badges\output\badge_management $badges) {
|
|
|
577 |
// New badge button.
|
|
|
578 |
$htmlnew = '';
|
|
|
579 |
if (has_capability('moodle/badges:createbadge', $this->page->context)) {
|
|
|
580 |
$n['type'] = $this->page->url->get_param('type');
|
|
|
581 |
$n['id'] = $this->page->url->get_param('id');
|
|
|
582 |
$btn = $this->output->single_button(new moodle_url('newbadge.php', $n), get_string('newbadge', 'badges'));
|
|
|
583 |
$htmlnew = $this->output->box($btn);
|
|
|
584 |
}
|
|
|
585 |
|
|
|
586 |
$output = '';
|
|
|
587 |
|
|
|
588 |
$output .= '<div class="rui-badge-wrapper">';
|
|
|
589 |
foreach ($badges->badges as $b) {
|
|
|
590 |
$style = !$b->is_active() ? 'rui-badge-not-available' : '';
|
|
|
591 |
$badgeimage = print_badge_image($b, $this->page->context, 'large');
|
|
|
592 |
$forlink = html_writer::start_tag('span') . $b->name . html_writer::end_tag('span');
|
|
|
593 |
$name = html_writer::link(new moodle_url('/badges/overview.php', array('id' => $b->id)), $forlink);
|
|
|
594 |
|
|
|
595 |
if (!$b->is_active()) {
|
|
|
596 |
$status = '<span class="badge badge-danger">' . $b->statstring . '</span>';
|
|
|
597 |
} else {
|
|
|
598 |
$status = '<span class="badge badge-success">' . $b->statstring . '</span>';
|
|
|
599 |
}
|
|
|
600 |
|
|
|
601 |
$criteria = self::print_badge_criteria($b, 'short');
|
|
|
602 |
|
|
|
603 |
$output .= '<div class="rui-badge-box w-100 ' . $style . '">';
|
|
|
604 |
$output .= '<div class="rui-badge-overview-actions d-flex justify-content-between"><div>' .
|
|
|
605 |
self::print_badge_table_actions($b, $this->page->context) . '</div>' .
|
|
|
606 |
$status .
|
|
|
607 |
'</div>';
|
|
|
608 |
|
|
|
609 |
$output .= '<div class="d-inline-flex align-items-start w-100">';
|
|
|
610 |
$output .= '<div class="border rounded p-5 mr-6">' . $badgeimage . '</div>';
|
|
|
611 |
$output .= html_writer::start_tag('div', array('class' => 'rui-badge-overview'));
|
|
|
612 |
|
|
|
613 |
$output .= html_writer::start_tag('h4', array('class' => 'rui-badge-name mt-2'));
|
|
|
614 |
$output .= $name;
|
|
|
615 |
$output .= html_writer::end_tag('h4');
|
|
|
616 |
$output .= html_writer::start_tag('div', array('class' => 'rui-badge-desc'));
|
|
|
617 |
|
|
|
618 |
$output .= html_writer::start_tag('h5', array('class' => 'd-inline-flex align-items-center w-100 mt-2'));
|
|
|
619 |
$output .= '<svg class="mr-2"
|
|
|
620 |
width="24"
|
|
|
621 |
height="24"
|
|
|
622 |
viewBox="0 0 24 24"
|
|
|
623 |
fill="none"
|
|
|
624 |
xmlns="http://www.w3.org/2000/svg">
|
|
|
625 |
<path d="M10.75 13.25H6.75L13.25 4.75V10.75H17.25L10.75 19.25V13.25Z"
|
|
|
626 |
stroke="currentColor"
|
|
|
627 |
stroke-width="1.5"
|
|
|
628 |
stroke-linecap="round"
|
|
|
629 |
stroke-linejoin="round"></path></svg>' . get_string('bcriteria', 'badges');
|
|
|
630 |
$output .= html_writer::end_tag('h5');
|
|
|
631 |
$output .= '<div class="ml-4">' . $criteria . '</div>';
|
|
|
632 |
|
|
|
633 |
if (has_capability('moodle/badges:viewawarded', $this->page->context)) {
|
|
|
634 |
$awards = html_writer::link(new moodle_url('/badges/recipients.php', array('id' => $b->id)), $b->awards);
|
|
|
635 |
$output .= html_writer::start_tag('h5', array('class' => 'd-inline-flex align-items-center w-100 mt-4'));
|
|
|
636 |
$output .= '<svg class="mr-2"
|
|
|
637 |
width="24"
|
|
|
638 |
height="24"
|
|
|
639 |
viewBox="0 0 24 24"
|
|
|
640 |
fill="none"
|
|
|
641 |
xmlns="http://www.w3.org/2000/svg">
|
|
|
642 |
<path d="M17.25 10C17.25 12.8995 14.8995 15.25 12 15.25C9.10051 15.25 6.75
|
|
|
643 |
12.8995 6.75 10C6.75 7.10051 9.10051 4.75 12 4.75C14.8995 4.75 17.25
|
|
|
644 |
7.10051 17.25 10Z"
|
|
|
645 |
stroke="currentColor"
|
|
|
646 |
stroke-width="1.5"
|
|
|
647 |
stroke-linecap="round"
|
|
|
648 |
stroke-linejoin="round"></path>
|
|
|
649 |
<path d="M8.75 14.75L7.75 19.25L12 17.75L16.25 19.25L15.25 14.75"
|
|
|
650 |
stroke="currentColor"
|
|
|
651 |
stroke-width="1.5"
|
|
|
652 |
stroke-linecap="round" stroke-linejoin="round"></path></svg>' . get_string('awards', 'badges');
|
|
|
653 |
$output .= html_writer::end_tag('h5');
|
|
|
654 |
$output .= '<div class="ml-4">' . $awards . '</div>';
|
|
|
655 |
} else {
|
|
|
656 |
$output .= html_writer::start_tag('h5', array('class' => 'd-inline-flex align-items-center w-100 mt-4'));
|
|
|
657 |
$output .= '<svg class="mr-2"
|
|
|
658 |
width="24"
|
|
|
659 |
height="24"
|
|
|
660 |
viewBox="0 0 24 24"
|
|
|
661 |
fill="none"
|
|
|
662 |
xmlns="http://www.w3.org/2000/svg">
|
|
|
663 |
<path d="M17.25 10C17.25 12.8995 14.8995 15.25 12 15.25C9.10051 15.25 6.75 12.8995 6.75
|
|
|
664 |
10C6.75 7.10051 9.10051 4.75 12 4.75C14.8995 4.75 17.25 7.10051 17.25 10Z"
|
|
|
665 |
stroke="currentColor"
|
|
|
666 |
stroke-width="1.5"
|
|
|
667 |
stroke-linecap="round"
|
|
|
668 |
stroke-linejoin="round"></path>
|
|
|
669 |
<path d="M8.75 14.75L7.75 19.25L12 17.75L16.25 19.25L15.25 14.75"
|
|
|
670 |
stroke="currentColor"
|
|
|
671 |
stroke-width="1.5"
|
|
|
672 |
stroke-linecap="round" stroke-linejoin="round"></path></svg>' .
|
|
|
673 |
get_string('awards', 'badges');
|
|
|
674 |
$output .= html_writer::end_tag('h5');
|
|
|
675 |
$output .= '<div class="ml-4">' . $b->awards . '</div>';
|
|
|
676 |
}
|
|
|
677 |
|
|
|
678 |
$output .= html_writer::end_tag('div'); // .rui-badge-desc.
|
|
|
679 |
$output .= html_writer::end_tag('div'); // .rui-badge-overview.
|
|
|
680 |
$output .= '</div>';
|
|
|
681 |
$output .= '</div>';
|
|
|
682 |
}
|
|
|
683 |
$output .= '</div>';
|
|
|
684 |
return $output;
|
|
|
685 |
}
|
|
|
686 |
|
|
|
687 |
/**
|
|
|
688 |
* Prints badge status box.
|
|
|
689 |
*
|
|
|
690 |
* @param badge $badge
|
|
|
691 |
* @return Either the status box html as a string or null
|
|
|
692 |
*/
|
|
|
693 |
public function print_badge_status_box(badge $badge) {
|
|
|
694 |
if (has_capability('moodle/badges:configurecriteria', $badge->get_context())) {
|
|
|
695 |
|
|
|
696 |
if (!$badge->has_criteria()) {
|
|
|
697 |
$criteriaurl = new moodle_url('/badges/criteria.php', array('id' => $badge->id));
|
|
|
698 |
$status = get_string('nocriteria', 'badges');
|
|
|
699 |
if ($this->page->url != $criteriaurl) {
|
|
|
700 |
$action = $this->output->single_button(
|
|
|
701 |
$criteriaurl,
|
|
|
702 |
get_string('addcriteria', 'badges'),
|
|
|
703 |
'POST',
|
|
|
704 |
array('class' => 'activatebadge ml-auto')
|
|
|
705 |
);
|
|
|
706 |
} else {
|
|
|
707 |
$action = '';
|
|
|
708 |
}
|
|
|
709 |
|
|
|
710 |
$message = '<p class="m-0">' . $status . $action . '</p>';
|
|
|
711 |
} else {
|
|
|
712 |
$status = get_string('statusmessage_' . $badge->status, 'badges');
|
|
|
713 |
if ($badge->is_active()) {
|
|
|
714 |
$action = $this->output->single_button(
|
|
|
715 |
new moodle_url(
|
|
|
716 |
'/badges/action.php',
|
|
|
717 |
array(
|
|
|
718 |
'id' => $badge->id,
|
|
|
719 |
'lock' => 1,
|
|
|
720 |
'sesskey' => sesskey(),
|
|
|
721 |
'return' => $this->page->url->out_as_local_url(false)
|
|
|
722 |
)
|
|
|
723 |
),
|
|
|
724 |
get_string('deactivate', 'badges'),
|
|
|
725 |
'POST',
|
|
|
726 |
array('class' => 'activatebadge ml-auto')
|
|
|
727 |
);
|
|
|
728 |
} else {
|
|
|
729 |
$action = $this->output->single_button(
|
|
|
730 |
new moodle_url(
|
|
|
731 |
'/badges/action.php',
|
|
|
732 |
array(
|
|
|
733 |
'id' => $badge->id,
|
|
|
734 |
'activate' => 1,
|
|
|
735 |
'sesskey' => sesskey(),
|
|
|
736 |
'return' => $this->page->url->out_as_local_url(false)
|
|
|
737 |
)
|
|
|
738 |
),
|
|
|
739 |
get_string('activate', 'badges'),
|
|
|
740 |
'POST',
|
|
|
741 |
array('class' => 'activatebadge ml-auto')
|
|
|
742 |
);
|
|
|
743 |
}
|
|
|
744 |
|
|
|
745 |
$message = '<p class="py-3 m-0">' . $status . $this->output->help_icon('status', 'badges') . $action . '</p>';
|
|
|
746 |
}
|
|
|
747 |
|
|
|
748 |
$style = $badge->is_active() ?
|
|
|
749 |
'wrapper-fw d-flex align-items-center justify-content-between
|
|
|
750 |
alert alert-info rui-statusbox active pr-2' :
|
|
|
751 |
'wrapper-fw d-flex align-items-center justify-content-between
|
|
|
752 |
alert alert-warning rui-statusbox inactive pr-2';
|
|
|
753 |
return $this->output->container($message, $style);
|
|
|
754 |
}
|
|
|
755 |
|
|
|
756 |
return null;
|
|
|
757 |
}
|
|
|
758 |
|
|
|
759 |
/**
|
|
|
760 |
* Outputs list en badges.
|
|
|
761 |
*
|
|
|
762 |
* @param badge $badge Badge object.
|
|
|
763 |
* @return string $output content endorsement to output.
|
|
|
764 |
*/
|
|
|
765 |
protected function print_badge_endorsement(badge $badge) {
|
|
|
766 |
$output = '';
|
|
|
767 |
$endorsement = $badge->get_endorsement();
|
|
|
768 |
$dl = array();
|
|
|
769 |
|
|
|
770 |
$output .= html_writer::start_tag('h5', array('class' => 'd-inline-flex align-items-center w-100'));
|
|
|
771 |
$output .= '<svg class="mr-2"
|
|
|
772 |
width="24"
|
|
|
773 |
height="24"
|
|
|
774 |
fill="none"
|
|
|
775 |
viewBox="0 0 24 24"><path stroke="currentColor"
|
|
|
776 |
stroke-linecap="round"
|
|
|
777 |
stroke-linejoin="round"
|
|
|
778 |
stroke-width="2"
|
|
|
779 |
d="M12 13V15"></path><circle cx="12"
|
|
|
780 |
cy="9"
|
|
|
781 |
r="1"
|
|
|
782 |
fill="currentColor"></circle><circle cx="12"
|
|
|
783 |
cy="12"
|
|
|
784 |
r="7.25"
|
|
|
785 |
stroke="currentColor"
|
|
|
786 |
stroke-linecap="round"
|
|
|
787 |
stroke-linejoin="round"
|
|
|
788 |
stroke-width="1.5"></circle></svg>' . get_string('endorsement', 'badges');
|
|
|
789 |
$output .= html_writer::end_tag('h5');
|
|
|
790 |
|
|
|
791 |
if (!empty($endorsement)) {
|
|
|
792 |
$output .= html_writer::start_tag('div', array('class' => 'ml-4'));
|
|
|
793 |
|
|
|
794 |
if (!empty(userdate($endorsement->dateissued))) {
|
|
|
795 |
$output .= html_writer::start_tag('span', array('class' => 'badge badge-light'));
|
|
|
796 |
$output .= '<span class="mr-1 font-weight-bold">' .
|
|
|
797 |
get_string('dateawarded', 'badges') .
|
|
|
798 |
': </span>' .
|
|
|
799 |
userdate($endorsement->dateissued);
|
|
|
800 |
$output .= html_writer::end_tag('span');
|
|
|
801 |
}
|
|
|
802 |
|
|
|
803 |
$output .= html_writer::start_tag('div',
|
|
|
804 |
array('class' => 'rui-badge-comment w-100 rounded p-4 my-2'));
|
|
|
805 |
$output .= '<label>' . get_string('claimcomment', 'badges') . '</label>';
|
|
|
806 |
$output .= html_writer::start_tag('p',
|
|
|
807 |
array('class' => 'd-inline-flex align-items-center w-100 mb-0'));
|
|
|
808 |
$output .= $endorsement->claimcomment;
|
|
|
809 |
$output .= html_writer::end_tag('p');
|
|
|
810 |
$output .= html_writer::end_tag('div');
|
|
|
811 |
|
|
|
812 |
if (!empty($endorsement->issuername) || !empty($endorsement->issueremail)) {
|
|
|
813 |
$output .= html_writer::start_tag('span', array('class' => 'alert alert-secondary d-block'));
|
|
|
814 |
$output .= $endorsement->issuername .
|
|
|
815 |
html_writer::tag('a', $endorsement->issueremail,
|
|
|
816 |
array('class' => 'ml-3'),
|
|
|
817 |
array('href' => 'mailto:' . $endorsement->issueremail))
|
|
|
818 |
. html_writer::link($endorsement->issuerurl,
|
|
|
819 |
$endorsement->issuerurl,
|
|
|
820 |
array('class' => 'ml-3'),
|
|
|
821 |
array('target' => '_blank'));
|
|
|
822 |
$output .= html_writer::end_tag('span');
|
|
|
823 |
}
|
|
|
824 |
|
|
|
825 |
$output .= html_writer::end_tag('div');
|
|
|
826 |
} else {
|
|
|
827 |
$output .= html_writer::start_tag('div', array('class' => 'ml-4'));
|
|
|
828 |
$output .= get_string('noendorsement', 'badges');
|
|
|
829 |
$output .= html_writer::end_tag('div');
|
|
|
830 |
}
|
|
|
831 |
return $output;
|
|
|
832 |
}
|
|
|
833 |
|
|
|
834 |
/**
|
|
|
835 |
* Print list badges related.
|
|
|
836 |
*
|
|
|
837 |
* @param badge $badge Badge objects.
|
|
|
838 |
* @return string $output List related badges to output.
|
|
|
839 |
*/
|
|
|
840 |
protected function print_badge_related(badge $badge) {
|
|
|
841 |
$output = '';
|
|
|
842 |
$relatedbadges = $badge->get_related_badges();
|
|
|
843 |
$output .= html_writer::start_tag('h5', array('class' => 'd-inline-flex align-items-center w-100'));
|
|
|
844 |
$output .= '<svg class="mr-2"
|
|
|
845 |
width="24"
|
|
|
846 |
height="24"
|
|
|
847 |
viewBox="0 0 24 24"
|
|
|
848 |
fill="none"
|
|
|
849 |
xmlns="http://www.w3.org/2000/svg"><path d="M17.25 10C17.25 12.8995
|
|
|
850 |
14.8995 15.25 12 15.25C9.10051 15.25 6.75 12.8995 6.75 10C6.75
|
|
|
851 |
7.10051 9.10051 4.75 12 4.75C14.8995 4.75 17.25 7.10051 17.25 10Z"
|
|
|
852 |
stroke="currentColor"
|
|
|
853 |
stroke-width="1.5"
|
|
|
854 |
stroke-linecap="round"
|
|
|
855 |
stroke-linejoin="round"></path><path d="M8.75 14.75L7.75 19.25L12
|
|
|
856 |
17.75L16.25 19.25L15.25 14.75"
|
|
|
857 |
stroke="currentColor"
|
|
|
858 |
stroke-width="1.5"
|
|
|
859 |
stroke-linecap="round"
|
|
|
860 |
stroke-linejoin="round"></path></svg>' . get_string('relatedbages', 'badges');
|
|
|
861 |
$output .= html_writer::end_tag('h5');
|
|
|
862 |
if (!empty($relatedbadges)) {
|
|
|
863 |
$items = array();
|
|
|
864 |
foreach ($relatedbadges as $related) {
|
|
|
865 |
$relatedurl = new moodle_url('/badges/overview.php', array('id' => $related->id));
|
|
|
866 |
$items[] = html_writer::link($relatedurl->out(), $related->name, array('target' => '_blank'));
|
|
|
867 |
}
|
|
|
868 |
$output .= html_writer::alist($items, array(), 'ul');
|
|
|
869 |
} else {
|
|
|
870 |
$output .= html_writer::start_tag('div', array('class' => 'ml-4'));
|
|
|
871 |
$output .= get_string('norelated', 'badges');
|
|
|
872 |
$output .= html_writer::end_tag('div');
|
|
|
873 |
}
|
|
|
874 |
return $output;
|
|
|
875 |
}
|
|
|
876 |
|
|
|
877 |
/**
|
|
|
878 |
* Print list badge alignments.
|
|
|
879 |
*
|
|
|
880 |
* @param badge $badge Badge objects.
|
|
|
881 |
* @return string $output List alignments to output.
|
|
|
882 |
*/
|
|
|
883 |
protected function print_badge_alignments(badge $badge) {
|
|
|
884 |
$output = '';
|
|
|
885 |
|
|
|
886 |
$output .= html_writer::start_tag('h5', array('class' => 'd-inline-flex align-items-center w-100'));
|
|
|
887 |
$output .= '<svg class="mr-2"
|
|
|
888 |
width="24"
|
|
|
889 |
height="24"
|
|
|
890 |
viewBox="0 0 24 24"
|
|
|
891 |
fill="none"
|
|
|
892 |
xmlns="http://www.w3.org/2000/svg"><path d="M7.75 5.75H16.25"
|
|
|
893 |
stroke="currentColor"
|
|
|
894 |
stroke-width="1.5"
|
|
|
895 |
stroke-linecap="round"
|
|
|
896 |
stroke-linejoin="round"></path><path d="M7.75 18.25H16.25"
|
|
|
897 |
stroke="currentColor"
|
|
|
898 |
stroke-width="1.5"
|
|
|
899 |
stroke-linecap="round"
|
|
|
900 |
stroke-linejoin="round"></path>
|
|
|
901 |
<path d="M4.75 12H19.25"
|
|
|
902 |
stroke="currentColor"
|
|
|
903 |
stroke-width="1.5"
|
|
|
904 |
stroke-linecap="round"
|
|
|
905 |
stroke-linejoin="round"></path></svg>' . get_string('alignment', 'badges');
|
|
|
906 |
$output .= html_writer::end_tag('h5');
|
|
|
907 |
|
|
|
908 |
$alignments = $badge->get_alignments();
|
|
|
909 |
if (!empty($alignments)) {
|
|
|
910 |
$items = array();
|
|
|
911 |
foreach ($alignments as $alignment) {
|
|
|
912 |
$urlaligment = new moodle_url(
|
|
|
913 |
'alignment.php',
|
|
|
914 |
array('id' => $badge->id, 'alignmentid' => $alignment->id)
|
|
|
915 |
);
|
|
|
916 |
$items[] = html_writer::link($urlaligment, $alignment->targetname, array('target' => '_blank'));
|
|
|
917 |
}
|
|
|
918 |
$output .= html_writer::alist($items, array('class' => 'ml-4'), 'ul');
|
|
|
919 |
} else {
|
|
|
920 |
$output .= html_writer::start_tag('div', array('class' => 'ml-4'));
|
|
|
921 |
$output .= get_string('noalignment', 'badges');
|
|
|
922 |
$output .= html_writer::end_tag('div');
|
|
|
923 |
}
|
|
|
924 |
return $output;
|
|
|
925 |
}
|
|
|
926 |
|
|
|
927 |
// Prints a badge overview infomation.
|
|
|
928 |
public function print_badge_overview($badge, $context) {
|
|
|
929 |
$languages = get_string_manager()->get_list_of_languages();
|
|
|
930 |
|
|
|
931 |
$output = '';
|
|
|
932 |
$output .= html_writer::start_tag('div', array('class' => 'mt-4'));
|
|
|
933 |
|
|
|
934 |
$output .= html_writer::start_tag('div', array('class' => 'rui-badge-overview-wrapper border rounded p-4 mt-0 mb-2 d-inline-flex flex-wrap align-items-start w-100'));
|
|
|
935 |
$output .= '<div class="border rounded p-3 mr-md-6 w-100 w-md-auto">' .
|
|
|
936 |
print_badge_image($badge, $context, 'large') .
|
|
|
937 |
'</div>';
|
|
|
938 |
|
|
|
939 |
$output .= html_writer::start_tag('div', array('class' => 'rui-badge-overview'));
|
|
|
940 |
// Badge details.
|
|
|
941 |
|
|
|
942 |
if (!empty($badge->version)) {
|
|
|
943 |
$output .= html_writer::start_tag('div', array('class' => 'pb-2 small'));
|
|
|
944 |
$output .= '<span class="mr-1 font-weight-bold">' .
|
|
|
945 |
get_string('version', 'badges') .
|
|
|
946 |
': </span>' .
|
|
|
947 |
$badge->version;
|
|
|
948 |
$output .= html_writer::end_tag('div');
|
|
|
949 |
}
|
|
|
950 |
|
|
|
951 |
if (!empty($languages[$badge->language])) {
|
|
|
952 |
$output .= html_writer::start_tag('div', array('class' => 'pb-2 small'));
|
|
|
953 |
$output .= '<span class="mr-1 font-weight-bold">' .
|
|
|
954 |
get_string('language') .
|
|
|
955 |
': </span>' .
|
|
|
956 |
$languages[$badge->language];
|
|
|
957 |
$output .= html_writer::end_tag('div');
|
|
|
958 |
}
|
|
|
959 |
|
|
|
960 |
if (!empty(userdate($badge->timecreated))) {
|
|
|
961 |
$output .= html_writer::start_tag('div', array('class' => 'pb-2 small'));
|
|
|
962 |
$output .= '<span class="mr-1 font-weight-bold">' .
|
|
|
963 |
get_string('createdon', 'search') .
|
|
|
964 |
': </span>' .
|
|
|
965 |
userdate($badge->timecreated);
|
|
|
966 |
$output .= html_writer::end_tag('div');
|
|
|
967 |
}
|
|
|
968 |
|
|
|
969 |
$output .= html_writer::start_tag('h4', array('class' => 'rui-badge-name'));
|
|
|
970 |
$output .= $badge->name;
|
|
|
971 |
$output .= html_writer::end_tag('h4');
|
|
|
972 |
|
|
|
973 |
// Issuance details if any.
|
|
|
974 |
if ($badge->can_expire()) {
|
|
|
975 |
if ($badge->expiredate) {
|
|
|
976 |
$output .= html_writer::start_tag('span', array('class' => 'rui-badge-expires-info'));
|
|
|
977 |
$output .= '<svg class="mr-2
|
|
|
978 |
width="24
|
|
|
979 |
height="24
|
|
|
980 |
fill="none
|
|
|
981 |
viewBox="0 0 24 24"><path stroke="currentColor
|
|
|
982 |
stroke-linecap="round
|
|
|
983 |
stroke-linejoin="round
|
|
|
984 |
stroke-width="1.5
|
|
|
985 |
d="M4.9522 16.3536L10.2152 5.85658C10.9531 4.38481 13.0539
|
|
|
986 |
4.3852 13.7913 5.85723L19.0495 16.3543C19.7156 17.6841
|
|
|
987 |
18.7487 19.25 17.2613 19.25H6.74007C5.25234 19.25 4.2854
|
|
|
988 |
17.6835 4.9522 16.3536Z"></path><path stroke="currentColor
|
|
|
989 |
stroke-linecap="round
|
|
|
990 |
stroke-linejoin="round
|
|
|
991 |
stroke-width="2
|
|
|
992 |
d="M12 10V12"></path><circle cx="12
|
|
|
993 |
cy="16
|
|
|
994 |
r="1
|
|
|
995 |
fill="currentColor"></circle></svg>' . get_string('expiredate', 'badges', userdate($badge->expiredate));
|
|
|
996 |
$output .= html_writer::end_tag('span');
|
|
|
997 |
} else if ($badge->expireperiod) {
|
|
|
998 |
if ($badge->expireperiod < 60) {
|
|
|
999 |
$output .= html_writer::start_tag('span', array('class' => 'rui-badge-expires-info'));
|
|
|
1000 |
$output .= get_string('expireperiods', 'badges', round($badge->expireperiod, 2));
|
|
|
1001 |
$output .= html_writer::end_tag('span');
|
|
|
1002 |
} else if ($badge->expireperiod < 60 * 60) {
|
|
|
1003 |
$output .= html_writer::start_tag('span', array('class' => 'rui-badge-expires-info'));
|
|
|
1004 |
$output .= get_string('expireperiodm', 'badges', round($badge->expireperiod / 60, 2));
|
|
|
1005 |
$output .= html_writer::end_tag('span');
|
|
|
1006 |
} else if ($badge->expireperiod < 60 * 60 * 24) {
|
|
|
1007 |
$output .= html_writer::start_tag('span', array('class' => 'rui-badge-expires-info'));
|
|
|
1008 |
$output .= get_string('expireperiodh', 'badges', round($badge->expireperiod / 60 / 60, 2));
|
|
|
1009 |
$output .= html_writer::end_tag('span');
|
|
|
1010 |
} else {
|
|
|
1011 |
$output .= html_writer::start_tag('span', array('class' => 'badge badge-danger'));
|
|
|
1012 |
$output .= get_string('expireperiod', 'badges', round($badge->expireperiod / 60 / 60 * 0.54, 2));
|
|
|
1013 |
$output .= html_writer::end_tag('span');
|
|
|
1014 |
}
|
|
|
1015 |
}
|
|
|
1016 |
} else {
|
|
|
1017 |
$output .= html_writer::start_tag('span', array('class' => 'badge badge-success'));
|
|
|
1018 |
$output .= '<span class="mr-1 font-weight-bold">' . get_string('noexpiry', 'badges') . '</span>';
|
|
|
1019 |
$output .= html_writer::end_tag('span');
|
|
|
1020 |
}
|
|
|
1021 |
|
|
|
1022 |
$output .= html_writer::start_tag('div', array('class' => 'rui-badge-desc mt-3'));
|
|
|
1023 |
|
|
|
1024 |
$output .= html_writer::start_tag('h5', array('class' => 'd-inline-flex align-items-center w-100'));
|
|
|
1025 |
$output .= get_string('description', 'badges');
|
|
|
1026 |
$output .= html_writer::end_tag('h5');
|
|
|
1027 |
|
|
|
1028 |
$output .= $badge->description;
|
|
|
1029 |
|
|
|
1030 |
$output .= html_writer::start_tag('ul', array('class' => 'rui-badge-desc-list mt-3 ml-3'));
|
|
|
1031 |
|
|
|
1032 |
if (!empty(userdate($badge->imageauthorname))) {
|
|
|
1033 |
$output .= html_writer::start_tag('li');
|
|
|
1034 |
$output .= '<span class="mr-1 font-weight-bold">' .
|
|
|
1035 |
get_string('imageauthorname', 'badges') . ': </span>' . $badge->imageauthorname;
|
|
|
1036 |
$output .= html_writer::end_tag('li');
|
|
|
1037 |
}
|
|
|
1038 |
|
|
|
1039 |
if (!empty(userdate($badge->imageauthoremail))) {
|
|
|
1040 |
$output .= html_writer::start_tag('li');
|
|
|
1041 |
$output .= '<span class="mr-1 font-weight-bold">' .
|
|
|
1042 |
get_string('imageauthoremail', 'badges') .
|
|
|
1043 |
': </span>' .
|
|
|
1044 |
html_writer::tag('a', $badge->imageauthoremail, array('href' => 'mailto:' .
|
|
|
1045 |
$badge->imageauthoremail));
|
|
|
1046 |
$output .= html_writer::end_tag('li');
|
|
|
1047 |
}
|
|
|
1048 |
if (!empty(userdate($badge->imageauthorurl))) {
|
|
|
1049 |
$output .= html_writer::start_tag('li');
|
|
|
1050 |
$output .= '<span class="mr-1 font-weight-bold">' . get_string('imageauthorurl', 'badges') .
|
|
|
1051 |
': </span>' . html_writer::link($badge->imageauthorurl, $badge->imageauthorurl, array('target' => '_blank'));
|
|
|
1052 |
$output .= html_writer::end_tag('li');
|
|
|
1053 |
}
|
|
|
1054 |
if (!empty($badge->imagecaption)) {
|
|
|
1055 |
$output .= html_writer::start_tag('li');
|
|
|
1056 |
$output .= '<span class="mr-1 font-weight-bold">' .
|
|
|
1057 |
get_string('imagecaption', 'badges') .
|
|
|
1058 |
': </span>' .
|
|
|
1059 |
$badge->imagecaption;
|
|
|
1060 |
$output .= html_writer::end_tag('li');
|
|
|
1061 |
}
|
|
|
1062 |
$output .= html_writer::end_tag('div');
|
|
|
1063 |
|
|
|
1064 |
$output .= html_writer::end_tag('div'); // End rui-badge-desc.
|
|
|
1065 |
$output .= html_writer::end_tag('div'); // End rui-badge-overview.
|
|
|
1066 |
|
|
|
1067 |
if (!empty($badge->issuername) || !empty($badge->issuercontact)) {
|
|
|
1068 |
$output .= html_writer::start_tag('span', array('class' => 'alert alert-secondary d-block'));
|
|
|
1069 |
$output .= '<span class="mr-1 font-weight-bold">' .
|
|
|
1070 |
get_string('issuername', 'badges') .
|
|
|
1071 |
': </span>' .
|
|
|
1072 |
$badge->issuername;
|
|
|
1073 |
|
|
|
1074 |
if (!empty($badge->issuername) || !empty($badge->issuercontact)) {
|
|
|
1075 |
$output .= html_writer::tag('a', $badge->issuercontact,
|
|
|
1076 |
array('href' => 'mailto:' . $badge->issuercontact));
|
|
|
1077 |
}
|
|
|
1078 |
|
|
|
1079 |
$output .= html_writer::end_tag('span');
|
|
|
1080 |
}
|
|
|
1081 |
|
|
|
1082 |
$output .= html_writer::start_tag('div', array('class' => 'wrapper-fw'));
|
|
|
1083 |
|
|
|
1084 |
// Criteria details if any.
|
|
|
1085 |
$output .= html_writer::start_tag('div', array('class' => 'rui-badge-criteria my-4'));
|
|
|
1086 |
|
|
|
1087 |
$output .= html_writer::start_tag('h5', array('class' => 'd-inline-flex align-items-center w-100'));
|
|
|
1088 |
$output .= '<svg class="mr-2"
|
|
|
1089 |
width="24"
|
|
|
1090 |
height="24"
|
|
|
1091 |
viewBox="0 0 24 24"
|
|
|
1092 |
fill="none"
|
|
|
1093 |
xmlns="http://www.w3.org/2000/svg">
|
|
|
1094 |
<path d="M10.75 13.25H6.75L13.25 4.75V10.75H17.25L10.75
|
|
|
1095 |
19.25V13.25Z"
|
|
|
1096 |
stroke="currentColor"
|
|
|
1097 |
stroke-width="1.5"
|
|
|
1098 |
stroke-linecap="round"
|
|
|
1099 |
stroke-linejoin="round"></path>
|
|
|
1100 |
</svg>' . get_string('bcriteria', 'badges');
|
|
|
1101 |
$output .= html_writer::end_tag('h5');
|
|
|
1102 |
|
|
|
1103 |
if ($badge->has_criteria()) {
|
|
|
1104 |
$output .= '<div class="ml-4">' . self::print_badge_criteria($badge) . '</div>';
|
|
|
1105 |
} else {
|
|
|
1106 |
$output .= '<p class="ml-4">' . get_string('nocriteria', 'badges') . '</p>';
|
|
|
1107 |
if (has_capability('moodle/badges:configurecriteria', $context)) {
|
|
|
1108 |
$output .= $this->output->single_button(
|
|
|
1109 |
new moodle_url('/badges/criteria.php', array('id' => $badge->id)),
|
|
|
1110 |
get_string('addcriteria', 'badges'),
|
|
|
1111 |
'POST',
|
|
|
1112 |
array('class' => 'activatebadge ml-4')
|
|
|
1113 |
);
|
|
|
1114 |
}
|
|
|
1115 |
}
|
|
|
1116 |
$output .= html_writer::end_tag('div');
|
|
|
1117 |
|
|
|
1118 |
// Awards details if any.
|
|
|
1119 |
$output .= html_writer::start_tag('div', array('class' => 'rui-badge-awards my-4'));
|
|
|
1120 |
if (has_capability('moodle/badges:viewawarded', $context)) {
|
|
|
1121 |
$output .= html_writer::start_tag('h5', array('class' => 'd-inline-flex align-items-center w-100'));
|
|
|
1122 |
$output .= '<svg class="mr-2"
|
|
|
1123 |
width="24"
|
|
|
1124 |
height="24"
|
|
|
1125 |
fill="none"
|
|
|
1126 |
viewBox="0 0 24 24"><path stroke="currentColor"
|
|
|
1127 |
stroke-linecap="round"
|
|
|
1128 |
stroke-linejoin="round"
|
|
|
1129 |
stroke-width="1.5"
|
|
|
1130 |
d="M5.78168 19.25H13.2183C13.7828 19.25 14.227 18.7817 14.1145
|
|
|
1131 |
18.2285C13.804 16.7012 12.7897 14 9.5 14C6.21031 14 5.19605
|
|
|
1132 |
16.7012 4.88549 18.2285C4.773 18.7817 5.21718 19.25 5.78168
|
|
|
1133 |
19.25Z"></path>
|
|
|
1134 |
<path stroke="currentColor"
|
|
|
1135 |
stroke-linecap="round"
|
|
|
1136 |
stroke-linejoin="round"
|
|
|
1137 |
stroke-width="1.5"
|
|
|
1138 |
d="M15.75 14C17.8288 14 18.6802 16.1479 19.0239
|
|
|
1139 |
17.696C19.2095 18.532 18.5333 19.25 17.6769
|
|
|
1140 |
19.25H16.75">
|
|
|
1141 |
</path>
|
|
|
1142 |
<circle cx="9.5"
|
|
|
1143 |
cy="7.5"
|
|
|
1144 |
r="2.75"
|
|
|
1145 |
stroke="currentColor"
|
|
|
1146 |
stroke-linecap="round"
|
|
|
1147 |
stroke-linejoin="round"
|
|
|
1148 |
stroke-width="1.5"></circle>
|
|
|
1149 |
<path stroke="currentColor"
|
|
|
1150 |
stroke-linecap="round"
|
|
|
1151 |
stroke-linejoin="round"
|
|
|
1152 |
stroke-width="1.5"
|
|
|
1153 |
d="M14.75 10.25C16.2688 10.25 17.25 9.01878 17.25
|
|
|
1154 |
7.5C17.25 5.98122 16.2688 4.75 14.75 4.75"></path>
|
|
|
1155 |
</svg>' .
|
|
|
1156 |
get_string('awards', 'badges');
|
|
|
1157 |
$output .= html_writer::end_tag('h5');
|
|
|
1158 |
|
|
|
1159 |
if ($badge->has_awards()) {
|
|
|
1160 |
$url = new moodle_url('/badges/recipients.php', array('id' => $badge->id));
|
|
|
1161 |
$a = new stdClass();
|
|
|
1162 |
$a->link = $url->out();
|
|
|
1163 |
$a->count = count($badge->get_awards());
|
|
|
1164 |
$output .= get_string('numawards', 'badges', $a);
|
|
|
1165 |
} else {
|
|
|
1166 |
$output .= html_writer::start_tag('div', array('class' => 'ml-4'));
|
|
|
1167 |
$output .= get_string('noawards', 'badges');
|
|
|
1168 |
$output .= html_writer::end_tag('div');
|
|
|
1169 |
}
|
|
|
1170 |
|
|
|
1171 |
if (
|
|
|
1172 |
has_capability('moodle/badges:awardbadge', $context) &&
|
|
|
1173 |
$badge->has_manual_award_criteria() &&
|
|
|
1174 |
$badge->is_active()
|
|
|
1175 |
) {
|
|
|
1176 |
$output .= html_writer::start_tag('div', array('class' => 'mt-3 ml-4'));
|
|
|
1177 |
$output .= $this->output->single_button(
|
|
|
1178 |
new moodle_url('/badges/award.php', array('id' => $badge->id)),
|
|
|
1179 |
get_string('award', 'badges'),
|
|
|
1180 |
'POST',
|
|
|
1181 |
array('class' => 'activatebadge ml-auto')
|
|
|
1182 |
);
|
|
|
1183 |
$output .= html_writer::end_tag('div');
|
|
|
1184 |
}
|
|
|
1185 |
}
|
|
|
1186 |
$output .= html_writer::end_tag('div');
|
|
|
1187 |
|
|
|
1188 |
$output .= html_writer::start_tag('div', array('class' => 'rui-badge-endorsement my-4'));
|
|
|
1189 |
$output .= self::print_badge_endorsement($badge);
|
|
|
1190 |
$output .= html_writer::end_tag('div');
|
|
|
1191 |
|
|
|
1192 |
$output .= html_writer::start_tag('div', array('class' => 'rui-badge-related my-4'));
|
|
|
1193 |
$output .= self::print_badge_related($badge);
|
|
|
1194 |
$output .= html_writer::end_tag('div');
|
|
|
1195 |
|
|
|
1196 |
$output .= html_writer::start_tag('div', array('class' => 'rui-badge-alignments my-4'));
|
|
|
1197 |
$output .= self::print_badge_alignments($badge);
|
|
|
1198 |
$output .= html_writer::end_tag('div');
|
|
|
1199 |
|
|
|
1200 |
$output .= html_writer::end_tag('div'); // End wrapper-fw.
|
|
|
1201 |
|
|
|
1202 |
$output .= html_writer::end_tag('div'); // End badge-ovrview-wrapper.
|
|
|
1203 |
|
|
|
1204 |
|
|
|
1205 |
return $output;
|
|
|
1206 |
}
|
|
|
1207 |
|
|
|
1208 |
/**
|
|
|
1209 |
* Renders a search form
|
|
|
1210 |
*
|
|
|
1211 |
* @param string $search Search string
|
|
|
1212 |
* @return string HTML
|
|
|
1213 |
*/
|
|
|
1214 |
protected function helper_search_form($search) {
|
|
|
1215 |
global $CFG;
|
|
|
1216 |
require_once($CFG->libdir . '/formslib.php');
|
|
|
1217 |
|
|
|
1218 |
$mform = new MoodleQuickForm('searchform', 'POST', $this->page->url);
|
|
|
1219 |
|
|
|
1220 |
$mform->addElement('hidden', 'sesskey', sesskey());
|
|
|
1221 |
|
|
|
1222 |
$el[] = $mform->createElement('text', 'search', get_string('search'), array('size' => 30));
|
|
|
1223 |
$mform->setDefault('search', $search);
|
|
|
1224 |
$el[] = $mform->createElement('submit', 'submitsearch', get_string('search'));
|
|
|
1225 |
$el[] = $mform->createElement('submit', 'clearsearch', get_string('clear'));
|
|
|
1226 |
$mform->addGroup($el, 'searchgroup', ' ', ' ', false);
|
|
|
1227 |
|
|
|
1228 |
ob_start();
|
|
|
1229 |
$mform->display();
|
|
|
1230 |
$out = ob_get_clean();
|
|
|
1231 |
|
|
|
1232 |
return $out;
|
|
|
1233 |
}
|
|
|
1234 |
}
|