--- /dev/null
+<?php
+// 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 <http://www.gnu.org/licenses/>.
+
+/**
+ * Class containing data for my overview block.
+ *
+ * @package block_myoverview
+ * @copyright 2017 Simey Lameze <simey@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+namespace block_myoverview\output;
+defined('MOODLE_INTERNAL') || die();
+
+use core_course\external\course_summary_exporter;
+use renderable;
+use renderer_base;
+use templatable;
+/**
+ * Class containing data for my overview block.
+ *
+ * @copyright 2017 Simey Lameze <simey@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class course_summary implements renderable, templatable {
+
+ /**
+ * Export this data so it can be used as the context for a mustache template.
+ *
+ * @param \renderer_base $output
+ * @return stdClass
+ */
+ public function export_for_template(renderer_base $output) {
+ $courses = enrol_get_my_courses('*');
+
+ $data = [];
+ foreach ($courses as $courseid => $value) {
+ $context = \context_course::instance($courseid);
+ $exporter = new course_summary_exporter($courses[$courseid], array('context' => $context));
+ $data[] = $exporter->export($output);
+ }
+ return $data;
+ }
+}
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+namespace block_myoverview\output;
defined('MOODLE_INTERNAL') || die;
+use plugin_renderer_base;
+use renderable;
+
/**
- * myoverview block rendrer
+ * myoverview block renderer
*
* @package block_myoverview
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class block_myoverview_renderer extends plugin_renderer_base {
+class renderer extends plugin_renderer_base {
/**
* Return the main content for the block overview.
*
- * @return {string} HTML string
+ * @return string HTML string
*/
- public function get_content() {
- return $this->render_from_template('block_myoverview/main', []);
+ public function render_course_summary(course_summary $coursesummary) {
+ return $this->render_from_template('block_myoverview/main', ['courses' => $coursesummary->export_for_template($this)]);
}
}