diff --git a/grade/grading/form/guide/tests/behat/assign_marking_guide.feature b/grade/grading/form/guide/tests/behat/assign_marking_guide.feature index e90e9770e57..3e5ad73b704 100644 --- a/grade/grading/form/guide/tests/behat/assign_marking_guide.feature +++ b/grade/grading/form/guide/tests/behat/assign_marking_guide.feature @@ -21,8 +21,6 @@ Feature: Display marking guide information to students | assign | C1 | Assign 1 | guide | And I am on the "Course 1" course page logged in as teacher1 And I go to "Assign 1" advanced grading definition page - # Set default grading definition and marking guide. - # By default marking guide definition and marks per criterion are enabled. And I set the following fields to these values: | Name | Assign 1 marking guide | | Description | Marking guide description | @@ -32,65 +30,43 @@ Feature: Display marking guide information to students | Grade Criteria 2 | Grade 2 description for students | Grade 2 description for markers | 30 | And I press "Save marking guide and make it ready" - - Scenario Outline: Confirm marking guide information display before student is graded - When I am on the "Assign 1" "assign activity" page logged in as student1 - # Verify that criteria 1 and 2 name and description are displayed when student is logged in before being graded. - Then I should see "Grade Criteria " in the "#guide-criteria .criterion. .criterionshortname" "css_element" - And I should see "Grade description for students" in the "#guide-criteria .criterion. .criteriondescription" "css_element" - - Examples: - |criteriacheck | criteriaclass | - | 1 | first | - | 2 | last | - - Scenario Outline: Confirm that marking guide information is not displayed after student is graded - # Update the existing marking guide to ensure that marks per criterion is displayed. - Given I click on "Edit the current form definition" "link" - And I set the field "Show marks per criterion to students" to "0" - And I press "Save" - And I am on the "Assign 1" "assign activity" page - And I go to "Student 1" "Assign 1" activity advanced grading page - And I grade by filling the marking guide with: - | Grade Criteria 1 | 50 | Excellent work! | - | Grade Criteria 2 | 20 | Try harder | - And I press "Save changes" - When I am on the "Assign 1" "assign activity" page logged in as student1 - # Confirm the marking guide information display after student is graded when marking per criterion display is disabled. - # Confirm that overall grade is displayed. - Then I should see "70.00 / 100.00" in the ".feedback .feedbacktable .generaltable .cell.c1.lastcol" "css_element" - # Verify that criteria 1 and 2 name, description and remark are displayed when marking per criterion display is disabled. - And I should see "Grade Criteria " in the "#guide0-criteria .criterion. .criterionshortname" "css_element" - And I should see "Grade description for students" in the "#guide-criteria .criterion. .criteriondescription" "css_element" - And I should see "" in the "#guide0-criteria .criterion. .remark" "css_element" - - Examples: - | criteriacheck | criteriaclass | criteriaremark | - | 1 | first | Excellent work! | - | 2 | last | Try harder | - - Scenario Outline: Confirm that marking guide information is displayed after student is graded - # No need to update marking guide as marking guide definition is already enabled by default - Given I am on the "Assign 1" "assign activity" page + Scenario: Confirm that marking guide information is not displayed after student is graded + # Update the existing marking guide to ensure that marks per criterion is displayed. + Given I click on "Edit the current form definition" "link" + And I set the field "Show marks per criterion to students" to "0" + And I press "Save" + And I am on the "Assign 1" "assign activity" page And I go to "Student 1" "Assign 1" activity advanced grading page And I grade by filling the marking guide with: | Grade Criteria 1 | 50 | Excellent work! | | Grade Criteria 2 | 20 | Try harder | And I press "Save changes" When I am on the "Assign 1" "assign activity" page logged in as student1 - # Confirm the marking guide information display after student is graded when marking per criterion display is enabled. + # Confirm the marking guide information display after student is graded when marking per criterion display is disabled. # Confirm that overall grade is displayed. - Then I should see "70.00 / 100.00" in the ".feedback .feedbacktable .generaltable .cell.c1.lastcol" "css_element" - # Confirm that criteria1 name is displayed. - # Confirm that all marking guide definition and marks per criterion are displayed. - # Verify that criteria 1 and 2 name, description, maximum score, remark and score are all displayed. - And I should see "Grade Criteria " in the "#guide0-criteria .criterion. .criterionshortname" "css_element" - And I should see "Grade description for students" in the "#guide-criteria .criterion. .criteriondescription" "css_element" - And I should see "" in the "#guide0-criteria .criterion. .criteriondescriptionscore" "css_element" - And I should see "" in the "#guide0-criteria .criterion. .remark" "css_element" - And I should see "" in the "#guide0-criteria .criterion. .score" "css_element" + Then I should see "70.00 / 100.00" + And I should see the marking guide information displayed as: + | criteria | description | remark | + | Grade Criteria 1 | Grade 1 description for students | Excellent work! | + | Grade Criteria 2 | Grade 2 description for students | Try harder | - Examples: - | criteriacheck | criteriaclass | criteriaremark | maxscore | criteriascore | - | 1 | first | Excellent work! | 70 | 50 / 70 | - | 2 | last | Try harder | 30 | 20 / 30 | + Scenario: Confirm that marking guide information is displayed after student is graded + Given I am on the "Assign 1" "assign activity" page logged in as student1 + And I should see "Grade 1 description for students" in the "Grade Criteria 1" "table_row" + And I should see "Grade 2 description for students" in the "Grade Criteria 2" "table_row" + # No grade to student1 yet. + And I should not see "70.00 / 100.00" + # No need to update marking guide as marking guide definition is already enabled by default + And I am on the "Assign 1" "assign activity" page logged in as teacher1 + And I go to "Student 1" "Assign 1" activity advanced grading page + And I grade by filling the marking guide with: + | Grade Criteria 1 | 50 | Excellent work! | + | Grade Criteria 2 | 20 | Try harder | + And I press "Save changes" + When I am on the "Assign 1" "assign activity" page logged in as student1 + # Student1 grade is now displayed. + Then I should see "70.00 / 100.00" + And I should see the marking guide information displayed as: + | criteria | description | remark | maxscore | criteriascore | + | Grade Criteria 1 | Grade 1 description for students | Excellent work! | 70 | 50 / 70 | + | Grade Criteria 2 | Grade 2 description for students | Try harder | 30 | 20 / 30 | diff --git a/mod/assign/tests/behat/behat_mod_assign.php b/mod/assign/tests/behat/behat_mod_assign.php new file mode 100644 index 00000000000..7d26105f466 --- /dev/null +++ b/mod/assign/tests/behat/behat_mod_assign.php @@ -0,0 +1,74 @@ +. + +/** + * Behat custom steps and configuration for mod_bigbluebuttonbn. + * + * @package mod_assign + * @category test + * @copyright 2024 Simey Lameze + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +require_once(__DIR__ . '/../../../../lib/behat/behat_base.php'); + +use Behat\Gherkin\Node\TableNode; + +/** + * Behat custom steps and configuration for mod_assign. + * + * @package mod_assign + * @category test + * @copyright 2024 Simey Lameze + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class behat_mod_assign extends behat_base { + + /** + * Check that the marking guide information is displayed correctly. + * + * @Then /^I should see the marking guide information displayed as:$/ + * @param TableNode $table The table of marking guide information to check. + */ + public function i_should_see_marking_guide_information(TableNode $table) { + + if (!$table->getRowsHash()) { + return; + } + + $criteriacheck = 1; + foreach ($table as $row) { + + $locator = "//table[@id='guide0-criteria']/tbody/tr[$criteriacheck]/td"; + + $this->assertSession()->elementContains('xpath', "{$locator}[@class='descriptionreadonly']", $row['criteria']); + $this->assertSession()->elementContains('xpath', "{$locator}[@class='descriptionreadonly']", $row['description']); + + if (!empty($row['remark'])) { + $this->assertSession()->elementContains('xpath', "{$locator}[@class='remark']", $row['remark']); + } + + if (!empty($row['maxscore'])) { + $this->assertSession()->elementContains('xpath', "{$locator}[@class='descriptionreadonly']", $row['maxscore']); + } + + if (!empty($row['criteriascore'])) { + $this->assertSession()->elementContains('xpath', "{$locator}[@class='score']", $row['criteriascore']); + } + + $criteriacheck++; + } + } +}