From 3ac3d942dd2caf266c6aae61d45850564890ea79 Mon Sep 17 00:00:00 2001 From: Angelia Dela Cruz Date: Wed, 8 Nov 2023 11:07:57 +0800 Subject: [PATCH 1/2] MDL-79990 gradingform: Behat test for marking guide information display --- .../tests/behat/assign_marking_guide.feature | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 grade/grading/form/guide/tests/behat/assign_marking_guide.feature diff --git a/grade/grading/form/guide/tests/behat/assign_marking_guide.feature b/grade/grading/form/guide/tests/behat/assign_marking_guide.feature new file mode 100644 index 0000000000000..e90e9770e5789 --- /dev/null +++ b/grade/grading/form/guide/tests/behat/assign_marking_guide.feature @@ -0,0 +1,96 @@ +@gradingform @gradingform_guide @javascript +Feature: Display marking guide information to students + In order for students to see the marking guide information + As a teacher + I should be able to change display settings for marking guide information + + Background: + Given the following "courses" exist: + | fullname | shortname | + | Course 1 | C1 | + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@example.com | + | student1 | Student | 1 | student1@example.com | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + And the following "activities" exist: + | activity | course | name | advancedgradingmethod_submissions | + | 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 | + And I define the following marking guide: + | Criterion name | Description for students | Description for markers | Maximum score | + | Grade Criteria 1 | Grade 1 description for students | Grade 1 description for markers | 70 | + | 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 + 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 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" + + Examples: + | criteriacheck | criteriaclass | criteriaremark | maxscore | criteriascore | + | 1 | first | Excellent work! | 70 | 50 / 70 | + | 2 | last | Try harder | 30 | 20 / 30 | From 2db07c4d0a837f503a9e9a2308ab3268293327ec Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Mon, 12 Feb 2024 18:08:35 +0800 Subject: [PATCH 2/2] MDL-79990 behat: custom step to verify assign grading data This commit also optimise the new behat test. --- .../tests/behat/assign_marking_guide.feature | 88 +++++++------------ mod/assign/tests/behat/behat_mod_assign.php | 74 ++++++++++++++++ 2 files changed, 106 insertions(+), 56 deletions(-) create mode 100644 mod/assign/tests/behat/behat_mod_assign.php 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 e90e9770e5789..3e5ad73b704d0 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 0000000000000..7d26105f46663 --- /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++; + } + } +}