Skip to content

Commit

Permalink
Fixed the code checker issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nithy1anand committed Nov 27, 2023
1 parent 43d1916 commit 9c0e241
Show file tree
Hide file tree
Showing 23 changed files with 124 additions and 118 deletions.
2 changes: 1 addition & 1 deletion classes/course_importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function import_from_template($templateid, $courseid) {

self::import('template' . $templateid, $courseid);
} else {
$course = (array) $DB->get_record('course', array('id' => $courseid));
$course = (array) $DB->get_record('course', ['id' => $courseid]);
$course['format'] = $template->format;
// Get format opitions.
$params['format'] = $template->format;
Expand Down
10 changes: 5 additions & 5 deletions classes/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

defined('MOODLE_INTERNAL') || die();

use \format_kickstart\course_importer;
use format_kickstart\course_importer;

require_once($CFG->libdir.'/externallib.php');

Expand All @@ -42,10 +42,10 @@ class external extends \external_api {
public static function import_template_parameters() {

return new \external_function_parameters(
array(
[
'templateid' => new \external_value(PARAM_INT, 'Kickstart Template id'),
'courseid' => new \external_value(PARAM_INT, 'Course id')
)
'courseid' => new \external_value(PARAM_INT, 'Course id'),
],
);
}

Expand All @@ -62,7 +62,7 @@ public static function import_template($templateid, $courseid) {
$context = \context_course::instance($courseid);
require_capability('format/kickstart:import_from_template', $context);
$params = self::validate_parameters(self::import_template_parameters(),
array('templateid' => $templateid, 'courseid' => $courseid));
['templateid' => $templateid, 'courseid' => $courseid]);
course_importer::import_from_template($templateid, $courseid);
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions classes/form/template_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function definition() {
$attributes = [];
$checkformat = !empty($template) && isset($template['courseformat']) && $template['courseformat'];
if ($checkformat) {
$attributes = array('disabled' => true);
$attributes = ['disabled' => true];
}
$mform->addElement('text', 'title', get_string('title', 'format_kickstart'), $attributes);
$mform->setType('title', PARAM_TEXT);
Expand All @@ -77,7 +77,7 @@ public function definition() {
'subdirs' => 0,
'maxfiles' => 1,
'accepted_types' => ['.mbz'],
'return_types' => FILE_INTERNAL | FILE_EXTERNAL
'return_types' => FILE_INTERNAL | FILE_EXTERNAL,
]);
$mform->addHelpButton('course_backup', 'course_backup', 'format_kickstart');
$mform->addRule('course_backup', get_string('required'), 'required');
Expand Down Expand Up @@ -108,7 +108,7 @@ public function definition() {
}

$mform->addElement('autocomplete', 'cohortids', get_string('cohorts', 'cohort'), $options, [
'multiple' => true
'multiple' => true,
]);
$mform->hideIf('cohortids', 'restrictcohort');

Expand Down
2 changes: 1 addition & 1 deletion classes/form/template_table_settings_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function definition() {
-1 => get_string('all'),
25 => '25',
50 => '50',
100 => '100'
100 => '100',
]);
$mform->setType('pagesize', PARAM_INT);
$mform->setDefault('pagesize', 25);
Expand Down
8 changes: 4 additions & 4 deletions classes/observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ public static function format_kickstart_changeconfig($event) {
$format = substr($plugin, 7);
if ($disable) {
$removetemplates = $DB->get_records_menu('format_kickstart_template',
array('format' => $format, 'courseformat' => 1), '', 'id,id');
['format' => $format, 'courseformat' => 1], '', 'id,id');
if ($removetemplates) {
$removetemplates = array_keys($removetemplates);
$templates = array_diff($templates, $removetemplates);
}
$DB->set_field('format_kickstart_template', 'visible', 0, array('format' => $format, 'courseformat' => 1));
$DB->set_field('format_kickstart_template', 'visible', 0, ['format' => $format, 'courseformat' => 1]);
} else {
$addtemplates = $DB->get_records_menu('format_kickstart_template',
array('format' => $format, 'courseformat' => 1), '', 'id,id');
['format' => $format, 'courseformat' => 1], '', 'id,id');
if ($addtemplates) {
$addtemplates = array_keys($addtemplates);
$templates = array_merge($templates, $addtemplates);
}
$DB->set_field('format_kickstart_template', 'visible', 1, array('format' => $format, 'courseformat' => 1));
$DB->set_field('format_kickstart_template', 'visible', 1, ['format' => $format, 'courseformat' => 1]);
}
set_config('kickstart_templates', implode(',', $templates));
}
Expand Down
4 changes: 2 additions & 2 deletions classes/output/course_template_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function get_templates() {
$template->hashtags = implode(' ', $tags);
$template->link = new \moodle_url('/course/format/kickstart/confirm.php', [
'template_id' => $template->id,
'course_id' => $COURSE->id
'course_id' => $COURSE->id,
]);
if (!$template->courseformat) {
$templatecount++;
Expand Down Expand Up @@ -198,7 +198,7 @@ public function export_for_template(renderer_base $output) {
'notemplates' => empty($templates),
'canmanage' => has_capability('format/kickstart:manage_templates', \context_system::instance()),
'createtemplateurl' => new \moodle_url('/course/format/kickstart/template.php', ['action' => 'create']),
'managetemplateurl' => new \moodle_url('/course/format/kickstart/templates.php')
'managetemplateurl' => new \moodle_url('/course/format/kickstart/templates.php'),
];
}

Expand Down
6 changes: 3 additions & 3 deletions classes/output/import_course_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ public function export_for_template(renderer_base $output) {
}
$course->url = new \moodle_url('/course/view.php', ['id' => $course->id]);
$course->fullname = format_string($course->fullname, true, [
'context' => \context_course::instance($course->id)
'context' => \context_course::instance($course->id),
]);
$course->importurl = new \moodle_url('/local/kickstart_pro/import.php', [
'id' => $COURSE->id,
'importid' => $course->id,
'target' => $target
'target' => $target,
]);
$courses[] = $course;
}
Expand All @@ -90,7 +90,7 @@ public function export_for_template(renderer_base $output) {
'searchlabel' => get_string('showing', 'format_kickstart', ['count' => $component->get_count()]),
'moreresults' => $component->has_more_results(),
'prourl' => 'https://bdecent.de/products/moodle-plugins/kickstart-course-wizard-pro/',
'courseurl' => new \moodle_url('/course/view.php', ['id' => $COURSE->id])
'courseurl' => new \moodle_url('/course/view.php', ['id' => $COURSE->id]),
];
}
}
24 changes: 12 additions & 12 deletions classes/template_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ public function col_status($data) {
$status = '';
if ($data->status) {
$status .= \html_writer::link($templateurl->out(false,
array('action' => 'disable', 'template' => $data->id)),
$OUTPUT->pix_icon('t/hide', get_string('disable'), 'moodle', array('class' => 'iconsmall')),
array('id' => "sort-template-up-action")). '';
['action' => 'disable', 'template' => $data->id]),
$OUTPUT->pix_icon('t/hide', get_string('disable'), 'moodle', ['class' => 'iconsmall']),
['id' => "sort-template-up-action"]). '';
} else {
$status .= \html_writer::link($templateurl->out(false,
array('action' => 'enable', 'template' => $data->id)),
$OUTPUT->pix_icon('t/show', get_string('enable'), 'moodle', array('class' => 'iconsmall')),
array('id' => "sort-template-up-action")). '';
['action' => 'enable', 'template' => $data->id]),
$OUTPUT->pix_icon('t/show', get_string('enable'), 'moodle', ['class' => 'iconsmall']),
['id' => "sort-template-up-action"]). '';
}
return $status;
}
Expand All @@ -173,21 +173,21 @@ public function col_updown($data) {
$updown = '';
$strup = get_string('up');
$strdown = get_string('down');
$spacer = $OUTPUT->pix_icon('spacer', '', 'moodle', array('class' => 'iconsmall'));
$spacer = $OUTPUT->pix_icon('spacer', '', 'moodle', ['class' => 'iconsmall']);
if ($this->cnt) {
$updown .= \html_writer::link($templateurl->out(false,
array('action' => 'up', 'template' => $data->id)),
$OUTPUT->pix_icon('t/up', $strup, 'moodle', array('class' => 'iconsmall')),
array('id' => "sort-template-up-action")). '';
['action' => 'up', 'template' => $data->id]),
$OUTPUT->pix_icon('t/up', $strup, 'moodle', ['class' => 'iconsmall']),
['id' => "sort-template-up-action"]). '';
} else {
$updown .= $spacer;
}

if ($this->cnt < ($this->totaltemplates - 1)) {
$updown .= '&nbsp;'. \html_writer::link($templateurl->out(false,
array('action' => 'down', 'template' => $data->id)),
['action' => 'down', 'template' => $data->id]),
$OUTPUT->pix_icon('t/down', $strdown, 'moodle',
array('class' => 'iconsmall')), array('id' => "sort-template-down-action"));
['class' => 'iconsmall']), ['id' => "sort-template-down-action"]);
} else {
$updown .= $spacer;
}
Expand Down
8 changes: 4 additions & 4 deletions db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => [
'manager' => CAP_ALLOW,
]
],
],
'format/kickstart:import_from_template' => [
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => [
'manager' => CAP_ALLOW,
'coursecreator' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW
]
]
'editingteacher' => CAP_ALLOW,
],
],
];

8 changes: 4 additions & 4 deletions db/caches.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

defined('MOODLE_INTERNAL') || die();

$definitions = array(
'templates' => array(
$definitions = [
'templates' => [
'mode' => cache_store::MODE_APPLICATION,
),
);
],
];
8 changes: 4 additions & 4 deletions db/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
*/
defined('MOODLE_INTERNAL') || die();

$observers = array(
array(
$observers = [
[
'eventname' => 'core\event\config_log_created',
'callback' => '\format_kickstart\observer::format_kickstart_changeconfig',
),
);
],
];
8 changes: 4 additions & 4 deletions db/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@

defined('MOODLE_INTERNAL') || die();

$functions = array(
'format_kickstart_import_template' => array(
$functions = [
'format_kickstart_import_template' => [
'classname' => 'format_kickstart\external',
'methodname' => 'import_template',
'description' => 'Import the template',
'type' => 'write',
'capabilities' => 'format/kickstart:import_from_template',
'ajax' => true,
'loginrequired' => true,
),
);
],
];
2 changes: 1 addition & 1 deletion db/uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function xmldb_format_kickstart_uninstall() {
$DB->delete_records_select(
'course_format_options',
"courseid = :siteid AND format != :site",
array("siteid" => $SITE->id, 'site' => 'site')
["siteid" => $SITE->id, 'site' => 'site'],
);
unset_config('kickstart_templates');
return true;
Expand Down
2 changes: 1 addition & 1 deletion db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ function xmldb_format_kickstart_upgrade($oldversion) {

if ($oldversion < 2023040300) {
$DB->set_field('tag_instance', 'itemtype', 'format_kickstart_template',
array('itemtype' => 'kickstart_template', 'component' => 'format_kickstart'));
['itemtype' => 'kickstart_template', 'component' => 'format_kickstart']);
// Kickstart savepoint reached.
upgrade_plugin_savepoint(true, 2023040300, 'format', 'kickstart');
}
Expand Down
2 changes: 1 addition & 1 deletion format.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
$output = $PAGE->get_renderer('format_kickstart');

$PAGE->requires->js_call_amd('format_kickstart/formatkickstart', 'init',
array('contextid' => $context->id, 'courseid' => $course->id));
['contextid' => $context->id, 'courseid' => $course->id]);

if (has_capability('format/kickstart:import_from_template', $context)) {
// Check the template add or remove.
Expand Down
4 changes: 2 additions & 2 deletions freetemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
global $freetemplates;
$freetemplates = [

'0' => array(
'0' => [
'id' => 0,
'title' => 'demo test 1',
'description' => '<p dir="ltr" style="text-align: left;">test content of the block content</p>',
Expand All @@ -42,6 +42,6 @@
'restrictrole' => 0,
'roleids' => [],
'descriptionformat' => 1,
),
],
];

Loading

0 comments on commit 9c0e241

Please sign in to comment.