Commit 60983cc2 authored by Mihail Geshoski's avatar Mihail Geshoski
Browse files

MDL-64438 block_starredcourses: Optionally show course category

AMOS BEGIN
CPY [displaycategories,block_myoverview],[displaycategories,block_starredcourses]
AMOS END
parent d0b237b3
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -39,6 +39,7 @@ function(
) {
var SELECTORS = {
BLOCK_CONTAINER: '[data-region="starred-courses"]',
STARRED_COURSES_REGION_VIEW: '[data-region="starred-courses-view"]',
STARRED_COURSES_REGION: '[data-region="starred-courses-view-content"]'
};
......@@ -80,6 +81,12 @@ function(
return Repository.getStarredCourses(args)
.then(function(courses) {
// Whether the course category should be displayed in the course item.
var showcoursecategory = $(SELECTORS.BLOCK_CONTAINER).data('displaycoursecategory');
courses = courses.map(function(course) {
course.showcoursecategory = showcoursecategory;
return course;
});
return renderCourses(root, courses);
}).then(function(html, js) {
return Templates.replaceNodeContents(content, html, js);
......
......@@ -72,4 +72,13 @@ class block_starredcourses extends block_base {
public function applicable_formats() {
return array('my' => true);
}
/**
* Allow the block to have a configuration page
*
* @return boolean
*/
public function has_config() {
return true;
}
}
......@@ -50,10 +50,12 @@ class main implements renderable, templatable {
global $USER;
$nocoursesurl = $output->image_url('courses', 'block_starredcourses')->out();
$config = get_config('block_starredcourses');
return [
'userid' => $USER->id,
'nocoursesimg' => $nocoursesurl
'nocoursesimg' => $nocoursesurl,
'displaycategories' => !empty($config->displaycategories)
];
}
}
......@@ -22,6 +22,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['displaycategories'] = 'Display categories';
$string['displaycategories_help'] = 'Display the course category on the starred courses block items.';
$string['pluginname'] = 'Starred courses';
$string['privacy:metadata'] = 'The starred courses block does not store any personal data.';
$string['starredcourses:myaddinstance'] = 'Add a new starred courses block to Dashboard';
......
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Settings for the starredcourses block
*
* @package block_starredcourses
* @copyright 2019 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
// Display Course Categories on the starred courses block items.
$settings->add(new admin_setting_configcheckbox(
'block_starredcourses/displaycategories',
get_string('displaycategories', 'block_starredcourses'),
get_string('displaycategories_help', 'block_starredcourses'),
1));
}
......@@ -23,7 +23,8 @@
{}
}}
<div id="block-starredcourses-{{uniqid}}" class="block-starredcourses block-cards" data-region="starred-courses">
<div id="block-starredcourses-{{uniqid}}" class="block-starredcourses block-cards" data-region="starred-courses"
data-displaycoursecategory="{{displaycategories}}">
<div class="container-fluid p-0">
{{> block_starredcourses/view }}
</div>
......
This file describes API changes in the starredcourses block code.
=== 3.8 ===
* New admin setting block_starredcourses/displaycategories which enables the starred courses block
to display the course category.
=== 3.7 ===
* The 'block/starredcourses:addinstance' capability has been removed. It has never been used in code.
\ No newline at end of file
......@@ -23,6 +23,6 @@
*/
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2019052000;
$plugin->version = 2019052001;
$plugin->requires = 2019051100;
$plugin->component = 'block_starredcourses';
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment