MDL-64438 block_myoverview: Optionally display course category

This commit is contained in:
Mihail Geshoski
2019-09-18 17:55:46 +08:00
parent 704f93f46f
commit 93ad530e8f
7 changed files with 72 additions and 30 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+5 -7
View File
@@ -470,13 +470,11 @@ function(
currentTemplate = TEMPLATES.COURSES_SUMMARY;
}
// Delete the course category if it is not to be displayed
if (filters.displaycategories != 'on') {
coursesData.courses = coursesData.courses.map(function(course) {
delete course.coursecategory;
return course;
});
}
// Whether the course category should be displayed in the course item.
coursesData.courses = coursesData.courses.map(function(course) {
course.showcoursecategory = filters.displaycategories == 'on' ? true : false;
return course;
});
if (coursesData.courses.length) {
return Templates.render(currentTemplate, {
@@ -53,14 +53,18 @@
</span>
{{/coursename}}
{{$coursecategory}}
<span class="sr-only">
{{#str}}aria:coursecategory, core_course{{/str}}
</span>
<span class="categoryname text-truncate">
{{{coursecategory}}}
</span>
{{#showcoursecategory}}
<span class="sr-only">
{{#str}}aria:coursecategory, core_course{{/str}}
</span>
<span class="categoryname text-truncate">
{{{coursecategory}}}
</span>
{{/showcoursecategory}}
{{/coursecategory}}
{{$divider}}
<div class="pl-1 pr-1">|</div>
{{#showcoursecategory}}
<div class="pl-1 pr-1">|</div>
{{/showcoursecategory}}
{{/divider}}
{{/ core_course/coursecards }}
+11 -7
View File
@@ -45,14 +45,18 @@
<div class="{{#hasprogress}}col-md-6{{/hasprogress}}{{^hasprogress}}col-md-11 col-md-11{{/hasprogress}} d-flex align-items-center">
<div>
<div class="text-muted muted d-flex flex-wrap">
<span class="sr-only">
{{#str}}aria:coursecategory, core_course{{/str}}
</span>
<span class="categoryname">
{{{coursecategory}}}
</span>
{{#showcoursecategory}}
<span class="sr-only">
{{#str}}aria:coursecategory, core_course{{/str}}
</span>
<span class="categoryname">
{{{coursecategory}}}
</span>
{{/showcoursecategory}}
{{#showshortname}}
<div class="pl-1 pr-1">|</div>
{{#showcoursecategory}}
<div class="pl-1 pr-1">|</div>
{{/showcoursecategory}}
<span class="sr-only">
{{#str}}aria:courseshortname, core_course{{/str}}
</span>
@@ -54,12 +54,18 @@
{{#str}}aria:coursecategory, core_course{{/str}}
</span>
{{$coursecategory}}
<span class="categoryname">
{{{coursecategory}}}
</span>
{{#showcoursecategory}}
<span class="categoryname">
{{#coursecategory}}
{{{coursecategory}}}
{{/coursecategory}}
</span>
{{/showcoursecategory}}
{{/coursecategory}}
{{#showshortname}}
<div class="pl-1 pr-1">|</div>
{{#showcoursecategory}}
<div class="pl-1 pr-1">|</div>
{{/showcoursecategory}}
<span class="sr-only">
{{#str}}aria:courseshortname, core_course{{/str}}
</span>
@@ -252,19 +252,49 @@ Feature: The my overview block allows users to easily access their courses
And I log out
Scenario: Show course category in cards display
Given I log in as "student1"
Given the following config values are set as admin:
| displaycategories | 1 | block_myoverview |
And I log in as "student1"
And I click on "Display drop-down menu" "button" in the "Course overview" "block"
When I click on "Card" "link" in the "Course overview" "block"
Then I should see "Category 1" in the "Course overview" "block"
Scenario: Show course category in list display
Given I log in as "student1"
Given the following config values are set as admin:
| displaycategories | 1 | block_myoverview |
And I log in as "student1"
And I click on "Display drop-down menu" "button" in the "Course overview" "block"
When I click on "List" "link" in the "Course overview" "block"
Then I should see "Category 1" in the "Course overview" "block"
Scenario: Show course category in summary display
Given I log in as "student1"
Given the following config values are set as admin:
| displaycategories | 1 | block_myoverview |
And I log in as "student1"
And I click on "Display drop-down menu" "button" in the "Course overview" "block"
When I click on "Summary" "link" in the "Course overview" "block"
Then I should see "Category 1" in the "Course overview" "block"
Scenario: Hide course category in cards display
Given the following config values are set as admin:
| displaycategories | 0 | block_myoverview |
And I log in as "student1"
And I click on "Display drop-down menu" "button" in the "Course overview" "block"
When I click on "Card" "link" in the "Course overview" "block"
Then I should not see "Category 1" in the "Course overview" "block"
Scenario: Hide course category in list display
Given the following config values are set as admin:
| displaycategories | 0 | block_myoverview |
And I log in as "student1"
And I click on "Display drop-down menu" "button" in the "Course overview" "block"
When I click on "List" "link" in the "Course overview" "block"
Then I should not see "Category 1" in the "Course overview" "block"
Scenario: Show course category in summary display
Given the following config values are set as admin:
| displaycategories | 0 | block_myoverview |
And I log in as "student1"
And I click on "Display drop-down menu" "button" in the "Course overview" "block"
When I click on "Summary" "link" in the "Course overview" "block"
Then I should not see "Category 1" in the "Course overview" "block"