forked from trampgeek/moodle-qtype_coderunner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgapfiller_ui.feature
123 lines (107 loc) · 4.59 KB
/
gapfiller_ui.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
@qtype @qtype_coderunner @javascript @gapfiller
Feature: Test the GapFiller_UI
In order to use the GapFiller UI
As a teacher
I should be able specify the required gaps in the global extra or test0 fields
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@asd.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | coderunner | Print answer | printans |
Scenario: Edit a CodeRunner printans question into a gap-filler question
When I am on the "Print answer" "core_question > edit" page logged in as teacher1
And I set the following fields to these values:
| customise | 1 |
| id_template | print('{{ STUDENT_ANSWER }}') |
| uiplugin | Gapfiller |
| id_expected_0 | ["bubble"] |
And I set the field "id_globalextra" to:
"""
I'm a line of text
Field: {[10]} rest of line
"""
And I press "id_updatebutton"
Then "[name='cr_gapfiller_field']" "css_element" should exist
And I set the field "cr_gapfiller_field" to "bubble"
And I set the field "Validate on save" to "1"
And I press "id_submitbutton"
Then I should not see "Failed 1 test(s)"
And I should see "Created by"
When I choose "Edit question" action for "Print answer" in the question bank
And I set the field "id_globalextra" to:
"""
I'm a line of text
Textarea: {[2, 20]} rest of line
"""
And I set the field "Validate on save" to "0"
And I press "id_updatebutton"
Then "[name='cr_gapfiller_field']" "css_element" should exist
When I set the field "cr_gapfiller_field" to:
"""
Line 1
Line 2
"""
And I set the field "id_expected_0" to:
"""
Line 1
Line 2
"""
And I set the field "id_template" to:
"""
answer = eval('''{{ STUDENT_ANSWER | e('py')}}''')
assert isinstance(answer, list)
for element in answer: print(element)
"""
And I set the field "Validate on save" to "1"
And I press "id_submitbutton"
Then I should not see "Failed 1 test(s)"
And I should see "Created by"
When I choose "Preview" action for "Print answer" in the question bank
And I set the field "cr_gapfiller_field" to:
"""
Line 1
Line 2
"""
And I press "Check"
Then I should see "Passed all tests!"
Scenario: Edit and run a gap-filler question using test0 as a source.
When I am on the "Print answer" "core_question > edit" page logged in as teacher1
And I set the following fields to these values:
| customise | 1 |
| id_template | print({{ STUDENT_ANSWER }}[0])|
| id_iscombinatortemplate | 0 |
| uiplugin | Gapfiller |
| id_expected_0 | bubble |
| id_templateparams | {"gapfiller_ui_source": "test0"} |
| id_validateonsave | 0 |
| id_twigall | 1 |
| id_testcode_0 | print("{[10]}") |
And I press "id_updatebutton"
Then I should see "UI parameters can no longer be defined within the template parameters field"
When I set the field "id_templateparams" to ""
And I set the field "id_uiparameters" to "{\"ui_source\": \"test0\"}"
And I press "id_updatebutton"
Then "[name='cr_gapfiller_field']" "css_element" should exist
And I set the field "cr_gapfiller_field" to "bubble"
And I set the field "Validate on save" to "1"
And I press "id_submitbutton"
Then I should not see "Failed 1 test(s)"
And I should see "Created by"
When I choose "Preview" action for "Print answer" in the question bank
And I set the field "cr_gapfiller_field" to "not a bubble"
And I press "Check"
Then I should not see "Passed all tests!"
And I set the field "cr_gapfiller_field" to "bubble"
And I press "Check"
Then I should see "Passed all tests!"