From 8ff753857cc225577569e3f8fc1a960115269611 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Mon, 30 Dec 2013 14:20:06 -0800 Subject: [PATCH 1/3] MDL-43332 core_grades: automated basic grade viewing functionality performed in MDLQA-317 --- grade/tests/behat/behat_grade.php | 49 +++++++++++++++++++++++++ grade/tests/behat/grade_view.feature | 55 ++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 grade/tests/behat/behat_grade.php create mode 100644 grade/tests/behat/grade_view.feature diff --git a/grade/tests/behat/behat_grade.php b/grade/tests/behat/behat_grade.php new file mode 100644 index 0000000000000..90a123bf30553 --- /dev/null +++ b/grade/tests/behat/behat_grade.php @@ -0,0 +1,49 @@ +. + +/** + * Behat grade related steps definitions. + * + * @package core_grades + * @category test + * @copyright 2013 Mark Nelson + * @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'); + +use Behat\Behat\Context\Step\Given as Given; + +class behat_grade extends behat_base { + + /** + * Enters a grade via the gradebook for a specific grade item and user when viewing the 'Grader report' with editing mode turned on. + * + * @Given /^I give the grade "(?P(?:[^"]|\\")*)" to the user "(?P(?:[^"]|\\")*)" for the grade item "(?P(?:[^"]|\\")*)"$/ + * @param int $grade + * @param string $userfullname the user's fullname as returned by fullname() + * @param string $itemname + * @return Given + */ + public function i_give_the_grade($grade, $userfullname, $itemname) { + $gradelabel = $userfullname . ' ' . $itemname; + $fieldstr = get_string('useractivitygrade', 'gradereport_grader', $gradelabel); + + return new Given('I fill in "' . $this->escape($fieldstr) . '" with "' . $grade . '"'); + } +} diff --git a/grade/tests/behat/grade_view.feature b/grade/tests/behat/grade_view.feature new file mode 100644 index 0000000000000..dd7d0bb9c3d2c --- /dev/null +++ b/grade/tests/behat/grade_view.feature @@ -0,0 +1,55 @@ +@core @core_grades +Feature: Viewing the gradebook + In order to check the expected results are displayed + As a teacher + I need to assign grades and check that they display correctly in the gradebook. + + @javascript + Scenario: Grade a grade item and ensure the results display correctly in the gradebook + Given the following "courses" exists: + | fullname | shortname | format | + | Course 1 | C1 | topics | + And the following "users" exists: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@asd.com | + | student1 | Student | 1 | student1@asd.com | + And the following "course enrolments" exists: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + And I log in as "teacher1" + 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 | + | 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" + When I press "Add submission" + And I fill the moodle form with: + | Online text | This is a submission | + And I press "Save changes" + Then I should see "Submitted for grading" + And I log out + And I log in as "teacher1" + 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 press "Update" + And I select "User report" from "Grade report" + And the "Grade report" select box should contain "Grader report" + And the "Grade report" select box should contain "Outcomes report" + And the "Grade report" select box should contain "User report" + And the "Select all or one user" select box should contain "All users (1)" + And I log out + 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" + From 1301a07a3ecf7d01289d87f7b96707acbbd04242 Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Thu, 9 Jan 2014 16:03:16 +0800 Subject: [PATCH 2/3] MDL-31597 gradebook: Removed the percentage symbol from weights in the gradebook. --- grade/report/user/lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grade/report/user/lib.php b/grade/report/user/lib.php index adb3badd29d2e..c2158278754c9 100644 --- a/grade/report/user/lib.php +++ b/grade/report/user/lib.php @@ -415,7 +415,7 @@ private function fill_table_recursive(&$element) { $data['weight']['headers'] = "$header_cat $header_row weight"; // has a weight assigned, might be extra credit if ($grade_object->aggregationcoef > 0 && $type <> 'courseitem') { - $data['weight']['content'] = number_format($grade_object->aggregationcoef,2).'%'; + $data['weight']['content'] = number_format($grade_object->aggregationcoef,2); } } From 4e2ba4bb31add3af6585f2f7dd687b86cbd3c30c Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Thu, 9 Jan 2014 16:03:57 +0800 Subject: [PATCH 3/3] MDL-31597 gradebook: Update to gradebook behat tests to include testing grade weightings. --- grade/tests/behat/grade_view.feature | 29 ++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/grade/tests/behat/grade_view.feature b/grade/tests/behat/grade_view.feature index dd7d0bb9c3d2c..24e54580b87e7 100644 --- a/grade/tests/behat/grade_view.feature +++ b/grade/tests/behat/grade_view.feature @@ -1,11 +1,11 @@ @core @core_grades -Feature: Viewing the gradebook +Feature: We can enter in grades and view reports from the gradebook In order to check the expected results are displayed As a teacher I need to assign grades and check that they display correctly in the gradebook. + I need to enable grade weightings and check that they are displayed correctly. - @javascript - Scenario: Grade a grade item and ensure the results display correctly in the gradebook + Background: Given the following "courses" exists: | fullname | shortname | format | | Course 1 | C1 | topics | @@ -40,7 +40,10 @@ Feature: Viewing the gradebook 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 press "Update" - And I select "User report" from "Grade report" + + @javascript + Scenario: Grade a grade item and ensure the results display correctly in the gradebook + When I select "User report" from "Grade report" And the "Grade report" select box should contain "Grader report" And the "Grade report" select box should contain "Outcomes report" And the "Grade report" select box should contain "User report" @@ -53,3 +56,21 @@ Feature: Viewing the gradebook And I select "Overview report" from "Grade report" And I should see "80.00" in the "overview-grade" "table" + @javascript + Scenario: We can add a weighting to a grade item and it is displayed properly in the user report + When I select "Full view" from "Grade report" + And I select "Weighted mean of grades" from "Aggregation" + And I fill the moodle form with: + | Extra credit value for Test assignment name | 0.72 | + And I press "Save changes" + And I select "User report" from "Grade report" + And I follow "Course grade settings" + And I fill the moodle form with: + | Show weightings | Show | + And I press "Save changes" + And I log out + 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"