Commit cd4abbc7 authored by Alexander Bias's avatar Alexander Bias
Browse files

MDL-66016 block_myoverview: Add 'All' course filter

parent ee47c8fd
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.
......@@ -67,6 +67,16 @@ function(
NOCOURSES: 'core_course/no-courses'
};
var GROUPINGS = {
GROUPING_ALLINCLUDINGHIDDEN: 'allincludinghidden',
GROUPING_ALL: 'all',
GROUPING_INPROGRESS: 'inprogress',
GROUPING_FUTURE: 'future',
GROUPING_PAST: 'past',
GROUPING_FAVOURITES: 'favourites',
GROUPING_HIDDEN: 'hidden'
};
var NUMCOURSES_PERPAGE = [12, 24, 48, 96, 0];
var loadedPages = [];
......@@ -252,15 +262,104 @@ function(
}).catch(Notification.exception);
};
/**
* Get the action menu item
*
* @param {Object} root root The course overview container
* @param {Number} courseId Course id.
* @return {Object} The hide course menu item.
*/
var getHideCourseMenuItem = function(root, courseId) {
return root.find('[data-action="hide-course"][data-course-id="' + courseId + '"]');
};
/**
* Get the action menu item
*
* @param {Object} root root The course overview container
* @param {Number} courseId Course id.
* @return {Object} The show course menu item.
*/
var getShowCourseMenuItem = function(root, courseId) {
return root.find('[data-action="show-course"][data-course-id="' + courseId + '"]');
};
/**
* Hide course
*
* @param {Object} root The course overview container
* @param {Number} courseId Course id number
*/
var hideCourse = function(root, courseId) {
var hideAction = getHideCourseMenuItem(root, courseId);
var showAction = getShowCourseMenuItem(root, courseId);
var filters = getFilterValues(root);
setCourseHiddenState(courseId, true);
// Remove the course from this view as it is now hidden and thus not covered by this view anymore.
// Do only if we are not in "All" view mode where really all courses are shown.
if (filters.grouping != GROUPINGS.GROUPING_ALLINCLUDINGHIDDEN) {
hideElement(root, courseId);
}
hideAction.addClass('hidden');
showAction.removeClass('hidden');
};
/**
* Show course
*
* @param {Object} root The course overview container
* @param {Number} courseId Course id number
*/
var showCourse = function(root, courseId) {
var hideAction = getHideCourseMenuItem(root, courseId);
var showAction = getShowCourseMenuItem(root, courseId);
var filters = getFilterValues(root);
setCourseHiddenState(courseId, null);
// Remove the course from this view as it is now shown again and thus not covered by this view anymore.
// Do only if we are not in "All" view mode where really all courses are shown.
if (filters.grouping != GROUPINGS.GROUPING_ALLINCLUDINGHIDDEN) {
hideElement(root, courseId);
}
hideAction.removeClass('hidden');
showAction.addClass('hidden');
};
/**
* Set the courses hidden status and push to repository
*
* @param {Number} courseId Course id to favourite.
* @param {Bool} status new hidden status.
* @return {Promise} Repository promise.
*/
var setCourseHiddenState = function(courseId, status) {
// If the given status is not hidden, the preference has to be deleted with a null value.
if (status === false) {
status = null;
}
return Repository.updateUserPreferences({
preferences: [
{
type: 'block_myoverview_hidden_course_' + courseId,
value: status
}
]
});
};
/**
* Reset the loadedPages dataset to take into account the hidden element
*
* @param {Object} root The course overview container
* @param {Object} target The course that you want to hide
* @param {Number} id The course id number
*/
var hideElement = function(root, target) {
var id = getCourseId(target);
var hideElement = function(root, id) {
var pagingBar = root.find('[data-region="paging-bar"]');
var jumpto = parseInt(pagingBar.attr('data-active-page-number'));
......@@ -570,38 +669,15 @@ function(
root.on(CustomEvents.events.activate, SELECTORS.ACTION_HIDE_COURSE, function(e, data) {
var target = $(e.target).closest(SELECTORS.ACTION_HIDE_COURSE);
var id = getCourseId(target);
var request = {
preferences: [
{
type: 'block_myoverview_hidden_course_' + id,
value: true
}
]
};
Repository.updateUserPreferences(request);
hideElement(root, target);
var courseId = getCourseId(target);
hideCourse(root, courseId);
data.originalEvent.preventDefault();
});
root.on(CustomEvents.events.activate, SELECTORS.ACTION_SHOW_COURSE, function(e, data) {
var target = $(e.target).closest(SELECTORS.ACTION_SHOW_COURSE);
var id = getCourseId(target);
var request = {
preferences: [
{
type: 'block_myoverview_hidden_course_' + id,
value: null
}
]
};
Repository.updateUserPreferences(request);
hideElement(root, target);
var courseId = getCourseId(target);
showCourse(root, courseId);
data.originalEvent.preventDefault();
});
};
......
......@@ -27,6 +27,7 @@ defined('MOODLE_INTERNAL') || die();
/**
* Constants for the user preferences grouping options
*/
define('BLOCK_MYOVERVIEW_GROUPING_ALLINCLUDINGHIDDEN', 'allincludinghidden');
define('BLOCK_MYOVERVIEW_GROUPING_ALL', 'all');
define('BLOCK_MYOVERVIEW_GROUPING_INPROGRESS', 'inprogress');
define('BLOCK_MYOVERVIEW_GROUPING_FUTURE', 'future');
......@@ -74,6 +75,7 @@ function block_myoverview_user_preferences() {
'default' => BLOCK_MYOVERVIEW_GROUPING_ALL,
'type' => PARAM_ALPHA,
'choices' => array(
BLOCK_MYOVERVIEW_GROUPING_ALLINCLUDINGHIDDEN,
BLOCK_MYOVERVIEW_GROUPING_ALL,
BLOCK_MYOVERVIEW_GROUPING_INPROGRESS,
BLOCK_MYOVERVIEW_GROUPING_FUTURE,
......
......@@ -21,6 +21,7 @@
Example context (json):
{
"allincludinghidden": false,
"all": true,
"inprogress": false,
"future": false,
......@@ -34,6 +35,7 @@
<button id="groupingdropdown" type="button" class="btn btn-outline-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-label="{{#str}} aria:groupingdropdown, block_myoverview {{/str}}">
{{#pix}} i/filter {{/pix}}
<span class="d-sm-inline-block" data-active-item-text>
{{#allincludinghidden}}{{#str}} allincludinghidden, block_myoverview {{/str}}{{/allincludinghidden}}
{{#all}}{{#str}} all, block_myoverview {{/str}}{{/all}}
{{#inprogress}}{{#str}} inprogress, block_myoverview {{/str}}{{/inprogress}}
{{#future}}{{#str}} future, block_myoverview {{/str}}{{/future}}
......@@ -43,6 +45,14 @@
</span>
</button>
<ul class="dropdown-menu" data-show-active-item data-active-item-text aria-labelledby="groupingdropdown">
<li>
<a class="dropdown-item {{#allincludinghidden}}active{{/allincludinghidden}}" href="#" data-filter="grouping" data-value="allincludinghidden" data-pref="allincludinghidden" aria-label="{{#str}} aria:allcoursesincludinghidden, block_myoverview {{/str}}" aria-controls="courses-view-{{uniqid}}">
{{#str}} allincludinghidden, block_myoverview {{/str}}
</a>
</li>
<li class="dropdown-divider" role="presentation">
<span class="filler">&nbsp;</span>
</li>
<li>
<a class="dropdown-item {{#all}}active{{/all}}" href="#" data-filter="grouping" data-value="all" data-pref="all" aria-label="{{#str}} aria:allcourses, block_myoverview {{/str}}" aria-controls="courses-view-{{uniqid}}">
{{#str}} all, block_myoverview {{/str}}
......
......@@ -28,7 +28,7 @@ Feature: The my overview block allows users to easily access their courses
Scenario: View past courses
Given I log in as "student1"
And I click on "All" "button" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
When I click on "Past" "link" in the "Course overview" "block"
Then I should see "Course 1" in the "Course overview" "block"
And I should not see "Course 2" in the "Course overview" "block"
......@@ -39,7 +39,7 @@ Feature: The my overview block allows users to easily access their courses
Scenario: View future courses
Given I log in as "student1"
And I click on "All" "button" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
When I click on "Future" "link" in the "Course overview" "block"
Then I should see "Course 5" in the "Course overview" "block"
And I should not see "Course 1" in the "Course overview" "block"
......@@ -50,7 +50,7 @@ Feature: The my overview block allows users to easily access their courses
Scenario: View inprogress courses
Given I log in as "student1"
And I click on "All" "button" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
When I click on "In progress" "link" in the "Course overview" "block"
Then I should see "Course 2" in the "Course overview" "block"
Then I should see "Course 3" in the "Course overview" "block"
......@@ -59,10 +59,22 @@ Feature: The my overview block allows users to easily access their courses
And I should not see "Course 5" in the "Course overview" "block"
And I log out
Scenario: View all courses
Scenario: View all (except hidden) courses
Given I log in as "student1"
And I click on "All" "button" in the "Course overview" "block"
When I click on "All" "link" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
When I click on "All (except hidden)" "link" in the "Course overview" "block"
Then I should see "Course 1" in the "Course overview" "block"
Then I should see "Course 2" in the "Course overview" "block"
Then I should see "Course 3" in the "Course overview" "block"
Then I should see "Course 4" in the "Course overview" "block"
Then I should see "Course 5" in the "Course overview" "block"
And I log out
Scenario: View all (including hidden) courses
Given I log in as "student1"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
# We have to click on the data attribute instead of the button element text as we might risk to click on the false positive "All (except hidden)" element instead
When I click on "[data-value='allincludinghidden']" "css_element" in the "Course overview" "block"
Then I should see "Course 1" in the "Course overview" "block"
Then I should see "Course 2" in the "Course overview" "block"
Then I should see "Course 3" in the "Course overview" "block"
......@@ -72,7 +84,7 @@ Feature: The my overview block allows users to easily access their courses
Scenario: View inprogress courses - test persistence
Given I log in as "student1"
And I click on "All" "button" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
And I click on "In progress" "link" in the "Course overview" "block"
And I reload the page
Then I should see "In progress" in the "Course overview" "block"
......@@ -83,12 +95,12 @@ Feature: The my overview block allows users to easily access their courses
And I should not see "Course 5" in the "Course overview" "block"
And I log out
Scenario: View all courses - w/ persistence
Scenario: View all (except hidden) courses - w/ persistence
Given I log in as "student1"
And I click on "All" "button" in the "Course overview" "block"
When I click on "All" "link" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
When I click on "All (except hidden)" "link" in the "Course overview" "block"
And I reload the page
Then I should see "All" in the "Course overview" "block"
Then I should see "All (except hidden)" in the "Course overview" "block"
Then I should see "Course 1" in the "Course overview" "block"
Then I should see "Course 2" in the "Course overview" "block"
Then I should see "Course 3" in the "Course overview" "block"
......@@ -98,7 +110,7 @@ Feature: The my overview block allows users to easily access their courses
Scenario: View past courses - w/ persistence
Given I log in as "student1"
And I click on "All" "button" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
When I click on "Past" "link" in the "Course overview" "block"
And I reload the page
Then I should see "Past" in the "Course overview" "block"
......@@ -111,7 +123,7 @@ Feature: The my overview block allows users to easily access their courses
Scenario: View future courses - w/ persistence
Given I log in as "student1"
And I click on "All" "button" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
When I click on "Future" "link" in the "Course overview" "block"
And I reload the page
Then I should see "Future" in the "Course overview" "block"
......@@ -164,7 +176,7 @@ Feature: The my overview block allows users to easily access their courses
Scenario: View inprogress courses with hide persistent functionality
Given I log in as "student1"
And I click on "All" "button" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
When I click on "In progress" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on "Hide from view" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
......@@ -178,7 +190,7 @@ Feature: The my overview block allows users to easily access their courses
Scenario: View past courses with hide persistent functionality
Given I log in as "student1"
And I click on "All" "button" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
When I click on "Past" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 1')]" "xpath_element"
And I click on "Hide from view" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 1')]" "xpath_element"
......@@ -192,7 +204,7 @@ Feature: The my overview block allows users to easily access their courses
Scenario: View future courses with hide persistent functionality
Given I log in as "student1"
And I click on "All" "button" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
When I click on "Future" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 5')]" "xpath_element"
And I click on "Hide from view" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 5')]" "xpath_element"
......@@ -204,6 +216,35 @@ Feature: The my overview block allows users to easily access their courses
And I should not see "Course 4" in the "Course overview" "block"
And I log out
Scenario: View all (except hidden) courses with hide persistent functionality
Given I log in as "student1"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
When I click on "All (except hidden)" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 5')]" "xpath_element"
And I click on "Hide from view" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 5')]" "xpath_element"
And I reload the page
Then I should not see "Course 5" in the "Course overview" "block"
And I should see "Course 1" in the "Course overview" "block"
And I should see "Course 2" in the "Course overview" "block"
And I should see "Course 3" in the "Course overview" "block"
And I should see "Course 4" in the "Course overview" "block"
And I log out
Scenario: View all (including hidden) courses with hide persistent functionality
Given I log in as "student1"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
# We have to click on the data attribute instead of the button element text as we might risk to click on the false positive "All (except hidden)" element instead
When I click on "[data-value='allincludinghidden']" "css_element" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 5')]" "xpath_element"
And I click on "Hide from view" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 5')]" "xpath_element"
And I reload the page
Then I should see "Course 5" in the "Course overview" "block"
And I should see "Course 1" in the "Course overview" "block"
And I should see "Course 2" in the "Course overview" "block"
And I should see "Course 3" in the "Course overview" "block"
And I should see "Course 4" in the "Course overview" "block"
And I log out
Scenario: Show course category in cards display
Given I log in as "student1"
And I click on "Display drop-down menu" "button" in the "Course overview" "block"
......
......@@ -25,7 +25,9 @@ Feature: The my overview block allows users to hide their courses
Scenario: Test hide toggle functionality
Given I log in as "student1"
When I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
When I click on "All (except hidden)" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on "Hide from view" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I reload the page
Then I should not see "Course 2" in the "Course overview" "block"
......@@ -33,13 +35,15 @@ Feature: The my overview block allows users to hide their courses
Scenario: Test hide toggle functionality w/ favorites
Given I log in as "student1"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
When I click on "All (except hidden)" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on "Star this course" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on "Hide from view" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
When I reload the page
Then I should not see "Course 2" in the "Course overview" "block"
And I click on "All" "button" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
And I click on "Starred" "link" in the "Course overview" "block"
Then I should not see "Course 2" in the "Course overview" "block"
And I click on "Starred" "button" in the "Course overview" "block"
......@@ -49,25 +53,29 @@ Feature: The my overview block allows users to hide their courses
Scenario: Test show toggle functionality
Given I log in as "student1"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
When I click on "All (except hidden)" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on "Hide from view" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
When I click on "All" "button" in the "Course overview" "block"
When I click on "All (except hidden)" "button" in the "Course overview" "block"
And I click on "Hidden" "link" in the "Course overview" "block"
When I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on "Show this course" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I reload the page
And I click on "Hidden" "button" in the "Course overview" "block"
When I click on "All" "link" in the "Course overview" "block"
When I click on "All (except hidden)" "link" in the "Course overview" "block"
Then I should see "Course 2" in the "Course overview" "block"
And I log out
Scenario: Test show toggle functionality w/ favorites
Given I log in as "student1"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
When I click on "All (except hidden)" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on "Star this course" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on "Hide from view" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on "All" "button" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
And I click on "Hidden" "link" in the "Course overview" "block"
And I should see "Course 2" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
......@@ -75,9 +83,36 @@ Feature: The my overview block allows users to hide their courses
When I reload the page
Then I should not see "Course 2" in the "Course overview" "block"
And I click on "Hidden" "button" in the "Course overview" "block"
And I click on "All" "link" in the "Course overview" "block"
And I click on "All (except hidden)" "link" in the "Course overview" "block"
Then I should see "Course 2" in the "Course overview" "block"
And I click on "All" "button" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
And I click on "Starred" "link" in the "Course overview" "block"
Then I should see "Course 2" in the "Course overview" "block"
And I log out
Scenario: Test a course is hidden directly with "All (except hidden)" courses
Given I log in as "student1"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
When I click on "All (except hidden)" "link" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on "Hide from view" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
Then I should not see "Course 2" in the "Course overview" "block"
And I log out
Scenario: Test a course is never hidden with "All (including hidden)" courses
Given I log in as "student1"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
# We have to click on the data attribute instead of the button element text as we might risk to click on the false positive "All (except hidden)" element instead
When I click on "[data-value='allincludinghidden']" "css_element" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on "Hide from view" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
Then I should see "Course 2" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I should not see "Hide from view" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I should see "Show this course" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I click on "Show this course" "link" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
Then I should see "Course 2" in the "Course overview" "block"
And I click on ".coursemenubtn" "css_element" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I should see "Hide from view" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I should not see "Show this course" in the "//div[@class='card dashboard-card' and contains(.,'Course 2')]" "xpath_element"
And I log out
\ No newline at end of file
......@@ -50,7 +50,7 @@ Feature: The my overview block allows users to persistence of their page limits
Given I log in as "student1"
When I click on "[data-toggle='dropdown']" "css_element" in the "Course overview" "block"
And I click on "All" "link"
And I click on "All" "button" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
And I click on "In progress" "link" in the "Course overview" "block"
Then I should see "Course 13"
And I should see "All" in the "[data-action='limit-toggle']" "css_element"
......
......@@ -22,8 +22,8 @@ Feature: Course overview block show users their progress on courses
Scenario: Course progress percentage should not be displayed if completion is not enabled
Given I log in as "student1"
And I click on "All" "button" in the "Course overview" "block"
When I click on "All" "link" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
When I click on "All (except hidden)" "link" in the "Course overview" "block"
Then I should not see "0%" in the "Course overview" "block"
And I log out
......@@ -38,12 +38,12 @@ Feature: Course overview block show users their progress on courses
And I press "Save and return to course"
And I log out
When I log in as "student1"
And I click on "All" "button" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
Then I should see "Course 1" in the "Course overview" "block"
And I should see "0%" in the "Course overview" "block"
And I am on "Course 1" course homepage
And I follow "Test choice 1"
And I follow "Dashboard" in the user menu
And I click on "All" "button" in the "Course overview" "block"
And I click on "All (except hidden)" "button" in the "Course overview" "block"
And I should see "100%" in the "Course overview" "block"
And I log out
......@@ -72,6 +72,7 @@ class block_myoverview_privacy_testcase extends \core_privacy\tests\provider_tes
return array(
array('block_myoverview_user_sort_preference', 'lastaccessed', ''),
array('block_myoverview_user_sort_preference', 'title', ''),
array('block_myoverview_user_grouping_preference', 'allincludinghidden', ''),
array('block_myoverview_user_grouping_preference', 'all', ''),
array('block_myoverview_user_grouping_preference', 'inprogress', ''),
array('block_myoverview_user_grouping_preference', 'future', ''),
......
......@@ -3741,6 +3741,8 @@ class core_course_external extends external_api {
$sort = $params['sort'];
switch($classification) {
case COURSE_TIMELINE_ALLINCLUDINGHIDDEN:
break;
case COURSE_TIMELINE_ALL:
break;
case COURSE_TIMELINE_PAST:
......@@ -3764,10 +3766,16 @@ class core_course_external extends external_api {
$hiddencourses = get_hidden_courses_on_timeline();
$courses = [];
// If the timeline requires the hidden courses then restrict the result to only $hiddencourses else exclude.
if ($classification == COURSE_TIMELINE_HIDDEN) {
// If the timeline requires really all courses, get really all courses.
if ($classification == COURSE_TIMELINE_ALLINCLUDINGHIDDEN) {
$courses = course_get_enrolled_courses_for_logged_in_user(0, $offset, $sort, $fields, COURSE_DB_QUERY_LIMIT);
// Otherwise if the timeline requires the hidden courses then restrict the result to only $hiddencourses.
} else if ($classification == COURSE_TIMELINE_HIDDEN) {
$courses = course_get_enrolled_courses_for_logged_in_user(0, $offset, $sort, $fields,
COURSE_DB_QUERY_LIMIT, $hiddencourses);
// Otherwise get the requested courses and exclude the hidden courses.
} else {
$courses = course_get_enrolled_courses_for_logged_in_user(0, $offset, $sort, $fields,
COURSE_DB_QUERY_LIMIT, [], $hiddencourses);
......
......@@ -56,6 +56,7 @@ define('FIRSTUSEDEXCELROW', 3);
define('MOD_CLASS_ACTIVITY', 0);
define('MOD_CLASS_RESOURCE', 1);
define('COURSE_TIMELINE_ALLINCLUDINGHIDDEN', 'allincludinghidden');
define('COURSE_TIMELINE_ALL', 'all');
define('COURSE_TIMELINE_PAST', 'past');
define('COURSE_TIMELINE_INPROGRESS', 'inprogress');
......@@ -4320,9 +4321,9 @@ function course_filter_courses_by_timeline_classification(
) : array {
if (!in_array($classification,
[COURSE_TIMELINE_ALL, COURSE_TIMELINE_PAST, COURSE_TIMELINE_INPROGRESS,
[COURSE_TIMELINE_ALLINCLUDINGHIDDEN, COURSE_TIMELINE_ALL, COURSE_TIMELINE_PAST, COURSE_TIMELINE_INPROGRESS,
COURSE_TIMELINE_FUTURE, COURSE_TIMELINE_HIDDEN])) {
$message = 'Classification must be one of COURSE_TIMELINE_ALL, COURSE_TIMELINE_PAST, '
$message = 'Classification must be one of COURSE_TIMELINE_ALLINCLUDINGHIDDEN, COURSE_TIMELINE_ALL, COURSE_TIMELINE_PAST, '
. 'COURSE_TIMELINE_INPROGRESS or COURSE_TIMELINE_FUTURE';
throw new moodle_exception($message);
}
......@@ -4336,7 +4337,7 @@ function course_filter_courses_by_timeline_classification(
$pref = get_user_preferences('block_myoverview_hidden_course_' . $course->id, 0);
// Added as of MDL-63457 toggle viewability for each user.
if (($classification == COURSE_TIMELINE_HIDDEN && $pref) ||
if ($classification == COURSE_TIMELINE_ALLINCLUDINGHIDDEN || ($classification == COURSE_TIMELINE_HIDDEN && $pref) ||
(($classification == COURSE_TIMELINE_ALL || $classification == course_classify_for_timeline($course)) && !$pref)) {
$filteredcourses[] = $course;
$filtermatches++;
......
......@@ -2,8 +2,12 @@ This files describes API changes in /course/*,
information provided here is intended especially for developers.
=== 3.8 ===
* The following functions have been finally deprecated and can not be used any more:
- core_course_external::get_activities_overview
* External function core_course_external::get_enrolled_courses_by_timeline_classification now also supports the classification
'allincludinghidden' which delivers all courses including hidden courses. The classification 'all' still returns all courses
without hidden courses.
=== 3.7 ===
......
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