Skip to content

Commit

Permalink
MDL-77581 behat: Apply new lesson generators to existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dpalou committed Nov 9, 2023
1 parent 6e979a8 commit 40bf6fc
Show file tree
Hide file tree
Showing 31 changed files with 525 additions and 1,154 deletions.
19 changes: 7 additions & 12 deletions lib/form/tests/behat/graderescale_for_lesson_pointscale.feature
Expand Up @@ -24,18 +24,13 @@ Feature: Using the lesson activities which support point scale

@javascript
Scenario: Lesson rescale grade should not be possible when users are graded
Given I am on the "Test lesson name" "lesson activity" page logged in as teacher1
And I follow "Add a question page"
And I set the field "Select a question type" to "Numerical"
And I press "Add a question page"
And I set the following fields to these values:
| Page title | Numerical question |
| Page contents | What is 1 + 2? |
| id_answer_editor_0 | 3 |
| id_jumpto_0 | End of lesson |
| id_enableotheranswers | 1 |
| id_jumpto_6 | Next page |
And I press "Save page"
Given the following "mod_lesson > page" exist:
| lesson | qtype | title | content |
| Test lesson name | numeric | Numerical question | What is 1 + 2? |
And the following "mod_lesson > answers" exist:
| page | answer | jumpto | score |
| Numerical question | 3 | End of lesson | 1 |
| Numerical question | @#wronganswer#@ | Next page | 0 |
And I am on the "Test lesson name" "lesson activity" page logged in as student1
And I set the field "Your answer" to "5"
And I press "Submit"
Expand Down
49 changes: 14 additions & 35 deletions mod/lesson/tests/behat/completion_condition_end_reached.feature
Expand Up @@ -10,45 +10,24 @@ Feature: Set end of lesson reached as a completion condition for a lesson
| student1 | Student | 1 | student1@example.com |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
| fullname | shortname | category | enablecompletion |
| Course 1 | C1 | 0 | 1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
Given the following "activity" exists:
| activity | lesson |
| course | C1 |
| idnumber | 0001 |
| name | Test lesson |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| Enable completion tracking | Yes |
And I press "Save and display"
And I am on the "Test lesson" "lesson activity editing" page
And I set the following fields to these values:
| Completion tracking | Show activity as complete when conditions are met |
| completionview | 0 |
| completionendreached | 1 |
And I press "Save and display"
And I follow "Add a content page"
And I set the following fields to these values:
| Page title | First page name |
| Page contents | First page contents |
| id_answer_editor_0 | Next page |
| id_jumpto_0 | Next page |
And I press "Save page"
And I select "Add a content page" from the "qtype" singleselect
And I set the following fields to these values:
| Page title | Second page name |
| Page contents | Second page contents |
| id_answer_editor_0 | Previous page |
| id_jumpto_0 | Previous page |
| id_answer_editor_1 | Next page |
| id_jumpto_1 | Next page |
And I press "Save page"
And the following "activity" exist:
| activity | name | course | idnumber | completion | completionview | completionendreached |
| lesson | Test lesson | C1 | 0001 | 2 | 0 | 1 |
And the following "mod_lesson > page" exist:
| lesson | qtype | title | content |
| Test lesson | content | First page name | First page contents |
| Test lesson | content | Second page name | Second page contents |
And the following "mod_lesson > answer" exist:
| page | answer | jumpto |
| First page name | Next page | Next page |
| Second page name | Previous page | Previous page |
| Second page name | Next page | Next page |
When I am on the "Course 1" course page logged in as student1
Then the "Go through the activity to the end" completion condition of "Test lesson" is displayed as "todo"
And I follow "Test lesson"
Expand Down
63 changes: 21 additions & 42 deletions mod/lesson/tests/behat/completion_condition_time_spent.feature
Expand Up @@ -6,50 +6,29 @@ Feature: Set time spent as a completion condition for a lesson

Scenario: Set time spent as a condition
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
| teacher1 | Teacher | 1 | teacher1@example.com |
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
| fullname | shortname | category | enablecompletion |
| Course 1 | C1 | 0 | 1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "activity" exists:
| activity | lesson |
| course | C1 |
| idnumber | 0001 |
| name | Test lesson |
And I am on the "Course 1" course page logged in as teacher1
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| Enable completion tracking | Yes |
And I press "Save and display"
And I am on the "Test lesson" "lesson activity editing" page
And I set the following fields to these values:
| Completion tracking | Show activity as complete when conditions are met |
| completionview | 0 |
| completiontimespentenabled | 1 |
| completiontimespent[timeunit] | 1 |
| completiontimespent[number] | 5 |
And I press "Save and display"
And I follow "Add a content page"
And I set the following fields to these values:
| Page title | First page name |
| Page contents | First page contents |
| id_answer_editor_0 | Next page |
| id_jumpto_0 | Next page |
And I press "Save page"
And I select "Add a content page" from the "qtype" singleselect
And I set the following fields to these values:
| Page title | Second page name |
| Page contents | Second page contents |
| id_answer_editor_0 | Previous page |
| id_jumpto_0 | Previous page |
| id_answer_editor_1 | Next page |
| id_jumpto_1 | Next page |
And I press "Save page"
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "activity" exist:
| activity | name | course | idnumber | completion | completionview | completiontimespentenabled | completiontimespent |
| lesson | Test lesson | C1 | 0001 | 2 | 0 | 1 | 5 |
And the following "mod_lesson > pages" exist:
| lesson | qtype | title | content |
| Test lesson | content | First page name | First page contents |
| Test lesson | content | Second page name | Second page contents |
And the following "mod_lesson > answer" exist:
| page | answer | jumpto |
| First page name | Next page | Next page |
| Second page name | Previous page | Previous page |
| Second page name | Next page | Next page |

When I am on the "Course 1" course page logged in as student1
Then the "Spend at least 5 secs on this activity" completion condition of "Test lesson" is displayed as "todo"
And I follow "Test lesson"
Expand Down
24 changes: 8 additions & 16 deletions mod/lesson/tests/behat/date_availability.feature
Expand Up @@ -19,11 +19,15 @@ Feature: A teacher can set available from and deadline dates to access a lesson
And the following "activities" exist:
| activity | name | course | idnumber |
| lesson | Test lesson | C1 | lesson1 |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And the following "mod_lesson > page" exist:
| lesson | qtype | title | content |
| Test lesson | content | First page name | First page contents |
And the following "mod_lesson > answer" exist:
| page | answer | jumpto |
| First page name | Next page | Next page |

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

Scenario: Forbidding lesson accesses after a specified date
Given I am on the "Test lesson" "lesson activity editing" page
Given I am on the "Test lesson" "lesson activity editing" page logged in as teacher1
And I set the field "id_deadline_enabled" to "1"
And I set the following fields to these values:
| deadline[day] | 1 |
Expand All @@ -52,12 +50,6 @@ Feature: A teacher can set available from and deadline dates to access a lesson
| deadline[hour] | 08 |
| deadline[minute] | 00 |
And I press "Save and display"
And I follow "Add a content page"
And I set the following fields to these values:
| Page title | First page name |
| Page contents | First page contents |
| Description | The first one |
And I press "Save page"
When I am on the "Test lesson" "lesson activity" page logged in as student1
Then the activity date in "Test lesson" should contain "Closed: Saturday, 1 January 2000, 8:00"
And I should not see "First page contents"
28 changes: 12 additions & 16 deletions mod/lesson/tests/behat/display_lesson_description.feature
Expand Up @@ -14,26 +14,22 @@ Feature: Display the lesson description in the lesson and optionally in the cour
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
Given the following "activity" exists:
| activity | lesson |
| course | C1 |
| idnumber | 0001 |
| name | Test lesson name |
| intro | Test lesson description |
And I am on the "Test lesson name" "lesson activity" page logged in as teacher1
And I follow "Add a content page"
And I set the following fields to these values:
| Page title | Test lesson part 1 |
| Description | Lesson part 1 description |
| Jump | Next page |
And I click on "Save page" "button"
And the following "activity" exist:
| activity | name | intro | course | idnumber |
| lesson | Test lesson name | Test lesson description | C1 | 0001 |
And the following "mod_lesson > page" exist:
| lesson | qtype | title | content |
| Test lesson name | content | Test lesson part 1 | Test lesson part 1 |
And the following "mod_lesson > answer" exist:
| page | answer | jumpto |
| Test lesson part 1 | Next page | Next page |

Scenario: Description is displayed in the Lesson
When I am on the "Test lesson name" "lesson activity" page
When I am on the "Test lesson name" "lesson activity" page logged in as teacher1
Then I should see "Test lesson description"

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

Scenario: Hide lesson description in the course homepage
Given I am on the "Test lesson name" "lesson activity editing" page
Given I am on the "Test lesson name" "lesson activity editing" page logged in as teacher1
And the following fields match these values:
| Display description on course page | |
And I press "Save and return to course"
Expand Down
24 changes: 8 additions & 16 deletions mod/lesson/tests/behat/lesson_activity_completion.feature
Expand Up @@ -28,22 +28,14 @@ Feature: View activity completion in the lesson activity
| completionendreached | 1 |
| completiontimespentenabled | 1 |
| completiontimespent | 3 |
And I am on the "Music history" "lesson activity" page logged in as teacher1
And I follow "Add a content page"
And I set the following fields to these values:
| Page title | Music history part 1 |
| Description | The history of music part 1 |
| Jump | Next page |
And I click on "Save page" "button"
And I select "Add a question page" from the "qtype" singleselect
And I set the field "Select a question type" to "Essay"
And I press "Add a question page"
And I set the following fields to these values:
| Page title | Music essay |
| Page contents | Write a really interesting music essay |
| Jump | End of lesson |
| Score | 1 |
And I press "Save page"
And the following "mod_lesson > page" exist:
| lesson | qtype | title | content |
| Music history | content | Music history part 1 | |
| Music history | essay | Music essay | Write a really interesting music essay |
And the following "mod_lesson > answer" exist:
| page | answer | jumpto | score |
| Music history part 1 | The history of music part 1 | Next page | 0 |
| Music essay | | Next page | 1 |

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

0 comments on commit 40bf6fc

Please sign in to comment.