diff --git a/CHANGES.md b/CHANGES.md
index 9705877..abb141a 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,10 @@
## Changelog ##
+- [1.3.1]:
+ - Ensured compatibility with Moodle 4.3.
+ - Changed code to comply with new moodle coding standards.
+ - [Bugfix]: Changed default error type template colors for new installations to improve contrast.
+
- [1.3.0]:
- [Bugfix]: Fixed a bug that prevented the order of Margic error types (that were subsequently added to an instance from an error type template) from being changed under certain conditions.
- [Bugfix]: Deleting error types now triggers a confirm prompt.
diff --git a/annotation_form.php b/annotation_form.php
index 022c5f9..51d1e0d 100644
--- a/annotation_form.php
+++ b/annotation_form.php
@@ -105,6 +105,6 @@ public function definition() {
* @return array Array with errors
*/
public function validation($data, $files) {
- return array();
+ return [];
}
}
diff --git a/annotations.php b/annotations.php
index b8214f3..bbd128e 100644
--- a/annotations.php
+++ b/annotations.php
@@ -60,9 +60,7 @@
throw new moodle_exception(get_string('incorrectmodule', 'margic'));
}
-if (! $coursesections = $DB->get_record("course_sections", array(
- "id" => $cm->section
-))) {
+if (! $coursesections = $DB->get_record("course_sections", ["id" => $cm->section])) {
throw new moodle_exception(get_string('incorrectmodule', 'margic'));
}
@@ -74,7 +72,7 @@
if ($annotations) {
echo json_encode($annotations);
} else {
- echo json_encode(array());
+ echo json_encode([]);
}
die;
@@ -83,10 +81,10 @@
require_capability('mod/margic:makeannotations', $context);
// Header.
-$PAGE->set_url('/mod/margic/annotations.php', array('id' => $id));
+$PAGE->set_url('/mod/margic/annotations.php', ['id' => $id]);
$PAGE->set_title(format_string($moduleinstance->name));
-$urlparams = array('id' => $id, 'annotationmode' => 1);
+$urlparams = ['id' => $id, 'annotationmode' => 1];
$redirecturl = new moodle_url('/mod/margic/view.php', $urlparams);
@@ -96,16 +94,13 @@
global $USER;
- $a = $DB->get_record('margic_annotations', array('id' => $deleteannotation, 'margic' => $moduleinstance->id));
+ $a = $DB->get_record('margic_annotations', ['id' => $deleteannotation, 'margic' => $moduleinstance->id]);
if (isset($a) && ($moduleinstance->overwriteannotations || $a->userid == $USER->id)) {
- $DB->delete_records('margic_annotations', array('id' => $deleteannotation, 'margic' => $moduleinstance->id));
+ $DB->delete_records('margic_annotations', ['id' => $deleteannotation, 'margic' => $moduleinstance->id]);
// Trigger module annotation deleted event.
- $event = \mod_margic\event\annotation_deleted::create(array(
- 'objectid' => $deleteannotation,
- 'context' => $context
- ));
+ $event = \mod_margic\event\annotation_deleted::create(['objectid' => $deleteannotation, 'context' => $context]);
$event->trigger();
@@ -119,14 +114,14 @@
require_once($CFG->dirroot . '/mod/margic/annotation_form.php');
// Instantiate form.
-$mform = new mod_margic_annotation_form(null, array('types' => $margic->get_errortypes_for_form()));
+$mform = new mod_margic_annotation_form(null, ['types' => $margic->get_errortypes_for_form()]);
if ($fromform = $mform->get_data()) {
// In this case you process validated data. $mform->get_data() returns data posted in form.
if ((isset($fromform->annotationid) && $fromform->annotationid !== 0) && isset($fromform->text)) { // Update annotation.
- $annotation = $DB->get_record('margic_annotations', array('margic' => $cm->instance, 'entry' => $fromform->entry,
- 'id' => $fromform->annotationid));
+ $annotation = $DB->get_record('margic_annotations', ['margic' => $cm->instance, 'entry' => $fromform->entry,
+ 'id' => $fromform->annotationid, ]);
// Prevent changes by user in hidden form fields.
if (!$annotation) {
@@ -140,7 +135,7 @@
}
$annotation->timemodified = time();
- $annotation->text = format_text($fromform->text, 2, array('para' => false));
+ $annotation->text = format_text($fromform->text, 2, ['para' => false]);
$annotation->type = $fromform->type;
if ($moduleinstance->overwriteannotations) {
@@ -150,14 +145,11 @@
$DB->update_record('margic_annotations', $annotation);
// Trigger module annotation updated event.
- $event = \mod_margic\event\annotation_updated::create(array(
- 'objectid' => $fromform->annotationid,
- 'context' => $context
- ));
+ $event = \mod_margic\event\annotation_updated::create(['objectid' => $fromform->annotationid, 'context' => $context]);
$event->trigger();
- $urlparams = array('id' => $id, 'annotationmode' => 1, 'focusannotation' => $fromform->annotationid);
+ $urlparams = ['id' => $id, 'annotationmode' => 1, 'focusannotation' => $fromform->annotationid];
$redirecturl = new moodle_url('/mod/margic/view.php', $urlparams);
redirect($redirecturl, get_string('annotationedited', 'mod_margic'), null, notification::NOTIFY_SUCCESS);
@@ -176,7 +168,7 @@
redirect($redirecturl, get_string('annotationinvalid', 'mod_margic'), null, notification::NOTIFY_ERROR);
}
- if (!$DB->record_exists('margic_entries', array('margic' => $cm->instance, 'id' => $fromform->entry))) {
+ if (!$DB->record_exists('margic_entries', ['margic' => $cm->instance, 'id' => $fromform->entry])) {
redirect($redirecturl, get_string('annotationinvalid', 'mod_margic'), null, notification::NOTIFY_ERROR);
}
@@ -200,13 +192,10 @@
$newid = $DB->insert_record('margic_annotations', $annotation);
// Trigger module annotation created event.
- $event = \mod_margic\event\annotation_created::create(array(
- 'objectid' => $newid,
- 'context' => $context
- ));
+ $event = \mod_margic\event\annotation_created::create(['objectid' => $newid, 'context' => $context]);
$event->trigger();
- $urlparams = array('id' => $id, 'annotationmode' => 1, 'focusannotation' => $newid);
+ $urlparams = ['id' => $id, 'annotationmode' => 1, 'focusannotation' => $newid];
$redirecturl = new moodle_url('/mod/margic/view.php', $urlparams);
redirect($redirecturl, get_string('annotationadded', 'mod_margic'), null, notification::NOTIFY_SUCCESS);
diff --git a/backup/moodle2/backup_margic_stepslib.php b/backup/moodle2/backup_margic_stepslib.php
index cd4e88b..a7a7520 100644
--- a/backup/moodle2/backup_margic_stepslib.php
+++ b/backup/moodle2/backup_margic_stepslib.php
@@ -37,30 +37,30 @@ protected function define_structure() {
$userinfo = $this->get_setting_value('userinfo');
// Replace with the attributes and final elements that the element will handle.
- $margic = new backup_nested_element('margic', array('id'), array(
+ $margic = new backup_nested_element('margic', ['id'], [
'name', 'intro', 'introformat', 'timecreated', 'timemodified',
'scale', 'assessed', 'assesstimestart', 'assesstimefinish',
- 'timeopen', 'timeclose', 'editentries', 'editentrydates', 'annotationareawidth'));
+ 'timeopen', 'timeclose', 'editentries', 'editentrydates', 'annotationareawidth', ]);
$errortypes = new backup_nested_element('errortypes');
- $errortype = new backup_nested_element('errortype', array('id'), array(
- 'timecreated', 'timemodified', 'name', 'color', 'priority'));
+ $errortype = new backup_nested_element('errortype', ['id'], [
+ 'timecreated', 'timemodified', 'name', 'color', 'priority', ]);
$entries = new backup_nested_element('entries');
- $entry = new backup_nested_element('entry', array('id'), array(
+ $entry = new backup_nested_element('entry', ['id'], [
'userid', 'timecreated', 'timemodified', 'text', 'format',
'rating', 'feedback', 'formatfeedback', 'teacher',
- 'timemarked', 'baseentry'));
+ 'timemarked', 'baseentry', ]);
$annotations = new backup_nested_element('annotations');
- $annotation = new backup_nested_element('annotation', array('id'), array(
+ $annotation = new backup_nested_element('annotation', ['id'], [
'userid', 'timecreated', 'timemodified', 'type', 'startcontainer', 'endcontainer',
- 'startoffset', 'endoffset', 'annotationstart', 'annotationend', 'exact', 'prefix', 'suffix', 'text'));
+ 'startoffset', 'endoffset', 'annotationstart', 'annotationend', 'exact', 'prefix', 'suffix', 'text', ]);
$ratings = new backup_nested_element('ratings');
- $rating = new backup_nested_element('rating', array('id'), array(
+ $rating = new backup_nested_element('rating', ['id'], [
'component', 'ratingarea', 'scaleid', 'value', 'userid',
- 'timecreated', 'timemodified'));
+ 'timecreated', 'timemodified', ]);
// Build the tree with these elements with $margic as the root of the backup tree.
$margic->add_child($errortypes);
@@ -77,24 +77,24 @@ protected function define_structure() {
// Define the source tables for the elements.
- $margic->set_source_table('margic', array('id' => backup::VAR_ACTIVITYID));
+ $margic->set_source_table('margic', ['id' => backup::VAR_ACTIVITYID]);
// Errortypes.
- $errortype->set_source_table('margic_errortypes', array('margic' => backup::VAR_PARENTID));
+ $errortype->set_source_table('margic_errortypes', ['margic' => backup::VAR_PARENTID]);
if ($userinfo) {
// Entries.
- $entry->set_source_table('margic_entries', array('margic' => backup::VAR_PARENTID));
+ $entry->set_source_table('margic_entries', ['margic' => backup::VAR_PARENTID]);
// Annotations.
- $annotation->set_source_table('margic_annotations', array('entry' => backup::VAR_PARENTID));
+ $annotation->set_source_table('margic_annotations', ['entry' => backup::VAR_PARENTID]);
// Ratings (core).
- $rating->set_source_table('rating', array('contextid' => backup::VAR_CONTEXTID,
+ $rating->set_source_table('rating', ['contextid' => backup::VAR_CONTEXTID,
'itemid' => backup::VAR_PARENTID,
'component' => backup_helper::is_sqlparam('mod_margic'),
- 'ratingarea' => backup_helper::is_sqlparam('entry')));
+ 'ratingarea' => backup_helper::is_sqlparam('entry'), ]);
$rating->set_source_alias('rating', 'value');
}
diff --git a/backup/moodle2/restore_margic_activity_task.class.php b/backup/moodle2/restore_margic_activity_task.class.php
index d22b8f0..eab052a 100644
--- a/backup/moodle2/restore_margic_activity_task.class.php
+++ b/backup/moodle2/restore_margic_activity_task.class.php
@@ -53,12 +53,12 @@ protected function define_my_steps() {
* @return array.
*/
public static function define_decode_contents() {
- $contents = array();
+ $contents = [];
// Define the contents (files).
- // tablename, array(field1, field 2), $mapping.
- $contents[] = new restore_decode_content('margic', array('intro'), 'margic');
- $contents[] = new restore_decode_content('margic_entries', array('text', 'feedback'), 'margic_entry');
+ // tablename, [field1, field 2], $mapping.
+ $contents[] = new restore_decode_content('margic', ['intro'], 'margic');
+ $contents[] = new restore_decode_content('margic_entries', ['text', 'feedback'], 'margic_entry');
return $contents;
}
@@ -69,16 +69,16 @@ public static function define_decode_contents() {
* @return array.
*/
public static function define_decode_rules() {
- $rules = array();
+ $rules = [];
// Define the rules.
$rules[] = new restore_decode_rule('MARGICINDEX', '/mod/margic/index.php?id=$1', 'course');
$rules[] = new restore_decode_rule('MARGICVIEWBYID', '/mod/margic/view.php?id=$1&userid=$2',
- array('course_module', 'userid'));
- $rules[] = new restore_decode_rule('MARGICEDITVIEW', '/mod/margic/edit.php?id=$1', array('course_module'));
+ ['course_module', 'userid']);
+ $rules[] = new restore_decode_rule('MARGICEDITVIEW', '/mod/margic/edit.php?id=$1', ['course_module']);
$rules[] = new restore_decode_rule('MARGICANNOTATIONSUMMARY', '/mod/margic/error_summary.php?id=$1', 'course_module');
- $rules[] = new restore_decode_rule('MARGICERRORTYPES', '/mod/margic/errortypes.php?id=$1', array('course_module'));
+ $rules[] = new restore_decode_rule('MARGICERRORTYPES', '/mod/margic/errortypes.php?id=$1', ['course_module']);
return $rules;
}
@@ -91,7 +91,7 @@ public static function define_decode_rules() {
* @return array.
*/
public static function define_restore_log_rules() {
- $rules = array();
+ $rules = [];
// Define the rules.
$rules[] = new restore_log_rule('margic', 'view', 'view.php?id={course_module}', '{margic}');
@@ -117,7 +117,7 @@ public static function define_restore_log_rules() {
* activity level. All them are rules not linked to any module instance (cmid = 0)
*/
public static function define_restore_log_rules_for_course() {
- $rules = array();
+ $rules = [];
$rules[] = new restore_log_rule('margic', 'view all', 'index.php?id={course}', null);
diff --git a/backup/moodle2/restore_margic_stepslib.php b/backup/moodle2/restore_margic_stepslib.php
index 8be8fff..3ee9d89 100644
--- a/backup/moodle2/restore_margic_stepslib.php
+++ b/backup/moodle2/restore_margic_stepslib.php
@@ -36,7 +36,7 @@ class restore_margic_activity_structure_step extends restore_activity_structure_
* @return restore_path_element[].
*/
protected function define_structure() {
- $paths = array();
+ $paths = [];
$userinfo = $this->get_setting_value('userinfo');
diff --git a/classes/event/annotation_created.php b/classes/event/annotation_created.php
index 0049944..08b47fb 100644
--- a/classes/event/annotation_created.php
+++ b/classes/event/annotation_created.php
@@ -66,15 +66,13 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
- return new \moodle_url('/mod/margic/view.php', array(
- 'id' => $this->contextinstanceid
- ));
+ return new \moodle_url('/mod/margic/view.php', ['id' => $this->contextinstanceid]);
}
/**
* Get objectid mapping for restore.
*/
public static function get_objectid_mapping() {
- return array('db' => 'margic_annotations', 'restore' => 'margic_annotation');
+ return ['db' => 'margic_annotations', 'restore' => 'margic_annotation'];
}
}
diff --git a/classes/event/annotation_deleted.php b/classes/event/annotation_deleted.php
index da1f750..1ae0546 100644
--- a/classes/event/annotation_deleted.php
+++ b/classes/event/annotation_deleted.php
@@ -66,15 +66,13 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
- return new \moodle_url('/mod/margic/view.php', array(
- 'id' => $this->contextinstanceid
- ));
+ return new \moodle_url('/mod/margic/view.php', ['id' => $this->contextinstanceid]);
}
/**
* Get objectid mapping for restore.
*/
public static function get_objectid_mapping() {
- return array('db' => 'margic_annotations', 'restore' => 'margic_annotation');
+ return ['db' => 'margic_annotations', 'restore' => 'margic_annotation'];
}
}
diff --git a/classes/event/annotation_updated.php b/classes/event/annotation_updated.php
index b0d99b3..5fb8299 100644
--- a/classes/event/annotation_updated.php
+++ b/classes/event/annotation_updated.php
@@ -66,15 +66,13 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
- return new \moodle_url('/mod/margic/view.php', array(
- 'id' => $this->contextinstanceid
- ));
+ return new \moodle_url('/mod/margic/view.php', ['id' => $this->contextinstanceid]);
}
/**
* Get objectid mapping for restore.
*/
public static function get_objectid_mapping() {
- return array('db' => 'margic_annotations', 'restore' => 'margic_annotation');
+ return ['db' => 'margic_annotations', 'restore' => 'margic_annotation'];
}
}
diff --git a/classes/event/course_module_viewed.php b/classes/event/course_module_viewed.php
index e814d9a..3dbaa16 100644
--- a/classes/event/course_module_viewed.php
+++ b/classes/event/course_module_viewed.php
@@ -47,6 +47,6 @@ protected function init() {
* Get objectid mapping for restore.
*/
public static function get_objectid_mapping() {
- return array('db' => 'margic', 'restore' => 'margic');
+ return ['db' => 'margic', 'restore' => 'margic'];
}
}
diff --git a/classes/event/download_margic_entries.php b/classes/event/download_margic_entries.php
index 7518ba1..90c0308 100644
--- a/classes/event/download_margic_entries.php
+++ b/classes/event/download_margic_entries.php
@@ -66,8 +66,6 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
- return new \moodle_url('/mod/margic/view.php', array(
- 'id' => $this->contextinstanceid
- ));
+ return new \moodle_url('/mod/margic/view.php', ['id' => $this->contextinstanceid]);
}
}
diff --git a/classes/event/entry_created.php b/classes/event/entry_created.php
index 044dcd7..703053c 100644
--- a/classes/event/entry_created.php
+++ b/classes/event/entry_created.php
@@ -66,15 +66,13 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
- return new \moodle_url('/mod/margic/edit.php', array(
- 'id' => $this->contextinstanceid
- ));
+ return new \moodle_url('/mod/margic/edit.php', ['id' => $this->contextinstanceid]);
}
/**
* Get objectid mapping for restore.
*/
public static function get_objectid_mapping() {
- return array('db' => 'margic_entries', 'restore' => 'margic_entry');
+ return ['db' => 'margic_entries', 'restore' => 'margic_entry'];
}
}
diff --git a/classes/event/entry_updated.php b/classes/event/entry_updated.php
index 5367513..78eb44d 100644
--- a/classes/event/entry_updated.php
+++ b/classes/event/entry_updated.php
@@ -66,15 +66,13 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
- return new \moodle_url('/mod/margic/edit.php', array(
- 'id' => $this->contextinstanceid
- ));
+ return new \moodle_url('/mod/margic/edit.php', ['id' => $this->contextinstanceid]);
}
/**
* Get objectid mapping for restore.
*/
public static function get_objectid_mapping() {
- return array('db' => 'margic_entries', 'restore' => 'margic_entry');
+ return ['db' => 'margic_entries', 'restore' => 'margic_entry'];
}
}
diff --git a/classes/event/feedback_updated.php b/classes/event/feedback_updated.php
index 24c6f29..7ca7a78 100644
--- a/classes/event/feedback_updated.php
+++ b/classes/event/feedback_updated.php
@@ -66,15 +66,13 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
- return new \moodle_url('/mod/margic/view.php', array(
- 'id' => $this->contextinstanceid
- ));
+ return new \moodle_url('/mod/margic/view.php', ['id' => $this->contextinstanceid]);
}
/**
* Get objectid mapping for restore.
*/
public static function get_objectid_mapping() {
- return array('db' => 'margic_entries', 'restore' => 'margic_entry');
+ return ['db' => 'margic_entries', 'restore' => 'margic_entry'];
}
}
diff --git a/classes/event/invalid_access_attempt.php b/classes/event/invalid_access_attempt.php
index 28d2232..0f0e2bb 100644
--- a/classes/event/invalid_access_attempt.php
+++ b/classes/event/invalid_access_attempt.php
@@ -68,6 +68,6 @@ public function get_description() {
* @return \moodle_url
*/
public function get_url() {
- return new \moodle_url('/mod/margic/view.php', array('id' => $this->contextinstanceid));
+ return new \moodle_url('/mod/margic/view.php', ['id' => $this->contextinstanceid]);
}
}
diff --git a/classes/forms/mod_margic_colorpicker_form_element.php b/classes/forms/mod_margic_colorpicker_form_element.php
index b77d96f..6efc76b 100644
--- a/classes/forms/mod_margic_colorpicker_form_element.php
+++ b/classes/forms/mod_margic_colorpicker_form_element.php
@@ -82,7 +82,7 @@ public function freeze() {
* @return string Frozen html
*/
public function getfrozenhtml() {
- $attributes = array('readonly' => 'readonly');
+ $attributes = ['readonly' => 'readonly'];
$this->updateAttributes($attributes);
return $this->_getTabs() . '_getAttrString($this->_attributes) . '/>' . $this->_getPersistantData();
}
@@ -95,8 +95,8 @@ public function getfrozenhtml() {
public function tohtml() {
global $CFG, $PAGE;
- $PAGE->requires->js_init_call('M.util.init_colour_picker', array('id_color', null));
- $PAGE->requires->js_call_amd('mod_margic/colorpicker-layout', 'init', array('id_color'));
+ $PAGE->requires->js_init_call('M.util.init_colour_picker', ['id_color', null]);
+ $PAGE->requires->js_call_amd('mod_margic/colorpicker-layout', 'init', ['id_color']);
// Add the class at the last minute.
if ($this->get_force_ltr()) {
diff --git a/classes/local/entrystats.php b/classes/local/entrystats.php
index 80bc8a5..4486e44 100644
--- a/classes/local/entrystats.php
+++ b/classes/local/entrystats.php
@@ -46,7 +46,7 @@ public static function get_entry_stats($entrytext, $entrytimecreated) {
$cleantext = preg_replace('#<[^>]+>#', ' ', $entrytext, -1, $replacementspacescount);
- $entrystats = array();
+ $entrystats = [];
$entrystats['words'] = self::get_stats_words($cleantext);
$entrystats['chars'] = self::get_stats_chars($cleantext) - $replacementspacescount;
$entrystats['sentences'] = self::get_stats_sentences($cleantext);
diff --git a/classes/local/helper.php b/classes/local/helper.php
index bf81b54..a7a2c04 100644
--- a/classes/local/helper.php
+++ b/classes/local/helper.php
@@ -67,11 +67,11 @@ public static function margic_update_calendar(stdClass $margic, $cmid) {
// The MOOTYPER_EVENT_TYPE_OPEN event should only be an action event if no close time is specified.
$event->type = empty($margic->timeclose) ? CALENDAR_EVENT_TYPE_ACTION : CALENDAR_EVENT_TYPE_STANDARD;
- if ($event->id = $DB->get_field('event', 'id', array(
+ if ($event->id = $DB->get_field('event', 'id', [
'modulename' => 'margic',
'instance' => $margic->id,
- 'eventtype' => $event->eventtype
- ))) {
+ 'eventtype' => $event->eventtype,
+ ])) {
if ((! empty($margic->timeopen)) && ($margic->timeopen > 0)) {
// Calendar event exists so update it.
@@ -112,11 +112,11 @@ public static function margic_update_calendar(stdClass $margic, $cmid) {
$event = new stdClass();
$event->type = CALENDAR_EVENT_TYPE_ACTION;
$event->eventtype = MARGIC_EVENT_TYPE_CLOSE;
- if ($event->id = $DB->get_field('event', 'id', array(
+ if ($event->id = $DB->get_field('event', 'id', [
'modulename' => 'margic',
'instance' => $margic->id,
- 'eventtype' => $event->eventtype
- ))) {
+ 'eventtype' => $event->eventtype,
+ ])) {
if ((! empty($margic->timeclose)) && ($margic->timeclose > 0)) {
// Calendar event exists so update it.
$event->name = get_string('calendarend', 'margic', $margic->name);
@@ -203,8 +203,8 @@ public static function download_entries($context, $course, $margic) {
}
$csv->filename .= '_'.clean_filename(gmdate("Ymd_Hi").'GMT.csv');
- $fields = array();
- $fields = array(
+ $fields = [];
+ $fields = [
get_string('id', 'margic'),
get_string('firstname'),
get_string('lastname'),
@@ -218,8 +218,8 @@ public static function download_entries($context, $course, $margic) {
get_string('teacher', 'margic'),
get_string('timemarked', 'margic'),
get_string('baseentry', 'margic'),
- get_string('text', 'margic')
- );
+ get_string('text', 'margic'),
+ ];
// Add the headings to our data array.
$csv->add_data($fields);
@@ -267,7 +267,7 @@ public static function download_entries($context, $course, $margic) {
$timemarked = date('Y-m-d H:i:s', $m->timemarked);
}
- $output = array(
+ $output = [
$m->entry,
$m->firstname,
$m->lastname,
@@ -281,8 +281,8 @@ public static function download_entries($context, $course, $margic) {
$m->teacher,
$timemarked,
$m->baseentry,
- format_text($m->text, $m->format, array('para' => false))
- );
+ format_text($m->text, $m->format, ['para' => false]),
+ ];
$csv->add_data($output);
}
}
@@ -303,7 +303,7 @@ public static function margic_get_editor_and_attachment_options($course, $contex
$maxbytes = $course->maxbytes;
// For the editor.
- $editoroptions = array(
+ $editoroptions = [
'trusttext' => true,
'maxfiles' => EDITOR_UNLIMITED_FILES,
'maxbytes' => $maxbytes,
@@ -311,22 +311,22 @@ public static function margic_get_editor_and_attachment_options($course, $contex
'subdirs' => false,
'editentrydates' => $margic->editentrydates, // Custom data (not really for editor).
- );
+ ];
// If maxfiles would be set to an int and more files are given the editor saves them all but
// saves the overcouting incorrect so that white box is diaplayed.
// For a file attachments field (not really needed here).
- $attachmentoptions = array(
+ $attachmentoptions = [
'subdirs' => false,
'maxfiles' => 1,
- 'maxbytes' => $maxbytes
- );
+ 'maxbytes' => $maxbytes,
+ ];
- return array(
+ return [
$editoroptions,
- $attachmentoptions
- );
+ $attachmentoptions,
+ ];
}
/**
@@ -375,7 +375,7 @@ public static function margic_get_edittime_options($moduleinstance) {
*/
public static function check_rating_entry($ratingoptions) {
global $DB, $CFG;
- $params = array();
+ $params = [];
$params['contextid'] = $ratingoptions->contextid;
$params['component'] = $ratingoptions->component;
$params['ratingarea'] = $ratingoptions->ratingarea;
@@ -458,10 +458,10 @@ public static function margic_return_feedback_area_for_entry($cmid, $context, $c
require_once(__DIR__ .'/../../../../lib/gradelib.php');
if ($entry->teacher) {
- $teacher = $DB->get_record('user', array('id' => $entry->teacher));
+ $teacher = $DB->get_record('user', ['id' => $entry->teacher]);
if ($teacher) {
$teacherimage = $OUTPUT->user_picture($teacher,
- array('courseid' => $course->id, 'link' => true, 'includefullname' => true, 'size' => 30));
+ ['courseid' => $course->id, 'link' => true, 'includefullname' => true, 'size' => 30]);
$hasteacher = true;
} else {
$teacherimage = false;
@@ -474,7 +474,7 @@ public static function margic_return_feedback_area_for_entry($cmid, $context, $c
$feedbackarea = '';
- $feedbacktext = format_text($entry->feedback, $entry->formatfeedback, array('para' => false));
+ $feedbacktext = format_text($entry->feedback, $entry->formatfeedback, ['para' => false]);
if ($canmanageentries) { // If user is teacher.
if (! $entry->teacher) {
@@ -505,9 +505,9 @@ public static function margic_return_feedback_area_for_entry($cmid, $context, $c
$data->{'rating_' . $entry->id} = $entry->rating;
$mform = new \mod_margic_grading_form(new \moodle_url('/mod/margic/grade_entry.php',
- array('id' => $cmid, 'entryid' => $entry->id)), array('courseid' => $course->id, 'margic' => $margic,
+ ['id' => $cmid, 'entryid' => $entry->id]), ['courseid' => $course->id, 'margic' => $margic,
'entry' => $entry, 'grades' => $grades, 'teacherimg' => $teacherimage, 'editoroptions' => $editoroptions,
- 'hasteacher' => $hasteacher));
+ 'hasteacher' => $hasteacher, ]);
// Set default data.
$mform->set_data($data);
@@ -526,9 +526,7 @@ public static function margic_return_feedback_area_for_entry($cmid, $context, $c
if ($margic->assessed > 0) {
// Gradebook preference.
- $gradinginfo = grade_get_grades($course->id, 'mod', 'margic', $entry->margic, array(
- $entry->userid
- ));
+ $gradinginfo = grade_get_grades($course->id, 'mod', 'margic', $entry->margic, [$entry->userid]);
// Branch check for string compatibility.
if (! empty($grades) && $entry->rating) {
diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php
index 4bd061b..b2a2fe3 100644
--- a/classes/privacy/provider.php
+++ b/classes/privacy/provider.php
@@ -114,7 +114,7 @@ public static function get_contexts_for_userid(int $userid): contextlist {
$params = [
'modulename' => 'margic',
'contextlevel' => CONTEXT_MODULE,
- 'userid' => $userid
+ 'userid' => $userid,
];
// Get contexts for entries.
@@ -431,7 +431,7 @@ protected static function export_annotation_data(int $userid, \context $context,
'timecreated' => transform::datetime($annotation->timecreated),
'timemodified' => $timemodified,
'type' => $annotation->type,
- 'text' => format_text($annotation->text, 2, array('para' => false)),
+ 'text' => format_text($annotation->text, 2, ['para' => false]),
];
// Store the annotation data.
diff --git a/classes/search/activity.php b/classes/search/activity.php
index 2eb42d7..0f399c9 100644
--- a/classes/search/activity.php
+++ b/classes/search/activity.php
@@ -48,11 +48,11 @@ public function uses_file_indexing() {
* @return array
*/
public function get_search_fileareas() {
- $fileareas = array(
+ $fileareas = [
'intro',
'entry',
- 'feedback'
- ); // Fileareas.
+ 'feedback',
+ ]; // Fileareas.
return $fileareas;
}
}
diff --git a/classes/search/entry.php b/classes/search/entry.php
index 63a2c9a..a68d2f2 100644
--- a/classes/search/entry.php
+++ b/classes/search/entry.php
@@ -41,7 +41,7 @@ class entry extends \core_search\base_mod {
*
* @var array Internal quick static cache.
*/
- protected $entriesdata = array();
+ protected $entriesdata = [];
/**
* Returns recordset containing required data for indexing margic entries.
@@ -65,7 +65,7 @@ public function get_document_recordset($modifiedfrom = 0, \context $context = nu
WHERE me.timemodified >= :timemodified
ORDER BY me.timemodified ASC";
return $DB->get_recordset_sql($sql, array_merge($contextparams, [
- 'timemodified' => $modifiedfrom
+ 'timemodified' => $modifiedfrom,
]));
}
@@ -76,7 +76,7 @@ public function get_document_recordset($modifiedfrom = 0, \context $context = nu
* @param array $options
* @return \core_search\document
*/
- public function get_document($entry, $options = array()) {
+ public function get_document($entry, $options = []) {
try {
$cm = $this->get_cm('margic', $entry->margic, $entry->course);
$context = \context_module::instance($cm->id);
@@ -156,9 +156,7 @@ public function get_doc_url(\core_search\document $doc) {
$entryuserid = $doc->get('userid');
$url = '/mod/margic/view.php';
- return new \moodle_url($url, array(
- 'id' => $contextmodule->instanceid
- ));
+ return new \moodle_url($url, ['id' => $contextmodule->instanceid]);
}
/**
@@ -169,9 +167,7 @@ public function get_doc_url(\core_search\document $doc) {
*/
public function get_context_url(\core_search\document $doc) {
$contextmodule = \context::instance_by_id($doc->get('contextid'));
- return new \moodle_url('/mod/margic/view.php', array(
- 'id' => $contextmodule->instanceid
- ));
+ return new \moodle_url('/mod/margic/view.php', ['id' => $contextmodule->instanceid]);
}
/**
@@ -187,6 +183,6 @@ protected function get_entry($entryid) {
global $DB;
return $DB->get_record_sql("SELECT me.*, m.course FROM {margic_entries} me
JOIN {margic} m ON m.id = me.margic
- WHERE me.id = ?", array('id' => $entryid), MUST_EXIST);
+ WHERE me.id = ?", ['id' => $entryid], MUST_EXIST);
}
}
diff --git a/db/access.php b/db/access.php
index 2f0de74..317c722 100644
--- a/db/access.php
+++ b/db/access.php
@@ -23,175 +23,175 @@
*/
defined('MOODLE_INTERNAL') || die();
-$capabilities = array(
+$capabilities = [
- 'mod/margic:addinstance' => array(
+ 'mod/margic:addinstance' => [
'riskbitmask' => RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
- 'archetypes' => array(
+ 'archetypes' => [
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- ),
- 'clonepermissionsfrom' => 'moodle/course:manageactivities'
- ),
+ 'manager' => CAP_ALLOW,
+ ],
+ 'clonepermissionsfrom' => 'moodle/course:manageactivities',
+ ],
- 'mod/margic:manageentries' => array(
+ 'mod/margic:manageentries' => [
'riskbitmask' => RISK_XSS | RISK_SPAM | RISK_PERSONAL,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'archetypes' => array(
+ 'archetypes' => [
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- )
- ),
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/margic:rate' => array(
+ 'mod/margic:rate' => [
'riskbitmask' => RISK_XSS | RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'archetypes' => array(
+ 'archetypes' => [
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- )
- ),
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/margic:addentries' => array(
+ 'mod/margic:addentries' => [
'riskbitmask' => RISK_XSS | RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'archetypes' => array(
+ 'archetypes' => [
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- )
- ),
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/margic:makeannotations' => array(
+ 'mod/margic:makeannotations' => [
'riskbitmask' => RISK_XSS | RISK_SPAM,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'archetypes' => array(
+ 'archetypes' => [
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- )
- ),
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/margic:deleteannotations' => array(
+ 'mod/margic:deleteannotations' => [
'riskbitmask' => RISK_DATALOSS,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'archetypes' => array(
+ 'archetypes' => [
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- )
- ),
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/margic:viewannotations' => array(
+ 'mod/margic:viewannotations' => [
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
- 'archetypes' => array(
+ 'archetypes' => [
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- )
- ),
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/margic:manageerrortypes' => array(
+ 'mod/margic:manageerrortypes' => [
'riskbitmask' => RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'archetypes' => array(
+ 'archetypes' => [
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- )
- ),
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/margic:viewerrorsummary' => array(
+ 'mod/margic:viewerrorsummary' => [
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
- 'archetypes' => array(
+ 'archetypes' => [
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- )
- ),
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/margic:viewerrorsfromallparticipants' => array(
+ 'mod/margic:viewerrorsfromallparticipants' => [
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
- 'archetypes' => array(
+ 'archetypes' => [
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- )
- ),
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/margic:editdefaulterrortypes' => array(
+ 'mod/margic:editdefaulterrortypes' => [
'riskbitmask' => RISK_XSS | RISK_DATALOSS,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
- 'archetypes' => array(
- 'manager' => CAP_ALLOW
- )
- ),
+ 'archetypes' => [
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/margic:receivegradingmessages' => array(
+ 'mod/margic:receivegradingmessages' => [
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
- 'archetypes' => array(
+ 'archetypes' => [
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- )
- ),
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/margic:viewotherusersentrytimes' => array(
+ 'mod/margic:viewotherusersentrytimes' => [
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
- 'archetypes' => array(
+ 'archetypes' => [
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- )
- ),
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/margic:viewotherusersannotationtimes' => array(
+ 'mod/margic:viewotherusersannotationtimes' => [
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
- 'archetypes' => array(
+ 'archetypes' => [
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- )
- ),
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
- 'mod/margic:viewotherusersfeedbacktimes' => array(
+ 'mod/margic:viewotherusersfeedbacktimes' => [
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
- 'archetypes' => array(
+ 'archetypes' => [
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- )
- ),
-);
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
+];
diff --git a/db/install.php b/db/install.php
index 81686a1..44770f5 100644
--- a/db/install.php
+++ b/db/install.php
@@ -36,7 +36,7 @@ function xmldb_margic_install() {
$errortype->timecreated = time();
$errortype->timemodified = 0;
$errortype->name = 'grammar_verb';
- $errortype->color = '0040FF';
+ $errortype->color = '6EB0FC';
$errortype->defaulttype = 1;
$errortype->userid = 0;
@@ -47,7 +47,7 @@ function xmldb_margic_install() {
$errortype->timecreated = time();
$errortype->timemodified = 0;
$errortype->name = 'grammar_syntax';
- $errortype->color = '0080FF';
+ $errortype->color = 'BAB2FD';
$errortype->defaulttype = 1;
$errortype->userid = 0;
@@ -58,7 +58,7 @@ function xmldb_margic_install() {
$errortype->timecreated = time();
$errortype->timemodified = 0;
$errortype->name = 'grammar_congruence';
- $errortype->color = '0489B1';
+ $errortype->color = '04CDD2';
$errortype->defaulttype = 1;
$errortype->userid = 0;
@@ -91,7 +91,7 @@ function xmldb_margic_install() {
$errortype->timecreated = time();
$errortype->timemodified = 0;
$errortype->name = 'orthography';
- $errortype->color = 'DF0101';
+ $errortype->color = 'FF571E';
$errortype->defaulttype = 1;
$errortype->userid = 0;
@@ -102,7 +102,7 @@ function xmldb_margic_install() {
$errortype->timecreated = time();
$errortype->timemodified = 0;
$errortype->name = 'punctuation';
- $errortype->color = 'FFFF00';
+ $errortype->color = 'F7D358';
$errortype->defaulttype = 1;
$errortype->userid = 0;
@@ -113,7 +113,7 @@ function xmldb_margic_install() {
$errortype->timecreated = time();
$errortype->timemodified = 0;
$errortype->name = 'other';
- $errortype->color = 'F7D358';
+ $errortype->color = 'FFFF00';
$errortype->defaulttype = 1;
$errortype->userid = 0;
diff --git a/db/messages.php b/db/messages.php
index fb480cb..c742e5f 100644
--- a/db/messages.php
+++ b/db/messages.php
@@ -25,13 +25,12 @@
defined('MOODLE_INTERNAL') || die();
-$messageproviders = array (
-
- 'gradingmessages' => array(
+$messageproviders = [
+ 'gradingmessages' => [
'capability' => 'mod/margic:receivegradingmessages',
- 'defaults' => array(
+ 'defaults' => [
'popup' => MESSAGE_PERMITTED + MESSAGE_DEFAULT_LOGGEDIN + MESSAGE_DEFAULT_LOGGEDOFF,
'email' => MESSAGE_PERMITTED,
- ),
- ),
-);
+ ],
+ ],
+];
diff --git a/edit.php b/edit.php
index 5dd5c3b..5faf017 100644
--- a/edit.php
+++ b/edit.php
@@ -23,7 +23,7 @@
*/
use mod_margic\local\helper;
-use \mod_margic\event\invalid_access_attempt;
+use mod_margic\event\invalid_access_attempt;
use core\output\notification;
use mod_margic\output\margic_entry;
@@ -57,9 +57,7 @@
throw new moodle_exception(get_string('incorrectcourseid', 'margic'));
}
-if (! $coursesections = $DB->get_record("course_sections", array(
- "id" => $cm->section
-))) {
+if (! $coursesections = $DB->get_record("course_sections", ["id" => $cm->section])) {
throw new moodle_exception(get_string('incorrectmodule', 'margic'));
}
@@ -70,13 +68,11 @@
// Prevent creating and editing of entries if user is not allowed to edit entry or activity is not available.
if (($entryid && !$moduleinstance->editentries) || !helper::margic_available($moduleinstance)) {
// Trigger invalid_access_attempt with redirect to the view page.
- $params = array(
+ $params = [
'objectid' => $id,
'context' => $context,
- 'other' => array(
- 'file' => 'edit.php'
- )
- );
+ 'other' => ['file' => 'edit.php'],
+ ];
$event = invalid_access_attempt::create($params);
$event->trigger();
redirect('view.php?id='.$id, get_string('editentrynotpossible', 'margic'), null, notification::NOTIFY_ERROR);
@@ -93,20 +89,20 @@
$data->id = $cm->id;
// Get the single record specified by firstkey.
-if ($DB->record_exists('margic_entries', array('margic' => $moduleinstance->id, "id" => $entryid))) {
- $entry = $DB->get_record('margic_entries', array('margic' => $moduleinstance->id, "id" => $entryid));
+if ($DB->record_exists('margic_entries', ['margic' => $moduleinstance->id, "id" => $entryid])) {
+ $entry = $DB->get_record('margic_entries', ['margic' => $moduleinstance->id, "id" => $entryid]);
$notnewestentry = false;
// Prevent editing of entries that are not the newest version of a base entry or a unedited entry.
if (isset($entry->baseentry)) { // If entry has a base entry check if this entry is the newest childentry.
$otherchildentries = $DB->get_records('margic_entries',
- array('margic' => $moduleinstance->id, 'baseentry' => $entry->baseentry), 'timecreated DESC');
+ ['margic' => $moduleinstance->id, 'baseentry' => $entry->baseentry], 'timecreated DESC');
if ($entry->timecreated < $otherchildentries[array_key_first($otherchildentries)]->timecreated) {
$notnewestentry = true;
}
} else { // If this entry has no base entry check if it has childentries and cant therefore be edited.
- $childentries = $DB->get_records('margic_entries', array('margic' => $moduleinstance->id, 'baseentry' => $entry->id),
+ $childentries = $DB->get_records('margic_entries', ['margic' => $moduleinstance->id, 'baseentry' => $entry->id],
'timecreated DESC');
if (!empty($childentries)) {
@@ -117,13 +113,11 @@
// Prevent editing of entries not started by this user or if it is not the newest child entry.
if ($entry->userid != $USER->id || $notnewestentry) {
// Trigger invalid_access_attempt with redirect to the view page.
- $params = array(
+ $params = [
'objectid' => $id,
'context' => $context,
- 'other' => array(
- 'file' => 'edit.php'
- )
- );
+ 'other' => ['file' => 'edit.php'],
+ ];
$event = invalid_access_attempt::create($params);
$event->trigger();
redirect('view.php?id='.$id, get_string('editentrynotpossible', 'margic'), null, notification::NOTIFY_ERROR);
@@ -135,7 +129,7 @@
$data->textformat = $entry->format;
$PAGE->requires->js_call_amd('mod_margic/annotations', 'init',
- array('cmid' => $cm->id, 'canmakeannotations' => false, 'myuserid' => $USER->id));
+ ['cmid' => $cm->id, 'canmakeannotations' => false, 'myuserid' => $USER->id]);
} else {
$entry = false;
@@ -153,7 +147,7 @@
// Create form.
$form = new mod_margic_entry_form(null,
- array('editentrydates' => $moduleinstance->editentrydates, 'editoroptions' => $editoroptions));
+ ['editentrydates' => $moduleinstance->editentrydates, 'editoroptions' => $editoroptions]);
// Set existing data for this entry.
$form->set_data($data);
@@ -190,7 +184,7 @@
// Check if timecreated is not older then connected entries.
if ($moduleinstance->editentrydates) {
- $baseentry = $DB->get_record('margic_entries', array('margic' => $moduleinstance->id, "id" => $newentry->baseentry));
+ $baseentry = $DB->get_record('margic_entries', ['margic' => $moduleinstance->id, "id" => $newentry->baseentry]);
if ($newentry->timecreated <= $baseentry->timemodified) {
redirect(new moodle_url('/mod/margic/view.php?id=' . $cm->id), get_string('timecreatedinvalid', 'mod_margic'),
@@ -198,7 +192,7 @@
}
$connectedentries = $DB->get_records('margic_entries',
- array('margic' => $moduleinstance->id, 'baseentry' => $newentry->baseentry), 'timecreated DESC');
+ ['margic' => $moduleinstance->id, 'baseentry' => $newentry->baseentry], 'timecreated DESC');
if ($connectedentries && $newentry->timecreated <= $connectedentries[array_key_first($connectedentries)]->timecreated) {
redirect(new moodle_url('/mod/margic/view.php?id=' . $cm->id), get_string('timecreatedinvalid', 'mod_margic'),
@@ -208,7 +202,7 @@
}
// Update timemodified for base entry.
- $baseentry = $DB->get_record('margic_entries', array('margic' => $moduleinstance->id, "id" => $newentry->baseentry));
+ $baseentry = $DB->get_record('margic_entries', ['margic' => $moduleinstance->id, "id" => $newentry->baseentry]);
$baseentry->timemodified = $newentry->timecreated;
$DB->update_record('margic_entries', $baseentry);
}
@@ -223,23 +217,23 @@
$entrytext = file_rewrite_pluginfile_urls($fromform->text, 'pluginfile.php', $context->id,
'mod_margic', 'entry', $newentry->id);
- $newentry->text = format_text($entrytext, $fromform->textformat, array('para' => false));
+ $newentry->text = format_text($entrytext, $fromform->textformat, ['para' => false]);
$newentry->format = $fromform->textformat;
$DB->update_record('margic_entries', $newentry);
if ($entry && $fromform->entryid) {
// Trigger module entry updated event.
- $event = \mod_margic\event\entry_updated::create(array(
+ $event = \mod_margic\event\entry_updated::create([
'objectid' => $newentry->id,
- 'context' => $context
- ));
+ 'context' => $context,
+ ]);
} else {
// Trigger module entry created event.
- $event = \mod_margic\event\entry_created::create(array(
+ $event = \mod_margic\event\entry_created::create([
'objectid' => $newentry->id,
- 'context' => $context
- ));
+ 'context' => $context,
+ ]);
}
$event->trigger();
@@ -254,7 +248,7 @@
}
-$PAGE->set_url('/mod/margic/edit.php', array('id' => $id));
+$PAGE->set_url('/mod/margic/edit.php', ['id' => $id]);
$PAGE->navbar->add($title);
$PAGE->set_title(format_string($moduleinstance->name) . ' - ' . $title);
$PAGE->set_heading($course->fullname);
@@ -295,7 +289,7 @@
$regradingstr = get_string('needsregrading', 'margic');
if ($entry->baseentry) { // If edited entry is child entry get base entry for rendering.
- $entry = $DB->get_record('margic_entries', array('margic' => $moduleinstance->id, "id" => $entry->baseentry));
+ $entry = $DB->get_record('margic_entries', ['margic' => $moduleinstance->id, "id" => $entry->baseentry]);
}
$page = new margic_entry($margic, $cm, $context, $moduleinstance, $entry, $margic->get_annotationarea_width(),
diff --git a/error_summary.php b/error_summary.php
index cf62f5a..e5ace10 100644
--- a/error_summary.php
+++ b/error_summary.php
@@ -67,9 +67,7 @@
throw new moodle_exception(get_string('incorrectmodule', 'margic'));
}
-if (! $coursesections = $DB->get_record("course_sections", array(
- "id" => $cm->section
-))) {
+if (! $coursesections = $DB->get_record("course_sections", ["id" => $cm->section])) {
throw new moodle_exception(get_string('incorrectmodule', 'margic'));
}
@@ -86,13 +84,13 @@
if ($addtomargic && $manageerrortypes) {
require_sesskey();
- $redirecturl = new moodle_url('/mod/margic/error_summary.php', array('id' => $id));
+ $redirecturl = new moodle_url('/mod/margic/error_summary.php', ['id' => $id]);
- if ($DB->record_exists('margic_errortype_templates', array('id' => $addtomargic))) {
+ if ($DB->record_exists('margic_errortype_templates', ['id' => $addtomargic])) {
global $USER;
- $type = $DB->get_record('margic_errortype_templates', array('id' => $addtomargic));
+ $type = $DB->get_record('margic_errortype_templates', ['id' => $addtomargic]);
if ($type->defaulttype == 1 || ($type->defaulttype == 0 && $type->userid == $USER->id)) {
@@ -118,12 +116,12 @@
}
// Change priority.
-if ($manageerrortypes && $mode == 2 && $priority && $action && $DB->record_exists('margic_errortypes', array('id' => $priority))) {
+if ($manageerrortypes && $mode == 2 && $priority && $action && $DB->record_exists('margic_errortypes', ['id' => $priority])) {
require_sesskey();
- $redirecturl = new moodle_url('/mod/margic/error_summary.php', array('id' => $id));
+ $redirecturl = new moodle_url('/mod/margic/error_summary.php', ['id' => $id]);
- $type = $DB->get_record('margic_errortypes', array('margic' => $moduleinstance->id, 'id' => $priority));
+ $type = $DB->get_record('margic_errortypes', ['margic' => $moduleinstance->id, 'id' => $priority]);
$etypes = $margic->get_margic_errortypes();
@@ -136,7 +134,7 @@
$type->priority -= 1;
$prioritychanged = true;
- $typeswitched = $DB->get_record('margic_errortypes', array('margic' => $moduleinstance->id, 'priority' => $type->priority));
+ $typeswitched = $DB->get_record('margic_errortypes', ['margic' => $moduleinstance->id, 'priority' => $type->priority]);
if (!$typeswitched) { // If no type with priority+1 search for types with higher priority values.
$typeswitched = $DB->get_records_select('margic_errortypes',
@@ -148,13 +146,13 @@
}
} else if ($type && $action == 2 && $type->priority != $DB->count_records('margic_errortypes',
- array('margic' => $moduleinstance->id)) + 1) { // Decrease priority (move further back).
+ ['margic' => $moduleinstance->id]) + 1) { // Decrease priority (move further back).
$oldpriority = $type->priority;
$type->priority += 1;
$prioritychanged = true;
- $typeswitched = $DB->get_record('margic_errortypes', array('margic' => $moduleinstance->id, 'priority' => $type->priority));
+ $typeswitched = $DB->get_record('margic_errortypes', ['margic' => $moduleinstance->id, 'priority' => $type->priority]);
if (!$typeswitched) { // If no type with priority+1 search for types with higher priority values.
$typeswitched = $DB->get_records_select('margic_errortypes',
@@ -187,7 +185,7 @@
require_sesskey();
- $redirecturl = new moodle_url('/mod/margic/error_summary.php', array('id' => $id));
+ $redirecturl = new moodle_url('/mod/margic/error_summary.php', ['id' => $id]);
if ($mode == 1) { // If type is template error type.
$table = 'margic_errortype_templates';
@@ -195,15 +193,15 @@
$table = 'margic_errortypes';
}
- if ($DB->record_exists($table, array('id' => $delete))) {
+ if ($DB->record_exists($table, ['id' => $delete])) {
- $type = $DB->get_record($table, array('id' => $delete));
+ $type = $DB->get_record($table, ['id' => $delete]);
if ($mode == 2 ||
($type->defaulttype == 1 && has_capability('mod/margic:editdefaulterrortypes', $context))
|| ($type->defaulttype == 0 && $type->userid == $USER->id)) {
- $DB->delete_records($table, array('id' => $delete));
+ $DB->delete_records($table, ['id' => $delete]);
redirect($redirecturl, get_string('errortypedeleted', 'mod_margic'), null, notification::NOTIFY_SUCCESS);
} else {
redirect($redirecturl, get_string('notallowedtodothis', 'mod_margic'), null, notification::NOTIFY_ERROR);
@@ -214,11 +212,9 @@
}
// Get the name for this margic activity.
-$margicname = format_string($moduleinstance->name, true, array(
- 'context' => $context
-));
+$margicname = format_string($moduleinstance->name, true, ['context' => $context]);
-$PAGE->set_url('/mod/margic/error_summary.php', array('id' => $cm->id));
+$PAGE->set_url('/mod/margic/error_summary.php', ['id' => $cm->id]);
$PAGE->navbar->add(get_string('errorsummary', 'mod_margic'));
$PAGE->set_title(get_string('modulename', 'mod_margic').': ' . $margicname);
@@ -244,7 +240,7 @@
foreach ($participants as $key => $participant) {
if (has_capability('mod/margic:viewerrorsfromallparticipants', $context) || $participant->id == $USER->id) {
- $participants[$key]->errors = array();
+ $participants[$key]->errors = [];
foreach ($errortypes as $i => $type) {
$sql = "SELECT COUNT(*)
@@ -253,7 +249,7 @@
WHERE e.margic = :margic AND
e.userid = :userid AND
a.type = :atype";
- $params = array('margic' => $moduleinstance->id, 'userid' => $participant->id, 'atype' => $i);
+ $params = ['margic' => $moduleinstance->id, 'userid' => $participant->id, 'atype' => $i];
$count = $DB->count_records_sql($sql, $params);
$participants[$key]->errors[$i] = $count;
diff --git a/errortypes.php b/errortypes.php
index c210291..c5eb248 100644
--- a/errortypes.php
+++ b/errortypes.php
@@ -61,9 +61,7 @@
throw new moodle_exception(get_string('incorrectmodule', 'margic'));
}
-if (! $coursesections = $DB->get_record("course_sections", array(
- "id" => $cm->section
-))) {
+if (! $coursesections = $DB->get_record("course_sections", ["id" => $cm->section])) {
throw new moodle_exception(get_string('incorrectmodule', 'margic'));
}
@@ -71,11 +69,11 @@
require_capability('mod/margic:manageerrortypes', $context);
-$redirecturl = new moodle_url('/mod/margic/error_summary.php', array('id' => $id));
+$redirecturl = new moodle_url('/mod/margic/error_summary.php', ['id' => $id]);
if ($edit !== 0) {
if ($mode == 1) { // If type is template error type.
- $editedtype = $DB->get_record('margic_errortype_templates', array('id' => $edit));
+ $editedtype = $DB->get_record('margic_errortype_templates', ['id' => $edit]);
if (isset($editedtype->defaulttype) && $editedtype->defaulttype == 1
&& !get_config('margic', 'defaulterrortypetemplateseditable')) {
@@ -83,7 +81,7 @@
redirect($redirecturl, get_string('notallowedtodothis', 'mod_margic'), null, notification::NOTIFY_ERROR);
}
} else if ($mode == 2) { // If type is margic error type.
- $editedtype = $DB->get_record('margic_errortypes', array('id' => $edit));
+ $editedtype = $DB->get_record('margic_errortypes', ['id' => $edit]);
if ($moduleinstance->id !== $editedtype->margic) {
redirect($redirecturl, get_string('errortypecantbeedited', 'mod_margic'), null, notification::NOTIFY_ERROR);
@@ -108,18 +106,18 @@
// Instantiate form.
$mform = new \mod_margic_errortypes_form(null,
- array('editdefaulttype' => has_capability('mod/margic:editdefaulterrortypes', $context), 'mode' => $mode));
+ ['editdefaulttype' => has_capability('mod/margic:editdefaulterrortypes', $context), 'mode' => $mode]);
if (isset($editedtypeid)) {
if ($mode == 1) { // If type is template error type.
- $mform->set_data(array('id' => $id, 'mode' => $mode, 'typeid' => $editedtypeid,
- 'typename' => $editedtypename, 'color' => $editedcolor, 'standardtype' => $editeddefaulttype));
+ $mform->set_data(['id' => $id, 'mode' => $mode, 'typeid' => $editedtypeid,
+ 'typename' => $editedtypename, 'color' => $editedcolor, 'standardtype' => $editeddefaulttype, ]);
} else if ($mode == 2) {
- $mform->set_data(array('id' => $id, 'mode' => $mode, 'typeid' => $editedtypeid, 'typename' => $editedtypename,
- 'color' => $editedcolor));
+ $mform->set_data(['id' => $id, 'mode' => $mode, 'typeid' => $editedtypeid, 'typename' => $editedtypename,
+ 'color' => $editedcolor, ]);
}
} else {
- $mform->set_data(array('id' => $id, 'mode' => $mode));
+ $mform->set_data(['id' => $id, 'mode' => $mode]);
}
if ($mform->is_cancelled()) {
@@ -133,7 +131,7 @@
$errortype = new stdClass();
$errortype->timecreated = time();
$errortype->timemodified = 0;
- $errortype->name = format_text($fromform->typename, 1, array('para' => false));
+ $errortype->name = format_text($fromform->typename, 1, ['para' => false]);
$errortype->color = $fromform->color;
if (isset($fromform->standardtype) && $fromform->standardtype === 1 &&
@@ -168,9 +166,9 @@
} else if ($fromform->typeid !== 0 && isset($fromform->typename)) { // Update existing annotation type.
if ($mode == 1) { // If type is template error type.
- $errortype = $DB->get_record('margic_errortype_templates', array('id' => $fromform->typeid));
+ $errortype = $DB->get_record('margic_errortype_templates', ['id' => $fromform->typeid]);
} else if ($mode == 2) { // If type is margic error type.
- $errortype = $DB->get_record('margic_errortypes', array('id' => $fromform->typeid));
+ $errortype = $DB->get_record('margic_errortypes', ['id' => $fromform->typeid]);
}
if ($errortype &&
@@ -181,7 +179,7 @@
&& $errortype->userid == $USER->id))) {
$errortype->timemodified = time();
- $errortype->name = format_text($fromform->typename, 1, array('para' => false));
+ $errortype->name = format_text($fromform->typename, 1, ['para' => false]);
$errortype->color = $fromform->color;
if ($mode == 1 && has_capability('mod/margic:editdefaulterrortypes', $context)) {
@@ -213,15 +211,12 @@
}
// Get the name for this margic activity.
-$margicname = format_string($moduleinstance->name, true, array(
- 'context' => $context
-));
+$margicname = format_string($moduleinstance->name, true, ['context' => $context]);
-$PAGE->set_url('/mod/margic/errortypes.php', array('id' => $cm->id));
+$PAGE->set_url('/mod/margic/errortypes.php', ['id' => $cm->id]);
$navtitle = '';
-
if (isset($editedtypeid)) {
$navtitle = get_string('editerrortype', 'mod_margic');
} else {
diff --git a/errortypes_form.php b/errortypes_form.php
index 7520b89..b66b577 100644
--- a/errortypes_form.php
+++ b/errortypes_form.php
@@ -93,7 +93,7 @@ public function definition() {
* @return array Array with errors
*/
public function validation($data, $files) {
- $errors = array();
+ $errors = [];
if (strlen($data['color']) !== 6 || preg_match("/[^a-fA-F0-9]/", $data['color'])) {
$errors['color'] = get_string('errnohexcolor', 'mod_margic');
diff --git a/grade_entry.php b/grade_entry.php
index 1d60aba..96d4e21 100644
--- a/grade_entry.php
+++ b/grade_entry.php
@@ -55,9 +55,7 @@
throw new moodle_exception(get_string('incorrectcourseid', 'margic'));
}
-if (! $coursesections = $DB->get_record("course_sections", array(
- "id" => $cm->section
-))) {
+if (! $coursesections = $DB->get_record("course_sections", ["id" => $cm->section])) {
throw new moodle_exception(get_string('incorrectmodule', 'margic'));
}
@@ -65,9 +63,9 @@
require_capability('mod/margic:addentries', $context);
-$PAGE->set_url('/mod/margic/grade_entry.php', array('id' => $id));
+$PAGE->set_url('/mod/margic/grade_entry.php', ['id' => $id]);
-$entry = $DB->get_record('margic_entries', array('id' => $entryid, 'margic' => $cm->instance));
+$entry = $DB->get_record('margic_entries', ['id' => $entryid, 'margic' => $cm->instance]);
$grades = make_grades_menu($moduleinstance->scale);
// Prepare editor for files.
@@ -89,8 +87,8 @@
$data->{'rating_' . $entry->id} = $entry->rating;
// Instantiate gradingform and save submitted data if it exists.
-$mform = new \mod_margic_grading_form(null, array('courseid' => $course->id, 'margic' => $moduleinstance, 'entry' => $entry,
- 'grades' => $grades, 'teacherimg' => '', 'editoroptions' => $editoroptions));
+$mform = new \mod_margic_grading_form(null, ['courseid' => $course->id, 'margic' => $moduleinstance, 'entry' => $entry,
+ 'grades' => $grades, 'teacherimg' => '', 'editoroptions' => $editoroptions, ]);
$mform->set_data($data);
@@ -98,12 +96,12 @@
// In this case you process validated data.
if ($fromform->entry !== $entryid) {
- redirect(new moodle_url('/mod/margic/view.php', array('id' => $id)), get_string('errfeedbacknotupdated', 'mod_margic'),
+ redirect(new moodle_url('/mod/margic/view.php', ['id' => $id]), get_string('errfeedbacknotupdated', 'mod_margic'),
null, notification::NOTIFY_ERROR);
}
if (!$fromform->{'feedback_' . $entry->id . '_editor'}) {
- redirect(new moodle_url('/mod/margic/view.php', array('id' => $id)),
+ redirect(new moodle_url('/mod/margic/view.php', ['id' => $id]),
get_string('errnofeedbackorratingdisabled', 'mod_margic'), null, notification::NOTIFY_ERROR);
}
@@ -113,7 +111,7 @@
$newfeedback = file_rewrite_pluginfile_urls($fromform->{'feedback_' . $entry->id}, 'pluginfile.php', $context->id,
'mod_margic', 'feedback', $entry->id);
- $newfeedback = format_text($newfeedback, $fromform->{'feedback_' . $entry->id . '_editor'}['format'], array('para' => false));
+ $newfeedback = format_text($newfeedback, $fromform->{'feedback_' . $entry->id . '_editor'}['format'], ['para' => false]);
if (isset($fromform->{'rating_' . $entry->id})) {
$newrating = $fromform->{'rating_' . $entry->id};
@@ -144,7 +142,7 @@
$entry->timemarked = $timenow;
if (!$DB->update_record("margic_entries", $entry)) {
- redirect(new moodle_url('/mod/margic/view.php', array('id' => $id)), get_string('errfeedbacknotupdated', 'mod_margic'),
+ redirect(new moodle_url('/mod/margic/view.php', ['id' => $id]), get_string('errfeedbacknotupdated', 'mod_margic'),
null, notification::NOTIFY_ERROR);
}
@@ -180,10 +178,10 @@
margic_update_grades($record, $entry->userid);
// Trigger module feedback updated event.
- $event = \mod_margic\event\feedback_updated::create(array(
+ $event = \mod_margic\event\feedback_updated::create([
'objectid' => $entry->id,
- 'context' => $context
- ));
+ 'context' => $context,
+ ]);
$event->trigger();
if ($fromform->sendgradingmessage) {
@@ -217,8 +215,8 @@
$urllink = '' . $url . '';
$footer = '
---------------------------------------------------------------------
'
. get_string('mailfooter', 'mod_margic', ['systemname' => get_config('shortname'),
- 'coursename' => $course->fullname, 'name' => $moduleinstance->name, 'url' => $url]);
- $content = array('*' => array('header' => $header, 'footer' => $footer)); // Extra content for specific processor.
+ 'coursename' => $course->fullname, 'name' => $moduleinstance->name, 'url' => $url, ]);
+ $content = ['*' => ['header' => $header, 'footer' => $footer]]; // Extra content for specific processor.
$message->set_additional_content('email', $content);
// Actually send the message.
@@ -227,15 +225,15 @@
// Redirect after updated from feedback and grades.
redirect(new moodle_url('/mod/margic/view.php',
- array('id' => $id, 'focusgradingform' => $entry->id, 'annotationmode' => 1)),
+ ['id' => $id, 'focusgradingform' => $entry->id, 'annotationmode' => 1]),
get_string('feedbackupdated', 'mod_margic'), null, notification::NOTIFY_SUCCESS);
} else {
redirect(new moodle_url('/mod/margic/view.php',
- array('id' => $id, 'focusgradingform' => $entry->id, 'annotationmode' => 1)),
+ ['id' => $id, 'focusgradingform' => $entry->id, 'annotationmode' => 1]),
get_string('errfeedbacknotupdated', 'mod_margic'), null, notification::NOTIFY_ERROR);
}
} else {
redirect(new moodle_url('/mod/margic/view.php',
- array('id' => $id, 'focusgradingform' => $entry->id, 'annotationmode' => 1)),
+ ['id' => $id, 'focusgradingform' => $entry->id, 'annotationmode' => 1]),
get_string('errfeedbacknotupdated', 'mod_margic'), null, notification::NOTIFY_ERROR);
}
diff --git a/grading_form.php b/grading_form.php
index 7f242bf..8ec9575 100644
--- a/grading_form.php
+++ b/grading_form.php
@@ -58,11 +58,11 @@ public function definition() {
$feedbacktext = $this->_customdata['entry']->feedback;
- $user = $DB->get_record('user', array('id' => $this->_customdata['entry']->userid));
+ $user = $DB->get_record('user', ['id' => $this->_customdata['entry']->userid]);
$userfullname = fullname($user);
$feedbackdisabled = false;
- $attr = array();
+ $attr = [];
if ($this->_customdata['margic']->assessed != 0) { // Append grading area only when grading is not disabled.
@@ -90,7 +90,7 @@ public function definition() {
$this->_customdata['courseid'] . '">' .
$gradinginfo->items[0]->grades[$this->_customdata['entry']->userid]->str_feedback . '';
- $attr = array('disabled' => 'disabled');
+ $attr = ['disabled' => 'disabled'];
}
}
diff --git a/index.php b/index.php
index 14a9490..6d8d101 100644
--- a/index.php
+++ b/index.php
@@ -27,9 +27,7 @@
$id = required_param('id', PARAM_INT); // Course.
-if (! $course = $DB->get_record('course', array(
- 'id' => $id
-))) {
+if (! $course = $DB->get_record('course', ['id' => $id])) {
throw new moodle_exception(get_string('incorrectcourseid', 'margic'));
}
@@ -38,9 +36,7 @@
// Header.
$strmargics = get_string('modulenameplural', 'margic');
$PAGE->set_pagelayout('incourse');
-$PAGE->set_url('/mod/margic/index.php', array(
- 'id' => $id
-));
+$PAGE->set_url('/mod/margic/index.php', ['id' => $id]);
$PAGE->navbar->add($strmargics);
$PAGE->set_title($strmargics);
$PAGE->set_heading($course->fullname);
@@ -65,8 +61,8 @@
// Table data.
$table = new html_table();
-$table->head = array();
-$table->align = array();
+$table->head = [];
+$table->align = [];
if ($usesections) {
// Add column heading based on the course format. e.g. Week, Topic.
$table->head[] = get_string('sectionname', 'format_' . $course->format);
@@ -102,9 +98,7 @@
}
// Link.
- $margicname = format_string($margic->name, true, array(
- 'context' => $context
- ));
+ $margicname = format_string($margic->name, true, ['context' => $context]);
if (! $margic->visible) {
// Show dimmed if the mod is hidden.
$table->data[$i][] = "coursemodule\">" . $margicname . "";
@@ -124,9 +118,7 @@
echo html_writer::table($table);
// Trigger course module instance list event.
-$params = array(
- 'context' => context_course::instance($course->id)
-);
+$params = ['context' => context_course::instance($course->id)];
$event = \mod_margic\event\course_module_instance_list_viewed::create($params);
$event->add_record_snapshot('course', $course);
$event->trigger();
diff --git a/lib.php b/lib.php
index 39dcb6e..05b88d8 100644
--- a/lib.php
+++ b/lib.php
@@ -63,7 +63,7 @@ function margic_add_instance($margic) {
$priority = 1;
foreach ($margic->errortypes as $id => $checked) {
if ($checked) {
- $type = $DB->get_record('margic_errortype_templates', array('id' => $id));
+ $type = $DB->get_record('margic_errortype_templates', ['id' => $id]);
$type->margic = $margic->id;
$type->priority = $priority;
@@ -108,7 +108,7 @@ function margic_update_instance($margic) {
// if scale changes - do we need to recheck the ratings, if ratings higher than scale how do we want to respond?
// for count and sum aggregation types the grade we check to make sure they do not exceed the scale (i.e. max score)
// when calculating the grade.
- $oldmargic = $DB->get_record('margic', array('id' => $margic->id));
+ $oldmargic = $DB->get_record('margic', ['id' => $margic->id]);
$updategrades = false;
@@ -153,13 +153,13 @@ function margic_update_instance($margic) {
function margic_delete_instance($id) {
global $DB;
- if (!$margic = $DB->get_record("margic", array("id" => $id))) {
+ if (!$margic = $DB->get_record("margic", ["id" => $id])) {
return false;
}
if (!$cm = get_coursemodule_from_instance('margic', $margic->id)) {
return false;
}
- if (!$course = $DB->get_record('course', array('id' => $cm->course))) {
+ if (!$course = $DB->get_record('course', ['id' => $cm->course])) {
return false;
}
@@ -176,16 +176,16 @@ function margic_delete_instance($id) {
margic_grade_item_delete($margic);
// Delete entries.
- $DB->delete_records("margic_entries", array("margic" => $margic->id));
+ $DB->delete_records("margic_entries", ["margic" => $margic->id]);
// Delete annotations.
- $DB->delete_records("margic_annotations", array("margic" => $margic->id));
+ $DB->delete_records("margic_annotations", ["margic" => $margic->id]);
// Delete error types for margic.
- $DB->delete_records("margic_errortypes", array("margic" => $margic->id));
+ $DB->delete_records("margic_errortypes", ["margic" => $margic->id]);
// Delete margic, else return false.
- if (!$DB->delete_records("margic", array("id" => $margic->id))) {
+ if (!$DB->delete_records("margic", ["id" => $margic->id])) {
return false;
}
@@ -248,7 +248,7 @@ function margic_supports($feature) {
function margic_user_outline($course, $user, $mod, $margic) {
global $DB;
- if ($count = $DB->count_records("margic_entries", array("userid" => $user->id, "margic" => $margic->id))) {
+ if ($count = $DB->count_records("margic_entries", ["userid" => $user->id, "margic" => $margic->id])) {
$result = new stdClass();
$result->info = $count . ' ' . get_string("entries");
return $result;
@@ -269,11 +269,11 @@ function margic_user_outline($course, $user, $mod, $margic) {
function margic_print_recent_activity($course, $viewfullnames, $timestart) {
global $CFG, $USER, $DB, $OUTPUT;
- $params = array(
+ $params = [
$timestart,
$course->id,
- 'margic'
- );
+ 'margic',
+ ];
// Moodle branch check.
if ($CFG->branch < 311) {
@@ -297,7 +297,7 @@ function margic_print_recent_activity($course, $viewfullnames, $timestart) {
$modinfo = get_fast_modinfo($course);
- $show = array();
+ $show = [];
foreach ($newentries as $entry) {
if (! array_key_exists($entry->cmid, $modinfo->get_cms())) {
@@ -383,13 +383,13 @@ function margic_get_recent_mod_activity(&$activities, &$index, $timestart, $cour
if ($COURSE->id == $courseid) {
$course = $COURSE;
} else {
- $course = $DB->get_record('course', array('id' => $courseid));
+ $course = $DB->get_record('course', ['id' => $courseid]);
}
$modinfo = get_fast_modinfo($course);
$cm = $modinfo->get_cm($cmid);
- $params = array();
+ $params = [];
if ($userid) {
$userselect = 'AND u.id = :userid';
$params['userid'] = $userid;
@@ -438,7 +438,7 @@ function margic_get_recent_mod_activity(&$activities, &$index, $timestart, $cour
$viewfullnames = has_capability('moodle/site:viewfullnames', $cmcontext);
$teacher = has_capability('mod/margic:manageentries', $cmcontext);
- $show = array();
+ $show = [];
foreach ($entries as $entry) {
if ($entry->userid == $USER->id) {
$show[] = $entry;
@@ -478,7 +478,7 @@ function margic_get_recent_mod_activity(&$activities, &$index, $timestart, $cour
if ($grader) {
require_once($CFG->libdir.'/gradelib.php');
- $userids = array();
+ $userids = [];
foreach ($show as $id => $entry) {
$userids[] = $entry->userid;
}
@@ -583,7 +583,7 @@ function margic_reset_course_form_definition(&$mform) {
* @return array
*/
function margic_reset_course_form_defaults($course) {
- return array('reset_margic_all' => 1, 'reset_margic_errortypes' => 1);
+ return ['reset_margic_all' => 1, 'reset_margic_errortypes' => 1];
}
/**
@@ -600,16 +600,16 @@ function margic_reset_userdata($data) {
require_once($CFG->dirroot . '/rating/lib.php');
$modulename = get_string('modulenameplural', 'margic');
- $status = array();
+ $status = [];
// Get margics in course that should be resetted.
$sql = "SELECT m.id
FROM {margic} m
WHERE m.course = ?";
- $params = array(
- $data->courseid
- );
+ $params = [
+ $data->courseid,
+ ];
$margics = $DB->get_records_sql($sql, $params);
@@ -650,18 +650,18 @@ function margic_reset_userdata($data) {
// Delete all entries.
$DB->delete_records_select('margic_entries', "margic IN ($sql)", $params);
- $status[] = array(
+ $status[] = [
'component' => $modulename,
'item' => get_string('alluserdatadeleted', 'margic'),
- 'error' => false
- );
+ 'error' => false,
+ ];
}
// Delete errortypes.
if (!empty($data->reset_margic_errortypes) ) {
$DB->delete_records_select('margic_errortypes', "margic IN ($sql)", $params);
- $status[] = array('component' => $modulename, 'item' => get_string('errortypesdeleted', 'margic'), 'error' => false);
+ $status[] = ['component' => $modulename, 'item' => get_string('errortypesdeleted', 'margic'), 'error' => false];
}
@@ -669,9 +669,9 @@ function margic_reset_userdata($data) {
if ($data->timeshift) {
// Any changes to the list of dates that needs to be rolled should be same during course restore and course reset.
// See MDL-9367.
- shift_course_mod_dates('margic', array('assesstimestart', 'assesstimefinish', 'timeopen', 'timeclose'),
+ shift_course_mod_dates('margic', ['assesstimestart', 'assesstimefinish', 'timeopen', 'timeclose'],
$data->timeshift, $data->courseid);
- $status[] = array('component' => $modulename, 'item' => get_string('datechanged'), 'error' => false);
+ $status[] = ['component' => $modulename, 'item' => get_string('datechanged'), 'error' => false];
}
return $status;
@@ -685,7 +685,7 @@ function margic_reset_userdata($data) {
function margic_reset_gradebook($courseid) {
global $DB;
- $params = array($courseid);
+ $params = [$courseid];
$sql = "SELECT ma.*, cm.idnumber as cmidnumber, ma.course as courseid
FROM {margic} ma, {course_modules} cm, {modules} m
@@ -766,10 +766,10 @@ function margic_grade_item_update($margic, $grades = null) {
global $CFG;
require_once($CFG->libdir . '/gradelib.php');
- $params = array(
+ $params = [
'itemname' => $margic->name,
- 'idnumber' => $margic->cmidnumber
- );
+ 'idnumber' => $margic->cmidnumber,
+ ];
if (! $margic->assessed || $margic->scale == 0) {
$params['gradetype'] = GRADE_TYPE_NONE;
@@ -801,9 +801,9 @@ function margic_grade_item_delete($margic) {
require_once($CFG->libdir . '/gradelib.php');
- return grade_update('mod/margic', $margic->course, 'mod', 'margic', $margic->id, 0, null, array(
- 'deleted' => 1
- ));
+ return grade_update('mod/margic', $margic->course, 'mod', 'margic', $margic->id, 0, null, [
+ 'deleted' => 1,
+ ]);
}
/**
@@ -836,7 +836,7 @@ function margic_scale_used_anywhere($scaleid) {
* @param array $options Additional options affecting the file serving.
* @return bool False if file not found, does not return if found - just send the file.
*/
-function margic_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
+function margic_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = []) {
global $DB, $USER;
if ($context->contextlevel != CONTEXT_MODULE) {
@@ -851,9 +851,7 @@ function margic_pluginfile($course, $cm, $context, $filearea, $args, $forcedownl
// Args[0] should be the entry id.
$entryid = intval(array_shift($args));
- $entry = $DB->get_record('margic_entries', array(
- 'id' => $entryid
- ), 'id, userid', MUST_EXIST);
+ $entry = $DB->get_record('margic_entries', ['id' => $entryid], 'id, userid', MUST_EXIST);
$canmanage = has_capability('mod/margic:manageentries', $context);
if (! $canmanage && ! has_capability('mod/margic:addentries', $context)) {
diff --git a/locallib.php b/locallib.php
index bef43b6..580947b 100644
--- a/locallib.php
+++ b/locallib.php
@@ -62,16 +62,16 @@ class margic {
private $page;
/** @var array Array with all accessible entries of the margic instance */
- private $entries = array();
+ private $entries = [];
/** @var array Array with all annotations to entries of the margic instance */
- private $annotations = array();
+ private $annotations = [];
/** @var array Array with all types of annotations */
- private $errortypes = array();
+ private $errortypes = [];
/** @var array Array of error messages encountered during the execution of margic related operations. */
- private $errors = array();
+ private $errors = [];
/**
* Constructor for the base margic class.
@@ -118,11 +118,11 @@ function sortannotation($a, $b) {
$this->cm = cm_info::create($cm);
- $this->instance = $DB->get_record('margic', array('id' => $this->cm->instance));
+ $this->instance = $DB->get_record('margic', ['id' => $this->cm->instance]);
$this->modulename = get_string('modulename', 'mod_margic');
- $this->annotations = $DB->get_records('margic_annotations', array('margic' => $this->get_course_module()->instance));
+ $this->annotations = $DB->get_records('margic_annotations', ['margic' => $this->get_course_module()->instance]);
$select = "margic = " . $this->instance->id;
$this->errortypes = (array) $DB->get_records_select('margic_errortypes', $select, null, 'priority ASC');
@@ -136,9 +136,9 @@ function sortannotation($a, $b) {
}
if (!array_key_exists($annotation->type, $this->errortypes) &&
- $DB->record_exists('margic_errortypes', array('id' => $annotation->type))) {
+ $DB->record_exists('margic_errortypes', ['id' => $annotation->type])) {
- $this->errortypes[$annotation->type] = $DB->get_record('margic_errortypes', array('id' => $annotation->type));
+ $this->errortypes[$annotation->type] = $DB->get_record('margic_errortypes', ['id' => $annotation->type]);
}
if (isset($this->errortypes[$annotation->type])) {
@@ -250,16 +250,16 @@ function sortannotation($a, $b) {
if ($this->mode == 'allentries') {
if ($userid && $userid != 0) {
- $this->entries = $DB->get_records('margic_entries', array('margic' => $this->instance->id, 'userid' => $userid,
- 'baseentry' => null), $sortoptions);
+ $this->entries = $DB->get_records('margic_entries', ['margic' => $this->instance->id, 'userid' => $userid,
+ 'baseentry' => null, ], $sortoptions);
} else {
- $this->entries = $DB->get_records('margic_entries', array('margic' => $this->instance->id,
- 'baseentry' => null), $sortoptions);
+ $this->entries = $DB->get_records('margic_entries', ['margic' => $this->instance->id,
+ 'baseentry' => null, ], $sortoptions);
}
} else if ($this->mode == 'ownentries') {
- $this->entries = $DB->get_records('margic_entries', array('margic' => $this->instance->id, 'userid' => $USER->id,
- 'baseentry' => null), $sortoptions);
+ $this->entries = $DB->get_records('margic_entries', ['margic' => $this->instance->id, 'userid' => $USER->id,
+ 'baseentry' => null, ], $sortoptions);
}
}
@@ -367,7 +367,7 @@ public function get_margic_errortypes() {
* @return array action
*/
public function get_errortypes_for_form() {
- $types = array();
+ $types = [];
$strmanager = get_string_manager();
foreach ($this->errortypes as $key => $type) {
if ($strmanager->string_exists($type->name, 'mod_margic')) {
@@ -434,7 +434,7 @@ public function get_pagebar() {
unset($groupedentries[0]);
if (isset($groupedentries[2])) {
- $pagebar = array();
+ $pagebar = [];
foreach ($groupedentries as $pagenr => $page) {
$obj = new stdClass();
if ($pagenr == $this->page) {
@@ -464,9 +464,9 @@ public function get_pagebar() {
*/
public function get_pagecountoptions() {
- $pagecountoptions = array(2, 3, 4, 5, 6, 7, 8, 9, 10,
+ $pagecountoptions = [2, 3, 4, 5, 6, 7, 8, 9, 10,
15, 20, 30, 40, 50, 100, 200, 300, 400, 500,
- 1000);
+ 1000, ];
foreach ($pagecountoptions as $key => $number) {
$obj = new stdClass();
@@ -516,7 +516,7 @@ public function prepare_entry($entry, $strmanager, $currentgroups, $allowedusers
global $DB, $USER, $CFG, $OUTPUT;
- $entry->user = $DB->get_record('user', array('id' => $entry->userid));
+ $entry->user = $DB->get_record('user', ['id' => $entry->userid]);
// Check if entry creation time should be shown.
if (!has_capability('mod/margic:viewotherusersentrytimes', $this->context) && $entry->userid != $USER->id) {
@@ -532,7 +532,7 @@ public function prepare_entry($entry, $strmanager, $currentgroups, $allowedusers
if (!$currentgroups || ($allowedusers && in_array($entry->user, $allowedusers))) {
// Get child entries for entry.
$entry->childentries = $DB->get_records('margic_entries',
- array('margic' => $this->instance->id, 'baseentry' => $entry->id), 'timecreated DESC');
+ ['margic' => $this->instance->id, 'baseentry' => $entry->id], 'timecreated DESC');
$revisionnr = count($entry->childentries);
foreach ($entry->childentries as $ci => $childentry) {
@@ -601,7 +601,7 @@ public function prepare_entry($entry, $strmanager, $currentgroups, $allowedusers
require_once($CFG->dirroot . '/mod/margic/classes/local/helper.php');
$entry->user->userpicture = $OUTPUT->user_picture($entry->user,
- array('courseid' => $this->course->id, 'link' => true, 'includefullname' => true, 'size' => 25));
+ ['courseid' => $this->course->id, 'link' => true, 'includefullname' => true, 'size' => 25]);
// Add feedback area to entry.
$entry->gradingform = helper::margic_return_feedback_area_for_entry($this->cm->id, $this->context,
@@ -629,7 +629,7 @@ private function prepare_entry_annotations($entry, $strmanager, $annotationmode
// Get annotations for entry.
$entry->annotations = array_values($DB->get_records('margic_annotations',
- array('margic' => $this->cm->instance, 'entry' => $entry->id)));
+ ['margic' => $this->cm->instance, 'entry' => $entry->id]));
foreach ($entry->annotations as $key => $annotation) {
@@ -639,7 +639,7 @@ private function prepare_entry_annotations($entry, $strmanager, $annotationmode
$entry->annotations[$key]->timemodified = false;
}
- if (!$DB->record_exists('margic_errortypes', array('id' => $annotation->type))) { // If annotation type does not exist.
+ if (!$DB->record_exists('margic_errortypes', ['id' => $annotation->type])) { // If annotation type does not exist.
$entry->annotations[$key]->color = 'FFFF00';
$entry->annotations[$key]->type = get_string('deletederrortype', 'mod_margic');
} else {
@@ -663,9 +663,9 @@ private function prepare_entry_annotations($entry, $strmanager, $annotationmode
if ($annotationmode) {
// Add annotater images to annotations.
- $annotater = $DB->get_record('user', array('id' => $annotation->userid));
+ $annotater = $DB->get_record('user', ['id' => $annotation->userid]);
$annotaterimage = $OUTPUT->user_picture($annotater,
- array('courseid' => $this->course->id, 'link' => true, 'includefullname' => true, 'size' => 20));
+ ['courseid' => $this->course->id, 'link' => true, 'includefullname' => true, 'size' => 20]);
$entry->annotations[$key]->userpicturestr = $annotaterimage;
} else {
@@ -685,10 +685,10 @@ private function prepare_entry_annotations($entry, $strmanager, $annotationmode
// Add annotation form.
if (!$readonly) {
require_once($CFG->dirroot . '/mod/margic/annotation_form.php');
- $mform = new mod_margic_annotation_form(new moodle_url('/mod/margic/annotations.php', array('id' => $this->cm->id)),
- array('types' => $this->get_errortypes_for_form()));
+ $mform = new mod_margic_annotation_form(new moodle_url('/mod/margic/annotations.php', ['id' => $this->cm->id]),
+ ['types' => $this->get_errortypes_for_form()]);
// Set default data.
- $mform->set_data(array('id' => $this->cm->id, 'entry' => $entry->id));
+ $mform->set_data(['id' => $this->cm->id, 'entry' => $entry->id]);
$entry->annotationform = $mform->render();
}
diff --git a/mod_form.php b/mod_form.php
index b2ca75c..b165657 100644
--- a/mod_form.php
+++ b/mod_form.php
@@ -47,9 +47,7 @@ public function definition() {
$mform->addElement('header', 'general', get_string('general', 'form'));
- $mform->addElement('text', 'name', get_string('margicname', 'margic'), array(
- 'size' => '64'
- ));
+ $mform->addElement('text', 'name', get_string('margicname', 'margic'), ['size' => '64']);
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
@@ -85,7 +83,7 @@ public function definition() {
$name .= '' . $type->name . '';
}
- $mform->addElement('advcheckbox', 'errortypes[' . $id . ']', $name, ' ', array('group' => 1), array(0, 1));
+ $mform->addElement('advcheckbox', 'errortypes[' . $id . ']', $name, ' ', ['group' => 1], [0, 1]);
}
}
@@ -93,14 +91,10 @@ public function definition() {
// Add the header for availability.
$mform->addElement('header', 'availibilityhdr', get_string('availability'));
- $mform->addElement('date_time_selector', 'timeopen', get_string('margicopentime', 'margic'), array(
- 'optional' => true
- ));
+ $mform->addElement('date_time_selector', 'timeopen', get_string('margicopentime', 'margic'), ['optional' => true]);
$mform->addHelpButton('timeopen', 'margicopentime', 'margic');
- $mform->addElement('date_time_selector', 'timeclose', get_string('margicclosetime', 'margic'), array(
- 'optional' => true
- ));
+ $mform->addElement('date_time_selector', 'timeclose', get_string('margicclosetime', 'margic'), ['optional' => true]);
$mform->addHelpButton('timeclose', 'margicclosetime', 'margic');
// Edit all setting if user can edit its own entries.
@@ -160,8 +154,8 @@ public function validation($data, $files) {
$maxwidth = 80;
if (!$data['annotationareawidth'] || $data['annotationareawidth'] < $minwidth || $data['annotationareawidth'] > $maxwidth) {
- $errors['annotationareawidth'] = get_string('errannotationareawidthinvalid', 'margic', array('minwidth' => $minwidth,
- 'maxwidth' => $maxwidth));
+ $errors['annotationareawidth'] = get_string('errannotationareawidthinvalid', 'margic', ['minwidth' => $minwidth,
+ 'maxwidth' => $maxwidth, ]);
}
return $errors;
diff --git a/settings.php b/settings.php
index 24a8e34..a82822f 100644
--- a/settings.php
+++ b/settings.php
@@ -32,34 +32,22 @@
// If default error type templates can be edited by admins or user with capability editdefaulterrortypes.
$settings->add(new admin_setting_configselect('margic/defaulterrortypetemplateseditable',
get_string('defaulterrortypetemplateseditable', 'margic'),
- get_string('defaulterrortypetemplateseditable_help', 'margic'), 1, array(
- '0' => get_string('no'),
- '1' => get_string('yes')
- )));
+ get_string('defaulterrortypetemplateseditable_help', 'margic'), 1, ['0' => get_string('no'), '1' => get_string('yes')]));
// Edit all own entries.
$settings->add(new admin_setting_configselect('margic/editentries',
get_string('editentries', 'margic'),
- get_string('editentries_help', 'margic'), 1, array(
- '0' => get_string('no'),
- '1' => get_string('yes')
- )));
+ get_string('editentries_help', 'margic'), 1, ['0' => get_string('no'), '1' => get_string('yes')]));
// Change the date of any new entry.
$settings->add(new admin_setting_configselect('margic/editentrydates',
get_string('editentrydates', 'margic'),
- get_string('editentrydates_help', 'margic'), 1, array(
- '0' => get_string('no'),
- '1' => get_string('yes')
- )));
+ get_string('editentrydates_help', 'margic'), 1, ['0' => get_string('no'), '1' => get_string('yes')]));
// Set if entry creators should be notified about feedback for their entries by default.
$settings->add(new admin_setting_configselect('margic/sendgradingmessage',
get_string('sendgradingmessagedefault', 'margic'),
- get_string('sendgradingmessagedefault_help', 'margic'), 1, array(
- '0' => get_string('no'),
- '1' => get_string('yes')
- )));
+ get_string('sendgradingmessagedefault_help', 'margic'), 1, ['0' => get_string('no'), '1' => get_string('yes')]));
// Appearance settings.
$settings->add(new admin_setting_heading('margic/appearance', get_string('appearance'), ''));
diff --git a/version.php b/version.php
index 1ff6676..31218fa 100644
--- a/version.php
+++ b/version.php
@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'mod_margic';
-$plugin->release = '1.3.0'; // User-friendly version number.
-$plugin->version = 2023100300; // The current module version (Date: YYYYMMDDXX).
+$plugin->release = '1.3.1'; // User-friendly version number.
+$plugin->version = 2023102000; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2020061507; // Requires Moodle 3.9.
$plugin->maturity = MATURITY_STABLE;
diff --git a/view.php b/view.php
index 16b3986..ead3e34 100644
--- a/view.php
+++ b/view.php
@@ -76,9 +76,7 @@
throw new moodle_exception(get_string('incorrectmodule', 'margic'));
}
-if (! $coursesections = $DB->get_record("course_sections", array(
- "id" => $cm->section
-))) {
+if (! $coursesections = $DB->get_record("course_sections", ["id" => $cm->section])) {
throw new moodle_exception(get_string('incorrectmodule', 'margic'));
}
@@ -93,7 +91,7 @@
if ($pagecount) {
// Redirect if pagecount is updated.
- redirect(new moodle_url('/mod/margic/view.php', array('id' => $id)), null, null, null);
+ redirect(new moodle_url('/mod/margic/view.php', ['id' => $id]), null, null, null);
}
// Toolbar action handler for download.
@@ -104,50 +102,37 @@
helper::download_entries($context, $course, $moduleinstance);
// Trigger module margic entries downloaded event.
- $event = \mod_margic\event\download_margic_entries::create(array(
- 'objectid' => $id,
- 'context' => $context
- ));
+ $event = \mod_margic\event\download_margic_entries::create(['objectid' => $id, 'context' => $context]);
$event->trigger();
}
// Trigger course_module_viewed event.
-$event = \mod_margic\event\course_module_viewed::create(array(
- 'objectid' => $id,
- 'context' => $context
-));
+$event = \mod_margic\event\course_module_viewed::create(['objectid' => $id, 'context' => $context]);
$event->add_record_snapshot('course_modules', $cm);
$event->add_record_snapshot('course', $course);
$event->add_record_snapshot('margic', $moduleinstance);
$event->trigger();
// Get the name for this margic activity.
-$margicname = format_string($moduleinstance->name, true, array(
- 'context' => $context
-));
+$margicname = format_string($moduleinstance->name, true, ['context' => $context]);
$canmakeannotations = has_capability('mod/margic:makeannotations', $context);
// Add javascript and navbar element if annotationmode is activated and user has capability.
if ($annotationmode === 1 && has_capability('mod/margic:viewannotations', $context)) {
- $PAGE->set_url('/mod/margic/view.php', array(
- 'id' => $cm->id,
- 'annotationmode' => 1,
- ));
+ $PAGE->set_url('/mod/margic/view.php', ['id' => $cm->id, 'annotationmode' => 1]);
- $PAGE->navbar->add(get_string("viewentries", "margic"), new moodle_url('/mod/margic/view.php', array('id' => $cm->id)));
+ $PAGE->navbar->add(get_string("viewentries", "margic"), new moodle_url('/mod/margic/view.php', ['id' => $cm->id]));
$PAGE->navbar->add(get_string('viewannotations', 'mod_margic'));
$PAGE->requires->js_call_amd('mod_margic/annotations', 'init',
- array( 'cmid' => $cm->id, 'canmakeannotations' => $canmakeannotations, 'myuserid' => $USER->id,
+ ['cmid' => $cm->id, 'canmakeannotations' => $canmakeannotations, 'myuserid' => $USER->id,
'focusannotation' => $focusannotation, 'focusgradingform' => $focusgradingform,
- 'overwriteannotations' => $moduleinstance->overwriteannotations));
+ 'overwriteannotations' => $moduleinstance->overwriteannotations, ]);
} else {
// Header.
- $PAGE->set_url('/mod/margic/view.php', array(
- 'id' => $cm->id
- ));
+ $PAGE->set_url('/mod/margic/view.php', ['id' => $cm->id]);
$PAGE->navbar->add(get_string("viewentries", "margic"));
}