diff --git a/mod/forum/classes/local/renderers/discussion_list.php b/mod/forum/classes/local/renderers/discussion_list.php index bde944f0054..307f40201cf 100644 --- a/mod/forum/classes/local/renderers/discussion_list.php +++ b/mod/forum/classes/local/renderers/discussion_list.php @@ -163,6 +163,7 @@ class discussion_list { $forumview = [ 'forum' => (array) $forumexporter->export($this->renderer), + 'newdiscussionhtml' => $this->get_discussion_form($user, $cm, $groupid), 'groupchangemenu' => groups_print_activity_menu( $cm, $this->urlfactory->get_forum_view_url_from_forum($forum), @@ -185,7 +186,6 @@ class discussion_list { $forumview, [ 'pagination' => $this->renderer->render(new \paging_bar($alldiscussionscount, $pageno, $pagesize, $PAGE->url, 'p')), - 'newdiscussionhtml' => $this->get_discussion_form($user, $cm, $groupid) ], $exportedposts ); @@ -193,43 +193,56 @@ class discussion_list { return $this->renderer->render_from_template($this->template, $forumview); } + /** + * Get the mod_forum_post_form. This is the default boiler plate from mod_forum/post_form.php with the inpage flag caveat + * + * @param stdClass $user The user the form is being generated for + * @param \cm_info $cm + * @param int $groupid The groupid if any + * + * @return string The rendered html + */ private function get_discussion_form(stdClass $user, \cm_info $cm, ?int $groupid) { global $PAGE; $forum = $this->forum; $forumrecord = $this->legacydatamapperfactory->get_forum_data_mapper()->to_legacy_object($forum); $modcontext = \context_module::instance($cm->id); - $post = new stdClass(); - $post->course = $forum->get_course_id(); - $post->forum = $forum->get_id(); - $post->discussion = 0; // Ie discussion # not defined yet. - $post->parent = 0; - $post->subject = ''; - $post->userid = $user->id; - $post->message = ''; - $post->messageformat = editors_get_preferred_format(); - $post->messagetrust = 0; - $post->groupid = $groupid; - + $coursecontext = \context_course::instance($forum->get_course_id()); + $post = (object) [ + 'course' => $forum->get_course_id(), + 'forum' => $forum->get_id(), + 'discussion' => 0, // Ie discussion # not defined yet. + 'parent' => 0, + 'subject' => '', + 'userid' => $user->id, + 'message' => '', + 'messageformat' => editors_get_preferred_format(), + 'messagetrust' => 0, + 'groupid' => $groupid, + ]; $thresholdwarning = forum_check_throttling($forum, $cm); - //$forumrecord = $DB->get_record('forum', array('id' => $forum->get_id())); + $mformpost = new \mod_forum_post_form('post.php', array('course' => $forum->get_course_record(), 'cm' => $cm, - 'coursecontext' => $forum->get_context(), + 'coursecontext' => $coursecontext, 'modcontext' => $modcontext, 'forum' => $forumrecord, 'post' => $post, 'subscribe' => \mod_forum\subscriptions::is_subscribed($user->id, $forumrecord, null, $cm), 'thresholdwarning' => $thresholdwarning, + 'inpagereply' => true, 'edit' => 0), 'post', '', array('id' => 'mformforum')); - // Setup the file related components. - $draftitemid = file_get_submitted_draft_itemid('attachments'); - $attachoptions = \mod_forum_post_form::attachment_options($forumrecord); - file_prepare_draft_area($draftitemid, $modcontext->id, 'mod_forum', 'attachment', null, $attachoptions); $params = array('reply' => 0, 'forum' => $forumrecord->id, 'edit' => 0) + - (isset($post->groupid) ? array('groupid' => $post->groupid) : array()); + (isset($post->groupid) ? array('groupid' => $post->groupid) : array()) + + array( + 'userid' => $post->userid, + 'parent' => $post->parent, + 'discussion' => $post->discussion, + 'course' => $forum->get_course_id() + ); $mformpost->set_data($params); return $mformpost->render(); diff --git a/mod/forum/classes/post_form.php b/mod/forum/classes/post_form.php index 1d9d303932e..5afcea7cf2b 100644 --- a/mod/forum/classes/post_form.php +++ b/mod/forum/classes/post_form.php @@ -94,8 +94,11 @@ class mod_forum_post_form extends moodleform { $edit = $this->_customdata['edit']; $thresholdwarning = $this->_customdata['thresholdwarning']; $canreplyprivately = $this->_customdata['canreplyprivately']; + $stripped = isset($this->_customdata['inpagereply']) ? $this->_customdata['inpagereply'] : false; - $mform->addElement('header', 'general', '');//fill in the data depending on page params later using set_data + if (!$stripped) { + $mform->addElement('header', 'general', '');//fill in the data depending on page params later using set_data + } // If there is a warning message and we are not editing a post we need to handle the warning. if (!empty($thresholdwarning) && !$edit) { @@ -115,146 +118,156 @@ class mod_forum_post_form extends moodleform { $mform->setType('message', PARAM_RAW); $mform->addRule('message', get_string('required'), 'required', null, 'client'); - $manageactivities = has_capability('moodle/course:manageactivities', $coursecontext); + if (!$stripped) { + $manageactivities = has_capability('moodle/course:manageactivities', $coursecontext); - if (\mod_forum\subscriptions::is_forcesubscribed($forum)) { - $mform->addElement('checkbox', 'discussionsubscribe', get_string('discussionsubscription', 'forum')); - $mform->freeze('discussionsubscribe'); - $mform->setDefaults('discussionsubscribe', 0); - $mform->addHelpButton('discussionsubscribe', 'forcesubscribed', 'forum'); + if (\mod_forum\subscriptions::is_forcesubscribed($forum)) { + $mform->addElement('advcheckbox', 'discussionsubscribe', get_string('discussionsubscription', 'forum')); + $mform->freeze('discussionsubscribe'); + $mform->setDefaults('discussionsubscribe', 0); + $mform->addHelpButton('discussionsubscribe', 'forcesubscribed', 'forum'); - } else if (\mod_forum\subscriptions::subscription_disabled($forum) && !$manageactivities) { - $mform->addElement('checkbox', 'discussionsubscribe', get_string('discussionsubscription', 'forum')); - $mform->freeze('discussionsubscribe'); - $mform->setDefaults('discussionsubscribe', 0); - $mform->addHelpButton('discussionsubscribe', 'disallowsubscription', 'forum'); + } else if (\mod_forum\subscriptions::subscription_disabled($forum) && !$manageactivities) { + $mform->addElement('advcheckbox', 'discussionsubscribe', get_string('discussionsubscription', 'forum')); + $mform->freeze('discussionsubscribe'); + $mform->setDefaults('discussionsubscribe', 0); + $mform->addHelpButton('discussionsubscribe', 'disallowsubscription', 'forum'); - } else { - $mform->addElement('checkbox', 'discussionsubscribe', get_string('discussionsubscription', 'forum')); - $mform->addHelpButton('discussionsubscribe', 'discussionsubscription', 'forum'); - } - - if (forum_can_create_attachment($forum, $modcontext)) { - $mform->addElement('filemanager', 'attachments', get_string('attachment', 'forum'), null, self::attachment_options($forum)); - $mform->addHelpButton('attachments', 'attachment', 'forum'); - } - - if (!$post->parent && has_capability('mod/forum:pindiscussions', $modcontext)) { - $mform->addElement('checkbox', 'pinned', get_string('discussionpinned', 'forum')); - $mform->addHelpButton('pinned', 'discussionpinned', 'forum'); - } - - if (empty($post->id) && $manageactivities) { - $mform->addElement('checkbox', 'mailnow', get_string('mailnow', 'forum')); - } - - if ((empty($post->id) && $canreplyprivately) || (!empty($post) && !empty($post->privatereplyto))) { - // Only show the option to change private reply settings if this is a new post and the user can reply - // privately, or if this is already private reply, in which case the state is shown but is not editable. - $mform->addElement('checkbox', 'isprivatereply', get_string('privatereply', 'forum')); - $mform->addHelpButton('isprivatereply', 'privatereply', 'forum'); - if (!empty($post->privatereplyto)) { - $mform->setDefault('isprivatereply', 1); - $mform->freeze('isprivatereply'); - } - } - - if ($groupmode = groups_get_activity_groupmode($cm, $course)) { - $groupdata = groups_get_activity_allowed_groups($cm); - - $groupinfo = array(); - foreach ($groupdata as $groupid => $group) { - // Check whether this user can post in this group. - // We must make this check because all groups are returned for a visible grouped activity. - if (forum_user_can_post_discussion($forum, $groupid, null, $cm, $modcontext)) { - // Build the data for the groupinfo select. - $groupinfo[$groupid] = $group->name; - } else { - unset($groupdata[$groupid]); - } - } - $groupcount = count($groupinfo); - - // Check whether a user can post to all of their own groups. - - // Posts to all of my groups are copied to each group that the user is a member of. Certain conditions must be met. - // 1) It only makes sense to allow this when a user is in more than one group. - // Note: This check must come before we consider adding accessallgroups, because that is not a real group. - $canposttoowngroups = empty($post->edit) && $groupcount > 1; - - // 2) Important: You can *only* post to multiple groups for a top level post. Never any reply. - $canposttoowngroups = $canposttoowngroups && empty($post->parent); - - // 3) You also need the canposttoowngroups capability. - $canposttoowngroups = $canposttoowngroups && has_capability('mod/forum:canposttomygroups', $modcontext); - if ($canposttoowngroups) { - // This user is in multiple groups, and can post to all of their own groups. - // Note: This is not the same as accessallgroups. This option will copy a post to all groups that a - // user is a member of. - $mform->addElement('checkbox', 'posttomygroups', get_string('posttomygroups', 'forum')); - $mform->addHelpButton('posttomygroups', 'posttomygroups', 'forum'); - $mform->disabledIf('groupinfo', 'posttomygroups', 'checked'); - } - - // Check whether this user can post to all groups. - // Posts to the 'All participants' group go to all groups, not to each group in a list. - // It makes sense to allow this, even if there currently aren't any groups because there may be in the future. - if (forum_user_can_post_discussion($forum, -1, null, $cm, $modcontext)) { - // Note: We must reverse in this manner because array_unshift renumbers the array. - $groupinfo = array_reverse($groupinfo, true ); - $groupinfo[-1] = get_string('allparticipants'); - $groupinfo = array_reverse($groupinfo, true ); - $groupcount++; - } - - // Determine whether the user can select a group from the dropdown. The dropdown is available for several reasons. - // 1) This is a new post (not an edit), and there are at least two groups to choose from. - $canselectgroupfornew = empty($post->edit) && $groupcount > 1; - - // 2) This is editing of an existing post and the user is allowed to movediscussions. - // We allow this because the post may have been moved from another forum where groups are not available. - // We show this even if no groups are available as groups *may* have been available but now are not. - $canselectgroupformove = $groupcount && !empty($post->edit) && has_capability('mod/forum:movediscussions', $modcontext); - - // Important: You can *only* change the group for a top level post. Never any reply. - $canselectgroup = empty($post->parent) && ($canselectgroupfornew || $canselectgroupformove); - - if ($canselectgroup) { - $mform->addElement('select','groupinfo', get_string('group'), $groupinfo); - $mform->setDefault('groupinfo', $post->groupid); - $mform->setType('groupinfo', PARAM_INT); } else { - if (empty($post->groupid)) { - $groupname = get_string('allparticipants'); - } else { - $groupname = format_string($groupdata[$post->groupid]->name); - } - $mform->addElement('static', 'groupinfo', get_string('group'), $groupname); + $mform->addElement('advcheckbox', 'discussionsubscribe', get_string('discussionsubscription', 'forum')); + $mform->addHelpButton('discussionsubscribe', 'discussionsubscription', 'forum'); } - } - if (!empty($CFG->forum_enabletimedposts) && !$post->parent && has_capability('mod/forum:viewhiddentimedposts', $coursecontext)) { - $mform->addElement('header', 'displayperiod', get_string('displayperiod', 'forum')); + if (forum_can_create_attachment($forum, $modcontext)) { + $mform->addElement('filemanager', 'attachments', get_string('attachment', 'forum'), null, + self::attachment_options($forum)); + $mform->addHelpButton('attachments', 'attachment', 'forum'); + } - $mform->addElement('date_time_selector', 'timestart', get_string('displaystart', 'forum'), array('optional' => true)); - $mform->addHelpButton('timestart', 'displaystart', 'forum'); + if (!$post->parent && has_capability('mod/forum:pindiscussions', $modcontext)) { + $mform->addElement('checkbox', 'pinned', get_string('discussionpinned', 'forum')); + $mform->addHelpButton('pinned', 'discussionpinned', 'forum'); + } - $mform->addElement('date_time_selector', 'timeend', get_string('displayend', 'forum'), array('optional' => true)); - $mform->addHelpButton('timeend', 'displayend', 'forum'); + if ((empty($post->id) && $canreplyprivately) || (!empty($post) && !empty($post->privatereplyto))) { + // Only show the option to change private reply settings if this is a new post and the user can reply + // privately, or if this is already private reply, in which case the state is shown but is not editable. + $mform->addElement('checkbox', 'isprivatereply', get_string('privatereply', 'forum')); + $mform->addHelpButton('isprivatereply', 'privatereply', 'forum'); + if (!empty($post->privatereplyto)) { + $mform->setDefault('isprivatereply', 1); + $mform->freeze('isprivatereply'); + } + } - } else { - $mform->addElement('hidden', 'timestart'); - $mform->setType('timestart', PARAM_INT); - $mform->addElement('hidden', 'timeend'); - $mform->setType('timeend', PARAM_INT); - $mform->setConstants(array('timestart' => 0, 'timeend' => 0)); - } + if ($groupmode = groups_get_activity_groupmode($cm, $course)) { + $groupdata = groups_get_activity_allowed_groups($cm); + if (empty($post->id) && $manageactivities) { + $mform->addElement('checkbox', 'mailnow', get_string('mailnow', 'forum')); + } - if (core_tag_tag::is_enabled('mod_forum', 'forum_posts')) { - $mform->addElement('header', 'tagshdr', get_string('tags', 'tag')); + if ($groupmode = groups_get_activity_groupmode($cm, $course)) { + $groupdata = groups_get_activity_allowed_groups($cm); - $mform->addElement('tags', 'tags', get_string('tags'), - array('itemtype' => 'forum_posts', 'component' => 'mod_forum')); + $groupinfo = array(); + foreach ($groupdata as $groupid => $group) { + // Check whether this user can post in this group. + // We must make this check because all groups are returned for a visible grouped activity. + if (forum_user_can_post_discussion($forum, $groupid, null, $cm, $modcontext)) { + // Build the data for the groupinfo select. + $groupinfo[$groupid] = $group->name; + } else { + unset($groupdata[$groupid]); + } + } + $groupcount = count($groupinfo); + + // Check whether a user can post to all of their own groups. + + // Posts to all of my groups are copied to each group that the user is a member of. Certain conditions must be met. + // 1) It only makes sense to allow this when a user is in more than one group. + // Note: This check must come before we consider adding accessallgroups, because that is not a real group. + $canposttoowngroups = empty($post->edit) && $groupcount > 1; + + // 2) Important: You can *only* post to multiple groups for a top level post. Never any reply. + $canposttoowngroups = $canposttoowngroups && empty($post->parent); + + // 3) You also need the canposttoowngroups capability. + $canposttoowngroups = $canposttoowngroups && has_capability('mod/forum:canposttomygroups', $modcontext); + if ($canposttoowngroups) { + // This user is in multiple groups, and can post to all of their own groups. + // Note: This is not the same as accessallgroups. This option will copy a post to all groups that a + // user is a member of. + $mform->addElement('checkbox', 'posttomygroups', get_string('posttomygroups', 'forum')); + $mform->addHelpButton('posttomygroups', 'posttomygroups', 'forum'); + $mform->disabledIf('groupinfo', 'posttomygroups', 'checked'); + } + + // Check whether this user can post to all groups. + // Posts to the 'All participants' group go to all groups, not to each group in a list. + // It makes sense to allow this, even if there currently aren't any groups because there may be in the future. + if (forum_user_can_post_discussion($forum, -1, null, $cm, $modcontext)) { + // Note: We must reverse in this manner because array_unshift renumbers the array. + $groupinfo = array_reverse($groupinfo, true); + $groupinfo[-1] = get_string('allparticipants'); + $groupinfo = array_reverse($groupinfo, true); + $groupcount++; + } + + // Determine whether the user can select a group from the dropdown. The dropdown is available for several reasons. + // 1) This is a new post (not an edit), and there are at least two groups to choose from. + $canselectgroupfornew = empty($post->edit) && $groupcount > 1; + + // 2) This is editing of an existing post and the user is allowed to movediscussions. + // We allow this because the post may have been moved from another forum where groups are not available. + // We show this even if no groups are available as groups *may* have been available but now are not. + $canselectgroupformove = + $groupcount && !empty($post->edit) && has_capability('mod/forum:movediscussions', $modcontext); + + // Important: You can *only* change the group for a top level post. Never any reply. + $canselectgroup = empty($post->parent) && ($canselectgroupfornew || $canselectgroupformove); + + if ($canselectgroup) { + $mform->addElement('select', 'groupinfo', get_string('group'), $groupinfo); + $mform->setDefault('groupinfo', $post->groupid); + $mform->setType('groupinfo', PARAM_INT); + } else { + if (empty($post->groupid)) { + $groupname = get_string('allparticipants'); + } else { + $groupname = format_string($groupdata[$post->groupid]->name); + } + $mform->addElement('static', 'groupinfo', get_string('group'), $groupname); + } + } + } + + if (!empty($CFG->forum_enabletimedposts) && !$post->parent && + has_capability('mod/forum:viewhiddentimedposts', $coursecontext)) { + $mform->addElement('header', 'displayperiod', get_string('displayperiod', 'forum')); + + $mform->addElement('date_time_selector', 'timestart', get_string('displaystart', 'forum'), + array('optional' => true)); + $mform->addHelpButton('timestart', 'displaystart', 'forum'); + + $mform->addElement('date_time_selector', 'timeend', get_string('displayend', 'forum'), + array('optional' => true)); + $mform->addHelpButton('timeend', 'displayend', 'forum'); + + } else { + $mform->addElement('hidden', 'timestart'); + $mform->setType('timestart', PARAM_INT); + $mform->addElement('hidden', 'timeend'); + $mform->setType('timeend', PARAM_INT); + $mform->setConstants(array('timestart' => 0, 'timeend' => 0)); + } + + if (core_tag_tag::is_enabled('mod_forum', 'forum_posts')) { + $mform->addElement('header', 'tagshdr', get_string('tags', 'tag')); + + $mform->addElement('tags', 'tags', get_string('tags'), + array('itemtype' => 'forum_posts', 'component' => 'mod_forum')); + } } //------------------------------------------------------------------------------- @@ -265,7 +278,23 @@ class mod_forum_post_form extends moodleform { $submit_string = get_string('posttoforum', 'forum'); } - $this->add_action_buttons(true, $submit_string); + // Always register a no submit button so it can be picked up if redirecting to the original post form. + $mform->registerNoSubmitButton('advancedadddiscussion'); + + // This is an inpage add discussion which requires custom buttons. + if ($stripped) { + $buttonarray = array(); + $buttonarray[] = &$mform->createElement('submit', 'submitbutton', $submit_string); + $buttonarray[] = &$mform->createElement('submit', 'advancedadddiscussion', + get_string('advanced')); + $buttonarray[] = &$mform->createElement('button', 'cancelbtn', + get_string('cancel', 'core'), + ['class' => 'btn-secondary', 'data-toggle' => 'collapse', 'data-target' => "#collapseAddForm"]); + $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); + $mform->closeHeaderBefore('buttonar'); + } else { + $this->add_action_buttons(true, $submit_string); + } $mform->addElement('hidden', 'course'); $mform->setType('course', PARAM_INT); diff --git a/mod/forum/post.php b/mod/forum/post.php index 4aa76e77057..fdea9c05ef0 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -781,14 +781,14 @@ if ($mformpost->is_cancelled()) { } else { redirect($urlfactory->get_discussion_view_url_from_discussion($discussionentity)); } -} else if ($fromform = $mformpost->get_data()) { +} else if ($mformpost->is_submitted() && !$mformpost->no_submit_button_pressed()) { if (empty($SESSION->fromurl)) { $errordestination = $urlfactory->get_forum_view_url_from_forum($forumentity); } else { $errordestination = $SESSION->fromurl; } - + $fromform = $mformpost->get_data(); $fromform->itemid = $fromform->message['itemid']; $fromform->messageformat = $fromform->message['format']; $fromform->message = $fromform->message['text']; diff --git a/mod/forum/templates/discussion_list.mustache b/mod/forum/templates/discussion_list.mustache index 6abcf924ff2..1f5303bcdbb 100644 --- a/mod/forum/templates/discussion_list.mustache +++ b/mod/forum/templates/discussion_list.mustache @@ -46,7 +46,7 @@ {{#str}}addanewdiscussion, forum{{/str}} {{/discussion_create_text}} -
+
{{{newdiscussionhtml}}}
diff --git a/mod/forum/tests/behat/behat_mod_forum.php b/mod/forum/tests/behat/behat_mod_forum.php index 6ad16bfbb95..e8af7e42c0e 100644 --- a/mod/forum/tests/behat/behat_mod_forum.php +++ b/mod/forum/tests/behat/behat_mod_forum.php @@ -116,6 +116,7 @@ class behat_mod_forum extends behat_base { // Navigate to forum. $this->execute('behat_general::click_link', $this->escape($forumname)); $this->execute('behat_general::click_link', $buttonstr); + $this->execute('behat_forms::press_button', get_string('advanced')); // Fill form and post. $this->execute('behat_forms::i_set_the_following_fields_to_these_values', $table); diff --git a/mod/forum/tests/behat/edit_tags.feature b/mod/forum/tests/behat/edit_tags.feature index 8af5d580969..8c87286e918 100644 --- a/mod/forum/tests/behat/edit_tags.feature +++ b/mod/forum/tests/behat/edit_tags.feature @@ -51,6 +51,7 @@ Feature: Edited forum posts handle tags correctly And I am on "Course 1" course homepage And I follow "Test forum" And I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" And I expand all fieldsets And I open the autocomplete suggestions list And I should see "OT1" in the ".form-autocomplete-suggestions" "css_element" diff --git a/mod/forum/tests/behat/forum_subscriptions_default.feature b/mod/forum/tests/behat/forum_subscriptions_default.feature index 3381138d5b3..ce7b0074af6 100644 --- a/mod/forum/tests/behat/forum_subscriptions_default.feature +++ b/mod/forum/tests/behat/forum_subscriptions_default.feature @@ -30,12 +30,14 @@ Feature: A user can control their default discussion subscription settings And I am on "Course 1" course homepage And I follow "Test forum name" When I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" Then "input[name=discussionsubscribe][checked=checked]" "css_element" should exist And I log out And I log in as "student2" And I am on "Course 1" course homepage And I follow "Test forum name" And I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" And "input[name=discussionsubscribe]:not([checked=checked])" "css_element" should exist Scenario: Replying to an existing discussion in an optional forum follows user preferences @@ -73,12 +75,14 @@ Feature: A user can control their default discussion subscription settings And I am on "Course 1" course homepage And I follow "Test forum name" When I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" Then "input[name=discussionsubscribe][checked=checked]" "css_element" should exist And I log out And I log in as "student2" And I am on "Course 1" course homepage And I follow "Test forum name" And I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" And "input[name=discussionsubscribe][checked=checked]" "css_element" should exist Scenario: Replying to an existing discussion in an automatic forum follows forum subscription diff --git a/mod/forum/tests/behat/separate_group_discussions.feature b/mod/forum/tests/behat/separate_group_discussions.feature index 7ec365e348a..aa5164ef816 100644 --- a/mod/forum/tests/behat/separate_group_discussions.feature +++ b/mod/forum/tests/behat/separate_group_discussions.feature @@ -57,6 +57,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u And I am on "Course 1" course homepage And I follow "Standard forum name" When I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" Then the "Group" select box should contain "All participants" And the "Group" select box should contain "Group A" And the "Group" select box should contain "Group B" @@ -69,6 +70,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u And I follow "Standard forum name" And I select "Group A" from the "Separate groups" singleselect When I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" Then I should see "Post a copy to all groups" And I set the following fields to these values: | Subject | Teacher 1 -> Group B | @@ -99,6 +101,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u And I follow "Standard forum name" And I select "Group A" from the "Separate groups" singleselect When I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" Then I should see "Post a copy to all groups" And I set the following fields to these values: | Subject | Teacher 1 -> Group C | @@ -128,6 +131,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u And I am on "Course 1" course homepage And I follow "Standard forum name" When I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" And I set the following fields to these values: | Subject | Teacher 1 -> Post to all | | Message | Teacher 1 -> Post to all | @@ -174,6 +178,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u When I follow "Standard forum name" And I select "Group A" from the "Separate groups" singleselect And I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" And 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" @@ -194,6 +199,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u # Now try posting in Group A (starting at Group B) And I select "Group B" from the "Separate groups" singleselect And I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" And 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" @@ -221,6 +227,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u And I am on "Course 1" course homepage And I follow "Standard forum name" When I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" 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" @@ -235,6 +242,7 @@ Feature: Posting to all groups in a separate group discussion is restricted to u And I am on "Course 1" course homepage And I follow "Standard forum name" When I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" 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" diff --git a/mod/forum/tests/behat/separate_group_single_group_discussions.feature b/mod/forum/tests/behat/separate_group_single_group_discussions.feature index 06c0ff71653..c7d53359859 100644 --- a/mod/forum/tests/behat/separate_group_single_group_discussions.feature +++ b/mod/forum/tests/behat/separate_group_single_group_discussions.feature @@ -59,12 +59,14 @@ Feature: Posting to groups in a separate group discussion when restricted to gro And I am on "Course 1" course homepage And I follow "Multiple groups forum" When I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" Then the "Group" select box should contain "All participants" And the "Group" select box should contain "G1G1" And the "Group" select box should contain "G1G2" And I am on "Course 1" course homepage And I follow "Single groups forum" And I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" And the "Group" select box should contain "All participants" And the "Group" select box should contain "G2G1" And I should not see "Post a copy to all groups" @@ -74,11 +76,13 @@ Feature: Posting to groups in a separate group discussion when restricted to gro And I am on "Course 1" course homepage And I follow "Multiple groups forum" When I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" Then the "Group" select box should not contain "All participants" And the "Group" select box should contain "G1G1" And the "Group" select box should contain "G1G2" And I am on "Course 1" course homepage And I follow "Single groups forum" And I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" And I should see "G2G1" And "Group" "select" should not exist diff --git a/mod/forum/tests/behat/visible_group_discussions.feature b/mod/forum/tests/behat/visible_group_discussions.feature index 02975aa8b13..f9452a39625 100644 --- a/mod/forum/tests/behat/visible_group_discussions.feature +++ b/mod/forum/tests/behat/visible_group_discussions.feature @@ -48,6 +48,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us And I am on "Course 1" course homepage And I follow "Standard forum name" When I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" Then the "Group" select box should contain "All participants" And the "Group" select box should contain "Group A" And the "Group" select box should contain "Group B" @@ -60,6 +61,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us And I follow "Standard forum name" And I select "Group A" from the "Visible groups" singleselect When I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" Then I should see "Post a copy to all groups" And I set the following fields to these values: | Subject | Teacher 1 -> Group B | @@ -90,6 +92,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us And I follow "Standard forum name" And I select "Group A" from the "Visible groups" singleselect When I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" Then I should see "Post a copy to all groups" And I set the following fields to these values: | Subject | Teacher 1 -> Group C | @@ -119,6 +122,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us And I am on "Course 1" course homepage And I follow "Standard forum name" When I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" And I set the following fields to these values: | Subject | Teacher 1 -> Post to all | | Message | Teacher 1 -> Post to all | @@ -156,6 +160,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us When I follow "Standard forum name" Then I should see "Group A" And I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" And I should see "Group A" And I should not see "Group B" And I should not see "Group C" @@ -174,6 +179,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us When I follow "Standard forum name" And I select "Group A" from the "Visible groups" singleselect And I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" And 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" @@ -194,6 +200,7 @@ Feature: Posting to all groups in a visible group discussion is restricted to us # Now try posting in Group A (starting at Group B) And I select "Group B" from the "Visible groups" singleselect And I click on "Add a new discussion topic" "link" + And I click on "Advanced" "button" And 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"