mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 07:56:06 +02:00
Merge branch 'MDL-45870-master' of git://github.com/FMCorz/moodle
This commit is contained in:
commit
8888451ed5
@ -6353,12 +6353,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)) {
|
||||
@ -6380,9 +6382,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];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6429,7 +6432,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);
|
||||
|
134
mod/assign/tests/behat/outcome_grading.feature
Normal file
134
mod/assign/tests/behat/outcome_grading.feature
Normal file
@ -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 members
|
||||
And I add "Student 1 (student1@asd.com)" user to "Group 1" group members
|
||||
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"
|
Loading…
x
Reference in New Issue
Block a user