display gradebook history properly. fixes #6051

changes to a grade were appearing in grade history only
on the date of the first grade. grade changes now display
once on each day that they occur.

Change-Id: I66e84a23f28757e3433e2bcbbe437a9a6ff046d8
Reviewed-on: https://gerrit.instructure.com/6373
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
This commit is contained in:
Zach Pendleton 2011-10-21 14:00:21 -06:00
parent c59c0f593f
commit b47504025c
4 changed files with 31 additions and 5 deletions

View File

@ -833,6 +833,7 @@ class Assignment < ActiveRecord::Base
submission_updated = true if submission.changed?
submission.workflow_state = "graded" if submission.score_changed? || submission.grade_matches_current_submission
submission.group = group
submission.graded_at = Time.now if did_grade
previously_graded ? submission.with_versioning(:explicit => true) { submission.save! } : submission.save!
tags.each do |tag|
tag.create_outcome_result(student, self, submission)

View File

@ -234,7 +234,7 @@ class SubmissionList
# Also don't add it to the list. Just pass the list to the next
# iteration of the block.
next(l) unless h[:score]
# If the submission is different (not null for the first one, or just
# different than the last one), set the previous_grade to nil (this is
# the first version that changes a grade), set the new_grade to this
@ -255,7 +255,7 @@ class SubmissionList
# Remove the old submission so that it doesn't show up twice in the
# grade history.
elsif prior_score != h[:score]
l.pop
l.pop if prior_graded_at.to_date == h[:graded_at].to_date && prior_grader == h[:grader]
h[:previous_grade] = prior_grade
h[:previous_graded_at] = prior_graded_at
h[:previous_grader] = prior_grader

View File

@ -73,6 +73,16 @@ describe SubmissionList do
end
end
end
it "should only keep one diff per grader per day" do
SubmissionList.days(@course).each do |day|
day.graders.each do |grader|
grader.assignments.each do |assignment|
assignment.submissions.length.should eql assignment.submissions.map(&:student_name).uniq.length
end
end
end
end
it "should be able to loop on assignments" do
available_keys = [:submission_count, :name, :submissions, :assignment_id]
@ -207,10 +217,13 @@ def interesting_submission_data(opts={})
opts[:submission] ||= {}
@grader = user_model({:name => 'some_grader'}.merge(opts[:grader]))
@grader2 = user_model({:name => 'another_grader'}.merge(opts[:grader]))
@student = factory_with_protected_attributes(User, {:name => "some student", :workflow_state => "registered"}.merge(opts[:user]))
@course = factory_with_protected_attributes(Course, {:name => "some course", :workflow_state => "available"}.merge(opts[:course]))
e = @course.enroll_teacher(@grader)
e.accept
[@grader, @grader2].each do |grader|
e = @course.enroll_teacher(grader)
e.accept
end
@course.enroll_student(@student)
@assignment = @course.assignments.new({
:title => "some assignment",
@ -220,7 +233,7 @@ def interesting_submission_data(opts={})
@assignment.save!
@assignment.grade_student(@student, {:grade => 1.5, :grader => @grader}.merge(opts[:submission]))
@assignment.grade_student(@student, {:grade => 3, :grader => @grader}.merge(opts[:submission]))
@assignment.grade_student(@student, {:grade => 5, :grader => @grader}.merge(opts[:submission]))
@assignment.grade_student(@student, {:grade => 5, :grader => @grader2}.merge(opts[:submission]))
@student = user_model(:name => 'another student')
@course.enroll_student(@student)
@assignment.reload

View File

@ -53,6 +53,18 @@ describe Assignment do
@submission.versions.length.should eql(1)
end
it "should update a submission's graded_at when grading it" do
setup_assignment_with_homework
@assignment.grade_student(@user, :grade => 1)
@submission = @assignment.submissions.first
original_graded_at = @submission.graded_at
new_time = Time.now + 1.hour
Time.stub!(:now).and_return(new_time)
@assignment.grade_student(@user, :grade => 2)
@submission.reload
@submission.graded_at.should_not eql original_graded_at
end
it "should update needs_grading_count when submissions transition state" do
setup_assignment_with_homework
@assignment.needs_grading_count.should eql(1)