Skip to content

Commit

Permalink
Merge branch 'release/1.2.3'
Browse files Browse the repository at this point in the history
* release/1.2.3:
  fix(view): Fixed typo.
  fix(events): Fixed typo and increment version
  fix(groupview): Fix for an error when a discourse group is deleted externally.
  fix(mustache): fixing typo
  feat(version): Incremented version and updated changelog
  feat(chore): Some code reformating to fix moodle code check errors
  feat(icon): Added monologo version of the activity icon for current Moodle versions.
  fix(js): regrunted js
  feat(chore): updated moodle ci workflow for github
  fix(layout): hide heading and intro in moodle 4.0 to avoid redundant information
  fix(layout): replacing bootstrap class pull-right with float-right for moodle 4.2
  • Loading branch information
Daniel Nolte committed May 5, 2023
2 parents 79e44e2 + bebc49b commit c4b92d2
Show file tree
Hide file tree
Showing 23 changed files with 224 additions and 140 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
12 changes: 10 additions & 2 deletions amd/build/groupview.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/groupview.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion backup/moodle2/restore_discourse_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion classes/event/course_module_instance_list_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
3 changes: 1 addition & 2 deletions classes/event/course_module_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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');
Expand Down
6 changes: 4 additions & 2 deletions classes/output/discourse_groupview.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions classes/output/discourse_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 10 additions & 8 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
];

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion db/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
);
3 changes: 2 additions & 1 deletion db/uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
38 changes: 24 additions & 14 deletions groupview.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
}

Expand All @@ -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();
Expand All @@ -97,23 +101,27 @@
$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();
$submission->timemodified = null;

$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);
}

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
4 changes: 2 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Loading

0 comments on commit c4b92d2

Please sign in to comment.