diff --git a/question/type/gapselect/tests/behat/basic_test.feature b/question/type/gapselect/tests/behat/basic_test.feature new file mode 100644 index 00000000000..890cb60025d --- /dev/null +++ b/question/type/gapselect/tests/behat/basic_test.feature @@ -0,0 +1,157 @@ +@ou @ou_vle @qtype @qtype_gapselect +Feature: Test all the basic functionality of this question type + In order to evaluate students responses, As a teacher I need to + create and preview gapselect (Select missing words) questions. + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | T1 | Teacher1 | teacher1@moodle.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 | + + @javascript + Scenario: Create, edit then preview a gapselect question. + Given I log in as "teacher1" + And I follow "Course 1" + And I navigate to "Question bank" node in "Course administration" + + # Create a new question. + And I add a "Select missing words" question filling the form with: + | Question name | Select missing words 001 | + | Question text | The [[1]] [[2]] on the [[3]]. | + | General feedback | The cat sat on the mat. | + | id_choices_0_answer | cat | + | id_choices_1_answer | sat | + | id_choices_2_answer | mat | + | id_choices_3_answer | dog | + | id_choices_4_answer | table | + | Hint 1 | First hint | + | Hint 2 | Second hint | + Then I should see "Select missing words 001" + + # Preview it. + When I click on "Preview" "link" in the "Select missing words 001" "table_row" + And I switch to "questionpreview" window + + # Gaps (drop-down menus) do not have labels. ids and names are generated + # dynamically and therefore not reliable, i.e. this is an accessibility bug + # which need to be fixed at some stage. Meanwhile, I use the ids and increment + # them as appropriate (e.g.: q3_1_p1 become q4_1_p1, etc.). + + # Set display and behaviour options + And I set the following fields to these values: + | How questions behave | Interactive with multiple tries | + | Marked out of | 3 | + | Marks | Show mark and max | + | Specific feedback | Shown | + | Right answer | Shown | + And I press "Start again with these options" + + # Answer question correctly + And I set the following fields to these values: + | q3_1_p1 | cat | + | q3_1_p2 | sat | + | q3_1_p3 | mat | + And I press "Check" + Then I should see "Your answer is correct" + And I should see "The cat sat on the mat" + And I should see "The correct answer is: The [cat] [sat] on the [mat]." + And I press "Start again" + + # Answer question partially correct twice and then correct + And I set the following fields to these values: + | q4_1_p1 | cat | + | q4_1_p2 | sat | + | q4_1_p3 | dog | + And I press "Check" + Then I should see "Your answer is partially correct" + And I should see "First hint" + + When I press "Try again" + And I set the field "q4_1_p3" to "table" + And I press "Check" + Then I should see "Your answer is partially correct" + And I should see "Second hint" + + When I press "Try again" + And I set the field "q4_1_p3" to "mat" + And I press "Check" + Then I should see "Your answer is correct" + And I should see "The cat sat on the mat" + And I should see "The correct answer is: The [cat] [sat] on the [mat]." + + # Set behaviour options + And I set the following fields to these values: + | behaviour | immediatefeedback | + And I press "Start again with these options" + + # Answer question correctly + When I press "Check" + Then I should see "Please put an answer in each box." + And I set the following fields to these values: + | q5_1_p1 | cat | + | q5_1_p2 | sat | + | q5_1_p3 | mat | + And I press "Check" + Then I should see "Your answer is correct" + And I should see "The cat sat on the mat" + And I should see "The correct answer is: The [cat] [sat] on the [mat]." + And I press "Start again" + + # Answer question partially correct + And I set the following fields to these values: + | q6_1_p1 | dog | + | q6_1_p2 | sat | + | q6_1_p3 | cat | + And I press "Check" + Then I should see "Your answer is partially correct" + And I should see "You have correctly selected 1." + And I should see "The cat sat on the mat" + And I should see "The correct answer is: The [cat] [sat] on the [mat]." + And I press "Start again" + + # Answer question incorrectly + And I set the following fields to these values: + | q7_1_p1 | mat | + | q7_1_p2 | cat | + | q7_1_p3 | sat | + And I press "Check" + Then I should see "Your answer is incorrect" + And I should see "The cat sat on the mat" + And I should see "The correct answer is: The [cat] [sat] on the [mat]." + And I switch to the main window + + # Backup the course and restore it. + When I log out + And I log in as "admin" + When I backup "Course 1" course using this options: + | Confirmation | Filename | test_backup.mbz | + When I restore "test_backup.mbz" backup into a new course using this options: + | Schema | Course name | Course 2 | + Then I should see "Course 2" + When I navigate to "Question bank" node in "Course administration" + Then I should see "Select missing words 001" + + # Edit the copy and verify the form field contents. + When I click on "Edit" "link" in the "Select missing words 001" "table_row" + Then the following fields match these values: + | Question name | Select missing words 001 | + | Question text | The [[1]] [[2]] on the [[3]]. | + | General feedback | The cat sat on the mat. | + | id_choices_0_answer | cat | + | id_choices_1_answer | sat | + | id_choices_2_answer | mat | + | id_choices_3_answer | dog | + | id_choices_4_answer | table | + | Hint 1 | First hint | + | Hint 2 | Second hint | + And I set the following fields to these values: + | Question name | Edited question name | + And I press "id_submitbutton" + Then I should see "Edited question name" + And I wait "10" seconds diff --git a/question/type/gapselect/tests/behat/import_test.feature b/question/type/gapselect/tests/behat/import_test.feature new file mode 100644 index 00000000000..836ced77ecb --- /dev/null +++ b/question/type/gapselect/tests/behat/import_test.feature @@ -0,0 +1,30 @@ +@ou @ou_vle @qtype @qtype_gapselect +Feature: Test all the basic functionality of this question type + As a manager/teacher i should be able to import questions from other courses to this course + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | manager1 | M1 | Manager1 | manager11@moodle.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 | + | manager1 | C1 | manager | + And I log in as "teacher1" + And I follow "Course 1" + + @javascript + Scenario: import a variable numeric sets question. + # Import sample file. + When I navigate to "Import" node in "Course administration > Question bank" + And I set the field "id_format_xml" to "1" + And I upload "question/type/gapselect/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager + And I press "id_submitbutton" + Then I should see "Parsing questions from import file." + And I should see "Importing 1 questions from file" + And I should see "1. The [[1]] [[2]] on the [[3]]." + And I press "Continue" + And I should see "Imported Select missing words 001" diff --git a/question/type/gapselect/tests/fixtures/testquestion.moodle.xml b/question/type/gapselect/tests/fixtures/testquestion.moodle.xml new file mode 100644 index 00000000000..e6f75fc60d3 --- /dev/null +++ b/question/type/gapselect/tests/fixtures/testquestion.moodle.xml @@ -0,0 +1,64 @@ + + + + + + $course$/Default for C1 + + + + + + + + Imported Select missing words 001 + + + The [[1]] [[2]] on the [[3]]. + + + The cat sat on the mat. + + 1.0000000 + 0.3333333 + 0 + 0 + + Your answer is correct. + + + Your answer is partially correct. + + + Your answer is incorrect. + + + + cat + 1 + + + sat + 1 + + + mat + 1 + + + dog + 1 + + + table + 1 + + + First hint + + + Second hint + + + + \ No newline at end of file