Skip to content

Commit 40bf6fc

Browse files
committed
MDL-77581 behat: Apply new lesson generators to existing tests
1 parent 6e979a8 commit 40bf6fc

31 files changed

+525
-1154
lines changed

lib/form/tests/behat/graderescale_for_lesson_pointscale.feature

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,13 @@ Feature: Using the lesson activities which support point scale
2424

2525
@javascript
2626
Scenario: Lesson rescale grade should not be possible when users are graded
27-
Given I am on the "Test lesson name" "lesson activity" page logged in as teacher1
28-
And I follow "Add a question page"
29-
And I set the field "Select a question type" to "Numerical"
30-
And I press "Add a question page"
31-
And I set the following fields to these values:
32-
| Page title | Numerical question |
33-
| Page contents | What is 1 + 2? |
34-
| id_answer_editor_0 | 3 |
35-
| id_jumpto_0 | End of lesson |
36-
| id_enableotheranswers | 1 |
37-
| id_jumpto_6 | Next page |
38-
And I press "Save page"
27+
Given the following "mod_lesson > page" exist:
28+
| lesson | qtype | title | content |
29+
| Test lesson name | numeric | Numerical question | What is 1 + 2? |
30+
And the following "mod_lesson > answers" exist:
31+
| page | answer | jumpto | score |
32+
| Numerical question | 3 | End of lesson | 1 |
33+
| Numerical question | @#wronganswer#@ | Next page | 0 |
3934
And I am on the "Test lesson name" "lesson activity" page logged in as student1
4035
And I set the field "Your answer" to "5"
4136
And I press "Submit"

mod/lesson/tests/behat/completion_condition_end_reached.feature

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,24 @@ Feature: Set end of lesson reached as a completion condition for a lesson
1010
| student1 | Student | 1 | student1@example.com |
1111
| teacher1 | Teacher | 1 | teacher1@example.com |
1212
And the following "courses" exist:
13-
| fullname | shortname | category |
14-
| Course 1 | C1 | 0 |
13+
| fullname | shortname | category | enablecompletion |
14+
| Course 1 | C1 | 0 | 1 |
1515
And the following "course enrolments" exist:
1616
| user | course | role |
1717
| teacher1 | C1 | editingteacher |
1818
| student1 | C1 | student |
19-
Given the following "activity" exists:
20-
| activity | lesson |
21-
| course | C1 |
22-
| idnumber | 0001 |
23-
| name | Test lesson |
24-
And I log in as "teacher1"
25-
And I am on "Course 1" course homepage with editing mode on
26-
And I navigate to "Settings" in current page administration
27-
And I set the following fields to these values:
28-
| Enable completion tracking | Yes |
29-
And I press "Save and display"
30-
And I am on the "Test lesson" "lesson activity editing" page
31-
And I set the following fields to these values:
32-
| Completion tracking | Show activity as complete when conditions are met |
33-
| completionview | 0 |
34-
| completionendreached | 1 |
35-
And I press "Save and display"
36-
And I follow "Add a content page"
37-
And I set the following fields to these values:
38-
| Page title | First page name |
39-
| Page contents | First page contents |
40-
| id_answer_editor_0 | Next page |
41-
| id_jumpto_0 | Next page |
42-
And I press "Save page"
43-
And I select "Add a content page" from the "qtype" singleselect
44-
And I set the following fields to these values:
45-
| Page title | Second page name |
46-
| Page contents | Second page contents |
47-
| id_answer_editor_0 | Previous page |
48-
| id_jumpto_0 | Previous page |
49-
| id_answer_editor_1 | Next page |
50-
| id_jumpto_1 | Next page |
51-
And I press "Save page"
19+
And the following "activity" exist:
20+
| activity | name | course | idnumber | completion | completionview | completionendreached |
21+
| lesson | Test lesson | C1 | 0001 | 2 | 0 | 1 |
22+
And the following "mod_lesson > page" exist:
23+
| lesson | qtype | title | content |
24+
| Test lesson | content | First page name | First page contents |
25+
| Test lesson | content | Second page name | Second page contents |
26+
And the following "mod_lesson > answer" exist:
27+
| page | answer | jumpto |
28+
| First page name | Next page | Next page |
29+
| Second page name | Previous page | Previous page |
30+
| Second page name | Next page | Next page |
5231
When I am on the "Course 1" course page logged in as student1
5332
Then the "Go through the activity to the end" completion condition of "Test lesson" is displayed as "todo"
5433
And I follow "Test lesson"

mod/lesson/tests/behat/completion_condition_time_spent.feature

Lines changed: 21 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,29 @@ Feature: Set time spent as a completion condition for a lesson
66

77
Scenario: Set time spent as a condition
88
Given the following "users" exist:
9-
| username | firstname | lastname | email |
10-
| student1 | Student | 1 | student1@example.com |
11-
| teacher1 | Teacher | 1 | teacher1@example.com |
9+
| username | firstname | lastname | email |
10+
| student1 | Student | 1 | student1@example.com |
11+
| teacher1 | Teacher | 1 | teacher1@example.com |
1212
And the following "courses" exist:
13-
| fullname | shortname | category |
14-
| Course 1 | C1 | 0 |
13+
| fullname | shortname | category | enablecompletion |
14+
| Course 1 | C1 | 0 | 1 |
1515
And the following "course enrolments" exist:
16-
| user | course | role |
17-
| teacher1 | C1 | editingteacher |
18-
| student1 | C1 | student |
19-
And the following "activity" exists:
20-
| activity | lesson |
21-
| course | C1 |
22-
| idnumber | 0001 |
23-
| name | Test lesson |
24-
And I am on the "Course 1" course page logged in as teacher1
25-
And I navigate to "Settings" in current page administration
26-
And I set the following fields to these values:
27-
| Enable completion tracking | Yes |
28-
And I press "Save and display"
29-
And I am on the "Test lesson" "lesson activity editing" page
30-
And I set the following fields to these values:
31-
| Completion tracking | Show activity as complete when conditions are met |
32-
| completionview | 0 |
33-
| completiontimespentenabled | 1 |
34-
| completiontimespent[timeunit] | 1 |
35-
| completiontimespent[number] | 5 |
36-
And I press "Save and display"
37-
And I follow "Add a content page"
38-
And I set the following fields to these values:
39-
| Page title | First page name |
40-
| Page contents | First page contents |
41-
| id_answer_editor_0 | Next page |
42-
| id_jumpto_0 | Next page |
43-
And I press "Save page"
44-
And I select "Add a content page" from the "qtype" singleselect
45-
And I set the following fields to these values:
46-
| Page title | Second page name |
47-
| Page contents | Second page contents |
48-
| id_answer_editor_0 | Previous page |
49-
| id_jumpto_0 | Previous page |
50-
| id_answer_editor_1 | Next page |
51-
| id_jumpto_1 | Next page |
52-
And I press "Save page"
16+
| user | course | role |
17+
| teacher1 | C1 | editingteacher |
18+
| student1 | C1 | student |
19+
And the following "activity" exist:
20+
| activity | name | course | idnumber | completion | completionview | completiontimespentenabled | completiontimespent |
21+
| lesson | Test lesson | C1 | 0001 | 2 | 0 | 1 | 5 |
22+
And the following "mod_lesson > pages" exist:
23+
| lesson | qtype | title | content |
24+
| Test lesson | content | First page name | First page contents |
25+
| Test lesson | content | Second page name | Second page contents |
26+
And the following "mod_lesson > answer" exist:
27+
| page | answer | jumpto |
28+
| First page name | Next page | Next page |
29+
| Second page name | Previous page | Previous page |
30+
| Second page name | Next page | Next page |
31+
5332
When I am on the "Course 1" course page logged in as student1
5433
Then the "Spend at least 5 secs on this activity" completion condition of "Test lesson" is displayed as "todo"
5534
And I follow "Test lesson"

mod/lesson/tests/behat/date_availability.feature

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ Feature: A teacher can set available from and deadline dates to access a lesson
1919
And the following "activities" exist:
2020
| activity | name | course | idnumber |
2121
| lesson | Test lesson | C1 | lesson1 |
22-
And I log in as "teacher1"
23-
And I am on "Course 1" course homepage with editing mode on
22+
And the following "mod_lesson > page" exist:
23+
| lesson | qtype | title | content |
24+
| Test lesson | content | First page name | First page contents |
25+
And the following "mod_lesson > answer" exist:
26+
| page | answer | jumpto |
27+
| First page name | Next page | Next page |
2428

2529
Scenario: Forbidding lesson accesses until a specified date
26-
Given I am on the "Test lesson" "lesson activity editing" page
30+
Given I am on the "Test lesson" "lesson activity editing" page logged in as teacher1
2731
And I set the field "id_available_enabled" to "1"
2832
And I set the following fields to these values:
2933
| available[day] | 1 |
@@ -32,18 +36,12 @@ Feature: A teacher can set available from and deadline dates to access a lesson
3236
| available[hour] | 08 |
3337
| available[minute] | 00 |
3438
And I press "Save and display"
35-
And I follow "Add a content page"
36-
And I set the following fields to these values:
37-
| Page title | First page name |
38-
| Page contents | First page contents |
39-
| Description | The first one |
40-
And I press "Save page"
4139
When I am on the "Test lesson" "lesson activity" page logged in as student1
4240
Then the activity date in "Test lesson" should contain "Opens: Tuesday, 1 January 2030, 8:00"
4341
And I should not see "First page contents"
4442

4543
Scenario: Forbidding lesson accesses after a specified date
46-
Given I am on the "Test lesson" "lesson activity editing" page
44+
Given I am on the "Test lesson" "lesson activity editing" page logged in as teacher1
4745
And I set the field "id_deadline_enabled" to "1"
4846
And I set the following fields to these values:
4947
| deadline[day] | 1 |
@@ -52,12 +50,6 @@ Feature: A teacher can set available from and deadline dates to access a lesson
5250
| deadline[hour] | 08 |
5351
| deadline[minute] | 00 |
5452
And I press "Save and display"
55-
And I follow "Add a content page"
56-
And I set the following fields to these values:
57-
| Page title | First page name |
58-
| Page contents | First page contents |
59-
| Description | The first one |
60-
And I press "Save page"
6153
When I am on the "Test lesson" "lesson activity" page logged in as student1
6254
Then the activity date in "Test lesson" should contain "Closed: Saturday, 1 January 2000, 8:00"
6355
And I should not see "First page contents"

mod/lesson/tests/behat/display_lesson_description.feature

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,22 @@ Feature: Display the lesson description in the lesson and optionally in the cour
1414
And the following "course enrolments" exist:
1515
| user | course | role |
1616
| teacher1 | C1 | editingteacher |
17-
Given the following "activity" exists:
18-
| activity | lesson |
19-
| course | C1 |
20-
| idnumber | 0001 |
21-
| name | Test lesson name |
22-
| intro | Test lesson description |
23-
And I am on the "Test lesson name" "lesson activity" page logged in as teacher1
24-
And I follow "Add a content page"
25-
And I set the following fields to these values:
26-
| Page title | Test lesson part 1 |
27-
| Description | Lesson part 1 description |
28-
| Jump | Next page |
29-
And I click on "Save page" "button"
17+
And the following "activity" exist:
18+
| activity | name | intro | course | idnumber |
19+
| lesson | Test lesson name | Test lesson description | C1 | 0001 |
20+
And the following "mod_lesson > page" exist:
21+
| lesson | qtype | title | content |
22+
| Test lesson name | content | Test lesson part 1 | Test lesson part 1 |
23+
And the following "mod_lesson > answer" exist:
24+
| page | answer | jumpto |
25+
| Test lesson part 1 | Next page | Next page |
3026

3127
Scenario: Description is displayed in the Lesson
32-
When I am on the "Test lesson name" "lesson activity" page
28+
When I am on the "Test lesson name" "lesson activity" page logged in as teacher1
3329
Then I should see "Test lesson description"
3430

3531
Scenario: Show lesson description in the course homepage
36-
Given I am on the "Test lesson name" "lesson activity editing" page
32+
Given I am on the "Test lesson name" "lesson activity editing" page logged in as teacher1
3733
And the following fields match these values:
3834
| Display description on course page | |
3935
And I set the following fields to these values:
@@ -43,7 +39,7 @@ Feature: Display the lesson description in the lesson and optionally in the cour
4339
Then I should see "Test lesson description"
4440

4541
Scenario: Hide lesson description in the course homepage
46-
Given I am on the "Test lesson name" "lesson activity editing" page
42+
Given I am on the "Test lesson name" "lesson activity editing" page logged in as teacher1
4743
And the following fields match these values:
4844
| Display description on course page | |
4945
And I press "Save and return to course"

mod/lesson/tests/behat/lesson_activity_completion.feature

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,14 @@ Feature: View activity completion in the lesson activity
2828
| completionendreached | 1 |
2929
| completiontimespentenabled | 1 |
3030
| completiontimespent | 3 |
31-
And I am on the "Music history" "lesson activity" page logged in as teacher1
32-
And I follow "Add a content page"
33-
And I set the following fields to these values:
34-
| Page title | Music history part 1 |
35-
| Description | The history of music part 1 |
36-
| Jump | Next page |
37-
And I click on "Save page" "button"
38-
And I select "Add a question page" from the "qtype" singleselect
39-
And I set the field "Select a question type" to "Essay"
40-
And I press "Add a question page"
41-
And I set the following fields to these values:
42-
| Page title | Music essay |
43-
| Page contents | Write a really interesting music essay |
44-
| Jump | End of lesson |
45-
| Score | 1 |
46-
And I press "Save page"
31+
And the following "mod_lesson > page" exist:
32+
| lesson | qtype | title | content |
33+
| Music history | content | Music history part 1 | |
34+
| Music history | essay | Music essay | Write a really interesting music essay |
35+
And the following "mod_lesson > answer" exist:
36+
| page | answer | jumpto | score |
37+
| Music history part 1 | The history of music part 1 | Next page | 0 |
38+
| Music essay | | Next page | 1 |
4739

4840
Scenario: View automatic completion items as a teacher
4941
When I am on the "Music history" "lesson activity" page logged in as teacher1

0 commit comments

Comments
 (0)