| Línea 28... |
Línea 28... |
| 28 |
use html_writer;
|
28 |
use html_writer;
|
| 29 |
use core_course_category;
|
29 |
use core_course_category;
|
| 30 |
use coursecat_helper;
|
30 |
use coursecat_helper;
|
| 31 |
use stdClass;
|
31 |
use stdClass;
|
| 32 |
use core_course_list_element;
|
32 |
use core_course_list_element;
|
| 33 |
use single_select;
|
- |
|
| 34 |
use lang_string;
|
33 |
use lang_string;
|
| 35 |
use cm_info;
|
- |
|
| 36 |
use core_text;
|
- |
|
| 37 |
use completion_info;
|
- |
|
| 38 |
use course_handler;
|
- |
|
| 39 |
use context_course;
|
- |
|
| 40 |
use theme_universe\util\course;
|
34 |
use theme_universe\util\course;
|
| Línea 41... |
Línea 35... |
| 41 |
|
35 |
|
| 42 |
/**
|
36 |
/**
|
| 43 |
* @package theme_universe
|
37 |
* @package theme_universe
|
| 44 |
* @copyright 2023 Marcin Czaja - Rosea Themes - rosea.io
|
38 |
* @copyright 2023 Marcin Czaja - Rosea Themes - rosea.io
|
| 45 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
39 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
| 46 |
*/
|
40 |
*/
|
| 47 |
class course_renderer extends \core_course_renderer
|
- |
|
| Línea 48... |
Línea 41... |
| 48 |
{
|
41 |
class course_renderer extends \core_course_renderer {
|
| 49 |
|
42 |
|
| 50 |
/**
|
43 |
/**
|
| 51 |
* Renders html to display a course search form
|
44 |
* Renders html to display a course search form
|
| 52 |
*
|
45 |
*
|
| 53 |
* @param string $value default value to populate the search field
|
46 |
* @param string $value default value to populate the search field
|
| 54 |
* @return string
|
47 |
* @return string
|
| 55 |
*/
|
- |
|
| Línea 56... |
Línea 48... |
| 56 |
public function course_search_form($value = '')
|
48 |
*/
|
| 57 |
{
|
49 |
public function course_search_form($value = '') {
|
| 58 |
|
50 |
|
| 59 |
$data = [
|
51 |
$data = [
|
| Línea 86... |
Línea 78... |
| 86 |
*
|
78 |
*
|
| 87 |
* @throws \coding_exception
|
79 |
* @throws \coding_exception
|
| 88 |
* @throws \dml_exception
|
80 |
* @throws \dml_exception
|
| 89 |
* @throws \moodle_exception
|
81 |
* @throws \moodle_exception
|
| 90 |
*/
|
82 |
*/
|
| 91 |
protected function coursecat_courses(coursecat_helper $chelper, $courses, $totalcount = null)
|
83 |
protected function coursecat_courses(coursecat_helper $chelper, $courses, $totalcount = null) {
|
| 92 |
{
|
- |
|
| 93 |
global $CFG, $COURSE;
|
84 |
global $CFG;
|
| Línea 94... |
Línea -... |
| 94 |
|
- |
|
| Línea 95... |
Línea 85... |
| 95 |
$theme = \theme_config::load('universe');
|
85 |
|
| 96 |
|
86 |
|
| 97 |
if ($totalcount === null) {
|
87 |
if ($totalcount === null) {
|
| Línea 157... |
Línea 147... |
| 157 |
$content .= $pagingbar;
|
147 |
$content .= $pagingbar;
|
| 158 |
}
|
148 |
}
|
| Línea 159... |
Línea 149... |
| 159 |
|
149 |
|
| Línea 160... |
Línea -... |
| 160 |
$coursecount = 1;
|
- |
|
| 161 |
|
- |
|
| 162 |
if ($theme->settings->courselistview == 1) {
|
- |
|
| 163 |
$content .= html_writer::start_tag('div', array('class' => 'rui-course--list mt-2'));
|
150 |
$coursecount = 1;
|
| 164 |
} else {
|
- |
|
| Línea 165... |
Línea 151... |
| 165 |
$content .= html_writer::start_tag('div', array('class' => 'rui-course-card-deck mt-2'));
|
151 |
|
| 166 |
}
|
152 |
$content .= html_writer::start_tag('div', array('class' => 'rui-course-card-deck mt-2'));
|
| Línea 167... |
Línea 153... |
| 167 |
|
153 |
|
| Línea 184... |
Línea 170... |
| 184 |
$content .= html_writer::end_tag('div'); // End courses.
|
170 |
$content .= html_writer::end_tag('div'); // End courses.
|
| Línea 185... |
Línea 171... |
| 185 |
|
171 |
|
| 186 |
return $content;
|
172 |
return $content;
|
| Línea 187... |
Línea 173... |
| 187 |
}
|
173 |
}
|
| 188 |
|
- |
|
| 189 |
protected function coursecat_subcategories(coursecat_helper $chelper, $coursecat, $depth)
|
174 |
|
| 190 |
{
|
175 |
protected function coursecat_subcategories(coursecat_helper $chelper, $coursecat, $depth) {
|
| 191 |
global $CFG;
|
176 |
global $CFG;
|
| 192 |
$subcategories = array();
|
177 |
$subcategories = [];
|
| 193 |
if (!$chelper->get_categories_display_option('nodisplay')) {
|
178 |
if (!$chelper->get_categories_display_option('nodisplay')) {
|
| 194 |
$subcategories = $coursecat->get_children($chelper->get_categories_display_options());
|
179 |
$subcategories = $coursecat->get_children($chelper->get_categories_display_options());
|
| 195 |
}
|
180 |
}
|
| Línea 217... |
Línea 202... |
| 217 |
);
|
202 |
);
|
| 218 |
if ($paginationallowall) {
|
203 |
if ($paginationallowall) {
|
| 219 |
$pagingbar .= html_writer::tag('div', html_writer::link(
|
204 |
$pagingbar .= html_writer::tag('div', html_writer::link(
|
| 220 |
$paginationurl->out(false, array('perpage' => 'all')),
|
205 |
$paginationurl->out(false, array('perpage' => 'all')),
|
| 221 |
get_string('showall', '', $totalcount)
|
206 |
get_string('showall', '', $totalcount)
|
| 222 |
), array('class' => 'paging paging-showall'));
|
207 |
), ['class' => 'paging paging-showall']);
|
| 223 |
}
|
208 |
}
|
| 224 |
} else if ($viewmoreurl = $chelper->get_categories_display_option('viewmoreurl')) {
|
209 |
} else if ($viewmoreurl = $chelper->get_categories_display_option('viewmoreurl')) {
|
| 225 |
// The option 'viewmoreurl' was specified, display more link (if it is link to category view page, add category id).
|
210 |
// The option 'viewmoreurl' was specified, display more link (if it is link to category view page, add category id).
|
| 226 |
if ($viewmoreurl->compare(new moodle_url('/course/index.php'), URL_MATCH_BASE)) {
|
211 |
if ($viewmoreurl->compare(new moodle_url('/course/index.php'), URL_MATCH_BASE)) {
|
| 227 |
$viewmoreurl->param('categoryid', $coursecat->id);
|
212 |
$viewmoreurl->param('categoryid', $coursecat->id);
|
| Línea 275... |
Línea 260... |
| 275 |
*
|
260 |
*
|
| 276 |
* @throws \coding_exception
|
261 |
* @throws \coding_exception
|
| 277 |
* @throws \dml_exception
|
262 |
* @throws \dml_exception
|
| 278 |
* @throws \moodle_exception
|
263 |
* @throws \moodle_exception
|
| 279 |
*/
|
264 |
*/
|
| 280 |
protected function coursecat_coursebox_content(coursecat_helper $chelper, $course)
|
265 |
protected function coursecat_coursebox_content(coursecat_helper $chelper, $course) {
|
| 281 |
{
|
- |
|
| 282 |
global $DB, $COURSE, $USER;
|
- |
|
| 283 |
$theme = \theme_config::load('universe');
|
266 |
$theme = \theme_config::load('universe');
|
| Línea 284... |
Línea 267... |
| 284 |
|
267 |
|
| 285 |
if ($course instanceof stdClass) {
|
268 |
if ($course instanceof stdClass) {
|
| 286 |
$course = new core_course_list_element($course);
|
269 |
$course = new core_course_list_element($course);
|
| Línea 287... |
Línea 270... |
| 287 |
}
|
270 |
}
|
| 288 |
|
271 |
|
| 289 |
$cccteachers = $theme->settings->cccteachers;
|
272 |
$cccteachers = $theme->settings->cccteachers;
|
| - |
|
273 |
$cccsummary = $theme->settings->cccsummary;
|
| - |
|
274 |
$coursecarddesclimit = $theme->settings->coursecarddesclimit;
|
| - |
|
275 |
|
| - |
|
276 |
if ($coursecarddesclimit == null) {
|
| - |
|
277 |
$coursecarddesclimit = 100;
|
| 290 |
$cccsummary = $theme->settings->cccsummary;
|
278 |
}
|
| Línea 291... |
Línea 279... |
| 291 |
$coursecarddesclimit = $theme->settings->coursecarddesclimit;
|
279 |
|
| 292 |
$courseprogressbar = $theme->settings->courseprogressbar;
|
- |
|
| 293 |
|
280 |
$courseprogressbar = $theme->settings->courseprogressbar;
|
| - |
|
281 |
|
| - |
|
282 |
$courseutil = new course($course);
|
| - |
|
283 |
$coursecontacts = $courseutil->get_course_contacts();
|
| - |
|
284 |
$metacoursecontacts = $courseutil->get_meta_course_contacts();
|
| - |
|
285 |
$metacourselang = $courseutil->get_meta_course_lang();
|
| - |
|
286 |
|
| - |
|
287 |
$showfilter1 = ($theme->settings->showfilter1 == '1') ? true : false;
|
| - |
|
288 |
$showfilter2 = ($theme->settings->showfilter2 == '1') ? true : false;
|
| - |
|
289 |
$showfilter3 = ($theme->settings->showfilter3 == '1') ? true : false;
|
| - |
|
290 |
$showfilter4 = ($theme->settings->showfilter4 == '1') ? true : false;
|
| - |
|
291 |
$showfilter5 = ($theme->settings->showfilter5 == '1') ? true : false;
|
| - |
|
292 |
$showfilter6 = ($theme->settings->showfilter6 == '1') ? true : false;
|
| - |
|
293 |
|
| - |
|
294 |
$customfiltertitle1 = $theme->settings->customfilter1;
|
| - |
|
295 |
$customfiltertitle2 = $theme->settings->customfilter2;
|
| - |
|
296 |
$customfiltertitle3 = $theme->settings->customfilter3;
|
| - |
|
297 |
$customfiltertitle4 = $theme->settings->customfilter4;
|
| - |
|
298 |
$customfiltertitle5 = $theme->settings->customfilter5;
|
| - |
|
299 |
$customfiltertitle6 = $theme->settings->customfilter6;
|
| - |
|
300 |
|
| - |
|
301 |
$metacoursecustomfilter1 = format_string($courseutil->get_meta_course_customfilter1());
|
| - |
|
302 |
$metacoursecustomfilter2 = format_string($courseutil->get_meta_course_customfilter2());
|
| - |
|
303 |
$metacoursecustomfilter3 = format_string($courseutil->get_meta_course_customfilter3());
|
| Línea 294... |
Línea 304... |
| 294 |
$courseutil = new course($course);
|
304 |
$metacoursecustomfilter4 = format_string($courseutil->get_meta_course_customfilter4());
|
| 295 |
|
305 |
$metacoursecustomfilter5 = format_string($courseutil->get_meta_course_customfilter5());
|
| 296 |
$coursecontacts = $courseutil->get_course_contacts();
|
- |
|
| 297 |
|
306 |
$metacoursecustomfilter6 = format_string($courseutil->get_meta_course_customfilter6());
|
| 298 |
$courseenrolmenticons = $courseutil->get_enrolment_icons();
|
307 |
|
| Línea 299... |
Línea 308... |
| 299 |
$courseenrolmenticons = !empty($courseenrolmenticons) ? $this->render_enrolment_icons($courseenrolmenticons) : false;
|
308 |
$courseenrolmenticons = $courseutil->get_enrolment_icons();
|
| 300 |
|
309 |
$courseenrolmenticons = !empty($courseenrolmenticons) ? $this->render_enrolment_icons($courseenrolmenticons) : false;
|
| 301 |
$courseprogress = $courseutil->get_progress();
|
- |
|
| 302 |
$hasprogress = $courseprogress != null;
|
310 |
$courseprogress = $courseutil->get_progress();
|
| 303 |
|
311 |
$hasprogress = $courseprogress != null;
|
| 304 |
if ($theme->settings->courselangbadge == 1) {
|
312 |
|
| 305 |
$forcedlanguage = strval($course->lang);
|
313 |
if ($courseprogressbar == 0) {
|
| 306 |
} else {
|
- |
|
| 307 |
$forcedlanguage = null;
|
- |
|
| 308 |
}
|
314 |
$hasprogress = false;
|
| 309 |
|
- |
|
| 310 |
if ($theme->settings->showcustomfields == 1) {
|
315 |
$courseprogress = false;
|
| 311 |
$showcustomfields = true;
|
- |
|
| 312 |
} else {
|
316 |
}
|
| - |
|
317 |
|
| 313 |
$showcustomfields = false;
|
318 |
$forcedlanguage = ($theme->settings->courselangbadge == 1) ? strval($course->lang) : null;
|
| 314 |
}
|
319 |
$showcustomfields = ($theme->settings->showcustomfields == 1) ? true : false;
|
| 315 |
|
320 |
|
| 316 |
$lastactivityurl = null;
|
- |
|
| 317 |
$params = [
|
321 |
$coursedates = '';
|
| 318 |
'userid' => $USER->id,
|
322 |
|
| - |
|
323 |
if ($this->page->theme->settings->ipcoursedates == 1) {
|
| 319 |
'courseid' => $course->id,
|
324 |
$coursedates .= html_writer::start_div('rui-custom-field-box');
|
| 320 |
'eventname' => '\\core\\event\\course_module_viewed',
|
325 |
$coursedates .= html_writer::tag('span', get_string('startdate', 'moodle'), ['class' => 'rui-custom-field-name']);
|
| 321 |
];
|
326 |
$coursedates .= html_writer::tag('span', userdate($course->startdate, get_string('strftimedaydate', 'core_langconfig')), ['class' => 'rui-custom-field-value']);
|
| 322 |
$lastactivity = $DB->get_record_sql(
|
327 |
$coursedates .= html_writer::end_div(); // .rui-custom-field-box.
|
| 323 |
"SELECT cm.id AS cmid, cmc.module, cmc.instance
|
328 |
|
| 324 |
FROM {logstore_standard_log} l
|
329 |
// Course End date.
|
| 325 |
JOIN {course_modules} cm ON cm.id = l.contextinstanceid
|
330 |
$courseenddate = $course->enddate;
|
| 326 |
JOIN {modules} cmc ON cm.module = cmc.id
|
- |
|
| 327 |
WHERE l.userid = :userid
|
- |
|
| 328 |
AND l.courseid = :courseid
|
331 |
if ($courseenddate != '0') {
|
| 329 |
AND l.eventname = :eventname
|
- |
|
| 330 |
ORDER BY l.timecreated DESC
|
- |
|
| 331 |
LIMIT 1",
|
- |
|
| 332 |
$params
|
332 |
$coursedates .= html_writer::start_div('rui-custom-field-box');
|
| 333 |
);
|
333 |
$coursedates .= html_writer::tag('span', get_string('enddate', 'moodle'), ['class' => 'rui-custom-field-name rui-course-enddate-label']);
|
| 334 |
|
334 |
$coursedates .= html_writer::tag('span', userdate($courseenddate, get_string('strftimedaydate', 'core_langconfig')), ['class' => 'rui-course-enddate rui-custom-field-value']);
|
| 335 |
if ($lastactivity) {
|
335 |
$coursedates .= html_writer::end_div(); // .rui-custom-field-box.
|
| 336 |
$lastactivityurl = new moodle_url('/mod/' . $lastactivity->module . '/view.php', ['id' => $lastactivity->cmid]);
|
336 |
}
|
| 337 |
}
|
337 |
}
|
| 338 |
|
338 |
|
| 339 |
$data = [
|
339 |
$data = [
|
| 340 |
'id' => $course->id,
|
340 |
'id' => $course->id,
|
| 341 |
'fullname' => $chelper->get_course_formatted_name($course),
|
- |
|
| 342 |
'visible' => $course->visible,
|
341 |
'fullname' => $chelper->get_course_formatted_name($course),
|
| - |
|
342 |
'visible' => $course->visible,
|
| - |
|
343 |
'image' => $courseutil->get_summary_image(),
|
| 343 |
'image' => $courseutil->get_summary_image(),
|
344 |
'summary' => $courseutil->get_summary($chelper),
|
| 344 |
'summary' => $courseutil->get_summary($chelper),
|
345 |
'category' => $courseutil->get_category(),
|
| 345 |
'category' => $courseutil->get_category(),
|
346 |
'showcustomfields' => $showcustomfields,
|
| 346 |
'customfields' => $courseutil->course_get_taux(),
|
347 |
'customfields' => $courseutil->course_get_taux(),
|
| 347 |
'showcustomfields' => $showcustomfields,
|
348 |
'coursedates' => $coursedates,
|
| 348 |
'hasprogress' => $hasprogress,
|
349 |
'hasprogress' => $hasprogress,
|
| - |
|
350 |
'progress' => (int) $courseprogress,
|
| - |
|
351 |
'hasenrolmenticons' => $courseenrolmenticons != false,
|
| - |
|
352 |
'enrolmenticons' => $courseenrolmenticons,
|
| - |
|
353 |
'hascontacts' => !empty($coursecontacts),
|
| - |
|
354 |
'contacts' => $coursecontacts,
|
| - |
|
355 |
'metacontacts' => $metacoursecontacts,
|
| - |
|
356 |
'metalang' => $metacourselang,
|
| - |
|
357 |
'metacoursecatid' => $course->category,
|
| - |
|
358 |
'metacoursecustomfilter1' => $metacoursecustomfilter1,
|
| - |
|
359 |
'metacoursecustomfilter2' => $metacoursecustomfilter2,
|
| - |
|
360 |
'metacoursecustomfilter3' => $metacoursecustomfilter3,
|
| - |
|
361 |
'metacoursecustomfilter4' => $metacoursecustomfilter4,
|
| - |
|
362 |
'metacoursecustomfilter5' => $metacoursecustomfilter5,
|
| - |
|
363 |
'metacoursecustomfilter6' => $metacoursecustomfilter6,
|
| - |
|
364 |
'showfilter1' => $showfilter1,
|
| - |
|
365 |
'showfilter2' => $showfilter2,
|
| - |
|
366 |
'showfilter3' => $showfilter3,
|
| - |
|
367 |
'showfilter4' => $showfilter4,
|
| - |
|
368 |
'showfilter5' => $showfilter5,
|
| - |
|
369 |
'showfilter6' => $showfilter6,
|
| - |
|
370 |
'customfiltertitle1' => $customfiltertitle1,
|
| 349 |
'progress' => (int) $courseprogress,
|
371 |
'customfiltertitle2' => $customfiltertitle2,
|
| 350 |
'hasenrolmenticons' => $courseenrolmenticons != false,
|
372 |
'customfiltertitle3' => $customfiltertitle3,
|
| 351 |
'enrolmenticons' => $courseenrolmenticons,
|
373 |
'customfiltertitle4' => $customfiltertitle4,
|
| 352 |
'hascontacts' => !empty($coursecontacts),
|
374 |
'customfiltertitle5' => $customfiltertitle5,
|
| 353 |
'contacts' => $coursecontacts,
|
375 |
'customfiltertitle6' => $customfiltertitle6,
|
| 354 |
'courseprogressbar' => $courseprogressbar,
|
- |
|
| 355 |
'cccteachers' => $cccteachers,
|
376 |
'courseprogressbar' => $courseprogressbar,
|
| Línea 356... |
Línea -... |
| 356 |
'cccsummary' => $cccsummary,
|
- |
|
| 357 |
'coursecarddesclimit' => $coursecarddesclimit,
|
- |
|
| 358 |
'forcedlanguage' => $forcedlanguage,
|
- |
|
| 359 |
'lastactivityurl' => $lastactivityurl,
|
377 |
'cccteachers' => $cccteachers,
|
| 360 |
];
|
- |
|
| 361 |
|
378 |
'cccsummary' => $cccsummary,
|
| Línea 362... |
Línea 379... |
| 362 |
if ($theme->settings->courselistview == 1) {
|
379 |
'coursecarddesclimit' => $coursecarddesclimit,
|
| 363 |
return $this->render_from_template('theme_universe/custom_courselist', $data);
|
380 |
'forcedlanguage' => $forcedlanguage
|
| 364 |
} else {
|
381 |
];
|
| Línea 376... |
Línea 393... |
| 376 |
* @param core_course_list_element|stdClass $course
|
393 |
* @param core_course_list_element|stdClass $course
|
| 377 |
* @param string $additionalclasses additional classes to add to the main <div> tag (usually
|
394 |
* @param string $additionalclasses additional classes to add to the main <div> tag (usually
|
| 378 |
* depend on the course position in list - first/last/even/odd)
|
395 |
* depend on the course position in list - first/last/even/odd)
|
| 379 |
* @return string
|
396 |
* @return string
|
| 380 |
*/
|
397 |
*/
|
| 381 |
protected function coursecat_coursebox(coursecat_helper $chelper, $course, $additionalclasses = '')
|
398 |
protected function coursecat_coursebox(coursecat_helper $chelper, $course, $additionalclasses = '') {
|
| 382 |
{
|
- |
|
| 383 |
if (!isset($this->strings->summary)) {
|
399 |
if (!isset($this->strings->summary)) {
|
| 384 |
$this->strings->summary = get_string('summary');
|
400 |
$this->strings->summary = get_string('summary');
|
| 385 |
}
|
401 |
}
|
| Línea 386... |
Línea 402... |
| 386 |
|
402 |
|
| Línea 400... |
Línea 416... |
| 400 |
*
|
416 |
*
|
| 401 |
* @param coursecat_helper $chelper various display options
|
417 |
* @param coursecat_helper $chelper various display options
|
| 402 |
* @param core_course_category $coursecat top category (this category's name and description will NOT be added to the tree)
|
418 |
* @param core_course_category $coursecat top category (this category's name and description will NOT be added to the tree)
|
| 403 |
* @return string
|
419 |
* @return string
|
| 404 |
*/
|
420 |
*/
|
| 405 |
protected function coursecat_tree(coursecat_helper $chelper, $coursecat)
|
421 |
protected function coursecat_tree(coursecat_helper $chelper, $coursecat) {
|
| 406 |
{
|
- |
|
| 407 |
// Reset the category expanded flag for this course category tree first.
|
422 |
// // Reset the category expanded flag for this course category tree first.
|
| 408 |
$this->categoryexpandedonload = false;
|
423 |
// $this->categoryexpandedonload = false;
|
| 409 |
$categorycontent = $this->coursecat_category_content($chelper, $coursecat, 1);
|
424 |
$categorycontent = $this->coursecat_category_content($chelper, $coursecat, 0);
|
| 410 |
if (empty($categorycontent)) {
|
425 |
if (empty($categorycontent)) {
|
| 411 |
return '';
|
426 |
return '';
|
| 412 |
}
|
427 |
}
|
| Línea 413... |
Línea 428... |
| 413 |
|
428 |
|
| 414 |
// Start content generation.
|
429 |
// Start content generation.
|
| 415 |
$content = '';
|
430 |
$content = '';
|
| 416 |
$attributes = $chelper->get_and_erase_attributes('course_category_tree clearfix');
|
- |
|
| 417 |
$content .= html_writer::start_tag('div', $attributes);
|
- |
|
| 418 |
|
- |
|
| 419 |
if ($coursecat->get_children_count()) {
|
- |
|
| 420 |
$classes = array(
|
- |
|
| 421 |
'collapseexpand',
|
- |
|
| 422 |
'aabtn'
|
- |
|
| 423 |
);
|
- |
|
| 424 |
|
- |
|
| 425 |
// Check if the category content contains subcategories with children's content loaded.
|
- |
|
| 426 |
if ($this->categoryexpandedonload) {
|
- |
|
| 427 |
$classes[] = 'collapse-all';
|
- |
|
| 428 |
$linkname = get_string('collapseall');
|
- |
|
| 429 |
} else {
|
- |
|
| 430 |
$linkname = get_string('expandall');
|
- |
|
| 431 |
}
|
- |
|
| 432 |
|
- |
|
| 433 |
// Only show the collapse/expand if there are children to expand.
|
- |
|
| 434 |
$content .= html_writer::start_tag('div', array('class' => 'wrapper-fw collapsible-actions position-relative'));
|
- |
|
| 435 |
$content .= html_writer::link('#', $linkname, array('class' => implode(' ', $classes)));
|
- |
|
| 436 |
$content .= html_writer::end_tag('div');
|
- |
|
| 437 |
$this->page->requires->strings_for_js(array('collapseall', 'expandall'), 'moodle');
|
- |
|
| 438 |
}
|
- |
|
| 439 |
|
- |
|
| Línea -... |
Línea 431... |
| - |
|
431 |
$attributes = $chelper->get_and_erase_attributes('course_category_tree clearfix');
|
| - |
|
432 |
|
| 440 |
$content .= html_writer::tag('div', $categorycontent, array('class' => 'content'));
|
433 |
$content .= html_writer::start_tag('div', $attributes);
|
| Línea 441... |
Línea 434... |
| 441 |
|
434 |
$content .= html_writer::tag('div', $categorycontent, ['class' => 'content']);
|
| 442 |
$content .= html_writer::end_tag('div'); // End course_category_tree.
|
435 |
$content .= html_writer::end_tag('div'); // End course_category_tree.
|
| Línea 453... |
Línea 446... |
| 453 |
* @param coursecat_helper $chelper various display options
|
446 |
* @param coursecat_helper $chelper various display options
|
| 454 |
* @param core_course_category $coursecat
|
447 |
* @param core_course_category $coursecat
|
| 455 |
* @param int $depth depth of this category in the current tree
|
448 |
* @param int $depth depth of this category in the current tree
|
| 456 |
* @return string
|
449 |
* @return string
|
| 457 |
*/
|
450 |
*/
|
| 458 |
protected function coursecat_category(coursecat_helper $chelper, $coursecat, $depth)
|
451 |
protected function coursecat_category(coursecat_helper $chelper, $coursecat, $depth) {
|
| - |
|
452 |
global $DB, $CFG;
|
| 459 |
{
|
453 |
|
| 460 |
// Open category tag.
|
454 |
// Open category tag.
|
| 461 |
$classes = array('category');
|
455 |
$classes = ['category'];
|
| 462 |
if (empty($coursecat->visible)) {
|
456 |
if (empty($coursecat->visible)) {
|
| 463 |
$classes[] = 'dimmed_category';
|
457 |
$classes[] = 'dimmed_category';
|
| 464 |
}
|
458 |
}
|
| 465 |
if ($chelper->get_subcat_depth() > 0 && $depth >= $chelper->get_subcat_depth()) {
|
- |
|
| 466 |
// Do not load content.
|
- |
|
| - |
|
459 |
|
| 467 |
$categorycontent = '';
|
460 |
$categorycontent = '';
|
| 468 |
$classes[] = 'notloaded';
|
- |
|
| 469 |
if (
|
- |
|
| 470 |
$coursecat->get_children_count() ||
|
- |
|
| 471 |
($chelper->get_show_courses() >= self::COURSECAT_SHOW_COURSES_COLLAPSED && $coursecat->get_courses_count())
|
- |
|
| 472 |
) {
|
- |
|
| 473 |
$classes[] = 'with_children';
|
- |
|
| 474 |
$classes[] = 'collapsed';
|
- |
|
| 475 |
}
|
- |
|
| 476 |
} else {
|
- |
|
| 477 |
// Load category content.
|
- |
|
| 478 |
$categorycontent = $this->coursecat_category_content($chelper, $coursecat, $depth);
|
- |
|
| 479 |
$classes[] = 'loaded';
|
- |
|
| 480 |
if (!empty($categorycontent)) {
|
- |
|
| 481 |
$classes[] = 'with_children';
|
- |
|
| 482 |
// Category content loaded with children.
|
- |
|
| 483 |
$this->categoryexpandedonload = true;
|
- |
|
| 484 |
}
|
- |
|
| 485 |
}
|
- |
|
| Línea 486... |
Línea 461... |
| 486 |
|
461 |
|
| 487 |
// Make sure JS file to expand category content is included.
|
- |
|
| Línea 488... |
Línea 462... |
| 488 |
$this->coursecat_include_js();
|
462 |
// Make sure JS file to expand category content is included.
|
| 489 |
|
463 |
|
| 490 |
$content = html_writer::start_tag('div', array(
|
464 |
$content = html_writer::start_tag('div', [
|
| 491 |
'class' => join(' ', $classes),
|
465 |
'class' => join(' ', $classes),
|
| 492 |
'data-categoryid' => $coursecat->id,
|
466 |
'data-categoryid' => $coursecat->id,
|
| 493 |
'data-depth' => $depth,
|
467 |
'data-depth' => $depth,
|
| 494 |
'data-showcourses' => $chelper->get_show_courses(),
|
468 |
// 'data-showcourses' => $chelper->get_show_courses(),
|
| - |
|
469 |
// 'data-type' => self::COURSECAT_TYPE_CATEGORY,
|
| - |
|
470 |
]);
|
| - |
|
471 |
|
| - |
|
472 |
// Number of courses.
|
| - |
|
473 |
$a = $coursecat->get_courses_count();
|
| - |
|
474 |
$b = $coursecat->get_children_count();
|
| Línea 495... |
Línea 475... |
| 495 |
'data-type' => self::COURSECAT_TYPE_CATEGORY,
|
475 |
$coursesum = $a + $b;
|
| 496 |
));
|
476 |
// End.
|
| 497 |
|
477 |
|
| 498 |
// Category name.
|
478 |
// Category name.
|
| 499 |
$categoryname = html_writer::link(
|
479 |
$categoryname = html_writer::link(
|
| 500 |
new moodle_url(
|
480 |
new moodle_url(
|
| 501 |
'/course/index.php',
|
481 |
'/course/index.php',
|
| 502 |
array('categoryid' => $coursecat->id)
|
482 |
['categoryid' => $coursecat->id]
|
| 503 |
),
|
483 |
),
|
| Línea 504... |
Línea -... |
| 504 |
$coursecat->get_formatted_name(),
|
- |
|
| 505 |
array('class' => 'rui-category-link')
|
- |
|
| 506 |
);
|
- |
|
| 507 |
|
- |
|
| 508 |
$icon = '<svg class="mr-1" width="18" height="18" fill="none" viewBox="0 0 24 24">
|
- |
|
| 509 |
<path stroke="currentColor"
|
- |
|
| 510 |
stroke-linecap="round"
|
- |
|
| 511 |
stroke-linejoin="round"
|
- |
|
| 512 |
stroke-width="2"
|
- |
|
| 513 |
d="M19.25 5.75C19.25 5.19772 18.8023 4.75 18.25 4.75H14C12.8954 4.75
|
- |
|
| 514 |
12 5.64543 12 6.75V19.25L12.8284 18.4216C13.5786 17.6714 14.596 17.25 15.6569
|
- |
|
| 515 |
17.25H18.25C18.8023 17.25 19.25 16.8023 19.25 16.25V5.75Z"></path>
|
- |
|
| 516 |
<path stroke="currentColor"
|
- |
|
| 517 |
stroke-linecap="round"
|
- |
|
| 518 |
stroke-linejoin="round"
|
- |
|
| 519 |
stroke-width="2"
|
- |
|
| 520 |
d="M4.75 5.75C4.75 5.19772 5.19772 4.75 5.75 4.75H10C11.1046 4.75 12
|
484 |
$coursecat->get_formatted_name(),
|
| Línea 521... |
Línea 485... |
| 521 |
5.64543 12 6.75V19.25L11.1716 18.4216C10.4214
|
485 |
['class' => 'rui-category-link text-decoration-none']
|
| 522 |
17.6714 9.40401 17.25 8.34315 17.25H5.75C5.19772 17.25 4.75 16.8023
|
486 |
);
|
| 523 |
4.75 16.25V5.75Z"></path>
|
487 |
|
| Línea -... |
Línea 488... |
| - |
|
488 |
$html = null;
|
| 524 |
</svg>';
|
489 |
|
| Línea 525... |
Línea -... |
| 525 |
|
- |
|
| 526 |
$a = $coursecat->get_courses_count();
|
- |
|
| 527 |
$b = $coursecat->get_children_count();
|
490 |
// Path for links.
|
| 528 |
$coursesum = $a + $b;
|
- |
|
| 529 |
|
- |
|
| 530 |
$coursescount = $icon . $coursesum;
|
- |
|
| 531 |
|
- |
|
| 532 |
$content .= html_writer::start_tag('div', array('class' => 'wrapper-fw info'));
|
- |
|
| 533 |
$content .= html_writer::start_tag('h5', array('class' => 'categoryname aabtn'));
|
- |
|
| 534 |
$content .= $categoryname;
|
- |
|
| 535 |
$acontent = '';
|
- |
|
| 536 |
if ($viewmoreurl = $chelper->get_courses_display_option('viewmoreurl')) {
|
- |
|
| 537 |
// The option for 'View more' link was specified, display more link.
|
- |
|
| 538 |
$viewmoretext = $chelper->get_courses_display_option('viewmoretext', new \lang_string('viewmore'));
|
491 |
$siteurl = $CFG->wwwroot;
|
| 539 |
// The option 'viewmoreurl' was specified, display more link (if it is link to category view page, add category id).
|
492 |
$catpath = "/course/index.php?categoryid=";
|
| 540 |
if ($viewmoreurl->compare(new moodle_url('/course/index.php'), URL_MATCH_BASE)) {
|
- |
|
| 541 |
$viewmoreurl->param('categoryid', $coursecat->id);
|
- |
|
| 542 |
}
|
493 |
|
| 543 |
$acontent .= html_writer::tag('div', html_writer::link(
|
- |
|
| Línea -... |
Línea 494... |
| - |
|
494 |
// // DB: List all records.
|
| 544 |
$viewmoreurl,
|
495 |
// $records = $DB->get_records('course_categories');
|
| Línea -... |
Línea 496... |
| - |
|
496 |
|
| - |
|
497 |
// // List of all categories.
|
| 545 |
$viewmoretext,
|
498 |
// foreach ($records as $value) {
|
| - |
|
499 |
// $caturl = "{$siteurl}{$catpath}{$value->id}";
|
| Línea 546... |
Línea 500... |
| 546 |
array('class' => 'btn btn-sm btn-light ml-2')
|
500 |
// $classcatdepth = "rui-subcat-badge categories-depth-{$value->depth}";
|
| 547 |
));
|
- |
|
| 548 |
}
|
- |
|
| 549 |
$content .= '<div class="rui-number-of-courses d-inline-flex">' .
|
- |
|
| Línea 550... |
Línea 501... |
| 550 |
html_writer::tag('span', $coursescount, array('class' => 'badge badge-sq badge-primary')) . $acontent . '</div>';
|
501 |
|
| 551 |
|
- |
|
| 552 |
$content .= html_writer::end_tag('h5');
|
- |
|
| Línea 553... |
Línea -... |
| 553 |
|
- |
|
| 554 |
$content .= html_writer::end_tag('div'); // End .info.
|
502 |
// $attributes = ['class' => $classcatdepth];
|
| 555 |
|
- |
|
| 556 |
// Add category content to the output.
|
503 |
// $catname = $value->name;
|
| 557 |
$content .= html_writer::tag('div', $categorycontent, array('class' => 'content'));
|
504 |
|
| 558 |
|
- |
|
| 559 |
$content .= html_writer::end_tag('div'); // End .category.
|
505 |
// // Depth.
|
| 560 |
|
- |
|
| 561 |
// Return the course category tree HTML.
|
- |
|
| 562 |
return $content;
|
- |
|
| 563 |
}
|
- |
|
| Línea 564... |
Línea -... |
| 564 |
|
- |
|
| 565 |
/**
|
506 |
// if ($value->parent > 0 && $value->parent == $coursecat->id) {
|
| 566 |
* Returns the first course's summary issue
|
507 |
// $html .= html_writer::link($caturl, $catname, $attributes);
|
| 567 |
*
|
508 |
// }
|
| 568 |
* @param \core_course_list_element $course
|
- |
|
| 569 |
* @param string $courselink
|
509 |
|
| 570 |
*
|
- |
|
| 571 |
* @return string
|
510 |
// }
|
| 572 |
*/
|
511 |
|
| 573 |
public static function get_course_summary_image($course, $courselink)
|
- |
|
| 574 |
{
|
512 |
$content .= html_writer::start_tag('div', ['class' => 'rui-categorybox-wrapper']);
|
| 575 |
global $CFG;
|
- |
|
| 576 |
|
- |
|
| 577 |
$contentimage = '';
|
513 |
|
| 578 |
foreach ($course->get_course_overviewfiles() as $file) {
|
- |
|
| 579 |
$isimage = $file->is_valid_image();
|
514 |
// Category Title.
|
| - |
|
515 |
$content .= html_writer::start_tag('h3', ['class' => 'rui-categoryname aabtn']);
|
| Línea -... |
Línea 516... |
| - |
|
516 |
$content .= $categoryname;
|
| - |
|
517 |
$content .= html_writer::end_tag('h3');
|
| - |
|
518 |
|
| - |
|
519 |
$content .= html_writer::start_tag('h5', ['class' => 'rui-no-courses-title']);
|
| - |
|
520 |
switch ($coursesum) {
|
| 580 |
$url = moodle_url::make_file_url(
|
521 |
case '1':
|
| 581 |
"$CFG->wwwroot/pluginfile.php",
|
522 |
$content .= $coursesum . ' ' . get_string('course', 'moodle');
|
| - |
|
523 |
break;
|
| 582 |
'/' . $file->get_contextid() . '/' . $file->get_component() . '/' .
|
524 |
default:
|
| Línea -... |
Línea 525... |
| - |
|
525 |
$content .= $coursesum . ' ' . get_string('courses', 'moodle');
|
| - |
|
526 |
break;
|
| - |
|
527 |
}
|
| - |
|
528 |
$content .= html_writer::end_tag('h5');
|
| - |
|
529 |
|
| - |
|
530 |
|
| 583 |
$file->get_filearea() . $file->get_filepath() . $file->get_filename(),
|
531 |
// Category desc.
|
| 584 |
!$isimage
|
532 |
// $content .= $chelper->get_category_formatted_description($coursecat);
|
| Línea 585... |
Línea 533... |
| 585 |
);
|
533 |
$content .= html_writer::end_tag('div'); // End .rui-categorybox-wrapper.
|
| 586 |
if ($isimage) {
|
534 |
|
| 587 |
$contentimage .= '<a href="' . $courselink . '">
|
535 |
// Display subcategories if exists.
|
| 588 |
<figure class="rui-course-card-img-top" style="background-image: url(' . $url . ');"></figure>
|
536 |
if($html != null) {
|
| 589 |
</a>';
|
537 |
$content .= html_writer::tag('div', $html, ['class' => 'rui-category-box-subcat']);
|
| 590 |
break;
|
538 |
}
|
| 591 |
}
|
539 |
|
| 592 |
}
|
540 |
// Add category content to the output.
|
| 593 |
|
- |
|
| 594 |
if (empty($contentimage)) {
|
541 |
$content .= html_writer::tag('div', $categorycontent, ['class' => 'rui-categorybox-wrapper']);
|
| Línea 595... |
Línea 542... |
| 595 |
$contentimage = '';
|
542 |
|
| 596 |
}
|
543 |
$content .= html_writer::end_tag('div'); // End .category.
|
| 597 |
|
544 |
|
| Línea 598... |
Línea 545... |
| 598 |
return $contentimage;
|
545 |
// Return the course category tree HTML.
|
| 599 |
}
|
546 |
return $content;
|
| - |
|
547 |
}
|
| 600 |
|
548 |
|