source for data:

pull/1/head
Jared Cosulich 9 years ago
parent d9335206d8
commit df594b9666

@ -2,39 +2,45 @@
// They will automatically be included in application.css. // They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/ // You can use Sass (SCSS) here: http://sass-lang.com/
.answers { .question {
width: 100%; .question-text {
border-bottom: 1px solid #ccc; height: 3em;
}
.answer { .answers {
border-top: 1px solid #ccc; width: 100%;
border-bottom: 1px solid #ccc;
.text { .answer {
width: 50%; border-top: 1px solid #ccc;
}
td { .text {
line-height: 2em; width: 50%;
div {
margin: 0.25em 0;
height: 1.5em;
} }
}
.bar0 { td {
background-color: red; line-height: 2em;
} div {
.bar1 { margin: 0.25em 0;
background-color: orange; height: 1.5em;
} }
.bar2 { }
background-color: lightgreen;
} .bar0 {
.bar3 { background-color: red;
background-color: green; }
} .bar1 {
.bar4 { background-color: orange;
background-color: gray; }
.bar2 {
background-color: lightgreen;
}
.bar3 {
background-color: green;
}
.bar4 {
background-color: gray;
}
} }
} }
} }

@ -22,6 +22,12 @@ class Question < ApplicationRecord
scope :for_category, -> (category) { where(category: category) } scope :for_category, -> (category) { where(category: category) }
enum target_group: [:unknown, :for_students, :for_teachers, :for_parents]
def source
target_group.gsub('for_', '')
end
def options def options
[option1, option2, option3, option4, option5] [option1, option2, option3, option4, option5]
end end

@ -4,7 +4,6 @@
.col-6.py-3 .col-6.py-3
.question.p-2{id: "question-#{question.id}"} .question.p-2{id: "question-#{question.id}"}
%p.question-text.pt-3.px-2 %p.question-text.pt-3.px-2
%b Question:
= question.text = question.text
.pb-3.px-2 .pb-3.px-2
@ -20,7 +19,7 @@
= truncate(aggregated_responses.most_popular_answer, length: 27) = truncate(aggregated_responses.most_popular_answer, length: 27)
%p %p
%b Source: %b Source:
=# question.source(@school) = question.source.titleize
.clearfix .clearfix

@ -0,0 +1,5 @@
class AddTargetGroupToQuestion < ActiveRecord::Migration[5.0]
def change
add_column :questions, :target_group, :integer, default: 0
end
end

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170312202259) do ActiveRecord::Schema.define(version: 20170316154053) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -65,8 +65,9 @@ ActiveRecord::Schema.define(version: 20170312202259) do
t.string "option4" t.string "option4"
t.string "option5" t.string "option5"
t.integer "category_id" t.integer "category_id"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.integer "target_group", default: 0
end end
create_table "recipient_lists", force: :cascade do |t| create_table "recipient_lists", force: :cascade do |t|

@ -143,7 +143,7 @@ namespace :data do
bad_answers = {} bad_answers = {}
year = '2016' year = '2016'
['student_responses', 'teacher_responses'].each do |file| ['student_responses', 'teacher_responses'].each do |file|
# source = Measurement.sources[file.split('_')[0]] target_group = Question.target_groups["for_#{file.split('_')[0]}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) csv = CSV.parse(csv_string, :headers => true)
csv.each do |row| csv.each do |row|
@ -179,6 +179,8 @@ namespace :data do
puts "Unable to find question: #{key}" puts "Unable to find question: #{key}"
missing_questions[key] = true missing_questions[key] = true
next next
else
question.update_attributes(target_group: target_group) if question.unknown?
end end
answer_index = question.option_index(value) answer_index = question.option_index(value)

Loading…
Cancel
Save