MDL-47494 gapselect: Fix qtype gapselect Behat tests. #33559
This commit is contained in:
@@ -53,10 +53,9 @@ Feature: Test all the basic functionality of this question type
|
||||
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 set space "1" to "cat" in the select missing words question
|
||||
And I set space "2" to "sat" in the select missing words question
|
||||
And I set space "3" to "mat" in the select missing words question
|
||||
And I press "Check"
|
||||
Then I should see "Your answer is correct"
|
||||
And I should see "The cat sat on the mat"
|
||||
@@ -64,22 +63,21 @@ Feature: Test all the basic functionality of this question type
|
||||
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 set space "1" to "cat" in the select missing words question
|
||||
And I set space "2" to "sat" in the select missing words question
|
||||
And I set space "3" to "dog" in the select missing words question
|
||||
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 set space "3" to "table" in the select missing words question
|
||||
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 set space "3" to "mat" in the select missing words question
|
||||
And I press "Check"
|
||||
Then I should see "Your answer is correct"
|
||||
And I should see "The cat sat on the mat"
|
||||
@@ -93,10 +91,9 @@ Feature: Test all the basic functionality of this question type
|
||||
# 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 set space "1" to "cat" in the select missing words question
|
||||
And I set space "2" to "sat" in the select missing words question
|
||||
And I set space "3" to "mat" in the select missing words question
|
||||
And I press "Check"
|
||||
Then I should see "Your answer is correct"
|
||||
And I should see "The cat sat on the mat"
|
||||
@@ -104,10 +101,9 @@ Feature: Test all the basic functionality of this question type
|
||||
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 set space "1" to "dog" in the select missing words question
|
||||
And I set space "2" to "sat" in the select missing words question
|
||||
And I set space "3" to "cat" in the select missing words question
|
||||
And I press "Check"
|
||||
Then I should see "Your answer is partially correct"
|
||||
And I should see "You have correctly selected 1."
|
||||
@@ -116,10 +112,9 @@ Feature: Test all the basic functionality of this question type
|
||||
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 set space "1" to "mat" in the select missing words question
|
||||
And I set space "2" to "cat" in the select missing words question
|
||||
And I set space "3" to "sat" in the select missing words question
|
||||
And I press "Check"
|
||||
Then I should see "Your answer is incorrect"
|
||||
And I should see "The cat sat on the mat"
|
||||
@@ -154,4 +149,3 @@ Feature: Test all the basic functionality of this question type
|
||||
| Question name | Edited question name |
|
||||
And I press "id_submitbutton"
|
||||
Then I should see "Edited question name"
|
||||
And I wait "10" seconds
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
// This file is part of Stack - http://stack.bham.ac.uk/
|
||||
//
|
||||
// Stack is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Stack is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Stack. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Behat steps definitions for the select missing words question type.
|
||||
*
|
||||
* @package qtype_gapselect
|
||||
* @category test
|
||||
* @copyright 2015 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
|
||||
|
||||
require_once(__DIR__ . '/../../../../../lib/behat/behat_base.php');
|
||||
|
||||
/**
|
||||
* Steps definitions related with for the select missing words question type.
|
||||
*
|
||||
* @copyright 2015 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class behat_qtype_gapselect extends behat_base {
|
||||
|
||||
/**
|
||||
* Get the xpath for a given missing word.
|
||||
* @param string $spacenumber the number of select menu.
|
||||
* @return string the xpath expression.
|
||||
*/
|
||||
protected function space_xpath($spacenumber) {
|
||||
$class = 'place' . $spacenumber;
|
||||
return "//select[contains(@class, ' $class')]";
|
||||
}
|
||||
|
||||
/**
|
||||
* Drag the drag item with the given text to the given space.
|
||||
*
|
||||
* @param int $spacenumber the number of the gap to drop into.
|
||||
* @param string $value the text of the response to select.
|
||||
*
|
||||
* @Given /^I set space "(?P<space_number>\d+)" to "(?P<value>[^"]*)" in the select missing words question$/
|
||||
*/
|
||||
public function i_set_space_to_in_the_select_missing_words_question($spacenumber, $value) {
|
||||
$formscontext = behat_context_helper::get('behat_forms');
|
||||
$formscontext->i_set_the_field_with_xpath_to($this->space_xpath($spacenumber), $value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user