Skip to content

Commit

Permalink
Corrected an issue where courses were not being shown on the report c…
Browse files Browse the repository at this point in the history
…ard unless

they had at least one supporting skill.
  • Loading branch information
rnhurt committed Sep 15, 2009
1 parent 17c1401 commit b2aeebf
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions lib/reports/report_card.rb
Expand Up @@ -92,19 +92,18 @@ def self.draw(params)
@initial_cursor = cursor # Use this to reset the position on each new page

# Function to generate the table containing the course grade information
def make_table(headers, data)
if data.blank?
text "No assignments found for course '#{@course.name}'."
else
table(
data,
:headers => headers,
:header_color => "C0C0C0",
:font_size => 7,
:border_style => :grid,
:border_width => 0.5,
:width => bounds.width)
end
def print_data(headers, data)
data = [["No supporting skills"] + [""] * (headers.size-1)] if data.blank?

# Draw the table containing the grade totals and the skill scores
table(
data,
:headers => headers,
:header_color => "C0C0C0",
:font_size => 7,
:border_style => :grid,
:border_width => 0.5,
:width => bounds.width)
end

# Function to generate a new page for the report.
Expand Down Expand Up @@ -173,7 +172,6 @@ def new_page
# Set up the text options
font "Helvetica", :size => 7, :align => :left


# Print the grades for each course
@courses.each_with_index do |@course, index|

Expand All @@ -184,15 +182,15 @@ def new_page
data_hash = {}
headers = ["#{@course.name}\n #{@course.teacher.full_name}"]

test_data = []
@course.course_terms.each{|ct| test_data << "ct#{ct.id}"}
skill_score = Struct.new(:supporting_skill, *test_data)
temp_data = []
@course.course_terms.each{|ct| temp_data << "ct#{ct.id}"}
skill_score = Struct.new(:supporting_skill, *temp_data)

# Gather the grades for each term in this course
@course.course_terms.sort!{|a,b| a.term.end_date <=> b.term.end_date}.each_with_index do |course_term, ctindex|
grade = course_term.calculate_grade(student.id)
header = "#{course_term.term.name}\n #{grade[:letter]}"
header += " (#{grade[:score].round}%)" if grade[:score] >= 0
header += " (#{grade[:score].round}%)" if grade[:score] >= 0 && !course_term.grading_scale.simple_view
headers << header

# Get a list of all supporting skills for all terms for this course
Expand All @@ -203,6 +201,7 @@ def new_page

# Get the score for the current course_term_skill
temp[ctindex+1] = ctskill.score(student)

# Store it back into the hash for data
data_hash[ctskill.supporting_skill] = temp
end
Expand All @@ -217,13 +216,13 @@ def new_page
# Print the course data alternately on the left & right side of the page
if index.even? then
bounding_box([0, @left_cursor], :width => (bounds.width / 2) - GUTTER_SIZE) do
make_table(headers,data)
print_data(headers,data)
end
move_down(GUTTER_SIZE)
@left_cursor = cursor
else
bounding_box([bounds.left + bounds.width / 2, @right_cursor], :width => (bounds.width / 2) - GUTTER_SIZE) do
make_table(headers,data)
print_data(headers,data)
end
move_down(GUTTER_SIZE)
@right_cursor = cursor
Expand Down Expand Up @@ -299,6 +298,7 @@ def self.print_keys(scales)
def self.print_skills
# Subheadings
bounding_box([250,bounds.height], :width => 250, :height => bounds.height) do
# FIXME: hardcoded data!
data = [
["(+)","Exceptional performance"],
["(b)","Satisfactory performance"],
Expand Down

0 comments on commit b2aeebf

Please sign in to comment.