renaming final_grade to final_score in relevant places. adding computed_final_grade
Change-Id: I09cfecc6ec075b1b45e872a6a1f2efa7e4bd63b9 Reviewed-on: https://gerrit.instructure.com/3034 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Whitmer <brian@instructure.com>
This commit is contained in:
parent
88242820c8
commit
3a171d27d2
|
@ -112,7 +112,7 @@ class AssignmentGroupsController < ApplicationController
|
|||
@group.assignments.first.update_order(order) unless @group.assignments.empty?
|
||||
AssignmentGroup.update_all({:updated_at => Time.now}, {:id => group_ids})
|
||||
ids = @group.assignments.map(&:id)
|
||||
@context.recompute_student_grades rescue nil
|
||||
@context.recompute_student_scores rescue nil
|
||||
respond_to do |format|
|
||||
format.json { render :json => {:reorder => true, :order => ids}, :status => :ok }
|
||||
end
|
||||
|
|
|
@ -687,7 +687,7 @@ class Assignment < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
end
|
||||
Enrollment.send_later_if_production(:recompute_final_grade, context.students.map(&:id), self.context_id) rescue nil
|
||||
Enrollment.send_later_if_production(:recompute_final_score, context.students.map(&:id), self.context_id) rescue nil
|
||||
send_later_if_production(:multiple_module_actions, context.students.map(&:id), :scored, score)
|
||||
|
||||
changed_since_publish = !!self.available?
|
||||
|
|
|
@ -56,7 +56,7 @@ class AssignmentGroup < ActiveRecord::Base
|
|||
|
||||
def update_student_grades
|
||||
if @grades_changed
|
||||
self.context.recompute_student_grades rescue nil
|
||||
self.context.recompute_student_scores rescue nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ class Course < ActiveRecord::Base
|
|||
before_save :assert_defaults
|
||||
before_save :set_update_account_associations_if_changed
|
||||
before_save :update_enrollments_later
|
||||
after_save :update_final_grades_on_weighting_scheme_change
|
||||
after_save :update_final_scores_on_weighting_scheme_change
|
||||
after_save :update_account_associations_if_changed
|
||||
validates_length_of :syllabus_body, :maximum => maximum_long_text_length, :allow_nil => true, :allow_blank => true
|
||||
|
||||
|
@ -461,14 +461,14 @@ class Course < ActiveRecord::Base
|
|||
end
|
||||
memoize :self_enrollment_code
|
||||
|
||||
def update_final_grades_on_weighting_scheme_change
|
||||
def update_final_scores_on_weighting_scheme_change
|
||||
if @group_weighting_scheme_changed
|
||||
Enrollment.send_later_if_production(:recompute_final_grade, self.students.map(&:id), self.id)
|
||||
Enrollment.send_later_if_production(:recompute_final_score, self.students.map(&:id), self.id)
|
||||
end
|
||||
end
|
||||
|
||||
def recompute_student_grades
|
||||
Enrollment.send_later_if_production(:recompute_final_grade, self.students.map(&:id), self.id)
|
||||
def recompute_student_scores
|
||||
Enrollment.send_later_if_production(:recompute_final_score, self.students.map(&:id), self.id)
|
||||
end
|
||||
|
||||
def home_page
|
||||
|
|
|
@ -385,15 +385,19 @@ class Enrollment < ActiveRecord::Base
|
|||
Enrollment.readable_type(self.class.to_s)
|
||||
end
|
||||
|
||||
def self.recompute_final_grades(user_id)
|
||||
def self.recompute_final_scores(user_id)
|
||||
user = User.find(user_id)
|
||||
user.student_enrollments.each do |enrollment|
|
||||
send_later(:recompute_final_grade, user_id, enrollment.course_id)
|
||||
send_later(:recompute_final_score, user_id, enrollment.course_id)
|
||||
end
|
||||
end
|
||||
|
||||
def self.recompute_final_grade(user_ids, course_id)
|
||||
GradeCalculator.recompute_final_grade(user_ids, course_id)
|
||||
def self.recompute_final_score(user_ids, course_id)
|
||||
GradeCalculator.recompute_final_score(user_ids, course_id)
|
||||
end
|
||||
|
||||
def computed_final_grade
|
||||
raise "TODO"
|
||||
end
|
||||
|
||||
def self.students(opts={})
|
||||
|
|
|
@ -142,7 +142,7 @@ class Submission < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def update_final_score
|
||||
Enrollment.send_later_if_production(:recompute_final_grade, self.user_id, self.context.id) if @score_changed
|
||||
Enrollment.send_later_if_production(:recompute_final_score, self.user_id, self.context.id) if @score_changed
|
||||
self.assignment.send_later_if_production(:multiple_module_actions, [self.user_id], :scored, self.score) if self.assignment && @score_changed
|
||||
true
|
||||
end
|
||||
|
|
|
@ -612,7 +612,7 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
self.reload
|
||||
Enrollment.send_later(:recompute_final_grades, new_user.id)
|
||||
Enrollment.send_later(:recompute_final_scores, new_user.id)
|
||||
self.destroy
|
||||
end
|
||||
|
||||
|
|
|
@ -28,17 +28,17 @@ class GradeCalculator
|
|||
@final_updates = []
|
||||
end
|
||||
|
||||
def self.recompute_final_grade(user_ids, course_id)
|
||||
def self.recompute_final_score(user_ids, course_id)
|
||||
calc = GradeCalculator.new user_ids, course_id
|
||||
calc.recompute_and_save_grades
|
||||
calc.recompute_and_save_scores
|
||||
end
|
||||
|
||||
# recomputes the grades and saves them to each user's Enrollment
|
||||
def recompute_and_save_grades
|
||||
# recomputes the scores and saves them to each user's Enrollment
|
||||
def recompute_and_save_scores
|
||||
@user_ids.each do |user_id|
|
||||
submissions = Submission.for_user(user_id)
|
||||
calculate_current_grade(user_id, submissions)
|
||||
calculate_final_grade(user_id, submissions)
|
||||
calculate_current_score(user_id, submissions)
|
||||
calculate_final_score(user_id, submissions)
|
||||
end
|
||||
|
||||
conn = ActiveRecord::Base.connection
|
||||
|
@ -53,15 +53,15 @@ class GradeCalculator
|
|||
|
||||
:private
|
||||
|
||||
# The grade ignoring unsubmitted assignments
|
||||
def calculate_current_grade(user_id, submissions)
|
||||
# The score ignoring unsubmitted assignments
|
||||
def calculate_current_score(user_id, submissions)
|
||||
group_sums = create_group_sums(submissions)
|
||||
score = calculate_total_from_group_scores(group_sums)
|
||||
@current_updates << "WHEN user_id=#{user_id} THEN #{score || "NULL"}"
|
||||
end
|
||||
|
||||
# The final grade for the class, so unsubmitted assignments count as zeros
|
||||
def calculate_final_grade(user_id, submissions)
|
||||
# The final score for the class, so unsubmitted assignments count as zeros
|
||||
def calculate_final_score(user_id, submissions)
|
||||
group_sums = create_group_sums(submissions, false)
|
||||
score = calculate_total_from_group_scores(group_sums, false)
|
||||
@final_updates << "WHEN user_id=#{user_id} THEN #{score || "NULL"}"
|
||||
|
|
|
@ -122,7 +122,7 @@ describe Course, "gradebook_to_csv" do
|
|||
@assignment = @course.assignments.create!(:title => "Some Assignment", :points_possible => 10, :assignment_group => @group)
|
||||
@assignment.grade_student(@user, :grade => "10")
|
||||
@assignment2 = @course.assignments.create!(:title => "Some Assignment 2", :points_possible => 10, :assignment_group => @group)
|
||||
@course.recompute_student_grades
|
||||
@course.recompute_student_scores
|
||||
@user.reload
|
||||
@course.reload
|
||||
|
||||
|
|
Loading…
Reference in New Issue