Skip to content

Instantly share code, notes, and snippets.

@superacidjax
Created August 16, 2012 17:05
Show Gist options
  • Save superacidjax/3371713 to your computer and use it in GitHub Desktop.
Save superacidjax/3371713 to your computer and use it in GitHub Desktop.
user_interviews.each do |user_interview|
sheet.row(current_row).default_format = bold_format
sheet.row(current_row).concat %w{Candidate Assessment\ Criteria Weight\ %}
users.each{|user| sheet.row(current_row).push user.name}
sheet.row(current_row).push "Total Score", "Average Score"
current_row += 1
first_criteria = true
interview.interview_criteria.order(:text).each do |interview_criterion|
row = sheet.row(current_row)
if first_criteria
first_criteria = false
row.push(user_interview.user.name)
else
row.push ""
end
row.push interview_criterion.text
row.push "#{interview_criterion.weight}%"
users.each do |user|
this_rating = all_criterion_ratings[user_interview.id][user.id][interview_criterion.id]
row.push this_rating ? this_rating : "-"
end
# source = criterion_rating_nouser[user_interview.id][interview_criterion.id]
# sum = source.sum
# row.push sum
# row.push (sum.to_f / source.size)
# current_row += 1
end
3.times {|i| sheet.row(current_row).push ""}
users.each do |user|
sheet.row(current_row).push all_criterion_ratings[user_interview.id][user.id].map{|ic, value| value}.reject{|i| i.nil?}.sum
end
sheet.row(current_row).push criterion_rating_nouser[user_interview.id].map{|ic, value| value.sum}.sum
weighted_avg = 0.0
interview.interview_criteria.each do |interview_criterion|
# source = criterion_rating_nouser[user_interview.id][interview_criterion.id]
# avg = source.sum.to_f / source.size
# weight = interview_criterion.weight / 100.0
# weighted_avg += (weight * avg)
end
sheet.row(current_row).push weighted_avg
current_row += 2
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment