| 1 | efrain | 1 | @mod @mod_forum @forumreport @forumreport_summary
 | 
        
           |  |  | 2 | Feature: Course level forum summary report
 | 
        
           |  |  | 3 |   In order to gain an overview of students' forum activities across a course
 | 
        
           |  |  | 4 |   As a teacher
 | 
        
           |  |  | 5 |   I should be able to prepare a summary report of all forums in a course
 | 
        
           |  |  | 6 |   | 
        
           |  |  | 7 |   Background:
 | 
        
           |  |  | 8 |     Given the following "users" exist:
 | 
        
           |  |  | 9 |       | username | firstname | lastname | email                |
 | 
        
           |  |  | 10 |       | teacher1 | Teacher   | 1        | teacher1@example.com |
 | 
        
           |  |  | 11 |       | student1 | Student   | 1        | student1@example.com |
 | 
        
           |  |  | 12 |       | student2 | Student   | 2        | student2@example.com |
 | 
        
           |  |  | 13 |       | student3 | Student   | 3        | student3@example.com |
 | 
        
           |  |  | 14 |     And the following "courses" exist:
 | 
        
           |  |  | 15 |       | fullname | shortname |
 | 
        
           |  |  | 16 |       | Course 1 | C1        |
 | 
        
           |  |  | 17 |       | Course 2 | C2        |
 | 
        
           |  |  | 18 |     And the following "course enrolments" exist:
 | 
        
           |  |  | 19 |       | user     | course | role           |
 | 
        
           |  |  | 20 |       | teacher1 | C1     | editingteacher |
 | 
        
           |  |  | 21 |       | teacher1 | C2     | editingteacher |
 | 
        
           |  |  | 22 |       | student1 | C1     | student        |
 | 
        
           |  |  | 23 |       | student2 | C1     | student        |
 | 
        
           |  |  | 24 |       | student2 | C2     | student        |
 | 
        
           |  |  | 25 |       | student3 | C2     | student        |
 | 
        
           |  |  | 26 |     And the following "activities" exist:
 | 
        
           |  |  | 27 |       | activity | name   | course | idnumber |
 | 
        
           |  |  | 28 |       | forum    | forum1 | C1     | forum1   |
 | 
        
           |  |  | 29 |       | forum    | forum2 | C1     | forum2   |
 | 
        
           |  |  | 30 |       | forum    | forum3 | C1     | forum3   |
 | 
        
           |  |  | 31 |       | forum    | forum4 | C2     | forum4   |
 | 
        
           |  |  | 32 |     And the following forum discussions exist in course "Course 1":
 | 
        
           |  |  | 33 |       | user     | forum  | name        | message      | created                 |
 | 
        
           |  |  | 34 |       | teacher1 | forum1 | discussion1 | Discussion 1 | ##2018-01-14 09:00:00## |
 | 
        
           |  |  | 35 |       | teacher1 | forum2 | discussion2 | Discussion 2 | ##2019-03-27 12:10:00## |
 | 
        
           |  |  | 36 |       | teacher1 | forum3 | discussion3 | Discussion 3 | ##2019-12-25 15:20:00## |
 | 
        
           |  |  | 37 |       | teacher1 | forum3 | discussion4 | Discussion 4 | ##2019-12-26 09:30:00## |
 | 
        
           |  |  | 38 |       | student1 | forum2 | discussion5 | Discussion 5 | ##2019-06-06 18:40:00## |
 | 
        
           |  |  | 39 |       | student1 | forum3 | discussion6 | Discussion 6 | ##2020-01-25 11:50:00## |
 | 
        
           |  |  | 40 |     And the following forum replies exist in course "Course 1":
 | 
        
           |  |  | 41 |       | user     | forum  | discussion  | subject | message | created                 |
 | 
        
           |  |  | 42 |       | teacher1 | forum1 | discussion1 | Re d1   | Reply 1 | ##2018-02-15 11:10:00## |
 | 
        
           |  |  | 43 |       | teacher1 | forum2 | discussion5 | Re d5   | Reply 2 | ##2019-06-09 18:20:00## |
 | 
        
           |  |  | 44 |       | teacher1 | forum2 | discussion5 | Re d5   | Reply 3 | ##2019-07-10 09:30:00## |
 | 
        
           |  |  | 45 |       | student1 | forum1 | discussion1 | Re d1   | Reply 4 | ##2018-01-25 16:40:00## |
 | 
        
           |  |  | 46 |       | student1 | forum2 | discussion2 | Re d6   | Reply 5 | ##2019-03-28 11:50:00## |
 | 
        
           |  |  | 47 |       | student1 | forum3 | discussion4 | Re d4   | Reply 6 | ##2019-12-30 20:00:00## |
 | 
        
           |  |  | 48 |     And the following forum discussions exist in course "Course 2":
 | 
        
           |  |  | 49 |       | user     | forum  | name        | message      | created                 |
 | 
        
           |  |  | 50 |       | teacher1 | forum4 | discussion7 | Discussion 7 | ##2020-01-29 15:00:00## |
 | 
        
           |  |  | 51 |       | student2 | forum4 | discussion8 | Discussion 8 | ##2020-02-02 16:00:00## |
 | 
        
           |  |  | 52 |     And the following forum replies exist in course "Course 2":
 | 
        
           |  |  | 53 |       | user     | forum  | discussion  | subject | message | created                 |
 | 
        
           |  |  | 54 |       | teacher1 | forum4 | discussion8 | Re d8   | Reply 7 | ##2020-02-03 09:45:00## |
 | 
        
           |  |  | 55 |       | student2 | forum4 | discussion7 | Re d7   | Reply 8 | ##2020-02-04 13:50:00## |
 | 
        
           |  |  | 56 |   | 
        
           |  |  | 57 |   Scenario: Course forum summary report can be viewed by teacher and contains accurate data
 | 
        
           |  |  | 58 |     When I am on the forum2 "forum activity" page logged in as teacher1
 | 
        
           |  |  | 59 |     And I navigate to "Reports" in current page administration
 | 
        
           |  |  | 60 |     And I should see "Export posts"
 | 
        
           |  |  | 61 |     And the following should exist in the "forumreport_summary_table" table:
 | 
        
           |  |  | 62 |     # |                      | Discussions | Replies |                                 |                                |
 | 
        
           |  |  | 63 |       | First name / Last name | -3-         | -4-     | Earliest post                   | Most recent post               |
 | 
        
           |  |  | 64 |       | Student 1            | 1           | 1       | Thursday, 28 March 2019, 11:50  | Thursday, 6 June 2019, 6:40    |
 | 
        
           |  |  | 65 |       | Student 2            | 0           | 0       | -                               | -                              |
 | 
        
           |  |  | 66 |       | Teacher 1            | 1           | 2       | Wednesday, 27 March 2019, 12:10 | Wednesday, 10 July 2019, 9:30  |
 | 
        
           |  |  | 67 |     And the following should not exist in the "forumreport_summary_table" table:
 | 
        
           |  |  | 68 |       | First name / Last name |
 | 
        
           |  |  | 69 |       | Student 3            |
 | 
        
           |  |  | 70 |     And the "Forum selected" select box should contain "All forums in course"
 | 
        
           |  |  | 71 |     And the "Forum selected" select box should contain "forum1"
 | 
        
           |  |  | 72 |     And the "Forum selected" select box should contain "forum2"
 | 
        
           |  |  | 73 |     And the "Forum selected" select box should contain "forum3"
 | 
        
           |  |  | 74 |     And the "Forum selected" select box should not contain "forum4"
 | 
        
           |  |  | 75 |     Then I select "All forums in course" from the "Forum selected" singleselect
 | 
        
           |  |  | 76 |     And I should not see "Export posts"
 | 
        
           |  |  | 77 |     And the following should exist in the "forumreport_summary_table" table:
 | 
        
           |  |  | 78 |     # |                      | Discussions | Replies |                                 |                                  |
 | 
        
           |  |  | 79 |       | First name / Last name | -3-         | -4-     | Earliest post                   | Most recent post                 |
 | 
        
           |  |  | 80 |       | Student 1            | 2           | 3       | Thursday, 25 January 2018, 4:40 | Saturday, 25 January 2020, 11:50 |
 | 
        
           |  |  | 81 |       | Student 2            | 0           | 0       | -                               | -                                |
 | 
        
           |  |  | 82 |       | Teacher 1            | 4           | 3       | Sunday, 14 January 2018, 9:00   | Thursday, 26 December 2019, 9:30 |
 | 
        
           |  |  | 83 |     And the following should not exist in the "forumreport_summary_table" table:
 | 
        
           |  |  | 84 |       | First name / Last name |
 | 
        
           |  |  | 85 |       | Student 3            |
 | 
        
           |  |  | 86 |   | 
        
           |  |  | 87 |   Scenario: Course forum summary report correctly formats forum activity names
 | 
        
           |  |  | 88 |     Given the "multilang" filter is "on"
 | 
        
           |  |  | 89 |     And the "multilang" filter applies to "content and headings"
 | 
        
           |  |  | 90 |     And the following "activity" exists:
 | 
        
           |  |  | 91 |       | activity | forum |
 | 
        
           |  |  | 92 |       | course   | C1    |
 | 
        
           |  |  | 93 |       | name     | <span class="multilang" lang="en">F-Eng</span><span class="multilang" lang="de">F-Ger</span> |
 | 
        
           |  |  | 94 |     When I am on the "C1" "Course" page logged in as "teacher1"
 | 
        
           |  |  | 95 |     And I follow "F-Eng"
 | 
        
           |  |  | 96 |     And I navigate to "Reports" in current page administration
 | 
        
           |  |  | 97 |     Then the "Forum selected" select box should contain "F-Eng"
 | 
        
           |  |  | 98 |   | 
        
           |  |  | 99 |   Scenario: Students given the view capability can view their own course report data
 | 
        
           |  |  | 100 |     Given the following "permission overrides" exist:
 | 
        
           |  |  | 101 |       | capability               | permission | role    | contextlevel | reference |
 | 
        
           |  |  | 102 |       | forumreport/summary:view | Allow      | student | Course       | C1        |
 | 
        
           |  |  | 103 |     When I am on the "forum1" "forum activity" page logged in as student1
 | 
        
           |  |  | 104 |     And I navigate to "Reports" in current page administration
 | 
        
           |  |  | 105 |     And the following should exist in the "forumreport_summary_table" table:
 | 
        
           |  |  | 106 |     # |                      | Discussions | Replies |                                 |                                 |
 | 
        
           |  |  | 107 |       | First name / Last name | -2-         | -3-     | Earliest post                   | Most recent post                |
 | 
        
           |  |  | 108 |       | Student 1            | 0           | 1       | Thursday, 25 January 2018, 4:40 | Thursday, 25 January 2018, 4:40 |
 | 
        
           |  |  | 109 |     And the following should not exist in the "forumreport_summary_table" table:
 | 
        
           |  |  | 110 |       | First name / Last name |
 | 
        
           |  |  | 111 |       | Student 2            |
 | 
        
           |  |  | 112 |       | Student 3            |
 | 
        
           |  |  | 113 |       | Teacher 1            |
 | 
        
           |  |  | 114 |     And the "Forum selected" select box should contain "All forums in course"
 | 
        
           |  |  | 115 |     And the "Forum selected" select box should contain "forum1"
 | 
        
           |  |  | 116 |     And the "Forum selected" select box should contain "forum2"
 | 
        
           |  |  | 117 |     And the "Forum selected" select box should contain "forum3"
 | 
        
           |  |  | 118 |     And the "Forum selected" select box should not contain "forum4"
 | 
        
           |  |  | 119 |     Then I select "All forums in course" from the "Forum selected" singleselect
 | 
        
           |  |  | 120 |     And the following should exist in the "forumreport_summary_table" table:
 | 
        
           |  |  | 121 |     # |                      | Discussions | Replies |                                 |                                  |
 | 
        
           |  |  | 122 |       | First name / Last name | -2-         | -3-     | Earliest post                   | Most recent post                 |
 | 
        
           |  |  | 123 |       | Student 1            | 2           | 3       | Thursday, 25 January 2018, 4:40 | Saturday, 25 January 2020, 11:50 |
 | 
        
           |  |  | 124 |     And the following should not exist in the "forumreport_summary_table" table:
 | 
        
           |  |  | 125 |       | First name / Last name |
 | 
        
           |  |  | 126 |       | Student 2            |
 | 
        
           |  |  | 127 |       | Student 3            |
 | 
        
           |  |  | 128 |       | Teacher 1            |
 |