Skip to content

Commit

Permalink
MDL-77581 behat: Apply new lesson cluster 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 db82329 commit eac49ff
Show file tree
Hide file tree
Showing 28 changed files with 201 additions and 493 deletions.
Expand Up @@ -19,11 +19,11 @@ Feature: Set end of lesson reached as a completion condition for a lesson
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:
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:
And the following "mod_lesson > answers" exist:
| page | answer | jumpto |
| First page name | Next page | Next page |
| Second page name | Previous page | Previous page |
Expand Down
Expand Up @@ -23,7 +23,7 @@ Feature: Set time spent as a completion condition for a lesson
| 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:
And the following "mod_lesson > answers" exist:
| page | answer | jumpto |
| First page name | Next page | Next page |
| Second page name | Previous page | Previous page |
Expand Down
4 changes: 2 additions & 2 deletions mod/lesson/tests/behat/date_availability.feature
Expand Up @@ -19,10 +19,10 @@ 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 the following "mod_lesson > page" exist:
And the following "mod_lesson > pages" exist:
| lesson | qtype | title | content |
| Test lesson | content | First page name | First page contents |
And the following "mod_lesson > answer" exist:
And the following "mod_lesson > answers" exist:
| page | answer | jumpto |
| First page name | Next page | Next page |

Expand Down
4 changes: 2 additions & 2 deletions mod/lesson/tests/behat/lesson_activity_completion.feature
Expand Up @@ -28,11 +28,11 @@ Feature: View activity completion in the lesson activity
| completionendreached | 1 |
| completiontimespentenabled | 1 |
| completiontimespent | 3 |
And the following "mod_lesson > page" exist:
And the following "mod_lesson > pages" 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:
And the following "mod_lesson > answers" exist:
| page | answer | jumpto | score |
| Music history part 1 | The history of music part 1 | Next page | 0 |
| Music essay | | Next page | 1 |
Expand Down
16 changes: 8 additions & 8 deletions mod/lesson/tests/behat/lesson_complete_report.feature
Expand Up @@ -20,11 +20,11 @@ Feature: Teachers can review student progress on all lessons in a course by view
| lesson | Test lesson name | C1 | lesson1 | 1 |

Scenario: View student progress for lesson that was never attempted
Given the following "mod_lesson > page" exist:
Given the following "mod_lesson > pages" exist:
| lesson | qtype | title | content |
| Test lesson name | content | First page name | First page contents |
| Test lesson name | truefalse | True/false question 1 | Paper is made from trees. |
And the following "mod_lesson > answer" exist:
And the following "mod_lesson > answers" exist:
| page | answer | response | jumpto | score |
| First page name | Next page | | Next page | 0 |
| True/false question 1 | True | Correct | Next page | 1 |
Expand All @@ -37,12 +37,12 @@ Feature: Teachers can review student progress on all lessons in a course by view
Then I should see "No attempts have been made on this lesson"

Scenario: View student progress for an incomplete lesson containing both content and question pages
Given the following "mod_lesson > page" exist:
Given the following "mod_lesson > pages" exist:
| lesson | qtype | title | content |
| Test lesson name | content | First page name | First page contents |
| Test lesson name | content | Second page name | Second page contents |
| Test lesson name | truefalse | True/false question 1 | Paper is made from trees. |
And the following "mod_lesson > answer" exist:
And the following "mod_lesson > answers" exist:
| page | answer | response | jumpto | score |
| First page name | Next page | | Next page | 0 |
| Second page name | Next page | | Next page | 0 |
Expand All @@ -60,13 +60,13 @@ Feature: Teachers can review student progress on all lessons in a course by view
And I should see "0" in the ".cell.c2" "css_element"

Scenario: View student progress for a lesson containing both content and question pages
Given the following "mod_lesson > page" exist:
Given the following "mod_lesson > pages" exist:
| lesson | qtype | title | content |
| Test lesson name | content | First page name | First page contents |
| Test lesson name | content | Second page name | Second page contents |
| Test lesson name | truefalse | True/false question 1 | Paper is made from trees. |
| Test lesson name | truefalse | True/false question 2 | The sky is Pink. |
And the following "mod_lesson > answer" exist:
And the following "mod_lesson > answers" exist:
| page | answer | response | jumpto | score |
| First page name | Next page | | Next page | 0 |
| Second page name | Previous page | | Previous page | 0 |
Expand Down Expand Up @@ -101,11 +101,11 @@ Feature: Teachers can review student progress on all lessons in a course by view
And I should see "1" in the ".cell.c3" "css_element"

Scenario: View student attempts in a lesson containing only content pages
Given the following "mod_lesson > page" exist:
Given the following "mod_lesson > pages" exist:
| lesson | qtype | title | content |
| Test lesson name | content | First page name | First page contents |
| Test lesson name | content | Second page name | Second page contents |
And the following "mod_lesson > answer" exist:
And the following "mod_lesson > answers" exist:
| page | answer | jumpto |
| First page name | Next page | Next page |
| Second page name | Previous page | Previous page |
Expand Down
Expand Up @@ -29,7 +29,7 @@ Feature: Pass grade activity completion in the lesson activity
And the following "mod_lesson > page" exist:
| lesson | qtype | title | content |
| Music history | numeric | Numerical question | What is 1 + 2? |
And the following "mod_lesson > answer" exist:
And the following "mod_lesson > answers" exist:
| page | answer | jumpto | score |
| Numerical question | 3 | End of lesson | 1 |
| Numerical question | @#wronganswer#@ | Next page | 0 |
Expand Down
2 changes: 1 addition & 1 deletion mod/lesson/tests/behat/lesson_course_reset.feature
Expand Up @@ -28,7 +28,7 @@ Feature: Lesson reset
And the following "mod_lesson > page" exist:
| lesson | qtype | title | content |
| Test lesson name | truefalse | True/false question 1 | Cat is an amphibian |
And the following "mod_lesson > answer" exist:
And the following "mod_lesson > answers" exist:
| page | answer | response | jumpto | score |
| True/false question 1 | False | Correct | Next page | 1 |
| True/false question 1 | True | Wrong | This page | 0 |
Expand Down
4 changes: 2 additions & 2 deletions mod/lesson/tests/behat/lesson_delete_answers.feature
Expand Up @@ -20,11 +20,11 @@ branch table contents
And the following "activities" exist:
| activity | name | course | idnumber |
| lesson | Test lesson name | C1 | lesson1 |
And the following "mod_lesson > page" exist:
And the following "mod_lesson > pages" exist:
| lesson | qtype | title | content |
| Test lesson name | content | First page name | First page contents |
| Test lesson name | numeric | Hardest question ever | 1 + 1? |
And the following "mod_lesson > answer" exist:
And the following "mod_lesson > answers" exist:
| page | answer | response | jumpto | score |
| First page name | Next page | | Next page | 0 |
| First page name | Previous page | | Previous page | 0 |
Expand Down
71 changes: 22 additions & 49 deletions mod/lesson/tests/behat/lesson_edit_cluster.feature
Expand Up @@ -19,57 +19,30 @@ Feature: In a lesson activity, teacher can edit a cluster page
And the following "activities" exist:
| activity | name | course | idnumber |
| lesson | Lesson with cluster | C1 | lesson1 |
And I am on the "Lesson with cluster" "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 | 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 edit type "Expanded"
And I click on "Add a cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][2]" "xpath_element"
And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][3]" "xpath_element"
And I set the field "Select a question type" to "Multichoice"
And I press "Add a question page"
And I set the following fields to these values:
| Page title | question 1 |
| Page contents | Question from cluster |
| id_answer_editor_0 | Correct answer |
| id_response_editor_0 | Good |
| id_jumpto_0 | Cluster |
| id_score_0 | 1 |
| id_answer_editor_1 | Incorrect answer |
| id_response_editor_1 | Bad |
| id_jumpto_1 | This page |
| id_score_1 | 0 |
And I press "Save page"
And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][4]" "xpath_element"
And I set the field "Select a question type" to "Multichoice"
And I press "Add a question page"
And I set the following fields to these values:
| Page title | question 2 |
| Page contents | Question from cluster |
| id_answer_editor_0 | Correct answer |
| id_response_editor_0 | Good |
| id_jumpto_0 | Cluster |
| id_score_0 | 1 |
| id_answer_editor_1 | Incorrect answer |
| id_response_editor_1 | Bad |
| id_jumpto_1 | This page |
| id_score_1 | 0 |
And I press "Save page"
And I click on "Add an end of cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][5]" "xpath_element"
And I click on "Add a content page" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][6]" "xpath_element"
And I set the following fields to these values:
| Page title | Second page name |
| Page contents | Content page after cluster |
| id_answer_editor_0 | Next page |
| id_jumpto_0 | Next page |
And I press "Save page"
And the following "mod_lesson > pages" exist:
| lesson | qtype | title | content |
| Lesson with cluster | content | First page name | First page contents |
| Lesson with cluster | cluster | Cluster | Cluster |
| Lesson with cluster | multichoice | Question 1 | Question from cluster |
| Lesson with cluster | multichoice | Question 2 | Question from cluster |
| Lesson with cluster | endofcluster | End of cluster | End of cluster |
| Lesson with cluster | content | Second page name | Content page after cluster |
And the following "mod_lesson > answers" exist:
| page | answer | response | jumpto | score |
| First page name | Next page | | Next page | 0 |
| Cluster | | | Unseen question within a cluster | 0 |
| Question 1 | Correct answer | Good | Cluster | 1 |
| Question 1 | Incorrect answer | Bad | This page | 0 |
| Question 2 | Correct answer | Good | Cluster | 1 |
| Question 2 | Incorrect answer | Bad | This page | 0 |
| End of cluster | | | Next page | 0 |
| Second page name | Next page | | Next page | 0 |

Scenario: Edit lesson cluster page
Given I click on "//th[normalize-space(.)='Cluster']/descendant::a[3]" "xpath_element"
Given I am on the "Lesson with cluster" "lesson activity" page logged in as teacher1
And I press "Edit lesson"
And I select edit type "Expanded"
And I click on "//th[normalize-space(.)='Cluster']/descendant::a[3]" "xpath_element"
When I set the following fields to these values:
| Page title | Modified name |
| Page contents | Modified contents |
Expand Down
4 changes: 2 additions & 2 deletions mod/lesson/tests/behat/lesson_edit_pages.feature
Expand Up @@ -19,12 +19,12 @@ Feature: In a lesson activity, teacher can edit lesson's pages
And the following "activities" exist:
| activity | name | course | idnumber |
| lesson | Test lesson name | C1 | lesson1 |
And the following "mod_lesson > page" exist:
And the following "mod_lesson > pages" exist:
| lesson | qtype | title | content |
| Test lesson name | content | First page name | First page contents |
| Test lesson name | content | Second page name | Second page contents |
| Test lesson name | numeric | Hardest question ever | 1 + 1? |
And the following "mod_lesson > answer" exist:
And the following "mod_lesson > answers" exist:
| page | answer | response | jumpto | score |
| First page name | Next page | | Next page | 0 |
| Second page name | Previous page | | Previous page | 0 |
Expand Down

0 comments on commit eac49ff

Please sign in to comment.