Refactor the query to get counts of graded, cancelled and in_progress exams to use ActiveRecord instead of raw sql