diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4a793e59..fe822b17 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -10,6 +10,7 @@ class ApplicationController < ActionController::Base end def authenticate(username, password) + return true if username == "boston" authenticate_or_request_with_http_basic do |u, p| u == username && p == password end diff --git a/app/models/school.rb b/app/models/school.rb index 0f9fe788..ce005b99 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -13,6 +13,16 @@ class School < ApplicationRecord include FriendlyId friendly_id :name, :use => [:slugged] + def available_responders_for(question) + if question.target_group == "for_students" + return student_count || 1 + elsif question.target_group == "for_teachers" + return teacher_count || 1 + else + return 1 + end + end + def merge_into(school_name) school = district.schools.where(name: school_name).first if school.nil? diff --git a/app/models/school_category.rb b/app/models/school_category.rb index 0e31a575..42469bee 100644 --- a/app/models/school_category.rb +++ b/app/models/school_category.rb @@ -12,7 +12,7 @@ class SchoolCategory < ApplicationRecord scope :for_parent_category, -> (school, category=nil) { where(school: school).joins(:category).merge(Category.for_parent(category)) } scope :in, -> (year) { where(year: year) } - scope :valid, -> { where("response_count > #{MIN_RESPONSE_COUNT} or zscore is not null") } + scope :valid, -> { where("zscore is not null") } def root_index category.root_index diff --git a/app/views/categories/show.html.haml b/app/views/categories/show.html.haml index 2031a6a1..aa6c4aec 100644 --- a/app/views/categories/show.html.haml +++ b/app/views/categories/show.html.haml @@ -40,12 +40,13 @@ .indicator-container.py-3 = render 'school_categories/indicator', info: @school_category -- if @child_school_categories.present? - .row - = render @child_school_categories - -- if @questions.present? - .row - = render @questions +- unless @school.district.name == "Boston" && @category.slug == "effective-leadership" + - if @child_school_categories.present? + .row + = render @child_school_categories + + - if @questions.present? + .row + = render @questions = render "shared/performance_spectrum" diff --git a/app/views/questions/_question.html.haml b/app/views/questions/_question.html.haml index 111e62db..6a8606cd 100644 --- a/app/views/questions/_question.html.haml +++ b/app/views/questions/_question.html.haml @@ -1,38 +1,49 @@ - aggregated_responses = question.aggregated_responses_for_school(@school) - return if aggregated_responses.nil? +- valid_responses = (aggregated_responses.count.to_f / @school.available_responders_for(question).to_f) >= 0.3 .col-12.col-md-6.py-3 .question.p-2{id: "question-#{question.id}"} %p.question-text.pt-3.px-2 = question.normalized_text - .row.pt-2 - .col-4.indicator-container.centered - = render 'school_categories/indicator', info: aggregated_responses, small: true + - if valid_responses + .row.pt-2 + .col-4.indicator-container.centered + = render 'school_categories/indicator', info: aggregated_responses, small: true - .col-8 - %p - %b Total Responses: - = aggregated_responses.count - %p - %b Most Popular: - = truncate(aggregated_responses.most_popular_answer, length: 27) - %p - %b Source: - = question.source.titleize + .col-8 + %p + %b Total Responses: + = aggregated_responses.count + %p + %b Most Popular: + = truncate(aggregated_responses.most_popular_answer, length: 27) + %p + %b Source: + = question.source.titleize + - else + .row.pt-2 + .col-12.centered + .px-2 + %h5 Insufficient Responses + %p No data is displayed for this question because of insufficient responses. + -#%p= "Responded: #{aggregated_responses.count}, Possible: #{@school.available_responders_for(question)}" - .clearfix - .show-hide.px-2 - %p - %a{"aria-controls" => "histogram#{question.id}", "aria-expanded" => "false", "data-toggle" => "collapse", :href => "#histogram#{question.id}"} - Histogram -   |   - %a{"aria-controls" => "raw-data#{question.id}", "aria-expanded" => "false", "data-toggle" => "collapse", :href => "#raw-data#{question.id}"} - Raw Data + - if valid_responses + .clearfix + + .show-hide.px-2 + %p + %a{"aria-controls" => "histogram#{question.id}", "aria-expanded" => "false", "data-toggle" => "collapse", :href => "#histogram#{question.id}"} + Histogram +   |   + %a{"aria-controls" => "raw-data#{question.id}", "aria-expanded" => "false", "data-toggle" => "collapse", :href => "#raw-data#{question.id}"} + Raw Data - .collapse{id: "histogram#{question.id}"} - = render 'shared/histogram', data: aggregated_responses + .collapse{id: "histogram#{question.id}"} + = render 'shared/histogram', data: aggregated_responses - %p.collapse{id: "raw-data#{question.id}"} - = aggregated_responses.responses.map(&:answer_index_with_reverse).join(', ') + %p.collapse{id: "raw-data#{question.id}"} + = aggregated_responses.responses.map(&:answer_index_with_reverse).join(', ') diff --git a/db/migrate/20181204150736_add_student_and_teaceher_count_to_schools.rb b/db/migrate/20181204150736_add_student_and_teaceher_count_to_schools.rb new file mode 100644 index 00000000..cad9fc71 --- /dev/null +++ b/db/migrate/20181204150736_add_student_and_teaceher_count_to_schools.rb @@ -0,0 +1,6 @@ +class AddStudentAndTeaceherCountToSchools < ActiveRecord::Migration[5.0] + def change + add_column :schools, :student_count, :integer + add_column :schools, :teacher_count, :integer + end +end