first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
/**
* Javascript to initialise the starred courses block.
*
* @module block_starredcourses/main
* @copyright 2018 Simey Lameze <simey@moodle.com>
* @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.map
File diff suppressed because one or more lines are too long
+10
View File
@@ -0,0 +1,10 @@
/**
* A javascript module to retrieve user's starred courses.
*
* @module block_starredcourses/repository
* @copyright 2018 Simey Lameze <simey@moodle.com>
* @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.map
@@ -0,0 +1 @@
{"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 <http://www.gnu.org/licenses/>.\n\n/**\n * A javascript module to retrieve user's starred courses.\n *\n * @module block_starredcourses/repository\n * @copyright 2018 Simey Lameze <simey@moodle.com>\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"}
+127
View File
@@ -0,0 +1,127 @@
// 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/>.
/**
* Javascript to initialise the starred courses block.
*
* @module block_starredcourses/main
* @copyright 2018 Simey Lameze <simey@moodle.com>
* @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
};
});
@@ -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 <http://www.gnu.org/licenses/>.
/**
* A javascript module to retrieve user's starred courses.
*
* @module block_starredcourses/repository
* @copyright 2018 Simey Lameze <simey@moodle.com>
* @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
};
});
@@ -0,0 +1,100 @@
<?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/>.
/**
* Starred courses block.
*
* @package block_starredcourses
* @copyright 2018 Simey Lameze <simey@moodle.com>
* @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 <simey@moodle.com>
* @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,
];
}
}
+145
View File
@@ -0,0 +1,145 @@
<?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/>.
/**
* Starred courses block external API
*
* @package block_starredcourses
* @category external
* @copyright 2018 Simey Lameze <simey@moodle.com>
* @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 <simey@moodle.com>
* @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());
}
}
@@ -0,0 +1,61 @@
<?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 starred courses block.
*
* @package block_starredcourses
* @copyright 2018 Simey Lameze <simey@moodle.com>
* @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 <simey@moodle.com>
* @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)
];
}
}
@@ -0,0 +1,48 @@
<?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/>.
/**
* Starred courses block renderer.
*
* @package block_starredcourses
* @copyright 2018 Simey Lameze <simey@moodle.com>
* @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 <simey@moodle.com>
* @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));
}
}
@@ -0,0 +1,45 @@
<?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/>.
/**
* Privacy Subsystem implementation for block_starredcourses.
*
* @package block_starredcourses
* @copyright 2018 Simey Lameze <simey@moodle.com>
* @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 <simey@moodle.com>
* @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';
}
}
+38
View File
@@ -0,0 +1,38 @@
<?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/>.
/**
* Starred courses block capabilities.
*
* @package block_starredcourses
* @copyright 2018 Simey Lameze <simey@moodle.com>
* @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'
)
);
+39
View File
@@ -0,0 +1,39 @@
<?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/>.
/**
* File description.
*
* @package block_starredcourses
* @copyright 2018 Simey Lameze <simey@moodle.com>
* @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),
),
);
@@ -0,0 +1,30 @@
<?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/>.
/**
* Starred courses block language strings.
*
* @package block_starredcourses
* @copyright 2018 Simey Lameze <simey@moodle.com>
* @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';
+49
View File
@@ -0,0 +1,49 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="157 -1305 148 125" preserveAspectRatio="xMinYMid meet">
<defs>
<style>
.cls-1 {
clip-path: url(#clip-Courses);
}
.cls-2 {
fill: #eee;
}
.cls-3 {
fill: #c4c8cc;
}
.cls-4 {
fill: #fff;
}
</style>
<clipPath id="clip-Courses">
<rect x="157" y="-1305" width="148" height="125"/>
</clipPath>
</defs>
<g id="Courses" class="cls-1">
<g id="Group_44" data-name="Group 44" transform="translate(-268 -1781)">
<ellipse id="Ellipse_41" data-name="Ellipse 41" class="cls-2" cx="74" cy="14.785" rx="74" ry="14.785" transform="translate(425 571.43)"/>
<rect id="Rectangle_87" data-name="Rectangle 87" class="cls-3" width="95.097" height="110.215" transform="translate(451.909 476)"/>
<g id="Group_43" data-name="Group 43" transform="translate(464.04 494)">
<rect id="Rectangle_88" data-name="Rectangle 88" class="cls-4" width="31.043" height="34" transform="translate(0)"/>
<rect id="Rectangle_89" data-name="Rectangle 89" class="cls-4" width="31.043" height="34" transform="translate(0 42)"/>
<rect id="Rectangle_90" data-name="Rectangle 90" class="cls-4" width="31.067" height="34" transform="translate(39.005)"/>
<rect id="Rectangle_91" data-name="Rectangle 91" class="cls-4" width="31.067" height="34" transform="translate(39.005 42)"/>
<rect id="Rectangle_92" data-name="Rectangle 92" class="cls-3" width="23.023" height="3.18" transform="translate(3.081 16.549)"/>
<rect id="Rectangle_93" data-name="Rectangle 93" class="cls-3" width="23.023" height="3.18" transform="translate(3.081 58.549)"/>
<rect id="Rectangle_94" data-name="Rectangle 94" class="cls-3" width="23.023" height="3.18" transform="translate(43.122 16.549)"/>
<rect id="Rectangle_95" data-name="Rectangle 95" class="cls-3" width="23.023" height="3.18" transform="translate(43.122 58.549)"/>
<rect id="Rectangle_96" data-name="Rectangle 96" class="cls-3" width="14.014" height="3.18" transform="translate(3.081 21.825)"/>
<rect id="Rectangle_97" data-name="Rectangle 97" class="cls-3" width="18.845" height="3.18" transform="translate(3.081 26.825)"/>
<rect id="Rectangle_98" data-name="Rectangle 98" class="cls-3" width="14.014" height="3.18" transform="translate(3.081 63.825)"/>
<rect id="Rectangle_99" data-name="Rectangle 99" class="cls-3" width="18.845" height="3.18" transform="translate(3.081 68.825)"/>
<rect id="Rectangle_100" data-name="Rectangle 100" class="cls-3" width="14.014" height="3.18" transform="translate(43.122 21.825)"/>
<rect id="Rectangle_101" data-name="Rectangle 101" class="cls-3" width="18.845" height="3.18" transform="translate(43.122 26.825)"/>
<rect id="Rectangle_102" data-name="Rectangle 102" class="cls-3" width="14.014" height="3.18" transform="translate(43.122 63.825)"/>
<rect id="Rectangle_103" data-name="Rectangle 103" class="cls-3" width="18.845" height="3.18" transform="translate(43.122 68.825)"/>
<ellipse id="Ellipse_42" data-name="Ellipse 42" class="cls-3" cx="5.658" cy="5.652" rx="5.658" ry="5.652" transform="translate(3.003 3.55)"/>
<ellipse id="Ellipse_43" data-name="Ellipse 43" class="cls-3" cx="5.658" cy="5.652" rx="5.658" ry="5.652" transform="translate(3.003 45.55)"/>
<ellipse id="Ellipse_44" data-name="Ellipse 44" class="cls-3" cx="5.658" cy="5.652" rx="5.658" ry="5.652" transform="translate(43.044 3.55)"/>
<ellipse id="Ellipse_45" data-name="Ellipse 45" class="cls-3" cx="5.658" cy="5.652" rx="5.658" ry="5.652" transform="translate(43.044 45.55)"/>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

+34
View File
@@ -0,0 +1,34 @@
<?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/>.
/**
* Settings for the starredcourses block
*
* @package block_starredcourses
* @copyright 2019 Mihail Geshoski <mihail@moodle.com>
* @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));
}
@@ -0,0 +1,36 @@
{{!
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/>.
}}
{{!
@template block_starredcourses/main
This template renders the main content area for the starred courses block.
Example context (json):
{}
}}
<div id="block-starredcourses-{{uniqid}}" class="block-starredcourses block-cards" data-region="starred-courses"
data-displaycoursecategory="{{displaycategories}}">
<div class="container-fluid p-0">
{{> block_starredcourses/view }}
</div>
</div>
{{#js}}
require(['block_starredcourses/main'], function(Main) {
Main.init('#block-starredcourses-{{uniqid}}');
});
{{/js}}
@@ -0,0 +1,21 @@
{{!
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/>.
}}
{{< core_course/no-courses}}
{{$nocoursestring}}
{{#str}} nocourses, block_starredcourses {{/str}}
{{/nocoursestring}}
{{/ core_course/no-courses}}
@@ -0,0 +1,39 @@
{{!
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/>.
}}
{{!
@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"
}
}}
<div id="starred-courses-view-{{uniqid}}"
data-region="starred-courses-view"
data-nocoursesimg="{{nocoursesimg}}">
<div data-region="starred-courses-view-content">
<div data-region="starred-courses-loading-placeholder">
<div class="card-grid mx-0 row row-cols-1 row-cols-sm-2 row-cols-lg-3 flex-nowrap overflow-hidden" style="height: 11.1rem">
<div class="col p-0">{{> core_course/placeholder-course }}</div>
<div class="col p-0">{{> core_course/placeholder-course }}</div>
<div class="col p-0">{{> core_course/placeholder-course }}</div>
</div>
</div>
</div>
</div>
@@ -0,0 +1,42 @@
@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"
+10
View File
@@ -0,0 +1,10 @@
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.
+28
View File
@@ -0,0 +1,28 @@
<?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/>.
/**
* Starred courses block version details.
*
* @package block_starredcourses
* @copyright 2018 Simey Lameze <simey@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2024042200;
$plugin->requires = 2024041600;
$plugin->component = 'block_starredcourses';