MDL-67690 block_myoverview: Clean usage of starred vs favourites

The block accidentally mixes usage of starred vs favourites, but core
requires favourites. This fixes the issue of user settings remembering
the correct value without a more major work.
This commit is contained in:
Eric Merrill
2020-01-23 15:22:02 -05:00
parent 36984d4d1d
commit 7bfcb01b81
2 changed files with 25 additions and 5 deletions
+11 -5
View File
@@ -121,7 +121,7 @@ class main implements renderable, templatable {
*
* @var boolean
*/
private $displaygroupingstarred;
private $displaygroupingfavourites;
/**
* Store a course grouping option setting.
@@ -168,7 +168,13 @@ class main implements renderable, templatable {
$config = get_config('block_myoverview');
// Build the course grouping option name to check if the given grouping is enabled afterwards.
$groupingconfigname = 'displaygrouping'.$grouping;
if ($grouping === 'favourites') {
// There was a mismatch in parts of block between the name starred and favourites. This helps fix that.
$groupingconfigname = 'displaygroupingstarred';
} else {
$groupingconfigname = 'displaygrouping'.$grouping;
}
// Check the given grouping and remember it if it is enabled.
if ($grouping && $config->$groupingconfigname == true) {
$this->grouping = $grouping;
@@ -214,7 +220,7 @@ class main implements renderable, templatable {
$this->displaygroupinginprogress = $config->displaygroupinginprogress;
$this->displaygroupingfuture = $config->displaygroupingfuture;
$this->displaygroupingpast = $config->displaygroupingpast;
$this->displaygroupingstarred = $config->displaygroupingstarred;
$this->displaygroupingfavourites = $config->displaygroupingstarred; // Note the name mismatch!
$this->displaygroupinghidden = $config->displaygroupinghidden;
$this->displaygroupingcustomfield = ($config->displaygroupingcustomfield && $config->customfiltergrouping);
$this->customfiltergrouping = $config->customfiltergrouping;
@@ -226,7 +232,7 @@ class main implements renderable, templatable {
$this->displaygroupinginprogress,
$this->displaygroupingfuture,
$this->displaygroupingpast,
$this->displaygroupingstarred,
$this->displaygroupingfavourites,
$this->displaygroupinghidden);
$displaygroupingselectorscount = count(array_filter($displaygroupingselectors));
if ($displaygroupingselectorscount > 1 || $this->displaygroupingcustomfield) {
@@ -439,7 +445,7 @@ class main implements renderable, templatable {
'displaygroupinginprogress' => $this->displaygroupinginprogress,
'displaygroupingfuture' => $this->displaygroupingfuture,
'displaygroupingpast' => $this->displaygroupingpast,
'displaygroupingstarred' => $this->displaygroupingstarred,
'displaygroupingstarred' => $this->displaygroupingfavourites, // Note the name mismatch!
'displaygroupinghidden' => $this->displaygroupinghidden,
'displaygroupingselector' => $this->displaygroupingselector,
'displaygroupingcustomfield' => $this->displaygroupingcustomfield && $customfieldvalues,
@@ -128,6 +128,20 @@ Feature: The my overview block allows users to easily access their courses
And I should not see "Course 3" in the "Course overview" "block"
And I should not see "Course 4" in the "Course overview" "block"
Scenario: View favourite courses - w/ persistence
Given I log in as "student1"
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 "All (except removed from view)" "button" in the "Course overview" "block"
When I click on "Starred" "link" in the "Course overview" "block"
And I reload the page
Then I should see "Starred" in the "Course overview" "block"
And I should see "Course 2" in the "Course overview" "block"
And I should not see "Course 1" in the "Course overview" "block"
And I should not see "Course 3" in the "Course overview" "block"
And I should not see "Course 4" in the "Course overview" "block"
And I should not see "Course 5" in the "Course overview" "block"
Scenario: List display persistence
Given I log in as "student1"
And I click on "Display drop-down menu" "button" in the "Course overview" "block"