Merge branch 'MDL-73613-master' of git://github.com/mickhawkins/moodle

This commit is contained in:
Jun Pataleta
2022-02-22 12:25:28 +08:00
9 changed files with 171 additions and 11 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
define ("block_timeline/view_courses",["jquery","core/notification","core/custom_interaction_events","core/templates","block_timeline/event_list","core_course/repository","block_timeline/calendar_events_repository","core/pending"],function(a,b,c,d,e,f,g,h){var i={MORE_COURSES_BUTTON:"[data-action=\"more-courses\"]",MORE_COURSES_BUTTON_CONTAINER:"[data-region=\"more-courses-button-container\"]",NO_COURSES_EMPTY_MESSAGE:"[data-region=\"no-courses-empty-message\"]",NO_COURSES_WITH_EVENTS_MESSAGE:"[data-region=\"no-events-empty-message\"]",COURSES_LIST:"[data-region=\"courses-list\"]",COURSE_ITEMS_LOADING_PLACEHOLDER:"[data-region=\"course-items-loading-placeholder\"]",COURSE_EVENTS_CONTAINER:"[data-region=\"course-events-container\"]",COURSE_NAME:"[data-region=\"course-name\"]",LOADING_ICON:".loading-icon",TIMELINE_BLOCK:"[data-region=\"timeline\"]",TIMELINE_SEARCH:"[data-action=\"search\"]"},j={COURSE_ITEMS:"block_timeline/course-items",LOADING_ICON:"core/loading"},k=86400,l={courseview:!0},m=function(a){a.find(i.COURSE_ITEMS_LOADING_PLACEHOLDER).addClass("hidden")},n=function(a){a.find(i.COURSE_ITEMS_LOADING_PLACEHOLDER).removeClass("hidden")},o=function(a){a.find(i.MORE_COURSES_BUTTON_CONTAINER).addClass("hidden")},p=function(a){a.find(i.MORE_COURSES_BUTTON_CONTAINER).removeClass("hidden")},q=function(a){var b=a.find(i.MORE_COURSES_BUTTON);b.prop("disabled",!0);d.render(j.LOADING_ICON,{}).then(function(a){b.append(a);return a}).catch(function(){return!1})},r=function(a){var b=a.find(i.MORE_COURSES_BUTTON);b.prop("disabled",!1);b.find(i.LOADING_ICON).remove()},s=function(a){var b=a.find(i.COURSES_LIST);d.replaceNodeContents(b,"","");a.find(i.NO_COURSES_WITH_EVENTS_MESSAGE).removeClass("hidden")},t=function(a){a.find(i.NO_COURSES_WITH_EVENTS_MESSAGE).addClass("hidden")},u=function(a,b){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:!1,e=a.find(i.COURSES_LIST);if(c){d.appendNodeContents(e,b,"")}else{d.replaceNodeContents(e,b,"")}},v=function(a){return parseInt(a.attr("data-offset"),10)},w=function(a,b){a.attr("data-offset",b)},x=function(a){return parseInt(a.attr("data-limit"),10)},y=function(a){return parseInt(a.attr("data-days-offset"),10)},z=function(a){var b=a.attr("data-days-limit");return b!=void 0?parseInt(b,10):void 0},A=function(a){return parseInt(a.attr("data-midnight"),10)},B=function(a){var b=A(a),c=y(a);return b+c*k},C=function(a){var b=A(a),c=z(a);return c!=void 0?b+c*k:null},D=function(a,b,c,d,e){var f={courseids:a,starttime:b,limit:c};if(d){f.endtime=d}if(e){f.searchvalue=e}return g.queryByCourses(f)},E=function(a){return a.data("last-event-load-time")},F=function(a,b){a.data("last-event-load-time",b)},G=function(a,b){return E(a)>b},H=function(a,b,c,d){var e=a.map(function(a){return a.id});return D(e,b,5+1,c,d)},I=function(a,b,c,e,f,g){return d.render(j.COURSE_ITEMS,{courses:a,midnight:c,hasdaysoffset:!0,hasdayslimit:f!=void 0,daysoffset:e,dayslimit:f,nodayslimit:f==void 0,courseview:!0,hascourses:!0}).then(function(a){m(b);if(a){u(b,a,g)}return a}).then(function(c){if(a.length<2){o(b)}else{p(b)}return c}).catch(function(){m(b)})},J=function(c){var d=1<arguments.length&&arguments[1]!==void 0?arguments[1]:!1,g=new h("block/timeline:load-more-courses"),j=v(c),k=x(c),m=B(c),n=C(c),q=c.closest(i.TIMELINE_BLOCK).find(i.TIMELINE_SEARCH).val();return f.getEnrolledCoursesWithEventsByTimelineClassification("inprogress",k,j,"fullname asc",q,m,n).then(function(b){var f=Date.now(),g=b.courses,h=b.nextoffset,i=y(c),k=z(c),r=A(c),t=b.morecoursesavailable;w(c,h);var u=H(g,m,n,q),v=I(g,c,r,i,k,d);return a.when(u,v).then(function(a){if(G(c,f)){return a}if(0<g.length){g.forEach(function(a){var b=a.id,d=c.find("[data-region=\"course-events-container\"][data-course-id=\""+b+"\"]"),f=d.find(e.rootSelector);e.init(f,l)});if(!t){o(c)}else{p(c)}}else{o(c);if(0==j){s(c)}}return a})}).then(function(){return g.resolve()}).catch(b.exception)},K=function(a){c.define(a,[c.events.activate]);a.on(c.events.activate,i.MORE_COURSES_BUTTON,function(b,c){q(a);J(a,!0).then(function(){r(a)}).catch(function(){r(a)});if(c){c.originalEvent.preventDefault();c.originalEvent.stopPropagation()}b.stopPropagation()})},L=function(a){if(!a.attr("data-seen")&&!a.find(i.NO_COURSES_EMPTY_MESSAGE).length){J(a);a.attr("data-seen",!0)}};return{init:function init(b){b=a(b);if(!b.find(i.NO_COURSES_EMPTY_MESSAGE).length){F(b,Date.now());if(b.hasClass("active")){J(b);b.attr("data-seen",!0)}K(b)}},reset:function reset(a){w(a,0);n(a);t(a);a.removeAttr("data-seen");if(a.hasClass("active")){L(a)}},shown:L}});
define ("block_timeline/view_courses",["jquery","core/notification","core/custom_interaction_events","core/templates","block_timeline/event_list","core_course/repository","block_timeline/calendar_events_repository","core/pending"],function(a,b,c,d,e,f,g,h){var i={MORE_COURSES_BUTTON:"[data-action=\"more-courses\"]",MORE_COURSES_BUTTON_CONTAINER:"[data-region=\"more-courses-button-container\"]",NO_COURSES_EMPTY_MESSAGE:"[data-region=\"no-courses-empty-message\"]",NO_COURSES_WITH_EVENTS_MESSAGE:"[data-region=\"no-events-empty-message\"]",COURSES_LIST:"[data-region=\"courses-list\"]",COURSE_ITEMS_LOADING_PLACEHOLDER:"[data-region=\"course-items-loading-placeholder\"]",COURSE_EVENTS_CONTAINER:"[data-region=\"course-events-container\"]",COURSE_NAME:"[data-region=\"course-name\"]",LOADING_ICON:".loading-icon",TIMELINE_BLOCK:"[data-region=\"timeline\"]",TIMELINE_SEARCH:"[data-action=\"search\"]"},j={COURSE_ITEMS:"block_timeline/course-items",LOADING_ICON:"core/loading"},k=86400,l={courseview:!0},m=function(a){a.find(i.COURSE_ITEMS_LOADING_PLACEHOLDER).addClass("hidden")},n=function(a){a.find(i.COURSE_ITEMS_LOADING_PLACEHOLDER).removeClass("hidden")},o=function(a){a.find(i.MORE_COURSES_BUTTON_CONTAINER).addClass("hidden")},p=function(a){a.find(i.MORE_COURSES_BUTTON_CONTAINER).removeClass("hidden")},q=function(a){var b=a.find(i.MORE_COURSES_BUTTON);b.prop("disabled",!0);d.render(j.LOADING_ICON,{}).then(function(a){b.append(a);return a}).catch(function(){return!1})},r=function(a){var b=a.find(i.MORE_COURSES_BUTTON);b.prop("disabled",!1);b.find(i.LOADING_ICON).remove()},s=function(a){var b=a.find(i.COURSES_LIST);d.replaceNodeContents(b,"","");a.find(i.NO_COURSES_WITH_EVENTS_MESSAGE).removeClass("hidden")},t=function(a){a.find(i.NO_COURSES_WITH_EVENTS_MESSAGE).addClass("hidden")},u=function(a,b){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:!1,e=a.find(i.COURSES_LIST);if(c){d.appendNodeContents(e,b,"")}else{d.replaceNodeContents(e,b,"")}},v=function(a){return parseInt(a.attr("data-offset"),10)},w=function(a,b){a.attr("data-offset",b)},x=function(a){return parseInt(a.attr("data-limit"),10)},y=function(a){return parseInt(a.attr("data-days-offset"),10)},z=function(a){var b=a.attr("data-days-limit");return b!=void 0?parseInt(b,10):void 0},A=function(a){return parseInt(a.attr("data-midnight"),10)},B=function(a){var b=A(a),c=y(a);return b+c*k},C=function(a){var b=null;if(a.attr("data-filter-overdue")){b=Math.floor(Date.now()/1e3)}else{var c=A(a),d=z(a);if(d!=void 0){b=c+d*k}}return b},D=function(a,b,c,d,e){var f={courseids:a,starttime:b,limit:c};if(d){f.endtime=d}if(e){f.searchvalue=e}return g.queryByCourses(f)},E=function(a){return a.data("last-event-load-time")},F=function(a,b){a.data("last-event-load-time",b)},G=function(a,b){return E(a)>b},H=function(a,b,c,d){var e=a.map(function(a){return a.id});return D(e,b,5+1,c,d)},I=function(a,b,c,e,f,g){return d.render(j.COURSE_ITEMS,{courses:a,midnight:c,hasdaysoffset:!0,hasdayslimit:f!=void 0,daysoffset:e,dayslimit:f,nodayslimit:f==void 0,courseview:!0,hascourses:!0}).then(function(a){m(b);if(a){u(b,a,g)}return a}).then(function(c){if(a.length<2){o(b)}else{p(b)}return c}).catch(function(){m(b)})},J=function(c){var d=1<arguments.length&&arguments[1]!==void 0?arguments[1]:!1,g=new h("block/timeline:load-more-courses"),j=v(c),k=x(c),m=B(c),n=C(c),q=c.closest(i.TIMELINE_BLOCK).find(i.TIMELINE_SEARCH).val();return f.getEnrolledCoursesWithEventsByTimelineClassification("inprogress",k,j,"fullname asc",q,m,n).then(function(b){var f=Date.now(),g=b.courses,h=b.nextoffset,i=y(c),k=z(c),r=A(c),t=b.morecoursesavailable;w(c,h);var u=H(g,m,n,q),v=I(g,c,r,i,k,d);return a.when(u,v).then(function(a){if(G(c,f)){return a}if(0<g.length){g.forEach(function(a){var b=a.id,d=c.find("[data-region=\"course-events-container\"][data-course-id=\""+b+"\"]"),f=d.find(e.rootSelector);e.init(f,l)});if(!t){o(c)}else{p(c)}}else{o(c);if(0==j){s(c)}}return a})}).then(function(){return g.resolve()}).catch(b.exception)},K=function(a){c.define(a,[c.events.activate]);a.on(c.events.activate,i.MORE_COURSES_BUTTON,function(b,c){q(a);J(a,!0).then(function(){r(a)}).catch(function(){r(a)});if(c){c.originalEvent.preventDefault();c.originalEvent.stopPropagation()}b.stopPropagation()})},L=function(a){if(!a.attr("data-seen")&&!a.find(i.NO_COURSES_EMPTY_MESSAGE).length){J(a);a.attr("data-seen",!0)}};return{init:function init(b){b=a(b);if(!b.find(i.NO_COURSES_EMPTY_MESSAGE).length){F(b,Date.now());if(b.hasClass("active")){J(b);b.attr("data-seen",!0)}K(b)}},reset:function reset(a){w(a,0);n(a);t(a);a.removeAttr("data-seen");if(a.hasClass("active")){L(a)}},shown:L}});
//# sourceMappingURL=view_courses.min.js.map
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,2 +1,2 @@
define ("block_timeline/view_nav",["jquery","core/custom_interaction_events","block_timeline/view","core/ajax","core/notification","core/utils"],function(a,b,c,d,e,f){var g={TIMELINE_DAY_FILTER:"[data-region=\"day-filter\"]",TIMELINE_DAY_FILTER_OPTION:"[data-from]",TIMELINE_VIEW_SELECTOR:"[data-region=\"view-selector\"]",DATA_DAYS_OFFSET:"[data-days-offset]",DATA_DAYS_LIMIT:"[data-days-limit]",TIMELINE_SEARCH_INPUT:"[data-action=\"search\"]",TIMELINE_SEARCH_CLEAR_ICON:"[data-action=\"clearsearch\"]",NO_COURSES_EMPTY_MESSAGE:"[data-region=\"no-courses-empty-message\"]"},h=function(a,b){d.call([{methodname:"core_user_update_user_preferences",args:{preferences:[{type:a,value:b}]}}])[0].fail(e.exception)},i=function(d,f){var i=d.find(g.TIMELINE_DAY_FILTER);b.define(i,[b.events.activate]);i.on(b.events.activate,g.TIMELINE_DAY_FILTER_OPTION,function(b,e){var i=a(b.currentTarget).data("filtername");h("block_timeline_user_filter_preference",i);var j=a(b.target).closest(g.TIMELINE_DAY_FILTER_OPTION);if("true"==j.attr("aria-current")){return}var k=j.attr("data-from"),l=j.attr("data-to"),m=d.find(g.DATA_DAYS_OFFSET);m.attr("data-days-offset",k);if(l!=void 0){m.attr("data-days-limit",l)}else{m.removeAttr("data-days-limit")}c.reset(f);e.originalEvent.preventDefault()})},j=function(d,f){var i=d.find(g.TIMELINE_VIEW_SELECTOR);i.on("shown shown.bs.tab",function(b){c.shown(f);a(b.target).removeClass("active")});b.define(i,[b.events.activate]);i.on(b.events.activate,"[data-toggle='tab']",function(b){var c=a(b.currentTarget).data("filtername");h("block_timeline_user_sort_preference",c)})},k=function(a,b){var c=a.find(g.TIMELINE_SEARCH_INPUT),d=a.find(g.TIMELINE_SEARCH_CLEAR_ICON);c.on("input",f.debounce(function(){if(""!==c.val()){l(d,b)}else{m(d,b)}},300));d.on("click",function(){c.val("");m(d,b);c.focus()})},l=function(a,b){a.removeClass("d-none");c.reset(b)},m=function(a,b){a.addClass("d-none");c.reset(b)};return{init:function init(b,c){b=a(b);j(b,c);if(!b.find(g.NO_COURSES_EMPTY_MESSAGE).length){i(b,c);k(b,c)}}}});
define ("block_timeline/view_nav",["jquery","core/custom_interaction_events","block_timeline/view","core/ajax","core/notification","core/utils"],function(a,b,c,d,e,f){var g={TIMELINE_DAY_FILTER:"[data-region=\"day-filter\"]",TIMELINE_DAY_FILTER_OPTION:"[data-from]",TIMELINE_VIEW_SELECTOR:"[data-region=\"view-selector\"]",DATA_DAYS_OFFSET:"[data-days-offset]",DATA_DAYS_LIMIT:"[data-days-limit]",TIMELINE_SEARCH_INPUT:"[data-action=\"search\"]",TIMELINE_SEARCH_CLEAR_ICON:"[data-action=\"clearsearch\"]",NO_COURSES_EMPTY_MESSAGE:"[data-region=\"no-courses-empty-message\"]"},h=function(a,b){d.call([{methodname:"core_user_update_user_preferences",args:{preferences:[{type:a,value:b}]}}])[0].fail(e.exception)},i=function(d,f){var i=d.find(g.TIMELINE_DAY_FILTER);b.define(i,[b.events.activate]);i.on(b.events.activate,g.TIMELINE_DAY_FILTER_OPTION,function(b,e){var i=a(b.currentTarget).data("filtername");h("block_timeline_user_filter_preference",i);var j=a(b.target).closest(g.TIMELINE_DAY_FILTER_OPTION);if("true"==j.attr("aria-current")){return}var k=j.attr("data-from"),l=j.attr("data-to"),m=d.find(g.DATA_DAYS_OFFSET);m.attr("data-days-offset",k);if(l!=void 0){m.attr("data-days-limit",l)}else{m.removeAttr("data-days-limit")}if("overdue"===j.attr("data-filtername")){m.attr("data-filter-overdue",!0)}else{m.removeAttr("data-filter-overdue")}c.reset(f);e.originalEvent.preventDefault()})},j=function(d,f){var i=d.find(g.TIMELINE_VIEW_SELECTOR);i.on("shown shown.bs.tab",function(b){c.shown(f);a(b.target).removeClass("active")});b.define(i,[b.events.activate]);i.on(b.events.activate,"[data-toggle='tab']",function(b){var c=a(b.currentTarget).data("filtername");h("block_timeline_user_sort_preference",c)})},k=function(a,b){var c=a.find(g.TIMELINE_SEARCH_INPUT),d=a.find(g.TIMELINE_SEARCH_CLEAR_ICON);c.on("input",f.debounce(function(){if(""!==c.val()){l(d,b)}else{m(d,b)}},300));d.on("click",function(){c.val("");m(d,b);c.focus()})},l=function(a,b){a.removeClass("d-none");c.reset(b)},m=function(a,b){a.addClass("d-none");c.reset(b)};return{init:function init(b,c){b=a(b);j(b,c);if(!b.find(g.NO_COURSES_EMPTY_MESSAGE).length){i(b,c);k(b,c)}}}});
//# sourceMappingURL=view_nav.min.js.map
File diff suppressed because one or more lines are too long
+16 -4
View File
@@ -254,15 +254,27 @@ function(
/**
* Return the end time for fetching events. This is calculated
* based on the user's midnight value so that timezones are
* preserved.
* preserved, unless filtering by overdue, where the current UNIX timestamp is used.
*
* @param {object} root The rool element.
* @return {Number}
*/
var getEndTime = function(root) {
var midnight = getMidnight(root);
var daysLimit = getDaysLimit(root);
return daysLimit != undefined ? midnight + (daysLimit * SECONDS_IN_DAY) : null;
let endTime = null;
if (root.attr('data-filter-overdue')) {
// If filtering by overdue, end time will be the current timestamp in seconds.
endTime = Math.floor(Date.now() / 1000);
} else {
const midnight = getMidnight(root);
const daysLimit = getDaysLimit(root);
if (daysLimit != undefined) {
endTime = midnight + (daysLimit * SECONDS_IN_DAY);
}
}
return endTime;
};
/**
+6
View File
@@ -110,6 +110,12 @@ function(
elementsWithDaysOffset.removeAttr('data-days-limit');
}
if (option.attr('data-filtername') === 'overdue') {
elementsWithDaysOffset.attr('data-filter-overdue', true);
} else {
elementsWithDaysOffset.removeAttr('data-filter-overdue');
}
// Reset the views to reinitialise the event lists now that we've
// updated the day limits.
View.reset(timelineViewRoot);
+3 -1
View File
@@ -44,7 +44,8 @@
"daysoffset": -14,
"dayslimit": false,
"limit": 0,
"hascourses": true
"hascourses": true,
"overdue": false
}
}}
<div data-region="timeline-view">
@@ -61,6 +62,7 @@
data-days-limit="{{dayslimit}}"
data-days-offset="{{daysoffset}}"
data-no-events-url="{{urls.noevents}}"
{{#overdue}}data-filter-overdue="{{overdue}}"{{/overdue}}
id="view_courses_{{uniqid}}"
>
{{> block_timeline/view-courses }}
@@ -15,6 +15,7 @@ Feature: The timeline block allows users to see upcoming courses
| Course 2 | C2 | 0 | ##yesterday## | ##tomorrow## |
| Course 3 | C3 | 0 | ##yesterday## | ##tomorrow## |
| Course 4 | C4 | 0 | ##first day of next month## | ##last day of next month## |
| Course 5 | C5 | 0 | ##yesterday## | ##tomorrow## |
And the following "activities" exist:
| activity | course | idnumber | name | intro | timeopen | timeclose |
| choice | C2 | choice1 | Test choice 1 | Test choice description | ##yesterday## | ##tomorrow## |
@@ -192,7 +193,13 @@ Feature: The timeline block allows users to see upcoming courses
And I should not see "Test choice 1"
Scenario: Only courses with matching events are displayed and are refreshed when filtering changes
Given I log in as "student1"
Given the following "activities" exist:
| activity | course | idnumber | name | intro | timeopen | duedate |
| assign | C5 | assign3 | Test assign 3 | Test assign description | ##yesterday## | ##now +1 minute## |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C5 | student |
When 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 by date" "button" in the "Timeline" "block"
@@ -201,30 +208,38 @@ Feature: The timeline block allows users to see upcoming courses
And I should see "Course 1" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 3" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 5" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 4" in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 1" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 2" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 3" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test choice 1" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test choice 3" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test feedback 5" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
When I click on "Overdue" "link" in the "Timeline" "block"
And I click on "Overdue" "link" in the "Timeline" "block"
Then I should see "Course 1" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 3" in the "Timeline" "block"
And I should not see "Course 5" in the "Timeline" "block"
And I should not see "Show more courses" in the "Timeline" "block"
And "Test assign 1" "link" should exist in the "Timeline" "block"
And "Test assign 2" "link" should exist in the "Timeline" "block"
And "Test assign 3" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test choice 1" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test choice 2" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test choice 3" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test feedback 5" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And I click on "Filter timeline by date" "button" in the "Timeline" "block"
And I click on "Next 7 days" "link" in the "Timeline" "block"
And I click on "Show more courses" "button" in the "Timeline" "block"
And I should see "Course 1" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 5" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 3" in the "Timeline" "block"
And I should not see "Show more courses" in the "Timeline" "block"
And "Test assign 2" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 3" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test choice 1" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test feedback 5" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 1" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
@@ -0,0 +1,125 @@
@block @block_timeline @javascript
Feature: The timeline block allows users to see courses with overdue activities
In order to view overdue activities in the timeline block
As a student
I can select the overdue filter in courses view
Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| student1 | Student | 1 | student1@example.com | S1 |
And the following "courses" exist:
| fullname | shortname | category | startdate | enddate |
| Course 1 | C1 | 0 | ##now -3 months## | ##tomorrow## |
| Course 2 | C2 | 0 | ##yesterday## | ##tomorrow## |
| Course 3 | C3 | 0 | ##yesterday## | ##tomorrow## |
| Course 4 | C4 | 0 | ##yesterday## | ##tomorrow## |
| Course 5 | C5 | 0 | ##yesterday## | ##tomorrow## |
| Course 6 | C6 | 0 | ##yesterday## | ##tomorrow## |
And the following "activities" exist:
| activity | course | idnumber | name | intro | timeopen | duedate |
| assign | C1 | assign1 | Test assign 1 | Assign due last month | ##now -2 months## | ##now -1 month## |
| assign | C2 | assign2 | Test assign 2 | Assign due yesterday | ##now -2 days## | ##yesterday## |
| assign | C3 | assign3 | Test assign 3 | Assign due yesterday | ##now -2 days## | ##yesterday## |
| assign | C4 | assign4 | Test assign 4 | Assign due later today | ##yesterday## | ##now +10 minutes## |
| assign | C5 | assign5 | Test assign 5 | Assign due yesterday | ##now -2 days## | ##yesterday## |
| assign | C6 | assign6 | Test assign 6 | Assign due tomorrow | ##yesterday## | ##tomorrow## |
Scenario: No activities to display as overdue displays expected message
Given the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| student1 | C4 | student |
| student1 | C6 | student |
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 by date" "button" in the "Timeline" "block"
When I click on "Overdue" "link" in the "Timeline" "block"
Then I should see "No activities require action" in the "Timeline" "block"
And I reload the page
And I should see "No activities require action" in the "Timeline" "block"
Scenario: If filtering by overdue, only courses with a matching item are included
Given the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| student1 | C2 | student |
| student1 | C4 | student |
| student1 | C5 | student |
| student1 | C6 | student |
When 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 by date" "button" in the "Timeline" "block"
And I click on "Overdue" "link" in the "Timeline" "block"
Then I should not see "Show more courses" in the "Timeline" "block"
And I should see "Course 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 5" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 1" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 3" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 4" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 6" in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 2" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 5" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 1" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 3" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 4" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 6" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And I reload the page
And I should not see "Show more courses" in the "Timeline" "block"
And I should see "Course 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 5" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 1" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 3" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 4" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 6" in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 2" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 5" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 1" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 3" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 4" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 6" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
Scenario: If filtering by overdue, only courses with a matching item are included and loading more is supported
Given the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| student1 | C2 | student |
| student1 | C3 | student |
| student1 | C4 | student |
| student1 | C5 | student |
| student1 | C6 | student |
When 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 by date" "button" in the "Timeline" "block"
And I click on "Overdue" "link" in the "Timeline" "block"
And I click on "Show more courses" "button" in the "Timeline" "block"
Then I should see "Course 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 3" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 5" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 1" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 4" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 6" in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 2" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 3" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 5" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 1" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 4" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 6" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Show more courses" in the "Timeline" "block"
And I reload the page
And I click on "Show more courses" "button" in the "Timeline" "block"
And I should see "Course 2" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 3" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should see "Course 5" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 1" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 4" in the ".block-timeline [data-region='view-courses']" "css_element"
And I should not see "Course 6" in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 2" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 3" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 5" "link" should exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 1" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 4" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"
And "Test assign 6" "link" should not exist in the ".block-timeline [data-region='view-courses']" "css_element"