diff --git a/blocks/myoverview/amd/build/main.min.js b/blocks/myoverview/amd/build/main.min.js
new file mode 100644
index 00000000000..ce2592db083
--- /dev/null
+++ b/blocks/myoverview/amd/build/main.min.js
@@ -0,0 +1 @@
+define(["jquery","block_myoverview/view","block_myoverview/view_nav"],function(a,b,c){var d={COURSES_VIEW:'[data-region="courses-view"]',COURSES_VIEW_CONTENT:'[data-region="course-view-content"]'},e=function(e){e=a(e);var f=e.find(d.COURSES_VIEW),g=e.find(d.COURSES_VIEW_CONTENT);c.init(e,f,g),b.init(f,g)};return{init:e}});
\ No newline at end of file
diff --git a/blocks/myoverview/amd/build/paging_bar.min.js b/blocks/myoverview/amd/build/paging_bar.min.js
deleted file mode 100644
index 40e8b6d9b2c..00000000000
--- a/blocks/myoverview/amd/build/paging_bar.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define(["jquery","core/custom_interaction_events"],function(a,b){var c={ROOT:'[data-region="paging-bar"]',PAGE_ITEM:'[data-region="page-item"]',ACTIVE_PAGE_ITEM:'[data-region="page-item"].active'},d={PAGE_SELECTED:"block_myoverview-paging-bar-page-selected"},e=function(a,b){return a.find(c.PAGE_ITEM+'[data-page-number="'+b+'"]')},f=function(a,b){var c=b.attr("data-page-number");return"first"==c?c=1:"last"==c&&(c=a.attr("data-page-count")),c},g=function(g){g=a(g),b.define(g,[b.events.activate]),g.on(b.events.activate,c.PAGE_ITEM,function(b,h){var i=a(b.target).closest(c.PAGE_ITEM),j=g.find(c.ACTIVE_PAGE_ITEM),k=f(g,i),l=k==f(g,j);l||(g.find(c.PAGE_ITEM).removeClass("active"),e(g,k).addClass("active")),g.trigger(d.PAGE_SELECTED,[{pageNumber:k,isSamePage:l}]),h.originalEvent.preventDefault()})};return{registerEventListeners:g,events:d,rootSelector:c.ROOT}});
\ No newline at end of file
diff --git a/blocks/myoverview/amd/build/paging_content.min.js b/blocks/myoverview/amd/build/paging_content.min.js
deleted file mode 100644
index 97da2cac13e..00000000000
--- a/blocks/myoverview/amd/build/paging_content.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define(["jquery","core/templates","block_myoverview/paging_bar"],function(a,b,c){var d={ROOT:'[data-region="paging-content"]',PAGE_REGION:'[data-region="paging-content-item"]'},e=function(b,c){this.root=a(b),this.pagingBar=a(c)};return e.rootSelector=d.ROOT,e.prototype.createPage=function(a){return this.loadContent(a).then(function(a,c){b.appendNodeContents(this.root,a,c)}.bind(this)).then(function(){return this.findPage(a)}.bind(this))},e.prototype.findPage=function(a){return this.root.find('[data-page="'+a+'"]')},e.prototype.showPage=function(a){var b=this.findPage(a);this.root.find(d.PAGE_REGION).addClass("hidden"),b.length?b.removeClass("hidden"):this.createPage(a).done(function(a){a.removeClass("hidden")})},e.prototype.registerEventListeners=function(){this.pagingBar.on(c.events.PAGE_SELECTED,function(a,b){b.isSamePage||this.showPage(b.pageNumber)}.bind(this))},e});
\ No newline at end of file
diff --git a/blocks/myoverview/amd/build/repository.min.js b/blocks/myoverview/amd/build/repository.min.js
new file mode 100644
index 00000000000..ab272626367
--- /dev/null
+++ b/blocks/myoverview/amd/build/repository.min.js
@@ -0,0 +1 @@
+define(["core/ajax"],function(a){var b=function(b){var c={methodname:"core_course_get_enrolled_courses_by_timeline_classification",args:b},d=a.call([c])[0];return d};return{getEnrolledCoursesByTimeline:b}});
\ No newline at end of file
diff --git a/blocks/myoverview/amd/build/view.min.js b/blocks/myoverview/amd/build/view.min.js
new file mode 100644
index 00000000000..1d9b2147efd
--- /dev/null
+++ b/blocks/myoverview/amd/build/view.min.js
@@ -0,0 +1 @@
+define(["jquery","core/notification","block_myoverview/repository","core/paged_content_factory","core/templates"],function(a,b,c,d,e){var f={COURSES_CARDS:"block_myoverview/view-cards",COURSES_LIST:"block_myoverview/view-list",COURSES_SUMMARY:"block_myoverview/view-summary",NOCOURSES:"block_myoverview/no-courses"},g=[12,24],h=[],i=function(a){var b={};return b.display=a.attr("data-display"),b.grouping=a.attr("data-grouping"),b.sort=a.attr("data-sort"),b},j={ignoreControlWhileLoading:!0,controlPlacementBottom:!0},k=function(a,b,d){return c.getEnrolledCoursesByTimeline({offset:d*b,limit:b,classification:a.grouping,sort:a.sort})},l=function(a,b,c){var d="";if(d="cards"==c.display?f.COURSES_CARDS:"list"==c.display?f.COURSES_LIST:f.COURSES_SUMMARY,b.courses.length)return e.render(d,{courses:b.courses});var g=a.attr("data-nocoursesimg");return e.render(f.NOCOURSES,{nocoursesimg:g})},m=function(c,f){c=a(c);var m=i(c),n=d.createWithLimit(g,function(a,d){var e=[];return a.forEach(function(a){var f=a.pageNumber-1,g=k(m,a.limit,f).then(function(b){return b.courses.length.
+
+/**
+ * Javascript to initialise the myoverview block.
+ *
+ * @package block_myoverview
+ * @copyright 2018 Bas Brands
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+define(
+[
+ 'jquery',
+ 'block_myoverview/view',
+ 'block_myoverview/view_nav'
+],
+function(
+ $,
+ View,
+ ViewNav
+) {
+
+ var SELECTORS = {
+ COURSES_VIEW: '[data-region="courses-view"]',
+ COURSES_VIEW_CONTENT: '[data-region="course-view-content"]'
+ };
+ /**
+ * Initialise all of the modules for the overview block.
+ *
+ * @param {object} root The root element for the overview block.
+ */
+ var init = function(root) {
+ root = $(root);
+ var coursesViewRoot = root.find(SELECTORS.COURSES_VIEW);
+ var coursesViewContent = root.find(SELECTORS.COURSES_VIEW_CONTENT);
+ // Initialise the course navigation elements.
+ ViewNav.init(root, coursesViewRoot, coursesViewContent);
+ // Initialise the courses view modules.
+ View.init(coursesViewRoot, coursesViewContent);
+ };
+
+ return {
+ init: init
+ };
+});
diff --git a/blocks/myoverview/amd/src/paging_bar.js b/blocks/myoverview/amd/src/paging_bar.js
deleted file mode 100644
index e153e2d5762..00000000000
--- a/blocks/myoverview/amd/src/paging_bar.js
+++ /dev/null
@@ -1,102 +0,0 @@
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle. If not, see .
-
-/**
- * Javascript to load and render the paging bar.
- *
- * @module block_myoverview/paging_bar
- * @package block_myoverview
- * @copyright 2016 Ryan Wyllie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-define(['jquery', 'core/custom_interaction_events'],
- function($, CustomEvents) {
-
- var SELECTORS = {
- ROOT: '[data-region="paging-bar"]',
- PAGE_ITEM: '[data-region="page-item"]',
- ACTIVE_PAGE_ITEM: '[data-region="page-item"].active'
- };
-
- var EVENTS = {
- PAGE_SELECTED: 'block_myoverview-paging-bar-page-selected',
- };
-
- /**
- * Get the page element by number.
- *
- * @param {object} root The root element.
- * @param {Number} pageNumber The page number.
- * @returns {*}
- */
- var getPageByNumber = function(root, pageNumber) {
- return root.find(SELECTORS.PAGE_ITEM + '[data-page-number="' + pageNumber + '"]');
- };
-
- /**
- * Get the page number.
- *
- * @param {object} root The root element.
- * @param {object} page The page.
- * @returns {*} the page number
- */
- var getPageNumber = function(root, page) {
- var pageNumber = page.attr('data-page-number');
-
- if (pageNumber == 'first') {
- pageNumber = 1;
- } else if (pageNumber == 'last') {
- pageNumber = root.attr('data-page-count');
- }
-
- return pageNumber;
- };
-
- /**
- * Register event listeners for the module.
- * @param {object} root The root element.
- */
- var registerEventListeners = function(root) {
- root = $(root);
- CustomEvents.define(root, [
- CustomEvents.events.activate
- ]);
-
- root.on(CustomEvents.events.activate, SELECTORS.PAGE_ITEM, function(e, data) {
- var page = $(e.target).closest(SELECTORS.PAGE_ITEM);
- var activePage = root.find(SELECTORS.ACTIVE_PAGE_ITEM);
- var pageNumber = getPageNumber(root, page);
- var isSamePage = pageNumber == getPageNumber(root, activePage);
-
- if (!isSamePage) {
- root.find(SELECTORS.PAGE_ITEM).removeClass('active');
- getPageByNumber(root, pageNumber).addClass('active');
- }
-
- root.trigger(EVENTS.PAGE_SELECTED, [{
- pageNumber: pageNumber,
- isSamePage: isSamePage,
- }]);
-
- data.originalEvent.preventDefault();
- });
- };
-
- return {
- registerEventListeners: registerEventListeners,
- events: EVENTS,
- rootSelector: SELECTORS.ROOT,
- };
-});
diff --git a/blocks/myoverview/amd/src/paging_content.js b/blocks/myoverview/amd/src/paging_content.js
deleted file mode 100644
index 1e33daef02d..00000000000
--- a/blocks/myoverview/amd/src/paging_content.js
+++ /dev/null
@@ -1,105 +0,0 @@
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle. If not, see .
-
-/**
- * Paging content module.
- *
- * @module block_myoverview/paging_content
- * @package block_myoverview
- * @copyright 2016 Ryan Wyllie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-define(['jquery', 'core/templates', 'block_myoverview/paging_bar'],
- function($, Templates, PagingBar) {
-
- var SELECTORS = {
- ROOT: '[data-region="paging-content"]',
- PAGE_REGION: '[data-region="paging-content-item"]'
- };
-
- /**
- * Constructor of the paging content module.
- *
- * @param {object} root
- * @param {object} pagingBarElement
- * @constructor
- */
- var PagingContent = function(root, pagingBarElement) {
- this.root = $(root);
- this.pagingBar = $(pagingBarElement);
-
- };
-
- PagingContent.rootSelector = SELECTORS.ROOT;
-
- /**
- * Load content and create page.
- *
- * @param {Number} pageNumber
- * @returns {*|Promise}
- */
- PagingContent.prototype.createPage = function(pageNumber) {
-
- return this.loadContent(pageNumber).then(function(html, js) {
- Templates.appendNodeContents(this.root, html, js);
- }.bind(this)).then(function() {
- return this.findPage(pageNumber);
- }.bind(this)
- );
- };
-
- /**
- * Find a page by the number.
- *
- * @param {Number} pageNumber The number of the page to be found.
- * @returns {*} Page root
- */
- PagingContent.prototype.findPage = function(pageNumber) {
- return this.root.find('[data-page="' + pageNumber + '"]');
- };
-
- /**
- * Make a page visible.
- *
- * @param {Number} pageNumber The number of the page to be visible.
- */
- PagingContent.prototype.showPage = function(pageNumber) {
-
- var existingPage = this.findPage(pageNumber);
- this.root.find(SELECTORS.PAGE_REGION).addClass('hidden');
-
- if (existingPage.length) {
- existingPage.removeClass('hidden');
- } else {
- this.createPage(pageNumber).done(function(newPage) {
- newPage.removeClass('hidden');
- });
- }
- };
-
- /**
- * Event listeners.
- */
- PagingContent.prototype.registerEventListeners = function() {
-
- this.pagingBar.on(PagingBar.events.PAGE_SELECTED, function(e, data) {
- if (!data.isSamePage) {
- this.showPage(data.pageNumber);
- }
- }.bind(this));
- };
-
- return PagingContent;
-});
diff --git a/blocks/myoverview/amd/src/repository.js b/blocks/myoverview/amd/src/repository.js
new file mode 100644
index 00000000000..b4f7b5d83e5
--- /dev/null
+++ b/blocks/myoverview/amd/src/repository.js
@@ -0,0 +1,53 @@
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see .
+
+/**
+ * A javascript module to retrieve enrolled coruses from the server.
+ *
+ * @package block_myoverview
+ * @copyright 2018 Bas Brands
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+define(['core/ajax'], function(Ajax) {
+
+ /**
+ * Retrieve a list of enrolled courses.
+ *
+ * Valid args are:
+ * string classification future, inprogress, past
+ * int limit number of records to retreive
+ * int Offset offset for pagination
+ * int sort sort by lastaccess or name
+ *
+ * @method getEnrolledCoursesByTimeline
+ * @param {object} args The request arguments
+ * @return {promise} Resolved with an array of courses
+ */
+ var getEnrolledCoursesByTimeline = function(args) {
+
+ var request = {
+ methodname: 'core_course_get_enrolled_courses_by_timeline_classification',
+ args: args
+ };
+
+ var promise = Ajax.call([request])[0];
+
+ return promise;
+ };
+
+ return {
+ getEnrolledCoursesByTimeline: getEnrolledCoursesByTimeline
+ };
+});
diff --git a/blocks/myoverview/amd/src/view.js b/blocks/myoverview/amd/src/view.js
new file mode 100644
index 00000000000..b6b6c626dff
--- /dev/null
+++ b/blocks/myoverview/amd/src/view.js
@@ -0,0 +1,188 @@
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see .
+
+/**
+ * Manage the courses view for the overview block.
+ *
+ * @package block_myoverview
+ * @copyright 2018 Bas Brands
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+define(
+[
+ 'jquery',
+ 'core/notification',
+ 'block_myoverview/repository',
+ 'core/paged_content_factory',
+ 'core/templates',
+],
+function(
+ $,
+ Notification,
+ Repository,
+ PagedContentFactory,
+ Templates
+) {
+
+ var TEMPLATES = {
+ COURSES_CARDS: 'block_myoverview/view-cards',
+ COURSES_LIST: 'block_myoverview/view-list',
+ COURSES_SUMMARY: 'block_myoverview/view-summary',
+ NOCOURSES: 'block_myoverview/no-courses'
+ };
+
+ var NUMCOURSES_PERPAGE = [12, 24];
+
+ var currentCourseList = [];
+
+ /**
+ * Get filter values from DOM.
+ *
+ * @param {object} root The root element for the courses view.
+ * @return {filters} Set filters.
+ */
+ var getFilterValues = function(root) {
+ var filters = {};
+ filters.display = root.attr('data-display');
+ filters.grouping = root.attr('data-grouping');
+ filters.sort = root.attr('data-sort');
+ return filters;
+ };
+
+ // We want the paged content controls below the paged content area
+ // and the controls should be ignored while data is loading.
+ var DEFAULT_PAGED_CONTENT_CONFIG = {
+ ignoreControlWhileLoading: true,
+ controlPlacementBottom: true,
+ };
+
+ /**
+ * Get enrolled courses from backend.
+ *
+ * @param {object} filters The filters for this view.
+ * @param {int} limit The number of courses to show.
+ * @param {int} pageNumber The pagenumber to view.
+ * @return {promise} Resolved with an array of courses.
+ */
+ var getMyCourses = function(filters, limit, pageNumber) {
+ return Repository.getEnrolledCoursesByTimeline({
+ offset: pageNumber * limit,
+ limit: limit,
+ classification: filters.grouping,
+ sort: filters.sort
+ });
+ };
+
+ /**
+ * Render the dashboard courses.
+ *
+ * @param {object} root The root element for the courses view.
+ * @param {array} coursesData containing array of returned courses.
+ * @param {object} filters The filters for this view.
+ * @return {promise} jQuery promise resolved after rendering is complete.
+ */
+ var renderCourses = function(root, coursesData, filters) {
+
+ var currentTemplate = '';
+ if (filters.display == 'cards') {
+ currentTemplate = TEMPLATES.COURSES_CARDS;
+ } else if (filters.display == 'list') {
+ currentTemplate = TEMPLATES.COURSES_LIST;
+ } else {
+ currentTemplate = TEMPLATES.COURSES_SUMMARY;
+ }
+
+ if (coursesData.courses.length) {
+ return Templates.render(currentTemplate, {
+ courses: coursesData.courses
+ });
+ } else {
+ var nocoursesimg = root.attr('data-nocoursesimg');
+ return Templates.render(TEMPLATES.NOCOURSES, {
+ nocoursesimg: nocoursesimg
+ });
+ }
+ };
+
+ /**
+ * Intialise the courses list and cards views on page load.
+ *
+ * @param {object} root The root element for the courses view.
+ * @param {object} content The content element for the courses view.
+ */
+ var init = function(root, content) {
+
+ root = $(root);
+
+ var filters = getFilterValues(root);
+
+ var pagedContentPromise = PagedContentFactory.createWithLimit(
+ NUMCOURSES_PERPAGE,
+ function(pagesData, actions) {
+ var promises = [];
+
+ pagesData.forEach(function(pageData) {
+ var pageNumber = pageData.pageNumber - 1;
+
+ var pagePromise = getMyCourses(
+ filters,
+ pageData.limit,
+ pageNumber
+ ).then(function(coursesData) {
+ if (coursesData.courses.length < pageData.limit) {
+ actions.allItemsLoaded(pageData.pageNumber);
+ }
+ currentCourseList = coursesData;
+ return renderCourses(root, coursesData, filters);
+ })
+ .catch(Notification.exception);
+
+ promises.push(pagePromise);
+ });
+
+ return promises;
+ },
+ DEFAULT_PAGED_CONTENT_CONFIG
+ );
+
+ pagedContentPromise.then(function(html, js) {
+ return Templates.replaceNodeContents(content, html, js);
+ }).catch(Notification.exception);
+ };
+
+ /**
+ * Reset the courses views to their original
+ * state on first page load.
+ *
+ * This is called when configuration has changed for the event lists
+ * to cause them to reload their data.
+ *
+ * @param {object} root The root element for the timeline view.
+ * @param {object} content The content element for the timeline view.
+ */
+ var reset = function(root, content) {
+ var filters = getFilterValues(root);
+ renderCourses(root, currentCourseList, filters)
+ .then(function(html, js) {
+ return Templates.replaceNodeContents(content, html, js);
+ }).catch(Notification.exception);
+ };
+
+ return {
+ init: init,
+ reset: reset
+ };
+});
diff --git a/blocks/myoverview/amd/src/view_nav.js b/blocks/myoverview/amd/src/view_nav.js
new file mode 100644
index 00000000000..131c3865f5a
--- /dev/null
+++ b/blocks/myoverview/amd/src/view_nav.js
@@ -0,0 +1,109 @@
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see .
+
+/**
+ * Manage the timeline view navigation for the overview block.
+ *
+ * @package block_myoverview
+ * @copyright 2018 Bas Brands
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+define(
+[
+ 'jquery',
+ 'core/custom_interaction_events',
+ 'block_myoverview/view'
+],
+function(
+ $,
+ CustomEvents,
+ View
+) {
+
+ var SELECTORS = {
+ FILTERS: '[data-region="filter"]',
+ FILTER_OPTION: '[data-filter]',
+ DISPLAY_OPTION: '[data-display-option]'
+ };
+
+ /**
+ * Event listener for the Display filter (cards, list).
+ *
+ * @param {object} root The root element for the overview block
+ * @param {object} viewRoot The root element for displaying courses.
+ * @param {object} viewContent content The content element for the courses view.
+ */
+ var registerSelector = function(root, viewRoot, viewContent) {
+
+ var Selector = root.find(SELECTORS.FILTERS);
+
+ CustomEvents.define(Selector, [CustomEvents.events.activate]);
+ Selector.on(
+ CustomEvents.events.activate,
+ SELECTORS.FILTER_OPTION,
+ function(e, data) {
+ var option = $(e.target);
+
+ if (option.hasClass('active')) {
+ // If it's already active then we don't need to do anything.
+ return;
+ }
+
+ var attributename = 'data-' + option.attr('data-filter');
+ viewRoot.attr(attributename, option.attr('data-value'));
+
+ // Reset the views.
+ View.init(viewRoot, viewContent);
+
+ data.originalEvent.preventDefault();
+ }
+ );
+
+ CustomEvents.define(Selector, [CustomEvents.events.activate]);
+ Selector.on(
+ CustomEvents.events.activate,
+ SELECTORS.DISPLAY_OPTION,
+ function(e, data) {
+ var option = $(e.target);
+
+ if (option.hasClass('active')) {
+ return;
+ }
+
+ viewRoot.attr('data-display', option.attr('data-value'));
+ View.reset(viewRoot, viewContent);
+ data.originalEvent.preventDefault();
+ }
+ );
+ };
+
+ /**
+ * Initialise the timeline view navigation by adding event listeners to
+ * the navigation elements.
+ *
+ * @param {object} root The root element for the myoverview block
+ * @param {object} viewRoot The root element for the myoverview block
+ * @param {object} viewContent The content element for the myoverview block
+ */
+ var init = function(root, viewRoot, viewContent) {
+ root = $(root);
+ registerSelector(root, viewRoot, viewContent);
+ };
+
+ return {
+ init: init
+ };
+});
diff --git a/blocks/myoverview/classes/output/courses_view.php b/blocks/myoverview/classes/output/courses_view.php
deleted file mode 100644
index 2c6027e0436..00000000000
--- a/blocks/myoverview/classes/output/courses_view.php
+++ /dev/null
@@ -1,189 +0,0 @@
-.
-
-/**
- * Class containing data for courses view in the myoverview block.
- *
- * @package block_myoverview
- * @copyright 2017 Ryan Wyllie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-namespace block_myoverview\output;
-defined('MOODLE_INTERNAL') || die();
-
-use renderable;
-use renderer_base;
-use templatable;
-use core_course\external\course_summary_exporter;
-
-/**
- * Class containing data for courses view in the myoverview block.
- *
- * @copyright 2017 Simey Lameze
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class courses_view implements renderable, templatable {
- /** Quantity of courses per page. */
- const COURSES_PER_PAGE = 6;
-
- /** @var array $courses List of courses the user is enrolled in. */
- protected $courses = [];
-
- /** @var array $coursesprogress List of progress percentage for each course. */
- protected $coursesprogress = [];
-
- /**
- * The courses_view constructor.
- *
- * @param array $courses list of courses.
- * @param array $coursesprogress list of courses progress.
- */
- public function __construct($courses, $coursesprogress) {
- $this->courses = $courses;
- $this->coursesprogress = $coursesprogress;
- }
-
- /**
- * Export this data so it can be used as the context for a mustache template.
- *
- * @param \renderer_base $output
- * @return array
- */
- public function export_for_template(renderer_base $output) {
- global $CFG;
- require_once($CFG->dirroot.'/course/lib.php');
-
- // Build courses view data structure.
- $coursesview = [
- 'hascourses' => !empty($this->courses)
- ];
-
- // How many courses we have per status?
- $coursesbystatus = ['past' => 0, 'inprogress' => 0, 'future' => 0];
- foreach ($this->courses as $course) {
- $courseid = $course->id;
- $context = \context_course::instance($courseid);
- $exporter = new course_summary_exporter($course, [
- 'context' => $context
- ]);
- $exportedcourse = $exporter->export($output);
- // Convert summary to plain text.
- $exportedcourse->summary = content_to_text($exportedcourse->summary, $exportedcourse->summaryformat);
-
- $course = new \core_course_list_element($course);
- foreach ($course->get_course_overviewfiles() as $file) {
- $isimage = $file->is_valid_image();
- if ($isimage) {
- $url = file_encode_url("$CFG->wwwroot/pluginfile.php",
- '/'. $file->get_contextid(). '/'. $file->get_component(). '/'.
- $file->get_filearea(). $file->get_filepath(). $file->get_filename(), !$isimage);
- $exportedcourse->courseimage = $url;
- $exportedcourse->classes = 'courseimage';
- break;
- }
- }
-
- $exportedcourse->color = $this->coursecolor($course->id);
-
- if (!isset($exportedcourse->courseimage)) {
- $pattern = new \core_geopattern();
- $pattern->setColor($exportedcourse->color);
- $pattern->patternbyid($courseid);
- $exportedcourse->classes = 'coursepattern';
- $exportedcourse->courseimage = $pattern->datauri();
- }
-
- // Include course visibility.
- $exportedcourse->visible = (bool)$course->visible;
-
- $courseprogress = null;
-
- $classified = course_classify_for_timeline($course);
-
- if (isset($this->coursesprogress[$courseid])) {
- $courseprogress = $this->coursesprogress[$courseid]['progress'];
- $exportedcourse->hasprogress = !is_null($courseprogress);
- $exportedcourse->progress = $courseprogress;
- }
-
- if ($classified == COURSE_TIMELINE_PAST) {
- // Courses that have already ended.
- $pastpages = floor($coursesbystatus['past'] / $this::COURSES_PER_PAGE);
-
- $coursesview['past']['pages'][$pastpages]['courses'][] = $exportedcourse;
- $coursesview['past']['pages'][$pastpages]['active'] = ($pastpages == 0 ? true : false);
- $coursesview['past']['pages'][$pastpages]['page'] = $pastpages + 1;
- $coursesview['past']['haspages'] = true;
- $coursesbystatus['past']++;
- } else if ($classified == COURSE_TIMELINE_FUTURE) {
- // Courses that have not started yet.
- $futurepages = floor($coursesbystatus['future'] / $this::COURSES_PER_PAGE);
-
- $coursesview['future']['pages'][$futurepages]['courses'][] = $exportedcourse;
- $coursesview['future']['pages'][$futurepages]['active'] = ($futurepages == 0 ? true : false);
- $coursesview['future']['pages'][$futurepages]['page'] = $futurepages + 1;
- $coursesview['future']['haspages'] = true;
- $coursesbystatus['future']++;
- } else {
- // Courses still in progress. Either their end date is not set, or the end date is not yet past the current date.
- $inprogresspages = floor($coursesbystatus['inprogress'] / $this::COURSES_PER_PAGE);
-
- $coursesview['inprogress']['pages'][$inprogresspages]['courses'][] = $exportedcourse;
- $coursesview['inprogress']['pages'][$inprogresspages]['active'] = ($inprogresspages == 0 ? true : false);
- $coursesview['inprogress']['pages'][$inprogresspages]['page'] = $inprogresspages + 1;
- $coursesview['inprogress']['haspages'] = true;
- $coursesbystatus['inprogress']++;
- }
- }
-
- // Build courses view paging bar structure.
- foreach ($coursesbystatus as $status => $total) {
- $quantpages = ceil($total / $this::COURSES_PER_PAGE);
-
- if ($quantpages) {
- $coursesview[$status]['pagingbar']['disabled'] = ($quantpages <= 1);
- $coursesview[$status]['pagingbar']['pagecount'] = $quantpages;
- $coursesview[$status]['pagingbar']['first'] = ['page' => '«', 'url' => '#'];
- $coursesview[$status]['pagingbar']['last'] = ['page' => '»', 'url' => '#'];
- for ($page = 0; $page < $quantpages; $page++) {
- $coursesview[$status]['pagingbar']['pages'][$page] = [
- 'number' => $page + 1,
- 'page' => $page + 1,
- 'url' => '#',
- 'active' => ($page == 0 ? true : false)
- ];
- }
- }
- }
-
- return $coursesview;
- }
-
- /**
- * Generate a semi-random color based on the courseid number (so it will always return
- * the same color for a course)
- *
- * @param int $courseid
- * @return string $color, hexvalue color code.
- */
- protected function coursecolor($courseid) {
- // The colour palette is hardcoded for now. It would make sense to combine it with theme settings.
- $basecolors = ['#81ecec', '#74b9ff', '#a29bfe', '#dfe6e9', '#00b894', '#0984e3', '#b2bec3', '#fdcb6e', '#fd79a8', '#6c5ce7'];
-
- $color = $basecolors[$courseid % 10];
- return $color;
- }
-}
diff --git a/blocks/myoverview/classes/output/main.php b/blocks/myoverview/classes/output/main.php
index 46834f318b3..c734468c192 100644
--- a/blocks/myoverview/classes/output/main.php
+++ b/blocks/myoverview/classes/output/main.php
@@ -27,14 +27,13 @@ defined('MOODLE_INTERNAL') || die();
use renderable;
use renderer_base;
use templatable;
-use core_completion\progress;
require_once($CFG->libdir . '/completionlib.php');
/**
* Class containing data for my overview block.
*
- * @copyright 2017 Simey Lameze
+ * @copyright 2018 Bas Brands
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class main implements renderable, templatable {
@@ -45,38 +44,11 @@ class main implements renderable, templatable {
* @return stdClass
*/
public function export_for_template(renderer_base $output) {
- global $USER;
- $courses = enrol_get_my_courses('*');
- $coursesprogress = [];
-
- foreach ($courses as $course) {
-
- $completion = new \completion_info($course);
-
- // First, let's make sure completion is enabled.
- if (!$completion->is_enabled()) {
- continue;
- }
-
- $percentage = progress::get_course_progress_percentage($course);
- if (!is_null($percentage)) {
- $percentage = floor($percentage);
- }
-
- $coursesprogress[$course->id]['completed'] = $completion->is_course_complete($USER->id);
- $coursesprogress[$course->id]['progress'] = $percentage;
- }
-
- $coursesview = new courses_view($courses, $coursesprogress);
$nocoursesurl = $output->image_url('courses', 'block_myoverview')->out();
- return [
- 'midnight' => usergetmidnight(time()),
- 'coursesview' => $coursesview->export_for_template($output),
- 'urls' => [
- 'nocourses' => $nocoursesurl,
- ],
+ return (object) [
+ 'nocoursesimg' => $nocoursesurl
];
}
}
diff --git a/blocks/myoverview/db/upgrade.php b/blocks/myoverview/db/upgrade.php
deleted file mode 100644
index b91cb9613a3..00000000000
--- a/blocks/myoverview/db/upgrade.php
+++ /dev/null
@@ -1,41 +0,0 @@
-.
-
-/**
- * This file keeps track of upgrades to the myoverview block
- *
- * @package block_myoverview
- * @copyright 2018 Ryan Wyllie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-/**
- * Upgrade code for the myoverview block.
- *
- * @param int $oldversion
- */
-function xmldb_block_myoverview_upgrade($oldversion) {
- global $DB;
-
- if ($oldversion < 2018092700) {
- $DB->delete_records('user_preferences', ['name' => 'block_myoverview_last_tab']);
- upgrade_block_savepoint(true, 2018092700, 'myoverview');
- }
-
- return true;
-}
diff --git a/blocks/myoverview/lang/en/block_myoverview.php b/blocks/myoverview/lang/en/block_myoverview.php
index df3ae6652b4..49fe21c2907 100644
--- a/blocks/myoverview/lang/en/block_myoverview.php
+++ b/blocks/myoverview/lang/en/block_myoverview.php
@@ -22,17 +22,48 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+$string['all'] = 'All';
+$string['aria:allcourses'] = 'All courses';
+$string['aria:card'] = 'Switch to card view';
+$string['aria:controls'] = 'Course overview controls';
+$string['aria:courseimage'] = 'Course image:';
+$string['aria:coursename'] = 'Course name:';
+$string['aria:coursesummary'] = 'Course summary text:';
+$string['aria:courseprogress'] = 'Course progress:';
+$string['aria:displaydropdown'] = 'Display dropdown';
+$string['aria:future'] = 'Show future courses';
+$string['aria:groupingdropdown'] = 'Grouping dropdown';
+$string['aria:inprogress'] = 'Show in courses in progress';
+$string['aria:lastaccessed'] = 'Sort courses by last accessed date';
+$string['aria:list'] = 'Switch to list view';
+$string['aria:title'] = 'Sort courses by title';
+$string['aria:past'] = 'Show past courses';
+$string['aria:summary'] = 'Switch to summary view';
+$string['aria:sortingdropdown'] = 'Sorting dropdown';
+$string['card'] = 'Card';
+$string['courseprogress'] = 'Course progress:';
+$string['complete'] = 'Complete';
+$string['favorite'] = 'Favorite';
$string['future'] = 'Future';
+$string['future:aria'] = 'View future courses';
+$string['hidden'] = 'Hidden';
$string['inprogress'] = 'In progress';
+$string['inprogress:aria'] = 'View in progress courses';
+$string['lastaccessed'] = 'Last accessed';
+$string['lastaccessed:aria'] = 'Sort course by lastaccessed';
+$string['list'] = 'List';
$string['morecourses'] = 'More courses';
$string['myoverview:addinstance'] = 'Add a new course overview block';
$string['myoverview:myaddinstance'] = 'Add a new course overview block to Dashboard';
-$string['nocourses'] = 'No courses';
-$string['nocoursesinprogress'] = 'No in progress courses';
$string['nocoursesfuture'] = 'No future courses';
+$string['nocoursesinprogress'] = 'No in progress courses';
+$string['nocourses'] = 'No courses';
$string['nocoursespast'] = 'No past courses';
$string['past'] = 'Past';
$string['pluginname'] = 'Course overview';
-$string['viewcourse'] = 'View course';
-$string['viewcoursename'] = 'View course {$a}';
$string['privacy:metadata'] = 'The myoverview block does not store any personal data.';
+$string['summary'] = 'Summary';
+$string['title'] = 'Title';
+$string['viewcoursename'] = 'View course {$a}';
+$string['viewcourse'] = 'View course';
+
diff --git a/blocks/myoverview/templates/course-paging-content-item.mustache b/blocks/myoverview/templates/course-paging-content-item.mustache
deleted file mode 100644
index bbaa63715af..00000000000
--- a/blocks/myoverview/templates/course-paging-content-item.mustache
+++ /dev/null
@@ -1,47 +0,0 @@
-{{!
- This file is part of Moodle - http://moodle.org/
-
- Moodle is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Moodle is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Moodle. If not, see .
-}}
-{{!
- @template block_myoverview/course-paging-content-item
-
- This template renders each course block.
-
- Example context (json):
- {
- "page": 1,
- "active": true,
- "courses": [
- {
- "fullnamedisplay": "course 1",
- "viewurl": "https://www.google.com",
- "summary": "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout."
- },
- {
- "fullnamedisplay": "course 2",
- "viewurl": "https://www.google.com",
- "summary": "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout."
- }
- ]
- }
-}}
-{{< block_myoverview/paging-content-item }}
- {{$classes}}row card-deck{{/classes}}
- {{$content}}
- {{#courses}}
- {{> block_myoverview/courses-view-course-item }}
- {{/courses}}
- {{/content}}
-{{/ block_myoverview/paging-content-item }}
diff --git a/blocks/myoverview/templates/course-paging-content.mustache b/blocks/myoverview/templates/course-paging-content.mustache
deleted file mode 100644
index 85ee437df13..00000000000
--- a/blocks/myoverview/templates/course-paging-content.mustache
+++ /dev/null
@@ -1,48 +0,0 @@
-{{!
- This file is part of Moodle - http://moodle.org/
-
- Moodle is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Moodle is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Moodle. If not, see .
-}}
-{{!
- @template block_myoverview/course-paging-content
-
- This template renders the each course block containing a summary and calendar events.
-
- Example context (json):
- {
- "pages": [
- {
- "page": 1,
- "active": true,
- "courses": [
- {
- "fullnamedisplay": "course 1",
- "viewurl": "https://www.google.com",
- "summary": "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout."
- },
- {
- "fullnamedisplay": "course 2",
- "viewurl": "https://www.google.com",
- "summary": "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout."
- }
- ]
- }
- ]
- }
-}}
-{{< block_myoverview/paging-content }}
- {{$paging-content-item}}
- {{> block_myoverview/course-paging-content-item }}
- {{/paging-content-item}}
-{{/ block_myoverview/paging-content }}
diff --git a/blocks/myoverview/templates/courses-view-by-status.mustache b/blocks/myoverview/templates/courses-view-by-status.mustache
deleted file mode 100644
index 3360d55db46..00000000000
--- a/blocks/myoverview/templates/courses-view-by-status.mustache
+++ /dev/null
@@ -1,45 +0,0 @@
-{{!
- This file is part of Moodle - http://moodle.org/
-
- Moodle is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Moodle is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Moodle. If not, see .
-}}
-{{!
- @template block_myoverview/courses-view-by-status
-
- This template renders the courses view for the myoverview block.
-
- Example context (json):
- {}
-}}
-
-{{#js}}
-require(['jquery', 'block_myoverview/paging_bar', 'block_myoverview/paging_content'],
- function($, PagingBar, PagingContent) {
-
- var root = $('#{{$id}}courses-view-status-{{uniqid}}{{/id}}');
- var pagingBarElement = root.find(PagingBar.rootSelector);
- var pagingContentElement = root.find(PagingContent.rootSelector);
-
- var content = new PagingContent(pagingContentElement, pagingBarElement);
- content.registerEventListeners();
-});
-{{/js}}
diff --git a/blocks/myoverview/templates/courses-view-course-item.mustache b/blocks/myoverview/templates/courses-view-course-item.mustache
deleted file mode 100644
index db2034d70fc..00000000000
--- a/blocks/myoverview/templates/courses-view-course-item.mustache
+++ /dev/null
@@ -1,49 +0,0 @@
-{{!
- This file is part of Moodle - http://moodle.org/
-
- Moodle is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Moodle is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Moodle. If not, see .
-}}
-{{!
- @template block_myoverview/courses-view-course-item
-
- This template renders the course summary (view by courses) for the myoverview block.
-
- Example context (json):
- {
- "fullnamedisplay": "course 3",
- "viewurl": "https://www.google.com",
- "summary": "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout."
- }
-}}
-
\ No newline at end of file
diff --git a/blocks/myoverview/templates/courses-view-nav-grouping-display-filter.mustache b/blocks/myoverview/templates/courses-view-nav-grouping-display-filter.mustache
deleted file mode 100644
index f7aa27534b4..00000000000
--- a/blocks/myoverview/templates/courses-view-nav-grouping-display-filter.mustache
+++ /dev/null
@@ -1,40 +0,0 @@
-{{!
- This file is part of Moodle - http://moodle.org/
-
- Moodle is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Moodle is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Moodle. If not, see .
-}}
-{{!
- @template block_myoverview/courses-view-nav-grouping-display-filter
-
- This template renders the main content area for the myoverview block.
-
- Example context (json):
- {}
-}}
-
+{{#js}}
+require(
+[
+ 'jquery',
+ 'block_myoverview/main',
+],
+function(
+ $,
+ Main
+) {
+ var root = $('#block-myoverview-{{uniqid}}');
+ Main.init(root);
+});
+{{/js}}
diff --git a/blocks/myoverview/templates/nav-display-selector.mustache b/blocks/myoverview/templates/nav-display-selector.mustache
new file mode 100644
index 00000000000..e5661dcc473
--- /dev/null
+++ b/blocks/myoverview/templates/nav-display-selector.mustache
@@ -0,0 +1,47 @@
+{{!
+ This file is part of Moodle - http://moodle.org/
+
+ Moodle is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Moodle is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Moodle. If not, see .
+}}
+{{!
+ @template block_myoverview/nav-display-selector
+
+ This template renders display dropdown.
+
+ Example context (json):
+ {}
+}}
+
\ No newline at end of file
diff --git a/blocks/myoverview/templates/nav-grouping-selector.mustache b/blocks/myoverview/templates/nav-grouping-selector.mustache
new file mode 100644
index 00000000000..ac57aa7bb3b
--- /dev/null
+++ b/blocks/myoverview/templates/nav-grouping-selector.mustache
@@ -0,0 +1,51 @@
+{{!
+ This file is part of Moodle - http://moodle.org/
+
+ Moodle is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Moodle is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Moodle. If not, see .
+}}
+{{!
+ @template block_myoverview/nav-grouping-selector
+
+ This template renders grouping dropdown.
+
+ Example context (json):
+ {}
+}}
+
diff --git a/blocks/myoverview/templates/nav-sort-selector.mustache b/blocks/myoverview/templates/nav-sort-selector.mustache
new file mode 100644
index 00000000000..e647be94e50
--- /dev/null
+++ b/blocks/myoverview/templates/nav-sort-selector.mustache
@@ -0,0 +1,43 @@
+{{!
+ This file is part of Moodle - http://moodle.org/
+
+ Moodle is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Moodle is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Moodle. If not, see .
+}}
+{{!
+ @template block_myoverview/nav-sort-selector
+
+ This template renders sorting dropdown.
+
+ Example context (json):
+ {}
+}}
+
+
\ No newline at end of file
diff --git a/blocks/myoverview/templates/paging-bar-item.mustache b/blocks/myoverview/templates/no-courses.mustache
similarity index 57%
rename from blocks/myoverview/templates/paging-bar-item.mustache
rename to blocks/myoverview/templates/no-courses.mustache
index 955ff02d991..46fab9f1ffe 100644
--- a/blocks/myoverview/templates/paging-bar-item.mustache
+++ b/blocks/myoverview/templates/no-courses.mustache
@@ -15,27 +15,19 @@
along with Moodle. If not, see .
}}
{{!
- @template block_myoverview/paging-bar-item
+ @template block_myoverview/no-courses
- This template renders a single item in the paging bar.
+ This template renders the no courses message.
Example context (json):
{
- "url": "#",
- "number": 1,
- "page": "1",
- "active": true
+ "nocoursesimg": "https://moodlesite/theme/image.php/boost/block_myoverview/1535727318/courses"
}
}}
-
\ No newline at end of file
diff --git a/blocks/myoverview/templates/paging-bar.mustache b/blocks/myoverview/templates/paging-bar.mustache
deleted file mode 100644
index 71ffecffcd4..00000000000
--- a/blocks/myoverview/templates/paging-bar.mustache
+++ /dev/null
@@ -1,96 +0,0 @@
-{{!
- This file is part of Moodle - http://moodle.org/
-
- Moodle is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Moodle is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Moodle. If not, see .
-}}
-{{!
- @template block_myoverview/paging-bar
-
- This template renders the bootstrap style paging bar.
-
- Example context (json):
- {
- "pagingbar": {
- "pagecount": 2,
- "previous": {},
- "next": {},
- "first": {
- "url": "#",
- "page": "first"
- },
- "last": {
- "url": "#",
- "page": "last"
- },
- "pages": [
- {
- "url": "#",
- "number": 1,
- "page": "1",
- "active": true
- },
- {
- "url": "#",
- "number": 2,
- "page": "2"
- }
- ]
- }
- }
-}}
-{{#pagingbar}}
-
-{{#js}}
-require(['jquery', 'block_myoverview/paging_bar'], function($, PagingBar) {
- var root = $('#{{$pagingbarid}}paging-bar-{{uniqid}}{{/pagingbarid}}');
- PagingBar.registerEventListeners(root);
-});
-{{/js}}
-{{/pagingbar}}
diff --git a/blocks/myoverview/templates/paging-content.mustache b/blocks/myoverview/templates/paging-content.mustache
deleted file mode 100644
index 83a9cdd799b..00000000000
--- a/blocks/myoverview/templates/paging-content.mustache
+++ /dev/null
@@ -1,44 +0,0 @@
-{{!
- This file is part of Moodle - http://moodle.org/
-
- Moodle is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Moodle is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Moodle. If not, see .
-}}
-{{!
- @template block_myoverview/paging-content
-
- This template renders each of the content regions for a paginated
- content section.
-
- Example context (json):
- {
- "pages": [
- {
- "active": true,
- "page": 1,
- "content": "
diff --git a/theme/bootstrapbase/templates/block_myoverview/paging-content-item.mustache b/blocks/myoverview/templates/placeholder-course.mustache
similarity index 59%
rename from theme/bootstrapbase/templates/block_myoverview/paging-content-item.mustache
rename to blocks/myoverview/templates/placeholder-course.mustache
index b70a1d25034..9b4aad34f80 100644
--- a/theme/bootstrapbase/templates/block_myoverview/paging-content-item.mustache
+++ b/blocks/myoverview/templates/placeholder-course.mustache
@@ -15,22 +15,19 @@
along with Moodle. If not, see .
}}
{{!
- @template block_myoverview/paging-content-item
+ @template block_myoverview/placeholder-course
- This template renders the content of a page. It is to be used with
- the paging bar to toggle visibility of the content items.
+ This template renders an course card item loading placeholder for the myoverview block.
Example context (json):
- {
- "active": true,
- "page": 1,
- "content": "
Some page content
"
- }
+ {}
}}
-
- {{$content}}
- {{{content}}}
- {{/content}}
-
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/blocks/myoverview/templates/paging-content-item.mustache b/blocks/myoverview/templates/progress-bar.mustache
similarity index 60%
rename from blocks/myoverview/templates/paging-content-item.mustache
rename to blocks/myoverview/templates/progress-bar.mustache
index 82e73e19bde..c95f8c9f1a5 100644
--- a/blocks/myoverview/templates/paging-content-item.mustache
+++ b/blocks/myoverview/templates/progress-bar.mustache
@@ -15,22 +15,20 @@
along with Moodle. If not, see .
}}
{{!
- @template block_myoverview/paging-content-item
+ @template block_myoverview/progress-bar
- This template renders the content of a page. It is to be used with
- the paging bar to toggle visibility of the content items.
+ This template renders a simple progress bar.
Example context (json):
{
- "active": true,
- "page": 1,
- "content": "
\ No newline at end of file
diff --git a/blocks/myoverview/templates/progress-chart.mustache b/blocks/myoverview/templates/progress-chart.mustache
deleted file mode 100644
index 18ff2a40890..00000000000
--- a/blocks/myoverview/templates/progress-chart.mustache
+++ /dev/null
@@ -1,50 +0,0 @@
-{{!
- This file is part of Moodle - http://moodle.org/
-
- Moodle is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Moodle is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Moodle. If not, see .
-}}
-{{!
- @template block_myoverview/progress-chart
-
- This template renders a doughnut chart to show course progress.
-
- Example context (json):
- {
- "hasprogress": true,
- "progress": "60"
- }
-}}
-
- {{#hasprogress}}
-
-
{{progress}}%
-
-
-
-
- {{/hasprogress}}
- {{^hasprogress}}
-
- {{#pix}} i/course {{/pix}}
-
- {{/hasprogress}}
-
diff --git a/blocks/myoverview/templates/view-cards.mustache b/blocks/myoverview/templates/view-cards.mustache
new file mode 100644
index 00000000000..8b0eaa312c8
--- /dev/null
+++ b/blocks/myoverview/templates/view-cards.mustache
@@ -0,0 +1,62 @@
+{{!
+ This file is part of Moodle - http://moodle.org/
+
+ Moodle is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Moodle is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Moodle. If not, see .
+}}
+{{!
+ @template block_myoverview/view-cards
+
+ This template renders the cards view for the myoverview block.
+
+ Example context (json):
+ {
+ "courses": [
+ {
+ "name": "Assignment due 1",
+ "viewurl": "https://moodlesite/course/view.php?id=2",
+ "courseimage": "https://moodlesite/pluginfile/123/course/overviewfiles/123.jpg",
+ "fullname": "course 3",
+ "hasprogress": true,
+ "progress": 10
+ }
+ ]
+ }
+}}
+
+
\ No newline at end of file
diff --git a/blocks/myoverview/templates/view-list.mustache b/blocks/myoverview/templates/view-list.mustache
new file mode 100644
index 00000000000..799c5246c8e
--- /dev/null
+++ b/blocks/myoverview/templates/view-list.mustache
@@ -0,0 +1,55 @@
+{{!
+ This file is part of Moodle - http://moodle.org/
+
+ Moodle is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Moodle is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Moodle. If not, see .
+}}
+{{!
+ @template block_myoverview/view-list
+
+ This template renders the list view for the myoverview block.
+
+ Example context (json):
+ {
+ "courses": [
+ {
+ "name": "Assignment due 1",
+ "viewurl": "https://moodlesite/course/view.php?id=2",
+ "courseimage": "https://moodlesite/pluginfile/123/course/overviewfiles/123.jpg",
+ "fullname": "course 3",
+ "hasprogress": true,
+ "progress": 10
+ }
+ ]
+ }
+}}
+
+
\ No newline at end of file
diff --git a/blocks/myoverview/templates/view-summary.mustache b/blocks/myoverview/templates/view-summary.mustache
new file mode 100644
index 00000000000..8f9531c50c7
--- /dev/null
+++ b/blocks/myoverview/templates/view-summary.mustache
@@ -0,0 +1,62 @@
+{{!
+ This file is part of Moodle - http://moodle.org/
+
+ Moodle is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Moodle is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Moodle. If not, see .
+}}
+{{!
+ @template block_myoverview/view-summary
+
+ This template renders the list view for the myoverview block.
+
+ Example context (json):
+ {
+ "courses": [
+ {
+ "name": "Assignment due 1",
+ "viewurl": "https://moodlesite/course/view.php?id=2",
+ "courseimage": "https://moodlesite/pluginfile/123/course/overviewfiles/123.jpg",
+ "fullname": "course 3",
+ "summary": "This course is about assignments",
+ "hasprogress": true,
+ "progress": 10
+ }
+ ]
+ }
+}}
+
diff --git a/theme/bootstrapbase/templates/block_myoverview/courses-view-nav-grouping-display-filter.mustache b/theme/bootstrapbase/templates/block_myoverview/courses-view-nav-grouping-display-filter.mustache
deleted file mode 100644
index 0cd929cd0ff..00000000000
--- a/theme/bootstrapbase/templates/block_myoverview/courses-view-nav-grouping-display-filter.mustache
+++ /dev/null
@@ -1,41 +0,0 @@
-{{!
- This file is part of Moodle - http://moodle.org/
-
- Moodle is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Moodle is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Moodle. If not, see .
-}}
-{{!
- @template block_myoverview/courses-view-nav-grouping-display-filter
-
- This template renders the main content area for the myoverview block.
-
- Example context (json):
- {}
-}}
-
diff --git a/theme/bootstrapbase/templates/block_myoverview/courses-view.mustache b/theme/bootstrapbase/templates/block_myoverview/courses-view.mustache
deleted file mode 100644
index 5bfc78dea49..00000000000
--- a/theme/bootstrapbase/templates/block_myoverview/courses-view.mustache
+++ /dev/null
@@ -1,105 +0,0 @@
-{{!
- This file is part of Moodle - http://moodle.org/
-
- Moodle is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Moodle is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Moodle. If not, see .
-}}
-{{!
- @template block_myoverview/courses-view
-
- This template renders the courses view for the myoverview block.
-
- Example context (json):
- {}
-}}
-
-{{#js}}
-require(['jquery', 'core/custom_interaction_events'], function($, customEvents) {
- var root = $('#courses-view-{{uniqid}}');
- customEvents.define(root, [customEvents.events.activate]);
- root.on(customEvents.events.activate, '[data-toggle="btns"] > .btn', function(e) {
- root.find('.btn.active').removeClass('active');
- $(e.target).closest('.btn').addClass('active');
- });
-});
-{{/js}}
diff --git a/theme/bootstrapbase/templates/block_myoverview/main.mustache b/theme/bootstrapbase/templates/block_myoverview/main.mustache
deleted file mode 100644
index 3a8a005509d..00000000000
--- a/theme/bootstrapbase/templates/block_myoverview/main.mustache
+++ /dev/null
@@ -1,43 +0,0 @@
-{{!
- This file is part of Moodle - http://moodle.org/
-
- Moodle is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Moodle is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Moodle. If not, see .
-}}
-{{!
- @template block_myoverview/main
-
- This template renders the main content area for the myoverview block.
-
- Example context (json):
- {}
-}}
-
-
diff --git a/theme/bootstrapbase/templates/block_myoverview/paging-bar.mustache b/theme/bootstrapbase/templates/block_myoverview/paging-bar.mustache
deleted file mode 100644
index 96d44d1f071..00000000000
--- a/theme/bootstrapbase/templates/block_myoverview/paging-bar.mustache
+++ /dev/null
@@ -1,97 +0,0 @@
-{{!
- This file is part of Moodle - http://moodle.org/
-
- Moodle is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Moodle is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Moodle. If not, see .
-}}
-{{!
- @template block_myoverview/paging-bar
-
- This template renders the bootstrap style paging bar.
-
- Example context (json):
- {
- "pagingbar": {
- "pagecount": 2,
- "previous": {},
- "next": {},
- "first": {
- "url": "#",
- "page": "first"
- },
- "last": {
- "url": "#",
- "page": "last"
- },
- "pages": [
- {
- "url": "#",
- "number": 1,
- "page": "1",
- "active": true
- },
- {
- "url": "#",
- "number": 2,
- "page": "2"
- }
- ]
- }
- }
-}}
-{{#pagingbar}}
-