ÿØÿà JFIF    ÿÛ „  ( %!1"%)+...383-7(-.+  -%%--------+------------/----------------------------ÿÀ  ¶" ÿÄ     ÿÄ @    !1AQaq‘¡"±ÁÑð2’BRráS‚ñ3b¢CT²Ò #cÿÄ    ÿÄ '   1!AQ2a"‘±#ÿÚ   ? ò(/p‘—–¢·,M|¯G»R£üešT. ôŸEoCFñ‡ 4ÔkåóxR|µÁ¨ÓDà!Ç´µ˜‡p ÍQ‹§!þž^õWsŒy  åÁ§$á«%ºq˜™JyyË0y«^Ϗ -3ÃÏËÈ£Æ\P’ä„s&•‹Üs üô'àWt¹pñCp$bÚF`·7.^)¾!)ÒÙ˜–ÅÏš^h¾ø³·ìe±ŒaeÖ—Í,e=B}Jéߦ$$½—šÙÜCC¯¶è8β–Åkèwx LÉngT±æ¹£Ócœ¿Í/©Éÿ ‰ÚCÒ­mq;Tt¶–}0"zÖPcd1š­¤tˆ„ÐÓâqú[™öUCŠ2޿د­É(¸ßúçšmW,Ò ºf‹Ån™ÄLêÁ8üÁkÁ€L¥ÍuJ1œôrÂSŒÓöt!7EUíïb)AËi¬â-ÙHk8òÁiXYwÅ)O^"ÇØriÛô{»wRUKÙÏÚlÓ¬€‚’שT ] ªb—ÊîKC^×M“xùäñz¬zJ× {4[¹M'IÆeH1LCWÕ]œûº WDæà°OÅ‚¹c²ÞuA–rL`HšpCez‡V’— Ž‚Ë„–ñ­'µR0ÕÖ=À:±G»C\nÆÉ5*¢ †3šhQ4ýÒi$Õ1"Ü]¢p-q3zcQ$ªö¨¥æf›‘»´ÝÚHá„e²JÇ–iÊ:·à¬Øc5Åk»Laª*wi [0Ówk ¦a¦0Õ²ÅÅ‚T¸’³q:Æ<¹ú Ò˜Æ}2VE•Ѐp¡Ô3Úº …h³^LJºçì¥Ánó|˜ÖˆÎˆ+« ¦dø‘Mº–d\ªDðÛ„Ì×LÝ——Ð9Ç|•FèçVm™¨€™3õS–9Äå¢<̉Ìm¢±`·º˜&Z²ž Ë®D«¶»6™‰©­HÈ Àá«h­i³04æ’hxœi3ï¨(ÓL·†‹¶ËpŒ ƒÜÒ? :õdsÀ –3æÓ·Üjâ¬9—]8n¼&]I F£¼…ì–—Œ0v°LǐÅfÛ2TÖ’aµ˜N@ÖBSÏ^à´4-±°b×nÈÈœÆD=KdŒø…ÄÈK,›ÖR§fjü$^ÔÎ!„6^ s:Üun\ôkCÞò÷<—Lúl Í›G¹ÀPá¼Nc¡šÒ…ÙWͳœ±vÊáЄ×9‹P‰cEØ‘™›µŸP<×g1 º©Ø¬wiÁ^l5× I/';Ë+´Z‡ÓÄFÕp[Èð’ HÄ ó 9¬Dl4“é±Ï”V=^Hð;žLädÉa‚°Ë,#/Ž~²BÔÛ QãñQtIeórVB,ÏÂf‹4#Μc‹É3ZIÖ Œ¢¥·üxa‡Ãçè„jŠ[5 Ä!U?,3žÎ×…ðdÓ÷háŠA‰ìÄ4÷ÃÜZÃE{‰®+W\ZÍE[‰»µk»MÝ­`¢©†˜ÃV‹-f¢¡†¢a«eŠ%«Y¨©q%jâd,Ôq`) ¤¦…šˆ ¦E>0Ùb²t–Ÿ  ÷jsςҒKÈcø(é›;k(’#ôŒQ ™C> õ³M9óºÆµ¤çâ;uÀ)5>RÔ¸fÓ~Ȧ—’-$fe«"FâUˆÊwµPÏu w+"åÉó¨6s™Û9(À¨ù©hE°½†n`m~“@©›p!Vkhµ Á1šbEqqÊ@ºèl›2 –Yã%‘‚hÛ{a¶‡ÅÞM²¬çL34®Çl]®‹ŽØŒm'RÜe35æöˆ­Á­ cP9šeÁköo´L³Ì=p8]”‡B¶,šº|ɏdzXˆØk*ÇÚ{#ñ‰pã(€¶‡9ý'šÜ³½¯kƒ†Â’ëSOƒ•Å®H6+a¢µˆ‹Y¨b˜b+XˆÖ!°u!¢"µˆˆn2ˆ Å0Ä`Å Ô®c(ÓÜGº•Ä»Œ âWî%q.áÐÄ÷î%umÍ£+ÜQ,Vn¦-GphU¸¢X­&,Gt ·K¢ÅÅ·¥RÄÊÉbKn N­R2g$VµÕó Qr#–ÓZUÏð0ÎtÙÀœz ëöo“Îk¯n„T°"SÞ+³/…€½"ižãO%Í%&Δâ‘ËØ´IˆÓ°Ë‰ÞM3.™yçÁzit›`4C`k¢¼á!álÄï sÂ[×!¤l¾æo"ƒIÔ'@ªu)3›ô®“@Z à¾] üœ'‡4¸PÞkÁ-qÄH‰ÓÍBd´ÿ —¹°ÄA&ÊUC„öz‚‚RæŠtf¬>˜ÑidšEçÑL÷áý¡V±h§­c¿¥¨ƒ@g¼…Ýö^ÞËc.ž„æ“I[ ª+·zÐÒÚ,½Ð»¶€C›7jk$๖€Ž¾ÅÙpp¶ÍþéΤ ½ØÎŒq ñpæžÅ¥#Øâ49ÃÂK^MYV“,¶Éz_òæ:…;Õ«¦I3âJ£¤û5$7Èxün\â]Êe¯(Ÿ&Ž‹¶2<6Ćf× æ¢ƱqWı[(ÙÂŽç‚T7¨@ÈÉÍß‚ïÙ"&3TYlGށ†)†#5ŠA©^T2ÆÁ†)©†©†¤yGXÁ†©"†)©¼ÅV WS†#©]R–r‹q5ÕbâWþBh¯u+ªÅÄ×ü„nÑ^êkªÁj‰jeœWˆÕÕ`µDµ2Ì+Ä µDµµ5Ô{¤Þ0RF’H÷AÛ<ÊÁ§ ƈæ0Ñ£ê4 öÚµ[¬/1²€â<-¬šö²r×0o×w ´xÐÒË„ g01¬„åEM蛇Ã\6µE›‘fÙO k÷CºnÓ1`iîÒ² áÂ!ÑLÄÿ ³¬\õ*:M=Ç»c‹2[‰ØsÕLò\ŒK L^™üÄN\¶#» Ç\……ßïIœÉ$¸ÎñÍ®ÔHÇ Ûí/´>Li”„†g^$ 7NÍÑÑ2M2ªNg=k½Ð}Ÿl6‡ —JWˆ”ÞéT·+µ¦üÂFè¢Vs6ýÆ4»2+2IÝ9ô9®ÇGÙÇ1+Ä8;*Õ§ž½D*îÑWÚçá3Ma¤·ˆ¥t}š²Ü…Q+Æüµ8HíS”üxGéÁˆ¦Ël„éÈ 5 µÄƒ6äÜ(kIš¯S†fÖ&¸®×v|Äyˆ*禌Éù@7-®Ä[]ÎÖ¿ê`º…=:…žJVnݳvðÖKE¼‚ »mà ÷f®:Ë ™–4rð¡4` ܹçž~‹C=œ…¾Ïj|VDtK.ƒ"9 Ï ­–éXá³6WÒïIL-Ї Ç PK\m=TTdb/services.phpnu[. /** * File description. * * @package block_starredcourses * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); $functions = array( 'block_starredcourses_get_starred_courses' => array( 'classpath' => 'block/starredcourses/classes/external.php', 'classname' => 'block_starredcourses_external', 'methodname' => 'get_starred_courses', 'description' => 'Get users starred courses.', 'type' => 'read', 'ajax' => true, 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE), ), ); PK\Dm db/access.phpnu[. /** * Starred courses block capabilities. * * @package block_starredcourses * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); $capabilities = array( 'block/starredcourses:myaddinstance' => array( 'captype' => 'write', 'contextlevel' => CONTEXT_SYSTEM, 'archetypes' => array( 'user' => CAP_ALLOW ), 'clonepermissionsfrom' => 'moodle/my:manageblocks' ) ); PK\iGa00 lang/en/block_starredcourses.phpnu[. /** * Starred courses block language strings. * * @package block_starredcourses * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ $string['displaycategories'] = 'Display categories'; $string['displaycategories_help'] = 'Display the course category on the starred courses block items.'; $string['pluginname'] = 'Starred courses'; $string['privacy:metadata'] = 'The starred courses block does not store any personal data.'; $string['starredcourses:myaddinstance'] = 'Add a new starred courses block to Dashboard'; $string['nocourses'] = 'No starred courses';PK\aepix/courses.svgnu[ PK\J version.phpnu[. /** * Starred courses block version details. * * @package block_starredcourses * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; $plugin->version = 2025041400; $plugin->requires = 2025040800; $plugin->component = 'block_starredcourses';PK\cclasses/external.phpnu[. /** * Starred courses block external API * * @package block_starredcourses * @category external * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; require_once($CFG->dirroot . '/course/lib.php'); require_once($CFG->dirroot . '/course/externallib.php'); use core_course\external\course_summary_exporter; use core_external\external_function_parameters; use core_external\external_multiple_structure; use core_external\external_value; /** * Starred courses block external functions. * * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class block_starredcourses_external extends core_course_external { /** * Returns description of method parameters * * @return external_function_parameters * @since Moodle 3.6 */ public static function get_starred_courses_parameters() { return new external_function_parameters([ 'limit' => new external_value(PARAM_INT, 'Limit', VALUE_DEFAULT, 0), 'offset' => new external_value(PARAM_INT, 'Offset', VALUE_DEFAULT, 0) ]); } /** * Get users starred courses. * * @param int $limit Limit * @param int $offset Offset * * @return array list of courses and warnings */ public static function get_starred_courses($limit, $offset) { global $USER, $PAGE; $params = self::validate_parameters(self::get_starred_courses_parameters(), [ 'limit' => $limit, 'offset' => $offset ]); $limit = $params['limit']; $offset = $params['offset']; $usercontext = context_user::instance($USER->id); self::validate_context($usercontext); $PAGE->set_context($usercontext); $renderer = $PAGE->get_renderer('core'); // Get the user favourites service, scoped to a single user (their favourites only). $userservice = \core_favourites\service_factory::get_service_for_user_context($usercontext); // Get the favourites, by type, for the user. $favourites = $userservice->find_favourites_by_type('core_course', 'courses', $offset, $limit); $favouritecourseids = []; if ($favourites) { $favouritecourseids = array_map( function($favourite) { return $favourite->itemid; }, $favourites); } // Get all courses that the current user is enroled in, restricted down to favourites. $filteredcourses = []; if ($favouritecourseids) { $courses = course_get_enrolled_courses_for_logged_in_user(0, 0, null, null, COURSE_DB_QUERY_LIMIT, $favouritecourseids); list($filteredcourses, $processedcount) = course_filter_courses_by_favourites( $courses, $favouritecourseids, 0 ); } // Grab the course ids. $filteredcourseids = array_column($filteredcourses, 'id'); // Filter out any favourites that are not in the list of enroled courses. $filteredfavourites = array_filter($favourites, function($favourite) use ($filteredcourseids) { return in_array($favourite->itemid, $filteredcourseids); }); // Sort the favourites getting last added first. usort($filteredfavourites, function($a, $b) { if ($a->timemodified == $b->timemodified) return 0; return ($a->timemodified > $b->timemodified) ? -1 : 1; }); $formattedcourses = array(); foreach ($filteredfavourites as $favourite) { $course = get_course($favourite->itemid); $context = \context_course::instance($favourite->itemid); $canviewhiddencourses = has_capability('moodle/course:viewhiddencourses', $context); if ($course->visible || $canviewhiddencourses) { $exporter = new course_summary_exporter($course, ['context' => $context, 'isfavourite' => true]); $formattedcourse = $exporter->export($renderer); $formattedcourses[] = $formattedcourse; } } return $formattedcourses; } /** * Returns description of method result value * * @return \core_external\external_description * @since Moodle 3.6 */ public static function get_starred_courses_returns() { return new external_multiple_structure(course_summary_exporter::get_read_structure()); } } PK\U9;classes/privacy/provider.phpnu[. /** * Privacy Subsystem implementation for block_starredcourses. * * @package block_starredcourses * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace block_starredcourses\privacy; defined('MOODLE_INTERNAL') || die(); /** * Privacy Subsystem for block_starredcourses. * * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class provider implements \core_privacy\local\metadata\null_provider { /** * Get the language string identifier with the component's language * file to explain why this plugin stores no data. * * @return string */ public static function get_reason(): string { return 'privacy:metadata'; } } PK\<3[classes/output/main.phpnu[. /** * Class containing data for starred courses block. * * @package block_starredcourses * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace block_starredcourses\output; defined('MOODLE_INTERNAL') || die(); use renderable; use renderer_base; use templatable; use core_course\external\course_summary_exporter; require_once($CFG->dirroot . '/course/lib.php'); require_once($CFG->libdir . '/completionlib.php'); /** * Class containing data for starred courses block. * * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class main implements renderable, templatable { /** * 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 $USER; $nocoursesurl = $output->image_url('courses', 'block_starredcourses')->out(); $config = get_config('block_starredcourses'); return [ 'userid' => $USER->id, 'nocoursesimg' => $nocoursesurl, 'displaycategories' => !empty($config->displaycategories) ]; } } PK\<M%%classes/output/renderer.phpnu[. /** * Starred courses block renderer. * * @package block_starredcourses * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace block_starredcourses\output; defined('MOODLE_INTERNAL') || die; use plugin_renderer_base; /** * Starred courses block renderer. * * @package block_starredcourses * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class renderer extends plugin_renderer_base { /** * Return the main content for the block. * * @param main $main The main renderable * @return string HTML string */ public function render_main(main $main) { return $this->render_from_template('block_starredcourses/main', $main->export_for_template($this)); } } PK\2templates/main.mustachenu[{{! 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_starredcourses/main This template renders the main content area for the starred courses block. Example context (json): {} }}
{{> block_starredcourses/view }}
{{#js}} require(['block_starredcourses/main'], function(Main) { Main.init('#block-starredcourses-{{uniqid}}'); }); {{/js}} PK\w`8>[[templates/no-courses.mustachenu[{{! 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 . }} {{< core_course/no-courses}} {{$nocoursestring}} {{#str}} nocourses, block_starredcourses {{/str}} {{/nocoursestring}} {{/ core_course/no-courses}} PK\l^^templates/view.mustachenu[{{! 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_starredcourses/view This template renders the view for the starred courses block. Example context (json): { "nocoursesimg": "https://moodlesite/theme/image.php/boost/block_starredcourses/1535727318/courses" } }}
{{> core_course/placeholder-course }}
{{> core_course/placeholder-course }}
{{> core_course/placeholder-course }}
PK\INd upgrade.txtnu[=== 4.5 Onwards === This file has been replaced by UPGRADING.md. See MDL-81125 for further information. === This file describes API changes in the starredcourses block code. === 3.8 === * New admin setting block_starredcourses/displaycategories which enables the starred courses block to display the course category. === 3.7 === * The 'block/starredcourses:addinstance' capability has been removed. It has never been used in code.PK\amd/src/repository.jsnu[// 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 user's starred courses. * * @module block_starredcourses/repository * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ define(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notification) { /** * Retrieve a list of starred courses. * * Valid args are: * int limit number of records to retrieve * int offset the offset of records to retrieve * * @method getStarredCourses * @param {object} args The request arguments * @return {promise} Resolved with an array of courses */ var getStarredCourses = function(args) { var request = { methodname: 'block_starredcourses_get_starred_courses', args: args }; var promise = Ajax.call([request])[0]; promise.fail(Notification.exception); return promise; }; return { getStarredCourses: getStarredCourses }; }); PK\}֐amd/src/main.jsnu[// 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 initialise the starred courses block. * * @module block_starredcourses/main * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ define( [ 'jquery', 'core/notification', 'block_starredcourses/repository', 'core/pubsub', 'core/templates', 'core_course/events' ], function( $, Notification, Repository, PubSub, Templates, CourseEvents ) { var SELECTORS = { BLOCK_CONTAINER: '[data-region="starred-courses"]', STARRED_COURSES_REGION_VIEW: '[data-region="starred-courses-view"]', STARRED_COURSES_REGION: '[data-region="starred-courses-view-content"]' }; /** * Render the starred courses. * * @method renderCourses * @param {object} root The root element for the starred view. * @param {array} courses containing array of returned courses. * @returns {promise} Resolved with HTML and JS strings */ var renderCourses = function(root, courses) { if (courses.length > 0) { return Templates.render('core_course/view-cards', { courses: courses }); } else { var nocoursesimg = root.find(SELECTORS.STARRED_COURSES_REGION_VIEW).attr('data-nocoursesimg'); return Templates.render('block_starredcourses/no-courses', { nocoursesimg: nocoursesimg }); } }; /** * Fetch user's starred courses and reload the content of the block. * * @param {object} root The root element for the starred view. * @returns {promise} The updated content for the block. */ var reloadContent = function(root) { var content = root.find(SELECTORS.STARRED_COURSES_REGION); var args = { limit: 0, offset: 0, }; return Repository.getStarredCourses(args) .then(function(courses) { // Whether the course category should be displayed in the course item. var showcoursecategory = $(SELECTORS.BLOCK_CONTAINER).data('displaycoursecategory'); courses = courses.map(function(course) { course.showcoursecategory = showcoursecategory; return course; }); return renderCourses(root, courses); }).then(function(html, js) { return Templates.replaceNodeContents(content, html, js); }).catch(Notification.exception); }; /** * Register event listeners for the block. * * @param {object} root The calendar root element */ var registerEventListeners = function(root) { PubSub.subscribe(CourseEvents.favourited, function() { reloadContent(root); }); PubSub.subscribe(CourseEvents.unfavorited, function() { reloadContent(root); }); }; /** * Initialise all of the modules for the starred courses block. * * @param {object} root The root element for the block. */ var init = function(root) { root = $(root); registerEventListeners(root); reloadContent(root); }; return { init: init }; }); PK\rk[[amd/build/repository.min.jsnu[/** * A javascript module to retrieve user's starred courses. * * @module block_starredcourses/repository * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ define("block_starredcourses/repository",["jquery","core/ajax","core/notification"],(function($,Ajax,Notification){return{getStarredCourses:function(args){var request={methodname:"block_starredcourses_get_starred_courses",args:args},promise=Ajax.call([request])[0];return promise.fail(Notification.exception),promise}}})); //# sourceMappingURL=repository.min.js.mapPK\Hśamd/build/repository.min.js.mapnu[{"version":3,"file":"repository.min.js","sources":["../src/repository.js"],"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 * A javascript module to retrieve user's starred courses.\n *\n * @module block_starredcourses/repository\n * @copyright 2018 Simey Lameze \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notification) {\n\n /**\n * Retrieve a list of starred courses.\n *\n * Valid args are:\n * int limit number of records to retrieve\n * int offset the offset of records to retrieve\n *\n * @method getStarredCourses\n * @param {object} args The request arguments\n * @return {promise} Resolved with an array of courses\n */\n var getStarredCourses = function(args) {\n\n var request = {\n methodname: 'block_starredcourses_get_starred_courses',\n args: args\n };\n\n var promise = Ajax.call([request])[0];\n\n promise.fail(Notification.exception);\n\n return promise;\n };\n\n return {\n getStarredCourses: getStarredCourses\n };\n});\n"],"names":["define","$","Ajax","Notification","getStarredCourses","args","request","methodname","promise","call","fail","exception"],"mappings":";;;;;;;AAsBAA,yCAAO,CAAC,SAAU,YAAa,sBAAsB,SAASC,EAAGC,KAAMC,oBA2B5D,CACHC,kBAfoB,SAASC,UAEzBC,QAAU,CACVC,WAAY,2CACZF,KAAMA,MAGNG,QAAUN,KAAKO,KAAK,CAACH,UAAU,UAEnCE,QAAQE,KAAKP,aAAaQ,WAEnBH"}PK\> amd/build/main.min.js.mapnu[{"version":3,"file":"main.min.js","sources":["../src/main.js"],"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 initialise the starred courses block.\n *\n * @module block_starredcourses/main\n * @copyright 2018 Simey Lameze \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(\n[\n 'jquery',\n 'core/notification',\n 'block_starredcourses/repository',\n 'core/pubsub',\n 'core/templates',\n 'core_course/events'\n],\nfunction(\n $,\n Notification,\n Repository,\n PubSub,\n Templates,\n CourseEvents\n) {\n\n var SELECTORS = {\n BLOCK_CONTAINER: '[data-region=\"starred-courses\"]',\n STARRED_COURSES_REGION_VIEW: '[data-region=\"starred-courses-view\"]',\n STARRED_COURSES_REGION: '[data-region=\"starred-courses-view-content\"]'\n };\n\n /**\n * Render the starred courses.\n *\n * @method renderCourses\n * @param {object} root The root element for the starred view.\n * @param {array} courses containing array of returned courses.\n * @returns {promise} Resolved with HTML and JS strings\n */\n var renderCourses = function(root, courses) {\n if (courses.length > 0) {\n return Templates.render('core_course/view-cards', {\n courses: courses\n });\n } else {\n var nocoursesimg = root.find(SELECTORS.STARRED_COURSES_REGION_VIEW).attr('data-nocoursesimg');\n return Templates.render('block_starredcourses/no-courses', {\n nocoursesimg: nocoursesimg\n });\n }\n };\n\n /**\n * Fetch user's starred courses and reload the content of the block.\n *\n * @param {object} root The root element for the starred view.\n * @returns {promise} The updated content for the block.\n */\n var reloadContent = function(root) {\n var content = root.find(SELECTORS.STARRED_COURSES_REGION);\n\n var args = {\n limit: 0,\n offset: 0,\n };\n\n return Repository.getStarredCourses(args)\n .then(function(courses) {\n // Whether the course category should be displayed in the course item.\n var showcoursecategory = $(SELECTORS.BLOCK_CONTAINER).data('displaycoursecategory');\n courses = courses.map(function(course) {\n course.showcoursecategory = showcoursecategory;\n return course;\n });\n return renderCourses(root, courses);\n }).then(function(html, js) {\n return Templates.replaceNodeContents(content, html, js);\n }).catch(Notification.exception);\n };\n\n /**\n * Register event listeners for the block.\n *\n * @param {object} root The calendar root element\n */\n var registerEventListeners = function(root) {\n PubSub.subscribe(CourseEvents.favourited, function() {\n reloadContent(root);\n });\n\n PubSub.subscribe(CourseEvents.unfavorited, function() {\n reloadContent(root);\n });\n };\n\n /**\n * Initialise all of the modules for the starred courses block.\n *\n * @param {object} root The root element for the block.\n */\n var init = function(root) {\n root = $(root);\n\n registerEventListeners(root);\n reloadContent(root);\n };\n\n return {\n init: init\n };\n});\n"],"names":["define","$","Notification","Repository","PubSub","Templates","CourseEvents","SELECTORS","reloadContent","root","content","find","getStarredCourses","limit","offset","then","courses","showcoursecategory","data","map","course","length","render","nocoursesimg","attr","renderCourses","html","js","replaceNodeContents","catch","exception","init","subscribe","favourited","unfavorited","registerEventListeners"],"mappings":";;;;;;;AAuBAA,mCACA,CACI,SACA,oBACA,kCACA,cACA,iBACA,uBAEJ,SACIC,EACAC,aACAC,WACAC,OACAC,UACAC,kBAGIC,0BACiB,kCADjBA,sCAE6B,uCAF7BA,iCAGwB,+CA8BxBC,cAAgB,SAASC,UACrBC,QAAUD,KAAKE,KAAKJ,yCAOjBJ,WAAWS,kBALP,CACPC,MAAO,EACPC,OAAQ,IAIPC,MAAK,SAASC,aAEPC,mBAAqBhB,EAAEM,2BAA2BW,KAAK,gCAC3DF,QAAUA,QAAQG,KAAI,SAASC,eAC3BA,OAAOH,mBAAqBA,mBACrBG,UAjCH,SAASX,KAAMO,YAC3BA,QAAQK,OAAS,SACVhB,UAAUiB,OAAO,yBAA0B,CAC9CN,QAASA,cAGTO,aAAed,KAAKE,KAAKJ,uCAAuCiB,KAAK,4BAClEnB,UAAUiB,OAAO,kCAAmC,CACvDC,aAAcA,eA2BPE,CAAchB,KAAMO,YAC5BD,MAAK,SAASW,KAAMC,WACZtB,UAAUuB,oBAAoBlB,QAASgB,KAAMC,OACrDE,MAAM3B,aAAa4B,kBA8BvB,CACHC,KARO,SAAStB,OAfS,SAASA,MAClCL,OAAO4B,UAAU1B,aAAa2B,YAAY,WACtCzB,cAAcC,SAGlBL,OAAO4B,UAAU1B,aAAa4B,aAAa,WACvC1B,cAAcC,UAYlB0B,CAFA1B,KAAOR,EAAEQ,OAGTD,cAAcC"}PK\xhͶamd/build/main.min.jsnu[/** * Javascript to initialise the starred courses block. * * @module block_starredcourses/main * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ define("block_starredcourses/main",["jquery","core/notification","block_starredcourses/repository","core/pubsub","core/templates","core_course/events"],(function($,Notification,Repository,PubSub,Templates,CourseEvents){var SELECTORS_BLOCK_CONTAINER='[data-region="starred-courses"]',SELECTORS_STARRED_COURSES_REGION_VIEW='[data-region="starred-courses-view"]',SELECTORS_STARRED_COURSES_REGION='[data-region="starred-courses-view-content"]',reloadContent=function(root){var content=root.find(SELECTORS_STARRED_COURSES_REGION);return Repository.getStarredCourses({limit:0,offset:0}).then((function(courses){var showcoursecategory=$(SELECTORS_BLOCK_CONTAINER).data("displaycoursecategory");return courses=courses.map((function(course){return course.showcoursecategory=showcoursecategory,course})),function(root,courses){if(courses.length>0)return Templates.render("core_course/view-cards",{courses:courses});var nocoursesimg=root.find(SELECTORS_STARRED_COURSES_REGION_VIEW).attr("data-nocoursesimg");return Templates.render("block_starredcourses/no-courses",{nocoursesimg:nocoursesimg})}(root,courses)})).then((function(html,js){return Templates.replaceNodeContents(content,html,js)})).catch(Notification.exception)};return{init:function(root){(function(root){PubSub.subscribe(CourseEvents.favourited,(function(){reloadContent(root)})),PubSub.subscribe(CourseEvents.unfavorited,(function(){reloadContent(root)}))})(root=$(root)),reloadContent(root)}}})); //# sourceMappingURL=main.min.js.mapPK\ block_starredcourses.phpnu[. /** * Starred courses block. * * @package block_starredcourses * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * Starred courses block definition class. * * @package block_starredcourses * @copyright 2018 Simey Lameze * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class block_starredcourses extends block_base { /** * Initialises the block. * * @return void */ public function init() { $this->title = get_string('pluginname', 'block_starredcourses'); } /** * Gets the block contents. * * @return string The block HTML. */ public function get_content() { if ($this->content !== null) { return $this->content; } $renderable = new \block_starredcourses\output\main(); $renderer = $this->page->get_renderer('block_starredcourses'); $this->content = (object) [ 'text' => $renderer->render($renderable), 'footer' => '' ]; return $this->content; } /** * Locations where block can be displayed. * * @return array */ public function applicable_formats() { return array('my' => true); } /** * Allow the block to have a configuration page * * @return boolean */ public function has_config() { return true; } /** * Return the plugin config settings for external functions. * * @return stdClass the configs for both the block instance and plugin * @since Moodle 3.8 */ public function get_config_for_external() { // Return all settings for all users since it is safe (no private keys, etc..). $configs = get_config('block_starredcourses'); return (object) [ 'instance' => new stdClass(), 'plugin' => $configs, ]; } } PK\P#tests/behat/starred_courses.featurenu[@block_starredcourses Feature: Starred courses In order for me to quickly navigate to my favourite courses As a user I must be able to add them to the Starred courses block Background: Given the following "users" exist: | username | firstname | lastname | email | | student1 | Student | 1 | student1@example.com | And the following "courses" exist: | shortname | fullname | | C1 | Course 1 | | C2 | Course 2 | | C3 | Course 3 | And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | | student1 | C2 | student | | student1 | C3 | student | And the following "blocks" exist: | blockname | contextlevel | reference | pagetypepattern | defaultregion | | starredcourses | User | student1 | my-index | content | @accessibility @javascript Scenario: User has no starred courses Given I log in as "student1" Then I should see "No starred courses" And the page should meet accessibility standards @accessibility @javascript Scenario: User has starred courses Given I am on the "My courses" page logged in as "student1" And I click on "Actions for course Course 1" "button" And I click on "Star for Course 1" "link" And I click on "Actions for course Course 3" "button" And I click on "Star for Course 3" "link" When I follow "Dashboard" Then the page should meet accessibility standards And I should see "Course 1" in the "Starred courses" "block" And I should see "Course 3" in the "Starred courses" "block" But I should not see "Course 2" in the "Starred courses" "block" PK\ Ԃ   settings.phpnu[. /** * Settings for the starredcourses block * * @package block_starredcourses * @copyright 2019 Mihail Geshoski * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; if ($ADMIN->fulltree) { // Display Course Categories on the starred courses block items. $settings->add(new admin_setting_configcheckbox( 'block_starredcourses/displaycategories', get_string('displaycategories', 'block_starredcourses'), get_string('displaycategories_help', 'block_starredcourses'), 1)); } PK\m=TTdb/services.phpnu[PK\Dm db/access.phpnu[PK\iGa00  lang/en/block_starredcourses.phpnu[PK\aepix/courses.svgnu[PK\J B version.phpnu[PK\c$classes/external.phpnu[PK\U9;9classes/privacy/provider.phpnu[PK\<3[?classes/output/main.phpnu[PK\<M%%Hclasses/output/renderer.phpnu[PK\2Ntemplates/main.mustachenu[PK\w`8>[[Stemplates/no-courses.mustachenu[PK\l^^XWtemplates/view.mustachenu[PK\INd ]upgrade.txtnu[PK\_amd/src/repository.jsnu[PK\}֐famd/src/main.jsnu[PK\rk[[vamd/build/repository.min.jsnu[PK\Hś`yamd/build/repository.min.js.mapnu[PK\> Jamd/build/main.min.js.mapnu[PK\xhͶamd/build/main.min.jsnu[PK\ block_starredcourses.phpnu[PK\P#tests/behat/starred_courses.featurenu[PK\ Ԃ   settings.phpnu[PKa