From 59b8d89ba82a5e68cb3b9910163d3787e666e1ba Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 28 Oct 2015 11:55:16 +0800 Subject: [PATCH 1/2] MDL-51939 mod_forum: Correct empty groupinfo check --- mod/forum/db/upgrade.php | 8 ++++++++ mod/forum/post.php | 2 +- mod/forum/version.php | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mod/forum/db/upgrade.php b/mod/forum/db/upgrade.php index c26485a33a1..8ac3fedefc3 100644 --- a/mod/forum/db/upgrade.php +++ b/mod/forum/db/upgrade.php @@ -181,5 +181,13 @@ function xmldb_forum_upgrade($oldversion) { upgrade_mod_savepoint(true, 2014051203, 'forum'); } + if ($oldversion < 2014051204) { + // Groupid = 0 is never valid. + $DB->set_field('forum_discussions', 'groupid', -1, array('groupid' => 0)); + + // Forum savepoint reached. + upgrade_mod_savepoint(true, 2014051204, 'forum'); + } + return true; } diff --git a/mod/forum/post.php b/mod/forum/post.php index 5fa7610d614..b40c6193ef5 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -840,7 +840,7 @@ if ($fromform = $mform_post->get_data()) { // Before we add this we must check that the user will not exceed the blocking threshold. forum_check_blocking_threshold($thresholdwarning); - if (isset($fromform->groupinfo)) { + if (!empty($fromform->groupinfo)) { // Use the value provided in the dropdown group selection. $fromform->groupid = $fromform->groupinfo; diff --git a/mod/forum/version.php b/mod/forum/version.php index 7aa50c67dd3..98c9fed5d2a 100644 --- a/mod/forum/version.php +++ b/mod/forum/version.php @@ -24,6 +24,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2014051203; // The current module version (Date: YYYYMMDDXX) +$plugin->version = 2014051204; // The current module version (Date: YYYYMMDDXX) $plugin->requires = 2014050800; // Requires this Moodle version $plugin->component = 'mod_forum'; // Full name of the plugin (used for diagnostics) From f857f7c44317fe91fb91549ba5e0f01f1f115264 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Thu, 29 Oct 2015 12:54:45 +0100 Subject: [PATCH 2/2] MDL-51939 mod_forum: all participants discussions are viewed by students Added scenario to verify that "all participants" discussions, under separate-groups mode are, by default, visible for students. --- .../tests/behat/separate_group_discussions.feature | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mod/forum/tests/behat/separate_group_discussions.feature b/mod/forum/tests/behat/separate_group_discussions.feature index 5ffa6330fa0..196c75d9e1d 100644 --- a/mod/forum/tests/behat/separate_group_discussions.feature +++ b/mod/forum/tests/behat/separate_group_discussions.feature @@ -82,3 +82,16 @@ Feature: Posting to all groups in a separate group discussion is restricted to u Then the "Group" select box should not contain "All participants" And the "Group" select box should contain "Group A" And the "Group" select box should contain "Group B" + + Scenario: Students can view all participants discussions in separate groups mode + Given I log in as "teacher1" + And I follow "Course 1" + When I add a new discussion to "Standard forum name" forum with: + | Subject | Forum post to all participants | + | Message | This is the body | + | Group | All participants | + And I log out + And I log in as "student1" + And I follow "Course 1" + And I follow "Standard forum name" + Then I should see "Forum post to all participants"