mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-08 23:18:18 -07:00
fixing bugs
This commit is contained in:
parent
10945d6c71
commit
76bdb86211
9 changed files with 29 additions and 24 deletions
|
|
@ -18,7 +18,7 @@ class CategoriesController < ApplicationController
|
|||
@year = (params[:year] || @years.first).to_i
|
||||
@years.delete(@year)
|
||||
@school_category = school_categories.in(@year).first
|
||||
@child_school_categories = SchoolCategory.for_parent_category(@school, @category).valid
|
||||
@child_school_categories = SchoolCategory.for_parent_category(@school, @category).in(@year).valid
|
||||
@questions = @category.questions
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ class Recipient < ApplicationRecord
|
|||
validates :name, presence: true
|
||||
|
||||
scope :for_school, -> (school) { where(school: school) }
|
||||
scope :created_in, -> (year) { where('extract(year from recipients.created_at) = ?', year) }
|
||||
|
||||
before_destroy :sync_lists
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class SchoolCategory < ApplicationRecord
|
|||
response_count: attempt_data.response_count || 0,
|
||||
answer_index_total: attempt_data.answer_index_total || 0,
|
||||
zscore: attempt_data.answer_index_total.nil? ?
|
||||
zscore :
|
||||
(attempt_data.response_count > MIN_RESPONSE_COUNT ? zscore : nil) :
|
||||
(attempt_data.response_count > MIN_RESPONSE_COUNT ?
|
||||
(attempt_data.answer_index_total.to_f / attempt_data.response_count.to_f - 3.to_f) :
|
||||
nil)
|
||||
|
|
@ -43,7 +43,7 @@ class SchoolCategory < ApplicationRecord
|
|||
_aggregated_responses = aggregated_responses
|
||||
|
||||
child_school_categories = category.child_categories.collect do |cc|
|
||||
SchoolCategory.for(school, cc).valid
|
||||
SchoolCategory.for(school, cc).in(year).valid
|
||||
end.flatten.compact
|
||||
|
||||
average_zscore = nil
|
||||
|
|
@ -70,6 +70,7 @@ class SchoolCategory < ApplicationRecord
|
|||
def sync_aggregated_responses
|
||||
return if ENV['BULK_PROCESS']
|
||||
update_attributes(chained_aggregated_responses)
|
||||
return if response_count == 0
|
||||
if category.parent_category.present?
|
||||
parent_school_category = SchoolCategory.for(school, category.parent_category).in(year).first
|
||||
if parent_school_category.nil?
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
%p
|
||||
= school_category.category.path.map { |c| link_to(c.name, [school_category.school, c]) }.join(' > ').html_safe
|
||||
= school_category.category.path.map { |c| link_to(c.name, school_category_path(school_category.school, c, year: school_category.year)) }.join(' > ').html_safe
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
.row
|
||||
.col
|
||||
=# link_to(image_tag(@district.logo), @district) if @district.present?
|
||||
%h2= link_to @school.name, @school
|
||||
%h2= link_to @school.name, school_path(@school, year: @year)
|
||||
= simple_format(@school.description)
|
||||
- if @year.present?
|
||||
%p
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
.col-12.col-sm-6.py-3
|
||||
.school_category.short.p-2
|
||||
%h4.title.text-center.pt-3
|
||||
= link_to(school_category.category.name, [school_category.school, school_category.category])
|
||||
= link_to(school_category.category.name, school_category_path(school_category.school, school_category.category, year: school_category.year))
|
||||
|
||||
.indicator-container.short
|
||||
= render 'school_categories/indicator', info: school_category
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
%h3 Insufficient Responses
|
||||
%p No data is displayed for this school because of insufficient responses.
|
||||
- else
|
||||
= render @school_categories
|
||||
.row
|
||||
= render @school_categories
|
||||
|
||||
= render "shared/performance_spectrum"
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,12 +1,10 @@
|
|||
# PSQL: /Applications/Postgres.app/Contents/Versions/9.6/bin/psql -h localhost
|
||||
|
||||
# LOAD DATA
|
||||
# RAILS_ENV=development rails db:environment:set db:drop db:create db:migrate
|
||||
# /Applications/Postgres.app/Contents/Versions/9.6/bin/pg_restore --verbose --clean --no-acl --no-owner -h localhost -d mciea_development latest.dump
|
||||
# rake db:migrate
|
||||
# run console: SchoolCategory.update_all(year: '2017')
|
||||
# rake data:load_questions_csv
|
||||
# rake data:load_responses
|
||||
# RAILS_ENV=development rails db:environment:set db:drop db:create db:migrate; /Applications/Postgres.app/Contents/Versions/9.6/bin/pg_restore --verbose --clean --no-acl --no-owner -h localhost -d mciea_development latest.dump; rake db:migrate;
|
||||
# rails c -> SchoolCategory.update_all(year: '2017')
|
||||
# rake data:load_questions_csv; rake data:load_responses
|
||||
|
||||
# sudo heroku run:detached rake data:load_responses -a mciea-beta --size performance-l
|
||||
|
||||
# Add:
|
||||
|
|
@ -20,6 +18,8 @@
|
|||
require 'csv'
|
||||
|
||||
namespace :data do
|
||||
@year = 2018
|
||||
|
||||
desc "Load in all data"
|
||||
task load: :environment do
|
||||
# return if School.count > 0
|
||||
|
|
@ -192,7 +192,6 @@ namespace :data do
|
|||
unknown_schools = {}
|
||||
missing_questions = {}
|
||||
bad_answers = {}
|
||||
year = '2018'
|
||||
|
||||
timeToRun = 120 * 60
|
||||
startIndex = 0
|
||||
|
|
@ -203,7 +202,7 @@ namespace :data do
|
|||
['student_responses'].each do |file|
|
||||
recipients = file.split('_')[0]
|
||||
target_group = Question.target_groups["for_#{recipients}s"]
|
||||
csv_string = File.read(File.expand_path("../../../data/#{file}_#{year}.csv", __FILE__))
|
||||
csv_string = File.read(File.expand_path("../../../data/#{file}_#{@year}.csv", __FILE__))
|
||||
csv = CSV.parse(csv_string, :headers => true)
|
||||
puts("LOADING CSV: #{csv.length} ROWS")
|
||||
|
||||
|
|
@ -244,7 +243,7 @@ namespace :data do
|
|||
next
|
||||
end
|
||||
|
||||
respondent_id = row['StudentID']
|
||||
respondent_id = row['X']
|
||||
recipient_id = respondent_map["#{school.id}-#{respondent_id}"]
|
||||
if recipient_id.present?
|
||||
recipient = school.recipients.where(id: recipient_id).first
|
||||
|
|
@ -271,7 +270,7 @@ namespace :data do
|
|||
row.each do |key, value|
|
||||
t1 = Time.new
|
||||
next if value.nil? or key.nil? or value.to_s == "-99"
|
||||
key = key.gsub(/[[:space:]]/, ' ').strip.gsub(/\s+/, ' ')
|
||||
key = key.gsub(/[[:space:]]/, ' ').gsub(/\./, '-').strip.gsub(/\s+/, ' ')
|
||||
value = value.gsub(/[[:space:]]/, ' ').strip.downcase
|
||||
|
||||
begin
|
||||
|
|
@ -307,7 +306,9 @@ namespace :data do
|
|||
answer_index = value.to_i
|
||||
end
|
||||
|
||||
responded_at = Date.strptime(row['End Date'], '%m/%d/%Y %H:%M')
|
||||
next if answer_index == 0
|
||||
|
||||
responded_at = Date.today#strptime(row['End Date'], '%m/%d/%Y %H:%M')
|
||||
begin
|
||||
recipient.attempts.create(question: question, answer_index: answer_index, responded_at: responded_at)
|
||||
rescue Exception => e
|
||||
|
|
@ -321,7 +322,7 @@ namespace :data do
|
|||
|
||||
sync_school_category_aggregates
|
||||
|
||||
Recipient.all.each { |r| r.update_counts }
|
||||
Recipient.created_in(@year).each { |r| r.update_counts }
|
||||
end
|
||||
|
||||
desc 'Load in nonlikert values for each school'
|
||||
|
|
@ -426,14 +427,15 @@ namespace :data do
|
|||
end
|
||||
|
||||
def sync_school_category_aggregates
|
||||
year = 2018
|
||||
School.all.each do |school|
|
||||
# School.all.each do |school|
|
||||
District.where(name: 'Winchester').first.schools.where(name: "Ambrose Elementary School").each do |school|
|
||||
Category.all.each do |category|
|
||||
school_category = SchoolCategory.for(school, category).in(year).first
|
||||
school_category = SchoolCategory.for(school, category).in(@year).first
|
||||
if school_category.nil?
|
||||
school_category = school.school_categories.create(category: category, year: year)
|
||||
school_category = school.school_categories.create(category: category, year: @year)
|
||||
end
|
||||
school_category.sync_aggregated_responses
|
||||
puts("SYNC: #{school.name}-#{category.name}-#{@year}: #{school_category.answer_index_total}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue