From 60608aa03262631689991d58dcbd67df0e944f01 Mon Sep 17 00:00:00 2001 From: Daniel Bucci Date: Mon, 9 Feb 2015 17:48:08 -0500 Subject: [PATCH] Fixed CSV and Student Gradebook Ordering --- app/helpers/gradebook_helper.rb | 6 +++--- app/models/assessment.rb | 2 +- app/views/gradebooks/student.html.erb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/helpers/gradebook_helper.rb b/app/helpers/gradebook_helper.rb index 1fc3f4023..1fa4c3150 100755 --- a/app/helpers/gradebook_helper.rb +++ b/app/helpers/gradebook_helper.rb @@ -77,7 +77,7 @@ def gradebook_rows(matrix, course, section = nil, lecture = nil) row["section"] = cud.section # TODO: formalize score render stack, consolidate with computed score - course.assessments.each do |a| + course.assessments.ordered.each do |a| next unless matrix.has_assessment? a.id cell = matrix.cell(a.id, cud.id) @@ -110,7 +110,7 @@ def csv_header(matrix, course) header = [ "Email", "first_name", "last_name", "Lecture", "Section", "School", "Major", "Year" ] course.assessment_categories.each do |cat| next unless matrix.has_category? cat.id - cat.assessments.each do |asmt| + cat.assessments.ordered.each do |asmt| next unless matrix.has_assessment? asmt.id header << asmt.name end @@ -146,7 +146,7 @@ def gradebook_csv(matrix, course) course.assessment_categories.each do |cat| next unless matrix.has_category? cat.id - cat.assessments.each do |asmt| + cat.assessments.ordered.each do |asmt| next unless matrix.has_assessment? asmt.id row << formatted_status(matrix.cell(asmt.id, cud.id)["status"]) diff --git a/app/models/assessment.rb b/app/models/assessment.rb index b78196517..610ce1725 100755 --- a/app/models/assessment.rb +++ b/app/models/assessment.rb @@ -44,7 +44,7 @@ class Assessment < ActiveRecord::Base RELEASED = "start_at < ?" # Scopes - scope :ordered, -> { order ORDERING } + scope :ordered, -> { order(ORDERING) } scope :released, ->(as_of = Time.now) { where(RELEASED, as_of) } scope :unreleased, ->(as_of = Time.now) { where.not(RELEASED, as_of) } diff --git a/app/views/gradebooks/student.html.erb b/app/views/gradebooks/student.html.erb index 620290890..e26ef9cac 100755 --- a/app/views/gradebooks/student.html.erb +++ b/app/views/gradebooks/student.html.erb @@ -86,7 +86,7 @@ Final Score - <% cat.assessments.each do |asmt| %> + <% cat.assessments.ordered.each do |asmt| %> <% aud = asmt.aud_for @_cud %>