diff --git a/lib/behat/classes/behat_generator_base.php b/lib/behat/classes/behat_generator_base.php index 9b9661f7895..262b6f415a6 100644 --- a/lib/behat/classes/behat_generator_base.php +++ b/lib/behat/classes/behat_generator_base.php @@ -279,6 +279,17 @@ abstract class behat_generator_base { ' data generator is not implemented'); } } + + // Notify that the all the elements have been generated. + if (method_exists($this->componentdatagenerator, 'finish_generate_' . $generatortype)) { + // Using the component's own data generator if it exists. + $this->componentdatagenerator->{'finish_generate_' . $generatortype}(); + + } else if (method_exists($this->datagenerator, 'finish_generate_' . $generatortype)) { + // Use a method on the core data geneator, if there is one. + $this->datagenerator->{'finish_generate_' . $generatortype}(); + + } } /** diff --git a/lib/form/tests/behat/graderescale_for_lesson_pointscale.feature b/lib/form/tests/behat/graderescale_for_lesson_pointscale.feature index f000b747894..f3c0a9a2675 100644 --- a/lib/form/tests/behat/graderescale_for_lesson_pointscale.feature +++ b/lib/form/tests/behat/graderescale_for_lesson_pointscale.feature @@ -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" diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 302721c5b41..f1a7babd311 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -10,6 +10,7 @@ information provided here is intended especially for developers. drag/drop, which can be used to add transition effects in calling code * course_modinfo now has a purge_course_modules_cache() method, which takes a list of cmids and purges them all in a single cache set. +* Behat generators can now implement the function finish_generate_ to detect when the whole list of elements have been generated. === 4.3 === diff --git a/mod/lesson/pagetypes/cluster.php b/mod/lesson/pagetypes/cluster.php index 164a1ad1af2..74948d04730 100644 --- a/mod/lesson/pagetypes/cluster.php +++ b/mod/lesson/pagetypes/cluster.php @@ -87,6 +87,29 @@ class lesson_page_type_cluster extends lesson_page { } return $this->properties->nextpageid; } + + /** + * Creates answers within the database for this cluster page. Usually only ever + * called when creating a new page instance. + * @param object $properties + * @return array + */ + public function create_answers($properties) { + global $DB; + + $newanswer = new stdClass; + $newanswer->lessonid = $this->lesson->id; + $newanswer->pageid = $this->properties->id; + $newanswer->timecreated = $this->properties->timecreated; + + if (isset($properties->jumpto[0])) { + $newanswer->jumpto = $properties->jumpto[0]; + } + $newanswer->id = $DB->insert_record('lesson_answers', $newanswer); + $answers = [$newanswer->id => new lesson_page_answer($newanswer)]; + $this->answers = $answers; + return $answers; + } } class lesson_add_page_form_cluster extends lesson_add_page_form_base { @@ -179,4 +202,4 @@ class lesson_add_page_form_cluster extends lesson_add_page_form_base { $lesson->add_message(get_string('addedcluster', 'lesson'), 'notifysuccess'); redirect($CFG->wwwroot.'/mod/lesson/edit.php?id='.$PAGE->cm->id); } -} \ No newline at end of file +} diff --git a/mod/lesson/pagetypes/endofbranch.php b/mod/lesson/pagetypes/endofbranch.php index fa172450175..dc5409cee79 100644 --- a/mod/lesson/pagetypes/endofbranch.php +++ b/mod/lesson/pagetypes/endofbranch.php @@ -115,6 +115,29 @@ class lesson_page_type_endofbranch extends lesson_page { public function valid_page_and_view(&$validpages, &$pageviews) { return $this->properties->nextpageid; } + + /** + * Creates answers within the database for this end of cluster page. Usually only ever + * called when creating a new page instance. + * @param object $properties + * @return array + */ + public function create_answers($properties) { + global $DB; + + $newanswer = new stdClass; + $newanswer->lessonid = $this->lesson->id; + $newanswer->pageid = $this->properties->id; + $newanswer->timecreated = $this->properties->timecreated; + + if (isset($properties->jumpto[0])) { + $newanswer->jumpto = $properties->jumpto[0]; + } + $newanswer->id = $DB->insert_record('lesson_answers', $newanswer); + $answers = [$newanswer->id => new lesson_page_answer($newanswer)]; + $this->answers = $answers; + return $answers; + } } class lesson_add_page_form_endofbranch extends lesson_add_page_form_base { diff --git a/mod/lesson/pagetypes/endofcluster.php b/mod/lesson/pagetypes/endofcluster.php index 4b756df61ed..05050139565 100644 --- a/mod/lesson/pagetypes/endofcluster.php +++ b/mod/lesson/pagetypes/endofcluster.php @@ -95,6 +95,29 @@ class lesson_page_type_endofcluster extends lesson_page { public function valid_page_and_view(&$validpages, &$pageviews) { return $this->properties->nextpageid; } + + /** + * Creates answers within the database for this end of cluster page. Usually only ever + * called when creating a new page instance. + * @param object $properties + * @return array + */ + public function create_answers($properties) { + global $DB; + + $newanswer = new stdClass; + $newanswer->lessonid = $this->lesson->id; + $newanswer->pageid = $this->properties->id; + $newanswer->timecreated = $this->properties->timecreated; + + if (isset($properties->jumpto[0])) { + $newanswer->jumpto = $properties->jumpto[0]; + } + $newanswer->id = $DB->insert_record('lesson_answers', $newanswer); + $answers = [$newanswer->id => new lesson_page_answer($newanswer)]; + $this->answers = $answers; + return $answers; + } } class lesson_add_page_form_endofcluster extends lesson_add_page_form_base { diff --git a/mod/lesson/tests/behat/completion_condition_end_reached.feature b/mod/lesson/tests/behat/completion_condition_end_reached.feature index d9508bce482..85291805605 100644 --- a/mod/lesson/tests/behat/completion_condition_end_reached.feature +++ b/mod/lesson/tests/behat/completion_condition_end_reached.feature @@ -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: - | Add requirements | 1 | - | 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 > 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 > answers" 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" diff --git a/mod/lesson/tests/behat/completion_condition_time_spent.feature b/mod/lesson/tests/behat/completion_condition_time_spent.feature index 46560113ff9..b02e3bbf777 100644 --- a/mod/lesson/tests/behat/completion_condition_time_spent.feature +++ b/mod/lesson/tests/behat/completion_condition_time_spent.feature @@ -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: - | Add requirements | 1 | - | 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 > answers" 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" diff --git a/mod/lesson/tests/behat/date_availability.feature b/mod/lesson/tests/behat/date_availability.feature index b9d6627a23c..4cfae904ee9 100644 --- a/mod/lesson/tests/behat/date_availability.feature +++ b/mod/lesson/tests/behat/date_availability.feature @@ -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 > pages" exist: + | lesson | qtype | title | content | + | Test lesson | content | First page name | First page contents | + And the following "mod_lesson > answers" 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 | @@ -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 | @@ -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" diff --git a/mod/lesson/tests/behat/display_lesson_description.feature b/mod/lesson/tests/behat/display_lesson_description.feature index 10b4254c3be..34f210da7ca 100644 --- a/mod/lesson/tests/behat/display_lesson_description.feature +++ b/mod/lesson/tests/behat/display_lesson_description.feature @@ -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: @@ -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" diff --git a/mod/lesson/tests/behat/lesson_activity_completion.feature b/mod/lesson/tests/behat/lesson_activity_completion.feature index 8b0df560ade..254a666cfbc 100644 --- a/mod/lesson/tests/behat/lesson_activity_completion.feature +++ b/mod/lesson/tests/behat/lesson_activity_completion.feature @@ -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 > 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 > answers" 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 diff --git a/mod/lesson/tests/behat/lesson_complete_report.feature b/mod/lesson/tests/behat/lesson_complete_report.feature index 76d1a37b9a6..e9b7d81cff5 100644 --- a/mod/lesson/tests/behat/lesson_complete_report.feature +++ b/mod/lesson/tests/behat/lesson_complete_report.feature @@ -18,29 +18,18 @@ Feature: Teachers can review student progress on all lessons in a course by view And the following "activities" exist: | activity | name | course | idnumber | retake | | lesson | Test lesson name | C1 | lesson1 | 1 | - And I am on the "Test lesson name" "lesson activity" page logged in as teacher1 Scenario: View student progress for lesson that was never attempted - 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 select "Add a question page" from the "qtype" singleselect - 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" + 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 > answers" exist: + | page | answer | response | jumpto | score | + | First page name | Next page | | Next page | 0 | + | True/false question 1 | True | Correct | Next page | 1 | + | True/false question 1 | False | Wrong | This page | 0 | + And I log in as "teacher1" When I am on "Course 1" course homepage And I navigate to course participants And I follow "Student 1" @@ -48,36 +37,17 @@ 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 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 question page" from the "qtype" singleselect - 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 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 I log out + 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 > answers" exist: + | page | answer | response | jumpto | score | + | First page name | Next page | | Next page | 0 | + | Second page name | Next page | | Next page | 0 | + | True/false question 1 | True | Correct | Next page | 1 | + | True/false question 1 | False | Wrong | This page | 0 | When I am on the "Test lesson name" "lesson activity" page logged in as student1 And I should see "First page contents" And I press "Next page" @@ -90,48 +60,21 @@ 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 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 question page" from the "qtype" singleselect - 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 | The sky is Pink. | - | 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 select "Add a question page" from the "qtype" singleselect - 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 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" + 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 > answers" exist: + | page | answer | response | jumpto | score | + | First page name | Next page | | Next page | 0 | + | Second page name | Previous page | | Previous page | 0 | + | Second page name | Next page | | Next page | 0 | + | True/false question 1 | True | Correct | Next page | 1 | + | True/false question 1 | False | Wrong | This page | 0 | + | True/false question 2 | False | Correct | Next page | 1 | + | True/false question 2 | True | Wrong | This page | 0 | When I am on the "Test lesson name" "lesson activity" page logged in as student1 And I should see "First page contents" And I press "Next page" @@ -158,22 +101,15 @@ 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 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 | End of lesson | - | id_jumpto_1 | End of lesson | - And I press "Save page" + 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 > answers" exist: + | page | answer | jumpto | + | First page name | Next page | Next page | + | Second page name | Previous page | Previous page | + | Second page name | End of lesson | End of lesson | When I am on the "Test lesson name" "lesson activity" page logged in as student1 And I should see "First page contents" And I press "Next page" diff --git a/mod/lesson/tests/behat/lesson_completion_pass_grade.feature b/mod/lesson/tests/behat/lesson_completion_pass_grade.feature index b631bfa3a9d..00da02e453a 100644 --- a/mod/lesson/tests/behat/lesson_completion_pass_grade.feature +++ b/mod/lesson/tests/behat/lesson_completion_pass_grade.feature @@ -9,21 +9,14 @@ Feature: Pass grade activity completion in the lesson activity | student3 | Vinnie | Student3 | student3@example.com | | teacher1 | Darrell | Teacher1 | teacher1@example.com | And the following "courses" exist: - | fullname | shortname | category | - | Course 1 | C1 | 0 | + | fullname | shortname | category | enablecompletion | showcompletionconditions | + | Course 1 | C1 | 0 | 1 | 1 | And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | | student2 | C1 | student | | student3 | C1 | student | | teacher1 | C1 | editingteacher | - And I am on the "Course 1" course page logged in as teacher1 - And I navigate to "Settings" in current page administration - And I expand all fieldsets - And I set the following fields to these values: - | Enable completion tracking | Yes | - | Show activity completion conditions | Yes | - And I press "Save and display" And the following "activity" exists: | activity | lesson | | course | C1 | @@ -33,18 +26,13 @@ Feature: Pass grade activity completion in the lesson activity | completion | 2 | | completionusegrade | 1 | | completionpassgrade | 1 | - And I am on the "Music history" "lesson activity" page - 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" + 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 > answers" exist: + | page | answer | jumpto | score | + | Numerical question | 3 | End of lesson | 1 | + | Numerical question | @#wronganswer#@ | Next page | 0 | Scenario: View automatic completion items as a teacher When I am on the "Music history" "lesson activity" page logged in as teacher1 diff --git a/mod/lesson/tests/behat/lesson_course_reset.feature b/mod/lesson/tests/behat/lesson_course_reset.feature index 5b647e54fb3..2fe0cb47f51 100644 --- a/mod/lesson/tests/behat/lesson_course_reset.feature +++ b/mod/lesson/tests/behat/lesson_course_reset.feature @@ -25,20 +25,13 @@ Feature: Lesson reset And the following "activities" exist: | activity | name | course | idnumber | | lesson | Test lesson name | C1 | lesson1 | - And 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 "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 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 > 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 | Scenario: Use course reset to clear all attempt data When I am on the "Test lesson name" "lesson activity" page logged in as student1 @@ -62,7 +55,7 @@ Feature: Lesson reset @javascript Scenario: Use course reset to remove user overrides. - 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 And I navigate to "Overrides" in current page administration And I follow "Add user override" And I set the following fields to these values: @@ -80,7 +73,8 @@ Feature: Lesson reset Then I should not see "Sam1 Student1" Scenario: Use course reset to remove group overrides. - When I navigate to "Overrides" in current page administration + When I am on the "Test lesson name" "lesson activity" page logged in as teacher1 + And I navigate to "Overrides" in current page administration And I select "Group overrides" from the "jump" singleselect And I follow "Add group override" And I set the following fields to these values: diff --git a/mod/lesson/tests/behat/lesson_create_pages.feature b/mod/lesson/tests/behat/lesson_create_pages.feature new file mode 100644 index 00000000000..d39be894c27 --- /dev/null +++ b/mod/lesson/tests/behat/lesson_create_pages.feature @@ -0,0 +1,284 @@ +@mod @mod_lesson +Feature: In a lesson activity, teacher can create lesson's pages + In order to set up an existing lesson + As a teacher + I need to create pages in the lesson + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@example.com | + | student1 | Student | 1 | student1@example.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 the following "activities" exist: + | activity | name | course | idnumber | + | lesson | Test lesson name | C1 | lesson1 | + + Scenario: Create content page + When 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 | First page name | + | Page contents | First page contents | + | id_answer_editor_0 | Forward | + | id_jumpto_0 | Next page | + | id_answer_editor_1 | Backward | + | id_jumpto_1 | Previous page | + And I press "Save page" + And I select edit type "Expanded" + Then I should see "First page name" + And I should see "First page contents" + And I should see "Forward" in the "Content 1" "table_row" + And I should see "Next page" in the "Jump 1" "table_row" + And I should see "Backward" in the "Content 2" "table_row" + And I should see "Previous page" in the "Jump 2" "table_row" + + Scenario: Create essay page + When 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 "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 I select edit type "Expanded" + Then I should see "Music essay" + And I should see "Write a really interesting music essay" + And I should see "End of lesson" in the "Jump 1" "table_row" + + Scenario: Create matching page + When 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 "Matching" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | Geography | + | Page contents | Match each city with its country | + | id_answer_editor_0 | Correct! | + | id_jumpto_0 | End of lesson | + | id_score_0 | 2 | + | id_answer_editor_1 | Wrong! | + | id_jumpto_1 | This page | + | id_score_1 | 0 | + | id_answer_editor_2 | Barcelona | + | id_response_editor_2 | Spain | + | id_answer_editor_3 | Perth | + | id_response_editor_3 | Australia | + | id_answer_editor_4 | Tokyo | + | id_response_editor_4 | Japan | + | id_answer_editor_5 | Buenos Aires | + | id_response_editor_5 | Argentina | + | id_answer_editor_6 | Cairo | + | id_response_editor_6 | Egypt | + And I press "Save page" + And I select edit type "Expanded" + Then I should see "Geography" + And I should see "Match each city with its country" + And I should see "Correct!" in the "Correct response" "table_row" + And I should see "2" in the "Correct answer score" "table_row" + And I should see "End of lesson" in the "Correct answer jump" "table_row" + And I should see "Wrong!" in the "Wrong response" "table_row" + And I should see "0" in the "Wrong answer score" "table_row" + And I should see "This page" in the "Wrong answer jump" "table_row" + And I should see "Barcelona" in the "Answer 1" "table_row" + And I should see "Spain" in the "Matches with answer 1" "table_row" + And I should see "Perth" in the "Answer 2" "table_row" + And I should see "Australia" in the "Matches with answer 2" "table_row" + And I should see "Tokyo" in the "Answer 3" "table_row" + And I should see "Japan" in the "Matches with answer 3" "table_row" + And I should see "Buenos Aires" in the "Answer 4" "table_row" + And I should see "Argentina" in the "Matches with answer 4" "table_row" + And I should see "Cairo" in the "Answer 5" "table_row" + And I should see "Egypt" in the "Matches with answer 5" "table_row" + + Scenario: Create multichoice page + When 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 "Multichoice" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | Multichoice question | + | Page contents | What animal is an amphibian? | + | id_answer_editor_0 | Frog | + | id_response_editor_0 | Correct answer | + | id_jumpto_0 | End of lesson | + | id_score_0 | 2 | + | id_answer_editor_1 | Cat | + | id_response_editor_1 | Incorrect answer | + | id_jumpto_1 | This page | + | id_score_1 | 0 | + | id_answer_editor_2 | Dog | + | id_response_editor_2 | Incorrect answer | + | id_jumpto_2 | Next page | + | id_score_2 | 0 | + And I press "Save page" + And I select edit type "Expanded" + Then I should see "Multichoice question" + And I should see "What animal is an amphibian?" + And I should see "Frog" in the "Answer 1" "table_row" + And I should see "Correct answer" in the "Response 1" "table_row" + And I should see "End of lesson" in the "//tr[contains(.,'Jump')][1]" "xpath_element" + And I should see "2" in the "//tr[contains(.,'Score')][1]" "xpath_element" + And I should see "Cat" in the "Answer 2" "table_row" + And I should see "Incorrect answer" in the "Response 2" "table_row" + And I should see "This page" in the "//tr[contains(.,'Jump')][2]" "xpath_element" + And I should see "0" in the "//tr[contains(.,'Score')][2]" "xpath_element" + And I should see "Dog" in the "Answer 3" "table_row" + And I should see "Incorrect answer" in the "Response 3" "table_row" + And I should see "Next page" in the "//tr[contains(.,'Jump')][3]" "xpath_element" + And I should see "0" in the "//tr[contains(.,'Score')][3]" "xpath_element" + + Scenario: Create numerical page + When 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 | Really hard question | + | Page contents | What is 1 + 2? | + | id_answer_editor_0 | 3 | + | id_response_editor_0 | Correct | + | id_jumpto_0 | End of lesson | + | id_score_0 | 2 | + | id_answer_editor_1 | 2 | + | id_response_editor_1 | Close, but wrong | + | id_jumpto_1 | Next page | + | id_score_1 | 1 | + | id_enableotheranswers | 1 | + | id_response_editor_6 | Wrong | + | id_jumpto_6 | This page | + | id_score_6 | 0 | + And I press "Save page" + And I select edit type "Expanded" + Then I should see "Really hard question" + And I should see "What is 1 + 2?" + And I should see "3" in the "Answer 1" "table_row" + And I should see "Correct" in the "Response 1" "table_row" + And I should see "End of lesson" in the "//tr[contains(.,'Jump')][1]" "xpath_element" + And I should see "2" in the "//tr[contains(.,'Score')][1]" "xpath_element" + And I should see "2" in the "Answer 2" "table_row" + And I should see "Close, but wrong" in the "Response 2" "table_row" + And I should see "Next page" in the "//tr[contains(.,'Jump')][2]" "xpath_element" + And I should see "1" in the "//tr[contains(.,'Score')][2]" "xpath_element" + And I should see "@#wronganswer#@" in the "Answer 3" "table_row" + And I should see "Wrong" in the "Response 3" "table_row" + And I should see "This page" in the "//tr[contains(.,'Jump')][3]" "xpath_element" + And I should see "0" in the "//tr[contains(.,'Score')][3]" "xpath_element" + + Scenario: Create short answer page + When 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 "Short answer" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | Geography | + | Page contents | Capital of Canada | + | id_answer_editor_0 | Ottawa | + | id_response_editor_0 | Correct | + | id_jumpto_0 | End of lesson | + | id_score_0 | 2 | + | id_answer_editor_1 | Toronto | + | id_response_editor_1 | It's in Canada, but it's not the capital | + | id_jumpto_1 | Next page | + | id_score_1 | 1 | + | id_answer_editor_2 | Vancouver | + | id_response_editor_2 | It's in Canada, but it's not the capital | + | id_jumpto_2 | Next page | + | id_score_2 | 1 | + | id_enableotheranswers | 1 | + | id_response_editor_6 | Wrong | + | id_jumpto_6 | This page | + | id_score_6 | 0 | + And I press "Save page" + And I select edit type "Expanded" + Then I should see "Geography" + And I should see "Capital of Canada" + And I should see "Ottawa" in the "Answer 1" "table_row" + And I should see "Correct" in the "Response 1" "table_row" + And I should see "End of lesson" in the "//tr[contains(.,'Jump')][1]" "xpath_element" + And I should see "2" in the "//tr[contains(.,'Score')][1]" "xpath_element" + And I should see "Toronto" in the "Answer 2" "table_row" + And I should see "It's in Canada, but it's not the capital" in the "Response 2" "table_row" + And I should see "Next page" in the "//tr[contains(.,'Jump')][2]" "xpath_element" + And I should see "1" in the "//tr[contains(.,'Score')][2]" "xpath_element" + And I should see "Vancouver" in the "Answer 3" "table_row" + And I should see "It's in Canada, but it's not the capital" in the "Response 3" "table_row" + And I should see "Next page" in the "//tr[contains(.,'Jump')][3]" "xpath_element" + And I should see "1" in the "//tr[contains(.,'Score')][3]" "xpath_element" + And I should see "@#wronganswer#@" in the "Answer 4" "table_row" + And I should see "Wrong" in the "Response 4" "table_row" + And I should see "This page" in the "//tr[contains(.,'Jump')][4]" "xpath_element" + And I should see "0" in the "//tr[contains(.,'Score')][4]" "xpath_element" + + Scenario: Create true/false page + When 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 "True/false" + And I press "Add a question page" + And I set the following fields to these values: + | Page title | True/false question | + | Page contents | Paper is made from trees. | + | id_answer_editor_0 | True | + | id_response_editor_0 | Correct | + | id_jumpto_0 | End of lesson | + | id_score_0 | 2 | + | id_answer_editor_1 | False | + | id_response_editor_1 | Wrong | + | id_jumpto_1 | This page | + | id_score_1 | 0 | + And I press "Save page" + And I select edit type "Expanded" + Then I should see "True/false question" + And I should see "Paper is made from trees." + And I should see "True" in the "Answer 1" "table_row" + And I should see "Correct" in the "Response 1" "table_row" + And I should see "End of lesson" in the "//tr[contains(.,'Jump')][1]" "xpath_element" + And I should see "2" in the "//tr[contains(.,'Score')][1]" "xpath_element" + And I should see "False" in the "Answer 2" "table_row" + And I should see "Wrong" in the "Response 2" "table_row" + And I should see "This page" in the "//tr[contains(.,'Jump')][2]" "xpath_element" + And I should see "0" in the "//tr[contains(.,'Score')][2]" "xpath_element" + + Scenario: Create cluster pages + When I am on the "Test lesson name" "lesson activity" page logged in as teacher1 + And I follow "Add a cluster" + And I select edit type "Expanded" + And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][2]" "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 content page" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][3]" "xpath_element" + And I set the following fields to these values: + | Page title | Second page name | + | Page contents | This page mark the the beginning of the subcluster it should not be seen by students | + | id_answer_editor_0 | Next page | + | id_jumpto_0 | Next page | + And I press "Save page" + And I click on "Add an end of branch" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][4]" "xpath_element" + And I click on "Add an end of cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][5]" "xpath_element" + Then I should see "Cluster" + And I should see "Unseen question within a cluster" in the "//tr[contains(.,'Jump')][1]" "xpath_element" + And I should see "Question from cluster" + And I should see "This page mark the the beginning of the subcluster it should not be seen by students" + And I should see "End of branch" + And I should see "End of cluster" diff --git a/mod/lesson/tests/behat/lesson_delete_answers.feature b/mod/lesson/tests/behat/lesson_delete_answers.feature index 571d4fca3cc..5d28dc3da40 100644 --- a/mod/lesson/tests/behat/lesson_delete_answers.feature +++ b/mod/lesson/tests/behat/lesson_delete_answers.feature @@ -20,31 +20,18 @@ branch table contents And the following "activities" exist: | activity | name | course | idnumber | | lesson | Test lesson name | C1 | lesson1 | + 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 > answers" exist: + | page | answer | response | jumpto | score | + | First page name | Next page | | Next page | 0 | + | First page name | Previous page | | Previous page | 0 | + | Hardest question ever | 2 | Correct answer | End of lesson | 1 | + | Hardest question ever | 1 | Incorrect answer | First page name | 0 | 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 | First page name | - | Page contents | First page contents | - | id_answer_editor_0 | Next page | - | id_jumpto_0 | Next page | - | id_answer_editor_1 | Previous page | - | id_jumpto_1 | Previous page | - And I press "Save page" - And I select "Add a question page" from the "qtype" singleselect - 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 | Hardest question ever | - | Page contents | 1 + 1? | - | id_answer_editor_0 | 2 | - | id_response_editor_0 | Correct answer | - | id_jumpto_0 | End of lesson | - | id_score_0 | 1 | - | id_answer_editor_1 | 1 | - | id_response_editor_1 | Incorrect answer | - | id_jumpto_1 | First page name | - | id_score_1 | 0 | - And I press "Save page" + And I press "Edit lesson" And I select edit type "Expanded" Scenario: Edit lesson content page diff --git a/mod/lesson/tests/behat/lesson_edit_cluster.feature b/mod/lesson/tests/behat/lesson_edit_cluster.feature index 49c55542d0f..1abacebd354 100644 --- a/mod/lesson/tests/behat/lesson_edit_cluster.feature +++ b/mod/lesson/tests/behat/lesson_edit_cluster.feature @@ -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 | diff --git a/mod/lesson/tests/behat/lesson_edit_pages.feature b/mod/lesson/tests/behat/lesson_edit_pages.feature index 26a957c4ba8..ada2cbc3e6d 100644 --- a/mod/lesson/tests/behat/lesson_edit_pages.feature +++ b/mod/lesson/tests/behat/lesson_edit_pages.feature @@ -19,39 +19,21 @@ 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 > 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 > answers" exist: + | page | answer | response | jumpto | score | + | First page name | Next page | | Next page | 0 | + | Second page name | Previous page | | Previous page | 0 | + | Second page name | Next page | | Next page | 0 | + | Hardest question ever | 2 | Correct answer | End of lesson | 1 | + | Hardest question ever | 1 | Incorrect answer | Second page name | 0 | 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 | 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 I press "Edit lesson" And I select edit type "Expanded" - 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 "Numerical" - And I press "Add a question page" - And I set the following fields to these values: - | Page title | Hardest question ever | - | Page contents | 1 + 1? | - | id_answer_editor_0 | 2 | - | id_response_editor_0 | Correct answer | - | id_jumpto_0 | End of lesson | - | id_score_0 | 1 | - | id_answer_editor_1 | 1 | - | id_response_editor_1 | Incorrect answer | - | id_jumpto_1 | Second page name | - | id_score_1 | 0 | - And I press "Save page" Scenario: Edit lesson content page Given I click on "//th[normalize-space(.)='Second page name']/descendant::a[3]" "xpath_element" diff --git a/mod/lesson/tests/behat/lesson_essay_question.feature b/mod/lesson/tests/behat/lesson_essay_question.feature index 3175432d23f..5d8d54404ae 100644 --- a/mod/lesson/tests/behat/lesson_essay_question.feature +++ b/mod/lesson/tests/behat/lesson_essay_question.feature @@ -18,14 +18,12 @@ Feature: In a lesson activity, teacher can add an essay question And the following "activities" exist: | activity | name | course | idnumber | feedback | | lesson | Test lesson name | C1 | lesson1 | 1 | - And 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 "Essay" - And I press "Add a question page" - And I set the following fields to these values: - | Page title | Essay question | - | Page contents |
Please write a story about a frog.
| - And I press "Save page" + And the following "mod_lesson > page" exist: + | lesson | qtype | title | content | + | Test lesson name | essay | Essay question |Please write a story about a frog.
| + And the following "mod_lesson > answer" exist: + | page | jumpto | score | + | Essay question | Next page | 1 | When I am on the "Test lesson name" "lesson activity" page logged in as student1 Then I should see "Please write a story about a frog." And I set the field "Your answer" to "Once upon a time there was a little green frog." diff --git a/mod/lesson/tests/behat/lesson_exit_enter_clusters.feature b/mod/lesson/tests/behat/lesson_exit_enter_clusters.feature index 761e3963d75..f5cb851a667 100644 --- a/mod/lesson/tests/behat/lesson_exit_enter_clusters.feature +++ b/mod/lesson/tests/behat/lesson_exit_enter_clusters.feature @@ -18,171 +18,51 @@ Feature: In a lesson activity, students can exit and re-enter the activity when 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 follow "Update page: Cluster" - And I set the following fields to these values: - | Page title | C Cluster | - | Page contents | C Cluster | - | Jump | Unseen question within a cluster | - And I press "Save page" - And I click on "Add a cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][2]" "xpath_element" - And I follow "Update page: Cluster" - And I set the following fields to these values: - | Page title | B Cluster | - | Page contents | B Cluster | - | Jump | Unseen question within a cluster | - And I press "Save page" - And I click on "Add a cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][2]" "xpath_element" - And I follow "Update page: Cluster" - And I set the following fields to these values: - | Page title | A Cluster | - | Page contents | A Cluster | - | Jump | Unseen question within a cluster | - And I press "Save page" - 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 A Cluster | - | Page contents | Question 1 from A cluster | - | id_answer_editor_0 | Correct answer | - | id_response_editor_0 | Good | - | id_jumpto_0 | B Cluster | - | id_score_0 | 1 | - | id_answer_editor_1 | Incorrect answer | - | id_response_editor_1 | Bad | - | id_jumpto_1 | Unseen question within a cluster | - | 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 A Cluster | - | Page contents | Question 2 from A cluster | - | id_answer_editor_0 | Correct answer | - | id_response_editor_0 | Good | - | id_jumpto_0 | B Cluster | - | id_score_0 | 1 | - | id_answer_editor_1 | Incorrect answer | - | id_response_editor_1 | Bad | - | id_jumpto_1 | Unseen question within a cluster | - | 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 ')][5]" "xpath_element" - And I press "Add a question page" - And I set the following fields to these values: - | Page title | Question 3 A Cluster | - | Page contents | Question 3 from A cluster | - | id_answer_editor_0 | Correct answer | - | id_response_editor_0 | Good | - | id_jumpto_0 | B Cluster | - | id_score_0 | 1 | - | id_answer_editor_1 | Incorrect answer | - | id_response_editor_1 | Bad | - | id_jumpto_1 | Unseen question within a cluster | - | 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 ')][6]" "xpath_element" - And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][8]" "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 B Cluster | - | Page contents | Question 1 from B cluster | - | id_answer_editor_0 | Correct answer | - | id_response_editor_0 | Good | - | id_jumpto_0 | C Cluster | - | id_score_0 | 1 | - | id_answer_editor_1 | Incorrect answer | - | id_response_editor_1 | Bad | - | id_jumpto_1 | Unseen question within a cluster | - | 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 ')][9]" "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 B Cluster | - | Page contents | Question 2 from B cluster | - | id_answer_editor_0 | Correct answer | - | id_response_editor_0 | Good | - | id_jumpto_0 | C Cluster | - | id_score_0 | 1 | - | id_answer_editor_1 | Incorrect answer | - | id_response_editor_1 | Bad | - | id_jumpto_1 | Unseen question within a cluster | - | 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 ')][10]" "xpath_element" - And I press "Add a question page" - And I set the following fields to these values: - | Page title | Question 3 B Cluster | - | Page contents | Question 3 from B cluster | - | id_answer_editor_0 | Correct answer | - | id_response_editor_0 | Good | - | id_jumpto_0 | C Cluster | - | id_score_0 | 1 | - | id_answer_editor_1 | Incorrect answer | - | id_response_editor_1 | Bad | - | id_jumpto_1 | Unseen question within a cluster | - | 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 ')][11]" "xpath_element" - And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][13]" "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 C Cluster | - | Page contents | Question 1 from C cluster | - | id_answer_editor_0 | Correct answer | - | id_response_editor_0 | Good | - | id_jumpto_0 | End of lesson | - | id_score_0 | 1 | - | id_answer_editor_1 | Incorrect answer | - | id_response_editor_1 | Bad | - | id_jumpto_1 | Unseen question within a cluster | - | 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 ')][14]" "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 C Cluster | - | Page contents | Question 2 from C cluster | - | id_answer_editor_0 | Correct answer | - | id_response_editor_0 | Good | - | id_jumpto_0 | End of lesson | - | id_score_0 | 1 | - | id_answer_editor_1 | Incorrect answer | - | id_response_editor_1 | Bad | - | id_jumpto_1 | Unseen question within a cluster | - | 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 ')][15]" "xpath_element" - And I press "Add a question page" - And I set the following fields to these values: - | Page title | Question 3 C Cluster | - | Page contents | Question 3 from C cluster | - | id_answer_editor_0 | Correct answer | - | id_response_editor_0 | Good | - | id_jumpto_0 | End of lesson | - | id_score_0 | 1 | - | id_answer_editor_1 | Incorrect answer | - | id_response_editor_1 | Bad | - | id_jumpto_1 | Unseen question within a cluster | - | 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 ')][16]" "xpath_element" + 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 | A Cluster | A Cluster | + | Lesson with cluster | multichoice | Question 1 A Cluster | Question 1 from A cluster | + | Lesson with cluster | multichoice | Question 2 A Cluster | Question 2 from A cluster | + | Lesson with cluster | multichoice | Question 3 A Cluster | Question 3 from A cluster | + | Lesson with cluster | endofcluster | End of A cluster | End of A cluster | + | Lesson with cluster | cluster | B Cluster | B Cluster | + | Lesson with cluster | multichoice | Question 1 B Cluster | Question 1 from B cluster | + | Lesson with cluster | multichoice | Question 2 B Cluster | Question 2 from B cluster | + | Lesson with cluster | multichoice | Question 3 B Cluster | Question 3 from B cluster | + | Lesson with cluster | endofcluster | End of B cluster | End of B cluster | + | Lesson with cluster | cluster | C Cluster | C Cluster | + | Lesson with cluster | multichoice | Question 1 C Cluster | Question 1 from C cluster | + | Lesson with cluster | multichoice | Question 2 C Cluster | Question 2 from C cluster | + | Lesson with cluster | multichoice | Question 3 C Cluster | Question 3 from C cluster | + | Lesson with cluster | endofcluster | End of C cluster | End of C cluster | + And the following "mod_lesson > answers" exist: + | page | answer | response | jumpto | score | + | First page name | Next page | | Next page | 0 | + | A Cluster | | | Unseen question within a cluster | 0 | + | Question 1 A Cluster | Correct answer | Good | B Cluster | 1 | + | Question 1 A Cluster | Incorrect answer | Bad | Unseen question within a cluster | 0 | + | Question 2 A Cluster | Correct answer | Good | B Cluster | 1 | + | Question 2 A Cluster | Incorrect answer | Bad | Unseen question within a cluster | 0 | + | Question 3 A Cluster | Correct answer | Good | B Cluster | 1 | + | Question 3 A Cluster | Incorrect answer | Bad | Unseen question within a cluster | 0 | + | End of A cluster | | | Next page | 0 | + | B Cluster | | | Unseen question within a cluster | 0 | + | Question 1 B Cluster | Correct answer | Good | C Cluster | 1 | + | Question 1 B Cluster | Incorrect answer | Bad | Unseen question within a cluster | 0 | + | Question 2 B Cluster | Correct answer | Good | C Cluster | 1 | + | Question 2 B Cluster | Incorrect answer | Bad | Unseen question within a cluster | 0 | + | Question 3 B Cluster | Correct answer | Good | C Cluster | 1 | + | Question 3 B Cluster | Incorrect answer | Bad | Unseen question within a cluster | 0 | + | End of B cluster | | | Next page | 0 | + | C Cluster | | | Unseen question within a cluster | 0 | + | Question 1 C Cluster | Correct answer | Good | End of lesson | 1 | + | Question 1 C Cluster | Incorrect answer | Bad | Unseen question within a cluster | 0 | + | Question 2 C Cluster | Correct answer | Good | End of lesson | 1 | + | Question 2 C Cluster | Incorrect answer | Bad | Unseen question within a cluster | 0 | + | Question 3 C Cluster | Correct answer | Good | End of lesson | 1 | + | Question 3 C Cluster | Incorrect answer | Bad | Unseen question within a cluster | 0 | + | End of C cluster | | | Next page | 0 | Scenario: Accessing as student to a cluster only lesson Given I am on the "Lesson with cluster" "lesson activity" page logged in as student1 diff --git a/mod/lesson/tests/behat/lesson_group_override.feature b/mod/lesson/tests/behat/lesson_group_override.feature index 639a61c901b..a0deacc51bc 100644 --- a/mod/lesson/tests/behat/lesson_group_override.feature +++ b/mod/lesson/tests/behat/lesson_group_override.feature @@ -32,20 +32,13 @@ Feature: Lesson group override And the following "activities" exist: | activity | name | groupmode | course | idnumber | | lesson | Test lesson name | 1 | C1 | lesson1 | - And 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 "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 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 > 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 | Scenario: Add, modify then delete a group override Given I am on the "Test lesson name" "lesson activity" page logged in as teacher1 diff --git a/mod/lesson/tests/behat/lesson_informations_at_end.feature b/mod/lesson/tests/behat/lesson_informations_at_end.feature index 22c499f2ac1..63bcbee46fa 100644 --- a/mod/lesson/tests/behat/lesson_informations_at_end.feature +++ b/mod/lesson/tests/behat/lesson_informations_at_end.feature @@ -20,31 +20,20 @@ Feature: In a lesson activity, if custom scoring is not enabled, student should And the following "activities" exist: | activity | name | course | idnumber | | lesson | Test lesson name | C1 | lesson1 | + 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 > answers" exist: + | page | answer | response | jumpto | score | + | First page name | Next page | | Next page | 0 | + | Hardest question ever | 2 | Correct answer | Next page | 1 | + | Hardest question ever | 1 | Incorrect answer | This page | 0 | And I am on the "Test lesson name" "lesson activity editing" page logged in as teacher1 And I set the following fields to these values: | Maximum grade | 75 | | Custom scoring | No | 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 question page" from the "qtype" singleselect - 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 | Hardest question ever | - | Page contents | 1 + 1? | - | id_answer_editor_0 | 2 | - | id_response_editor_0 | Correct answer | - | id_jumpto_0 | Next page | - | id_answer_editor_1 | 1 | - | id_response_editor_1 | Incorrect answer | - | id_jumpto_1 | This page | - And I press "Save page" And I am on "Course 1" course homepage with editing mode on And I duplicate "Test lesson name" activity And I wait until section "1" is available diff --git a/mod/lesson/tests/behat/lesson_navigation.feature b/mod/lesson/tests/behat/lesson_navigation.feature index 0f197c55ebf..d329ba753d4 100644 --- a/mod/lesson/tests/behat/lesson_navigation.feature +++ b/mod/lesson/tests/behat/lesson_navigation.feature @@ -19,42 +19,20 @@ Feature: In a lesson activity, students can navigate through a series of pages i And the following "activities" exist: | activity | name | course | idnumber | | lesson | Test lesson name | C1 | lesson1 | - And I log in as "teacher1" Scenario: Student navigation with pages and questions - Given I am on the "Test lesson name" "lesson activity" page - 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 I select edit type "Expanded" - 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 "Numerical" - And I press "Add a question page" - And I set the following fields to these values: - | Page title | Hardest question ever | - | Page contents | 1 + 1? | - | id_answer_editor_0 | 2 | - | id_response_editor_0 | Correct answer | - | id_jumpto_0 | End of lesson | - | id_score_0 | 1 | - | id_answer_editor_1 | 1 | - | id_response_editor_1 | Incorrect answer | - | id_jumpto_1 | Second page name | - | id_score_1 | 0 | - And I press "Save page" + 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 | numeric | Hardest question ever | 1 + 1? | + 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 | + | Second page name | Next page | | Next page | 0 | + | Hardest question ever | 2 | Correct answer | End of lesson | 1 | + | Hardest question ever | 1 | Incorrect answer | Second page name | 0 | When I am on the "Test lesson name" "lesson activity" page logged in as student1 Then I should see "First page contents" And I press "Next page" @@ -84,21 +62,18 @@ Feature: In a lesson activity, students can navigate through a series of pages i And I should see "Your score is 0 (out of 1)." Scenario: Student reattempts a question until out of attempts - Given I am on the "Test lesson name" "lesson activity editing" page + Given the following "mod_lesson > page" exist: + | lesson | qtype | title | content | + | Test lesson name | truefalse | Test question | Test content | + And the following "mod_lesson > answers" exist: + | page | answer | jumpto | score | + | Test question | right | Next page | 1 | + | Test question | wrong | This page | 0 | + And I am on the "Test lesson name" "lesson activity editing" page logged in as teacher1 And I set the following fields to these values: | id_review | Yes | | id_maxattempts | 3 | And I press "Save and display" - And I follow "Add a question page" - And I set the following fields to these values: - | id_qtype | True/false | - And I press "Add a question page" - And I set the following fields to these values: - | Page title | Test question | - | Page contents | Test content | - | id_answer_editor_0 | right | - | id_answer_editor_1 | wrong | - And I press "Save page" When I am on the "Test lesson name" "lesson activity" page logged in as student1 Then I should see "Test content" And I set the following fields to these values: @@ -121,32 +96,21 @@ Feature: In a lesson activity, students can navigate through a series of pages i And I should see "Congratulations - end of lesson reached" Scenario: Student reattempts a question until out of attempts with specific jumps - Given I am on the "Test lesson name" "lesson activity editing" page + Given the following "mod_lesson > pages" exist: + | lesson | qtype | title | content | + | Test lesson name | truefalse | Test question | Test content 1 | + | Test lesson name | truefalse | Test question 2 | Test content 2 | + And the following "mod_lesson > answers" exist: + | page | answer | jumpto | score | + | Test question | right | Next page | 1 | + | Test question | wrong | This page | 0 | + | Test question 2 | right | Test question | 1 | + | Test question 2 | wrong | Test question | 0 | + And I am on the "Test lesson name" "lesson activity editing" page logged in as teacher1 And I set the following fields to these values: - | id_review | Yes | - | id_maxattempts | 3 | + | id_review | Yes | + | id_maxattempts | 3 | And I press "Save and display" - And I follow "Add a question page" - And I set the following fields to these values: - | id_qtype | True/false | - And I press "Add a question page" - And I set the following fields to these values: - | Page title | Test question | - | Page contents | Test content 1 | - | id_answer_editor_0 | right | - | id_answer_editor_1 | wrong | - And I press "Save page" - And I select "Add a question page" from the "qtype" singleselect - 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 | Test question 2 | - | Page contents | Test content 2 | - | id_answer_editor_0 | right | - | id_jumpto_0 | Test question | - | id_answer_editor_1 | wrong | - | id_jumpto_1 | Test question | - And I press "Save page" When I am on the "Test lesson name" "lesson activity" page logged in as student1 Then I should see "Test content 1" And I set the following fields to these values: @@ -173,21 +137,18 @@ Feature: In a lesson activity, students can navigate through a series of pages i And I should see "Test content 1" Scenario: Student should not see remaining attempts notification if maximum number of attempts is set to unlimited - Given I am on the "Test lesson name" "lesson activity editing" page + Given the following "mod_lesson > page" exist: + | lesson | qtype | title | content | + | Test lesson name | truefalse | Test question | Test content | + And the following "mod_lesson > answers" exist: + | page | answer | jumpto | score | + | Test question | right | Next page | 1 | + | Test question | wrong | This page | 0 | + And I am on the "Test lesson name" "lesson activity editing" page logged in as teacher1 And I set the following fields to these values: | id_review | Yes | | id_maxattempts | 0 | And I press "Save and display" - And I follow "Add a question page" - And I set the following fields to these values: - | id_qtype | True/false | - And I press "Add a question page" - And I set the following fields to these values: - | Page title | Test question | - | Page contents | Test content | - | id_answer_editor_0 | right | - | id_answer_editor_1 | wrong | - And I press "Save page" When I am on the "Test lesson name" "lesson activity" page logged in as student1 Then I should see "Test content" And I set the following fields to these values: diff --git a/mod/lesson/tests/behat/lesson_number_of_student_attempts.feature b/mod/lesson/tests/behat/lesson_number_of_student_attempts.feature index 310052d1d0a..74fc49a94a9 100644 --- a/mod/lesson/tests/behat/lesson_number_of_student_attempts.feature +++ b/mod/lesson/tests/behat/lesson_number_of_student_attempts.feature @@ -27,7 +27,20 @@ Feature: In Dashboard, teacher can see the number of student attempts to lessons | idnumber | 0001 | | name | Test lesson name | | retake | 1 | - When I am on the "Test lesson name" "lesson activity editing" page + And the following "mod_lesson > pages" exist: + | lesson | qtype | title | content | + | Test lesson name | truefalse | True/false question 1 | Cat is an amphibian | + | Test lesson name | truefalse | True/false question 2 | Paper is made from trees. | + | Test lesson name | truefalse | True/false question 3 | 1+1=2 | + 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 | + | True/false question 2 | True | Correct | Next page | 1 | + | True/false question 2 | False | Wrong | This page | 0 | + | True/false question 3 | True | Correct | Next page | 1 | + | True/false question 3 | False | Wrong | This page | 0 | + And I am on the "Test lesson name" "lesson activity editing" page And I expand all fieldsets And I set the following fields to these values: | id_deadline_enabled | 1 | @@ -37,47 +50,7 @@ Feature: In Dashboard, teacher can see the number of student attempts to lessons | deadline[hour] | 08 | | deadline[minute] | 00 | And I press "Save and display" - And 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 select "Add a question page" from the "qtype" singleselect - 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 select edit type "Expanded" - 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 "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 am on the "Test lesson name" "lesson activity" page logged in as student1 + When I am on the "Test lesson name" "lesson activity" page logged in as student1 And I should see "Cat is an amphibian" And I set the following fields to these values: | False | 1 | diff --git a/mod/lesson/tests/behat/lesson_numerical_question_with_locale.feature b/mod/lesson/tests/behat/lesson_numerical_question_with_locale.feature index 1be05ec5fab..a94fcfded78 100644 --- a/mod/lesson/tests/behat/lesson_numerical_question_with_locale.feature +++ b/mod/lesson/tests/behat/lesson_numerical_question_with_locale.feature @@ -19,22 +19,37 @@ Feature: In a lesson activity, I need to edit pages in the lesson taking into ac And the following "activities" exist: | activity | name | course | idnumber | modattempts | | lesson | Test lesson name | C1 | lesson1 | 1 | - And I am on the "Test lesson name" "lesson activity" page logged in as teacher1 - And I follow "Add a question page" + And the following "mod_lesson > page" exist: + | lesson | qtype | title | content | + | Test lesson name | numeric | Hardest question ever | 1 + 1? | + And the following "mod_lesson > answers" exist: + | page | answer | response | jumpto | score | + | Hardest question ever | 2.87 | Correct answer | End of lesson | 1 | + | Hardest question ever | 2.1:2.8 | Incorrect answer | This page | 0 | + + Scenario: Create a numerical question with the locale specific variables + Given the following "activities" exist: + | activity | name | course | idnumber | modattempts | + | lesson | Empty lesson name | C1 | lesson2 | 1 | + And I am on the "Empty lesson name" "lesson activity" page logged in as teacher1 + When 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 | Hardest question ever | - | Page contents | 1 + 1? | - | id_answer_editor_0 | 2#87 | + | Page title | Second question | + | Page contents | 2 + 2? | + | id_answer_editor_0 | 4#87 | | id_response_editor_0 | Correct answer | | id_jumpto_0 | End of lesson | | id_score_0 | 1 | - | id_answer_editor_1 | 2#1:2#8 | + | id_answer_editor_1 | 4#1:4#8 | | id_response_editor_1 | Incorrect answer | | id_jumpto_1 | This page | | id_score_1 | 0 | And I press "Save page" + And I follow "Second question" + Then I should see "4#87" + And I should see "4#1:4#8" Scenario: Edit a numerical question with the locale specific variables Given I am on the "Test lesson name" "lesson activity" page logged in as teacher1 diff --git a/mod/lesson/tests/behat/lesson_outline_report.feature b/mod/lesson/tests/behat/lesson_outline_report.feature index d31470bb6b9..fd922442b7c 100644 --- a/mod/lesson/tests/behat/lesson_outline_report.feature +++ b/mod/lesson/tests/behat/lesson_outline_report.feature @@ -24,62 +24,35 @@ Feature: Teachers can review student progress on all lessons in a course by view And I am on the "Test lesson name" "lesson activity" page logged in as teacher1 Scenario: View student progress for lesson that was never attempted - 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 select "Add a question page" from the "qtype" singleselect - 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" - When I am on "Course 1" course homepage + 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 > answers" exist: + | page | answer | response | jumpto | score | + | First page name | Next page | | Next page | 0 | + | True/false question 1 | True | Correct | Next page | 1 | + | True/false question 1 | False | Wrong | This page | 0 | + When I log in as "teacher1" + And I am on "Course 1" course homepage And I navigate to course participants And I follow "Student 1" And I follow "Outline report" 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 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 question page" from the "qtype" singleselect - 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 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" + 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 > answers" exist: + | page | answer | response | jumpto | score | + | First page name | Next page | | Next page | 0 | + | Second page name | Previous page | | Previous page | 0 | + | Second page name | Next page | | Next page | 0 | + | True/false question 1 | True | Correct | Next page | 1 | + | True/false question 1 | False | Wrong | This page | 0 | When I am on the "Test lesson name" "lesson activity" page logged in as student1 And I should see "First page contents" And I press "Next page" @@ -90,35 +63,18 @@ Feature: Teachers can review student progress on all lessons in a course by view And I should see "Lesson has been started, but not yet completed" Scenario: View student progress for a lesson containing both content and 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 select "Add a question page" from the "qtype" singleselect - 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 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" + 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 > answers" exist: + | page | answer | response | jumpto | score | + | First page name | Next page | | Next page | 0 | + | Second page name | Previous page | | Previous page | 0 | + | Second page name | Next page | | Next page | 0 | + | True/false question 1 | True | Correct | Next page | 1 | + | True/false question 1 | False | Wrong | This page | 0 | When I am on the "Test lesson name" "lesson activity" page logged in as student1 And I should see "First page contents" And I press "Next page" @@ -137,22 +93,15 @@ Feature: Teachers can review student progress on all lessons in a course by view And I should see "Grade: 100.00 / 100.00" Scenario: View student attempts in a lesson containing 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 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 | End of lesson | - | id_jumpto_1 | End of lesson | - And I press "Save page" + 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 > answers" exist: + | page | answer | jumpto | score | + | First page name | Next page | Next page | 0 | + | Second page name | Previous page | Previous page | 0 | + | Second page name | End of lesson | End of lesson | 0 | When I am on the "Test lesson name" "lesson activity" page logged in as student1 And I should see "First page contents" And I press "Next page" diff --git a/mod/lesson/tests/behat/lesson_practice.feature b/mod/lesson/tests/behat/lesson_practice.feature index 38beffc38d7..9d7a8e2b528 100644 --- a/mod/lesson/tests/behat/lesson_practice.feature +++ b/mod/lesson/tests/behat/lesson_practice.feature @@ -21,17 +21,14 @@ Feature: Practice mode in a lesson activity | course | C1 | | idnumber | 0001 | | name | Test lesson name | - And 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 "True/false" - And I press "Add a question page" - And I set the following fields to these values: - | Page title | True or False | - | Page contents | Paper is made from trees. | - | id_answer_editor_0 | True | - | id_answer_editor_1 | False | - And I press "Save page" - And I am on the "Test lesson name" "lesson activity editing" page + And the following "mod_lesson > page" exist: + | lesson | qtype | title | content | + | Test lesson name | truefalse | True or False | Paper is made from trees. | + And the following "mod_lesson > answers" exist: + | page | answer | jumpto | score | + | True or False | True | Next page | 1 | + | True or False | False | This page | 0 | + And I am on the "Test lesson name" "lesson activity editing" page logged in as teacher1 Scenario: Non-practice lesson records grades in the gradebook Given I set the following fields to these values: diff --git a/mod/lesson/tests/behat/lesson_progress_bar.feature b/mod/lesson/tests/behat/lesson_progress_bar.feature index 8fba00a7219..d8e7ba1e1ac 100644 --- a/mod/lesson/tests/behat/lesson_progress_bar.feature +++ b/mod/lesson/tests/behat/lesson_progress_bar.feature @@ -19,42 +19,22 @@ Feature: In a lesson activity, students can see their progress viewing a progres And the following "activities" exist: | activity | name | course | idnumber | | lesson | Test lesson name | C1 | lesson1 | + 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 > answers" exist: + | page | answer | response | jumpto | score | + | First page name | Next page | | Next page | 0 | + | Second page name | Previous page | | Previous page | 0 | + | Second page name | Next page | | Next page | 0 | + | Hardest question ever | 2 | Correct answer | End of lesson | 1 | + | Hardest question ever | 1 | Incorrect answer | First page name | 0 | And I am on the "Test lesson name" "lesson activity editing" page logged in as teacher1 And I set the following fields to these values: | Progress bar | Yes | 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 I select edit type "Expanded" - 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 "Numerical" - And I press "Add a question page" - And I set the following fields to these values: - | Page title | Hardest question ever | - | Page contents | 1 + 1? | - | id_answer_editor_0 | 2 | - | id_response_editor_0 | Correct answer | - | id_jumpto_0 | End of lesson | - | id_score_0 | 1 | - | id_answer_editor_1 | 1 | - | id_response_editor_1 | Incorrect answer | - | id_jumpto_1 | Second page name | - | id_score_1 | 0 | - And I press "Save page" When I am on the "Test lesson name" "lesson activity" page logged in as student1 Then I should see "First page contents" And I should see "You have completed 0% of the lesson" diff --git a/mod/lesson/tests/behat/lesson_question_attempts.feature b/mod/lesson/tests/behat/lesson_question_attempts.feature index 48721426b5c..110f626a9b7 100644 --- a/mod/lesson/tests/behat/lesson_question_attempts.feature +++ b/mod/lesson/tests/behat/lesson_question_attempts.feature @@ -22,71 +22,27 @@ Feature: In a lesson activity, students can not re-attempt a question more than | name | Test lesson name | | retake | 1 | | minquestions | 3 | - 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 | 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 | 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 select "Add a question page" from the "qtype" singleselect - 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 | 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 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 I select "Add a question page" from the "qtype" singleselect - 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 select "Add a question page" from the "qtype" singleselect - 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 | The earth is round. | - | 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 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 | The earth is round. | + | Test lesson name | truefalse | True/false question 2 | Kermit is a frog | + | Test lesson name | content | Second page name | Second page contents | + | Test lesson name | truefalse | True/false question 3 | Paper is made from trees. | + | Test lesson name | content | Third page name | Third page contents | + 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 | + | Second page name | Next page | | Next page | 0 | + | True/false question 1 | True | Correct | Next page | 1 | + | True/false question 1 | False | Wrong | This page | 0 | + | True/false question 2 | True | Correct | Next page | 1 | + | True/false question 2 | False | Wrong | This page | 0 | + | True/false question 3 | True | Correct | Next page | 1 | + | True/false question 3 | False | Wrong | This page | 0 | + | Third page name | Previous page | | Previous page | 0 | + | Third page name | Next page | | Next page | 0 | Scenario: Check that we can leave a quiz and when we re-enter we can not re-attempt the question again Given I am on the "Test lesson name" "lesson activity" page logged in as student1 diff --git a/mod/lesson/tests/behat/lesson_report.feature b/mod/lesson/tests/behat/lesson_report.feature index ee2b9074bc9..cdb850b66b5 100644 --- a/mod/lesson/tests/behat/lesson_report.feature +++ b/mod/lesson/tests/behat/lesson_report.feature @@ -19,60 +19,26 @@ Feature: In a lesson activity, teachers can review student attempts And the following "activities" exist: | activity | name | course | idnumber | retake | | lesson | Test lesson name | C1 | lesson1 | 1 | - And I am on the "Test lesson name" "lesson activity" page logged in as teacher1 Scenario: View student attempts in a lesson containing both content and 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 select "Add a question page" from the "qtype" singleselect - 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 select "Add a question page" from the "qtype" singleselect - 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 select "Add a content page" from the "qtype" singleselect - 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 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" + 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 | content | Third page name | Third page contents | + | Test lesson name | truefalse | True/false question 1 | Paper is made from trees. | + | Test lesson name | truefalse | True/false question 2 | Kermit is a frog | + 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 | + | Second page name | Next page | | Next page | 0 | + | Third page name | Previous page | | Previous page | 0 | + | Third page name | Next page | | Next page | 0 | + | True/false question 1 | True | Correct | Next page | 1 | + | True/false question 1 | False | Wrong | This page | 0 | + | True/false question 2 | True | Correct | Next page | 1 | + | True/false question 2 | False | Wrong | This page | 0 | When I am on the "Test lesson name" "lesson activity" page logged in as student1 And I should see "First page contents" And I press "Next page" @@ -100,40 +66,21 @@ Feature: In a lesson activity, teachers can review student attempts And I should see "Low score" Scenario: View student attempts in a lesson containing 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 select "Add a content page" from the "qtype" singleselect - 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 select "Add a content page" from the "qtype" singleselect - 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 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" + 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 | content | Third page name | Third page contents | + | Test lesson name | content | Fourth page name | Fourth page contents | + And the following "mod_lesson > answers" 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 | + | Third page name | Previous page | Previous page | + | Third page name | Next page | Next page | + | Fourth page name | Previous page | Previous page | + | Fourth page name | End of lesson | End of lesson | When I am on the "Test lesson name" "lesson activity" page logged in as student1 And I should see "First page contents" And I press "Next page" diff --git a/mod/lesson/tests/behat/lesson_report_detailed_statistics.feature b/mod/lesson/tests/behat/lesson_report_detailed_statistics.feature index 16f275ce328..f741b275a26 100644 --- a/mod/lesson/tests/behat/lesson_report_detailed_statistics.feature +++ b/mod/lesson/tests/behat/lesson_report_detailed_statistics.feature @@ -24,15 +24,12 @@ Feature: In a lesson activity, teachers can view detailed statistics report And I am on the "Test lesson name" "lesson activity" page logged in as teacher1 Scenario: View detailed statistics in a lesson when empty string is given as answer - Given 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 + 0.5? | - | id_answer_editor_0 | 1.5 | - | id_jumpto_0 | End of lesson | - 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 + 0.5? | + And the following "mod_lesson > answer" exist: + | page | answer | jumpto | score | + | Numerical question | 1.5 | End of lesson | 1 | When I am on the "Test lesson name" "lesson activity" page logged in as student1 And I press "Submit" And I log out diff --git a/mod/lesson/tests/behat/lesson_review.feature b/mod/lesson/tests/behat/lesson_review.feature index 5fe06a81309..7169af8adb2 100644 --- a/mod/lesson/tests/behat/lesson_review.feature +++ b/mod/lesson/tests/behat/lesson_review.feature @@ -16,9 +16,19 @@ Feature: In a lesson activity, students can review the answers they gave to ques | user | course | role | | teacher1 | C1 | editingteacher | | student1 | C1 | student | - Given the following "activities" exist: + And the following "activity" exist: | activity | name | course | idnumber | | lesson | Test lesson name | C1 | lesson1 | + And the following "mod_lesson > pages" exist: + | lesson | qtype | title | content | + | Test lesson name | numeric | Hardest question ever | 1 + 1? | + | Test lesson name | truefalse | Next question | Paper is made from trees. | + And the following "mod_lesson > answers" exist: + | page | answer | response | jumpto | score | + | Hardest question ever | 2 | Correct answer | Next page | 1 | + | Hardest question ever | 1 | Incorrect answer | This page | 0 | + | Next question | True | Correct | Next page | 1 | + | Next question | False | Wrong | This page | 0 | And I am on the "Test lesson name" "lesson activity editing" page logged in as teacher1 And I set the following fields to these values: | Display ongoing score | Yes | @@ -29,32 +39,6 @@ Feature: In a lesson activity, students can review the answers they gave to ques | Custom scoring | No | | Re-takes allowed | Yes | And I press "Save and display" - 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 | Hardest question ever | - | Page contents | 1 + 1? | - | id_answer_editor_0 | 2 | - | id_response_editor_0 | Correct answer | - | id_jumpto_0 | Next page | - | id_answer_editor_1 | 1 | - | id_response_editor_1 | Incorrect answer | - | id_jumpto_1 | This page | - And I press "Save page" - And I select "Add a question page" from the "qtype" singleselect - 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 | Next question | - | 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 am on the "Test lesson name" "lesson activity" page logged in as student1 And I should see "You have answered 0 correctly out of 0 attempts." And I set the following fields to these values: diff --git a/mod/lesson/tests/behat/lesson_student_dashboard.feature b/mod/lesson/tests/behat/lesson_student_dashboard.feature deleted file mode 100644 index 1ca18de2304..00000000000 --- a/mod/lesson/tests/behat/lesson_student_dashboard.feature +++ /dev/null @@ -1,325 +0,0 @@ -@mod @mod_lesson -Feature: In Dashboard, a student can see their current status on all lessons with an upcoming due date - In order to know my status on a lesson - As a student - I need to see it in Dashboard - - Background: - Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | Teacher | 1 | teacher1@example.com | - | student1 | Student | 1 | student1@example.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 the following "activities" exist: - | activity | name | deadline | retake | course | idnumber | - | lesson | Test lesson name | 1893481200 | 1 | C1 | lesson1 | - - Scenario: A completed lesson with only questions that allows multiple attempts - 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 "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 select "Add a question page" from the "qtype" singleselect - 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 am on the "Test lesson name" "lesson activity" page logged in as student1 - 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: - | False | 1 | - And I press "Submit" - And I press "Continue" - And I should see "Congratulations - end of lesson reached" - - Scenario: A completed lesson with only questions that does not allow multiple attempts - Given I am on the "Test lesson name" "lesson activity editing" page logged in as teacher1 - And I set the following fields to these values: - | Re-takes allowed | 0 | - And I press "Save and display" - And 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 select "Add a question page" from the "qtype" singleselect - 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 am on the "Test lesson name" "lesson activity" page logged in as student1 - 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: - | False | 1 | - And I press "Submit" - And I press "Continue" - And I should see "Congratulations - end of lesson reached" - - Scenario: A completed lesson with only content pages that allows multiple attempts - Given 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 | 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 | End of lesson | - | id_jumpto_1 | End of lesson | - And I press "Save page" - And I am on the "Test lesson name" "lesson activity" page logged in as student1 - And I should see "First page contents" - And I press "Next page" - And I should see "Second page contents" - And I press "End of lesson" - - Scenario: A completed lesson with only content pages that does not allow multiple attempts - Given I am on the "Test lesson name" "lesson activity editing" page logged in as teacher1 - And I set the following fields to these values: - | Re-takes allowed | 0 | - 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 | End of lesson | - | id_jumpto_1 | End of lesson | - And I press "Save page" - And I am on the "Test lesson name" "lesson activity" page logged in as student1 - And I should see "First page contents" - And I press "Next page" - And I should see "Second page contents" - And I press "End of lesson" - - Scenario: An incomplete lesson with only questions. - 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 "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 select "Add a question page" from the "qtype" singleselect - 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 am on the "Test lesson name" "lesson activity" page logged in as student1 - 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" - - Scenario: An incomplete lesson with only content pages. - Given 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 | 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 | End of lesson | - | id_jumpto_1 | End of lesson | - And I press "Save page" - And I am on the "Test lesson name" "lesson activity" page logged in as student1 - And I should see "First page contents" - And I press "Next page" - And I should see "Second page contents" - - Scenario: A lesson with only questions that has not been started. - 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 "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 select "Add a question page" from the "qtype" singleselect - 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" - - Scenario: A lesson with only content pages that has not been started. - Given 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 | 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 | End of lesson | - | id_jumpto_1 | End of lesson | - And I press "Save page" - - Scenario: Viewing the status for multiple lessons in multiple courses - Given the following "courses" exist: - | fullname | shortname | category | - | Course 2 | C2 | 0 | - And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C2 | editingteacher | - | student1 | C2 | student | - And the following "activities" exist: - | activity | name | deadline | retake | course | idnumber | - | lesson | Test lesson name 2 | 1893481200 | 1 | C1 | lesson1 | - | lesson | Test lesson name 3 | 1893481200 | 1 | C2 | lesson1 | - And 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 "True/false" - And I press "Add a question page" - And I set the following fields to these values: - | Page title | True/false question | - | Page contents | D035 M00d13 r0x0rz j00 b0x0rs? | - | id_answer_editor_0 | True | - | id_answer_editor_1 | False | - And I press "Save page" - And I am on the "Test lesson name 2" "lesson activity" page - And 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 | - | Page contents | D035 M00d13 r0x0rz j00 b0x0rs? | - | id_answer_editor_0 | True | - | id_answer_editor_1 | False | - And I press "Save page" - And I am on the "Test lesson name 3" "lesson activity" page - And 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 | D035 M00d13 r0x0rz j00 b0x0rs? | - | id_answer_editor_0 | True | - | id_answer_editor_1 | False | - And I press "Save page" - And I select "Add a question page" from the "qtype" singleselect - 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 | D035 M00d13 r0x0rz j00 b0x0rs? | - | id_answer_editor_0 | True | - | id_answer_editor_1 | False | - And I press "Save page" - And I am on the "Test lesson name" "lesson activity" page logged in as student1 - And I should see "D035 M00d13 r0x0rz j00 b0x0rs?" - And I set the following fields to these values: - | True | 1 | - And I press "Submit" - And I am on the "Test lesson name 3" "lesson activity" page - And I should see "D035 M00d13 r0x0rz j00 b0x0rs?" - And I set the following fields to these values: - | True | 1 | - And I press "Submit" diff --git a/mod/lesson/tests/behat/lesson_student_resume.feature b/mod/lesson/tests/behat/lesson_student_resume.feature index 73be4605071..124b603a430 100644 --- a/mod/lesson/tests/behat/lesson_student_resume.feature +++ b/mod/lesson/tests/behat/lesson_student_resume.feature @@ -20,60 +20,26 @@ Feature: In a lesson activity a student should | course | C1 | | idnumber | 0001 | | retake | 1 | - And I am on the "Test lesson name" "lesson activity" page logged in as teacher1 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 select "Add a question page" from the "qtype" singleselect - 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 select "Add a question page" from the "qtype" singleselect - 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 select "Add a content page" from the "qtype" singleselect - 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 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" + 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 | content | Third page name | Third page contents | + | Test lesson name | truefalse | True/false question 1 | Paper is made from trees. | + | Test lesson name | truefalse | True/false question 2 | Kermit is a frog | + 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 | + | Second page name | Next page | | Next page | 0 | + | Third page name | Previous page | | Previous page | 0 | + | Third page name | Next page | | Next page | 0 | + | True/false question 1 | True | Correct | Next page | 1 | + | True/false question 1 | False | Wrong | This page | 0 | + | True/false question 2 | True | Correct | Next page | 1 | + | True/false question 2 | False | Wrong | This page | 0 | When I am on the "Test lesson name" "lesson activity" page logged in as student1 And I should see "First page contents" And I press "Next page" @@ -116,40 +82,21 @@ Feature: In a lesson activity a student should And I should see "Congratulations - end of lesson reached" 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 select "Add a content page" from the "qtype" singleselect - 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 select "Add a content page" from the "qtype" singleselect - 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 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" + 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 | content | Third page name | Third page contents | + | Test lesson name | content | Fourth page name | Fourth page contents | + And the following "mod_lesson > answers" 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 | + | Third page name | Previous page | Previous page | + | Third page name | Next page | Next page | + | Fourth page name | Previous page | Previous page | + | Fourth page name | End of lesson | End of lesson | When I am on the "Test lesson name" "lesson activity" page logged in as student1 And I should see "First page contents" And I press "Next page" @@ -173,92 +120,36 @@ Feature: In a lesson activity a student should And I should see "First page contents" 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 select "Add a question page" from the "qtype" singleselect - 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 select "Add a content page" from the "qtype" singleselect - 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 select "Add a question page" from the "qtype" singleselect - 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 select "Add a question page" from the "qtype" singleselect - 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 select "Add a question page" from the "qtype" singleselect - 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 select "Add a content page" from the "qtype" singleselect - 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" + Given the following "mod_lesson > pages" exist: + | lesson | qtype | title | content | + | Test lesson name | truefalse | True/false question 1 | Cat is an amphibian | + | Test lesson name | content | First page name | First page contents | + | Test lesson name | truefalse | True/false question 2 | Paper is made from trees. | + | Test lesson name | truefalse | True/false question 3 | 1+1=2 | + | Test lesson name | truefalse | True/false question 4 | 2+2=4 | + | Test lesson name | content | Second page name | Second page contents | + | Test lesson name | truefalse | True/false question 5 | Kermit is a frog | + 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 | + | First page name | Next page | | Next page | 0 | + | True/false question 2 | True | Correct | Next page | 1 | + | True/false question 2 | False | Wrong | This page | 0 | + | True/false question 3 | True | Correct | Next page | 1 | + | True/false question 3 | False | Wrong | This page | 0 | + | True/false question 4 | True | Correct | Next page | 1 | + | True/false question 4 | False | Wrong | This page | 0 | + | Second page name | Next page | | Next page | 0 | + | True/false question 5 | True | Correct | Next page | 1 | + | True/false question 5 | False | Wrong | This page | 0 | When I am on the "Test lesson name" "lesson activity" page logged in as student1 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 should see "First page contents" And I press "Next page" And I should see "Paper is made from trees." And I set the following fields to these values: @@ -285,13 +176,13 @@ Feature: In a lesson activity a student should And I wait "1" seconds And I press "Submit" And I press "Continue" - And I should see "Second content page" + And I should see "Second page contents" And I am on "Course 1" course homepage 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 should see "Second page contents" And I press "Next page" And I should see "Kermit is a frog" And I set the following fields to these values: @@ -301,71 +192,25 @@ Feature: In a lesson activity a student should And I should see "Congratulations - end of lesson reached" 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 select "Add a question page" from the "qtype" singleselect - 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 select "Add a question page" from the "qtype" singleselect - 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 select "Add a question page" from the "qtype" singleselect - 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 select "Add a question page" from the "qtype" singleselect - 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" + Given the following "mod_lesson > pages" exist: + | lesson | qtype | title | content | + | Test lesson name | truefalse | True/false question 1 | Cat is an amphibian | + | Test lesson name | truefalse | True/false question 2 | Paper is made from trees. | + | Test lesson name | truefalse | True/false question 3 | 1+1=2 | + | Test lesson name | truefalse | True/false question 4 | 2+2=4 | + | Test lesson name | truefalse | True/false question 5 | Kermit is a frog | + 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 | + | True/false question 2 | True | Correct | Next page | 1 | + | True/false question 2 | False | Wrong | This page | 0 | + | True/false question 3 | True | Correct | Next page | 1 | + | True/false question 3 | False | Wrong | This page | 0 | + | True/false question 4 | True | Correct | Next page | 1 | + | True/false question 4 | False | Wrong | This page | 0 | + | True/false question 5 | True | Correct | Next page | 1 | + | True/false question 5 | False | Wrong | This page | 0 | When I am on the "Test lesson name" "lesson activity" page logged in as student1 And I should see "Cat is an amphibian" And I set the following fields to these values: diff --git a/mod/lesson/tests/behat/lesson_user_override.feature b/mod/lesson/tests/behat/lesson_user_override.feature index 47a33997384..df9847047ed 100644 --- a/mod/lesson/tests/behat/lesson_user_override.feature +++ b/mod/lesson/tests/behat/lesson_user_override.feature @@ -21,20 +21,13 @@ Feature: Lesson user override And the following "activities" exist: | activity | name | course | idnumber | | lesson | Test lesson name | C1 | lesson1 | - And 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 "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 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 > 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 | @javascript Scenario: Add, modify then delete a user override diff --git a/mod/lesson/tests/behat/lesson_with_clusters.feature b/mod/lesson/tests/behat/lesson_with_clusters.feature index ee5f1ce1b3d..b88bc1aff56 100644 --- a/mod/lesson/tests/behat/lesson_with_clusters.feature +++ b/mod/lesson/tests/behat/lesson_with_clusters.feature @@ -22,102 +22,39 @@ Feature: In a lesson activity, students can see questions in random order And I log in as "teacher1" Scenario: Lesson with two clusters - Given I am on the "Lesson with clusters" "lesson activity" page - 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 I select edit type "Expanded" - And I click on "Add a cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][3]" "xpath_element" - 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 1 | - | Page contents | Question from cluster 1 | - | 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 ')][5]" "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 1 | - | 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 ')][6]" "xpath_element" - And I click on "Add a content page" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][7]" "xpath_element" - And I set the following fields to these values: - | Page title | Third page name | - | Page contents | Content page after cluster 1 | - | id_answer_editor_0 | Next page | - | id_jumpto_0 | Next page | - And I press "Save page" - And I click on "Add a cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][8]" "xpath_element" - And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][9]" "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 3 | - | Page contents | Question from cluster 2 | - | id_answer_editor_0 | Correct answer | - | id_response_editor_0 | Good | - | id_jumpto_0 | Unseen question within a 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 ')][10]" "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 4 | - | Page contents | Question from cluster 2 | - | id_answer_editor_0 | Correct answer | - | id_response_editor_0 | Good | - | id_jumpto_0 | Unseen question within a 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 ')][11]" "xpath_element" - And I click on "Add a content page" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][12]" "xpath_element" - And I set the following fields to these values: - | Page title | Fourth page name | - | Page contents | Content page after cluster 2 | - | id_answer_editor_0 | Next page | - | id_jumpto_0 | Next page | - And I press "Save page" + Given the following "mod_lesson > pages" exist: + | lesson | qtype | title | content | + | Lesson with clusters | content | First page name | First page contents | + | Lesson with clusters | content | Second page name | Second page contents | + | Lesson with clusters | cluster | Cluster 1 | Cluster 1 | + | Lesson with clusters | multichoice | Question 1 | Question from cluster 1 | + | Lesson with clusters | multichoice | Question 2 | Question from cluster 1 | + | Lesson with clusters | endofcluster | End of cluster 1 | End of cluster 1 | + | Lesson with clusters | content | Third page name | Content page after cluster 1 | + | Lesson with clusters | cluster | Cluster 2 | Cluster 2 | + | Lesson with clusters | multichoice | Question 3 | Question from cluster 2 | + | Lesson with clusters | multichoice | Question 4 | Question from cluster 2 | + | Lesson with clusters | endofcluster | End of cluster 2 | End of cluster 2 | + | Lesson with clusters | content | Fourth page name | Content page after cluster 2 | + 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 | + | Second page name | Next page | | Next page | 0 | + | Cluster 1 | | | Unseen question within a cluster | 0 | + | Question 1 | Correct answer | Good | Cluster 1 | 1 | + | Question 1 | Incorrect answer | Bad | This page | 0 | + | Question 2 | Correct answer | Good | Cluster 1 | 1 | + | Question 2 | Incorrect answer | Bad | This page | 0 | + | End of cluster 1 | | | Next page | 0 | + | Third page name | Next page | | Next page | 0 | + | Cluster 2 | | | Unseen question within a cluster | 0 | + | Question 3 | Correct answer | Good | Unseen question within a cluster | 1 | + | Question 3 | Incorrect answer | Bad | This page | 0 | + | Question 4 | Correct answer | Good | Unseen question within a cluster | 1 | + | Question 4 | Incorrect answer | Bad | This page | 0 | + | End of cluster 2 | | | Next page | 0 | + | Fourth page name | Next page | | Next page | 0 | When I am on the "Lesson with clusters" "lesson activity" page logged in as student1 Then I should see "First page contents" And I press "Next page" diff --git a/mod/lesson/tests/behat/lesson_with_subcluster.feature b/mod/lesson/tests/behat/lesson_with_subcluster.feature index 006c491afcf..be6f92b492b 100644 --- a/mod/lesson/tests/behat/lesson_with_subcluster.feature +++ b/mod/lesson/tests/behat/lesson_with_subcluster.feature @@ -22,122 +22,40 @@ Feature: In a lesson activity, students can see questions in random order and a And I log in as "teacher1" Scenario: Lesson with subcluster - Given I am on the "Lesson with subcluster" "lesson activity" page - 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 a content page" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][5]" "xpath_element" - And I set the following fields to these values: - | Page title | Second page name | - | Page contents | This page mark the the beginning of the subcluster it should not be seen by students | - | id_answer_editor_0 | Next page | - | id_jumpto_0 | Next page | - And I press "Save page" - And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][6]" "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 3 | - | 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 ')][7]" "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 4 | - | 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 ')][8]" "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 5 | - | 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 branch" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][9]" "xpath_element" - And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][10]" "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 6 | - | 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 ')][11]" "xpath_element" - And I click on "Add a content page" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][12]" "xpath_element" - And I set the following fields to these values: - | Page title | Third page name | - | Page contents | Content page after cluster | - | id_answer_editor_0 | Next page | - | id_jumpto_0 | Next page | - And I press "Save page" + Given the following "mod_lesson > pages" exist: + | lesson | qtype | title | content | + | Lesson with subcluster | content | First page name | First page contents | + | Lesson with subcluster | cluster | Cluster | Cluster | + | Lesson with subcluster | multichoice | Question 1 | Question from cluster | + | Lesson with subcluster | multichoice | Question 2 | Question from cluster | + | Lesson with subcluster | content | Second page name | Beginning of the subcluster, should not be seen by students | + | Lesson with subcluster | multichoice | Question 3 | Question from cluster | + | Lesson with subcluster | multichoice | Question 4 | Question from cluster | + | Lesson with subcluster | multichoice | Question 5 | Question from cluster | + | Lesson with subcluster | endofbranch | End of branch | End of branch | + | Lesson with subcluster | multichoice | Question 6 | Question from cluster | + | Lesson with subcluster | endofcluster | End of cluster | End of cluster | + | Lesson with subcluster | content | Third 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 | + | Second page name | Next page | | Next page | 0 | + | Question 3 | Correct answer | Good | Cluster | 1 | + | Question 3 | Incorrect answer | Bad | This page | 0 | + | Question 4 | Correct answer | Good | Cluster | 1 | + | Question 4 | Incorrect answer | Bad | This page | 0 | + | Question 5 | Correct answer | Good | Cluster | 1 | + | Question 5 | Incorrect answer | Bad | This page | 0 | + | End of branch | | | Second page name | 0 | + | Question 6 | Correct answer | Good | Cluster | 1 | + | Question 6 | Incorrect answer | Bad | This page | 0 | + | End of cluster | | | Next page | 0 | + | Third page name | Next page | | Next page | 0 | When I am on the "Lesson with subcluster" "lesson activity" page logged in as student1 Then I should see "First page contents" And I press "Next page" diff --git a/mod/lesson/tests/behat/link_to_gradebook.feature b/mod/lesson/tests/behat/link_to_gradebook.feature index 6315265a45a..37b68ecf59b 100644 --- a/mod/lesson/tests/behat/link_to_gradebook.feature +++ b/mod/lesson/tests/behat/link_to_gradebook.feature @@ -19,23 +19,15 @@ Feature: link to gradebook on the end of lesson page And the following "activities" exist: | activity | name | course | idnumber | | lesson | Test lesson | C1 | lesson1 | - And I am on the "Test lesson" "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 "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 "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 > answers" 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 | Scenario: Link to gradebook for non practice lesson When I am on the "Test lesson" "lesson activity" page logged in as student1 @@ -48,7 +40,7 @@ Feature: link to gradebook on the end of lesson page And I should see "Test lesson" Scenario: No link to gradebook for non graded lesson - 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 following fields to these values: | Type | None | And I press "Save and display" @@ -59,7 +51,7 @@ Feature: link to gradebook on the end of lesson page And I should not see "View grades" Scenario: No link to gradebook for practice lesson - 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 following fields to these values: | Practice lesson | Yes | And I press "Save and display" @@ -70,7 +62,8 @@ Feature: link to gradebook on the end of lesson page And I should not see "View grades" Scenario: No link if Show gradebook to student disabled - Given I am on "Course 1" course homepage + Given I log in as "teacher1" + And I am on "Course 1" course homepage And I navigate to "Settings" in current page administration And I set the following fields to these values: | Show gradebook to students | No | diff --git a/mod/lesson/tests/behat/password_protection.feature b/mod/lesson/tests/behat/password_protection.feature index 7e348eeaddf..63ffd65404f 100644 --- a/mod/lesson/tests/behat/password_protection.feature +++ b/mod/lesson/tests/behat/password_protection.feature @@ -23,13 +23,12 @@ Feature: A teacher can password protect a lesson | name | Test lesson | | usepassword | 1 | | password | moodle_rules | - And I am on the "Test lesson" "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 | - | Description | The first one | - And I press "Save page" + Given 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 | The first one | Next page | When I am on the "Test lesson" "lesson activity" page logged in as student1 Then I should see "Test lesson is a password protected lesson" And I should not see "First page contents" diff --git a/mod/lesson/tests/behat/teacher_grade_essays.feature b/mod/lesson/tests/behat/teacher_grade_essays.feature index 2f169e81046..3f12eb5a245 100644 --- a/mod/lesson/tests/behat/teacher_grade_essays.feature +++ b/mod/lesson/tests/behat/teacher_grade_essays.feature @@ -42,17 +42,16 @@ Feature: In a lesson activity, a non editing teacher can grade essay questions And the following "activities" exist: | activity | name | course | idnumber | | lesson | Test lesson name | C1 | lesson1 | + And the following "mod_lesson > page" exist: + | lesson | qtype | title | content | + | Test lesson name | essay | Essay question |
Please write a story about a frog.
| + And the following "mod_lesson > answer" exist: + | page | jumpto | score | + | Essay question | Next page | 1 | And I am on the "Test lesson name" "lesson activity editing" page logged in as teacher1 And I set the following fields to these values: | Group mode | Separate groups | And I press "Save and display" - And I follow "Add a question page" - 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 | Essay question | - | Page contents |Please write a story about a frog.
| - And I press "Save page" And I am on the "Test lesson name" "lesson activity" page logged in as student1 And I set the field "Your answer" to "Once upon a time there was a little green frog."
And I press "Submit"
diff --git a/mod/lesson/tests/behat/time_limit.feature b/mod/lesson/tests/behat/time_limit.feature
index 420e91922b5..8024910d9be 100644
--- a/mod/lesson/tests/behat/time_limit.feature
+++ b/mod/lesson/tests/behat/time_limit.feature
@@ -20,6 +20,12 @@ Feature: A teacher can set a time limit for a lesson
And the following "activities" exist:
| activity | course | name |
| lesson | C1 | Test lesson |
+ And the following "mod_lesson > page" exist:
+ | lesson | qtype | title | content |
+ | Test lesson | content | Lesson page name | Single lesson page contents |
+ And the following "mod_lesson > answer" exist:
+ | page | answer | jumpto |
+ | Lesson page name | Single button | This page |
And I am on the "Test lesson" "lesson activity editing" page logged in as teacher1
And I expand all fieldsets
And I set the following fields to these values:
@@ -27,12 +33,6 @@ Feature: A teacher can set a time limit for a lesson
| timelimit[timeunit] | 1 |
| timelimit[number] | 10 |
And I press "Save and display"
- And I follow "Add a content page"
- And I set the following fields to these values:
- | Page title | Lesson page name |
- | Page contents | Single lesson page contents |
- | Description | Single button |
- And I press "Save page"
When I am on the "Test lesson" "lesson activity" page logged in as student1
Then I should see "You have 10 secs to finish the lesson."
And I wait "3" seconds
diff --git a/mod/lesson/tests/behat/wrong_answer_continue.feature b/mod/lesson/tests/behat/wrong_answer_continue.feature
index b9095b4e27c..270bcdd89f4 100644
--- a/mod/lesson/tests/behat/wrong_answer_continue.feature
+++ b/mod/lesson/tests/behat/wrong_answer_continue.feature
@@ -26,24 +26,15 @@ Feature: An incorrect response to an answer with multiple attempts show appropri
And I press "Save and display"
Scenario: A student answering incorrectly to a question will see an option to move to the next question if set up.
- Given 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 | Next page |
- | id_answer_editor_1 | 2 |
- | id_jumpto_1 | 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 | Just move on page |
- | Page contents | You are here to move on |
- | id_answer_editor_0 | End this lesson |
- | id_jumpto_0 | End of lesson |
- And I press "Save page"
+ Given the following "mod_lesson > pages" exist:
+ | lesson | qtype | title | content |
+ | Test lesson name | numeric | Numerical question | What is 1 + 2? |
+ | Test lesson name | content | Just move on page | You are here to move on |
+ And the following "mod_lesson > answers" exist:
+ | page | answer | jumpto | score |
+ | Numerical question | 3 | Next page | 1 |
+ | Numerical question | 2 | Next page | 0 |
+ | Just move on page | End this lesson | End of lesson | 0 |
And I am on the "Test lesson name" "lesson activity" page logged in as student1
When I set the field "Your answer" to "2"
And I press "Submit"
@@ -53,22 +44,14 @@ Feature: An incorrect response to an answer with multiple attempts show appropri
Then I should see "You are here to move on"
Scenario: A student answering incorrectly to a question will only see an option to try again if there is no matching wrong response.
- Given 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 | 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 | Just move on page |
- | Page contents | You are here to move on |
- | id_answer_editor_0 | End this lesson |
- | id_jumpto_0 | End of lesson |
- And I press "Save page"
+ Given the following "mod_lesson > pages" exist:
+ | lesson | qtype | title | content |
+ | Test lesson name | numeric | Numerical question | What is 1 + 2? |
+ | Test lesson name | content | Just move on page | You are here to move on |
+ And the following "mod_lesson > answers" exist:
+ | page | answer | jumpto | score |
+ | Numerical question | 3 | Next page | 1 |
+ | Just move on page | End this lesson | End of lesson | 0 |
And I am on the "Test lesson name" "lesson activity" page logged in as student1
When I set the field "Your answer" to "2"
And I press "Submit"
diff --git a/mod/lesson/tests/generator/behat_mod_lesson_generator.php b/mod/lesson/tests/generator/behat_mod_lesson_generator.php
new file mode 100644
index 00000000000..4e023113fa0
--- /dev/null
+++ b/mod/lesson/tests/generator/behat_mod_lesson_generator.php
@@ -0,0 +1,65 @@
+.
+
+/**
+ * Behat data generator for mod_lesson.
+ *
+ * @package mod_lesson
+ * @category test
+ * @copyright 2023 Dani Palou