update the assessor on regrading/reassessing a rubric

This patchset updates the assessor on re-assessment/re-grading a
rubric assessment. It also seeds the submission when updated to record
for grade change purposes who is making the change.

fixes GRADE-369

test plan:
 - Make sure you have Cassandra configured
 - Have a course with a student, two teachers, and an assignment that
   has a rubric.
 - As the first teacher, grade the student using the rubric
 - As the second teacher, regrade the student using the rubric
 - As the first teacher, regrade the student using the rubic
 - As the second teacher, regrade the student using the rubric
 - Go into gradebook history and note that the grader in the report
   matches the pattern of grading above and isn't just the first
   grader

Change-Id: Ia167d282c7e7284039b07d74b8f764044c362800
Reviewed-on: https://gerrit.instructure.com/131894
Tested-by: Jenkins
Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
This commit is contained in:
Keith Garner 2017-11-06 09:46:36 -06:00 committed by Keith T. Garner
parent 782685913c
commit 69a4a8db7e
2 changed files with 45 additions and 0 deletions

View File

@ -307,6 +307,8 @@ class RubricAssociation < ActiveRecord::Base
if assessments_unique_per_asset?(params[:assessment_type])
# Unless it's for grading, in which case assessments are unique per artifact (the assessor can change, depending on if the teacher/TA updates it)
assessment = association.rubric_assessments.where(artifact_id: artifact, artifact_type: artifact.class.to_s, assessment_type: params[:assessment_type]).first
# Update the assessor in case it did change
assessment&.assessor = opts[:assessor]
else
# Assessments are unique per artifact/assessor/assessment_type.
assessment = association.rubric_assessments.where(artifact_id: artifact, artifact_type: artifact.class.to_s, assessor_id: opts[:assessor], assessment_type: params[:assessment_type]).first

View File

@ -198,4 +198,47 @@ describe RubricAssociation do
@rubric.update_with_association(@user, rubric_params, @course, rubric_association_params)
end
end
describe "#assess" do
let(:course) { Course.create! }
let!(:first_teacher) { course_with_teacher(course: course, active_all: true).user }
let!(:second_teacher) { course_with_teacher(course: course, active_all: true).user }
let(:student) { student_in_course(course: course, active_all: true).user }
let(:assignment) { course.assignments.create!(submission_types: 'online_text_entry') }
let(:rubric) do
course.rubrics.create! do |r|
r.title = "rubric"
r.user = first_teacher
r.data = [{
id: "stuff",
description: "stuff",
long_description: "",
points: 1.0,
ratings: [
{ description: "Full Marks", points: 1.0, id: "blank" },
{ description: "No Marks", points: 0.0, id: "blank_2" }
]
}]
end
end
let!(:rubric_association) do
params = rubric_association_params_for_assignment(assignment)
RubricAssociation.generate(first_teacher, rubric, course, params)
end
let(:submission) { assignment.submit_homework(student) }
let(:assessment_params) { { assessment_type: 'grading', criterion_stuff: { points: 1 } } }
it "updates the assessor/grader if the second assessor is different than the first" do
rubric_association.assess(user: student, assessor: first_teacher, artifact: submission,
assessment: assessment_params)
assessment_params[:criterion_stuff][:points] = 0
assessment = rubric_association.assess(user: student, assessor: second_teacher, artifact: submission,
assessment: assessment_params)
submission.reload
expect(assessment.assessor).to eq(second_teacher)
expect(submission.grader).to eq(second_teacher)
end
end
end