3ae54f212200cafa0abcb1a96140cdc300aaf500
[moodle.git] / mod / quiz / tests / behat / completion_condition_passing_grade.feature
1 @mod @mod_quiz
2 Feature: Set a quiz to be marked complete when the student passes
3   In order to ensure a student has learned the material before being marked complete
4   As a teacher
5   I need to set a quiz to complete when the student recieves a passing grade
7   Background:
8     Given the following "users" exist:
9       | username | firstname | lastname | email |
10       | student1 | Student | 1 | student1@example.com |
11       | teacher1 | Teacher | 1 | teacher1@example.com |
12     And the following "courses" exist:
13       | fullname | shortname | category |
14       | Course 1 | C1 | 0 |
15     And the following "course enrolments" exist:
16       | user | course | role |
17       | teacher1 | C1 | editingteacher |
18       | student1 | C1 | student |
19     And the following config values are set as admin:
20      | enablecompletion | 1 |
21     And I log in as "admin"
22     And I navigate to "Grade item settings" node in "Site administration > Grades"
23     And I set the field "Advanced grade item options" to "hiddenuntil"
24     And I press "Save changes"
25     And I log out
27   Scenario: student1 passes on the first try
28     When I log in as "teacher1"
29     And I follow "Course 1"
30     And I turn editing mode on
31     And I click on "Edit settings" "link" in the "Administration" "block"
32     And I set the following fields to these values:
33       | Enable completion tracking | Yes |
34     And I press "Save and display"
35     And I add a "Quiz" to section "1" and I fill the form with:
36       | Name        | Test quiz name        |
37       | Description | Test quiz description |
38       | Completion tracking | Show activity as complete when conditions are met |
39       | Attempts allowed | 4 |
40       | Require passing grade | 1 |
41     And I add a "True/False" question to the "Test quiz name" quiz with:
42       | Question name                      | First question                          |
43       | Question text                      | Answer the first question               |
44       | General feedback                   | Thank you, this is the general feedback |
45       | Correct answer                     | True                                    |
46       | Feedback for the response 'True'.  | So you think it is true                 |
47       | Feedback for the response 'False'. | So you think it is false                |
48     And I follow "Course 1"
49     And I navigate to "Grades" node in "Course administration"
50     And I set the field "jump" to "Categories and items"
51     And I press "Go"
52     And I follow "Edit  quiz Test quiz name"
53     Then I should see "Edit grade item"
54     And I set the field "gradepass" to "5"
55     And I press "Save changes"
56     Then I should see "Categories and items"
57     And I log out
59     And I log in as "student1"
60     And I follow "Course 1"
61     And "//img[contains(@alt, 'Not completed: Test quiz name')]" "xpath_element" should exist in the "li.modtype_quiz" "css_element"
62     And I follow "Test quiz name"
63     And I press "Attempt quiz now"
64     Then I should see "Question 1"
65     And I should see "Answer the first question"
66     And I set the field "False" to "1"
67     And I press "Next"
68     And I should see "Answer saved"
69     And I press "Submit all and finish"
70     And I follow "C1"
71     And "//img[contains(@alt, 'Not completed: Test quiz name')]" "xpath_element" should exist in the "li.modtype_quiz" "css_element"
72     And I follow "Test quiz name"
73     And I press "Re-attempt quiz"
74     Then I should see "Question 1"
75     And I should see "Answer the first question"
76     And I set the field "True" to "1"
77     And I press "Next"
78     And I should see "Answer saved"
79     And I press "Submit all and finish"
80     And I follow "C1"
81     And "//img[contains(@alt, 'Completed: Test quiz name')]" "xpath_element" should exist in the "li.modtype_quiz" "css_element"
82     And I log out
83     And I log in as "teacher1"
84     And I follow "Course 1"
85     And I follow "Activity completion"
86     Then "//img[contains(@title,'Test quiz name') and @alt='Completed']" "xpath_element" should exist in the "Student 1" "table_row"