diff --git a/CHANGELOG.md b/CHANGELOG.md index e01f5e4..14f53b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Change Log All notable changes to this project will be documented in this file. +## [2.0.5] dev-2020-10-12 +### Added +- categoryid parameter for {coursecards categoryid=x} tag (ALPHA). + ## [2.0.4] dev-2020-10-09 ### Added - New {ifingroup id|idnumber}{/ifingroup} tags. diff --git a/README.md b/README.md index 01d6871..c431006 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,7 @@ FilterCodes are meant to be entered as regular text in the Moodle WYSIWYG editor * {coursecompletiondate} : Course completion date. If not completed, will display "Not completed". Will also detect if completion is not enabled. * {courseprogress}: (ALPHA) Displays course progress status in words. Only works within a course. * {courseprogressbar}: (ALPHA) Displays course progress status as a status bar. Only works within a course. +* {coursecards categoryid=x}: (ALPHA) Display available courses as cards. Optional categoryid parameter to specify one or more category IDs. * {course_fields}: Displays the custom course fields. NOTE: Respects a custom course field's Visible To setting. * {course_field_shortname} : Display's custom course field. Replace "shortname" with the shortname of a custom course field all in lowercase. NOTE: Respects a custom course field's Visible To setting. * {courseimage} : Display's the course image. @@ -569,7 +570,7 @@ Create a Page on your Moodle site, preferably in a course, so that those tags wo * Completion date [{coursecompletiondate}]: {coursecompletiondate} * Course progress (ALPHA) [{courseprogress}]: {courseprogress} * Course progress bar (ALPHA) [{courseprogressbar}]: {courseprogressbar} -* Course cards (ALPHA) [{coursecards}]: {coursecards} +* Course cards (ALPHA) [{coursecards categoryid=1}]: If miscellaneous category still exists, it will be displayed: {coursecards categoryid=1} * Category cards (ALPHA) [{categorycards}]: {categorycards} * Total courses [{coursecount}]: {coursecount} * Institution [{institution}]: {institution} diff --git a/filter.php b/filter.php index 6d6e49f..31afca0 100644 --- a/filter.php +++ b/filter.php @@ -770,9 +770,9 @@ function ($matches) { $coursefiles = $course->get_course_overviewfiles(); foreach ($coursefiles as $file) { if ($isimage = $file->is_valid_image()) { - $imgurl = file_encode_url("/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() - . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename() , !$isimage); - $imgurl = new moodle_url($imgurl); + $imgurl = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), + $file->get_filearea(), null, $file->get_filepath(), + $file->get_filename())->out(false); break; } } @@ -870,62 +870,78 @@ function ($matches) { } } - if (stripos($text, '{coursecards}') !== false) { + if (stripos($text, '{coursecards') !== false) { //Only do the expensive regex if it's worth it. global $CFG, $OUTPUT; + $matches = []; - $chelper = new coursecat_helper(); - $chelper->set_show_courses(20)->set_courses_display_options(array( - 'recursive' => true, - 'limit' => $CFG->frontpagecourselimit, - 'viewmoreurl' => new moodle_url('/course/index.php'), - 'viewmoretext' => new lang_string('fulllistofcourses') - )); - - $chelper->set_attributes(array('class' => 'frontpage-course-list-all')); - $courses = core_course_category::get(0)->get_courses($chelper->get_courses_display_options()); - - $rcourseids = array_keys($courses); - - $header = '