@ -4,11 +4,14 @@ require 'csv'
module Dese
class ThreeBOne
include Dese :: Scraper
include Dese :: Enrollments
attr_reader :filepaths
def initialize ( filepaths : [ Rails . root . join ( 'data' , 'admin_data' , 'dese' , '3B_1_masscore.csv' ) ,
Rails . root . join ( 'data' , 'admin_data' , 'dese' , '3B_1_advcoursecomprate.csv' ) ,
Rails . root . join ( 'data' , 'admin_data' , 'dese' , '3B_1_ap.csv' ) ] )
Rails . root . join ( 'data' , 'admin_data' , 'dese' , '3B_1_ap.csv' ) ,
Rails . root . join ( 'data' , 'admin_data' , 'dese' , '3B_1_student_courses_ratio.csv' ) ] )
@filepaths = filepaths
end
@ -34,6 +37,11 @@ module Dese
write_headers ( filepath : , headers : )
run_a_curv_i3 ( filepath : )
filepath = filepaths [ 3 ]
headers = [ 'Raw likert calculation' , 'Likert Score' , 'Admin Data Item' , 'Academic Year' , 'School Name' , 'DESE ID' ,
'Total # of Classes' , 'Average Class Size' , 'Number of Students' , 'Female %' , 'Male %' , 'English Language Learner %' , 'Students with Disabilities %' , 'Low Income %' , 'Number of Students' ]
write_headers ( filepath : , headers : )
run_a_curv_i5 ( filepath : )
browser . close
end
@ -90,5 +98,33 @@ module Dese
Prerequisites . new ( filepath , url , selectors , submit_id , admin_data_item_id , calculation )
end
end
def run_a_curv_i5 ( filepath : )
run do | academic_year |
url = 'https://profiles.doe.mass.edu/statereport/classsizebygenderpopulation.aspx'
range = academic_year . range
selectors = { 'ctl00_ContentPlaceHolder1_ddReportType' = > 'School' ,
'ctl00_ContentPlaceHolder1_ddYear' = > range }
submit_id = 'btnViewReport'
calculation = lambda { | headers , items |
row = headers . keys . zip ( items ) . to_h
dese_id = row [ 'School Code' ] . to_i
is_hs = ( row [ 'School Name' ] in / High School /i )
school = School . find_by ( dese_id : )
is_hs = school . is_hs if school . present?
next 'NA' unless is_hs
num_of_classes = row [ 'Total # of Classes' ] . delete ( ',' ) . to_f
num_of_students = student_count ( filepath : Rails . root . join ( 'data' , 'admin_data' , 'dese' , 'enrollments.csv' ) ,
dese_id : , year : academic_year . range ) || 0
items << num_of_students
actual = num_of_students / num_of_classes
benchmark = 5
( ( benchmark - actual ) + benchmark ) * 4 / benchmark if num_of_classes . present? && num_of_students . present?
}
admin_data_item_id = 'a-curv-i5'
Prerequisites . new ( filepath , url , selectors , submit_id , admin_data_item_id , calculation )
end
end
end
end