From 83cd293a107eeaab6545a9995dda447ff5e93ddd Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Mon, 27 Jul 2015 19:31:39 +0100 Subject: [PATCH] MDL-50933 quiz: improve completion behat tests These now use the faster set-up methods. --- ...completion_condition_attempts_used.feature | 82 ++++++----------- ...completion_condition_passing_grade.feature | 88 ++++++------------- 2 files changed, 52 insertions(+), 118 deletions(-) diff --git a/mod/quiz/tests/behat/completion_condition_attempts_used.feature b/mod/quiz/tests/behat/completion_condition_attempts_used.feature index b69e3747ca6..405d7143607 100644 --- a/mod/quiz/tests/behat/completion_condition_attempts_used.feature +++ b/mod/quiz/tests/behat/completion_condition_attempts_used.feature @@ -6,82 +6,52 @@ Feature: Set a quiz to be marked complete when the student uses all attempts all Background: 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 | + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | And the following config values are set as admin: - | enablecompletion | 1 | - And I log in as "admin" - And I navigate to "Grade item settings" node in "Site administration > Grades" - And I set the field "Advanced grade item options" to "hiddenuntil" - And I press "Save changes" - And I log out + | enablecompletion | 1 | + | grade_item_advanced | hiddenuntil | + And the following "question categories" exist: + | contextlevel | reference | name | + | Course | C1 | Test questions | + And the following "questions" exist: + | questioncategory | qtype | name | questiontext | + | Test questions | truefalse | First question | Answer the first question | + And the following "activities" exist: + | activity | name | course | idnumber | attempts | gradepass | completion | completionattemptsexhausted | + | quiz | Test quiz name | C1 | quiz1 | 2 | 5.00 | 2 | 1 | + And quiz "Test quiz name" contains the following questions: + | question | page | + | First question | 1 | Scenario: student1 uses up both attempts without passing - When I log in as "teacher1" - And I follow "Course 1" - And I turn editing mode on - And I click on "Edit settings" "link" in the "Administration" "block" - And I set the following fields to these values: - | Enable completion tracking | Yes | - And I press "Save and display" - And I add a "Quiz" to section "1" and I fill the form with: - | Name | Test quiz name | - | Description | Test quiz description | - | Completion tracking | Show activity as complete when conditions are met | - | Attempts allowed | 2 | - | Require passing grade | 1 | - | Or all available attempts completed | 1 | - And I add a "True/False" question to the "Test quiz name" quiz with: - | Question name | First question | - | Question text | Answer the first question | - | General feedback | Thank you, this is the general feedback | - | Correct answer | True | - | Feedback for the response 'True'. | So you think it is true | - | Feedback for the response 'False'. | So you think it is false | - And I follow "Course 1" - And I navigate to "Grades" node in "Course administration" - And I navigate to "Categories and items" node in "Grade administration > Setup" - And I follow "Edit quiz Test quiz name" - Then I should see "Edit grade item" - And I set the field "gradepass" to "5" - And I press "Save changes" - And I should see "Categories and items" - Then I log out - - And I log in as "student1" + When I log in as "student1" And I follow "Course 1" And "//img[contains(@alt, 'Not completed: Test quiz name')]" "xpath_element" should exist in the "li.modtype_quiz" "css_element" And I follow "Test quiz name" And I press "Attempt quiz now" - And I should see "Question 1" - And I should see "Answer the first question" And I set the field "False" to "1" And I press "Next" - And I should see "Answer saved" And I press "Submit all and finish" And I follow "C1" And "//img[contains(@alt, 'Not completed: Test quiz name')]" "xpath_element" should exist in the "li.modtype_quiz" "css_element" And I follow "Test quiz name" And I press "Re-attempt quiz" - Then I should see "Question 1" - And I should see "Answer the first question" And I set the field "False" to "1" And I press "Next" - And I should see "Answer saved" And I press "Submit all and finish" And I follow "C1" - And "//img[contains(@alt, 'Completed: Test quiz name')]" "xpath_element" should exist in the "li.modtype_quiz" "css_element" + Then "//img[contains(@alt, 'Completed: Test quiz name')]" "xpath_element" should exist in the "li.modtype_quiz" "css_element" And I log out And I log in as "teacher1" And I follow "Course 1" - And I follow "Activity completion" - Then "//img[contains(@title,'Test quiz name') and @alt='Completed']" "xpath_element" should exist in the "Student 1" "table_row" - + And I navigate to "Activity completion" node in "Course administration > Reports" + And "//img[contains(@title,'Test quiz name') and @alt='Completed']" "xpath_element" should exist in the "Student 1" "table_row" diff --git a/mod/quiz/tests/behat/completion_condition_passing_grade.feature b/mod/quiz/tests/behat/completion_condition_passing_grade.feature index 3ae54f21220..ba735c1ab59 100644 --- a/mod/quiz/tests/behat/completion_condition_passing_grade.feature +++ b/mod/quiz/tests/behat/completion_condition_passing_grade.feature @@ -6,81 +6,45 @@ Feature: Set a quiz to be marked complete when the student passes Background: 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 | + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | And the following config values are set as admin: - | enablecompletion | 1 | - And I log in as "admin" - And I navigate to "Grade item settings" node in "Site administration > Grades" - And I set the field "Advanced grade item options" to "hiddenuntil" - And I press "Save changes" - And I log out + | enablecompletion | 1 | + | grade_item_advanced | hiddenuntil | + And the following "question categories" exist: + | contextlevel | reference | name | + | Course | C1 | Test questions | + And the following "questions" exist: + | questioncategory | qtype | name | questiontext | + | Test questions | truefalse | First question | Answer the first question | + And the following "activities" exist: + | activity | name | course | idnumber | attempts | gradepass | completion | completionpass | + | quiz | Test quiz name | C1 | quiz1 | 4 | 5.00 | 2 | 1 | + And quiz "Test quiz name" contains the following questions: + | question | page | + | First question | 1 | Scenario: student1 passes on the first try - When I log in as "teacher1" - And I follow "Course 1" - And I turn editing mode on - And I click on "Edit settings" "link" in the "Administration" "block" - And I set the following fields to these values: - | Enable completion tracking | Yes | - And I press "Save and display" - And I add a "Quiz" to section "1" and I fill the form with: - | Name | Test quiz name | - | Description | Test quiz description | - | Completion tracking | Show activity as complete when conditions are met | - | Attempts allowed | 4 | - | Require passing grade | 1 | - And I add a "True/False" question to the "Test quiz name" quiz with: - | Question name | First question | - | Question text | Answer the first question | - | General feedback | Thank you, this is the general feedback | - | Correct answer | True | - | Feedback for the response 'True'. | So you think it is true | - | Feedback for the response 'False'. | So you think it is false | - And I follow "Course 1" - And I navigate to "Grades" node in "Course administration" - And I set the field "jump" to "Categories and items" - And I press "Go" - And I follow "Edit quiz Test quiz name" - Then I should see "Edit grade item" - And I set the field "gradepass" to "5" - And I press "Save changes" - Then I should see "Categories and items" - And I log out - - And I log in as "student1" + When I log in as "student1" And I follow "Course 1" And "//img[contains(@alt, 'Not completed: Test quiz name')]" "xpath_element" should exist in the "li.modtype_quiz" "css_element" And I follow "Test quiz name" And I press "Attempt quiz now" - Then I should see "Question 1" - And I should see "Answer the first question" - And I set the field "False" to "1" - And I press "Next" - And I should see "Answer saved" - And I press "Submit all and finish" - And I follow "C1" - And "//img[contains(@alt, 'Not completed: Test quiz name')]" "xpath_element" should exist in the "li.modtype_quiz" "css_element" - And I follow "Test quiz name" - And I press "Re-attempt quiz" - Then I should see "Question 1" - And I should see "Answer the first question" And I set the field "True" to "1" And I press "Next" - And I should see "Answer saved" And I press "Submit all and finish" And I follow "C1" - And "//img[contains(@alt, 'Completed: Test quiz name')]" "xpath_element" should exist in the "li.modtype_quiz" "css_element" + Then "//img[contains(@alt, 'Completed: Test quiz name')]" "xpath_element" should exist in the "li.modtype_quiz" "css_element" And I log out And I log in as "teacher1" And I follow "Course 1" - And I follow "Activity completion" - Then "//img[contains(@title,'Test quiz name') and @alt='Completed']" "xpath_element" should exist in the "Student 1" "table_row" + And I navigate to "Activity completion" node in "Course administration > Reports" + And "//img[contains(@title,'Test quiz name') and @alt='Completed']" "xpath_element" should exist in the "Student 1" "table_row" -- 2.43.0