mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
Merge branch 'wip-mdl-46817-m26' of git://github.com/rajeshtaneja/moodle into MOODLE_26_STABLE
This commit is contained in:
commit
0f9d61091b
3 changed files with 168 additions and 10 deletions
|
@ -21,16 +21,27 @@ Feature: We can enter in grades and view reports from the gradebook
|
|||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment name |
|
||||
| Assignment name | Test assignment name 1 |
|
||||
| Description | Submit your online text |
|
||||
| assignsubmission_onlinetext_enabled | 1 |
|
||||
And I add a "Assignment" to section "1" and I fill the form with:
|
||||
| Assignment name | Test assignment name 2 |
|
||||
| Description | Submit your online text |
|
||||
| assignsubmission_onlinetext_enabled | 1 |
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I follow "Test assignment name"
|
||||
And I follow "Test assignment name 1"
|
||||
When I press "Add submission"
|
||||
And I fill the moodle form with:
|
||||
| Online text | This is a submission |
|
||||
| Online text | This is a submission for assignment 1 |
|
||||
And I press "Save changes"
|
||||
Then I should see "Submitted for grading"
|
||||
And I follow "Course 1"
|
||||
And I follow "Test assignment name 2"
|
||||
When I press "Add submission"
|
||||
And I fill the moodle form with:
|
||||
| Online text | This is a submission for assignment 2 |
|
||||
And I press "Save changes"
|
||||
Then I should see "Submitted for grading"
|
||||
And I log out
|
||||
|
@ -38,7 +49,8 @@ Feature: We can enter in grades and view reports from the gradebook
|
|||
And I follow "Course 1"
|
||||
And I follow "Grades"
|
||||
And I turn editing mode on
|
||||
And I give the grade "80.00" to the user "Student 1" for the grade item "Test assignment name"
|
||||
And I give the grade "80.00" to the user "Student 1" for the grade item "Test assignment name 1"
|
||||
And I give the grade "90.00" to the user "Student 1" for the grade item "Test assignment name 2"
|
||||
And I press "Update"
|
||||
|
||||
@javascript
|
||||
|
@ -52,9 +64,17 @@ Feature: We can enter in grades and view reports from the gradebook
|
|||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I follow "Grades"
|
||||
And I should see "80.00" in the "Test assignment name" "table_row"
|
||||
And I select "Overview report" from "Grade report"
|
||||
And I should see "80.00" in the "overview-grade" "table"
|
||||
Then the following should exist in the "user-grade" table:
|
||||
| Grade item | Grade | Range | Percentage |
|
||||
| Test assignment name 1 | 80.00 | 0–100 | 80.00 % |
|
||||
| Test assignment name 2 | 90.00 | 0–100 | 90.00 % |
|
||||
| Course total | 85.00 | 0–100 | 85.00 % |
|
||||
And the following should not exist in the "user-grade" table:
|
||||
| Grade item | Grade | Range | Percentage |
|
||||
| Course total | 90.00 | 0–110 | 90.00 % |
|
||||
And I set the field "Grade report" to "Overview report"
|
||||
And "C1" row "Grade" column of "overview-grade" table should contain "85.00"
|
||||
And "C1" row "Grade" column of "overview-grade" table should not contain "90.00"
|
||||
|
||||
@javascript
|
||||
Scenario: We can add a weighting to a grade item and it is displayed properly in the user report
|
||||
|
@ -72,5 +92,13 @@ Feature: We can enter in grades and view reports from the gradebook
|
|||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I follow "Grades"
|
||||
Then I should see "0.72" in the "Test assignment name" "table_row"
|
||||
And I should not see "0.72%" in the "Test assignment name" "table_row"
|
||||
Then the following should exist in the "user-grade" table:
|
||||
| Grade item | Weight | Grade | Range | Percentage |
|
||||
| Test assignment name 1 | 0.72 | 80.00 | 0–100 | 80.00 % |
|
||||
| Test assignment name 2 | 1.00 | 90.00 | 0–100 | 90.00 % |
|
||||
| Course total | - | 85.81 | 0–100 | 85.81 % |
|
||||
And the following should not exist in the "user-grade" table:
|
||||
| Grade item | Weight | Percentage |
|
||||
| Test assignment name 1 | 0.72% | 0.72% |
|
||||
| Test assignment name 2 | 1.00% | 1.00% |
|
||||
| Course total | 1.00% | 1.00% |
|
||||
|
|
|
@ -110,6 +110,9 @@ XPATH
|
|||
, 'filemanager' => <<<XPATH
|
||||
//div[contains(concat(' ', normalize-space(@class), ' '), ' ffilemanager ')]
|
||||
/descendant::input[@id = //label[contains(normalize-space(string(.)), %locator%)]/@for]
|
||||
XPATH
|
||||
, 'table' => <<<XPATH
|
||||
.//table[(./@id = %locator% or contains(.//caption, %locator%) or contains(concat(' ', normalize-space(@class), ' '), %locator% ))]
|
||||
XPATH
|
||||
);
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@ use Behat\Mink\Exception\ExpectationException as ExpectationException,
|
|||
Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException,
|
||||
Behat\Mink\Exception\DriverException as DriverException,
|
||||
WebDriver\Exception\NoSuchElement as NoSuchElement,
|
||||
WebDriver\Exception\StaleElementReference as StaleElementReference;
|
||||
WebDriver\Exception\StaleElementReference as StaleElementReference,
|
||||
Behat\Gherkin\Node\TableNode as TableNode;
|
||||
|
||||
/**
|
||||
* Cross component steps definitions.
|
||||
|
@ -1011,4 +1012,130 @@ class behat_general extends behat_base {
|
|||
$this->getSession());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the provided value exists in specific row/column of table.
|
||||
*
|
||||
* @Then /^"(?P<row_string>[^"]*)" row "(?P<column_string>[^"]*)" column of "(?P<table_string>[^"]*)" table should contain "(?P<value_string>[^"]*)"$/
|
||||
* @throws ElementNotFoundException
|
||||
* @param string $row row text which will be looked in.
|
||||
* @param string $column column text to search
|
||||
* @param string $table table id/class/caption
|
||||
* @param string $value text to check.
|
||||
*/
|
||||
public function row_column_of_table_should_contain($row, $column, $table, $value) {
|
||||
$tablenode = $this->get_selected_node('table', $table);
|
||||
$tablexpath = $tablenode->getXpath();
|
||||
|
||||
// Check if column exists, it can be in thead or tbody first row.
|
||||
$columnheaderxpath = $tablexpath . "[thead/tr/th[normalize-space(.)='$column'] | "
|
||||
. "tbody/tr[1]/th[normalize-space(.)='" . $column . "']]";
|
||||
$columnheader = $this->getSession()->getDriver()->find($columnheaderxpath);
|
||||
if (empty($columnheader)) {
|
||||
$columnexceptionmsg = $column . '" in table "' . $table . '"';
|
||||
throw new ElementNotFoundException($this->getSession(), 'Column', null, $columnexceptionmsg);
|
||||
}
|
||||
|
||||
// Check if value exists in specific row/column.
|
||||
// Get row xpath.
|
||||
$rowxpath = $tablexpath."/tbody/tr[th[normalize-space(.)='" . $row . "'] | td[normalize-space(.)='" . $row . "']]";
|
||||
|
||||
// Following conditions were considered before finding column count.
|
||||
// 1. Table header can be in thead/tr/th or tbody/tr/td[1].
|
||||
// 2. First column can have th (Gradebook -> user report), so having lenient sibling check.
|
||||
$columnpositionxpath = "/child::*[position() = count(" . $tablexpath . "/thead/tr[1]/th[normalize-space(.)='" .
|
||||
$column . "']/preceding-sibling::*) + 1]";
|
||||
$columnvaluexpath = $rowxpath . $columnpositionxpath . "[text()[contains(normalize-space(.),'" . $value . "')]]";
|
||||
|
||||
// Looks for the requested node inside the container node.
|
||||
$coumnnode = $this->getSession()->getDriver()->find($columnvaluexpath);
|
||||
if (empty($coumnnode)) {
|
||||
// Check if tbody/tr[1] contains header selector.
|
||||
$columnpositionxpath = "/child::*[position() = count(" . $tablexpath . "/tbody/tr[1]/td[normalize-space(.)='" .
|
||||
$column . "']/preceding-sibling::*) + 1]";
|
||||
$columnvaluexpath = $rowxpath . $columnpositionxpath . "[text()[contains(normalize-space(.),'" . $value . "')]]";
|
||||
$coumnnode = $this->getSession()->getDriver()->find($columnvaluexpath);
|
||||
if (empty($coumnnode)) {
|
||||
$locatorexceptionmsg = $value . '" in "' . $row . '" row with column "' . $column;
|
||||
throw new ElementNotFoundException($this->getSession(), 'Column value', null, $locatorexceptionmsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the provided value should not exist in specific row/column of table.
|
||||
*
|
||||
* @Then /^"(?P<row_string>[^"]*)" row "(?P<column_string>[^"]*)" column of "(?P<table_string>[^"]*)" table should not contain "(?P<value_string>[^"]*)"$/
|
||||
* @throws ElementNotFoundException
|
||||
* @param string $row row text which will be looked in.
|
||||
* @param string $column column text to search
|
||||
* @param string $table table id/class/caption
|
||||
* @param string $value text to check.
|
||||
*/
|
||||
public function row_column_of_table_should_not_contain($row, $column, $table, $value) {
|
||||
try {
|
||||
$this->row_column_of_table_should_contain($row, $column, $table, $value);
|
||||
// Throw exception if found.
|
||||
throw new ExpectationException(
|
||||
'"' . $column . '" with value "' . $value . '" is present in "' . $row . '" row for table "' . $table . '"',
|
||||
$this->getSession()
|
||||
);
|
||||
} catch (ElementNotFoundException $e) {
|
||||
// Table row/column doesn't contain this value. Nothing to do.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the provided value exist in table.
|
||||
* More info in http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps.
|
||||
*
|
||||
* @Then /^the following should exist in the "(?P<table_string>[^"]*)" table:$/
|
||||
* @throws ExpectationException
|
||||
* @param string $table name of table
|
||||
* @param TableNode $data table with first row as header and following values
|
||||
* | Header 1 | Header 2 | Header 3 |
|
||||
* | Value 1 | Value 2 | Value 3|
|
||||
*/
|
||||
public function following_should_exit_in_the_table($table, TableNode $data) {
|
||||
$datahash = $data->getHash();
|
||||
|
||||
foreach ($datahash as $value) {
|
||||
$row = array_shift($value);
|
||||
foreach ($value as $column => $value) {
|
||||
$this->row_column_of_table_should_contain($row, $column, $table, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the provided value exist in table.
|
||||
* More info in http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps.
|
||||
*
|
||||
* @Then /^the following should not exist in the "(?P<table_string>[^"]*)" table:$/
|
||||
* @throws ExpectationException
|
||||
* @param string $table name of table
|
||||
* @param TableNode $data table with first row as header and following values
|
||||
* | Header 1 | Header 2 | Header 3 |
|
||||
* | Value 1 | Value 2 | Value 3|
|
||||
*/
|
||||
public function following_should_not_exit_in_the_table($table, TableNode $data) {
|
||||
$datahash = $data->getHash();
|
||||
|
||||
foreach ($datahash as $value) {
|
||||
$row = array_shift($value);
|
||||
foreach ($value as $column => $value) {
|
||||
try {
|
||||
$this->row_column_of_table_should_contain($row, $column, $table, $value);
|
||||
// Throw exception if found.
|
||||
throw new ExpectationException('"' . $column . '" with value "' . $value . '" is present in "' .
|
||||
$row . '" row for table "' . $table . '"', $this->getSession()
|
||||
);
|
||||
} catch (ElementNotFoundException $e) {
|
||||
// Table row/column doesn't contain this value. Nothing to do.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue