require 'rubygems' require 'lib/report' require 'models' # == Example Reports # # Overall number of ratings for each step on the scale. # Report.create "Overall Ratings" do # scale = { # -2 => "Strongly Disagree", # -1 => "Disagree", # 0 => "Neither Agree nor Disagree", # 1 => "Agree", # 2 => "Strongly Agree" # } # ratings = {} # scale.each do |k, v| # ratings[v] = Rating.find(:all, :conditions => "score = #{k}").size # end # ratings.sort # end # # Report.create "All Ratings" do # ratings = Rating.find(:all, :include => :standard, # :order => "standards.identifier", # :conditions => "ratings.standard_id IS NOT NULL") # data = ratings.map { |r| [r.standard.identifier, r.score, r.comment] } # [["Identifier", "Score", "Comments"]] + data # end # # # Participation Overviews # # Report.create "District Participation" do # data = District.find(:all, :order => "number").map do |district| # profiles = district.profiles # ratings = profiles.collect { |p| p.ratings.size } # [district.county, profiles.size, ratings.sum] # end # [["District", "Respondants", "Ratings"]] + data # end # # Report.create "Subject Area Participation" do # data = Subject.find(:all, :order => "area").map do |subject| # profiles = subject.profiles # ratings = profiles.collect { |p| p.ratings.size } # [subject.area, profiles.size, ratings.sum] # end # [["Subject Area", "Respondants", "Ratings"]] + data # end # # Report.create "Grade Level Participation" do # data = Grade.find(:all, :order => "position").map do |grade| # profiles = grade.profiles # ratings = profiles.collect { |p| p.ratings.size } # [grade.level, profiles.size, ratings.sum] # end # [["Grade Level", "Respondants", "Ratings"]] + data # end