MDL-65069 mod_forum: Stripped out inpage form and advanced redirect
authorPeter <peter@moodle.com>
Mon, 25 Mar 2019 23:24:53 +0000 (07:24 +0800)
committerPeter <peter@moodle.com>
Wed, 24 Apr 2019 02:29:30 +0000 (10:29 +0800)
* Stripped out the form for the inpage on the discussion list page.
* Tweaked the 'Advanced' redirect to take into account a nosubmit button
 which populates the subject, message and any files used within it.

mod/forum/classes/local/renderers/discussion_list.php
mod/forum/classes/post_form.php
mod/forum/post.php
mod/forum/templates/discussion_list.mustache
mod/forum/tests/behat/behat_mod_forum.php
mod/forum/tests/behat/edit_tags.feature
mod/forum/tests/behat/forum_subscriptions_default.feature
mod/forum/tests/behat/separate_group_discussions.feature
mod/forum/tests/behat/separate_group_single_group_discussions.feature
mod/forum/tests/behat/visible_group_discussions.feature

index bde944f..307f402 100644 (file)
@@ -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();
index 1d9d303..5afcea7 100644 (file)
@@ -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 (\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');
-
-        } 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 {
-            $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 (!$stripped) {
+            $manageactivities = has_capability('moodle/course:manageactivities', $coursecontext);
 
-        if (!$post->parent && has_capability('mod/forum:pindiscussions', $modcontext)) {
-            $mform->addElement('checkbox', 'pinned', get_string('discussionpinned', 'forum'));
-            $mform->addHelpButton('pinned', 'discussionpinned', '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');
 
-        if (empty($post->id) && $manageactivities) {
-            $mform->addElement('checkbox', 'mailnow', get_string('mailnow', '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');
 
-        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('advcheckbox', 'discussionsubscribe', get_string('discussionsubscription', 'forum'));
+                $mform->addHelpButton('discussionsubscribe', 'discussionsubscription', 'forum');
             }
-        }
 
-        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');
+            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');
             }
 
-            // 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++;
+            if (!$post->parent && has_capability('mod/forum:pindiscussions', $modcontext)) {
+                $mform->addElement('checkbox', 'pinned', get_string('discussionpinned', 'forum'));
+                $mform->addHelpButton('pinned', 'discussionpinned', 'forum');
             }
 
-            // 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);
+            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');
+                }
+            }
 
-            // Important: You can *only* change the group for a top level post. Never any reply.
-            $canselectgroup = empty($post->parent) && ($canselectgroupfornew || $canselectgroupformove);
+            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 ($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);
+                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('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'));
+            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', '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');
+                $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));
-        }
+            } 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'));
+            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'));
+                $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);
index 4aa76e7..fdea9c0 100644 (file)
@@ -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'];
index 6abcf92..1f5303b 100644 (file)
@@ -46,7 +46,7 @@
                     {{#str}}addanewdiscussion, forum{{/str}}
                 {{/discussion_create_text}}
             </a>
-            <div class="collapse" id="collapseAddForm">
+            <div class="collapse m-t-1" id="collapseAddForm">
                 {{{newdiscussionhtml}}}
             </div>
         </div>
index 6ad16bf..e8af7e4 100644 (file)
@@ -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);
index 8af5d58..8c87286 100644 (file)
@@ -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"
index 3381138..ce7b007 100644 (file)
@@ -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
index 7ec365e..aa5164e 100644 (file)
@@ -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"
index 06c0ff7..c7d5335 100644 (file)
@@ -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
index 02975aa..f9452a3 100644 (file)
@@ -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"