| 1 | efrain | 1 | @mod @mod_assign @javascript
 | 
        
           |  |  | 2 | Feature: Set availability dates for an assignment
 | 
        
           |  |  | 3 |   In order to control when a student can upload an assignment
 | 
        
           |  |  | 4 |   As a teacher
 | 
        
           |  |  | 5 |   I need be able to set availability dates for an assignment
 | 
        
           |  |  | 6 |   | 
        
           |  |  | 7 |   Background:
 | 
        
           |  |  | 8 |     Given I log in as "admin"
 | 
        
           |  |  | 9 |     And I set the following administration settings values:
 | 
        
           |  |  | 10 |       | Enable timed assignments | 1 |
 | 
        
           |  |  | 11 |     And the following "courses" exist:
 | 
        
           |  |  | 12 |       | fullname | shortname |
 | 
        
           |  |  | 13 |       | Course 1 | C1        |
 | 
        
           |  |  | 14 |     And the following "users" exist:
 | 
        
           |  |  | 15 |       | username | firstname | lastname | email                |
 | 
        
           |  |  | 16 |       | teacher1 | Teacher   | 1        | teacher1@example.com |
 | 
        
           |  |  | 17 |       | student1 | Student   | 1        | student1@example.com |
 | 
        
           |  |  | 18 |       | student2 | Student   | 2        | student2@example.com |
 | 
        
           |  |  | 19 |     And the following "course enrolments" exist:
 | 
        
           |  |  | 20 |       | user     | course | role           |
 | 
        
           |  |  | 21 |       | teacher1 | C1     | editingteacher |
 | 
        
           |  |  | 22 |       | student1 | C1     | student        |
 | 
        
           |  |  | 23 |       | student2 | C1     | student        |
 | 
        
           |  |  | 24 |     And the following "activity" exists:
 | 
        
           |  |  | 25 |       | activity                           | assign                 |
 | 
        
           |  |  | 26 |       | course                             | C1                     |
 | 
        
           |  |  | 27 |       | name                               | Assignment name        |
 | 
        
           |  |  | 28 |       | description                        | Assignment description |
 | 
        
           |  |  | 29 |       | assignsubmission_file_enabled      | 1                      |
 | 
        
           |  |  | 30 |       | assignsubmission_file_maxfiles     | 1                      |
 | 
        
           |  |  | 31 |       | assignsubmission_file_maxsizebytes | 0                      |
 | 
        
           |  |  | 32 |       | submissiondrafts                   | 0                      |
 | 
        
           |  |  | 33 |     Given the following "activity" exists:
 | 
        
           |  |  | 34 |       | activity                            | assign                               |
 | 
        
           |  |  | 35 |       | course                              | C1                                   |
 | 
        
           |  |  | 36 |       | name                                | Test late assignment with time limit |
 | 
        
           |  |  | 37 |       | assignsubmission_onlinetext_enabled | 1                                    |
 | 
        
           |  |  | 38 |       | assignsubmission_file_enabled       | 1                                    |
 | 
        
           |  |  | 39 |       | assignsubmission_file_maxfiles      | 1                                    |
 | 
        
           |  |  | 40 |       | assignsubmission_file_maxsizebytes  | 1000000                              |
 | 
        
           |  |  | 41 |       | submissiondrafts                    | 0                                    |
 | 
        
           |  |  | 42 |       | allowsubmissionsfromdate_enabled    | 0                                    |
 | 
        
           |  |  | 43 |       | duedate_enabled                     | 0                                    |
 | 
        
           |  |  | 44 |       | cutoffdate_enabled                  | 0                                    |
 | 
        
           |  |  | 45 |       | gradingduedate_enabled              | 0                                    |
 | 
        
           |  |  | 46 |   | 
        
           |  |  | 47 |   Scenario: Student cannot submit an assignment prior to the 'allow submissions from' date
 | 
        
           |  |  | 48 |     Given I am on the "Assignment name" Activity page logged in as teacher1
 | 
        
           |  |  | 49 |     And I navigate to "Settings" in current page administration
 | 
        
           |  |  | 50 |     And I click on "Expand all" "link" in the "region-main" "region"
 | 
        
           |  |  | 51 |     # Set 'Allow submissions from' to tomorrow at noon.
 | 
        
           |  |  | 52 |     And I set the field "Allow submissions from" to "##tomorrow noon##"
 | 
        
           |  |  | 53 |     And I press "Save and return to course"
 | 
        
           |  |  | 54 |     And I log out
 | 
        
           |  |  | 55 |   | 
        
           |  |  | 56 |     When I am on the "Assignment name" Activity page logged in as student1
 | 
        
           |  |  | 57 |     Then "Add submission" "button" should not exist
 | 
        
           |  |  | 58 |     And the activity date in "Assignment name" should contain "Opens:"
 | 
        
           |  |  | 59 |     And the activity date in "Assignment name" should contain "##tomorrow noon##%A, %d %B %Y, %I:%M##"
 | 
        
           |  |  | 60 |   | 
        
           |  |  | 61 |   Scenario: Student can see the assignment's due date in the course calendar
 | 
        
           |  |  | 62 |     Given the following "activity" exists:
 | 
        
           |  |  | 63 |       | activity                            | assign                                     |
 | 
        
           |  |  | 64 |       | course                              | C1                                         |
 | 
        
           |  |  | 65 |       | name                                | Assignment name                            |
 | 
        
           |  |  | 66 |       | assignsubmission_onlinetext_enabled | 1                                          |
 | 
        
           |  |  | 67 |       | assignsubmission_file_enabled       | 0                                          |
 | 
        
           |  |  | 68 |       | submissiondrafts                    | 0                                          |
 | 
        
           |  |  | 69 |       | allowsubmissionsfromdate            | ##first day of this month noon##           |
 | 
        
           |  |  | 70 |       | duedate                             | ##first day of this month noon +24 hours## |
 | 
        
           |  |  | 71 |     And the following "blocks" exist:
 | 
        
           |  |  | 72 |       | blockname      | contextlevel | reference | pagetypepattern | defaultregion |
 | 
        
           |  |  | 73 |       | calendar_month | Course       | C1        | course-view-*   | site-post     |
 | 
        
           |  |  | 74 |     When I am on the "C1" Course page logged in as student1
 | 
        
           |  |  | 75 |     And I hover over day "2" of this month in the mini-calendar block
 | 
        
           |  |  | 76 |     Then I should see "Assignment name is due"
 | 
        
           |  |  | 77 |   | 
        
           |  |  | 78 |   @_file_upload
 | 
        
           |  |  | 79 |   Scenario: Student can submit an assignment before the due date
 | 
        
           |  |  | 80 |     Given I am on the "Assignment name" Activity page logged in as teacher1
 | 
        
           |  |  | 81 |     And I navigate to "Settings" in current page administration
 | 
        
           |  |  | 82 |     And I click on "Expand all" "link" in the "region-main" "region"
 | 
        
           |  |  | 83 |     # Set 'Allow submissions from' to now.
 | 
        
           |  |  | 84 |     And I set the field "Allow submissions from" to "##now##"
 | 
        
           |  |  | 85 |     # Set 'Due date' to 2 days 5 hours 30 minutes in the future.
 | 
        
           |  |  | 86 |     And I set the field "Due date" to "##+2 days 5 hours 30 minutes##"
 | 
        
           |  |  | 87 |     And I press "Save and return to course"
 | 
        
           |  |  | 88 |     And I log out
 | 
        
           |  |  | 89 |   | 
        
           |  |  | 90 |     When I am on the "Assignment name" Activity page logged in as student1
 | 
        
           |  |  | 91 |     And the activity date in "Assignment name" should contain "Due:"
 | 
        
           |  |  | 92 |     And the activity date in "Assignment name" should contain "##+2 days 5 hours 30 minutes##%A, %d %B %Y##"
 | 
        
           |  |  | 93 |     And I should see "2 days 5 hours" in the "Time remaining" "table_row"
 | 
        
           |  |  | 94 |     And "Add submission" "button" should exist
 | 
        
           |  |  | 95 |     And I press "Add submission"
 | 
        
           |  |  | 96 |     And I upload "lib/tests/fixtures/empty.txt" file to "File submissions" filemanager
 | 
        
           |  |  | 97 |     When I press "Save changes"
 | 
        
           |  |  | 98 |     Then I should see "Submitted for grading" in the "Submission status" "table_row"
 | 
        
           |  |  | 99 |     And I log out
 | 
        
           |  |  | 100 |   | 
        
           |  |  | 101 |     And I am on the "Assignment name" Activity page logged in as teacher1
 | 
        
           |  |  | 102 |     And I should see "1" in the "Submitted" "table_row"
 | 
        
           | 1441 | ariadna | 103 |     And I navigate to "Submissions" in current page administration
 | 
        
           | 1 | efrain | 104 |     And I should see "Submitted for grading" in the "Student 1" "table_row"
 | 
        
           |  |  | 105 |   | 
        
           |  |  | 106 |   @_file_upload
 | 
        
           |  |  | 107 |   Scenario: Student can submit an assignment after the due date and the submission is marked as late
 | 
        
           |  |  | 108 |     Given I am on the "Assignment name" Activity page logged in as teacher1
 | 
        
           |  |  | 109 |     And I navigate to "Settings" in current page administration
 | 
        
           |  |  | 110 |     And I click on "Expand all" "link" in the "region-main" "region"
 | 
        
           |  |  | 111 |     # Set 'Allow submissions from' to 3 days ago.
 | 
        
           |  |  | 112 |     And I set the field "Allow submissions from" to "##3 days ago##"
 | 
        
           |  |  | 113 |     # Set 'Due date' to 2 days 5 hours 30 minutes ago.
 | 
        
           |  |  | 114 |     And I set the field "Due date" to "##2 days 5 hours 30 minutes ago##"
 | 
        
           |  |  | 115 |     # Set 'Cut-off date' to tomorrow at noon.
 | 
        
           |  |  | 116 |     And I set the field "Cut-off date" to "##tomorrow noon##"
 | 
        
           |  |  | 117 |     And I press "Save and return to course"
 | 
        
           |  |  | 118 |     And I log out
 | 
        
           |  |  | 119 |   | 
        
           |  |  | 120 |     And I am on the "Assignment name" Activity page logged in as student1
 | 
        
           |  |  | 121 |     And the activity date in "Assignment name" should contain "Due:"
 | 
        
           |  |  | 122 |     And the activity date in "Assignment name" should contain "##2 days 5 hours 30 minutes ago##%A, %d %B %Y##"
 | 
        
           |  |  | 123 |     And I should see "Assignment is overdue by: 2 days 5 hours" in the "Time remaining" "table_row"
 | 
        
           |  |  | 124 |     And "Add submission" "button" should exist
 | 
        
           |  |  | 125 |     And I press "Add submission"
 | 
        
           |  |  | 126 |     And I upload "lib/tests/fixtures/empty.txt" file to "File submissions" filemanager
 | 
        
           |  |  | 127 |     When I press "Save changes"
 | 
        
           |  |  | 128 |     Then I should see "Submitted for grading" in the "Submission status" "table_row"
 | 
        
           |  |  | 129 |     And I should see "Assignment was submitted 2 days 5 hours late" in the "Time remaining" "table_row"
 | 
        
           |  |  | 130 |     And I log out
 | 
        
           |  |  | 131 |   | 
        
           |  |  | 132 |     And I am on the "Assignment name" Activity page logged in as teacher1
 | 
        
           |  |  | 133 |     And I should see "1" in the "Submitted" "table_row"
 | 
        
           | 1441 | ariadna | 134 |     And I navigate to "Submissions" in current page administration
 | 
        
           | 1 | efrain | 135 |     And I should see "Submitted for grading" in the "Student 1" "table_row"
 | 
        
           |  |  | 136 |     And I should see "2 days 5 hours late" in the "Student 1" "table_row"
 | 
        
           |  |  | 137 |   | 
        
           |  |  | 138 |   @_file_upload
 | 
        
           |  |  | 139 |   Scenario: Student can submit an assignment before the time limit runs out
 | 
        
           |  |  | 140 |     Given I log in as "admin"
 | 
        
           |  |  | 141 |     And I change the window size to "large"
 | 
        
           |  |  | 142 |     And I set the following administration settings values:
 | 
        
           |  |  | 143 |       | Enable timed assignments | 1  |
 | 
        
           |  |  | 144 |     And I log out
 | 
        
           |  |  | 145 |     And I am on the "Assignment name" Activity page logged in as teacher1
 | 
        
           |  |  | 146 |     And I navigate to "Settings" in current page administration
 | 
        
           |  |  | 147 |     And I click on "Expand all" "link" in the "region-main" "region"
 | 
        
           |  |  | 148 |     # Set 'Time limit' to 20 seconds.
 | 
        
           |  |  | 149 |     And I set the field "timelimit[enabled]" to "1"
 | 
        
           |  |  | 150 |     And I set the field "timelimit[number]" to "20"
 | 
        
           |  |  | 151 |     And I set the field "timelimit[timeunit]" to "seconds"
 | 
        
           |  |  | 152 |     And I press "Save and return to course"
 | 
        
           |  |  | 153 |     And I log out
 | 
        
           |  |  | 154 |   | 
        
           |  |  | 155 |     When I am on the "Assignment name" Activity page logged in as student1
 | 
        
           |  |  | 156 |     And I should see "20 secs" in the "Time limit" "table_row"
 | 
        
           |  |  | 157 |     And "Begin assignment" "link" should exist
 | 
        
           |  |  | 158 |     And I follow "Begin assignment"
 | 
        
           |  |  | 159 |     And I wait "1" seconds
 | 
        
           |  |  | 160 |     And "Begin assignment" "button" should exist
 | 
        
           |  |  | 161 |     And I press "Begin assignment"
 | 
        
           |  |  | 162 |     And I upload "lib/tests/fixtures/empty.txt" file to "File submissions" filemanager
 | 
        
           |  |  | 163 |     When I press "Save changes"
 | 
        
           |  |  | 164 |     Then I should see "Submitted for grading" in the "Submission status" "table_row"
 | 
        
           |  |  | 165 |     And I should see "secs under the time limit" in the "Time remaining" "table_row"
 | 
        
           |  |  | 166 |   | 
        
           |  |  | 167 |   @_file_upload
 | 
        
           |  |  | 168 |   Scenario: Assignment with time limit and due date shows how late assignment is submitted relative to due date
 | 
        
           |  |  | 169 |     Given I log in as "admin"
 | 
        
           |  |  | 170 |     And I change the window size to "large"
 | 
        
           |  |  | 171 |     And I set the following administration settings values:
 | 
        
           |  |  | 172 |       | Enable timed assignments | 1  |
 | 
        
           |  |  | 173 |     And I log out
 | 
        
           |  |  | 174 |     And I am on the "Assignment name" Activity page logged in as teacher1
 | 
        
           |  |  | 175 |     And I navigate to "Settings" in current page administration
 | 
        
           |  |  | 176 |     And I click on "Expand all" "link" in the "region-main" "region"
 | 
        
           |  |  | 177 |     # Set 'Time limit' to 5 seconds.
 | 
        
           |  |  | 178 |     And I set the field "timelimit[enabled]" to "1"
 | 
        
           |  |  | 179 |     And I set the field "timelimit[number]" to "5"
 | 
        
           |  |  | 180 |     And I set the field "timelimit[timeunit]" to "seconds"
 | 
        
           |  |  | 181 |     # Set 'Due date' to 2 days 5 hours 30 minutes ago.
 | 
        
           |  |  | 182 |     And I set the field "Due date" to "##2 days 5 hours 30 minutes ago##"
 | 
        
           |  |  | 183 |     And I press "Save and display"
 | 
        
           |  |  | 184 |     And I should see "5 secs" in the "Time limit" "table_row"
 | 
        
           |  |  | 185 |     And I log out
 | 
        
           |  |  | 186 |   | 
        
           |  |  | 187 |     When I am on the "Assignment name" Activity page logged in as student1
 | 
        
           |  |  | 188 |     And "Begin assignment" "link" should exist
 | 
        
           |  |  | 189 |     And I follow "Begin assignment"
 | 
        
           |  |  | 190 |     And I wait "1" seconds
 | 
        
           |  |  | 191 |     And "Begin assignment" "button" should exist
 | 
        
           |  |  | 192 |     And I press "Begin assignment"
 | 
        
           |  |  | 193 |     And I wait "5" seconds
 | 
        
           |  |  | 194 |     And I upload "lib/tests/fixtures/empty.txt" file to "File submissions" filemanager
 | 
        
           |  |  | 195 |     When I press "Save changes"
 | 
        
           |  |  | 196 |     Then I should see "Assignment was submitted 2 days 5 hours late" in the "Time remaining" "table_row"
 | 
        
           |  |  | 197 |   | 
        
           |  |  | 198 |   Scenario: Student cannot submit an assignment after the cut-off date
 | 
        
           |  |  | 199 |     Given I am on the "Assignment name" Activity page logged in as teacher1
 | 
        
           |  |  | 200 |     And I navigate to "Settings" in current page administration
 | 
        
           |  |  | 201 |     And I click on "Expand all" "link" in the "region-main" "region"
 | 
        
           |  |  | 202 |     # Set 'Allow submissions from' to 3 days ago.
 | 
        
           |  |  | 203 |     And I set the field "Allow submissions from" to "##3 days ago##"
 | 
        
           |  |  | 204 |     # Set 'Due date' to 2 days 5 hours 30 minutes ago.
 | 
        
           |  |  | 205 |     And I set the field "Due date" to "##2 days 5 hours 30 minutes ago##"
 | 
        
           |  |  | 206 |     # Set 'Cut-off date' to yesterday at noon.
 | 
        
           |  |  | 207 |     And I set the field "Cut-off date" to "##yesterday noon##"
 | 
        
           |  |  | 208 |     And I press "Save and return to course"
 | 
        
           |  |  | 209 |     And I log out
 | 
        
           |  |  | 210 |   | 
        
           |  |  | 211 |     When I am on the "Assignment name" Activity page logged in as student1
 | 
        
           |  |  | 212 |     Then "Add submission" "button" should not exist
 | 
        
           |  |  | 213 |     And I log out
 | 
        
           |  |  | 214 |   | 
        
           |  |  | 215 |     And I am on the "Assignment name" Activity page logged in as teacher1
 | 
        
           |  |  | 216 |     And I should see "0" in the "Submitted" "table_row"
 | 
        
           | 1441 | ariadna | 217 |     And I navigate to "Submissions" in current page administration
 | 
        
           | 1 | efrain | 218 |     And I should see "No submission" in the "Student 1" "table_row"
 | 
        
           |  |  | 219 |     And I should see "Assignment is overdue by: 2 days 5 hours" in the "Student 1" "table_row"
 | 
        
           |  |  | 220 |   | 
        
           |  |  | 221 |   @_file_upload
 | 
        
           |  |  | 222 |   Scenario: Late submission will be calculated only when the student starts the assignment
 | 
        
           |  |  | 223 |     Given I am on the "Test late assignment with time limit" Activity page logged in as admin
 | 
        
           |  |  | 224 |     And I navigate to "Settings" in current page administration
 | 
        
           |  |  | 225 |     And I click on "Expand all" "link" in the "region-main" "region"
 | 
        
           |  |  | 226 |     # Set 'Time limit' to 5 seconds.
 | 
        
           |  |  | 227 |     And I set the field "timelimit[enabled]" to "1"
 | 
        
           |  |  | 228 |     And I set the field "timelimit[number]" to "5"
 | 
        
           |  |  | 229 |     And I set the field "timelimit[timeunit]" to "seconds"
 | 
        
           |  |  | 230 |     And I press "Save and return to course"
 | 
        
           |  |  | 231 |     When I am on the "Test late assignment with time limit" Activity page logged in as student1
 | 
        
           |  |  | 232 |     And I wait "6" seconds
 | 
        
           |  |  | 233 |     And I click on "Begin assignment" "link"
 | 
        
           |  |  | 234 |     And I click on "Begin assignment" "button"
 | 
        
           |  |  | 235 |     And I upload "lib/tests/fixtures/empty.txt" file to "File submissions" filemanager
 | 
        
           |  |  | 236 |     And I press "Save changes"
 | 
        
           |  |  | 237 |     Then I should see "Submitted for grading" in the "Submission status" "table_row"
 | 
        
           |  |  | 238 |     And I should see "under the time limit" in the "Time remaining" "table_row"
 |