Create ui for data filters. Add listeners to direct to the correct url. Update ui based on the list of selected params
parent
4f0b92fa79
commit
765ad6a624
@ -0,0 +1 @@
|
||||
{}
|
||||
@ -0,0 +1,6 @@
|
||||
{
|
||||
"parserOptions": {
|
||||
"sourceType": "module",
|
||||
"ecmaVersion": 2020
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
{
|
||||
"parserOptions": {
|
||||
"sourceType": "module",
|
||||
"ecmaVersion": 2020
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
module AnalysisGraph
|
||||
class StudentsAndTeachers
|
||||
def to_s
|
||||
'Students & Teachers'
|
||||
end
|
||||
|
||||
def value
|
||||
'students-and-teachers'
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,11 @@
|
||||
module AnalysisGraph
|
||||
class StudentsByGroup
|
||||
def to_s
|
||||
'Students by Group'
|
||||
end
|
||||
|
||||
def value
|
||||
'students-by-group'
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,4 @@
|
||||
class Race < ApplicationRecord
|
||||
include FriendlyId
|
||||
friendly_id :designation, use: [:slugged]
|
||||
end
|
||||
@ -0,0 +1,31 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'csv'
|
||||
|
||||
class DemographicLoader
|
||||
def self.load_data(filepath:)
|
||||
CSV.parse(File.read(filepath), headers: true) do |row|
|
||||
qualtrics_code = row['Race Qualtrics Code'].to_i
|
||||
designation = row['Race/Ethnicity']
|
||||
next unless qualtrics_code && designation
|
||||
|
||||
if qualtrics_code.between?(6, 7)
|
||||
UnknownRace.new(qualtrics_code:, designation:)
|
||||
else
|
||||
KnownRace.new(qualtrics_code:, designation:)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class KnownRace
|
||||
def initialize(qualtrics_code:, designation:)
|
||||
Race.find_or_create_by!(qualtrics_code:, designation:)
|
||||
end
|
||||
end
|
||||
|
||||
class UnknownRace
|
||||
def initialize(qualtrics_code:, designation:)
|
||||
Race.find_or_create_by!(qualtrics_code: 99, designation: 'Unknown')
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,28 @@
|
||||
<h3 class="sub-header-4 mt-5">Data Filters</h3>
|
||||
<div class="bg-gray p-3" data-controller="analyze">
|
||||
<% @graphs.each do |graph| %>
|
||||
<div>
|
||||
<input type="radio" id="<%= graph.value %>" name="graph"
|
||||
value="<%= base_url %>"
|
||||
data-action="click->analyze#refresh"
|
||||
<%= graph.value == @graph ? "checked" : "" %>>
|
||||
<label for="<%= graph.value %>"><%= graph.to_s %></label>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<p class="sub-header-5 mt-3 font-size-14"> Select a group </p>
|
||||
|
||||
<% @races.each do |race | %>
|
||||
<div class="d-flex <%= race.slug %>">
|
||||
<input
|
||||
id="<%= race.slug %>"
|
||||
class="m-3 race-checkbox"
|
||||
type="checkbox"
|
||||
name="race-checkbox"
|
||||
value="<%= base_url %>"
|
||||
data-action="click->analyze#refresh"
|
||||
<%= @selected_races.map(&:slug).include?(race.slug) ? "checked" : "" %>>
|
||||
<label for="<%= race.qualtrics_code %>"><%= race.designation %></label>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
@ -0,0 +1,14 @@
|
||||
<h3 class="sub-header-4">Focus Area</h3>
|
||||
<p>Select a category & subcategory to analyze measure-level results</p>
|
||||
<select id="select-category" class="mx-3 form-select" data-id="category-dropdown" data-action="analyze#refresh">
|
||||
<% categories.each do |category| %>
|
||||
<option value="<%= analyze_category_link(district: district, school: school, academic_year: academic_year, category: category) %>" <%= category.id == category.id ? "selected": "" %>><%= "#{category.category_id}: #{category.name}" %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
<select id="select-subcategory" class="mx-3 form-select mt-3" data-id="subcategory-dropdown" data-action="analyze#refresh">
|
||||
<% subcategories.each do |subcategory| %>
|
||||
<option value="<%= analyze_subcategory_link(district: district, school: school, academic_year: academic_year, category: category, subcategory: subcategory) %>" <%= subcategory.subcategory_id == subcategory.subcategory_id ? "selected": "" %>>
|
||||
<%= "#{subcategory.subcategory_id}: #{subcategory.name}" %>
|
||||
</option>
|
||||
<% end %>
|
||||
</select>
|
||||
@ -0,0 +1,32 @@
|
||||
<g id="graph-background">
|
||||
<rect x="0" y="0" width="100%" height="<%= analyze_zone_height * 2 %>%" fill="#edecf0" />
|
||||
<rect x="0" y="<%= analyze_zone_height * 2 %>%" width="100%" height="<%= analyze_zone_height * 3 %>%" fill="#fffaee" />
|
||||
<rect x="0" y="0" width="100%" height="<%= analyze_graph_height %>%" fill="none" stroke="grey" />
|
||||
<line x1="<%= column_end_x(1) %>%" y1="0" x2="<%= column_end_x(1) %>%" y2="85%" stroke="grey" stroke-width="1" stroke-dasharray="5,2" />
|
||||
<line x1="<%= column_end_x(2) %>%" y1="0" x2="<%= column_end_x(2) %>%" y2="85%" stroke="grey" stroke-width="1" stroke-dasharray="5,2" />
|
||||
<rect x="0" y="<%= benchmark_y %>%" width="100%" height="<%= benchmark_height %>%" fill="black" />
|
||||
|
||||
<g id="zone-dividers" stroke-width="1">
|
||||
<line x1="0" y1="17%" x2="100%" y2="17%" stroke="white" />
|
||||
<line x1="0" y1="51%" x2="100%" y2="51%" stroke="#edecf0" />
|
||||
<line x1="0" y1="68%" x2="100%" y2="68%" stroke="#edecf0" />
|
||||
</g>
|
||||
|
||||
<g id="zone-labels">
|
||||
<text class="zone-header" x="<%= zone_label_x %>%" y="<%= zone_label_y(1) %>%" text-anchor="start" dominant-baseline="middle">
|
||||
Ideal
|
||||
</text>
|
||||
<text class="zone-header" x="<%= zone_label_x %>%" y="<%= zone_label_y(2) %>%" text-anchor="start" dominant-baseline="middle">
|
||||
Approval
|
||||
</text>
|
||||
<text class="zone-header" x="<%= zone_label_x %>%" y="<%= zone_label_y(3) %>%" text-anchor="start" dominant-baseline="middle">
|
||||
Growth
|
||||
</text>
|
||||
<text class="zone-header" x="<%= zone_label_x %>%" y="<%= zone_label_y(4) %>%" text-anchor="start" dominant-baseline="middle">
|
||||
Watch
|
||||
</text>
|
||||
<text class="zone-header" x="<%= zone_label_x %>%" y="<%= zone_label_y(5) %>%" text-anchor="start" dominant-baseline="middle">
|
||||
Warning
|
||||
</text>
|
||||
</g>
|
||||
</g>
|
||||
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 472 B |
@ -0,0 +1,21 @@
|
||||
<h3 class="sub-header-4 mt-5">School Years</h3>
|
||||
<% available_academic_years.each_with_index do | year, index | %>
|
||||
<div class="d-flex justify-content-start align-items-center mt-1" data-controller="analyze">
|
||||
<input type="checkbox"
|
||||
id="<%= year.range %>"
|
||||
name="year-checkbox"
|
||||
value="<%= analyze_subcategory_link(district: district, school: school, academic_year: academic_year, category: category, subcategory: subcategory) %>"
|
||||
<%= selected_academic_years.include?(year) ? "checked" : "" %>
|
||||
data-action="click->analyze#refresh"
|
||||
<%= empty_dataset?(measures: measures, school: school, academic_year: year) ? "disabled" : "" %>>
|
||||
|
||||
<label class="px-3" for="<%= year.range %>"><%= year.range %></label><br>
|
||||
<div class="bg-color-blue px-3" style="width:20px;height:20px;background-color:<%= colors[index] %>;"></div>
|
||||
<% if empty_dataset?(measures: measures, school: school, academic_year: year) %>
|
||||
<i class="fa-solid fa-circle-exclamation px-3"
|
||||
data-bs-toggle="popover" data-bs-placement="right"
|
||||
data-bs-content="Teacher and student survey response rates below <%= ResponseRateCalculator::TEACHER_RATE_THRESHOLD %>%">
|
||||
</i>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -0,0 +1,12 @@
|
||||
class CreateRaces < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :races do |t|
|
||||
t.string :designation
|
||||
t.integer :qualtrics_code
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :races, :designation, unique: true
|
||||
add_index :races, :qualtrics_code, unique: true
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,6 @@
|
||||
class AddSlugToRace < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
add_column :races, :slug, :string
|
||||
add_index :races, :slug, unique: true
|
||||
end
|
||||
end
|
||||
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,34 @@
|
||||
require 'rails_helper'
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
RSpec.describe AdminDataValue, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
let(:school) { create(:school) }
|
||||
let(:admin_data_item) { create(:admin_data_item) }
|
||||
let(:academic_year) { create(:academic_year) }
|
||||
context '#value' do
|
||||
context 'when the value is in the valid range of greater than zero to five' do
|
||||
it 'should return valid values' do
|
||||
value = AdminDataValue.create!(likert_score: 1, school:, admin_data_item:, academic_year:)
|
||||
expect(value.likert_score).to eq(1)
|
||||
value = AdminDataValue.create!(likert_score: 2, school:, admin_data_item:, academic_year:)
|
||||
expect(value.likert_score).to eq(2)
|
||||
value = AdminDataValue.create!(likert_score: 5, school:, admin_data_item:, academic_year:)
|
||||
expect(value.likert_score).to eq(5)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the value is zero or below or greater than 5' do
|
||||
it 'should not create the value' do
|
||||
expect do
|
||||
AdminDataValue.create!(likert_score: 0, school:, admin_data_item:,
|
||||
academic_year:)
|
||||
end.to raise_error
|
||||
expect do
|
||||
AdminDataValue.create!(likert_score: 5.00001, school:, admin_data_item:,
|
||||
academic_year:)
|
||||
end.to raise_error
|
||||
expect(AdminDataValue.count).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Race, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
@ -0,0 +1,22 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe DemographicLoader do
|
||||
let(:filepath) { 'spec/fixtures/sample_demographics.csv' }
|
||||
|
||||
before :each do
|
||||
DemographicLoader.load_data(filepath:)
|
||||
end
|
||||
|
||||
after :each do
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
|
||||
describe 'self.load_data' do
|
||||
it 'does not load qualtrics categories for `prefer not to disclose` or `prefer to self-describe`' do
|
||||
expect(Race.find_by_qualtrics_code(6)).to be nil
|
||||
end
|
||||
it 'loads all racial designations' do
|
||||
expect(Race.all.count).to eq 8
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in new issue