diff --git a/README.md b/README.md index fa45b20..f38dc23 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ To allow your plugin to deliver the custom element file, you'll need to add or m // my/plugin/lib.php function my_plugin_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) { $pluginpath = __DIR__.'/'; - + // ... if ($filearea === 'vendorjs') { @@ -65,7 +65,7 @@ function my_plugin_pluginfile($course, $cm, $context, $filearea, $args, $forcedo send_file($path, basename($path)); return true; } - + // ... } ``` @@ -80,6 +80,7 @@ as a parameter in the example above. The following example shows how to make use of Angular to call string functions from Moodle. This is a general purpose Angular service that allows consuming any Moodle service function: + ```ts import {Injectable} from '@angular/core'; @@ -407,7 +408,12 @@ Enjoy! ``` +## Flags + +### The `local_ce_enable_usage`flag. + ## License + Copyright (c) 2021 Open LMS (https://www.openlms.net) This program is free software: you can redistribute it and/or modify it under @@ -420,4 +426,4 @@ 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 -this program. If not, see . +this program. If not, see [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/). diff --git a/classes/api/custom_element_parameters.php b/classes/api/custom_element_parameters.php index 52d3233..cfcf365 100644 --- a/classes/api/custom_element_parameters.php +++ b/classes/api/custom_element_parameters.php @@ -42,7 +42,7 @@ class custom_element_parameters { public const CE_VALID_PARAMS = [ self::CE_PARAM_NUMBER, self::CE_PARAM_BOOL, - self::CE_PARAM_STRING + self::CE_PARAM_STRING, ]; /** @@ -122,7 +122,7 @@ public function add_parameter(string $name, string $type): void { } $this->parameters[] = [ 'name' => $name, - 'type' => $type + 'type' => $type, ]; } diff --git a/classes/api/custom_element_requirements.php b/classes/api/custom_element_requirements.php index c40af4b..d37c9ca 100644 --- a/classes/api/custom_element_requirements.php +++ b/classes/api/custom_element_requirements.php @@ -129,7 +129,7 @@ public function get_plugins(): array { public function add_plugin(string $pluginid, string $pluginversion): void { $this->plugins[] = [ 'pluginid' => $pluginid, - 'pluginversion' => $pluginversion + 'pluginversion' => $pluginversion, ]; } diff --git a/classes/api/instance_config.php b/classes/api/instance_config.php index 824e691..1179436 100644 --- a/classes/api/instance_config.php +++ b/classes/api/instance_config.php @@ -106,7 +106,7 @@ public function get_parameters(): array { public function add_parameter(string $name, $value): void { $this->parameters[] = [ 'name' => $name, - 'value' => $value + 'value' => $value, ]; } } diff --git a/classes/ce_loader.php b/classes/ce_loader.php index c53baf6..3cdbca4 100644 --- a/classes/ce_loader.php +++ b/classes/ce_loader.php @@ -1,5 +1,4 @@ addElement('course', 'courseids', get_string('courses'), [ 'multiple' => true, 'includefrontpage' => true, - 'noselectionstring' => get_string('allcourses', 'search') + 'noselectionstring' => get_string('allcourses', 'search'), ]); $capabilityopts = [ @@ -101,7 +101,7 @@ public function get_iconfile_options($forform = false) { if ($forform) { $opts['accepted_types'] = [ - 'web_image' + 'web_image', ]; $opts['return_types'] = FILE_INTERNAL | FILE_EXTERNAL; } diff --git a/classes/model/custom_element.php b/classes/model/custom_element.php index aea1ae0..2612f37 100644 --- a/classes/model/custom_element.php +++ b/classes/model/custom_element.php @@ -164,14 +164,14 @@ public function __construct($id, $name, $cename, $cetype, $channel, $defaulticon $murl = new \moodle_url('/local/ce/view.php', [ 'controller' => 'admin', 'action' => 'editce', - 'ceid' => $this->id + 'ceid' => $this->id, ]); $this->editurl = $murl->out(false); $murl = new \moodle_url('/local/ce/view.php', [ 'controller' => 'admin', 'action' => 'deletece', - 'ceid' => $this->id + 'ceid' => $this->id, ]); $this->deleteurl = $murl->out(false); @@ -226,13 +226,13 @@ public function validate(): array { } $matches = []; - preg_match('/[a-z]+-[a-z\\-]+/',$this->cename,$matches); + preg_match('/[a-z]+-[a-z\\-]+/', $this->cename, $matches); if (empty($matches)) { $errors['cename'] = get_string('ce_form_error_cename_lettershyphens', 'local_ce'); } $matches = []; - preg_match('/[A-Z]+/',$this->cename,$matches); + preg_match('/[A-Z]+/', $this->cename, $matches); if (!empty($matches)) { $errors['cename'] = get_string('ce_form_error_cename_nouppercase', 'local_ce'); } diff --git a/classes/model/instance.php b/classes/model/instance.php index a195c33..1a3b9f7 100644 --- a/classes/model/instance.php +++ b/classes/model/instance.php @@ -105,7 +105,7 @@ public function __construct($id, $customname, $customelementid, $setid, $config, 'controller' => 'admin', 'action' => 'editinstance', 'setid' => $this->setid, - 'instanceid' => $this->id + 'instanceid' => $this->id, ]); $this->editurl = $murl->out(false); @@ -113,13 +113,13 @@ public function __construct($id, $customname, $customelementid, $setid, $config, 'controller' => 'admin', 'action' => 'deleteinstance', 'setid' => $this->setid, - 'instanceid' => $this->id + 'instanceid' => $this->id, ]); $this->deleteurl = $murl->out(false); $murl = new \moodle_url('/local/ce/view.php', [ 'action' => 'launch', - 'instanceid' => $this->id + 'instanceid' => $this->id, ]); $this->launchurl = $murl->out(false); diff --git a/classes/model/set.php b/classes/model/set.php index c160aed..44877a1 100644 --- a/classes/model/set.php +++ b/classes/model/set.php @@ -109,21 +109,21 @@ public function __construct($id, $name, $status, $defaulticon, $requiredcapabili $murl = new \moodle_url('/local/ce/view.php', [ 'controller' => 'admin', 'action' => 'editset', - 'setid' => $this->id + 'setid' => $this->id, ]); $this->editurl = $murl->out(false); $murl = new \moodle_url('/local/ce/view.php', [ 'controller' => 'admin', 'action' => 'deleteset', - 'setid' => $this->id + 'setid' => $this->id, ]); $this->deleteurl = $murl->out(false); $murl = new \moodle_url('/local/ce/view.php', [ 'controller' => 'admin', 'action' => 'listinstances', - 'setid' => $this->id + 'setid' => $this->id, ]); $this->instancesurl = $murl->out(false); @@ -206,7 +206,7 @@ public static function get_all_published_with_caps($caps = []) : array { $capquery .= ')'; $params = array_merge([ - 'status' => self::SET_STATUS_PUBLISHED + 'status' => self::SET_STATUS_PUBLISHED, ], $capparams); $thetable = static::get_table(); diff --git a/controller/admin.php b/controller/admin.php index 2e57725..88003e3 100644 --- a/controller/admin.php +++ b/controller/admin.php @@ -22,7 +22,7 @@ * @copyright Copyright (c) 2020 Open LMS (https://www.openlms.net) * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License */ -defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.'); +defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); use local_ce\api\custom_element_requirements; use local_ce\form\instance_form; @@ -283,7 +283,7 @@ public function editset_action() { $courseidsparams = [ 'courseids' => array_map(function($setcourse) { return $setcourse->courseid; - }, $setcourses) + }, $setcourses), ]; $mform->set_data((object)array_merge((array)$set, (array)$toform, $courseidsparams)); @@ -338,7 +338,7 @@ public function listinstances_action() { $newurl = new moodle_url('/local/ce/view.php', [ 'controller' => 'admin', 'action' => 'editinstance', - 'setid' => $setid + 'setid' => $setid, ]); $saved = optional_param('saved', 0, PARAM_INT); @@ -356,7 +356,7 @@ public function listinstances_action() { 'instances' => $instances, 'newurl' => $newurl->out(false), 'setname' => $setname, - 'listsetsurl' => $listsetsurl + 'listsetsurl' => $listsetsurl, ]); } @@ -372,7 +372,7 @@ public function editinstance_action() { $listinstancessmurl = new moodle_url('/local/ce/view.php', [ 'controller' => 'admin', 'action' => 'listinstances', - 'setid' => $setid + 'setid' => $setid, ]); $listinstancesurl = $listinstancessmurl->out(false); $listinstancesstr = get_string('admin_listinstances', 'local_ce'); @@ -396,7 +396,7 @@ public function editinstance_action() { $submitparams = [ 'controller' => 'admin', 'action' => 'editinstance', - 'setid' => $setid + 'setid' => $setid, ]; if (!empty($instanceid)) { $submitparams['instanceid'] = $instanceid; @@ -480,7 +480,7 @@ private function render_ce_admin_tabs($action) { 'url' => $listsetsurl, 'label' => $listsetsstr, ], - ] + ], ]); } } diff --git a/db/access.php b/db/access.php index 9619f0d..c54954c 100644 --- a/db/access.php +++ b/db/access.php @@ -23,7 +23,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -defined('MOODLE_INTERNAL') or die(); +defined('MOODLE_INTERNAL') || die(); $capabilities = [ // Manage custom elements. diff --git a/lib.php b/lib.php index 898adc3..ea86681 100644 --- a/lib.php +++ b/lib.php @@ -86,7 +86,7 @@ function local_ce_pluginfile($course, $cm, $context, $filearea, $args, $forcedow // We can now send the file back to the browser - in this case with a cache lifetime of 1 day and no filtering. send_stored_file($file, 86400, 0, $forcedownload, $options); } else { - return false; + return false; } } @@ -113,7 +113,7 @@ function local_ce_add_dock_to_footer() { $currentcaps = []; $capstocheck = [ 'local/ce:learnerset_view', - 'local/ce:instructorset_view' + 'local/ce:instructorset_view', ]; // Check for caps. foreach ($capstocheck as $cap) { @@ -137,7 +137,7 @@ function local_ce_add_dock_to_footer() { } $template = $OUTPUT->render_from_template('local_ce/set_dock', (object)[ - 'sets' => $setstorender + 'sets' => $setstorender, ]); if (!isset($CFG->additionalhtmlfooter)) { diff --git a/settings.php b/settings.php index 84f636c..1281f37 100644 --- a/settings.php +++ b/settings.php @@ -56,7 +56,7 @@ // Custom Elements management page. $urlmanagece = new moodle_url('/local/ce/view.php', [ 'controller' => 'admin', - 'action' => 'view' + 'action' => 'view', ]); $ADMIN->add($plugin, new admin_externalpage('adminpage_view', new lang_string('adminpageheading', $plugin), diff --git a/version.php b/version.php index db17080..08f841f 100644 --- a/version.php +++ b/version.php @@ -32,5 +32,5 @@ $plugin->cron = 0; $plugin->maturity = MATURITY_ALPHA; $plugin->dependencies = [ - 'local_mr' => ANY_VERSION + 'local_mr' => ANY_VERSION, ];