fix another assignment editing bug
fixes CNVS-8100, refs CNVS-1672 This applies to complete/incomplete, and probably letter grade and gpa scale Test plan: * make a complete/incomplete assignment with 0 points possible * give it a due date, but no availability date * mark some students complete, some students incomplete * add an availability date * the complete/incomplete for each submission status should be retained Change-Id: I84400145a57926aa2677aef515562b29a1f32463 Reviewed-on: https://gerrit.instructure.com/36383 Reviewed-by: Simon Williams <simon@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Amber Taniuchi <amber@instructure.com> Product-Review: Simon Williams <simon@instructure.com>
This commit is contained in:
parent
e4648d39a7
commit
31d2de08e5
|
@ -263,7 +263,7 @@ class Assignment < ActiveRecord::Base
|
|||
def update_student_submissions
|
||||
graded_at = Time.zone.now
|
||||
submissions.graded.includes(:user).find_each do |s|
|
||||
s.grade = score_to_grade(s.score)
|
||||
s.grade = score_to_grade(s.score, s.grade)
|
||||
s.graded_at = graded_at
|
||||
s.assignment = self
|
||||
s.assignment_changed_not_sub = true
|
||||
|
@ -637,14 +637,11 @@ class Assignment < ActiveRecord::Base
|
|||
when "percent"
|
||||
result = "#{score_to_grade_percent(score)}%"
|
||||
when "pass_fail"
|
||||
if points_possible && points_possible > 0
|
||||
passed = score > 0
|
||||
elsif given_grade
|
||||
# the score for a zero-point pass/fail assignment could be considered
|
||||
# either pass *or* fail, so look at what the current given grade is
|
||||
# instead
|
||||
passed = ["complete", "pass"].include?(given_grade)
|
||||
end
|
||||
passed = if points_possible && points_possible > 0
|
||||
score > 0
|
||||
elsif given_grade
|
||||
given_grade == "complete" || given_grade == "pass"
|
||||
end
|
||||
result = passed ? "complete" : "incomplete"
|
||||
when "letter_grade", "gpa_scale"
|
||||
if self.points_possible.to_f > 0.0
|
||||
|
|
|
@ -303,33 +303,6 @@ describe Assignment do
|
|||
@submission.user_id.should eql(@user.id)
|
||||
end
|
||||
|
||||
it "should preserve pass/fail with no points possible" do
|
||||
setup_assignment_without_submission
|
||||
@assignment.grading_type = 'pass_fail'
|
||||
@assignment.points_possible = nil
|
||||
@assignment.save
|
||||
s = @assignment.grade_student(@user, :grade => 'pass')
|
||||
s.should be_is_a(Array)
|
||||
@assignment.reload
|
||||
@assignment.submissions.size.should eql(1)
|
||||
@submission = @assignment.submissions.first
|
||||
@submission.state.should eql(:graded)
|
||||
@submission.should eql(s[0])
|
||||
@submission.score.should eql(0.0)
|
||||
@submission.grade.should eql('complete')
|
||||
@submission.user_id.should eql(@user.id)
|
||||
|
||||
@assignment.grade_student(@user, :grade => 'fail')
|
||||
@assignment.reload
|
||||
@assignment.submissions.size.should eql(1)
|
||||
@submission = @assignment.submissions.first
|
||||
@submission.state.should eql(:graded)
|
||||
@submission.should eql(s[0])
|
||||
@submission.score.should eql(0.0)
|
||||
@submission.grade.should eql('incomplete')
|
||||
@submission.user_id.should eql(@user.id)
|
||||
end
|
||||
|
||||
it "should preserve letter grades with zero points possible" do
|
||||
setup_assignment_without_submission
|
||||
@assignment.grading_type = 'letter_grade'
|
||||
|
@ -2443,24 +2416,29 @@ describe Assignment do
|
|||
end
|
||||
|
||||
describe "update_student_submissions" do
|
||||
before do
|
||||
@student1, @student2 = n_students_in_course(2)
|
||||
@assignment = @course.assignments.create! grading_type: "pass_fail",
|
||||
points_possible: 5
|
||||
@sub1 = @assignment.grade_student(@student1, grade: "complete").first
|
||||
@sub2 = @assignment.grade_student(@student2, grade: "incomplete").first
|
||||
end
|
||||
|
||||
it "should save a version when changing grades" do
|
||||
setup_assignment_without_submission
|
||||
s = @assignment.grade_student(@user, :grade => "10").first
|
||||
@assignment.points_possible = 5
|
||||
@assignment.save!
|
||||
s.reload.version_number.should == 2
|
||||
@assignment.update_attribute :points_possible, 10
|
||||
@sub1.reload.version_number.should == 2
|
||||
end
|
||||
|
||||
it "works for pass/fail assignments" do
|
||||
student1, student2 = n_students_in_course(2)
|
||||
a = @course.assignments.create! grading_type: "pass_fail", points_possible: 5
|
||||
sub1 = a.grade_student(student1, grade: "complete").first
|
||||
sub2 = a.grade_student(student2, grade: "incomplete").first
|
||||
@assignment.update_attribute :points_possible, 10
|
||||
@sub1.reload.grade.should == "complete"
|
||||
@sub2.reload.grade.should == "incomplete"
|
||||
end
|
||||
|
||||
a.update_attribute :points_possible, 10
|
||||
|
||||
sub1.reload.grade.should == "complete"
|
||||
sub2.reload.grade.should == "incomplete"
|
||||
it "works for pass/fail assignments with 0 points possible" do
|
||||
@assignment.update_attribute :points_possible, 0
|
||||
@sub1.reload.grade.should == "complete"
|
||||
@sub2.reload.grade.should == "incomplete"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue