Permalink
Browse files

Evaluation Optimization

 * Cleaned up some problem code in the Skills evaluations
  • Loading branch information...
1 parent 5be2513 commit 2fb90459492570f4ce696485658368664fd614f1 @rnhurt committed Jan 15, 2010
@@ -23,7 +23,8 @@ def show
when "skills"
@ctskills = @course_term.course_term_skills.paginate(
:per_page => 5,
- :page => params[:page])
+ :page => params[:page],
+ :include => [:supporting_skill, :supporting_skill_evaluations])
render :partial => "skills"
@@ -30,15 +30,14 @@ def skills_header
# Build the body for the skills evaluation partial
def skills_body
- students = @course_term.students.sort_by {|a| a.last_name }
- options = SupportingSkillCode.all
- body = ''
+ options = SupportingSkillCode.all
+ body = ''
- if students.size == 0
+ if @course_term.students.size == 0
body << "<tr><td>No Students Found</td></tr>"
else
# Process each student
- students.each_with_index do |student, index|
+ @course_term.students.sort_by {|a| a.last_name }.each_with_index do |student, index|
# Set up the row for this student
body << "<tr class='calc #{cycle('odd','even')}' id='skill#{student.id}'>"
body << "<td width='100' id='#{student.id}'>#{student.full_name}</td>"
@@ -67,7 +66,7 @@ def skills_body
end
body << '</select></td>'
- a_counter += students.size
+ a_counter += @course_term.students.size
end
body << '</tr>'
@@ -9,7 +9,7 @@ class CourseTermSkill < ActiveRecord::Base
# Calculate a students current score for a particular course & term.
def score(student_id)
- temp = self.supporting_skill_evaluations.first(:conditions => { :student_id => student_id})
+ temp = self.supporting_skill_evaluations.detect{|e| e.student_id == student_id}
return temp.blank? ? "" : temp.score
end

0 comments on commit 2fb9045

Please sign in to comment.