Skip to content

Commit

Permalink
Course cards now include visible cards without an end date.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-milette committed Oct 23, 2023
1 parent c0750f4 commit 5312a60
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Change Log
All notable changes to this project will be documented in this file.

## [2.4.0] 2023-10-22
## [2.4.1] 2023-10-23
### Added
- New %7Bwwwroot%7D - alias for the {wwwroot} tag.
### Updated
- Fixed: {coursecard}, {coursecards}, {mycoursescards} and {coursecardsbyenrol} now include visible courses without an end date.
- Fixed a failed PHPUnit test for {coursemoduleid}.
- Fix spacing for some failed CSS code checks.
- Tested compatible with PHP 8.2.
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,16 @@ FilterCodes are meant to be entered as regular text in the Moodle WYSIWYG editor
### UI Elements

* {teamcards} : Displays photos, names (optionally linked) and optional descriptions of the users who are teachers. Only Verbose format is suitable for use in a side block.
* (ALPHA) {coursecards} or {coursecards categoryID} : Display available courses as cards. You can optionally specify the ID number of a category. Example: {coursecards 1} will only display courses in the default Miscellaneous category. Note: The categoryID is not the "Category ID Number" field that you can optionally specify when creating a category. The maximum number of courses displayed is controlled by the front page setting called **frontpagecourselimit**. You can change the layout from vertical cards to horizontal cards or a table list using the Course Cards Layout setting in the FilterCodes settings.
* (ALPHA) {coursecard ids} : Display specific course cards by specifying a list of one or more course ids separated by a space. Example: {coursecard 20 43 104} will display 3 course cards assuming they exist. Courses that have their visibility set to Hidden or that have an expired end-date will only be visible to those who have the capability to see hidden courses (e.g. Site Administrator or Manager role). The maximum number of courses displayed is controlled by the front page setting called **frontpagecourselimit**. You can change the layout from vertical cards to horizontal cards or a table list using the Course Cards Layout setting in the FilterCodes settings.
* (ALPHA) {coursecardsbyenrol} : Display course cards for the most popular courses based on enrolment. The maximum number of cards is configurable in the plugin settings. You can change the layout from vertical cards to horizontal cards or a table list using the Course Cards Layout setting in the FilterCodes settings.
* (ALPHA) {coursecards} or {coursecards categoryID} : Display available courses as cards. You can optionally specify the ID number of a category. Example: {coursecards 1} will only display courses in the default Miscellaneous category. Note: The categoryID is not the "Category ID Number" field that you can optionally specify when creating a category. The maximum number of courses displayed is controlled by the front page setting called **frontpagecourselimit**. You can change the layout from vertical cards to horizontal cards or a table list using the Course Cards Layout setting in the FilterCodes settings. Course will be displayed if its visibility is set to Show AND (either has no end date OR a future end date). Courses not visible will be still visible to site admins or users with viewhiddencourses capability.
* (ALPHA) {coursecard ids} : Display specific course cards by specifying a list of one or more course ids separated by a space. Example: {coursecard 20 43 104} will display 3 course cards assuming they exist. Courses that have their visibility set to Hidden or that have an expired end-date will only be visible to those who have the capability to see hidden courses (e.g. Site Administrator or Manager role). The maximum number of courses displayed is controlled by the front page setting called **frontpagecourselimit**. You can change the layout from vertical cards to horizontal cards or a table list using the Course Cards Layout setting in the FilterCodes settings. Course will be displayed if its visibility is set to Show AND (either has no end date OR a future end date). Courses not visible will be still visible to site admins or users with viewhiddencourses capability.
* (ALPHA) {coursecardsbyenrol} : Display course cards for the most popular courses based on enrolment. The maximum number of cards is configurable in the plugin settings. You can change the layout from vertical cards to horizontal cards or a table list using the Course Cards Layout setting in the FilterCodes settings. Course will be displayed if its visibility is set to Show AND (either has no end date OR a future end date). Courses not visible will be still visible to site admins or users with viewhiddencourses capability.
* (ALPHA) {courseprogress} : Displays course progress status in words. Only works within a course.
* {courseprogresspercent} : Displays course progress percentage as a number without a percentage symbol. Only works within a course.
* (ALPHA) {courseprogressbar}: Displays course progress status as a status bar. Only works within a course.
* (ALPHA) {categorycards} or {categorycards id} : Display top-level categories as cards using the current category as the top-level category. For example, on the Frontpage, it will display all top-level categories. However, if you are inside the Miscellaneous category (e.g., in Miscellaneous > Your Course), it will only display the next level of categories under the Miscellaneous category. You can optionally specify a category in the tag.
* {mycourses} : Display an unordered list of links to all my enrolled courses. Note that there is a FilterCodes setting to determine whether this list includes completed courses.
* {myccourses} : Display an unordered list of links to all my **completed** courses. Only includes courses in which course completion has been configured and enabled.
* {mycoursescards[ categoryID(s)]} : Displays a series of cards for my enrolled courses. You may optionally specify one or more category IDs separated by a space. You can change the layout from vertical cards to horizontal cards or a table list using the **Course Cards Layout** setting in the FilterCodes settings. A message indicating that you are not logged-in will be displayed if you are not logged in.
* {mycoursescards[ categoryID(s)]} : Displays a series of cards for my enrolled courses. You may optionally specify one or more category IDs separated by a space. You can change the layout from vertical cards to horizontal cards or a table list using the **Course Cards Layout** setting in the FilterCodes settings. A message indicating that you are not logged-in will be displayed if you are not logged in. Course will be displayed if its visibility is set to Show AND (either has no end date OR a future end date). Courses not visible will be still visible to site admins or users with viewhiddencourses capability.
* {courserequest} : Displays a Request a Course link.
* {label type}{/label} : Display text over background colour. The Boost theme supports the following types: **info**, **important**, **secondary**, **success** and **warning**. Other themes may also support **primary**, **danger**, **light**, **dark** and more. Example: {label info}For your information{/label}. Actual foreground and background colours vary depending on the theme. If the type is not specified, it will default to **info**. If the type specified is not supported by your theme, it may default to secondary.
* {button URL}Label{/button} : Create a clickable button link formatted like a primary button.
Expand Down
10 changes: 6 additions & 4 deletions filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ private function rendercategorycard($category, $categoryshowpic) {
}

/**
* Render course cards for list of course ids.
* Render course cards for list of course ids. Not visible for hidden courses or if it has expired.
*
* @param array $rcourseids Array of course ids.
* @param string $format orientation/layout of course cards.
Expand All @@ -487,9 +487,11 @@ private function rendercoursecards($rcourseids, $format = 'vertical') {
}
$course = get_course($courseid);
$context = context_course::instance($course->id);
// Skip if the course is not visible to user or course is site.
$visible = ($course->visible && !empty($course->enddate) && time() < $course->enddate);
// Course will be displayed if its visibility is set to Show AND (either has no end date OR a future end date).
$visible = ($course->visible && (empty($course->enddate) || time() < $course->enddate));
// Courses not visible will be still visible to site admins or users with viewhiddencourses capability.
if (!$visible && !($isadmin || has_capability('moodle/course:viewhiddencourses', $context))) {
// Skip if the course is not visible to user or course is the "site".
continue;
}

Expand Down Expand Up @@ -2591,7 +2593,7 @@ function ($matches) use ($datecreated) {
$chelper->set_attributes(['class' => 'frontpage-course-list-all']);
// Find all coursecards tags where category ID was specified.
preg_match_all('/\{coursecards ([0-9]+)\}/', $text, $matches);
// Check if tag with no cateogry.
// Check if tag with no category.
$nocat = (stripos($text, '{coursecards}') !== false);
if ($nocat) {
$matches[1][] = 0;
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2023102200; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2023102300; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2014051200; // Requires Moodle version 2.7 or later.
$plugin->component = 'filter_filtercodes'; // Full name of the plugin (used for diagnostics).
$plugin->release = '2.4.0';
$plugin->release = '2.4.1';
$plugin->maturity = MATURITY_STABLE;

0 comments on commit 5312a60

Please sign in to comment.