From 1606fb681259acba42d30feb41e95b21863e194b Mon Sep 17 00:00:00 2001 From: Stefan Topfstedt Date: Wed, 22 May 2019 15:07:02 -0700 Subject: [PATCH] MDL-65621 block_myoverview: tag courses as "hidden from students" This is intended to visually separate hidden course from open courses in the course overview block by applying a "Hidden from students" tag to the various views in this block. To achive this, the course summary exporter's output must be augmented with a "visiblity" attribute, carrying the given course's corresponding visibility setting. Since the exporter now expects this data point as part of its input, the output of the course_get_recent_courses() function had to also be augmented with the course visibility setting to provide this value. --- blocks/myoverview/templates/view-cards.mustache | 3 ++- blocks/myoverview/templates/view-list.mustache | 8 +++++++- blocks/myoverview/templates/view-summary.mustache | 8 +++++++- course/classes/external/course_summary_exporter.php | 3 +++ course/lib.php | 2 +- course/templates/coursecard.mustache | 8 +++++++- 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/blocks/myoverview/templates/view-cards.mustache b/blocks/myoverview/templates/view-cards.mustache index 0a995fd9933..d3527fff946 100644 --- a/blocks/myoverview/templates/view-cards.mustache +++ b/blocks/myoverview/templates/view-cards.mustache @@ -29,7 +29,8 @@ "fullname": "course 3", "hasprogress": true, "progress": 10, - "coursecategory": "Miscellaneous" + "coursecategory": "Miscellaneous", + "visible": true } ] } diff --git a/blocks/myoverview/templates/view-list.mustache b/blocks/myoverview/templates/view-list.mustache index ab98fcb1e54..37992f044f5 100644 --- a/blocks/myoverview/templates/view-list.mustache +++ b/blocks/myoverview/templates/view-list.mustache @@ -29,7 +29,8 @@ "fullname": "course 3", "hasprogress": true, "progress": 10, - "coursecategory": "Miscellaneous" + "coursecategory": "Miscellaneous", + "visible": true } ] } @@ -65,6 +66,11 @@ {{{fullname}}} + {{^visible}} +
+ {{#str}} hiddenfromstudents {{/str}} +
+ {{/visible}} {{#hasprogress}} diff --git a/blocks/myoverview/templates/view-summary.mustache b/blocks/myoverview/templates/view-summary.mustache index a57c6906251..c53cc32fa8c 100644 --- a/blocks/myoverview/templates/view-summary.mustache +++ b/blocks/myoverview/templates/view-summary.mustache @@ -30,7 +30,8 @@ "summary": "This course is about assignments", "hasprogress": true, "progress": 10, - "coursecategory": "Miscellaneous" + "coursecategory": "Miscellaneous", + "visible": true } ] } @@ -75,6 +76,11 @@ {{> block_myoverview/course-action-menu }} + {{^visible}} +
+ {{#str}} hiddenfromstudents {{/str}} +
+ {{/visible}}
{{#str}}aria:coursesummary, block_myoverview{{/str}} {{{summary}}} diff --git a/course/classes/external/course_summary_exporter.php b/course/classes/external/course_summary_exporter.php index 566af235f79..65471f7298d 100644 --- a/course/classes/external/course_summary_exporter.php +++ b/course/classes/external/course_summary_exporter.php @@ -105,6 +105,9 @@ class course_summary_exporter extends \core\external\exporter { ), 'enddate' => array( 'type' => PARAM_INT, + ), + 'visible' => array( + 'type' => PARAM_BOOL, ) ); } diff --git a/course/lib.php b/course/lib.php index 52432a46bb3..d044be06b44 100644 --- a/course/lib.php +++ b/course/lib.php @@ -4593,7 +4593,7 @@ function course_get_recent_courses(int $userid = null, int $limit = 0, int $offs } $basefields = array('id', 'idnumber', 'summary', 'summaryformat', 'startdate', 'enddate', 'category', - 'shortname', 'fullname', 'timeaccess', 'component'); + 'shortname', 'fullname', 'timeaccess', 'component', 'visible'); $sort = trim($sort); if (empty($sort)) { diff --git a/course/templates/coursecard.mustache b/course/templates/coursecard.mustache index 2d45db27414..74300b9fb6c 100644 --- a/course/templates/coursecard.mustache +++ b/course/templates/coursecard.mustache @@ -28,7 +28,8 @@ "courseimage": "https://moodlesite/pluginfile/123/course/overviewfiles/123.jpg", "fullname": "course 3", "hasprogress": true, - "progress": 10 + "progress": 10, + "visible": true } ] } @@ -63,6 +64,11 @@ {{$coursename}}{{/coursename}} + {{^visible}} +
+ {{#str}} hiddenfromstudents {{/str}} +
+ {{/visible}}
{{$menu}}{{/menu}}