From 36cef83e0803f19ce9e74222ac4fabec7a35cd00 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Thu, 5 Jun 2014 15:56:13 +0800 Subject: [PATCH 1/2] MDL-45870 mod_assign: Outcomes are saved for each group member --- mod/assign/locallib.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 2869d83afa9..9d8f97cb1f6 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -6237,12 +6237,14 @@ class assign { /** - * Save outcomes submitted from grading form + * Save outcomes submitted from grading form. * * @param int $userid * @param stdClass $formdata + * @param int $sourceuserid The user ID under which the outcome data is accessible. This is relevant + * for an outcome set to a user but applied to an entire group. */ - protected function process_outcomes($userid, $formdata) { + protected function process_outcomes($userid, $formdata, $sourceuserid = null) { global $CFG, $USER; if (empty($CFG->enableoutcomes)) { @@ -6264,9 +6266,10 @@ class assign { if (!empty($gradinginfo->outcomes)) { foreach ($gradinginfo->outcomes as $index => $oldoutcome) { $name = 'outcome_'.$index; - if (isset($formdata->{$name}[$userid]) && - $oldoutcome->grades[$userid]->grade != $formdata->{$name}[$userid]) { - $data[$index] = $formdata->{$name}[$userid]; + $sourceuserid = $sourceuserid !== null ? $sourceuserid : $userid; + if (isset($formdata->{$name}[$sourceuserid]) && + $oldoutcome->grades[$userid]->grade != $formdata->{$name}[$sourceuserid]) { + $data[$index] = $formdata->{$name}[$sourceuserid]; } } } @@ -6313,7 +6316,7 @@ class assign { foreach ($members as $member) { // User may exist in multple groups (which should put them in the default group). $this->apply_grade_to_user($data, $member->id, $data->attemptnumber); - $this->process_outcomes($member->id, $data); + $this->process_outcomes($member->id, $data, $userid); } } else { $this->apply_grade_to_user($data, $userid, $data->attemptnumber); From 66f93d133a2cab2708484a3dc5b26576b4e67edd Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Fri, 6 Jun 2014 12:23:45 +0800 Subject: [PATCH 2/2] MDL-45870 mod_assign: Behat test covering some outcome usage --- .../tests/behat/outcome_grading.feature | 134 ++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 mod/assign/tests/behat/outcome_grading.feature diff --git a/mod/assign/tests/behat/outcome_grading.feature b/mod/assign/tests/behat/outcome_grading.feature new file mode 100644 index 00000000000..b10c5dc2b52 --- /dev/null +++ b/mod/assign/tests/behat/outcome_grading.feature @@ -0,0 +1,134 @@ +@mod @mod_assign @core_outcome @javascript +Feature: Outcome grading + In order to give an outcome to my student + As a teacher + I need to grade a submission + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@asd.com | + | student0 | Student | 0 | student0@asd.com | + | student1 | Student | 1 | student1@asd.com | + And the following "courses" exist: + | fullname | shortname | category | groupmode | + | Course 1 | C1 | 0 | 1 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student0 | C1 | student | + | student1 | C1 | student | + And I log in as "admin" + And I set the following administration settings values: + | Enable outcomes | 1 | + And I expand "Grades" node + And I follow "Scales" + And I press "Add a new scale" + And I set the following fields to these values: + | Name | Test Scale | + | Scale | Disappointing, Excellent, Good, Very good, Excellent | + And I press "Save changes" + And I follow "Outcomes" + And I press "Add a new outcome" + And I set the following fields to these values: + | Full name | Outcome Test | + | Short name | OT | + | Scale | Test Scale | + And I press "Save changes" + And I am on homepage + And I follow "Course 1" + And I follow "Outcomes" + And I set the field "Available standard outcomes" to "Outcome Test" + And I click on "#add" "css_element" + And I log out + + Scenario: Giving an outcome to a student + Given 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 | Test assignment description | + | assignsubmission_onlinetext_enabled | 1 | + | Outcome Test | 1 | + And I log out + And I log in as "student1" + And I follow "Course 1" + And I follow "Test assignment name" + And I press "Add submission" + And I set the following fields to these values: + | Online text | My online text | + And I press "Save changes" + And I log out + When I log in as "teacher1" + And I follow "Course 1" + And I follow "Test assignment name" + And I follow "View/grade all submissions" + And I click on "img[alt='Grade Student 0']" "css_element" + And I set the following fields to these values: + | Outcome Test: | Excellent | + And I press "Save changes" + And I press "Continue" + Then I should see "Outcome Test: Excellent" in the "Student 0" "table_row" + And I should not see "Outcome Test: Excellent" in the "Student 1" "table_row" + + Scenario: Giving an outcome to a group submission + Given the following "users" exist: + | username | firstname | lastname | email | + | student2 | Student | 2 | student2@asd.com | + And the following "course enrolments" exist: + | user | course | role | + | student2 | C1 | student | + And the following "groups" exist: + | name | course | idnumber | + | Group 1 | C1 | G1 | + And I log in as "teacher1" + And I follow "Course 1" + And I expand "Users" node + And I follow "Groups" + And I add "Student 0 (student0@asd.com)" user to "Group 1" group + And I add "Student 1 (student1@asd.com)" user to "Group 1" group + And I am on homepage + 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 | Test assignment description | + | assignsubmission_onlinetext_enabled | 1 | + | Students submit in groups | Yes | + | Group mode | No groups | + | Outcome Test | 1 | + And I log out + And I log in as "student1" + And I follow "Course 1" + And I follow "Test assignment name" + And I press "Add submission" + And I set the following fields to these values: + | Online text | My online text | + And I press "Save changes" + And I log out + When I log in as "teacher1" + And I follow "Course 1" + And I follow "Test assignment name" + And I follow "View/grade all submissions" + And I click on "img[alt='Grade Student 0']" "css_element" + And I set the following fields to these values: + | Outcome Test: | Excellent | + | Apply grades and feedback to entire group | Yes | + And I press "Save changes" + And I press "Continue" + Then I should see "Outcome Test: Excellent" in the "Student 0" "table_row" + And I should see "Outcome Test: Excellent" in the "Student 1" "table_row" + And I should not see "Outcome Test: Excellent" in the "Student 2" "table_row" + And I click on "img[alt='Grade Student 1']" "css_element" + And I set the following fields to these values: + | Outcome Test: | Disappointing | + | Apply grades and feedback to entire group | No | + And I press "Save changes" + And I press "Continue" + And I should see "Outcome Test: Excellent" in the "Student 0" "table_row" + And I should see "Outcome Test: Disappointing" in the "Student 1" "table_row" + And I should not see "Outcome Test: Disappointing" in the "Student 0" "table_row" + And I should not see "Outcome Test: Excellent" in the "Student 1" "table_row" + And I should not see "Outcome Test: Disappointing" in the "Student 2" "table_row" + And I should not see "Outcome Test: Excellent" in the "Student 2" "table_row"