working on administrative data

pull/1/head
Jared Cosulich 8 years ago
parent 24d442497a
commit 55263dd058

BIN
.DS_Store vendored

Binary file not shown.

1
.gitignore vendored

@ -20,3 +20,4 @@
# Ignore Byebug command history file.
.byebug_history
config/local_env.yml
.DS_Store

@ -35,6 +35,15 @@ class SchoolCategory < ApplicationRecord
SchoolCategory.for(school, cc)
end.flatten
new_zscore = zscore
if new_zscore.nil?
zscore_categories = child_school_categories.select { |csc| csc.zscore.present? }
if zscore_categories.length > 0
total_zscore = zscore_categories.inject(0) { |total, zc| total + zc.zscore }
new_zscore = total_zscore / zscore_categories.length
end
end
return {
attempt_count:
_aggregated_responses[:attempt_count] +
@ -44,7 +53,8 @@ class SchoolCategory < ApplicationRecord
child_school_categories.inject(0) { |total, csc| total + csc.response_count },
answer_index_total:
_aggregated_responses[:answer_index_total] +
child_school_categories.inject(0) { |total, csc| total + csc.answer_index_total }
child_school_categories.inject(0) { |total, csc| total + csc.answer_index_total },
zscore: new_zscore
}
end

@ -13,14 +13,23 @@
%p= @category.description
%p
%b Total&nbsp;Responses:
= number_with_delimiter(@school_category.response_count)
- if @school_category.response_count > 0
%b Total&nbsp;Responses:
= number_with_delimiter(@school_category.response_count)
&nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;
%b Average&nbsp;Response:
= @school_category.answer_index_average.round(1)
(out of 5)
%b Average&nbsp;Response:
= @school_category.answer_index_average.round(1)
(out of 5)
- if @school_category.response_count > 0 && @school_category.zscore.present?
&nbsp; &nbsp; &nbsp;
- if @school_category.zscore.present?
%b Administrative&nbsp;Data
= @school_category.zscore.round(1) + 3
(out of 5)
.indicator-container.py-3
= render 'school_categories/indicator', info: @school_category

@ -1,5 +1,11 @@
- num_likerts = 5
- likert = info.answer_index_average
- zscore = info.zscore.present? ? info.zscore + 3 : nil
- if zscore.present?
- likert = info.answer_index_average.nan? ? zscore : (info.answer_index_average + zscore) / 2
- likert = likert.round(1)
- average_offset = (likert/num_likerts) * 100
- approval_zone = [[76, 90], [77, 91], [71, 85], [73, 86], [73, 86], []][info.category.root_index]
@ -32,7 +38,7 @@
This School
- else
.average{style: "left: #{average_offset - 5}%", title: this_school_zone}
%span This School
%span= "This School #{likert}"
- if local_assigns[:caption]
.explanation

@ -0,0 +1 @@
NonLikert Title,District,School,Value,Z-Score Percentage of Teachers Working in Area of Licensure,Winchester,Vinson-Owen Elementary School,100%,2 Percentage of Teachers Working in Area of Licensure,Winchester,Lynch Elementary School,100%,2 Percentage of Teachers Working in Area of Licensure,Winchester,McCall Middle School,100%,2
1 NonLikert Title District School Value Z-Score Percentage of Teachers Working in Area of Licensure Winchester Vinson-Owen Elementary School 100% 2 Percentage of Teachers Working in Area of Licensure Winchester Lynch Elementary School 100% 2 Percentage of Teachers Working in Area of Licensure Winchester McCall Middle School 100% 2

@ -0,0 +1,5 @@
class AddZScoreToSchoolCategories < ActiveRecord::Migration[5.0]
def change
add_column :school_categories, :zscore, :float
end
end

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180119145356) do
ActiveRecord::Schema.define(version: 20180120150542) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -147,6 +147,7 @@ ActiveRecord::Schema.define(version: 20180119145356) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.float "nonlikert"
t.float "zscore"
t.index ["category_id"], name: "index_school_categories_on_category_id", using: :btree
t.index ["school_id"], name: "index_school_categories_on_school_id", using: :btree
end

@ -241,16 +241,48 @@ namespace :data do
end
end
ENV.delete('BULK_PROCESS')
sync_school_category_aggregates
Recipient.all.each { |r| r.update_counts }
end
desc 'Load in nonlikert values for each school'
task load_nonlikert_values: :environment do
ENV['BULK_PROCESS'] = 'true'
csv_string = File.read(File.expand_path("../../../data/samplenonlikert.csv", __FILE__))
csv = CSV.parse(csv_string, :headers => true)
puts("LOADING NONLIKERT CSV: #{csv.length} ROWS")
t = Time.new
school_category_id = -1
csv.each_with_index do |row, index|
nonlikert_category = Category.find_by_name(row["NonLikert Title"])
district = District.find_by_name(row["District"])
school = district.schools.find_by_name(row["School"])
school_category = school.school_categories.find_or_create_by(category: nonlikert_category)
school_category.update(
nonlikert: row["Value"],
zscore: row["Z-Score"]
)
school_category_id = school_category.id
end
ENV.delete('BULK_PROCESS')
sync_school_category_aggregates
end
def sync_school_category_aggregates
School.all.each do |school|
Category.all.each do |category|
school_category = SchoolCategory.for(school, category).first
if school_category.nil?
school_category = SchoolCategory.create(school: school, category: category)
school_category = school.school_categories.create(category: category)
end
school_category.sync_aggregated_responses
end
end
Recipient.all.each { |r| r.update_counts }
end
end

Loading…
Cancel
Save