From d0b237b30675b0f04bc8979a136579505aa61cb6 Mon Sep 17 00:00:00 2001 From: Mihail Geshoski Date: Wed, 18 Sep 2019 17:57:47 +0800 Subject: [PATCH] MDL-64438 block_recentlyaccessedcourses: Optionally show course category AMOS BEGIN CPY [displaycategories,block_myoverview],[displaycategories,block_recentlyaccessedcourses] AMOS END --- .../amd/build/main.min.js | Bin 3529 -> 3665 bytes .../amd/build/main.min.js.map | Bin 22955 -> 23379 bytes .../recentlyaccessedcourses/amd/src/main.js | 3 + .../block_recentlyaccessedcourses.php | 9 +++ .../classes/output/main.php | 4 +- .../lang/en/block_recentlyaccessedcourses.php | 4 +- blocks/recentlyaccessedcourses/settings.php | 34 +++++++++++ .../templates/course-card.mustache | 15 +++-- .../templates/main.mustache | 2 +- ..._recentlyaccessedcourses_dashboard.feature | 55 ++++++++++++++++-- blocks/recentlyaccessedcourses/upgrade.txt | 5 ++ blocks/recentlyaccessedcourses/version.php | 2 +- 12 files changed, 119 insertions(+), 14 deletions(-) create mode 100644 blocks/recentlyaccessedcourses/settings.php diff --git a/blocks/recentlyaccessedcourses/amd/build/main.min.js b/blocks/recentlyaccessedcourses/amd/build/main.min.js index 6c3de1c93c6a3517f6132dccbfde9d6e01254b6c..4d8e69fd15ada5a16645c15b15f5352b81c8509c 100644 GIT binary patch delta 140 zcmX>peNkq@Z&oKCe`oKB|D`ALi?hZk#VYA+{C$umE>R;>4=fY!?C%%i=;`Mgq^XyZ zSdyrrl#*Fokds)MoL^d0oSK|ilA4}hRH>w?lWLo!mz!9ikye_QT#}ier;(^xov2rw dkzbCg)HcO>@;TNh#?;B0Y|@OWn_byj*a6h8F^B*F delta 55 zcmca8b5eT3Zx(0AAeTvu(woB=7qJK>>E$LCXrz_qC6{F8=V>HrR!1{+ggn+Z?CRpa>ZV)cV&5d z`QVLXcaI&69}n90SA|&Bq!6a&k;0h5rFl(iF(G0~>eof^5-vk1-Oz>D(3N~miirhW zhEX0BBKnu~QV5rmC|wp}SxFO8Oikc2as(q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X}K7cl@1ju{)$i z;8*`)UG=YuTkdi#=77c;G*-sDO966Z!&E`^0n{tuIdy>%sGo>gg-+Q?m0ks$y58WSx_m zGWZ?m%CR<8c~QzFPgIpTdd^L;!dXTgZGOjq!-#4dy0 zK(||so~vX)nO`)DFct8*@-;ES&4A&>*KbJ7QW?)&sC~7+4tTY-?Oy`9ecP`bJJST= Q true); } + + /** + * Allow the block to have a configuration page + * + * @return boolean + */ + public function has_config() { + return true; + } } diff --git a/blocks/recentlyaccessedcourses/classes/output/main.php b/blocks/recentlyaccessedcourses/classes/output/main.php index 631af28407b..0534d17670e 100644 --- a/blocks/recentlyaccessedcourses/classes/output/main.php +++ b/blocks/recentlyaccessedcourses/classes/output/main.php @@ -46,6 +46,7 @@ class main implements renderable, templatable { global $USER; $nocoursesurl = $output->image_url('courses', 'block_recentlyaccessedcourses')->out(false); + $config = get_config('block_recentlyaccessedcourses'); return [ 'userid' => $USER->id, @@ -53,7 +54,8 @@ class main implements renderable, templatable { 'pagingbar' => [ 'next' => true, 'previous' => true - ] + ], + 'displaycategories' => !empty($config->displaycategories) ]; } } diff --git a/blocks/recentlyaccessedcourses/lang/en/block_recentlyaccessedcourses.php b/blocks/recentlyaccessedcourses/lang/en/block_recentlyaccessedcourses.php index 8a722478083..86e88c38c33 100644 --- a/blocks/recentlyaccessedcourses/lang/en/block_recentlyaccessedcourses.php +++ b/blocks/recentlyaccessedcourses/lang/en/block_recentlyaccessedcourses.php @@ -20,7 +20,9 @@ * @copyright 2018 Victor Deniz * @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 recently accessed courses block items.'; $string['pluginname'] = 'Recently accessed courses'; $string['privacy:metadata'] = 'The Recently accessed courses block does not store any personal data.'; $string['recentlyaccessedcourses:myaddinstance'] = 'Add a new recently accessed courses block to Dashboard'; -$string['nocourses'] = 'No recent courses'; \ No newline at end of file +$string['nocourses'] = 'No recent courses'; diff --git a/blocks/recentlyaccessedcourses/settings.php b/blocks/recentlyaccessedcourses/settings.php new file mode 100644 index 00000000000..2e763433818 --- /dev/null +++ b/blocks/recentlyaccessedcourses/settings.php @@ -0,0 +1,34 @@ +. + +/** + * Settings for the recentlyaccessedcourses block + * + * @package block_recentlyaccessedcourses + * @copyright 2019 Mihail Geshoski + * @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 recently accessed courses block items. + $settings->add(new admin_setting_configcheckbox( + 'block_recentlyaccessedcourses/displaycategories', + get_string('displaycategories', 'block_recentlyaccessedcourses'), + get_string('displaycategories_help', 'block_recentlyaccessedcourses'), + 1)); +} diff --git a/blocks/recentlyaccessedcourses/templates/course-card.mustache b/blocks/recentlyaccessedcourses/templates/course-card.mustache index 7b98a5eb203..c18f12438f1 100644 --- a/blocks/recentlyaccessedcourses/templates/course-card.mustache +++ b/blocks/recentlyaccessedcourses/templates/course-card.mustache @@ -35,10 +35,17 @@ {{< core_course/coursecard }} {{$coursecategory}} - - {{#str}}aria:coursecategory, core_course{{/str}} - - {{{coursecategory}}} + {{#showcoursecategory}} + + {{#str}}aria:coursecategory, core_course{{/str}} + + {{{coursecategory}}} + {{/showcoursecategory}} {{/coursecategory}} {{$coursename}} {{{fullname}}} {{/coursename}} + {{$divider}} + {{#showcoursecategory}} +
|
+ {{/showcoursecategory}} + {{/divider}} {{/ core_course/coursecard }} diff --git a/blocks/recentlyaccessedcourses/templates/main.mustache b/blocks/recentlyaccessedcourses/templates/main.mustache index 84e64d532eb..1a072606902 100644 --- a/blocks/recentlyaccessedcourses/templates/main.mustache +++ b/blocks/recentlyaccessedcourses/templates/main.mustache @@ -27,7 +27,7 @@ }}
+ data-userid="{{userid}}" data-displaycoursecategory="{{displaycategories}}">
{{> block_recentlyaccessedcourses/recentlyaccessedcourses-view }}
diff --git a/blocks/recentlyaccessedcourses/tests/behat/block_recentlyaccessedcourses_dashboard.feature b/blocks/recentlyaccessedcourses/tests/behat/block_recentlyaccessedcourses_dashboard.feature index 1361760cec8..731e1efc670 100644 --- a/blocks/recentlyaccessedcourses/tests/behat/block_recentlyaccessedcourses_dashboard.feature +++ b/blocks/recentlyaccessedcourses/tests/behat/block_recentlyaccessedcourses_dashboard.feature @@ -8,13 +8,16 @@ Feature: The recently accessed courses block allows users to easily access their Given the following "users" exist: | username | firstname | lastname | email | | student1 | Student | 1 | student1@example.com | + And the following "categories" exist: + | name | category | idnumber | + | Category 1 | 0 | CAT1 | And the following "courses" exist: - | fullname | shortname | - | Course 1 | C1 | - | Course 2 | C2 | - | Course 3 | C3 | - | Course 4 | C4 | - | Course 5 | C5 | + | fullname | shortname | category | + | Course 1 | C1 | 0 | + | Course 2 | C2 | 0 | + | Course 3 | C3 | 0 | + | Course 4 | C4 | CAT1 | + | Course 5 | C5 | 0 | And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | @@ -40,3 +43,43 @@ Feature: The recently accessed courses block allows users to easily access their And I should not see "Course 3" in the "Recently accessed courses" "block" And I should not see "Course 4" in the "Recently accessed courses" "block" And I should not see "Course 5" in the "Recently accessed courses" "block" + + Scenario: Show course category name + Given the following config values are set as admin: + | displaycategories | 1 | block_recentlyaccessedcourses | + And I log in as "student1" + And I am on "Course 1" course homepage + And I am on "Course 4" course homepage + And I follow "Dashboard" in the user menu + And I should see "Miscellaneous" in the "Recently accessed courses" "block" + And I should see "Category 1" in the "Recently accessed courses" "block" + + Scenario: Hide course category name + Given the following config values are set as admin: + | displaycategories | 0 | block_recentlyaccessedcourses | + And I log in as "student1" + And I am on "Course 1" course homepage + And I am on "Course 4" course homepage + And I follow "Dashboard" in the user menu + And I should not see "Miscellaneous" in the "Recently accessed courses" "block" + And I should not see "Category 1" in the "Recently accessed courses" "block" + + Scenario: Show short course name + Given the following config values are set as admin: + | courselistshortnames | 1 | + And I log in as "student1" + And I am on "Course 1" course homepage + And I am on "Course 4" course homepage + And I follow "Dashboard" in the user menu + And I should see "C1" in the "Recently accessed courses" "block" + And I should see "C4" in the "Recently accessed courses" "block" + + Scenario: Hide short course name + Given the following config values are set as admin: + | courselistshortnames | 0 | + And I log in as "student1" + And I am on "Course 1" course homepage + And I am on "Course 4" course homepage + And I follow "Dashboard" in the user menu + And I should not see "C1" in the "Recently accessed courses" "block" + And I should not see "C4" in the "Recently accessed courses" "block" diff --git a/blocks/recentlyaccessedcourses/upgrade.txt b/blocks/recentlyaccessedcourses/upgrade.txt index 2f6b9225310..97340542227 100644 --- a/blocks/recentlyaccessedcourses/upgrade.txt +++ b/blocks/recentlyaccessedcourses/upgrade.txt @@ -1,5 +1,10 @@ This file describes API changes in the recentlyaccessedcourses block code. +=== 3.8 === + +* New admin setting block_recentlyaccessedcourses/displaycategories which enables the recently accessed + courses block to display the course category. + === 3.7 === * The 'block/recentlyaccessedcourses:addinstance' capability has been removed. It has never been used in code. \ No newline at end of file diff --git a/blocks/recentlyaccessedcourses/version.php b/blocks/recentlyaccessedcourses/version.php index a05f8fb9ece..08dcbadd91d 100644 --- a/blocks/recentlyaccessedcourses/version.php +++ b/blocks/recentlyaccessedcourses/version.php @@ -22,6 +22,6 @@ */ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2019052000; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2019052001; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2019051100; // Requires this Moodle version. $plugin->component = 'block_recentlyaccessedcourses'; // Full name of the plugin (used for diagnostics). -- 2.43.0