chore: start adding browse view

This commit is contained in:
Nelson Jovel 2024-01-26 07:43:52 -08:00
parent a538eb72f2
commit f71f88a4ac
12 changed files with 296 additions and 87 deletions

View file

@ -1,8 +1,8 @@
module Dashboard
class Race < ApplicationRecord
include FriendlyId
has_many :dashboard_student_races
has_many :dashboard_students, through: :student_races
has_and_belongs_to_many :students, join_table: :dashboard_student_races, class_name: "Student",
foreign_key: :dashboard_student_id, association_foreign_key: :dashboard_student_id
friendly_id :designation, use: [:slugged]

View file

@ -1,8 +1,8 @@
module Dashboard
class Student < ApplicationRecord
# has_many :dashboard_survey_item_responses
has_many :dashboard_student_races
has_and_belongs_to_many :races, join_table: :student_races
has_and_belongs_to_many :races, join_table: :dashboard_student_races, class_name: "Race",
foreign_key: :dashboard_race_id, association_foreign_key: :dashboard_race_id
encrypts :lasid, deterministic: true
end

View file

@ -54,7 +54,7 @@ module Dashboard
def self.grouped_responses(school:, academic_year:)
@grouped_responses ||= Hash.new do |memo, (school, academic_year)|
memo[[school, academic_year]] =
SurveyItemResponse.where(school:, academic_year:).group(:survey_item_id).average(:likert_score)
SurveyItemResponse.where(school:, academic_year:).group(:dashboard_survey_item_id).average(:likert_score)
end
@grouped_responses[[school, academic_year]]
end