MDL-72275 timeline: Display "all" time on page load fix

When the timeframe filter was set to "all" when the timeline
block was initially loaded, an incorrect value rendered into
the template meant the timeframe limit was set to 0 (which will
return no results) instead of setting no limit (which would fetch all
 action events, as intended).
This commit is contained in:
Michael Hawkins
2021-09-24 11:24:49 +08:00
parent 0360329c46
commit dcf2239198
2 changed files with 26 additions and 4 deletions
+3 -3
View File
@@ -102,7 +102,7 @@ class main implements renderable, templatable {
*/
private function get_filter_offsets() {
$limit = false;
$limit = '';
if (in_array($this->filter, [BLOCK_TIMELINE_FILTER_BY_NONE, BLOCK_TIMELINE_FILTER_BY_OVERDUE])) {
$offset = -14;
if ($this->filter == BLOCK_TIMELINE_FILTER_BY_OVERDUE) {
@@ -170,8 +170,8 @@ class main implements renderable, templatable {
'sorttimelinecourses' => $this->order == BLOCK_TIMELINE_SORT_BY_COURSES,
'selectedfilter' => $this->filter,
'hasdaysoffset' => true,
'hasdayslimit' => $offsets['dayslimit'] !== false ,
'nodayslimit' => $offsets['dayslimit'] === false ,
'hasdayslimit' => $offsets['dayslimit'] !== '' ,
'nodayslimit' => $offsets['dayslimit'] === '' ,
'limit' => $this->limit
];
return array_merge($contextvariables, $filters, $offsets);
@@ -77,7 +77,7 @@ Feature: The timeline block allows users to see upcoming courses
And I click on "Sort by dates" "link" in the "Timeline" "block"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by courses" "link" in the "Timeline" "block"
And I reload the page
When I reload the page
Then I should see "Course 1" in the "Timeline" "block"
And I should see "Course 2" in the "Timeline" "block"
And I should see "More courses" in the "Timeline" "block"
@@ -89,3 +89,25 @@ Feature: The timeline block allows users to see upcoming courses
And I should not see "Test feedback 2 closes" in the "Timeline" "block"
And I should not see "Test feedback 3 closes" in the "Timeline" "block"
And I should not see "Test assign 1 is due" in the "Timeline" "block"
Scenario: Persistent All in course view
Given I log in as "student1"
And I click on "Sort timeline items" "button" in the "Timeline" "block"
And I click on "Sort by courses" "link" in the "Timeline" "block"
And I click on "Filter timeline items" "button" in the "Timeline" "block"
And I click on "All" "link" in the "Timeline" "block"
When I reload the page
And I click on "More courses" "button" in the "Timeline" "block"
Then I should see "Course 3" in the "Timeline" "block"
And I should see "Course 2" in the "Timeline" "block"
And I should see "Course 1" in the "Timeline" "block"
And I should see "Test choice 1 closes" in the "Timeline" "block"
And I should see "Test choice 3 closes" in the "Timeline" "block"
And I should see "Test feedback 1 closes" in the "Timeline" "block"
And I should see "Test feedback 2 closes" in the "Timeline" "block"
And I should see "Test feedback 3 closes" in the "Timeline" "block"
And I should see "Test assign 1 is due" in the "Timeline" "block"
And I should not see "More courses" in the "Timeline" "block"
And I should not see "Course 4" in the "Timeline" "block"
And I should not see "Test choice 2 closes" in the "Timeline" "block"
And I should not see "Test feedback 4 closes" in the "Timeline" "block"