From a7bb4aa06d58dd31a3fa7aa9d68a2ec13b3c7b54 Mon Sep 17 00:00:00 2001 From: Daniel Nolte <> Date: Mon, 23 Oct 2023 13:53:39 +0200 Subject: [PATCH] fix(icon): Ensured compatibility with Moodle 4.3. Changed size of svgs to 24*24. --- .github/workflows/ci.yml | 4 +- CHANGES.md | 5 + amd/build/view.min.js.map | 2 +- backup/moodle2/backup_pingo_stepslib.php | 12 +- .../restore_pingo_activity_task.class.php | 12 +- backup/moodle2/restore_pingo_stepslib.php | 2 +- classes/event/connection_closed.php | 6 +- classes/event/connection_created.php | 6 +- classes/event/course_module_viewed.php | 2 +- classes/event/pingo_login_failed.php | 4 +- classes/event/pingo_login_successful.php | 6 +- classes/event/pingo_survey_created.php | 4 +- classes/pingo_api/api.php | 92 +++++----- classes/privacy/provider.php | 16 +- db/access.php | 56 +++--- index.php | 18 +- lib.php | 68 ++----- login_form.php | 2 +- mod_form.php | 2 +- pix/icon.svg | 24 ++- pix/monologo.svg | 19 +- questionfromcatalogue_form.php | 4 +- quickstart_form.php | 2 +- stopsurvey_form.php | 2 +- version.php | 4 +- view.php | 166 +++++++++--------- 26 files changed, 256 insertions(+), 284 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d48dd6a..2e8ef50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,8 +30,8 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.3', '7.4', '8.0', '8.1'] - moodle-branch: ['MOODLE_39_STABLE', 'MOODLE_310_STABLE', 'MOODLE_311_STABLE', 'MOODLE_400_STABLE', 'MOODLE_401_STABLE', 'MOODLE_402_STABLE'] + php: ['7.3', '7.4', '8.0', '8.1', '8.2'] + moodle-branch: ['MOODLE_39_STABLE', 'MOODLE_310_STABLE', 'MOODLE_311_STABLE', 'MOODLE_400_STABLE', 'MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE'] database: [pgsql, mariadb] steps: diff --git a/CHANGES.md b/CHANGES.md index 34de7ef..d0f3c3e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ ## Changelog ## +- [1.0.3]: + - Ensured compatibility with Moodle 4.3. + - Changed code to comply with new moodle coding standards. + - Changed size of svgs to 24*24. + - [1.0.2]: - Added monologo icon. - Changed purpose to communication. diff --git a/amd/build/view.min.js.map b/amd/build/view.min.js.map index 65df7ea..bd8f342 100644 --- a/amd/build/view.min.js.map +++ b/amd/build/view.min.js.map @@ -1 +1 @@ -{"version":3,"file":"view.min.js","sources":["../src/view.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * JavaScript for the main page of the plugin.\n *\n * @module mod_pingo/view\n * @copyright 2023 coactum GmbH\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\n\nexport const init = () => {\n $(\"#id_tag\").on('change', function() {\n $('input[name=reload]').val(1);\n this.form.submit();\n });\n\n $('input[name=\"activatesession\"]').change(function() {\n if (this.checked) {\n window.location.search += '&activatesession=' + this.id;\n } else {\n window.location.search += '&activatesession=' + 0;\n }\n });\n\n if ($(\"#endtime\").text()) {\n // Set the date we're counting down to.\n var countDownDate = new Date($(\"#endtime\").text()).getTime();\n\n // Update the count down every 1 second.\n var x = setInterval(function() {\n\n // Get today's date and time.\n var now = new Date().getTime();\n\n // Find the distance between now and the count down date.\n var distance = countDownDate - now;\n\n // Time calculations for minutes and seconds.\n var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));\n var seconds = Math.floor((distance % (1000 * 60)) / 1000);\n\n if (seconds < 10) {\n seconds = '0' + seconds;\n }\n\n // Display the result in the element with id=\"endtime\".\n $(\"#endtime\").html(minutes + \":\" + seconds);\n\n // If the countdown is finished reload.\n if (distance < 0) {\n clearInterval(x);\n $(\"#endtime\").html('-');\n\n location.reload();\n }\n }, 1000);\n\n }\n};"],"names":["obj","_jquery","__esModule","default","_exports","init","$","on","val","this","form","submit","change","checked","window","location","search","id","text","countDownDate","Date","getTime","x","setInterval","now","distance","minutes","Math","floor","seconds","html","clearInterval","reload"],"mappings":"yEAuBuB,IAAAA;;;;;;;kFAAvBC,SAAuBD,IAAvBC,UAAuBD,IAAAE,WAAAF,IAAAG,CAAAA,QAAAH,KAkDrBI,SAAAC,KAhDkBA,KAchB,IAbA,EAAAC,QAAAA,SAAE,WAAWC,GAAG,UAAU,YACtB,EAAAD,QAAAA,SAAE,sBAAsBE,IAAI,GAC5BC,KAAKC,KAAKC,QACd,KAEA,EAAAL,iBAAE,iCAAiCM,QAAO,WAClCH,KAAKI,QACLC,OAAOC,SAASC,QAAU,oBAAsBP,KAAKQ,GAErDH,OAAOC,SAASC,QAAU,oBAElC,KAEI,EAAAV,iBAAE,YAAYY,OAEd,IAAIC,cAAgB,IAAIC,MAAK,EAAAd,QAACH,SAAC,YAAYe,QAAQG,UAG/CC,EAAIC,aAAY,WAGhB,IAAIC,KAAM,IAAIJ,MAAOC,UAGjBI,SAAWN,cAAgBK,IAG3BE,QAAUC,KAAKC,MAAOH,SAAY,KAAe,KACjDI,QAAUF,KAAKC,MAAOH,SAAY,IAAc,KAEhDI,QAAU,KACVA,QAAU,IAAMA,UAIpB,EAAAvB,QAACH,SAAC,YAAY2B,KAAKJ,QAAU,IAAMG,SAG/BJ,SAAW,IACXM,cAAcT,IACd,EAAAhB,QAAAA,SAAE,YAAYwB,KAAK,KAEnBf,SAASiB,SAEhB,GAAE,IAEP,CACF"} \ No newline at end of file +{"version":3,"file":"view.min.js","sources":["../src/view.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * JavaScript for the main page of the plugin.\n *\n * @module mod_pingo/view\n * @copyright 2023 coactum GmbH\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport $ from 'jquery';\n\nexport const init = () => {\n $(\"#id_tag\").on('change', function() {\n $('input[name=reload]').val(1);\n this.form.submit();\n });\n\n $('input[name=\"activatesession\"]').change(function() {\n if (this.checked) {\n window.location.search += '&activatesession=' + this.id;\n } else {\n window.location.search += '&activatesession=' + 0;\n }\n });\n\n if ($(\"#endtime\").text()) {\n // Set the date we're counting down to.\n var countDownDate = new Date($(\"#endtime\").text()).getTime();\n\n // Update the count down every 1 second.\n var x = setInterval(function() {\n\n // Get today's date and time.\n var now = new Date().getTime();\n\n // Find the distance between now and the count down date.\n var distance = countDownDate - now;\n\n // Time calculations for minutes and seconds.\n var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));\n var seconds = Math.floor((distance % (1000 * 60)) / 1000);\n\n if (seconds < 10) {\n seconds = '0' + seconds;\n }\n\n // Display the result in the element with id=\"endtime\".\n $(\"#endtime\").html(minutes + \":\" + seconds);\n\n // If the countdown is finished reload.\n if (distance < 0) {\n clearInterval(x);\n $(\"#endtime\").html('-');\n\n location.reload();\n }\n }, 1000);\n\n }\n};"],"names":["obj","_jquery","__esModule","default","_exports","init","$","on","val","this","form","submit","change","checked","window","location","search","id","text","countDownDate","Date","getTime","x","setInterval","now","distance","minutes","Math","floor","seconds","html","clearInterval","reload"],"mappings":"yEAuBuB,IAAAA;;;;;;;kFAAvBC,SAAuBD,IAAvBC,UAAuBD,IAAAE,WAAAF,KAAAG,QAAAH,KAkDrBI,SAAAC,KAhDkBA,KAchB,IAbA,EAAAC,iBAAE,WAAWC,GAAG,UAAU,YACtB,EAAAD,iBAAE,sBAAsBE,IAAI,GAC5BC,KAAKC,KAAKC,aAGd,EAAAL,iBAAE,iCAAiCM,QAAO,WAClCH,KAAKI,QACLC,OAAOC,SAASC,QAAU,oBAAsBP,KAAKQ,GAErDH,OAAOC,SAASC,QAAU,yBAI9B,EAAAV,iBAAE,YAAYY,OAEd,IAAIC,cAAgB,IAAIC,MAAK,EAAAd,iBAAE,YAAYY,QAAQG,UAG/CC,EAAIC,aAAY,WAGhB,IAAIC,KAAM,IAAIJ,MAAOC,UAGjBI,SAAWN,cAAgBK,IAG3BE,QAAUC,KAAKC,MAAOH,mBACtBI,QAAUF,KAAKC,MAAOH,aAA0B,KAEhDI,QAAU,KACVA,QAAU,IAAMA,UAIpB,EAAAvB,iBAAE,YAAYwB,KAAKJ,QAAU,IAAMG,SAG/BJ,SAAW,IACXM,cAAcT,IACd,EAAAhB,iBAAE,YAAYwB,KAAK,KAEnBf,SAASiB,YAEd,KAGT"} \ No newline at end of file diff --git a/backup/moodle2/backup_pingo_stepslib.php b/backup/moodle2/backup_pingo_stepslib.php index 3574981..a472659 100644 --- a/backup/moodle2/backup_pingo_stepslib.php +++ b/backup/moodle2/backup_pingo_stepslib.php @@ -41,12 +41,12 @@ protected function define_structure() { $userinfo = $this->get_setting_value('userinfo'); // Replace with the attributes and final elements that the element will handle. - $pingo = new backup_nested_element('pingo', array('id'), array( - 'name', 'intro', 'introformat', 'timecreated', 'timemodified', 'editableforall')); + $pingo = new backup_nested_element('pingo', ['id'], [ + 'name', 'intro', 'introformat', 'timecreated', 'timemodified', 'editableforall', ]); $connections = new backup_nested_element('connections'); - $connection = new backup_nested_element('connection', array('id'), array( - 'userid', 'authenticationtoken', 'timestarted', 'activesession')); + $connection = new backup_nested_element('connection', ['id'], [ + 'userid', 'authenticationtoken', 'timestarted', 'activesession', ]); // Build the tree with these elements with $pingo as the root of the backup tree. $pingo->add_child($connections); @@ -54,11 +54,11 @@ protected function define_structure() { // Define the source tables for the elements. - $pingo->set_source_table('pingo', array('id' => backup::VAR_ACTIVITYID)); + $pingo->set_source_table('pingo', ['id' => backup::VAR_ACTIVITYID]); if ($userinfo) { // Connections. - $connection->set_source_table('pingo_connections', array('pingo' => backup::VAR_PARENTID)); + $connection->set_source_table('pingo_connections', ['pingo' => backup::VAR_PARENTID]); } // Define id annotations. diff --git a/backup/moodle2/restore_pingo_activity_task.class.php b/backup/moodle2/restore_pingo_activity_task.class.php index 64526cf..2a27003 100644 --- a/backup/moodle2/restore_pingo_activity_task.class.php +++ b/backup/moodle2/restore_pingo_activity_task.class.php @@ -57,12 +57,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. + // tablename, [field1, field 2], $mapping. - $contents[] = new restore_decode_content('pingo', array('intro'), 'pingo'); + $contents[] = new restore_decode_content('pingo', ['intro'], 'pingo'); return $contents; } @@ -73,7 +73,7 @@ public static function define_decode_contents() { * @return array. */ public static function define_decode_rules() { - $rules = array(); + $rules = []; // Define the 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 to restore the logs (one rule for each event / file in the plugin/event/ folder). @@ -112,7 +112,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('pingo', 'view all', 'index.php?id={course}', null); diff --git a/backup/moodle2/restore_pingo_stepslib.php b/backup/moodle2/restore_pingo_stepslib.php index 60b5224..33b8c8c 100644 --- a/backup/moodle2/restore_pingo_stepslib.php +++ b/backup/moodle2/restore_pingo_stepslib.php @@ -37,7 +37,7 @@ class restore_pingo_activity_structure_step extends restore_activity_structure_s * @return restore_path_element[]. */ protected function define_structure() { - $paths = array(); + $paths = []; $userinfo = $this->get_setting_value('userinfo'); $paths[] = new restore_path_element('pingo', '/activity/pingo'); diff --git a/classes/event/connection_closed.php b/classes/event/connection_closed.php index 5599963..739f7bf 100644 --- a/classes/event/connection_closed.php +++ b/classes/event/connection_closed.php @@ -66,15 +66,13 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/mod/pingo/view.php', array( - 'id' => $this->contextinstanceid - )); + return new \moodle_url('/mod/pingo/view.php', ['id' => $this->contextinstanceid]); } /** * Get objectid mapping for restore. */ public static function get_objectid_mapping() { - return array('db' => 'pingo_connections', 'restore' => 'pingo_connection'); + return ['db' => 'pingo_connections', 'restore' => 'pingo_connection']; } } diff --git a/classes/event/connection_created.php b/classes/event/connection_created.php index 47d3446..667aad2 100644 --- a/classes/event/connection_created.php +++ b/classes/event/connection_created.php @@ -66,15 +66,13 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/mod/pingo/view.php', array( - 'id' => $this->contextinstanceid - )); + return new \moodle_url('/mod/pingo/view.php', ['id' => $this->contextinstanceid]); } /** * Get objectid mapping for restore. */ public static function get_objectid_mapping() { - return array('db' => 'pingo_connections', 'restore' => 'pingo_connection'); + return ['db' => 'pingo_connections', 'restore' => 'pingo_connection']; } } diff --git a/classes/event/course_module_viewed.php b/classes/event/course_module_viewed.php index ce0a062..6737440 100644 --- a/classes/event/course_module_viewed.php +++ b/classes/event/course_module_viewed.php @@ -46,6 +46,6 @@ protected function init() { * Get objectid mapping for restore. */ public static function get_objectid_mapping() { - return array('db' => 'pingo', 'restore' => 'pingo'); + return ['db' => 'pingo', 'restore' => 'pingo']; } } diff --git a/classes/event/pingo_login_failed.php b/classes/event/pingo_login_failed.php index 6ba99cd..cd8009f 100644 --- a/classes/event/pingo_login_failed.php +++ b/classes/event/pingo_login_failed.php @@ -66,8 +66,6 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/mod/pingo/view.php', array( - 'id' => $this->contextinstanceid - )); + return new \moodle_url('/mod/pingo/view.php', ['id' => $this->contextinstanceid]); } } diff --git a/classes/event/pingo_login_successful.php b/classes/event/pingo_login_successful.php index c5c1ffc..2b565d4 100644 --- a/classes/event/pingo_login_successful.php +++ b/classes/event/pingo_login_successful.php @@ -66,15 +66,13 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/mod/pingo/view.php', array( - 'id' => $this->contextinstanceid - )); + return new \moodle_url('/mod/pingo/view.php', ['id' => $this->contextinstanceid]); } /** * Get objectid mapping for restore. */ public static function get_objectid_mapping() { - return array('db' => 'pingo_connections', 'restore' => 'pingo_connection'); + return ['db' => 'pingo_connections', 'restore' => 'pingo_connection']; } } diff --git a/classes/event/pingo_survey_created.php b/classes/event/pingo_survey_created.php index 3093e14..d6b8f1d 100644 --- a/classes/event/pingo_survey_created.php +++ b/classes/event/pingo_survey_created.php @@ -66,8 +66,6 @@ public function get_description() { * @return \moodle_url */ public function get_url() { - return new \moodle_url('/mod/pingo/view.php', array( - 'id' => $this->contextinstanceid - )); + return new \moodle_url('/mod/pingo/view.php', ['id' => $this->contextinstanceid]); } } diff --git a/classes/pingo_api/api.php b/classes/pingo_api/api.php index a81bb90..ae6fbc6 100644 --- a/classes/pingo_api/api.php +++ b/classes/pingo_api/api.php @@ -49,17 +49,17 @@ public static function get_authtoken($remoteurl, $email, $password) { $data = 'password=' . urlencode($password) . '&email=' . urlencode($email); - $options = array( + $options = [ 'RETURNTRANSFER' => 1, 'HEADER' => 0, 'FAILONERROR' => 1, - ); + ]; - $header = array( + $header = [ 'Content-Type: application/x-www-form-urlencoded', 'Content-Length: ' . strlen($data), - 'Accept: application/json' - ); + 'Accept: application/json', + ]; $curl = new \curl(); $curl->setHeader($header); @@ -88,17 +88,17 @@ public static function get_session($remoteurl, $authtoken, $session) { $data = ''; - $options = array( + $options = [ 'RETURNTRANSFER' => 1, 'HEADER' => 0, 'FAILONERROR' => 1, - ); + ]; - $header = array( + $header = [ 'Content-Type: application/x-www-form-urlencoded', 'Content-Length: ' . strlen($data), - 'Accept: application/json' - ); + 'Accept: application/json', + ]; $curl = new \curl(); @@ -132,17 +132,17 @@ public static function get_sessions($remoteurl, $authtoken) { $data = ''; - $options = array( + $options = [ 'RETURNTRANSFER' => 1, 'HEADER' => 0, 'FAILONERROR' => 1, - ); + ]; - $header = array( + $header = [ 'Content-Type: application/x-www-form-urlencoded', 'Content-Length: ' . strlen($data), - 'Accept: application/json' - ); + 'Accept: application/json', + ]; $curl = new \curl(); $curl->setHeader($header); @@ -171,17 +171,17 @@ public static function get_durationchoices($remoteurl) { $data = ''; - $options = array( + $options = [ 'RETURNTRANSFER' => 1, 'HEADER' => 0, 'FAILONERROR' => 1, - ); + ]; - $header = array( + $header = [ 'Content-Type: application/x-www-form-urlencoded', 'Content-Length: ' . strlen($data), - 'Accept: application/json' - ); + 'Accept: application/json', + ]; $curl = new \curl(); $curl->setHeader($header); @@ -234,17 +234,17 @@ public static function get_quickstart_formdata($remoteurl, $authtoken) { $data = ''; - $options = array( + $options = [ 'RETURNTRANSFER' => 1, 'HEADER' => 0, 'FAILONERROR' => 1, - ); + ]; - $header = array( + $header = [ 'Content-Type: application/x-www-form-urlencoded', 'Content-Length: ' . strlen($data), - 'Accept: application/json' - ); + 'Accept: application/json', + ]; $curl = new \curl(); $curl->setHeader($header); @@ -256,11 +256,11 @@ public static function get_quickstart_formdata($remoteurl, $authtoken) { } else if (isset($response['question_types'])) { $qts = $response['question_types']; - $questiontypes = array(); - $answeroptions = array(); + $questiontypes = []; + $answeroptions = []; foreach ($qts as $i => $type) { - $tempoptions = array(); + $tempoptions = []; if (current_language() == 'de') { if ($type['type'] == 'text') { @@ -321,14 +321,14 @@ public static function run_quickstart($remoteurl, $authtoken, $session, $questio $url = $remoteurl . "/events/$session/quick_start"; // Set the request data. - $data = array('auth_token' => $authtoken, 'options' => $answeroption, 'q_type' => $questiontype, 'duration' => $duration); + $data = ['auth_token' => $authtoken, 'options' => $answeroption, 'q_type' => $questiontype, 'duration' => $duration]; $data = json_encode($data); // Set the request header. - $header = array( + $header = [ 'Content-Type: application/json', - 'Accept: application/json' - ); + 'Accept: application/json', + ]; // Perform the POST request. $curl->setHeader($header); @@ -357,15 +357,15 @@ public static function get_questionfromcatalogue_formdata($remoteurl, $authtoken $data = ''; - $options = array( + $options = [ 'RETURNTRANSFER' => 1, 'HEADER' => 0, 'FAILONERROR' => 1, - ); + ]; - $header = array( - 'Accept: application/json' - ); + $header = [ + 'Accept: application/json', + ]; $curl = new \curl(); $curl->setHeader($header); @@ -380,7 +380,7 @@ public static function get_questionfromcatalogue_formdata($remoteurl, $authtoken return false; } else { // Get array with all tags used by questions. - $tags = array('alltags' => get_string('alltags', 'mod_pingo')); + $tags = ['alltags' => get_string('alltags', 'mod_pingo')]; foreach ($questions as $question) { foreach ($question['tags'] as $tag) { $tagformatted = format_text($tag, 2); @@ -416,14 +416,14 @@ public static function run_question_from_catalogue($remoteurl, $authtoken, $sess $url = $remoteurl . "/events/$session/add_question.js"; // Set the request data. - $data = array('auth_token' => $authtoken, 'question' => $questionid, 'duration' => $duration); + $data = ['auth_token' => $authtoken, 'question' => $questionid, 'duration' => $duration]; $data = json_encode($data); // Set the request header. - $header = array( + $header = [ 'Content-Type: application/json', - 'Accept: application/json' - ); + 'Accept: application/json', + ]; // Perform the POST request. $curl->setHeader($header); @@ -457,14 +457,14 @@ public static function stop_survey($remoteurl, $authtoken, $session, $surveyid, $url = $remoteurl . "/events/$session/surveys/$surveyid/stop"; // Set the request data. - $data = array('auth_token' => $authtoken, 'stoptime' => $stoptime); + $data = ['auth_token' => $authtoken, 'stoptime' => $stoptime]; $data = json_encode($data); // Set the request header. - $header = array( + $header = [ 'Content-Type: application/json', - 'Accept: application/json' - ); + 'Accept: application/json', + ]; // Perform the POST request. $curl->setHeader($header); diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 604f296..f3fa8f9 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -24,14 +24,14 @@ namespace mod_pingo\privacy; -use \core_privacy\local\request\userlist; -use \core_privacy\local\request\approved_contextlist; -use \core_privacy\local\request\approved_userlist; -use \core_privacy\local\request\writer; -use \core_privacy\local\request\helper; -use \core_privacy\local\metadata\collection; -use \core_privacy\local\request\transform; -use \core_privacy\local\request\contextlist; +use core_privacy\local\request\userlist; +use core_privacy\local\request\approved_contextlist; +use core_privacy\local\request\approved_userlist; +use core_privacy\local\request\writer; +use core_privacy\local\request\helper; +use core_privacy\local\metadata\collection; +use core_privacy\local\request\transform; +use core_privacy\local\request\contextlist; /** * Implementation of the privacy subsystem plugin provider for the PINGO activity module. diff --git a/db/access.php b/db/access.php index bba9a46..969d78e 100644 --- a/db/access.php +++ b/db/access.php @@ -25,60 +25,60 @@ defined('MOODLE_INTERNAL') || die(); -$capabilities = array( +$capabilities = [ - 'mod/pingo:addinstance' => array( + 'mod/pingo: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/pingo:viewoverview' => array( + 'mod/pingo:viewoverview' => [ 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_MODULE, - 'archetypes' => array( + 'archetypes' => [ 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) - ), + 'manager' => CAP_ALLOW, + ], + ], - 'mod/pingo:logintopingo' => array( + 'mod/pingo:logintopingo' => [ 'riskbitmask' => RISK_PERSONAL | RISK_SPAM, 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, - 'archetypes' => array( + 'archetypes' => [ 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) - ), + 'manager' => CAP_ALLOW, + ], + ], - 'mod/pingo:viewallsessions' => array( + 'mod/pingo:viewallsessions' => [ 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_MODULE, - 'archetypes' => array( + 'archetypes' => [ 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) - ), + 'manager' => CAP_ALLOW, + ], + ], - 'mod/pingo:startsurvey' => array( + 'mod/pingo:startsurvey' => [ 'riskbitmask' => RISK_PERSONAL | RISK_SPAM, 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, - 'archetypes' => array( + 'archetypes' => [ 'teacher' => CAP_ALLOW, 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ) - ), -); + 'manager' => CAP_ALLOW, + ], + ], +]; diff --git a/index.php b/index.php index bebbbe3..eb19e43 100644 --- a/index.php +++ b/index.php @@ -28,7 +28,7 @@ $id = required_param('id', PARAM_INT); // ID of the course. if ($id) { - if (!$course = $DB->get_record('course', array('id' => $id))) { + if (!$course = $DB->get_record('course', ['id' => $id])) { throw new moodle_exception('invalidcourseid'); } } else { @@ -40,9 +40,7 @@ $coursecontext = context_course::instance($course->id); // Trigger course_module_instance_list_viewed event. -$event = \mod_pingo\event\course_module_instance_list_viewed::create(array( - 'context' => $coursecontext -)); +$event = \mod_pingo\event\course_module_instance_list_viewed::create(['context' => $coursecontext]); $event->add_record_snapshot('course', $course); $event->trigger(); @@ -51,7 +49,7 @@ $PAGE->set_pagelayout('incourse'); -$PAGE->set_url('/mod/pingo/index.php', array('id' => $id)); +$PAGE->set_url('/mod/pingo/index.php', ['id' => $id]); $PAGE->navbar->add($modulenameplural); @@ -72,12 +70,12 @@ } if (empty($moduleinstances)) { - notice(get_string('nonewmodules', 'mod_pingo'), new moodle_url('/course/view.php', array('id' => $course->id))); + notice(get_string('nonewmodules', 'mod_pingo'), new moodle_url('/course/view.php', ['id' => $course->id])); } $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); @@ -113,9 +111,7 @@ } // Link. - $pingoname = format_string($pingo->name, true, array( - 'context' => $context - )); + $pingoname = format_string($pingo->name, true, ['context' => $context]); if (! $pingo->visible) { // Show dimmed if the mod is hidden. $table->data[$i][] = "coursemodule\">" . $pingoname . ""; diff --git a/lib.php b/lib.php index 583ed92..c26f1dc 100644 --- a/lib.php +++ b/lib.php @@ -110,23 +110,23 @@ function pingo_update_instance($moduleinstance, $mform = null) { function pingo_delete_instance($id) { global $DB; - if (!$pingo = $DB->get_record('pingo', array('id' => $id))) { + if (!$pingo = $DB->get_record('pingo', ['id' => $id])) { return false; } if (!$cm = get_coursemodule_from_instance('pingo', $pingo->id)) { return false; } - if (!$course = $DB->get_record('course', array('id' => $cm->course))) { + if (!$course = $DB->get_record('course', ['id' => $cm->course])) { return false; } // Delete pingo connections. - if ($DB->record_exists('pingo_connections', array('pingo' => $id))) { - $DB->delete_records('pingo_connections', array('pingo' => $id)); + if ($DB->record_exists('pingo_connections', ['pingo' => $id])) { + $DB->delete_records('pingo_connections', ['pingo' => $id]); } // Delete pingo, else return false. - if (!$DB->delete_records("pingo", array("id" => $pingo->id))) { + if (!$DB->delete_records("pingo", ["id" => $pingo->id])) { return false; } @@ -173,7 +173,7 @@ function pingo_reset_course_form_definition(&$mform) { * @return array */ function pingo_reset_course_form_defaults($course) { - return array('reset_pingo_all' => 1); + return ['reset_pingo_all' => 1]; } /** @@ -190,16 +190,16 @@ function pingo_reset_userdata($data) { require_once($CFG->dirroot . '/rating/lib.php'); $componentstr = get_string('modulenameplural', 'pingo'); - $status = array(); + $status = []; // Get pingos in course that should be resetted. $sql = "SELECT p.id FROM {pingo} p WHERE p.course = ?"; - $params = array( - $data->courseid - ); + $params = [ + $data->courseid, + ]; $pingos = $DB->get_records_sql($sql, $params); @@ -208,19 +208,19 @@ function pingo_reset_userdata($data) { $DB->delete_records_select('pingo_connections', "pingo IN ($sql)", $params); - $status[] = array( + $status[] = [ 'component' => $componentstr, 'item' => get_string('alluserdatadeleted', 'pingo'), - 'error' => false - ); + 'error' => false, + ]; } // Updating dates - shift may be negative too. 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('pingo', array(''), $data->timeshift, $data->courseid); - $status[] = array('component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false); + shift_course_mod_dates('pingo', [''], $data->timeshift, $data->courseid); + $status[] = ['component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false]; } return $status; @@ -262,7 +262,7 @@ function pingo_get_file_info($browser, $areas, $course, $cm, $context, $filearea * @param array $options Additional options affecting the file serving. * @return bool false if file not found, does not return if found - just sends the file. */ -function pingo_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, $options = array()) { +function pingo_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, $options = []) { global $DB, $CFG; if ($context->contextlevel != CONTEXT_MODULE) { @@ -284,39 +284,3 @@ function pingo_pluginfile($course, $cm, $context, $filearea, $args, $forcedownlo send_file_not_found(); } - -/** - * Extends the global navigation tree by adding mod_pingo nodes if there is a relevant content. - * - * This can be called by an AJAX request so do not rely on $PAGE as it might not be set up properly. - * - * @param navigation_node $pingonode An object representing the navigation tree node. - * @param stdClass $course Course object - * @param context_course $coursecontext Course context - */ -function pingo_extend_navigation_course($pingonode, $course, $coursecontext) { - $modinfo = get_fast_modinfo($course); // Get mod_fast_modinfo from $course. - $index = 1; // Set index. - foreach ($modinfo->get_cms() as $cmid => $cm) { // Search existing course modules for this course. - if ($index == 1 && $cm->modname == "pingo" && $cm->uservisible && $cm->available) { - $url = new moodle_url("/mod/" . $cm->modname . "/index.php", - array("id" => $course->id)); // Set url for the link in the navigation node. - $node = navigation_node::create(get_string('viewallpingos', 'pingo'), $url, - navigation_node::TYPE_CUSTOM, null , null , null); - $pingonode->add_node($node); - $index++; - } - } -} - -/** - * Extends the settings navigation with the mod_pingo settings. - * - * This function is called when the context for the page is a mod_pingo module. - * This is not called by AJAX so it is safe to rely on the $PAGE. - * - * @param settings_navigation $settingsnav - * @param navigation_node $pingonode - */ -function pingo_extend_settings_navigation($settingsnav, $pingonode = null) { -} diff --git a/login_form.php b/login_form.php index 490be84..c7a86d6 100644 --- a/login_form.php +++ b/login_form.php @@ -82,6 +82,6 @@ public function definition() { * @return array Array with errors */ public function validation($data, $files) { - return array(); + return []; } } diff --git a/mod_form.php b/mod_form.php index f464e29..e3e43c1 100644 --- a/mod_form.php +++ b/mod_form.php @@ -47,7 +47,7 @@ public function definition() { $mform->addElement('header', 'general', get_string('general', 'form')); // Adding the standard "name" field. - $mform->addElement('text', 'name', get_string('modulename', 'mod_pingo'), array('size' => '64')); + $mform->addElement('text', 'name', get_string('modulename', 'mod_pingo'), ['size' => '64']); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); diff --git a/pix/icon.svg b/pix/icon.svg index d21a0f9..559a79b 100644 --- a/pix/icon.svg +++ b/pix/icon.svg @@ -1,20 +1,28 @@ - + - + Canvas 1 Layer 1 - Page-1 + Canvas_1 - logo + Canvas_1_Layer_1 - Ebene_1_1_ - - P - + Group_2 + + Group_3 + + Group_4 + + Graphic_5 + + + + + diff --git a/pix/monologo.svg b/pix/monologo.svg index 46cdbda..ad800fe 100644 --- a/pix/monologo.svg +++ b/pix/monologo.svg @@ -1,8 +1,8 @@ - + - + Canvas 1 Layer 1 @@ -17,9 +17,18 @@ Group_4 - Graphic_5 - - + Group_5 + + Group_6 + + Group_7 + + Graphic_8 + + + + + diff --git a/questionfromcatalogue_form.php b/questionfromcatalogue_form.php index e2676ff..6320152 100644 --- a/questionfromcatalogue_form.php +++ b/questionfromcatalogue_form.php @@ -71,7 +71,7 @@ public function definition() { get_string('filterbytags', 'mod_pingo'), $this->_customdata['tags']); $mform->setType('tag', PARAM_TEXT); - $radioarray = array(); + $radioarray = []; foreach ($this->_customdata['questions'] as $i => $question) { $radioarray[] = $mform->createElement('radio', 'question', '', @@ -79,7 +79,7 @@ public function definition() { format_text($question['id'], 2)); } - $mform->addGroup($radioarray, 'question', get_string('yourquestions', 'mod_pingo'), array('
'), false); + $mform->addGroup($radioarray, 'question', get_string('yourquestions', 'mod_pingo'), ['
'], false); $mform->setType('question', PARAM_TEXT); $select = $mform->addElement('select', 'duration_choices', diff --git a/quickstart_form.php b/quickstart_form.php index 566ea6d..85e3c66 100644 --- a/quickstart_form.php +++ b/quickstart_form.php @@ -93,6 +93,6 @@ public function definition() { * @return array Array with errors */ public function validation($data, $files) { - return array(); + return []; } } diff --git a/stopsurvey_form.php b/stopsurvey_form.php index ed23d3d..9b9d480 100644 --- a/stopsurvey_form.php +++ b/stopsurvey_form.php @@ -76,6 +76,6 @@ public function definition() { * @return array Array with errors */ public function validation($data, $files) { - return array(); + return []; } } diff --git a/version.php b/version.php index c386a1f..174c18c 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'mod_pingo'; -$plugin->release = '1.0.2'; -$plugin->version = 2023063000; +$plugin->release = '1.0.3'; +$plugin->version = 2023102300; $plugin->requires = 2020061507; $plugin->maturity = MATURITY_STABLE; diff --git a/view.php b/view.php index dd30243..0978a02 100644 --- a/view.php +++ b/view.php @@ -68,22 +68,22 @@ $context = context_module::instance($cm->id); // Check if connection is active. -$activeconnection = $DB->get_record('pingo_connections', array('pingo' => $moduleinstance->id)); +$activeconnection = $DB->get_record('pingo_connections', ['pingo' => $moduleinstance->id]); -if ($closeconnection && $DB->record_exists('pingo_connections', array('pingo' => $moduleinstance->id))) { +if ($closeconnection && $DB->record_exists('pingo_connections', ['pingo' => $moduleinstance->id])) { require_sesskey(); // Trigger PINGO connection closed event. - $event = \mod_pingo\event\connection_closed::create(array( + $event = \mod_pingo\event\connection_closed::create([ 'objectid' => (int) $activeconnection->id, - 'context' => $context - )); + 'context' => $context, + ]); $event->trigger(); - $DB->delete_records('pingo_connections', array('pingo' => $moduleinstance->id)); + $DB->delete_records('pingo_connections', ['pingo' => $moduleinstance->id]); - $urlparams = array('id' => $id); + $urlparams = ['id' => $id]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl, get_string('eventconnectionclosed', 'mod_pingo'), null, notification::NOTIFY_SUCCESS); @@ -93,10 +93,10 @@ $remoteurl = get_config('pingo', 'remoteserver'); // Trigger course_module_viewed event. -$event = \mod_pingo\event\course_module_viewed::create(array( +$event = \mod_pingo\event\course_module_viewed::create([ 'objectid' => $moduleinstance->id, - 'context' => $context -)); + 'context' => $context, +]); $event->add_record_snapshot('course_modules', $cm); $event->add_record_snapshot('course', $course); @@ -104,34 +104,34 @@ $event->trigger(); // Get the name for this activity. -$modulename = format_string($moduleinstance->name, true, array( - 'context' => $context -)); +$modulename = format_string($moduleinstance->name, true, [ + 'context' => $context, +]); // Set $PAGE and completion. -$PAGE->navbar->add(get_string("overview", "pingo"), new moodle_url('/mod/pingo/view.php', array('id' => $cm->id))); +$PAGE->navbar->add(get_string("overview", "pingo"), new moodle_url('/mod/pingo/view.php', ['id' => $cm->id])); if (!$activeconnection) { $PAGE->navbar->add(get_string("login", "pingo")); - $PAGE->set_url('/mod/pingo/view.php', array('id' => $cm->id)); + $PAGE->set_url('/mod/pingo/view.php', ['id' => $cm->id]); } else if (!$session && $mode == 1) { $PAGE->navbar->add(get_string("sessions", "pingo")); - $PAGE->set_url('/mod/pingo/view.php', array('id' => $cm->id, 'mode' => $mode)); + $PAGE->set_url('/mod/pingo/view.php', ['id' => $cm->id, 'mode' => $mode]); } else if ($mode == 2) { $PAGE->navbar->add(get_string("quickstart", "pingo") . ' (' . $session . ')'); - $PAGE->set_url('/mod/pingo/view.php', array('id' => $cm->id, 'session' => $session, 'mode' => $mode)); + $PAGE->set_url('/mod/pingo/view.php', ['id' => $cm->id, 'session' => $session, 'mode' => $mode]); } else if ($mode == 3) { $PAGE->navbar->add(get_string("catalogue", "pingo") . ' (' . $session . ')'); - $PAGE->set_url('/mod/pingo/view.php', array('id' => $cm->id, 'session' => $session, 'mode' => $mode)); + $PAGE->set_url('/mod/pingo/view.php', ['id' => $cm->id, 'session' => $session, 'mode' => $mode]); } else if ($mode == 4) { $PAGE->navbar->add(get_string("session", "pingo") . ' (' . $session . ')'); - $PAGE->set_url('/mod/pingo/view.php', array('id' => $cm->id, 'session' => $session, 'mode' => $mode)); + $PAGE->set_url('/mod/pingo/view.php', ['id' => $cm->id, 'session' => $session, 'mode' => $mode]); } else { - $PAGE->set_url('/mod/pingo/view.php', array('id' => $cm->id, 'session' => $session, 'mode' => $mode)); + $PAGE->set_url('/mod/pingo/view.php', ['id' => $cm->id, 'session' => $session, 'mode' => $mode]); } -$PAGE->requires->js_call_amd('mod_pingo/view', 'init', array()); +$PAGE->requires->js_call_amd('mod_pingo/view', 'init', []); $completion = new completion_info($course); $completion->set_module_viewed($cm); @@ -166,36 +166,36 @@ $newconnectionid = $DB->insert_record('pingo_connections', $connection); // Trigger PINGO connection login successful event. - $event = \mod_pingo\event\pingo_login_successful::create(array( + $event = \mod_pingo\event\pingo_login_successful::create([ 'objectid' => $newconnectionid, - 'context' => $context - )); + 'context' => $context, + ]); $event->trigger(); // Trigger PINGO connection created event. - $event = \mod_pingo\event\connection_created::create(array( + $event = \mod_pingo\event\connection_created::create([ 'objectid' => $newconnectionid, - 'context' => $context - )); + 'context' => $context, + ]); $event->trigger(); - $urlparams = array('id' => $id); + $urlparams = ['id' => $id]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl, get_string('loginsuccessful', 'mod_pingo'), null, notification::NOTIFY_SUCCESS); } else { // Trigger PINGO connection login failed event. - $event = \mod_pingo\event\pingo_login_failed::create(array( + $event = \mod_pingo\event\pingo_login_failed::create([ 'objectid' => (int) $USER->id, - 'context' => $context - )); + 'context' => $context, + ]); $event->trigger(); - $urlparams = array('id' => $id); + $urlparams = ['id' => $id]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl, get_string('loginfailed', 'mod_pingo'), null, notification::NOTIFY_ERROR); @@ -203,7 +203,7 @@ } } else { // No login because of invalid credentials. - $urlparams = array('id' => $id); + $urlparams = ['id' => $id]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl, get_string('loginfailedinvalidcredentials', 'mod_pingo'), null, notification::NOTIFY_ERROR); @@ -218,8 +218,8 @@ if ($data) { $mform = new mod_pingo_quickstart_form(null, - array('question_types' => $data->questiontypes, 'duration_choices' => $durationchoices, - 'answer_options' => $data->answeroptions, 'sessiontoken' => '', 'sessionname' => '')); + ['question_types' => $data->questiontypes, 'duration_choices' => $durationchoices, + 'answer_options' => $data->answeroptions, 'sessiontoken' => '', 'sessionname' => '', ]); if ($fromform = $mform->get_data()) { @@ -242,37 +242,37 @@ if ($surveycreated) { // Set session active. if ($fromform->setsessionactive) { - $connection = $DB->get_record('pingo_connections', array('pingo' => $moduleinstance->id)); + $connection = $DB->get_record('pingo_connections', ['pingo' => $moduleinstance->id]); $connection->activesession = $fromform->session; $DB->update_record('pingo_connections', $connection); } // Trigger PINGO survey created event. - $event = \mod_pingo\event\pingo_survey_created::create(array( + $event = \mod_pingo\event\pingo_survey_created::create([ 'objectid' => (int) $fromform->session, - 'context' => $context - )); + 'context' => $context, + ]); $event->trigger(); - $urlparams = array('id' => $id, 'session' => $session, 'mode' => 4); + $urlparams = ['id' => $id, 'session' => $session, 'mode' => 4]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl, get_string('surveycreated', 'mod_pingo'), null, notification::NOTIFY_SUCCESS); } else { - $urlparams = array('id' => $id, 'session' => $session, 'mode' => 2); + $urlparams = ['id' => $id, 'session' => $session, 'mode' => 2]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl, get_string('errsurveynotcreated', 'mod_pingo'), null, notification::NOTIFY_ERROR); } } else { - $urlparams = array('id' => $id, 'session' => $session, 'mode' => 2); + $urlparams = ['id' => $id, 'session' => $session, 'mode' => 2]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl, get_string('errsurveynotcreated', 'mod_pingo'), null, notification::NOTIFY_ERROR); } } else { - $urlparams = array('id' => $id, 'session' => $session, 'mode' => 2); + $urlparams = ['id' => $id, 'session' => $session, 'mode' => 2]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl, get_string('errsurveynotcreated', 'mod_pingo'), null, notification::NOTIFY_ERROR); @@ -288,8 +288,8 @@ if ($data) { $mform = new mod_pingo_questionfromcatalogue_form(null, - array('questions' => $data->questions, 'duration_choices' => $durationchoices, 'sessiontoken' => '', - 'sessionname' => '', 'remoteurl' => $remoteurl, 'tags' => $data->tags)); + ['questions' => $data->questions, 'duration_choices' => $durationchoices, 'sessiontoken' => '', + 'sessionname' => '', 'remoteurl' => $remoteurl, 'tags' => $data->tags, ]); if ($fromform = $mform->get_data()) { // In this case you process validated data. $mform->get_data() returns data posted in form. @@ -304,7 +304,7 @@ $tag = ''; } - $urlparams = array('id' => $id, 'session' => $session, 'mode' => 3, 'tag' => $tag); + $urlparams = ['id' => $id, 'session' => $session, 'mode' => 3, 'tag' => $tag]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl); @@ -321,36 +321,36 @@ if ($surveycreated) { // Set session active. if ($fromform->setsessionactive) { - $connection = $DB->get_record('pingo_connections', array('pingo' => $moduleinstance->id)); + $connection = $DB->get_record('pingo_connections', ['pingo' => $moduleinstance->id]); $connection->activesession = $fromform->session; $DB->update_record('pingo_connections', $connection); } // Trigger PINGO survey created event. - $event = \mod_pingo\event\pingo_survey_created::create(array( + $event = \mod_pingo\event\pingo_survey_created::create([ 'objectid' => (int) $fromform->session, - 'context' => $context - )); + 'context' => $context, + ]); $event->trigger(); - $urlparams = array('id' => $id, 'session' => $session, 'mode' => 4); + $urlparams = ['id' => $id, 'session' => $session, 'mode' => 4]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl, get_string('surveycreated', 'mod_pingo'), null, notification::NOTIFY_SUCCESS); } else { - $urlparams = array('id' => $id, 'session' => $session, 'mode' => 3); + $urlparams = ['id' => $id, 'session' => $session, 'mode' => 3]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl, get_string('errsurveynotcreated', 'mod_pingo'), null, notification::NOTIFY_ERROR); } } else { - $urlparams = array('id' => $id, 'session' => $session, 'mode' => 3); + $urlparams = ['id' => $id, 'session' => $session, 'mode' => 3]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl, get_string('errsurveynotcreated', 'mod_pingo'), null, notification::NOTIFY_ERROR); } } else { - $urlparams = array('id' => $id, 'session' => $session, 'mode' => 3); + $urlparams = ['id' => $id, 'session' => $session, 'mode' => 3]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl, get_string('errsurveynotcreated', 'mod_pingo'), null, notification::NOTIFY_ERROR); @@ -370,15 +370,15 @@ if ($sessiondata) { $mform = new mod_pingo_stopsurvey_form(null, - array('remoteurl' => $remoteurl, 'authtoken' => $activeconnection->authenticationtoken, - 'duration_choices' => $durationchoices, 'session' => $session)); + ['remoteurl' => $remoteurl, 'authtoken' => $activeconnection->authenticationtoken, + 'duration_choices' => $durationchoices, 'session' => $session, ]); if ($fromform = $mform->get_data()) { // In this case you process validated data. $mform->get_data() returns data posted in form. // Reload page if session has ended. if ($fromform->surveyended == 1) { - $urlparams = array('id' => $id, 'session' => $session, 'mode' => 4); + $urlparams = ['id' => $id, 'session' => $session, 'mode' => 4]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl); @@ -391,24 +391,24 @@ $fromform->session, $fromform->surveyid, $fromform->stoptime); if ($surveystopped) { - $urlparams = array('id' => $id, 'session' => $session, 'mode' => 4); + $urlparams = ['id' => $id, 'session' => $session, 'mode' => 4]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl, get_string('surveystopped', 'mod_pingo'), null, notification::NOTIFY_SUCCESS); } else { - $urlparams = array('id' => $id, 'session' => $session, 'mode' => 4); + $urlparams = ['id' => $id, 'session' => $session, 'mode' => 4]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl, get_string('errsurveynotstopped', 'mod_pingo'), null, notification::NOTIFY_ERROR); } } else { - $urlparams = array('id' => $id, 'session' => $session, 'mode' => 4); + $urlparams = ['id' => $id, 'session' => $session, 'mode' => 4]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl, get_string('errsurveynotstopped', 'mod_pingo'), null, notification::NOTIFY_ERROR); } } else { - $urlparams = array('id' => $id, 'session' => $session, 'mode' => 4); + $urlparams = ['id' => $id, 'session' => $session, 'mode' => 4]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl, get_string('errsurveynotstopped', 'mod_pingo'), null, notification::NOTIFY_ERROR); @@ -416,12 +416,12 @@ } } } else if ($activatesession >= 0) { - $connection = $DB->get_record('pingo_connections', array('pingo' => $moduleinstance->id)); + $connection = $DB->get_record('pingo_connections', ['pingo' => $moduleinstance->id]); $connection->activesession = $activatesession; $DB->update_record('pingo_connections', $connection); - $urlparams = array('id' => $id, 'mode' => 1); + $urlparams = ['id' => $id, 'mode' => 1]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); redirect($redirecturl, get_string('sessionactivated', 'mod_pingo'), null, notification::NOTIFY_SUCCESS); @@ -511,19 +511,19 @@ if ($data && $sessiondata) { // Add form. - $mform = new mod_pingo_quickstart_form(new moodle_url('/mod/pingo/view.php', array('id' => $cm->id)), - array('question_types' => $data->questiontypes, 'duration_choices' => $durationchoices, + $mform = new mod_pingo_quickstart_form(new moodle_url('/mod/pingo/view.php', ['id' => $cm->id]), + ['question_types' => $data->questiontypes, 'duration_choices' => $durationchoices, 'answer_options' => $data->answeroptions, 'sessiontoken' => format_text($sessiondata['token'], 2), - 'sessionname' => format_text($sessiondata['name'], 2))); + 'sessionname' => format_text($sessiondata['name'], 2), ]); // Set default data. - $mform->set_data(array('id' => $cm->id, 'session' => $sessiondata['token'])); + $mform->set_data(['id' => $cm->id, 'session' => $sessiondata['token']]); // Render form. echo $mform->render(); } else { - $urlparams = array('id' => $id, 'session' => $session, 'mode' => 2); + $urlparams = ['id' => $id, 'session' => $session, 'mode' => 2]; $redirecturl = new moodle_url('/mod/pingo/view.php', $urlparams); echo '