Permalink
Browse files

Worked on several small bug fixes

* reordered the school year index
* added first_name to the Student sort ordering
* corrected a bug in the report card where it was not only using active courses
  • Loading branch information...
1 parent ee21506 commit 6926bd941d02d33050dead2c26faba5fbcca9492 @rnhurt committed Oct 1, 2011
@@ -26,10 +26,10 @@ def edit
value = params[:value].split('||')
if value.pop == 'H' then
# Find students by "Home Room"
- @students = Student.active.find_all_by_homeroom(value[0])
+ @students = Student.active.sorted.find_all_by_homeroom(value[0])
else
# Find students by "Class Of"
- @students = Student.active.find_all_by_class_of(value[0])
+ @students = Student.active.sorted.find_all_by_class_of(value[0])
end
render :partial => "student_list"
@@ -2,7 +2,9 @@ class Settings::SchoolYearsController < SettingsController
after_filter :expire_cache, :only => [:create, :update, :destroy]
def index
- @years = SchoolYear.all(:order => "end_date DESC", :include => :terms)
+ # Due to the way SchoolYear objects are built, we have to sort them and limit them
+ # when they are used instead of in the Model where it should be. :(
+ @years = SchoolYear.all(:include => :terms).sort! { |x,y| y.end_date <=> x.end_date } [0..5]
end
def show
View
@@ -21,7 +21,7 @@ class Student < User
:conditions => { :active => true }
# :conditions => ["active = ? AND homeroom != ''", true]
- named_scope :sorted, :order => 'last_name ASC'
+ named_scope :sorted, :order => 'last_name ASC, first_name ASC'
def current_course_terms
return CourseTerm.all(:joins => :course)
@@ -412,7 +412,7 @@ def self.print_attendance(position, student)
data_hash = {}
attendance = Struct.new(:name, *(@terms.collect{|t| t.name} << :total))
- homeroom_course = student.courses.reject{|c| !c.course_type.is_homeroom?}.first
+ homeroom_course = student.courses.active.reject{|c| !c.course_type.is_homeroom?}.first
if homeroom_course
# Found a "homeroom" course; build the attendance array
homeroom_course.course_terms.sort!{|a,b| a.term.end_date <=> b.term.end_date}.each do |course_term|
@@ -421,6 +421,7 @@ def self.print_attendance(position, student)
evaluations = course_term.assignment_evaluations.reject{|i| i.student != student}
# Collect the attendance "assignment" data
+ debugger
evaluations.each do |eval|
data_hash[eval.assignment.name] = attendance.new(eval.assignment.name) if data_hash[eval.assignment.name].blank?
data_hash[eval.assignment.name][course_term.term.name] = eval.points_earned.to_f

0 comments on commit 6926bd9

Please sign in to comment.