diff --git a/mod/lesson/tests/behat/completion_condition_end_reached.feature b/mod/lesson/tests/behat/completion_condition_end_reached.feature index feae2dc8deb..1bdc2a97736 100644 --- a/mod/lesson/tests/behat/completion_condition_end_reached.feature +++ b/mod/lesson/tests/behat/completion_condition_end_reached.feature @@ -60,6 +60,9 @@ Feature: Set end of lesson reached as a completion condition for a lesson And I hover "//li[contains(concat(' ', normalize-space(@class), ' '), ' modtype_lesson ')]/descendant::img[@alt='Not completed: Test lesson']" "xpath_element" And I follow "Course 1" And I follow "Test lesson" + And I should see "You have seen more than one page of this lesson already." + And I should see "Do you want to start at the last page you saw?" + And I follow "No" And I press "Next page" And I press "Next page" And I follow "Course 1" diff --git a/mod/lesson/tests/behat/lesson_student_resume.feature b/mod/lesson/tests/behat/lesson_student_resume.feature new file mode 100644 index 00000000000..078cf35188a --- /dev/null +++ b/mod/lesson/tests/behat/lesson_student_resume.feature @@ -0,0 +1,405 @@ +@mod @mod_lesson +Feature: In a lesson activity a student should + be able to close the lesson and then later resume. + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@asd.com | + | student1 | Student | 1 | student1@asd.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + And I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + And I add a "Lesson" to section "1" + And I set the following fields to these values: + | Name | Test lesson name | + | Description | Test lesson description | + | Re-takes allowed | Yes | + And I press "Save and return to course" + And I follow "Test lesson name" + + @javascript + Scenario: resume a lesson with both content then question pages + Given 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 set the field "qtype" to "Question" + And I set the field "Select a question type" to "True/false" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | True/false question 2 | + | Page contents | Kermit is a frog | + | id_answer_editor_0 | True | + | id_response_editor_0 | Correct | + | id_jumpto_0 | Next page | + | id_answer_editor_1 | False | + | id_response_editor_1 | Wrong | + | id_jumpto_1 | This page | + And I press "Save page" + And I set the field "qtype" to "Question" + And I set the field "Select a question type" to "True/false" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | True/false question 1 | + | Page contents | Paper is made from trees. | + | id_answer_editor_0 | True | + | id_response_editor_0 | Correct | + | id_jumpto_0 | Next page | + | id_answer_editor_1 | False | + | id_response_editor_1 | Wrong | + | id_jumpto_1 | This page | + And I press "Save page" + And I set the field "qtype" to "Add a content page" + And I set the following fields to these values: + | Page title | Third page name | + | Page contents | Third 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 I set the field "qtype" to "Add a content page" + 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 I log out + When I log in as "student1" + And I follow "Course 1" + And I follow "Test lesson name" + And I should see "First page contents" + And I press "Next page" + And I should see "Second page contents" + And I press "Next page" + And I should see "Third page contents" + And I follow "Test lesson name" + And I should see "You have seen more than one page of this lesson already." + And I should see "Do you want to start at the last page you saw?" + And I follow "Yes" + Then I should see "Third page contents" + And I press "Next page" + And I should see "Paper is made from trees." + And I follow "Test lesson name" + And I should see "You have seen more than one page of this lesson already." + And I should see "Do you want to start at the last page you saw?" + And I follow "Yes" + And I should see "Paper is made from trees." + And I set the following fields to these values: + | True | 1 | + And I press "Submit" + And I press "Continue" + And I should see "Kermit is a frog" + And I follow "Test lesson name" + And I should see "You have seen more than one page of this lesson already." + And I should see "Do you want to start at the last page you saw?" + And I follow "Yes" + And I should see "Kermit is a frog" + And I set the following fields to these values: + | True | 1 | + And I press "Submit" + And I press "Continue" + And I should see "Congratulations - end of lesson reached" + + @javascript + Scenario: resume a lesson with only content pages + Given 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 set the field "qtype" to "Add a content page" + And I set the following fields to these values: + | Page title | Fourth page name | + | Page contents | Fourth page contents | + | id_answer_editor_0 | Previous page | + | id_jumpto_0 | Previous page | + | id_answer_editor_1 | End of lesson | + | id_jumpto_1 | End of lesson | + And I press "Save page" + And I set the field "qtype" to "Add a content page" + And I set the following fields to these values: + | Page title | Third page name | + | Page contents | Third 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 I set the field "qtype" to "Add a content page" + 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 I log out + When I log in as "student1" + And I follow "Course 1" + And I follow "Test lesson name" + And I should see "First page contents" + And I press "Next page" + And I should see "Second page contents" + And I press "Next page" + And I should see "Third page contents" + And I follow "Test lesson name" + Then I should see "You have seen more than one page of this lesson already." + And I should see "Do you want to start at the last page you saw?" + And I follow "Yes" + And I should see "Third page contents" + And I press "Next page" + And I should see "Fourth page contents" + And I press "End of lesson" + And I log out + And I log in as "student1" + And I follow "Course 1" + And I follow "Test lesson name" + And I should see "First page contents" + And I log out + + @javascript + Scenario: resume a lesson with both question then content pages + Given I follow "Add a question page" + And I set the field "Select a question type" to "True/false" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | True/false question 1 | + | Page contents | Cat is an amphibian | + | id_answer_editor_0 | False | + | id_response_editor_0 | Correct | + | id_jumpto_0 | Next page | + | id_answer_editor_1 | True | + | id_response_editor_1 | Wrong | + | id_jumpto_1 | This page | + And I press "Save page" + And I set the field "qtype" to "Question" + And I set the field "Select a question type" to "True/false" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | True/false question 5 | + | Page contents | Kermit is a frog | + | id_answer_editor_0 | True | + | id_response_editor_0 | Correct | + | id_jumpto_0 | Next page | + | id_answer_editor_1 | False | + | id_response_editor_1 | Wrong | + | id_jumpto_1 | This page | + And I press "Save page" + And I set the field "qtype" to "Add a content page" + And I set the following fields to these values: + | Page title | Content page 2 | + | Page contents | Second content page | + | id_answer_editor_0 | Next page | + | id_jumpto_0 | Next page | + And I press "Save page" + And I set the field "qtype" to "Question" + And I set the field "Select a question type" to "True/false" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | True/false question 4 | + | Page contents | 2+2=4 | + | id_answer_editor_0 | True | + | id_response_editor_0 | Correct | + | id_jumpto_0 | Next page | + | id_answer_editor_1 | False | + | id_response_editor_1 | Wrong | + | id_jumpto_1 | This page | + And I press "Save page" + And I set the field "qtype" to "Question" + And I set the field "Select a question type" to "True/false" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | True/false question 3 | + | Page contents | 1+1=2 | + | id_answer_editor_0 | True | + | id_response_editor_0 | Correct | + | id_jumpto_0 | Next page | + | id_answer_editor_1 | False | + | id_response_editor_1 | Wrong | + | id_jumpto_1 | This page | + And I press "Save page" + And I set the field "qtype" to "Question" + And I set the field "Select a question type" to "True/false" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | True/false question 2 | + | Page contents | Paper is made from trees. | + | id_answer_editor_0 | True | + | id_response_editor_0 | Correct | + | id_jumpto_0 | Next page | + | id_answer_editor_1 | False | + | id_response_editor_1 | Wrong | + | id_jumpto_1 | This page | + And I press "Save page" + And I set the field "qtype" to "Add a content page" + And I set the following fields to these values: + | Page title | Content page 1 | + | Page contents | First content page | + | id_answer_editor_0 | Next page | + | id_jumpto_0 | Next page | + And I press "Save page" + And I log out + When I log in as "student1" + And I follow "Course 1" + And I follow "Test lesson name" + And I should see "Cat is an amphibian" + And I set the following fields to these values: + | False | 1 | + And I press "Submit" + And I press "Continue" + And I should see "First content page" + And I press "Next page" + And I should see "Paper is made from trees." + And I set the following fields to these values: + | True | 1 | + And I press "Submit" + And I press "Continue" + And I should see "1+1=2" + And I set the following fields to these values: + | True | 1 | + And I press "Submit" + And I press "Continue" + And I should see "2+2=4" + And I follow "Test lesson name" + And I should see "You have seen more than one page of this lesson already." + Then I should see "Do you want to start at the last page you saw?" + And I follow "Yes" + And I should see "2+2=4" + And I set the following fields to these values: + | True | 1 | + And I press "Submit" + And I press "Continue" + And I should see "Second content page" + And I follow "Test lesson name" + And I should see "You have seen more than one page of this lesson already." + And I should see "Do you want to start at the last page you saw?" + And I follow "Yes" + And I should see "Second content page" + And I press "Next page" + And I should see "Kermit is a frog" + And I set the following fields to these values: + | True | 1 | + And I press "Submit" + And I press "Continue" + And I should see "Congratulations - end of lesson reached" + + @javascript + Scenario: resume a lesson with only question pages + Given I follow "Add a question page" + And I set the field "Select a question type" to "True/false" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | True/false question 1 | + | Page contents | Cat is an amphibian | + | id_answer_editor_0 | False | + | id_response_editor_0 | Correct | + | id_jumpto_0 | Next page | + | id_answer_editor_1 | True | + | id_response_editor_1 | Wrong | + | id_jumpto_1 | This page | + And I press "Save page" + And I set the field "qtype" to "Question" + And I set the field "Select a question type" to "True/false" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | True/false question 5 | + | Page contents | Kermit is a frog | + | id_answer_editor_0 | True | + | id_response_editor_0 | Correct | + | id_jumpto_0 | Next page | + | id_answer_editor_1 | False | + | id_response_editor_1 | Wrong | + | id_jumpto_1 | This page | + And I press "Save page" + And I set the field "qtype" to "Question" + And I set the field "Select a question type" to "True/false" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | True/false question 4 | + | Page contents | 2+2=4 | + | id_answer_editor_0 | True | + | id_response_editor_0 | Correct | + | id_jumpto_0 | Next page | + | id_answer_editor_1 | False | + | id_response_editor_1 | Wrong | + | id_jumpto_1 | This page | + And I press "Save page" + And I set the field "qtype" to "Question" + And I set the field "Select a question type" to "True/false" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | True/false question 3 | + | Page contents | 1+1=2 | + | id_answer_editor_0 | True | + | id_response_editor_0 | Correct | + | id_jumpto_0 | Next page | + | id_answer_editor_1 | False | + | id_response_editor_1 | Wrong | + | id_jumpto_1 | This page | + And I press "Save page" + And I set the field "qtype" to "Question" + And I set the field "Select a question type" to "True/false" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | True/false question 2 | + | Page contents | Paper is made from trees. | + | id_answer_editor_0 | True | + | id_response_editor_0 | Correct | + | id_jumpto_0 | Next page | + | id_answer_editor_1 | False | + | id_response_editor_1 | Wrong | + | id_jumpto_1 | This page | + And I press "Save page" + And I log out + When I log in as "student1" + And I follow "Course 1" + And I follow "Test lesson name" + And I should see "Cat is an amphibian" + And I set the following fields to these values: + | False | 1 | + And I press "Submit" + And I press "Continue" + And I should see "Paper is made from trees." + And I set the following fields to these values: + | True | 1 | + And I press "Submit" + And I press "Continue" + And I should see "1+1=2" + And I set the following fields to these values: + | True | 1 | + And I press "Submit" + And I press "Continue" + And I should see "2+2=4" + And I follow "Test lesson name" + Then I should see "You have seen more than one page of this lesson already." + And I should see "Do you want to start at the last page you saw?" + And I follow "Yes" + And I should see "2+2=4" + And I set the following fields to these values: + | True | 1 | + And I press "Submit" + And I press "Continue" + And I should see "Kermit is a frog" + And I set the following fields to these values: + | True | 1 | + And I press "Submit" + And I press "Continue" + And I should see "Congratulations - end of lesson reached" \ No newline at end of file