Skip to content

Commit 22ba2ab

Browse files
Add validation: Sandbox lang cannot be empty when creating a prototype (#195)
1 parent 1b024b0 commit 22ba2ab

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

edit_coderunner_form.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,11 @@ public function validation($data, $files) {
904904
$errors = array_merge($errors, $testcaseerrors);
905905
}
906906

907+
if ($data['prototypetype'] == 2 && empty($data['language'])) {
908+
// Language cannot be empty when it is a prototype template.
909+
$errors['languages'] = get_string('emptysandboxlanguage', 'qtype_coderunner');
910+
}
911+
907912
if ($data['iscombinatortemplate'] && empty($data['testsplitterre'])) {
908913
$errors['templatecontrols'] = get_string('bad_empty_splitter', 'qtype_coderunner');
909914
}

lang/en/qtype_coderunner.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
$string['editingcoderunner'] = 'Editing a CodeRunner Question';
147147
$string['empty_new_prototype_name'] = 'New question type name cannot be empty';
148148
$string['emptypenaltyregime'] = 'Penalty regime must be defined (since version 3.1)';
149+
$string['emptysandboxlanguage'] = 'Sandbox language cannot be empty when creating a prototype.';
149150
$string['enable'] = 'Enable';
150151
$string['enablecombinator'] = 'Enable combinator';
151152
$string['enable_diff_check'] = 'Enable \'Show differences\' button';

tests/behat/make_prototype.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,13 @@ Feature: make_prototype
7777
And I set the field "prototypetype" to "No"
7878
And I set the field "id_coderunnertype" to "python3" and dismiss the alert
7979
Then I should not see "This is a prototype; cannot change question type"
80+
81+
Scenario: As a teacher, when I try to create the prototype with empty Sandbox language I should see the validation error
82+
Given I am on the "PROTOTYPE_test_prototype" "core_question > edit" page logged in as teacher1
83+
And I click on "a[aria-controls='id_advancedcustomisationheadercontainer']" "css_element"
84+
When I set the field "language" to ""
85+
And I press "id_submitbutton"
86+
Then I should see "Sandbox language cannot be empty when creating a prototype."
87+
And I set the field "language" to "python3"
88+
And I press "id_submitbutton"
89+
And I should see "Question bank"

0 commit comments

Comments
 (0)