diff --git a/blocks/timeline/amd/build/event_list.min.js b/blocks/timeline/amd/build/event_list.min.js index 076f5bf9470..3703214d397 100644 --- a/blocks/timeline/amd/build/event_list.min.js +++ b/blocks/timeline/amd/build/event_list.min.js @@ -1,2 +1,2 @@ -define ("block_timeline/event_list",["jquery","core/notification","core/templates","core/paged_content_factory","core/str","core/user_date","block_timeline/calendar_events_repository"],function(a,b,c,d,e,f,g){var h=!1,i={EMPTY_MESSAGE:"[data-region=\"empty-message\"]",ROOT:"[data-region=\"event-list-container\"]",EVENT_LIST_CONTENT:"[data-region=\"event-list-content\"]",EVENT_LIST_LOADING_PLACEHOLDER:"[data-region=\"event-list-loading-placeholder\"]",TIMELINE_BLOCK:"[data-region=\"timeline\"]",TIMELINE_SEARCH:"[data-region=\"search-input\"]"},j={EVENT_LIST_CONTENT:"block_timeline/event-list-content"},k={ignoreControlWhileLoading:!0,controlPlacementBottom:!0,ariaLabels:{itemsperpagecomponents:"ariaeventlistpagelimit, block_timeline"}},l=function(a){a.find(i.EVENT_LIST_CONTENT).addClass("hidden");a.find(i.EMPTY_MESSAGE).removeClass("hidden")},m=function(a){a.find(i.EVENT_LIST_CONTENT).removeClass("hidden");a.find(i.EMPTY_MESSAGE).addClass("hidden")},n=function(a){a.find(i.EVENT_LIST_CONTENT).empty()},o=function(a,b){var c={},d={courseview:h,eventsbyday:[]};a.forEach(function(a){var b=a.timeusermidnight;if(c[b]){c[b].push(a)}else{c[b]=[a]}});Object.keys(c).forEach(function(a){var e=c[a];d.eventsbyday.push({past:ac}return!0}),e=d.length<=l;if(e){b.allItemsLoaded(k)}else{d.pop()}return d})},s=function(c,f,g,h,i,j,l,m,n,o){var q={1:0},s=!1,t=a.extend({},k,n);return e.get_string("ariaeventlistpagelimit","block_timeline",a.isArray(c)?c[0].value:c).then(function(a){t.ariaLabels.itemsperpage=a;t.ariaLabels.paginationnav=m;return a}).then(function(){return d.createWithLimit(c,function(c,d){var e=[];c.forEach(function(a){var c=a.pageNumber,h=r(a,d,g,q,f,i,j,l,o).then(function(a){if(a.length){s=!0;var b=a[a.length-1].id;q[c+1]=b;return p(a,g)}else{return a}}).catch(b.exception);e.push(h)});a.when.apply(a,e).then(function(){h.resolve(s)}).catch(function(){h.resolve(s)});return e},t)})};return{init:function init(d,e,f,g){var j=4c}return!e||a.overdue}),h=g.length<=l;if(h){b.allItemsLoaded(k)}else{g.pop()}return g})},s=function(c,f,g,h,i,j,l,m,n,o){var q={1:0},s=!1,t=a.extend({},k,n);return e.get_string("ariaeventlistpagelimit","block_timeline",a.isArray(c)?c[0].value:c).then(function(a){t.ariaLabels.itemsperpage=a;t.ariaLabels.paginationnav=m;return a}).then(function(){return d.createWithLimit(c,function(c,d){var e=[];c.forEach(function(a){var c=a.pageNumber,h=r(a,d,g,q,f,i,j,l,o).then(function(a){if(a.length){s=!0;var b=a[a.length-1].id;q[c+1]=b;return p(a)}else{return a}}).catch(b.exception);e.push(h)});a.when.apply(a,e).then(function(){h.resolve(s)}).catch(function(){h.resolve(s)});return e},t)})};return{init:function init(d,e,f,g){var j=4.\n\n/**\n * Javascript to load and render the list of calendar events for a\n * given day range.\n *\n * @module block_timeline/event_list\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(\n[\n 'jquery',\n 'core/notification',\n 'core/templates',\n 'core/paged_content_factory',\n 'core/str',\n 'core/user_date',\n 'block_timeline/calendar_events_repository'\n],\nfunction(\n $,\n Notification,\n Templates,\n PagedContentFactory,\n Str,\n UserDate,\n CalendarEventsRepository\n) {\n\n var SECONDS_IN_DAY = 60 * 60 * 24;\n var courseview = false;\n\n var SELECTORS = {\n EMPTY_MESSAGE: '[data-region=\"empty-message\"]',\n ROOT: '[data-region=\"event-list-container\"]',\n EVENT_LIST_CONTENT: '[data-region=\"event-list-content\"]',\n EVENT_LIST_LOADING_PLACEHOLDER: '[data-region=\"event-list-loading-placeholder\"]',\n TIMELINE_BLOCK: '[data-region=\"timeline\"]',\n TIMELINE_SEARCH: '[data-region=\"search-input\"]'\n };\n\n var TEMPLATES = {\n EVENT_LIST_CONTENT: 'block_timeline/event-list-content'\n };\n\n // We want the paged content controls below the paged content area\n // and the controls should be ignored while data is loading.\n var DEFAULT_PAGED_CONTENT_CONFIG = {\n ignoreControlWhileLoading: true,\n controlPlacementBottom: true,\n ariaLabels: {\n itemsperpagecomponents: 'ariaeventlistpagelimit, block_timeline',\n }\n };\n\n /**\n * Hide the content area and display the empty content message.\n *\n * @param {object} root The container element\n */\n var hideContent = function(root) {\n root.find(SELECTORS.EVENT_LIST_CONTENT).addClass('hidden');\n root.find(SELECTORS.EMPTY_MESSAGE).removeClass('hidden');\n };\n\n /**\n * Show the content area and hide the empty content message.\n *\n * @param {object} root The container element\n */\n var showContent = function(root) {\n root.find(SELECTORS.EVENT_LIST_CONTENT).removeClass('hidden');\n root.find(SELECTORS.EMPTY_MESSAGE).addClass('hidden');\n };\n\n /**\n * Empty the content area.\n *\n * @param {object} root The container element\n */\n var emptyContent = function(root) {\n root.find(SELECTORS.EVENT_LIST_CONTENT).empty();\n };\n\n /**\n * Construct the template context from a list of calendar events. The events\n * are grouped by which day they are on. The day is calculated from the user's\n * midnight timestamp to ensure that the calculation is timezone agnostic.\n *\n * The return data structure will look like:\n * {\n * eventsbyday: [\n * {\n * dayTimestamp: 1533744000,\n * events: [\n * { ...event 1 data... },\n * { ...event 2 data... }\n * ]\n * },\n * {\n * dayTimestamp: 1533830400,\n * events: [\n * { ...event 3 data... },\n * { ...event 4 data... }\n * ]\n * }\n * ]\n * }\n *\n * Each day timestamp is the day's midnight in the user's timezone.\n *\n * @param {array} calendarEvents List of calendar events\n * @param {Number} midnight A timestamp representing midnight in the user's timezone\n * @return {object}\n */\n var buildTemplateContext = function(calendarEvents, midnight) {\n var eventsByDay = {};\n var templateContext = {\n courseview,\n eventsbyday: []\n };\n\n calendarEvents.forEach(function(calendarEvent) {\n var dayTimestamp = calendarEvent.timeusermidnight;\n if (eventsByDay[dayTimestamp]) {\n eventsByDay[dayTimestamp].push(calendarEvent);\n } else {\n eventsByDay[dayTimestamp] = [calendarEvent];\n }\n });\n\n Object.keys(eventsByDay).forEach(function(dayTimestamp) {\n var events = eventsByDay[dayTimestamp];\n templateContext.eventsbyday.push({\n past: dayTimestamp < midnight,\n dayTimestamp: dayTimestamp,\n events: events\n });\n });\n\n return templateContext;\n };\n\n /**\n * Render the HTML for the given calendar events.\n *\n * @param {array} calendarEvents A list of calendar events\n * @param {Number} midnight A timestamp representing midnight for the user\n * @return {promise} Resolved with HTML and JS strings.\n */\n var render = function(calendarEvents, midnight) {\n var templateContext = buildTemplateContext(calendarEvents, midnight);\n var templateName = TEMPLATES.EVENT_LIST_CONTENT;\n\n return Templates.render(templateName, templateContext);\n };\n\n /**\n * Retrieve a list of calendar events from the server for the given\n * constraints.\n *\n * @param {Number} midnight The user's midnight time in unix timestamp.\n * @param {Number} limit Limit the result set to this number of items\n * @param {Number} daysOffset How many days (from midnight) to offset the results from\n * @param {int|undefined} daysLimit How many dates (from midnight) to limit the result to\n * @param {int|false} lastId The ID of the last seen event (if any)\n * @param {int|undefined} courseId Course ID to restrict events to\n * @param {string|undefined} searchValue Search value\n * @return {Promise} A jquery promise\n */\n var load = function(midnight, limit, daysOffset, daysLimit, lastId, courseId, searchValue) {\n var startTime = midnight + (daysOffset * SECONDS_IN_DAY);\n var endTime = daysLimit != undefined ? midnight + (daysLimit * SECONDS_IN_DAY) : false;\n\n var args = {\n starttime: startTime,\n limit: limit,\n };\n\n if (lastId) {\n args.aftereventid = lastId;\n }\n\n if (endTime) {\n args.endtime = endTime;\n }\n\n if (searchValue) {\n args.searchvalue = searchValue;\n }\n\n if (courseId) {\n // If we have a course id then we only want events from that course.\n args.courseid = courseId;\n return CalendarEventsRepository.queryByCourse(args);\n } else {\n // Otherwise we want events from any course.\n return CalendarEventsRepository.queryByTime(args);\n }\n };\n\n /**\n * Handle a single page request from the paged content. Uses the given page data to request\n * the events from the server.\n *\n * Checks the given preloadedPages before sending a request to the server to make sure we\n * don't load data unnecessarily.\n *\n * @param {object} pageData A single page data (see core/paged_content_pages for more info).\n * @param {object} actions Paged content actions (see core/paged_content_pages for more info).\n * @param {Number} midnight The user's midnight time in unix timestamp.\n * @param {object} lastIds The last event ID for each loaded page. Page number is key, id is value.\n * @param {object} preloadedPages An object of preloaded page data. Page number as key, data promise as value.\n * @param {int|undefined} courseId Course ID to restrict events to\n * @param {Number} daysOffset How many days (from midnight) to offset the results from\n * @param {int|undefined} daysLimit How many dates (from midnight) to limit the result to\n * @param {string|undefined} searchValue Search value\n * @return {object} jQuery promise resolved with calendar events.\n */\n var loadEventsFromPageData = function(\n pageData,\n actions,\n midnight,\n lastIds,\n preloadedPages,\n courseId,\n daysOffset,\n daysLimit,\n searchValue\n ) {\n var pageNumber = pageData.pageNumber;\n var limit = pageData.limit;\n var lastPageNumber = pageNumber;\n\n // This is here to protect us if, for some reason, the pages\n // are loaded out of order somehow and we don't have a reference\n // to the previous page. In that case, scan back to find the most\n // recent page we've seen.\n while (!lastIds.hasOwnProperty(lastPageNumber)) {\n lastPageNumber--;\n }\n // Use the last id of the most recent page.\n var lastId = lastIds[lastPageNumber];\n var eventsPromise = null;\n\n if (preloadedPages && preloadedPages.hasOwnProperty(pageNumber)) {\n // This page has been preloaded so use that rather than load the values\n // again.\n eventsPromise = preloadedPages[pageNumber];\n } else {\n // Load one more than the given limit so that we can tell if there\n // is more content to load after this.\n eventsPromise = load(midnight, limit + 1, daysOffset, daysLimit, lastId, courseId, searchValue);\n }\n\n return eventsPromise.then(function(result) {\n if (!result.events.length) {\n // If we didn't get any events back then tell the paged content\n // that we're done loading.\n actions.allItemsLoaded(pageNumber);\n return [];\n }\n\n var calendarEvents = result.events.filter(function(event) {\n if (event.eventtype == \"open\" || event.eventtype == \"opensubmission\") {\n var dayTimestamp = UserDate.getUserMidnightForTimestamp(event.timesort, midnight);\n return dayTimestamp > midnight;\n }\n return true;\n });\n // We expect to receive limit + 1 events back from the server.\n // Any less means there are no more events to load.\n var loadedAll = calendarEvents.length <= limit;\n\n if (loadedAll) {\n // Tell the pagination that everything is loaded.\n actions.allItemsLoaded(pageNumber);\n } else {\n // Remove the last element from the array because it isn't\n // needed in this result set.\n calendarEvents.pop();\n }\n\n return calendarEvents;\n });\n };\n\n /**\n * Use the paged content factory to create a paged content element for showing\n * the event list. We only provide a page limit to the factory because we don't\n * know exactly how many pages we'll need. This creates a paging bar with just\n * next/previous buttons.\n *\n * This function specifies the callback for loading the event data that the user\n * is requesting.\n *\n * @param {int|array} pageLimit A single limit or list of limits as options for the paged content\n * @param {object} preloadedPages An object of preloaded page data. Page number as key, data promise as value.\n * @param {Number} midnight The user's midnight time in unix timestamp.\n * @param {object} firstLoad A jQuery promise to be resolved after the first set of data is loaded.\n * @param {int|undefined} courseId Course ID to restrict events to\n * @param {Number} daysOffset How many days (from midnight) to offset the results from\n * @param {int|undefined} daysLimit How many dates (from midnight) to limit the result to\n * @param {string} paginationAriaLabel String to set as the aria label for the pagination bar.\n * @param {object} additionalConfig Additional config options to pass to pagedContentFactory\n * @param {string|undefined} searchValue Search value\n * @return {object} jQuery promise.\n */\n var createPagedContent = function(\n pageLimit,\n preloadedPages,\n midnight,\n firstLoad,\n courseId,\n daysOffset,\n daysLimit,\n paginationAriaLabel,\n additionalConfig,\n searchValue\n ) {\n // Remember the last event id we loaded on each page because we can't\n // use the offset value since the backend can skip events if the user doesn't\n // have the capability to see them. Instead we load the next page of events\n // based on the last seen event id.\n var lastIds = {'1': 0};\n var hasContent = false;\n var config = $.extend({}, DEFAULT_PAGED_CONTENT_CONFIG, additionalConfig);\n\n return Str.get_string(\n 'ariaeventlistpagelimit',\n 'block_timeline',\n $.isArray(pageLimit) ? pageLimit[0].value : pageLimit\n )\n .then(function(string) {\n config.ariaLabels.itemsperpage = string;\n config.ariaLabels.paginationnav = paginationAriaLabel;\n return string;\n })\n .then(function() {\n return PagedContentFactory.createWithLimit(\n pageLimit,\n function(pagesData, actions) {\n var promises = [];\n\n pagesData.forEach(function(pageData) {\n var pageNumber = pageData.pageNumber;\n // Load the page data.\n var pagePromise = loadEventsFromPageData(\n pageData,\n actions,\n midnight,\n lastIds,\n preloadedPages,\n courseId,\n daysOffset,\n daysLimit,\n searchValue\n ).then(function(calendarEvents) {\n if (calendarEvents.length) {\n // Remember that we've loaded content.\n hasContent = true;\n // Remember the last id we've seen.\n var lastEventId = calendarEvents[calendarEvents.length - 1].id;\n // Record the id that the next page will need to start from.\n lastIds[pageNumber + 1] = lastEventId;\n // Get the HTML and JS for these calendar events.\n return render(calendarEvents, midnight);\n } else {\n return calendarEvents;\n }\n })\n .catch(Notification.exception);\n\n promises.push(pagePromise);\n });\n\n $.when.apply($, promises).then(function() {\n // Tell the calling code that the first page has been loaded\n // and whether it contains any content.\n firstLoad.resolve(hasContent);\n return;\n })\n .catch(function() {\n firstLoad.resolve(hasContent);\n });\n\n return promises;\n },\n config\n );\n });\n };\n\n /**\n * Create a paged content region for the calendar events in the given root element.\n * The content of the root element are replaced with a new paged content section\n * each time this function is called.\n *\n * This function will be called each time the offset or limit values are changed to\n * reload the event list region.\n *\n * @param {object} root The event list container element\n * @param {int|array} pageLimit A single limit or list of limits as options for the paged content\n * @param {object} preloadedPages An object of preloaded page data. Page number as key, data promise as value.\n * @param {string} paginationAriaLabel String to set as the aria label for the pagination bar.\n * @param {object} additionalConfig Additional config options to pass to pagedContentFactory\n */\n var init = function(root, pageLimit, preloadedPages, paginationAriaLabel, additionalConfig = {}) {\n root = $(root);\n\n courseview = !!additionalConfig.courseview;\n\n // Create a promise that will be resolved once the first set of page\n // data has been loaded. This ensures that the loading placeholder isn't\n // hidden until we have all of the data back to prevent the page elements\n // jumping around.\n var firstLoad = $.Deferred();\n var eventListContent = root.find(SELECTORS.EVENT_LIST_CONTENT);\n var loadingPlaceholder = root.find(SELECTORS.EVENT_LIST_LOADING_PLACEHOLDER);\n var courseId = root.attr('data-course-id');\n var daysOffset = parseInt(root.attr('data-days-offset'), 10);\n var daysLimit = root.attr('data-days-limit');\n var midnight = parseInt(root.attr('data-midnight'), 10);\n const searchValue = root.closest(SELECTORS.TIMELINE_BLOCK).find(SELECTORS.TIMELINE_SEARCH).val();\n\n // Make sure the content area and loading placeholder is visible.\n // This is because the init function can be called to re-initialise\n // an existing event list area.\n emptyContent(root);\n showContent(root);\n loadingPlaceholder.removeClass('hidden');\n\n // Days limit isn't mandatory.\n if (daysLimit != undefined) {\n daysLimit = parseInt(daysLimit, 10);\n }\n\n // Created the paged content element.\n return createPagedContent(pageLimit, preloadedPages, midnight, firstLoad, courseId, daysOffset, daysLimit,\n paginationAriaLabel, additionalConfig, searchValue)\n .then(function(html, js) {\n html = $(html);\n // Hide the content for now.\n html.addClass('hidden');\n // Replace existing elements with the newly created paged content.\n // If we're reinitialising an existing event list this will replace\n // the old event list (including removing any event handlers).\n Templates.replaceNodeContents(eventListContent, html, js);\n\n firstLoad.then(function(hasContent) {\n // Prevent changing page elements too much by only showing the content\n // once we've loaded some data for the first time. This allows our\n // fancy loading placeholder to shine.\n html.removeClass('hidden');\n loadingPlaceholder.addClass('hidden');\n\n if (!hasContent) {\n // If we didn't get any data then show the empty data message.\n hideContent(root);\n }\n\n return hasContent;\n })\n .catch(function() {\n return false;\n });\n\n return html;\n })\n .catch(Notification.exception);\n };\n\n return {\n init: init,\n rootSelector: SELECTORS.ROOT,\n };\n});\n"],"file":"event_list.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/event_list.js"],"names":["define","$","Notification","Templates","PagedContentFactory","Str","UserDate","CalendarEventsRepository","courseview","SELECTORS","EMPTY_MESSAGE","ROOT","EVENT_LIST_CONTENT","EVENT_LIST_LOADING_PLACEHOLDER","TIMELINE_BLOCK","TIMELINE_SEARCH","TEMPLATES","DEFAULT_PAGED_CONTENT_CONFIG","ignoreControlWhileLoading","controlPlacementBottom","ariaLabels","itemsperpagecomponents","hideContent","root","find","addClass","removeClass","showContent","emptyContent","empty","buildTemplateContext","calendarEvents","eventsByDay","templateContext","eventsbyday","forEach","calendarEvent","dayTimestamp","timeusermidnight","push","Object","keys","events","render","templateName","load","midnight","limit","daysOffset","daysLimit","lastId","courseId","searchValue","endTime","args","starttime","aftereventid","endtime","searchvalue","courseid","queryByCourse","queryByTime","loadEventsFromPageData","pageData","actions","lastIds","preloadedPages","pageNumber","lastPageNumber","hasOwnProperty","eventsPromise","then","result","length","allItemsLoaded","overdueFilter","document","querySelector","filterByOverdue","getAttribute","filter","event","eventtype","getUserMidnightForTimestamp","timesort","overdue","loadedAll","pop","createPagedContent","pageLimit","firstLoad","paginationAriaLabel","additionalConfig","hasContent","config","extend","get_string","isArray","value","string","itemsperpage","paginationnav","createWithLimit","pagesData","promises","pagePromise","lastEventId","id","catch","exception","when","apply","resolve","init","Deferred","eventListContent","loadingPlaceholder","attr","parseInt","closest","val","html","js","replaceNodeContents","rootSelector"],"mappings":"AAuBAA,OAAM,6BACN,CACI,QADJ,CAEI,mBAFJ,CAGI,gBAHJ,CAII,4BAJJ,CAKI,UALJ,CAMI,gBANJ,CAOI,2CAPJ,CADM,CAUN,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAMIC,CANJ,CAOIC,CAPJ,CAQE,IAGMC,CAAAA,CAAU,GAHhB,CAKMC,CAAS,CAAG,CACZC,aAAa,CAAE,iCADH,CAEZC,IAAI,CAAE,wCAFM,CAGZC,kBAAkB,CAAE,sCAHR,CAIZC,8BAA8B,CAAE,kDAJpB,CAKZC,cAAc,CAAE,4BALJ,CAMZC,eAAe,CAAE,gCANL,CALlB,CAcMC,CAAS,CAAG,CACZJ,kBAAkB,CAAE,mCADR,CAdlB,CAoBMK,CAA4B,CAAG,CAC/BC,yBAAyB,GADM,CAE/BC,sBAAsB,GAFS,CAG/BC,UAAU,CAAE,CACRC,sBAAsB,CAAE,wCADhB,CAHmB,CApBrC,CAiCMC,CAAW,CAAG,SAASC,CAAT,CAAe,CAC7BA,CAAI,CAACC,IAAL,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AACnB,IAAV,CAAe,SAASsB,CAAT,CAAqB,CAIhC4B,CAAI,CAAC/F,WAAL,CAAiB,QAAjB,EACA0F,CAAkB,CAAC3F,QAAnB,CAA4B,QAA5B,EAEA,GAAI,CAACoE,CAAL,CAAiB,CAEbvE,CAAW,CAACC,CAAD,CACd,CAED,MAAOsE,CAAAA,CACV,CAbD,EAcCe,KAdD,CAcO,UAAW,CACd,QACH,CAhBD,EAkBA,MAAOa,CAAAA,CACV,CA9BE,EA+BFb,KA/BE,CA+BI1G,CAAY,CAAC2G,SA/BjB,CAgCV,CAEM,CAEHe,YAAY,CAAEnH,CAAS,CAACE,IAFrB,CAIV,CAvdK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Javascript to load and render the list of calendar events for a\n * given day range.\n *\n * @module block_timeline/event_list\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(\n[\n 'jquery',\n 'core/notification',\n 'core/templates',\n 'core/paged_content_factory',\n 'core/str',\n 'core/user_date',\n 'block_timeline/calendar_events_repository'\n],\nfunction(\n $,\n Notification,\n Templates,\n PagedContentFactory,\n Str,\n UserDate,\n CalendarEventsRepository\n) {\n\n var SECONDS_IN_DAY = 60 * 60 * 24;\n var courseview = false;\n\n var SELECTORS = {\n EMPTY_MESSAGE: '[data-region=\"empty-message\"]',\n ROOT: '[data-region=\"event-list-container\"]',\n EVENT_LIST_CONTENT: '[data-region=\"event-list-content\"]',\n EVENT_LIST_LOADING_PLACEHOLDER: '[data-region=\"event-list-loading-placeholder\"]',\n TIMELINE_BLOCK: '[data-region=\"timeline\"]',\n TIMELINE_SEARCH: '[data-region=\"search-input\"]'\n };\n\n var TEMPLATES = {\n EVENT_LIST_CONTENT: 'block_timeline/event-list-content'\n };\n\n // We want the paged content controls below the paged content area\n // and the controls should be ignored while data is loading.\n var DEFAULT_PAGED_CONTENT_CONFIG = {\n ignoreControlWhileLoading: true,\n controlPlacementBottom: true,\n ariaLabels: {\n itemsperpagecomponents: 'ariaeventlistpagelimit, block_timeline',\n }\n };\n\n /**\n * Hide the content area and display the empty content message.\n *\n * @param {object} root The container element\n */\n var hideContent = function(root) {\n root.find(SELECTORS.EVENT_LIST_CONTENT).addClass('hidden');\n root.find(SELECTORS.EMPTY_MESSAGE).removeClass('hidden');\n };\n\n /**\n * Show the content area and hide the empty content message.\n *\n * @param {object} root The container element\n */\n var showContent = function(root) {\n root.find(SELECTORS.EVENT_LIST_CONTENT).removeClass('hidden');\n root.find(SELECTORS.EMPTY_MESSAGE).addClass('hidden');\n };\n\n /**\n * Empty the content area.\n *\n * @param {object} root The container element\n */\n var emptyContent = function(root) {\n root.find(SELECTORS.EVENT_LIST_CONTENT).empty();\n };\n\n /**\n * Construct the template context from a list of calendar events. The events\n * are grouped by which day they are on. The day is calculated from the user's\n * midnight timestamp to ensure that the calculation is timezone agnostic.\n *\n * The return data structure will look like:\n * {\n * eventsbyday: [\n * {\n * dayTimestamp: 1533744000,\n * events: [\n * { ...event 1 data... },\n * { ...event 2 data... }\n * ]\n * },\n * {\n * dayTimestamp: 1533830400,\n * events: [\n * { ...event 3 data... },\n * { ...event 4 data... }\n * ]\n * }\n * ]\n * }\n *\n * Each day timestamp is the day's midnight in the user's timezone.\n *\n * @param {array} calendarEvents List of calendar events\n * @return {object}\n */\n var buildTemplateContext = function(calendarEvents) {\n var eventsByDay = {};\n var templateContext = {\n courseview,\n eventsbyday: []\n };\n\n calendarEvents.forEach(function(calendarEvent) {\n var dayTimestamp = calendarEvent.timeusermidnight;\n if (eventsByDay[dayTimestamp]) {\n eventsByDay[dayTimestamp].push(calendarEvent);\n } else {\n eventsByDay[dayTimestamp] = [calendarEvent];\n }\n });\n\n Object.keys(eventsByDay).forEach(function(dayTimestamp) {\n var events = eventsByDay[dayTimestamp];\n templateContext.eventsbyday.push({\n dayTimestamp: dayTimestamp,\n events: events\n });\n });\n\n return templateContext;\n };\n\n /**\n * Render the HTML for the given calendar events.\n *\n * @param {array} calendarEvents A list of calendar events\n * @return {promise} Resolved with HTML and JS strings.\n */\n var render = function(calendarEvents) {\n var templateContext = buildTemplateContext(calendarEvents);\n var templateName = TEMPLATES.EVENT_LIST_CONTENT;\n\n return Templates.render(templateName, templateContext);\n };\n\n /**\n * Retrieve a list of calendar events from the server for the given\n * constraints.\n *\n * @param {Number} midnight The user's midnight time in unix timestamp.\n * @param {Number} limit Limit the result set to this number of items\n * @param {Number} daysOffset How many days (from midnight) to offset the results from\n * @param {int|undefined} daysLimit How many dates (from midnight) to limit the result to\n * @param {int|false} lastId The ID of the last seen event (if any)\n * @param {int|undefined} courseId Course ID to restrict events to\n * @param {string|undefined} searchValue Search value\n * @return {Promise} A jquery promise\n */\n var load = function(midnight, limit, daysOffset, daysLimit, lastId, courseId, searchValue) {\n var startTime = midnight + (daysOffset * SECONDS_IN_DAY);\n var endTime = daysLimit != undefined ? midnight + (daysLimit * SECONDS_IN_DAY) : false;\n\n var args = {\n starttime: startTime,\n limit: limit,\n };\n\n if (lastId) {\n args.aftereventid = lastId;\n }\n\n if (endTime) {\n args.endtime = endTime;\n }\n\n if (searchValue) {\n args.searchvalue = searchValue;\n }\n\n if (courseId) {\n // If we have a course id then we only want events from that course.\n args.courseid = courseId;\n return CalendarEventsRepository.queryByCourse(args);\n } else {\n // Otherwise we want events from any course.\n return CalendarEventsRepository.queryByTime(args);\n }\n };\n\n /**\n * Handle a single page request from the paged content. Uses the given page data to request\n * the events from the server.\n *\n * Checks the given preloadedPages before sending a request to the server to make sure we\n * don't load data unnecessarily.\n *\n * @param {object} pageData A single page data (see core/paged_content_pages for more info).\n * @param {object} actions Paged content actions (see core/paged_content_pages for more info).\n * @param {Number} midnight The user's midnight time in unix timestamp.\n * @param {object} lastIds The last event ID for each loaded page. Page number is key, id is value.\n * @param {object} preloadedPages An object of preloaded page data. Page number as key, data promise as value.\n * @param {int|undefined} courseId Course ID to restrict events to\n * @param {Number} daysOffset How many days (from midnight) to offset the results from\n * @param {int|undefined} daysLimit How many dates (from midnight) to limit the result to\n * @param {string|undefined} searchValue Search value\n * @return {object} jQuery promise resolved with calendar events.\n */\n var loadEventsFromPageData = function(\n pageData,\n actions,\n midnight,\n lastIds,\n preloadedPages,\n courseId,\n daysOffset,\n daysLimit,\n searchValue\n ) {\n var pageNumber = pageData.pageNumber;\n var limit = pageData.limit;\n var lastPageNumber = pageNumber;\n\n // This is here to protect us if, for some reason, the pages\n // are loaded out of order somehow and we don't have a reference\n // to the previous page. In that case, scan back to find the most\n // recent page we've seen.\n while (!lastIds.hasOwnProperty(lastPageNumber)) {\n lastPageNumber--;\n }\n // Use the last id of the most recent page.\n var lastId = lastIds[lastPageNumber];\n var eventsPromise = null;\n\n if (preloadedPages && preloadedPages.hasOwnProperty(pageNumber)) {\n // This page has been preloaded so use that rather than load the values\n // again.\n eventsPromise = preloadedPages[pageNumber];\n } else {\n // Load one more than the given limit so that we can tell if there\n // is more content to load after this.\n eventsPromise = load(midnight, limit + 1, daysOffset, daysLimit, lastId, courseId, searchValue);\n }\n\n return eventsPromise.then(function(result) {\n if (!result.events.length) {\n // If we didn't get any events back then tell the paged content\n // that we're done loading.\n actions.allItemsLoaded(pageNumber);\n return [];\n }\n\n // Determine if the overdue filter is applied.\n const overdueFilter = document.querySelector(\"[data-filtername='overdue']\");\n const filterByOverdue = (overdueFilter && overdueFilter.getAttribute('aria-current'));\n\n var calendarEvents = result.events.filter(function(event) {\n if (event.eventtype == \"open\" || event.eventtype == \"opensubmission\") {\n var dayTimestamp = UserDate.getUserMidnightForTimestamp(event.timesort, midnight);\n return dayTimestamp > midnight;\n }\n\n // When filtering by overdue, we fetch all events due today, in case any have elapsed already and are overdue.\n // This means if filtering by overdue, some events fetched might not be required (eg if due later today).\n return (!filterByOverdue || event.overdue);\n });\n // We expect to receive limit + 1 events back from the server.\n // Any less means there are no more events to load.\n var loadedAll = calendarEvents.length <= limit;\n\n if (loadedAll) {\n // Tell the pagination that everything is loaded.\n actions.allItemsLoaded(pageNumber);\n } else {\n // Remove the last element from the array because it isn't\n // needed in this result set.\n calendarEvents.pop();\n }\n\n return calendarEvents;\n });\n };\n\n /**\n * Use the paged content factory to create a paged content element for showing\n * the event list. We only provide a page limit to the factory because we don't\n * know exactly how many pages we'll need. This creates a paging bar with just\n * next/previous buttons.\n *\n * This function specifies the callback for loading the event data that the user\n * is requesting.\n *\n * @param {int|array} pageLimit A single limit or list of limits as options for the paged content\n * @param {object} preloadedPages An object of preloaded page data. Page number as key, data promise as value.\n * @param {Number} midnight The user's midnight time in unix timestamp.\n * @param {object} firstLoad A jQuery promise to be resolved after the first set of data is loaded.\n * @param {int|undefined} courseId Course ID to restrict events to\n * @param {Number} daysOffset How many days (from midnight) to offset the results from\n * @param {int|undefined} daysLimit How many dates (from midnight) to limit the result to\n * @param {string} paginationAriaLabel String to set as the aria label for the pagination bar.\n * @param {object} additionalConfig Additional config options to pass to pagedContentFactory\n * @param {string|undefined} searchValue Search value\n * @return {object} jQuery promise.\n */\n var createPagedContent = function(\n pageLimit,\n preloadedPages,\n midnight,\n firstLoad,\n courseId,\n daysOffset,\n daysLimit,\n paginationAriaLabel,\n additionalConfig,\n searchValue\n ) {\n // Remember the last event id we loaded on each page because we can't\n // use the offset value since the backend can skip events if the user doesn't\n // have the capability to see them. Instead we load the next page of events\n // based on the last seen event id.\n var lastIds = {'1': 0};\n var hasContent = false;\n var config = $.extend({}, DEFAULT_PAGED_CONTENT_CONFIG, additionalConfig);\n\n return Str.get_string(\n 'ariaeventlistpagelimit',\n 'block_timeline',\n $.isArray(pageLimit) ? pageLimit[0].value : pageLimit\n )\n .then(function(string) {\n config.ariaLabels.itemsperpage = string;\n config.ariaLabels.paginationnav = paginationAriaLabel;\n return string;\n })\n .then(function() {\n return PagedContentFactory.createWithLimit(\n pageLimit,\n function(pagesData, actions) {\n var promises = [];\n\n pagesData.forEach(function(pageData) {\n var pageNumber = pageData.pageNumber;\n // Load the page data.\n var pagePromise = loadEventsFromPageData(\n pageData,\n actions,\n midnight,\n lastIds,\n preloadedPages,\n courseId,\n daysOffset,\n daysLimit,\n searchValue\n ).then(function(calendarEvents) {\n if (calendarEvents.length) {\n // Remember that we've loaded content.\n hasContent = true;\n // Remember the last id we've seen.\n var lastEventId = calendarEvents[calendarEvents.length - 1].id;\n // Record the id that the next page will need to start from.\n lastIds[pageNumber + 1] = lastEventId;\n // Get the HTML and JS for these calendar events.\n return render(calendarEvents);\n } else {\n return calendarEvents;\n }\n })\n .catch(Notification.exception);\n\n promises.push(pagePromise);\n });\n\n $.when.apply($, promises).then(function() {\n // Tell the calling code that the first page has been loaded\n // and whether it contains any content.\n firstLoad.resolve(hasContent);\n return;\n })\n .catch(function() {\n firstLoad.resolve(hasContent);\n });\n\n return promises;\n },\n config\n );\n });\n };\n\n /**\n * Create a paged content region for the calendar events in the given root element.\n * The content of the root element are replaced with a new paged content section\n * each time this function is called.\n *\n * This function will be called each time the offset or limit values are changed to\n * reload the event list region.\n *\n * @param {object} root The event list container element\n * @param {int|array} pageLimit A single limit or list of limits as options for the paged content\n * @param {object} preloadedPages An object of preloaded page data. Page number as key, data promise as value.\n * @param {string} paginationAriaLabel String to set as the aria label for the pagination bar.\n * @param {object} additionalConfig Additional config options to pass to pagedContentFactory\n */\n var init = function(root, pageLimit, preloadedPages, paginationAriaLabel, additionalConfig = {}) {\n root = $(root);\n\n courseview = !!additionalConfig.courseview;\n\n // Create a promise that will be resolved once the first set of page\n // data has been loaded. This ensures that the loading placeholder isn't\n // hidden until we have all of the data back to prevent the page elements\n // jumping around.\n var firstLoad = $.Deferred();\n var eventListContent = root.find(SELECTORS.EVENT_LIST_CONTENT);\n var loadingPlaceholder = root.find(SELECTORS.EVENT_LIST_LOADING_PLACEHOLDER);\n var courseId = root.attr('data-course-id');\n var daysOffset = parseInt(root.attr('data-days-offset'), 10);\n var daysLimit = root.attr('data-days-limit');\n var midnight = parseInt(root.attr('data-midnight'), 10);\n const searchValue = root.closest(SELECTORS.TIMELINE_BLOCK).find(SELECTORS.TIMELINE_SEARCH).val();\n\n // Make sure the content area and loading placeholder is visible.\n // This is because the init function can be called to re-initialise\n // an existing event list area.\n emptyContent(root);\n showContent(root);\n loadingPlaceholder.removeClass('hidden');\n\n // Days limit isn't mandatory.\n if (daysLimit != undefined) {\n daysLimit = parseInt(daysLimit, 10);\n }\n\n // Created the paged content element.\n return createPagedContent(pageLimit, preloadedPages, midnight, firstLoad, courseId, daysOffset, daysLimit,\n paginationAriaLabel, additionalConfig, searchValue)\n .then(function(html, js) {\n html = $(html);\n // Hide the content for now.\n html.addClass('hidden');\n // Replace existing elements with the newly created paged content.\n // If we're reinitialising an existing event list this will replace\n // the old event list (including removing any event handlers).\n Templates.replaceNodeContents(eventListContent, html, js);\n\n firstLoad.then(function(hasContent) {\n // Prevent changing page elements too much by only showing the content\n // once we've loaded some data for the first time. This allows our\n // fancy loading placeholder to shine.\n html.removeClass('hidden');\n loadingPlaceholder.addClass('hidden');\n\n if (!hasContent) {\n // If we didn't get any data then show the empty data message.\n hideContent(root);\n }\n\n return hasContent;\n })\n .catch(function() {\n return false;\n });\n\n return html;\n })\n .catch(Notification.exception);\n };\n\n return {\n init: init,\n rootSelector: SELECTORS.ROOT,\n };\n});\n"],"file":"event_list.min.js"} \ No newline at end of file diff --git a/blocks/timeline/amd/src/event_list.js b/blocks/timeline/amd/src/event_list.js index df38f5bfd35..806a76ad69b 100644 --- a/blocks/timeline/amd/src/event_list.js +++ b/blocks/timeline/amd/src/event_list.js @@ -124,10 +124,9 @@ function( * Each day timestamp is the day's midnight in the user's timezone. * * @param {array} calendarEvents List of calendar events - * @param {Number} midnight A timestamp representing midnight in the user's timezone * @return {object} */ - var buildTemplateContext = function(calendarEvents, midnight) { + var buildTemplateContext = function(calendarEvents) { var eventsByDay = {}; var templateContext = { courseview, @@ -146,7 +145,6 @@ function( Object.keys(eventsByDay).forEach(function(dayTimestamp) { var events = eventsByDay[dayTimestamp]; templateContext.eventsbyday.push({ - past: dayTimestamp < midnight, dayTimestamp: dayTimestamp, events: events }); @@ -159,11 +157,10 @@ function( * Render the HTML for the given calendar events. * * @param {array} calendarEvents A list of calendar events - * @param {Number} midnight A timestamp representing midnight for the user * @return {promise} Resolved with HTML and JS strings. */ - var render = function(calendarEvents, midnight) { - var templateContext = buildTemplateContext(calendarEvents, midnight); + var render = function(calendarEvents) { + var templateContext = buildTemplateContext(calendarEvents); var templateName = TEMPLATES.EVENT_LIST_CONTENT; return Templates.render(templateName, templateContext); @@ -275,12 +272,19 @@ function( return []; } + // Determine if the overdue filter is applied. + const overdueFilter = document.querySelector("[data-filtername='overdue']"); + const filterByOverdue = (overdueFilter && overdueFilter.getAttribute('aria-current')); + var calendarEvents = result.events.filter(function(event) { if (event.eventtype == "open" || event.eventtype == "opensubmission") { var dayTimestamp = UserDate.getUserMidnightForTimestamp(event.timesort, midnight); return dayTimestamp > midnight; } - return true; + + // When filtering by overdue, we fetch all events due today, in case any have elapsed already and are overdue. + // This means if filtering by overdue, some events fetched might not be required (eg if due later today). + return (!filterByOverdue || event.overdue); }); // We expect to receive limit + 1 events back from the server. // Any less means there are no more events to load. @@ -378,7 +382,7 @@ function( // Record the id that the next page will need to start from. lastIds[pageNumber + 1] = lastEventId; // Get the HTML and JS for these calendar events. - return render(calendarEvents, midnight); + return render(calendarEvents); } else { return calendarEvents; } diff --git a/blocks/timeline/classes/output/main.php b/blocks/timeline/classes/output/main.php index 05f0084862a..90164ea545e 100644 --- a/blocks/timeline/classes/output/main.php +++ b/blocks/timeline/classes/output/main.php @@ -106,7 +106,7 @@ class main implements renderable, templatable { 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) { - $limit = 0; + $limit = 1; } } else { $offset = 0; diff --git a/blocks/timeline/templates/event-list-content.mustache b/blocks/timeline/templates/event-list-content.mustache index 11c799305cd..e3df62add1d 100644 --- a/blocks/timeline/templates/event-list-content.mustache +++ b/blocks/timeline/templates/event-list-content.mustache @@ -67,7 +67,6 @@ {{#eventsbyday}}
{{#userdate}} {{dayTimestamp}}, {{#str}} strftimedaydate, core_langconfig {{/str}} {{/userdate}}
- {{#past}}{{#str}} overdue, block_timeline {{/str}}{{/past}}
{{> block_timeline/event-list-items }} {{/eventsbyday}} diff --git a/blocks/timeline/templates/event-list-item.mustache b/blocks/timeline/templates/event-list-item.mustache index b824dafdf63..ad1365bff8a 100644 --- a/blocks/timeline/templates/event-list-item.mustache +++ b/blocks/timeline/templates/event-list-item.mustache @@ -41,7 +41,8 @@ "key": "icon", "component": "mod_assign", "alttext": "Assignment icon" - } + }, + "overdue": false } }}
- -
{{{activityname}}}
-
+
+ + {{{activityname}}} + {{#overdue}}{{#str}} overdue, block_timeline {{/str}}{{/overdue}} +
{{#courseview}} {{activitystr}} diff --git a/blocks/timeline/templates/nav-day-filter.mustache b/blocks/timeline/templates/nav-day-filter.mustache index 4c36eee4317..f215912f13b 100644 --- a/blocks/timeline/templates/nav-day-filter.mustache +++ b/blocks/timeline/templates/nav-day-filter.mustache @@ -51,7 +51,7 @@ class="dropdown-item" href="#" data-from="-14" - data-to="0" + data-to="1" data-filtername="overdue" {{#overdue}}aria-current="true"{{/overdue}} aria-label="{{#str}} ariadayfilteroption, block_timeline, {{#str}} overdue, block_timeline {{/str}}{{/str}}" diff --git a/blocks/timeline/tests/behat/block_timeline_courses.feature b/blocks/timeline/tests/behat/block_timeline_courses.feature index dcc924bae6e..9a009dc6440 100644 --- a/blocks/timeline/tests/behat/block_timeline_courses.feature +++ b/blocks/timeline/tests/behat/block_timeline_courses.feature @@ -24,9 +24,11 @@ Feature: The timeline block allows users to see upcoming courses | feedback | C1 | feedback2 | Test feedback 2 | Test feedback description | ##first day of +10 months## | ##last day of +10 months## | | feedback | C3 | feedback3 | Test feedback 3 | Test feedback description | ##first day of +5 months## | ##last day of +5 months## | | feedback | C4 | feedback4 | Test feedback 4 | Test feedback description | ##yesterday## | ##tomorrow## | + | feedback | C1 | feedback5 | Test feedback 5 | Test feedback description | ##yesterday## | ##now +1 minute## | And the following "activities" exist: - | activity | course | idnumber | name | intro | timeopen | duedate | - | assign | C1 | assign1 | Test assign 1 | Test assign description | ##1 month ago## | ##yesterday## | + | activity | course | idnumber | name | intro | timeopen | duedate | + | assign | C1 | assign1 | Test assign 1 | Test assign description | ##1 month ago## | ##yesterday## | + | assign | C2 | assign2 | Test assign 2 | Test assign description | ##yesterday## | ##now -1 minute## | And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | @@ -36,6 +38,8 @@ Feature: The timeline block allows users to see upcoming courses Scenario: Next 30 days in course view Given I log in as "student1" + And I click on "Filter timeline by date" "button" in the "Timeline" "block" + And I click on "Next 30 days" "link" in the "Timeline" "block" And I click on "Sort timeline items" "button" in the "Timeline" "block" When I click on "Sort by courses" "link" in the "Timeline" "block" Then I should see "Course 1" in the "Timeline" "block" @@ -45,13 +49,14 @@ Feature: The timeline block allows users to see upcoming courses And I should see "Choice closes" in the "Timeline" "block" And "Test feedback 1" "link" should exist in the "Timeline" "block" And I should see "Feedback closes" in the "Timeline" "block" + And "Test feedback 5" "link" should exist in the "Timeline" "block" + And "Test assign 2" "link" should exist in the "Timeline" "block" And I should not see "Course 3" in the "Timeline" "block" And "Test choice 2" "link" should not exist in the "Timeline" "block" And "Test choice 3" "link" should not exist in the "Timeline" "block" And "Test feedback 2" "link" should not exist in the "Timeline" "block" And "Test feedback 3" "link" should not exist in the "Timeline" "block" And "Test assign 1" "link" should not exist in the "Timeline" "block" - And I should not see "Assignment is due" in the "Timeline" "block" Scenario: All in course view Given I log in as "student1" @@ -68,7 +73,9 @@ Feature: The timeline block allows users to see upcoming courses And "Test feedback 1" "link" should exist in the "Timeline" "block" And "Test feedback 2" "link" should exist in the "Timeline" "block" And "Test feedback 3" "link" should exist in the "Timeline" "block" + And "Test feedback 5" "link" should exist 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 I should see "Assignment is due" in the "Timeline" "block" And I should see "Choice closes" in the "Timeline" "block" And I should not see "More courses" in the "Timeline" "block" @@ -88,6 +95,8 @@ Feature: The timeline block allows users to see upcoming courses And I should see "More courses" in the "Timeline" "block" And "Test choice 1" "link" should exist in the "Timeline" "block" And "Test feedback 1" "link" should exist in the "Timeline" "block" + And "Test feedback 5" "link" should exist in the "Timeline" "block" + And "Test assign 2" "link" should exist in the "Timeline" "block" And I should not see "Course 3" in the "Timeline" "block" And "Test choice 2" "link" should not exist in the "Timeline" "block" And "Test choice 3" "link" should not exist in the "Timeline" "block" @@ -136,3 +145,38 @@ Feature: The timeline block allows users to see upcoming courses And I click on "More courses" "button" in the "Timeline" "block" Then "Test assign 1" "link" should exist in the "Timeline" "block" And "Test feedback 2" "link" should exist in the "Timeline" "block" + + Scenario: Overdue 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 by date" "button" in the "Timeline" "block" + When I click on "Overdue" "link" in the "Timeline" "block" + Then "Test assign 1" "link" should exist in the "Timeline" "block" + And "Test assign 2" "link" should exist in the "Timeline" "block" + And I should not see "Test feedback 1" in the "Timeline" "block" + And I should not see "Test feedback 2" in the "Timeline" "block" + And I should not see "Test feedback 3" in the "Timeline" "block" + And I should not see "Test feedback 4" in the "Timeline" "block" + And I should not see "Test feedback 5" in the "Timeline" "block" + And I should not see "Test choice 1" in the "Timeline" "block" + And I should not see "Test choice 2" in the "Timeline" "block" + And I should not see "Test choice 3" in the "Timeline" "block" + + Scenario: Persistent Overdue 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 by date" "button" in the "Timeline" "block" + When I click on "Overdue" "link" in the "Timeline" "block" + And I reload the page + Then "Test assign 1" "link" should exist in the "Timeline" "block" + And "Test assign 2" "link" should exist in the "Timeline" "block" + And "Test feedback 1" "link" should not exist in the "Timeline" "block" + And "Test feedback 2" "link" should not exist in the "Timeline" "block" + And "Test feedback 3" "link" should not exist in the "Timeline" "block" + And "Test feedback 4" "link" should not exist in the "Timeline" "block" + And "Test feedback 5" "link" should not exist in the "Timeline" "block" + And "Test choice 1" "link" should not exist in the "Timeline" "block" + And "Test choice 2" "link" should not exist in the "Timeline" "block" + And "Test choice 3" "link" should not exist in the "Timeline" "block" diff --git a/blocks/timeline/tests/behat/block_timeline_dates.feature b/blocks/timeline/tests/behat/block_timeline_dates.feature index 1cc9b697f21..82ac1279397 100644 --- a/blocks/timeline/tests/behat/block_timeline_dates.feature +++ b/blocks/timeline/tests/behat/block_timeline_dates.feature @@ -22,9 +22,11 @@ Feature: The timeline block allows users to see upcoming activities | feedback | C2 | feedback1 | Test feedback 1 | Test feedback description | ##yesterday## | ##tomorrow## | | feedback | C1 | feedback2 | Test feedback 2 | Test feedback description | ##first day of +10 months## | ##last day of +10 months## | | feedback | C3 | feedback3 | Test feedback 3 | Test feedback description | ##first day of +5 months## | ##last day of +5 months## | + | feedback | C2 | feedback4 | Test feedback 4 | Test feedback description | ##yesterday## | ##now +1 minute## | And the following "activities" exist: - | activity | course | idnumber | name | intro | timeopen | duedate | - | assign | C1 | assign1 | Test assign 1 | Test assign description | ##1 month ago## | ##yesterday## | + | activity | course | idnumber | name | intro | timeopen | duedate | + | assign | C1 | assign1 | Test assign 1 | Test assign description | ##1 month ago## | ##yesterday## | + | assign | C2 | assign2 | Test assign 2 | Test assign description | ##yesterday## | ##now -1 minute## | And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | @@ -40,6 +42,8 @@ Feature: The timeline block allows users to see upcoming activities And I should see "Course 2 · Choice closes" in the "Timeline" "block" And "Test feedback 1" "link" should exist in the "Timeline" "block" And I should see "Course 2 · Feedback closes" in the "Timeline" "block" + And "Test assign 2" "link" should exist in the "Timeline" "block" + And "Test feedback 4" "link" should exist in the "Timeline" "block" And "Test choice 2" "link" should not exist in the "Timeline" "block" And "Test choice 3" "link" should not exist in the "Timeline" "block" And "Test feedback 3" "link" should not exist in the "Timeline" "block" @@ -50,13 +54,15 @@ Feature: The timeline block allows users to see upcoming activities Given I log in as "student1" And I click on "Filter timeline by date" "button" in the "Timeline" "block" When I click on "Overdue" "link" in the "Timeline" "block" - And "Test assign 1" "link" should exist in the "Timeline" "block" - Then I should see "Course 1 · Assignment is due" in the "Timeline" "block" + Then "Test assign 1" "link" should exist in the "Timeline" "block" + And I should see "Course 1 · Assignment is due" in the "Timeline" "block" + And "Test assign 2" "link" should exist in the "Timeline" "block" And "Test choice 2" "link" should not exist in the "Timeline" "block" And "Test feedback 1" "link" should not exist in the "Timeline" "block" And "Test choice 1" "link" should not exist in the "Timeline" "block" And "Test choice 3" "link" should not exist in the "Timeline" "block" And "Test feedback 3" "link" should not exist in the "Timeline" "block" + And "Test feedback 4" "link" should not exist in the "Timeline" "block" Scenario: All in date view Given I log in as "student1" @@ -64,24 +70,26 @@ Feature: The timeline block allows users to see upcoming activities When I click on "All" "link" in the "Timeline" "block" Then "Test assign 1" "link" should exist in the "Timeline" "block" And I should see "Course 1 · Assignment is due" in the "Timeline" "block" + And "Test assign 2" "link" should exist in the "Timeline" "block" + And I should see "Course 2 · Assignment is due" in the "Timeline" "block" And "Test feedback 1" "link" should exist in the "Timeline" "block" And I should see "Course 2 · Feedback closes" in the "Timeline" "block" And "Test choice 1" "link" should exist in the "Timeline" "block" And I should see "Course 2 · Choice closes" in the "Timeline" "block" - And "Test choice 3" "link" should exist in the "Timeline" "block" - And I should see "Course 3 · Choice closes" in the "Timeline" "block" - And "Test feedback 3" "link" should exist in the "Timeline" "block" - And I should see "Course 3 · Feedback closes" in the "Timeline" "block" + And "Test feedback 4" "link" should exist in the "Timeline" "block" + And I should see "Course 2 · Feedback closes" in the "Timeline" "block" And "Test choice 2" "link" should not exist in the "Timeline" "block" And "Test feedback 2" "link" should not exist in the "Timeline" "block" And I click on "[data-region='paging-bar'] [data-control='next'] [data-region='page-link']" "css_element" in the "Timeline" "block" And "Test feedback 2" "link" should exist in the "Timeline" "block" And I should see "Course 1 · Feedback closes" in the "Timeline" "block" + And "Test choice 3" "link" should exist in the "Timeline" "block" + And I should see "Course 3 · Choice closes" in the "Timeline" "block" + And "Test feedback 3" "link" should exist in the "Timeline" "block" + And I should see "Course 3 · Feedback closes" in the "Timeline" "block" And I should not see "Test assign 1" in the "Timeline" "block" And I should not see "Test feedback 1" in the "Timeline" "block" And I should not see "Test choice 1" in the "Timeline" "block" - And I should not see "Test choice 3" in the "Timeline" "block" - And I should not see "Test feedback 3" in the "Timeline" "block" And I should not see "Test choice 2" in the "Timeline" "block" Scenario: All in date view no next @@ -92,7 +100,10 @@ Feature: The timeline block allows users to see upcoming activities When I click on "25" "link" in the "Timeline" "block" Then "Test assign 1" "link" should exist in the "Timeline" "block" And I should see "Course 1 · Assignment is due" in the "Timeline" "block" + And "Test assign 2" "link" should exist in the "Timeline" "block" + And I should see "Course 2 · Assignment is due" in the "Timeline" "block" And "Test feedback 1" "link" should exist in the "Timeline" "block" + And "Test feedback 4" "link" should exist in the "Timeline" "block" And I should see "Course 2 · Feedback closes" in the "Timeline" "block" And "Test choice 1" "link" should exist in the "Timeline" "block" And I should see "Course 2 · Choice closes" in the "Timeline" "block" @@ -111,25 +122,27 @@ Feature: The timeline block allows users to see upcoming activities And I reload the page Then "Test assign 1" "link" should exist in the "Timeline" "block" And I should see "Course 1 · Assignment is due" in the "Timeline" "block" + And "Test assign 2" "link" should exist in the "Timeline" "block" + And I should see "Course 2 · Assignment is due" in the "Timeline" "block" And "Test feedback 1" "link" should exist in the "Timeline" "block" And I should see "Course 2 · Feedback closes" in the "Timeline" "block" And "Test choice 1" "link" should exist in the "Timeline" "block" And I should see "Course 2 · Choice closes" in the "Timeline" "block" - And "Test choice 3" "link" should exist in the "Timeline" "block" - And I should see "Course 3 · Choice closes" in the "Timeline" "block" - And "Test feedback 3" "link" should exist in the "Timeline" "block" - And I should see "Course 3 · Feedback closes" in the "Timeline" "block" + And "Test feedback 4" "link" should exist in the "Timeline" "block" + And I should see "Course 2 · Feedback closes" in the "Timeline" "block" And I should not see "Test choice 2" in the "Timeline" "block" And I should not see "Test feedback 2" in the "Timeline" "block" And I click on "[data-region='paging-bar'] [data-control='next']" "css_element" in the "Timeline" "block" And "Test feedback 2" "link" should exist in the "Timeline" "block" And I should see "Course 1 · Feedback closes" in the "Timeline" "block" + And "Test choice 3" "link" should exist in the "Timeline" "block" + And I should see "Course 3 · Choice closes" in the "Timeline" "block" + And "Test feedback 3" "link" should exist in the "Timeline" "block" + And I should see "Course 3 · Feedback closes" in the "Timeline" "block" And I should not see "Test assign 1" in the "Timeline" "block" And I should not see "Test feedback 1" in the "Timeline" "block" - And I should not see "Test feedback 3" in the "Timeline" "block" And I should not see "Test choice 1" in the "Timeline" "block" And I should not see "Test choice 2" in the "Timeline" "block" - And I should not see "Test choice 3" in the "Timeline" "block" Scenario: Persistent Overdue in date view Given I log in as "student1" @@ -137,11 +150,15 @@ Feature: The timeline block allows users to see upcoming activities When I click on "Overdue" "link" in the "Timeline" "block" And I reload the page Then "Test assign 1" "link" should exist in the "Timeline" "block" - And "Test choice 2" "link" should not exist in the "Timeline" "block" + And I should see "Course 1 · Assignment is due" in the "Timeline" "block" + And "Test assign 2" "link" should exist in the "Timeline" "block" + And I should see "Course 2 · Assignment is due" in the "Timeline" "block" And "Test feedback 1" "link" should not exist in the "Timeline" "block" - And "Test choice 1" "link" should not exist in the "Timeline" "block" - And "Test choice 3" "link" should not exist in the "Timeline" "block" And "Test feedback 3" "link" should not exist in the "Timeline" "block" + And "Test feedback 4" "link" should not exist in the "Timeline" "block" + And "Test choice 1" "link" should not exist in the "Timeline" "block" + And "Test choice 2" "link" should not exist in the "Timeline" "block" + And "Test choice 3" "link" should not exist in the "Timeline" "block" Scenario: Current filtering always applies in date view Given I log in as "student1" diff --git a/calendar/classes/external/event_exporter_base.php b/calendar/classes/external/event_exporter_base.php index 7f761193539..2ae3cc579bd 100644 --- a/calendar/classes/external/event_exporter_base.php +++ b/calendar/classes/external/event_exporter_base.php @@ -91,6 +91,7 @@ class event_exporter_base extends exporter { $data->visible = $event->is_visible() ? 1 : 0; $data->timemodified = $event->get_times()->get_modified_time()->getTimestamp(); $data->component = $event->get_component(); + $data->overdue = $data->timesort < time(); if ($repeats = $event->get_repeats()) { $data->repeatid = $repeats->get_id(); @@ -212,6 +213,12 @@ class event_exporter_base extends exporter { 'timeusermidnight' => ['type' => PARAM_INT], 'visible' => ['type' => PARAM_INT], 'timemodified' => ['type' => PARAM_INT], + 'overdue' => [ + 'type' => PARAM_BOOL, + 'optional' => true, + 'default' => false, + 'null' => NULL_ALLOWED + ], ]; }