Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolved Code Checker Errors #2

Open
wants to merge 6 commits into
base: MOODLE_401_STABLE
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ 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') {
$path = $pluginpath.'vendorjs/'.implode('/', $args);
send_file($path, basename($path));
return true;
}

// ...
}
```
Expand All @@ -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';

Expand Down Expand Up @@ -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
Expand All @@ -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 <http://www.gnu.org/licenses/>.
this program. If not, see [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/).
4 changes: 2 additions & 2 deletions classes/api/custom_element_parameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];

/**
Expand Down Expand Up @@ -122,7 +122,7 @@ public function add_parameter(string $name, string $type): void {
}
$this->parameters[] = [
'name' => $name,
'type' => $type
'type' => $type,
];
}

Expand Down
2 changes: 1 addition & 1 deletion classes/api/custom_element_requirements.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
}

Expand Down
2 changes: 1 addition & 1 deletion classes/api/instance_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
}
}
1 change: 0 additions & 1 deletion classes/ce_loader.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand Down
4 changes: 2 additions & 2 deletions classes/form/custom_element_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function get_iconfile_options($forform = false) {

if ($forform) {
$opts['accepted_types'] = [
'web_image'
'web_image',
];
$opts['return_types'] = FILE_INTERNAL | FILE_EXTERNAL;
}
Expand All @@ -153,7 +153,7 @@ public function get_modulefile_options($forform = false) {

if ($forform) {
$opts['accepted_types'] = [
'js'
'js',
];
$opts['return_types'] = FILE_INTERNAL | FILE_EXTERNAL;
}
Expand Down
4 changes: 2 additions & 2 deletions classes/form/set_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function definition() {
$mform->addElement('course', 'courseids', get_string('courses'), [
'multiple' => true,
'includefrontpage' => true,
'noselectionstring' => get_string('allcourses', 'search')
'noselectionstring' => get_string('allcourses', 'search'),
]);

$capabilityopts = [
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions classes/model/custom_element.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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');
}
Expand Down
6 changes: 3 additions & 3 deletions classes/model/instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,21 @@ 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);

$murl = new \moodle_url('/local/ce/view.php', [
'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);

Expand Down
8 changes: 4 additions & 4 deletions classes/model/set.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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();
Expand Down
14 changes: 7 additions & 7 deletions controller/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand All @@ -356,7 +356,7 @@ public function listinstances_action() {
'instances' => $instances,
'newurl' => $newurl->out(false),
'setname' => $setname,
'listsetsurl' => $listsetsurl
'listsetsurl' => $listsetsurl,
]);
}

Expand All @@ -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');
Expand All @@ -396,7 +396,7 @@ public function editinstance_action() {
$submitparams = [
'controller' => 'admin',
'action' => 'editinstance',
'setid' => $setid
'setid' => $setid,
];
if (!empty($instanceid)) {
$submitparams['instanceid'] = $instanceid;
Expand Down Expand Up @@ -480,7 +480,7 @@ private function render_ce_admin_tabs($action) {
'url' => $listsetsurl,
'label' => $listsetsstr,
],
]
],
]);
}
}
2 changes: 1 addition & 1 deletion db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand All @@ -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) {
Expand All @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
$plugin->cron = 0;
$plugin->maturity = MATURITY_ALPHA;
$plugin->dependencies = [
'local_mr' => ANY_VERSION
'local_mr' => ANY_VERSION,
];