Merge branch 'MDL-79246-402' of https://github.com/andrewnicols/moodle into MOODLE_402_STABLE
This commit is contained in:
@@ -27,9 +27,9 @@
|
||||
|
||||
require_once(__DIR__ . '/../../../../../../lib/behat/behat_base.php');
|
||||
|
||||
use Behat\Gherkin\Node\TableNode as TableNode,
|
||||
Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException,
|
||||
Behat\Mink\Exception\ExpectationException as ExpectationException;
|
||||
use Behat\Gherkin\Node\TableNode;
|
||||
use Behat\Mink\Exception\ElementNotFoundException;
|
||||
use Behat\Mink\Exception\ExpectationException;
|
||||
|
||||
/**
|
||||
* Steps definitions to help with rubrics.
|
||||
@@ -66,7 +66,6 @@ class behat_gradingform_rubric extends behat_base {
|
||||
* @param TableNode $rubric
|
||||
*/
|
||||
public function i_define_the_following_rubric(TableNode $rubric) {
|
||||
|
||||
// Being a smart method is nothing good when we talk about step definitions, in
|
||||
// this case we didn't have any other options as there are no labels no elements
|
||||
// id we can point to without having to "calculate" them.
|
||||
@@ -80,7 +79,6 @@ class behat_gradingform_rubric extends behat_base {
|
||||
// Cleaning the current ones.
|
||||
$deletebuttons = $this->find_all('css', "input[value='" . get_string('criteriondelete', 'gradingform_rubric') . "']");
|
||||
if ($deletebuttons) {
|
||||
|
||||
// We should reverse the deletebuttons because otherwise once we delete
|
||||
// the first one the DOM will change and the [X] one will not exist anymore.
|
||||
$deletebuttons = array_reverse($deletebuttons, true);
|
||||
@@ -132,7 +130,10 @@ class behat_gradingform_rubric extends behat_base {
|
||||
}
|
||||
|
||||
// Add new criterion.
|
||||
$addcriterionbutton->click();
|
||||
$this->execute('behat_general::i_click_on', [
|
||||
$addcriterionbutton,
|
||||
'NodeElement',
|
||||
]);
|
||||
|
||||
$criterionroot = 'rubric[criteria][NEWID' . ($criterionit + 1) . ']';
|
||||
|
||||
@@ -158,12 +159,14 @@ class behat_gradingform_rubric extends behat_base {
|
||||
if ($this->running_javascript()) {
|
||||
$deletelevel = $this->find_button($criterionroot . '[levels][NEWID' . $i . '][delete]');
|
||||
$this->click_and_confirm($deletelevel);
|
||||
|
||||
} else {
|
||||
// Only if the level exists.
|
||||
$buttonname = $criterionroot . '[levels][NEWID' . $i . '][delete]';
|
||||
if ($deletelevel = $this->getSession()->getPage()->findButton($buttonname)) {
|
||||
$deletelevel->click();
|
||||
$this->execute('behat_general::i_click_on', [
|
||||
$deletelevel,
|
||||
'NodeElement',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,7 +174,10 @@ class behat_gradingform_rubric extends behat_base {
|
||||
// Adding levels if we don't have enough.
|
||||
$addlevel = $this->find_button($criterionroot . '[levels][addlevel]');
|
||||
for ($i = ($defaultnumberoflevels + 1); $i <= $nlevels; $i++) {
|
||||
$addlevel->click();
|
||||
$this->execute('behat_general::i_click_on', [
|
||||
$addlevel,
|
||||
'NodeElement',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +232,6 @@ class behat_gradingform_rubric extends behat_base {
|
||||
* @param string $criterionname
|
||||
*/
|
||||
public function i_replace_rubric_level_with($currentvalue, $value, $criterionname) {
|
||||
|
||||
$currentvalueliteral = behat_context_helper::escape($currentvalue);
|
||||
$criterionliteral = behat_context_helper::escape($criterionname);
|
||||
|
||||
@@ -247,14 +252,15 @@ class behat_gradingform_rubric extends behat_base {
|
||||
"/descendant::textarea[text()=$currentvalueliteral]";
|
||||
|
||||
if ($this->running_javascript()) {
|
||||
|
||||
$spansufix = "/ancestor::div[@class='level-wrapper']" .
|
||||
"/descendant::div[@class='definition']" .
|
||||
"/descendant::span[@class='textvalue']";
|
||||
|
||||
// Expanding the level input boxes.
|
||||
$spannode = $this->find('xpath', $inputxpath . $spansufix . '|' . $textareaxpath . $spansufix);
|
||||
$spannode->click();
|
||||
$this->execute('behat_general::i_click_on', [
|
||||
$inputxpath . $spansufix . '|' . $textareaxpath . $spansufix,
|
||||
'xpath',
|
||||
]);
|
||||
|
||||
$inputfield = $this->find('xpath', $inputxpath . '|' . $textareaxpath);
|
||||
$inputfield->setValue($value);
|
||||
@@ -263,7 +269,6 @@ class behat_gradingform_rubric extends behat_base {
|
||||
$fieldnode = $this->find('xpath', $inputxpath . '|' . $textareaxpath);
|
||||
$this->set_rubric_field_value($fieldnode->getAttribute('name'), $value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -275,7 +280,6 @@ class behat_gradingform_rubric extends behat_base {
|
||||
* @param TableNode $rubric
|
||||
*/
|
||||
public function i_grade_by_filling_the_rubric_with(TableNode $rubric) {
|
||||
|
||||
$criteria = $rubric->getRowsHash();
|
||||
|
||||
$stepusage = '"I grade by filling the rubric with:" step needs you to provide a table where each row is a criterion' .
|
||||
@@ -288,7 +292,6 @@ class behat_gradingform_rubric extends behat_base {
|
||||
|
||||
// First element -> name, second -> points, third -> Remark.
|
||||
foreach ($criteria as $name => $criterion) {
|
||||
|
||||
// We only expect the points and the remark, as the criterion name is $name.
|
||||
if (count($criterion) !== 2) {
|
||||
throw new ExpectationException($stepusage, $this->getSession());
|
||||
@@ -349,7 +352,6 @@ class behat_gradingform_rubric extends behat_base {
|
||||
* @return void
|
||||
*/
|
||||
public function the_level_with_points_was_previously_selected_for_the_rubric_criterion($points, $criterionname) {
|
||||
|
||||
$levelxpath = $this->get_criterion_xpath($criterionname) .
|
||||
$this->get_level_xpath($points) .
|
||||
"[contains(concat(' ', normalize-space(@class), ' '), ' currentchecked ')]";
|
||||
@@ -378,7 +380,6 @@ class behat_gradingform_rubric extends behat_base {
|
||||
* @return void
|
||||
*/
|
||||
public function the_level_with_points_is_selected_for_the_rubric_criterion($points, $criterionname) {
|
||||
|
||||
$levelxpath = $this->get_criterion_xpath($criterionname) .
|
||||
$this->get_level_xpath($points);
|
||||
|
||||
@@ -409,7 +410,6 @@ class behat_gradingform_rubric extends behat_base {
|
||||
* @return void
|
||||
*/
|
||||
public function the_level_with_points_is_not_selected_for_the_rubric_criterion($points, $criterionname) {
|
||||
|
||||
$levelxpath = $this->get_criterion_xpath($criterionname) .
|
||||
$this->get_level_xpath($points);
|
||||
|
||||
@@ -437,12 +437,13 @@ class behat_gradingform_rubric extends behat_base {
|
||||
* @return void
|
||||
*/
|
||||
protected function set_rubric_field_value($name, $value, $visible = false) {
|
||||
|
||||
// Fields are hidden by default.
|
||||
if ($this->running_javascript() == true && $visible === false) {
|
||||
$xpath = "//*[@name='$name']/following-sibling::*[contains(concat(' ', normalize-space(@class), ' '), ' plainvalue ')]";
|
||||
$textnode = $this->find('xpath', $xpath);
|
||||
$textnode->click();
|
||||
$this->execute('behat_general::i_click_on', [
|
||||
$xpath,
|
||||
'xpath',
|
||||
]);
|
||||
}
|
||||
|
||||
// Set the value now.
|
||||
@@ -457,19 +458,20 @@ class behat_gradingform_rubric extends behat_base {
|
||||
* @return void
|
||||
*/
|
||||
protected function click_and_confirm($node) {
|
||||
|
||||
// Clicks to perform the action.
|
||||
$node->click();
|
||||
$this->execute('behat_general::i_click_on', [
|
||||
$node,
|
||||
'NodeElement',
|
||||
]);
|
||||
|
||||
// Confirms the delete.
|
||||
if ($this->running_javascript()) {
|
||||
$confirmbutton = $this->get_node_in_container(
|
||||
'button',
|
||||
$this->execute('behat_general::i_click_on_in_the', [
|
||||
get_string('yes'),
|
||||
'button',
|
||||
get_string('confirmation', 'admin'),
|
||||
'dialogue',
|
||||
get_string('confirmation', 'admin')
|
||||
);
|
||||
$confirmbutton->click();
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user