optimize gradebook_json

Change-Id: Ib780ade2a6c89dd508c8df467c9e0f13497f189c
Reviewed-on: https://gerrit.instructure.com/2936
Reviewed-by: Brian Whitmer <brian@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
This commit is contained in:
Zach Wily 2011-04-01 16:03:50 -06:00
parent d95bd6ac7a
commit e4d88c5fcb
1 changed files with 10 additions and 13 deletions

View File

@ -885,18 +885,15 @@ class Course < ActiveRecord::Base
end
def gradebook_json
to_json(
:include_root => false,
:include => {
:active_assignments => {},
:students => {
:include => {
:submissions => {
:include => :quiz_submission
}
}
}
})
hash = self.as_json(:include_root => false)
submissions = self.submissions
hash['active_assignments'] = self.active_assignments.map{|a| a.as_json(:include_root => false) }
hash['students'] = self.students.map do |user|
res = user.as_json(:include_root => false)
res['submissions'] = submissions.select{|s| s.user_id == user.id }.map{|s| s.as_json(:include_root => false) }
res
end
hash.to_json
end
def add_aggregate_entries(entries, feed)