You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature: Check that Python and other languages can be used instead of Twig as a template params preprocessor and that they processes the STUDENT variable correctly.
3
3
To check that the STUDENT template parameter variables work when a language other than python is the preprocessor
4
-
As a teacher
5
-
I should be able to write a function that prints the seed and my username it should be marked right
4
+
As a teacher or a student
5
+
I should be able to write a function that prints the seed and my username
6
+
It should be marked right
6
7
7
8
Background:
8
9
Given the CodeRunner test configuration file is loaded
@@ -17,92 +18,105 @@ Feature: Check that Python and other languages can be used instead of Twig as a
17
18
| user | course | role |
18
19
| teacher1 | C1 | editingteacher |
19
20
| student1 | C1 | student |
20
-
And the following "question categories" exist:
21
-
| contextlevel | reference | name |
22
-
| Course | C1 | Testquestions |
23
21
And the following "activities" exist:
24
-
| activity | name | course | idnumber |
25
-
| quiz | Testquiz | C1 | quiz1 |
26
-
And I am on the "Course 1""core_question > course question bank" page logged in as teacher1
And I set the field "item_qtype_coderunner" to "1"
34
+
And I press "submitbutton"
35
+
Then I should see "Adding a CodeRunner question"
42
36
43
-
When I choose "Edit question" action for "Python preprocessor" in the question bank
37
+
And I set the field "id_coderunnertype" to "python3"
38
+
And I set the field "id_customise" to "1"
39
+
And I set the field "id_name" to "Python preprocessor"
40
+
And I set the field "id_questiontext" to "Write a program that prints True if seed parameter provided, then {{ firstname }} {{ lastname }}"
41
+
And I set the field "id_answerboxlines" to "5"
44
42
And I set the field "id_templateparams" to "import sys, json; keyvalues = {param.split('=')[0]: param.split('=')[1] for param in sys.argv[1:]}; print(json.dumps(keyvalues))"
45
43
And I set the field "id_twigall" to "1"
46
44
And I set the field "id_template" to "print({{seed}} > 0, end=' '); {{STUDENT_ANSWER}}"
47
45
And I set the field "id_templateparamslang" to "python3"
48
46
And I set CodeRunner behat testing flag
49
47
And I set the field "id_templateparamsevalpertry" to "1"
50
-
And I press "Save changes"
51
-
52
-
And I am on the "Test quiz""mod_quiz > Edit" page logged in as teacher1
53
-
And I open the "last" add to quiz menu
54
-
And I follow "from question bank"
55
-
And I set the field with xpath "//input[@type='checkbox' and @id='qbheadercheckbox']" to "1"
56
-
And I press "Add selected questions to the quiz"
57
-
And I set CodeRunner behat testing flag
48
+
And I set the field "id_expected_0" to "True {{ firstname }} {{ lastname }}"
49
+
And I set the field "id_uiplugin" to "none"
50
+
And I press "id_submitbutton"
51
+
Then I should see "Python preprocessor Write a program that prints True if seed"
58
52
59
-
Scenario: Preview as a teacher, submit answer as a student, review as a teacher
60
-
When I am on the "Test quiz""quiz activity" page
61
-
And I press "Preview quiz"
53
+
When I am on the "Quiz 1""quiz activity" page logged in as teacher1
54
+
When I press "Preview quiz"
62
55
Then I should see "Write a program that prints True if seed parameter provided, then Teacher Last"
63
56
64
57
When I set the field with xpath "//textarea[contains(@name, 'answer')]" to "print('Teacher Last')"
65
58
And I press "Check"
66
59
Then I should see "Passed all tests"
67
60
68
61
When I log out
69
-
And I am on the "Test quiz""quiz activity" page logged in as student1
62
+
And I am on the "Quiz 1""quiz activity" page logged in as student1
70
63
And I press "Attempt quiz"
71
64
Then I should see "Write a program that prints True if seed parameter provided, then StudentFirst OConnell"
72
65
And I set the field with xpath "//textarea[contains(@name, 'answer')]" to "print('StudentFirst OConnell')"
73
66
And I press "Check"
74
67
Then I should see "Passed all tests"
75
68
76
69
When I log out
77
-
And I am on the "Test quiz""quiz activity" page logged in as teacher1
70
+
And I am on the "Quiz 1""quiz activity" page logged in as teacher1
78
71
And I follow "Attempts: 1"
79
72
And I follow "Review attempt"
80
73
Then I should see "Write a program that prints True if seed parameter provided, then StudentFirst OConnell"
81
74
And I should see "Passed all tests"
82
75
83
-
Scenario: Turn off per-try evaluation. Question should fail when attempted by student.
84
-
When I am on the "Course 1""core_question > course question bank" page
85
-
And I choose "Edit question" action for "Python preprocessor" in the question bank
Scenario: if evaluate per student is unchecked, the teacher's name is displayed not the student's.
77
+
When I am on the "Quiz 1""mod_quiz > Edit" page logged in as "teacher1"
78
+
And I disable UI plugins in the CodeRunner question type
79
+
And I open the "last" add to quiz menu
80
+
And I follow "a new question"
81
+
And I set the field "item_qtype_coderunner" to "1"
82
+
And I press "submitbutton"
83
+
Then I should see "Adding a CodeRunner question"
84
+
85
+
And I set the field "id_coderunnertype" to "python3"
86
+
And I set the field "id_customise" to "1"
87
+
And I set the field "id_name" to "Python preprocessor"
88
+
And I set the field "id_questiontext" to "Write a program that prints True if seed parameter provided, then {{ firstname }} {{ lastname }}"
89
+
And I set the field "id_answerboxlines" to "5"
90
+
And I set the field "id_templateparams" to "import sys, json; keyvalues = {param.split('=')[0]: param.split('=')[1] for param in sys.argv[1:]}; print(json.dumps(keyvalues))"
91
+
And I set the field "id_twigall" to "1"
92
+
And I set the field "id_template" to "print({{seed}} > 0, end=' '); {{STUDENT_ANSWER}}"
93
+
And I set the field "id_templateparamslang" to "python3"
94
+
And I set CodeRunner behat testing flag
88
95
And I set the field "id_templateparamsevalpertry" to "0"
96
+
And I set the field "id_expected_0" to "True {{ firstname }} {{ lastname }}"
97
+
And I set the field "id_uiplugin" to "none"
89
98
And I press "id_submitbutton"
90
-
Then I should see "Created by"
99
+
Then I should see "Python preprocessor Write a program that prints True if seed"
91
100
92
-
When I am on the "Test quiz""quiz activity" page
93
-
AndI press "Preview quiz"
94
-
Then I should see "Variant without per-try evaluation"
101
+
When I am on the "Quiz 1""quiz activity" page logged in as teacher1
102
+
WhenI press "Preview quiz"
103
+
Then I should see "Write a program that prints True if seed parameter provided, then Teacher Last"
95
104
96
105
When I set the field with xpath "//textarea[contains(@name, 'answer')]" to "print('Teacher Last')"
97
106
And I press "Check"
98
107
Then I should see "Passed all tests"
99
108
100
109
When I log out
101
-
And I am on the "Test quiz""quiz activity" page logged in as student1
110
+
And I am on the "Quiz 1""quiz activity" page logged in as student1
102
111
And I press "Attempt quiz"
103
-
Then I should see "Variant without per-try evaluation"
112
+
Then I should see "Write a program that prints True if seed parameter provided, then Teacher Last"
104
113
And I set the field with xpath "//textarea[contains(@name, 'answer')]" to "print('StudentFirst OConnell')"
105
114
And I press "Check"
106
-
Then I should see "True StudentFirst OConnell"
107
-
And I should see "True Teacher Last"
115
+
Then I should not see "Passed all tests"
116
+
117
+
When I log out
118
+
And I am on the "Quiz 1""quiz activity" page logged in as teacher1
119
+
And I follow "Attempts: 1"
120
+
And I follow "Review attempt"
121
+
Then I should not see "Write a program that prints True if seed parameter provided, then StudentFirst OConnell"
0 commit comments