diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2df604a..d48dd6a 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'] - moodle-branch: ['MOODLE_311_STABLE'] + 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'] database: [pgsql, mariadb] steps: diff --git a/CHANGES.md b/CHANGES.md index 691be15..3dd9183 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,12 @@ ## Changelog ## +- [1.2.3]: + - Ensured compatibility with Moodle 4.2. + - [Layout]: Minor layout fixes because of the new versions of the bootstrap and fontawesome libraries. + - [Icon]: Added monologo version of the activity icon for current Moodle versions. + - [Bugfix]: Fix for an error when a discourse group is deleted externally. + - [Bugfix]: Hide heading and intro in Moodle 4.0 to avoid redundant information. + - [Chore]: Some code reformating to fix moodle code check errors. + - [1.2.2]: - Hotfix to make recent changes for icon and layout compatible with Moodle pre 4.0. diff --git a/amd/build/groupview.min.js b/amd/build/groupview.min.js index da46f2c..3472c5a 100644 --- a/amd/build/groupview.min.js +++ b/amd/build/groupview.min.js @@ -1,2 +1,10 @@ -define ("mod_discourse/groupview",["jquery"],function(a){return{init:function init(){a("#id_cancel").click(function(b){b.preventDefault();a(".collapseSubmissionForm").each(function(){if(a(this).hasClass("show")){a(this).removeClass("show")}else{a(this).addClass("show")}})})}}}); -//# sourceMappingURL=groupview.min.js.map +/** + * Module for the group view a discourse. + * + * @module mod_discourse/group_view + * @copyright 2022 coactum GmbH + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define("mod_discourse/groupview",["jquery"],(function($){return{init:function(){$("#id_cancel").click((function(e){e.preventDefault(),$(".collapseSubmissionForm").each((function(){$(this).hasClass("show")?$(this).removeClass("show"):$(this).addClass("show")}))}))}}})); + +//# sourceMappingURL=groupview.min.js.map \ No newline at end of file diff --git a/amd/build/groupview.min.js.map b/amd/build/groupview.min.js.map index 6bb8b6e..6067412 100644 --- a/amd/build/groupview.min.js.map +++ b/amd/build/groupview.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/groupview.js"],"names":["define","$","init","click","e","preventDefault","each","hasClass","removeClass","addClass"],"mappings":"AAuBCA,OAAM,2BAAC,CAAC,QAAD,CAAD,CAAa,SAASC,CAAT,CAAY,CAC5B,MAAO,CACHC,IAAI,CAAE,eAAW,CACfD,CAAC,CAAC,YAAD,CAAD,CAAgBE,KAAhB,CAAsB,SAASC,CAAT,CAAY,CAChCA,CAAC,CAACC,cAAF,GACAJ,CAAC,CAAC,yBAAD,CAAD,CAA6BK,IAA7B,CAAkC,UAAW,CACzC,GAAIL,CAAC,CAAC,IAAD,CAAD,CAAQM,QAAR,CAAiB,MAAjB,CAAJ,CAA8B,CAC1BN,CAAC,CAAC,IAAD,CAAD,CAAQO,WAAR,CAAoB,MAApB,CACH,CAFD,IAEO,CACHP,CAAC,CAAC,IAAD,CAAD,CAAQQ,QAAR,CAAiB,MAAjB,CACH,CACJ,CAND,CAOD,CATD,CAUD,CAZE,CAcV,CAfM,CAAN","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 * Module for the group view a discourse.\n *\n * @module mod_discourse/group_view\n * @copyright 2022 coactum GmbH\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n define(['jquery'], function($) {\n return {\n init: function() {\n $('#id_cancel').click(function(e) {\n e.preventDefault();\n $('.collapseSubmissionForm').each(function() {\n if ($(this).hasClass('show')) {\n $(this).removeClass('show');\n } else {\n $(this).addClass('show');\n }\n });\n });\n }\n };\n});"],"file":"groupview.min.js"} \ No newline at end of file +{"version":3,"file":"groupview.min.js","sources":["../src/groupview.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 * Module for the group view a discourse.\n *\n * @module mod_discourse/group_view\n * @copyright 2022 coactum GmbH\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n define(['jquery'], function($) {\n return {\n init: function() {\n $('#id_cancel').click(function(e) {\n e.preventDefault();\n $('.collapseSubmissionForm').each(function() {\n if ($(this).hasClass('show')) {\n $(this).removeClass('show');\n } else {\n $(this).addClass('show');\n }\n });\n });\n }\n };\n});"],"names":["define","$","init","click","e","preventDefault","each","this","hasClass","removeClass","addClass"],"mappings":";;;;;;;AAuBCA,iCAAO,CAAC,WAAW,SAASC,SAClB,CACHC,KAAM,WACJD,EAAE,cAAcE,OAAM,SAASC,GAC7BA,EAAEC,iBACFJ,EAAE,2BAA2BK,MAAK,WAC1BL,EAAEM,MAAMC,SAAS,QACjBP,EAAEM,MAAME,YAAY,QAEpBR,EAAEM,MAAMG,SAAS"} \ No newline at end of file diff --git a/backup/moodle2/restore_discourse_stepslib.php b/backup/moodle2/restore_discourse_stepslib.php index b412b70..a39a50f 100644 --- a/backup/moodle2/restore_discourse_stepslib.php +++ b/backup/moodle2/restore_discourse_stepslib.php @@ -127,7 +127,8 @@ protected function process_discourse($data) { $groups = groups_get_all_groups($data->course, 0, $data->groupingid); // Change discourse id in the new groups to the new discourse id. foreach ($groups as $group) { - $group->idnumber = preg_replace('/discourse_[0-9]+_/', 'discourse_' . $this->newdiscourseid . '_', $group->idnumber); + $group->idnumber = preg_replace('/discourse_[0-9]+_/', + 'discourse_' . $this->newdiscourseid . '_', $group->idnumber); $group->enablemessaging = 1; groups_update_group($group); } diff --git a/classes/event/course_module_instance_list_viewed.php b/classes/event/course_module_instance_list_viewed.php index f30b2d3..564484e 100644 --- a/classes/event/course_module_instance_list_viewed.php +++ b/classes/event/course_module_instance_list_viewed.php @@ -28,7 +28,6 @@ * The mod_discourse instance list viewed event class. * * @package mod_discourse - * @since Moodle 3.9 * @copyright 2022 coactum GmbH * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/classes/event/course_module_viewed.php b/classes/event/course_module_viewed.php index 71cff3b..244401b 100644 --- a/classes/event/course_module_viewed.php +++ b/classes/event/course_module_viewed.php @@ -28,7 +28,6 @@ * The mod_discourse course module viewed event class. * * @package mod_discourse - * @since Moodle 3.9 * @copyright 2022 coactum GmbH * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -44,7 +43,7 @@ protected function init() { } /** - * Get objectid mapping + * Get objectid mapping for restore. */ public static function get_objectid_mapping() { return array('db' => 'discourse', 'restore' => 'discourse'); diff --git a/classes/output/discourse_groupview.php b/classes/output/discourse_groupview.php index 34c1540..1afc0ff 100644 --- a/classes/output/discourse_groupview.php +++ b/classes/output/discourse_groupview.php @@ -85,13 +85,15 @@ public function export_for_template(renderer_base $output) { $data->group = $this->group; if ($data->group->submission) { - $data->group->submission->submission = format_text($data->group->submission->submission, $data->group->submission->format, array('para' => false)); + $data->group->submission->submission = format_text($data->group->submission->submission, + $data->group->submission->format, array('para' => false)); } if ($data->group->formersubmissions) { foreach ($data->group->formersubmissions as $key => $submission) { if ($submission->submission) { - $data->group->formersubmissions[$key]->submission = format_text($submission->submission, $submission->format, array('para' => false)); + $data->group->formersubmissions[$key]->submission = format_text($submission->submission, + $submission->format, array('para' => false)); } } } diff --git a/classes/output/discourse_view.php b/classes/output/discourse_view.php index 89fcc02..53ec3c5 100644 --- a/classes/output/discourse_view.php +++ b/classes/output/discourse_view.php @@ -122,9 +122,10 @@ class discourse_view implements renderable, templatable { * @param bool $phasehints If any phase hints are set. */ public function __construct($cmid, $groups, $autoswitch, $activephaseone, $activephasetwo, $activephasethree, $activephasefour, - $hintphaseone, $hintphasetwo, $hintphasethree, $hintphasefour, $hintphaseoneshortened, $hintphasetwoshortened, $hintphasethreeshortened, - $hintphasefourshortened, $deadlinephaseone, $deadlinephasetwo, $deadlinephasethree, $deadlinephasefour, $caneditphase, $canswitchphase, - $canviewallgroups, $canviewgroupparticipants, $shouldswitchphase, $userid, $sesskey, $phasehints) { + $hintphaseone, $hintphasetwo, $hintphasethree, $hintphasefour, $hintphaseoneshortened, $hintphasetwoshortened, + $hintphasethreeshortened, $hintphasefourshortened, $deadlinephaseone, $deadlinephasetwo, $deadlinephasethree, + $deadlinephasefour, $caneditphase, $canswitchphase, $canviewallgroups, $canviewgroupparticipants, $shouldswitchphase, + $userid, $sesskey, $phasehints) { $this->cmid = $cmid; $this->groups = $groups; diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 59ca857..9149451 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -95,9 +95,9 @@ public static function get_contexts_for_userid(int $userid) : contextlist { $contextlist = new contextlist(); $params = [ - 'modulename' => 'discourse', - 'contextlevel' => CONTEXT_MODULE, - 'userid' => $userid, + 'modulename' => 'discourse', + 'contextlevel' => CONTEXT_MODULE, + 'userid' => $userid, ]; // Select discourses of user. @@ -130,8 +130,8 @@ public static function get_users_in_context(userlist $userlist) { } $params = [ - 'instanceid' => $context->id, - 'modulename' => 'discourse', + 'instanceid' => $context->id, + 'modulename' => 'discourse', ]; // Get users. @@ -200,8 +200,8 @@ public static function export_user_data(approved_contextlist $contextlist) { } $discoursedata = [ - 'id' => $discourse->discourse, - 'timecreated' => \core_privacy\local\request\transform::datetime($discourse->timecreated), + 'id' => $discourse->discourse, + 'timecreated' => \core_privacy\local\request\transform::datetime($discourse->timecreated), 'timemodified' => $discourse->timemodified, ]; @@ -273,7 +273,9 @@ public static function export_user_data(approved_contextlist $contextlist) { * @param array $subcontext The location within the current context that this data belongs. * @param \stdClass $user the user record */ - protected static function export_discourse_data_for_user(array $discoursedata, \context_module $context, array $subcontext, \stdClass $user) { + protected static function export_discourse_data_for_user(array $discoursedata, \context_module $context, + array $subcontext, \stdClass $user) { + // Fetch the generic module data for the discourse activity. $contextdata = helper::get_context_data($context, $user); // Merge with discourse data and write it. diff --git a/db/events.php b/db/events.php index 3d31f2c..395624b 100644 --- a/db/events.php +++ b/db/events.php @@ -29,6 +29,6 @@ $observers = array( array( 'eventname' => '\core\event\course_module_created', - 'callback' => 'mod_discourse_observer::course_module_created', + 'callback' => 'mod_discourse_observer::course_module_created', ) ); diff --git a/db/uninstall.php b/db/uninstall.php index 6bb9a62..74e60bc 100644 --- a/db/uninstall.php +++ b/db/uninstall.php @@ -49,7 +49,8 @@ function xmldb_discourse_uninstall() { $select .= "AND idnumber LIKE '%phase%'"; $select .= "AND idnumber LIKE '%group%'"; - // Deleting groups created by discourse activity with idnumber discourse_X_phase_x_group_X to prevent problems with already existing idsnumbers after reinstallation of plugin. + // Deleting groups created by discourse activity with idnumber discourse_X_phase_x_group_X + // to prevent problems with already existing idsnumbers after reinstallation of plugin. $discoursegroups = $DB->get_recordset_select('groups', $select); if ($discoursegroups->valid()) { diff --git a/groupview.php b/groupview.php index be112cf..b72e031 100644 --- a/groupview.php +++ b/groupview.php @@ -34,13 +34,13 @@ $id = optional_param('id', null, PARAM_INT); // Module instance ID as alternative. -$d = optional_param('d', null, PARAM_INT); +$d = optional_param('d', null, PARAM_INT); // ID of the group to be viewed. -$groupid = required_param('group', PARAM_INT); +$groupid = required_param('group', PARAM_INT); // ID of the user viewing (for unique draft savings). -$userid = required_param('userid', PARAM_INT); +$userid = required_param('userid', PARAM_INT); $discourse = discourse::get_discourse_instance($id, $d); @@ -63,14 +63,16 @@ $group = $discourse->get_group($groupid); if (!$group) { - redirect(new moodle_url('/mod/discourse/view.php', array('id' => $id)), get_string('groupinvalid', 'mod_discourse'), null, notification::NOTIFY_ERROR); + redirect(new moodle_url('/mod/discourse/view.php', array('id' => $id)), get_string('groupinvalid', 'mod_discourse'), + null, notification::NOTIFY_ERROR); } else if ($userid != $USER->id) { - redirect(new moodle_url('/mod/discourse/view.php', array('id' => $id)), get_string('useridinvalid', 'mod_discourse'), null, notification::NOTIFY_ERROR); + redirect(new moodle_url('/mod/discourse/view.php', array('id' => $id)), get_string('useridinvalid', 'mod_discourse'), + null, notification::NOTIFY_ERROR); } echo $OUTPUT->header(); -if ($CFG->branch < 41) { +if ($CFG->branch < 400) { echo $OUTPUT->heading(get_string('modulename', 'mod_discourse').': ' . format_string($moduleinstance->name), 3); } @@ -84,8 +86,10 @@ if (isset($fromform->submissionid)) { if ($fromform->submissionid !== 0) { // Update existing submission. - $submission = $DB->get_record('discourse_submissions', array('discourse' => $moduleinstance->id, 'groupid' => $fromform->group, 'id' => $fromform->submissionid)); - $submission->submission = format_text($fromform->submission['text'], $fromform->submission['format'], array('para' => false)); + $submission = $DB->get_record('discourse_submissions', + array('discourse' => $moduleinstance->id, 'groupid' => $fromform->group, 'id' => $fromform->submissionid)); + $submission->submission = format_text($fromform->submission['text'], $fromform->submission['format'], + array('para' => false)); $submission->currentversion += 1; $submission->format = (int) $fromform->submission['format']; $submission->timemodified = time(); @@ -97,7 +101,8 @@ $submission = new stdClass(); $submission->discourse = (int) $moduleinstance->id; $submission->groupid = $fromform->group; - $submission->submission = format_text($fromform->submission['text'], $fromform->submission['format'], array('para' => false)); + $submission->submission = format_text($fromform->submission['text'], $fromform->submission['format'], + array('para' => false)); $submission->currentversion = 1; $submission->format = (int) $fromform->submission['format']; $submission->timecreated = time(); @@ -105,15 +110,18 @@ $DB->insert_record('discourse_submissions', $submission); } else { - redirect(new moodle_url('/mod/discourse/groupview.php', array('id' => $id, 'group' => $fromform->group, 'userid' => $userid)), + redirect(new moodle_url('/mod/discourse/groupview.php', + array('id' => $id, 'group' => $fromform->group, 'userid' => $userid)), get_string('submissionfaileddoubled', 'mod_discourse'), null, notification::NOTIFY_ERROR ); } } - redirect(new moodle_url('/mod/discourse/groupview.php', array('id' => $id, 'group' => $fromform->group, 'userid' => $userid))); + redirect(new moodle_url('/mod/discourse/groupview.php', + array('id' => $id, 'group' => $fromform->group, 'userid' => $userid))); } } else { - redirect(new moodle_url('/mod/discourse/groupview.php', array('id' => $id, 'group' => $fromform->group, 'userid' => $userid)), + redirect(new moodle_url('/mod/discourse/groupview.php', + array('id' => $id, 'group' => $fromform->group, 'userid' => $userid)), get_string('nogroupmember', 'mod_discourse'), null, notification::NOTIFY_ERROR); } @@ -141,7 +149,8 @@ // Set default data. if (isset($group->submission) && $group->submission) { // Default data if group has made submission. $mform->set_data(array('id' => $id, 'group' => $groupid, 'submissionid' => $group->submission->id, - 'submission' => ['text' => $group->submission->submission, 'format' => $group->submission->format], 'userid' => $userid)); + 'submission' => ['text' => $group->submission->submission, 'format' => $group->submission->format], + 'userid' => $userid)); } else if (isset($formersubmission)) { // Default data if group has merged submissions from former groups of the participants. $mform->set_data(array('id' => $id, 'group' => $groupid, 'submissionid' => 0, 'submission' => ['text' => $formersubmission->text, 'format' => $formersubmission->format], 'userid' => $userid)); @@ -188,7 +197,8 @@ $phaseactive = false; } - $page = new discourse_groupview($cm->id, $phasehint, $phaseactive, $group, $form, $caneditsubmission, $canviewgroupparticipants); + $page = new discourse_groupview($cm->id, $phasehint, $phaseactive, $group, $form, $caneditsubmission, + $canviewgroupparticipants); // Render page and display the form. echo $OUTPUT->render($page); diff --git a/index.php b/index.php index 48bbeee..3baaf6f 100644 --- a/index.php +++ b/index.php @@ -59,13 +59,13 @@ $table->attributes['class'] = 'generaltable mod_index'; if ($course->format == 'weeks') { - $table->head = array(get_string('week'), get_string('name')); + $table->head = array(get_string('week'), get_string('name')); $table->align = array('center', 'left'); } else if ($course->format == 'topics') { - $table->head = array(get_string('topic'), get_string('name')); + $table->head = array(get_string('topic'), get_string('name')); $table->align = array('center', 'left', 'left', 'left'); } else { - $table->head = array(get_string('name')); + $table->head = array(get_string('name')); $table->align = array('left', 'left', 'left'); } diff --git a/lib.php b/lib.php index daae62a..0489bde 100644 --- a/lib.php +++ b/lib.php @@ -275,8 +275,8 @@ function discourse_reset_userdata($data) { // 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. - $shifterror = !shift_course_mod_dates('discourse', array('deadlinephaseone', 'deadlinephasetwo', 'deadlinephasethree', 'deadlinephasefour'), - $data->timeshift, $data->courseid); + $shifterror = !shift_course_mod_dates('discourse', array('deadlinephaseone', 'deadlinephasetwo', + 'deadlinephasethree', 'deadlinephasefour'), $data->timeshift, $data->courseid); $status[] = array('component' => $componentstr, 'item' => get_string('datechanged'), 'error' => $shifterror); } diff --git a/locallib.php b/locallib.php index f9a3c51..47225c6 100644 --- a/locallib.php +++ b/locallib.php @@ -82,7 +82,8 @@ public function __construct($id, $d) { $this->modulename = get_string('modulename', 'mod_discourse'); - $this->participants = $DB->get_records('discourse_participants', array('discourse' => $this->cm->instance), '', 'userid, discourse, groupids'); + $this->participants = $DB->get_records('discourse_participants', array('discourse' => $this->cm->instance), + '', 'userid, discourse, groupids'); $grouping = groups_get_grouping($this->instance->groupingid); if ($this->instance->groupingid && $grouping && $grouping->courseid == $this->instance->course) { @@ -113,10 +114,12 @@ function compare($a, $b) { foreach ($groups as $group) { - // Fix for caching bug in Moodle 4.0 where groups_get_activity_allowed_groups returns the groups of the original cm after duplicating an activity ... - // despite the correct grouping is connected with the duplicated discourse (see https://tracker.moodle.org/browse/MDL-75530). + // Fix for caching bug in Moodle 4.0 where groups_get_activity_allowed_groups returns the groups + // of the original cm after duplicating an activity despite the correct grouping is connected with + // the duplicated discourse (see https://tracker.moodle.org/browse/MDL-75530). // Workaround is clearing the moodle cache or renaming an course activity. - $control = $DB->get_record('groupings_groups', array('groupingid' => $this->instance->groupingid, 'groupid' => $group->id)); + $control = $DB->get_record('groupings_groups', + array('groupingid' => $this->instance->groupingid, 'groupid' => $group->id)); if (!$control) { $groups = array(); @@ -154,7 +157,8 @@ function compare($a, $b) { if ($this->instance->name && strpos($group->name, $this->instance->name)) { // If instance name is in group name. $group->shortenedname = explode($this->instance->name, $group->name)[1]; - $group->shortenednametwo = explode($this->instance->name, $group->name)[0] . '-' . explode($this->instance->name, $group->name)[1]; + $group->shortenednametwo = explode($this->instance->name, $group->name)[0] . '-' . + explode($this->instance->name, $group->name)[1]; } else { // If instance name is not in group name (e.g. because group was manually renamed). $group->shortenedname = $group->name; $group->shortenednametwo = $group->name; @@ -184,9 +188,11 @@ function compare($a, $b) { array_push($group->participants, $participant); if ($group->phase != 1 && $this->participants && isset($this->participants[$participant->id]) - && !in_array(json_decode($this->participants[$participant->id]->groupids)[$group->phase - 2], $formergroupids)) { + && !in_array(json_decode($this->participants[$participant->id]->groupids)[$group->phase - 2], + $formergroupids)) { - array_push($formergroupids, json_decode($this->participants[$participant->id]->groupids)[$group->phase - 2]); + array_push($formergroupids, + json_decode($this->participants[$participant->id]->groupids)[$group->phase - 2]); } } @@ -199,18 +205,27 @@ function compare($a, $b) { $formergroupname = groups_get_group_name($formergroupid); - if (!$formersubmission = $DB->get_record('discourse_submissions', array('discourse' => $this->instance->id, 'groupid' => $formergroupid))) { + if (!$formersubmission = $DB->get_record('discourse_submissions', + array('discourse' => $this->instance->id, 'groupid' => $formergroupid))) { $formersubmission = new stdClass(); $formersubmission->submission = false; } - if (isset(explode($this->instance->name, $formergroupname)[0]) && isset(explode($this->instance->name, $formergroupname)[1])) { - $formersubmission->groupname = explode($this->instance->name, $formergroupname)[0] . '-' . explode($this->instance->name, $formergroupname)[1]; + if (isset(explode($this->instance->name, $formergroupname)[0]) + && isset(explode($this->instance->name, $formergroupname)[1])) { + $formersubmission->groupname = explode($this->instance->name, $formergroupname)[0] . '-' . + explode($this->instance->name, $formergroupname)[1]; } else { $formersubmission->groupname = $formergroupname; } - $formersubmission->participants = implode(', ', array_column(groups_get_members($formergroupid), 'firstname', 'lastname')); + if (groups_group_exists($formergroupid)) { + $formersubmission->participants = implode(', ', + array_column(groups_get_members($formergroupid), 'firstname', 'lastname')); + } else { + $formersubmission->participants = false; + } + array_push($formersubmissions, $formersubmission); } @@ -389,7 +404,8 @@ public function create_groups_and_grouping($users) { // Group for solo phase. foreach ($users as $user) { - $groupdata->name = get_string('phaseone', 'mod_discourse') . ' ' . $this->instance->name . ' ' . get_string('group', 'mod_discourse') . ' ' . $i; + $groupdata->name = get_string('phaseone', 'mod_discourse') . ' ' . $this->instance->name . ' ' . + get_string('group', 'mod_discourse') . ' ' . $i; $groupdata->description = get_string('groupfor', 'mod_discourse', get_string('phaseone', 'mod_discourse')); $groupdata->enablemessaging = 0; $groupdata->idnumber = 'discourse_' . $this->instance->id . '_phase_' . 1 . '_group_' . $i; @@ -407,7 +423,8 @@ public function create_groups_and_grouping($users) { // Groups for 1st group phase. for ($i = 1; $i <= 4; $i ++) { - $groupdata->name = get_string('phasetwo', 'mod_discourse') . ' ' . $this->instance->name . ' ' . get_string('group', 'mod_discourse') . ' ' . $i; + $groupdata->name = get_string('phasetwo', 'mod_discourse') . ' ' . $this->instance->name . ' ' . + get_string('group', 'mod_discourse') . ' ' . $i; $groupdata->description = get_string('groupfor', 'mod_discourse', get_string('phasetwo', 'mod_discourse')); $groupdata->enablemessaging = 1; $groupdata->idnumber = 'discourse_' . $this->instance->id . '_phase_' . 2 . '_group_' . $i; @@ -420,7 +437,8 @@ public function create_groups_and_grouping($users) { // Groups for 2nd group phase. for ($i = 5; $i <= 6; $i ++) { - $groupdata->name = get_string('phasethree', 'mod_discourse') . ' ' . $this->instance->name . ' ' . get_string('group', 'mod_discourse') . ' ' . ($i - 4); + $groupdata->name = get_string('phasethree', 'mod_discourse') . ' ' . $this->instance->name . ' ' . + get_string('group', 'mod_discourse') . ' ' . ($i - 4); $groupdata->description = get_string('groupfor', 'mod_discourse', get_string('phasethree', 'mod_discourse')); $groupdata->enablemessaging = 1; $groupdata->idnumber = 'discourse_' . $this->instance->id . '_phase_' . 3 . '_group_' . ($i - 4); @@ -457,7 +475,8 @@ public function create_groups_and_grouping($users) { } // Group for collaborative phase. - $groupdata->name = get_string('phasefour', 'mod_discourse') . ' ' . $this->instance->name . ' ' . get_string('group', 'mod_discourse') . ' ' . 1; + $groupdata->name = get_string('phasefour', 'mod_discourse') . ' ' . $this->instance->name . ' ' . + get_string('group', 'mod_discourse') . ' ' . 1; $groupdata->description = get_string('groupfor', 'mod_discourse', get_string('phasefour', 'mod_discourse')); $groupdata->enablemessaging = 1; $groupdata->idnumber = 'discourse_' . $this->instance->id . '_phase_' . 4 . '_group_' . 1; @@ -479,7 +498,9 @@ public function create_groups_and_grouping($users) { )); // Set group mode for module. - if ($DB->get_field('course_modules', 'groupmode', array('id' => $this->cm->id, 'course' => $this->course->id, 'instance' => $this->instance->id)) === 0) { + if ($DB->get_field('course_modules', 'groupmode', + array('id' => $this->cm->id, 'course' => $this->course->id, 'instance' => $this->instance->id)) === 0) { + $DB->set_field('course_modules', 'groupmode', 1, array( 'id' => $this->cm->id, 'course' => $this->course->id, diff --git a/mod_form.php b/mod_form.php index 75d9c6b..3b802c1 100644 --- a/mod_form.php +++ b/mod_form.php @@ -95,7 +95,8 @@ public function definition() { $mform->addElement('date_time_selector', 'deadlinephasefour', get_string('deadlinephasefour', 'mod_discourse')); $mform->setDefault('deadlinephasefour', strtotime("+28 days noon")); - $mform->addElement('advcheckbox', 'autoswitch', get_string('modeautoswitch', 'mod_discourse'), get_string('autoswitch', 'mod_discourse')); + $mform->addElement('advcheckbox', 'autoswitch', get_string('modeautoswitch', 'mod_discourse'), + get_string('autoswitch', 'mod_discourse')); if (isset($id) && $id !== 0 && !isset($discourse->get_module_instance()->autoswitch)) { $mform->setDefault('autoswitch', 0); @@ -106,16 +107,20 @@ public function definition() { // Adding section for phase hints. $mform->addElement('header', 'phaseshints', get_string('phaseshints', 'mod_discourse')); - $mform->addElement('textarea', 'hintphaseone', get_string('hintphaseone', 'mod_discourse'), 'wrap="virtual" rows="2" cols="150"'); + $mform->addElement('textarea', 'hintphaseone', get_string('hintphaseone', 'mod_discourse'), + 'wrap="virtual" rows="2" cols="150"'); $mform->setType('hintphaseone', PARAM_TEXT); - $mform->addElement('textarea', 'hintphasetwo', get_string('hintphasetwo', 'mod_discourse'), 'wrap="virtual" rows="2" cols="150"'); + $mform->addElement('textarea', 'hintphasetwo', get_string('hintphasetwo', 'mod_discourse'), + 'wrap="virtual" rows="2" cols="150"'); $mform->setType('hintphasetwo', PARAM_TEXT); - $mform->addElement('textarea', 'hintphasethree', get_string('hintphasethree', 'mod_discourse'), 'wrap="virtual" rows="2" cols="150"'); + $mform->addElement('textarea', 'hintphasethree', get_string('hintphasethree', 'mod_discourse'), + 'wrap="virtual" rows="2" cols="150"'); $mform->setType('hintphasethree', PARAM_TEXT); - $mform->addElement('textarea', 'hintphasefour', get_string('hintphasefour', 'mod_discourse'), 'wrap="virtual" rows="2" cols="150"'); + $mform->addElement('textarea', 'hintphasefour', get_string('hintphasefour', 'mod_discourse'), + 'wrap="virtual" rows="2" cols="150"'); $mform->setType('hintphasefour', PARAM_TEXT); // Add standard elements. diff --git a/pix/monologo.png b/pix/monologo.png new file mode 100644 index 0000000..cd9e92a Binary files /dev/null and b/pix/monologo.png differ diff --git a/pix/monologo.svg b/pix/monologo.svg new file mode 100644 index 0000000..4116a5d --- /dev/null +++ b/pix/monologo.svg @@ -0,0 +1,15 @@ + + + + + + Canvas 1 + + Layer 1 + + + + + + + diff --git a/templates/discourse_groupview.mustache b/templates/discourse_groupview.mustache index dc249c2..b945169 100644 --- a/templates/discourse_groupview.mustache +++ b/templates/discourse_groupview.mustache @@ -48,10 +48,12 @@
- {{#canviewgroupparticipants}}{{/canviewgroupparticipants}} - - - {{#caneditsubmission}}{{/caneditsubmission}} + + {{#canviewgroupparticipants}}{{/canviewgroupparticipants}} + + + {{#caneditsubmission}}{{/caneditsubmission}} + {{#canviewgroupparticipants}} {{#caneditsubmission}}{{/caneditsubmission}}
{{#str}}groupparticipants, mod_discourse{{/str}}{{#str}}submissionstate, mod_discourse{{/str}}{{#str}}currentversion, mod_discourse{{/str}}
{{#str}}groupparticipants, mod_discourse{{/str}}{{#str}}submissionstate, mod_discourse{{/str}}{{#str}}currentversion, mod_discourse{{/str}}
@@ -69,8 +71,8 @@ {{^submission.id}}-{{/submission.id}} - {{#submission.id}}{{/submission.id}} - {{^submission.id}}{{/submission.id}} + {{#submission.id}}{{/submission.id}} + {{^submission.id}}{{/submission.id}}
diff --git a/templates/discourse_view.mustache b/templates/discourse_view.mustache index 4f0cbfa..6cdd650 100644 --- a/templates/discourse_view.mustache +++ b/templates/discourse_view.mustache @@ -44,30 +44,32 @@
- + + + @@ -88,8 +90,8 @@ {{/submission.id}} {{^submission.id}}{{#str}}nosubmission, mod_discourse{{/str}}{{/submission.id}} - {{#submission.timecreated}}{{/submission.timecreated}} - {{^submission.timecreated}}{{/submission.timecreated}} + {{#submission.timecreated}}{{/submission.timecreated}} + {{^submission.timecreated}}{{/submission.timecreated}}
@@ -97,8 +99,8 @@ {{shortenedname}} - {{#submission.timecreated}}{{/submission.timecreated}} - {{^submission.timecreated}}{{/submission.timecreated}} + {{#submission.timecreated}}{{/submission.timecreated}} + {{^submission.timecreated}}{{/submission.timecreated}}
{{/groups.phaseone}} @@ -109,30 +111,32 @@
- {{#canviewallgroups}}{{/canviewallgroups}} - {{#str}}phaseone, mod_discourse{{/str}} - {{#activephaseone}}{{#str}}activephase, mod_discourse{{/str}} {{/activephaseone}} - {{^activephaseone}}{{#canswitchphase}}{{/canswitchphase}}{{/activephaseone}} -
+ {{#canviewallgroups}}{{/canviewallgroups}} + {{#str}}phaseone, mod_discourse{{/str}} + {{#activephaseone}}{{#str}}activephase, mod_discourse{{/str}} {{/activephaseone}} + {{^activephaseone}}{{#canswitchphase}}{{/canswitchphase}}{{/activephaseone}} +
{{#deadlinephaseone}} {{#str}}sheduledend, mod_discourse{{/str}}: - {{#userdate}}{{deadlinephaseone}}, {{#str}} strftimedaydatetime, core_langconfig {{/str}}{{/userdate}} + {{#userdate}}{{deadlinephaseone}}, {{#str}} strftimedaydatetime, core_langconfig {{/str}}{{/userdate}}

{{/deadlinephaseone}} {{#hintphaseone}} {{#hintphaseoneshortened}}{{/hintphaseoneshortened}} {{#str}}hint, mod_discourse{{/str}}: {{#hintphaseoneshortened}} -

{{hintphaseone}}

-

{{#shortentext}} 250, {{hintphaseone}} {{/shortentext}}

+

{{hintphaseone}}

+

{{#shortentext}} 250, {{hintphaseone}} {{/shortentext}}

{{/hintphaseoneshortened}} {{^hintphaseoneshortened}} -

{{hintphaseone}}

+

{{hintphaseone}}

{{/hintphaseoneshortened}} {{/hintphaseone}}
- + + + @@ -156,8 +160,8 @@ {{/submission.id}} {{^submission.id}}{{#str}}nosubmission, mod_discourse{{/str}}{{/submission.id}} - {{#submission.timecreated}}{{/submission.timecreated}} - {{^submission.timecreated}}{{/submission.timecreated}} + {{#submission.timecreated}}{{/submission.timecreated}} + {{^submission.timecreated}}{{/submission.timecreated}}
@@ -165,8 +169,8 @@ {{shortenedname}} - {{#submission.timecreated}}{{/submission.timecreated}} - {{^submission.timecreated}}{{/submission.timecreated}} + {{#submission.timecreated}}{{/submission.timecreated}} + {{^submission.timecreated}}{{/submission.timecreated}}
{{/groups.phasetwo}} @@ -178,34 +182,36 @@
- {{#canviewallgroups}}{{/canviewallgroups}} - {{#str}}phasetwo, mod_discourse{{/str}} - {{#activephasetwo}}{{#str}}activephase, mod_discourse{{/str}} {{/activephasetwo}} - {{^activephasetwo}}{{#canswitchphase}}{{/canswitchphase}}{{/activephasetwo}} -
+ {{#canviewallgroups}}{{/canviewallgroups}} + {{#str}}phasetwo, mod_discourse{{/str}} + {{#activephasetwo}}{{#str}}activephase, mod_discourse{{/str}} {{/activephasetwo}} + {{^activephasetwo}}{{#canswitchphase}}{{/canswitchphase}}{{/activephasetwo}} +
{{#deadlinephasetwo}} {{#str}}sheduledend, mod_discourse{{/str}}: - {{#userdate}}{{deadlinephasetwo}}, {{#str}} strftimedaydatetime, core_langconfig {{/str}}{{/userdate}} + {{#userdate}}{{deadlinephasetwo}}, {{#str}} strftimedaydatetime, core_langconfig {{/str}}{{/userdate}}

{{/deadlinephasetwo}} {{#hintphasetwo}} {{#hintphasetwoshortened}}{{/hintphasetwoshortened}} {{#str}}hint, mod_discourse{{/str}}: {{#hintphasetwoshortened}} -

{{hintphasetwo}}

-

{{#shortentext}} 250, {{hintphasetwo}} {{/shortentext}}

+

{{hintphasetwo}}

+

{{#shortentext}} 250, {{hintphasetwo}} {{/shortentext}}

{{/hintphasetwoshortened}} {{^hintphasetwoshortened}} -

{{hintphasetwo}}

+

{{hintphasetwo}}

{{/hintphasetwoshortened}} {{/hintphasetwo}}
- + + + - + {{#groups.phasethree}} {{/groups.phasethree}} @@ -247,30 +253,32 @@
- {{#canviewallgroups}}{{/canviewallgroups}} - {{#str}}phasethree, mod_discourse{{/str}} - {{#activephasethree}}{{#str}}activephase, mod_discourse{{/str}} {{/activephasethree}} - {{^activephasethree}}{{#canswitchphase}}{{/canswitchphase}}{{/activephasethree}} -
+ {{#canviewallgroups}}{{/canviewallgroups}} + {{#str}}phasethree, mod_discourse{{/str}} + {{#activephasethree}}{{#str}}activephase, mod_discourse{{/str}} {{/activephasethree}} + {{^activephasethree}}{{#canswitchphase}}{{/canswitchphase}}{{/activephasethree}} +
{{#deadlinephasethree}} {{#str}}sheduledend, mod_discourse{{/str}}: - {{#userdate}}{{deadlinephasethree}}, {{#str}} strftimedaydatetime, core_langconfig {{/str}}{{/userdate}} + {{#userdate}}{{deadlinephasethree}}, {{#str}} strftimedaydatetime, core_langconfig {{/str}}{{/userdate}}

{{/deadlinephasethree}} {{#hintphasethree}} {{#hintphasethreeshortened}}{{/hintphasethreeshortened}} {{#str}}hint, mod_discourse{{/str}}: {{#hintphasethreeshortened}} -

{{hintphasethree}}

-

{{#shortentext}} 250, {{hintphasethree}} {{/shortentext}}

+

{{hintphasethree}}

+

{{#shortentext}} 250, {{hintphasethree}} {{/shortentext}}

{{/hintphasethreeshortened}} {{^hintphasethreeshortened}} -

{{hintphasethree}}

+

{{hintphasethree}}

{{/hintphasethreeshortened}} {{/hintphasethree}}
@@ -225,8 +231,8 @@ {{/submission.id}} {{^submission.id}}{{#str}}nosubmission, mod_discourse{{/str}}{{/submission.id}} - {{#submission.timecreated}}{{/submission.timecreated}} - {{^submission.timecreated}}{{/submission.timecreated}} + {{#submission.timecreated}}{{/submission.timecreated}} + {{^submission.timecreated}}{{/submission.timecreated}}
@@ -234,8 +240,8 @@ {{shortenedname}} - {{#submission.timecreated}}{{/submission.timecreated}} - {{^submission.timecreated}}{{/submission.timecreated}} + {{#submission.timecreated}}{{/submission.timecreated}} + {{^submission.timecreated}}{{/submission.timecreated}}
- + + + @@ -293,8 +301,8 @@ {{/submission.id}} {{^submission.id}}{{#str}}nosubmission, mod_discourse{{/str}}{{/submission.id}} - {{#submission.timecreated}}{{/submission.timecreated}} - {{^submission.timecreated}}{{/submission.timecreated}} + {{#submission.timecreated}}{{/submission.timecreated}} + {{^submission.timecreated}}{{/submission.timecreated}}
@@ -302,8 +310,8 @@ {{shortenedname}} - {{#submission.timecreated}}{{/submission.timecreated}} - {{^submission.timecreated}}{{/submission.timecreated}} + {{#submission.timecreated}}{{/submission.timecreated}} + {{^submission.timecreated}}{{/submission.timecreated}}
{{/groups.phasefour}} diff --git a/version.php b/version.php index e061589..787fa3c 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'mod_discourse'; -$plugin->release = '1.2.2'; -$plugin->version = 2022120200; +$plugin->release = '1.2.3'; +$plugin->version = 2023050500; $plugin->requires = 2020061500; $plugin->maturity = MATURITY_STABLE; diff --git a/view.php b/view.php index 50d7741..a064e3c 100644 --- a/view.php +++ b/view.php @@ -33,10 +33,10 @@ $id = optional_param('id', null, PARAM_INT); // Module instance ID as alternative. -$d = optional_param('d', null, PARAM_INT); +$d = optional_param('d', null, PARAM_INT); // New phase that discourse should switch to. -$newphase = optional_param('newphase', null, PARAM_INT); +$newphase = optional_param('newphase', null, PARAM_INT); $discourse = discourse::get_discourse_instance($id, $d); @@ -92,7 +92,8 @@ $DB->update_record('discourse', $moduleinstance); - redirect(new moodle_url('/mod/discourse/view.php', array('id' => $id)), get_string('phaseswitched', 'mod_discourse'), null, notification::NOTIFY_SUCCESS); + redirect(new moodle_url('/mod/discourse/view.php', array('id' => $id)), get_string('phaseswitched', 'mod_discourse'), + null, notification::NOTIFY_SUCCESS); } @@ -109,7 +110,7 @@ $PAGE->set_heading(format_string($course->fullname)); $PAGE->set_context($context); -if ($CFG->branch < 41) { +if ($CFG->branch < 400) { $PAGE->force_settings_menu(); } @@ -117,11 +118,11 @@ echo $OUTPUT->header(); -if ($CFG->branch < 41) { +if ($CFG->branch < 400) { echo $OUTPUT->heading(get_string('modulename', 'mod_discourse').': ' . format_string($moduleinstance->name), 3); if ($moduleinstance->intro) { - echo $OUTPUT->box(format_module_intro('discourse', $moduleinstance, $cm->id), 'generalbox mod_introbox', 'newmoduleintro'); + echo $OUTPUT->box(format_module_intro('discourse', $moduleinstance, $cm->id), 'generalbox', 'intro'); } } @@ -201,11 +202,12 @@ $phasehints = false; } -$page = new discourse_view($cm->id, $discourse->get_groups(), $moduleinstance->autoswitch, $activephaseone, $activephasetwo, - $activephasethree, $activephasefour, $moduleinstance->hintphaseone, $moduleinstance->hintphasetwo, $moduleinstance->hintphasethree, - $moduleinstance->hintphasefour, $hintphaseoneshortened, $hintphasetwoshortened, $hintphasethreeshortened, $hintphasefourshortened, - $moduleinstance->deadlinephaseone, $moduleinstance->deadlinephasetwo, $moduleinstance->deadlinephasethree, $moduleinstance->deadlinephasefour, - $caneditphase, $canswitchphase, $canviewallgroups, $canviewgroupparticipants, $shouldswitchphase, $userid, sesskey(), $phasehints); +$page = new discourse_view($cm->id, $discourse->get_groups(), $moduleinstance->autoswitch, $activephaseone, + $activephasetwo, $activephasethree, $activephasefour, $moduleinstance->hintphaseone, $moduleinstance->hintphasetwo, + $moduleinstance->hintphasethree, $moduleinstance->hintphasefour, $hintphaseoneshortened, $hintphasetwoshortened, + $hintphasethreeshortened, $hintphasefourshortened, $moduleinstance->deadlinephaseone, $moduleinstance->deadlinephasetwo, + $moduleinstance->deadlinephasethree, $moduleinstance->deadlinephasefour, $caneditphase, $canswitchphase, $canviewallgroups, + $canviewgroupparticipants, $shouldswitchphase, $userid, sesskey(), $phasehints); echo $OUTPUT->render($page);
- {{#canviewallgroups}}{{/canviewallgroups}} - {{#str}}phasefour, mod_discourse{{/str}} - {{#activephasefour}}{{#str}}activephase, mod_discourse{{/str}} {{/activephasefour}} - {{^activephasefour}}{{#canswitchphase}}{{/canswitchphase}}{{/activephasefour}} -
+ {{#canviewallgroups}}{{/canviewallgroups}} + {{#str}}phasefour, mod_discourse{{/str}} + {{#activephasefour}}{{#str}}activephase, mod_discourse{{/str}} {{/activephasefour}} + {{^activephasefour}}{{#canswitchphase}}{{/canswitchphase}}{{/activephasefour}} +
{{#deadlinephasefour}} {{#str}}sheduledend, mod_discourse{{/str}}: - {{#userdate}}{{deadlinephasefour}}, {{#str}} strftimedaydatetime, core_langconfig {{/str}}{{/userdate}} + {{#userdate}}{{deadlinephasefour}}, {{#str}} strftimedaydatetime, core_langconfig {{/str}}{{/userdate}}

{{/deadlinephasefour}} {{#hintphasefour}} {{#hintphasefourshortened}}{{/hintphasefourshortened}} {{#str}}hint, mod_discourse{{/str}}: {{#hintphasefourshortened}} -

{{hintphasefour}}

-

{{#shortentext}} 250, {{hintphasefour}} {{/shortentext}}

+

{{hintphasefour}}

+

{{#shortentext}} 250, {{hintphasefour}} {{/shortentext}}

{{/hintphasefourshortened}} {{^hintphasefourshortened}} -

{{hintphasefour}}

+

{{hintphasefour}}

{{/hintphasefourshortened}} {{/hintphasefour}}