-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathepk_ela_gradepk_create_or_refresh_bq_datasource.sql
More file actions
174 lines (127 loc) · 4.11 KB
/
epk_ela_gradepk_create_or_refresh_bq_datasource.sql
File metadata and controls
174 lines (127 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
-----------------------------------------------------------------------------
--run this combined script to refresh the ELA Grade PK BigQuery Datasource---
-----------------------------------------------------------------------------
--[step 01.1] import data from classroom trackers
--import ela: heggerty assessment 1
SELECT *
FROM `harlemlinksy2122.trackers.ela_heggerty_gradepk_assessment1`;
--import ela: heggerty assessment 2
SELECT *
FROM `harlemlinksy2122.trackers.ela_heggerty_gradepk_assessment2`;
--add a data pull for the next ela: heggerty assessment below
--[step 01.2] import data from the ela level 3 question bank
SELECT *
FROM `harlemlinksy2122.questions.ela` ;
--[step 01.3] import data from the students (subgroups and demographics) table
SELECT *
FROM `harlemlinksy2122.demographics.students` ;
--[step 01.4] unpivot ela: heggerty data (all assessments)----
--unpivot ela: heggerty grade 1 assessment #1
CREATE OR REPLACE TABLE
`harlemlinksy2122.unpivots.ela_heggerty_gradepk_assessment1` AS
SELECT
osis,
question_id,
points_earned
FROM
`harlemlinksy2122.trackers.ela_heggerty_gradepk_assessment1` UNPIVOT(points_earned FOR question_id IN (
heggerty_gradepk_assessment1_01,
heggerty_gradepk_assessment1_02,
heggerty_gradepk_assessment1_03,
heggerty_gradepk_assessment1_04,
heggerty_gradepk_assessment1_05,
heggerty_gradepk_assessment1_06
)) ;
--unpivot ela: heggerty grade 1 assessment #2
CREATE OR REPLACE TABLE
`harlemlinksy2122.unpivots.ela_heggerty_gradepk_assessment2` AS
SELECT
osis,
question_id,
points_earned
FROM
`harlemlinksy2122.trackers.ela_heggerty_gradepk_assessment2` UNPIVOT(points_earned FOR question_id IN (
heggerty_gradepk_assessment2_01,
heggerty_gradepk_assessment2_02,
heggerty_gradepk_assessment2_03,
heggerty_gradepk_assessment2_04,
heggerty_gradepk_assessment2_05,
heggerty_gradepk_assessment2_06
)) ;
--add the next ela: heggerty assessment below
--[step 01.5] create unions table for all grade 1 ela: heggerty assessments----
CREATE OR REPLACE TABLE
`harlemlinksy2122.unions.ela_heggerty_gradepk` AS
--pull unpivoted data from ela: heggerty grade 1 assessment 1
SELECT
osis,
question_id,
points_earned,
FROM
`harlemlinksy2122.unpivots.ela_heggerty_gradepk_assessment1`
--pull unpivoted data from ela: heggerty grade 1 assessment 2
UNION ALL
SELECT
osis,
question_id,
points_earned,
FROM
`harlemlinksy2122.unpivots.ela_heggerty_gradepk_assessment2`
--insert UNION ALL code block here for the next assessment
;
--[step 01.6] join questions table to unions table to create results table
----create a results table for ela: heggerty grade 1----
CREATE OR REPLACE TABLE
--the results is used to calculate benchmarks grouped by students.osis and questions.unit
`harlemlinksy2122.results.ela_heggerty_gradepk` AS
SELECT
unions.osis,
unions.question_id,
--pulls in columns for questions.points_available and questions.unit
grade_level,
unit,
ccls_standard,
standard_description,
question_text,
points_earned,
points_available
FROM
`harlemlinksy2122.unions.ela_heggerty_gradepk` unions
LEFT JOIN
`harlemlinksy2122.questions.ela` questions
ON
unions.question_id = questions.question_id
WHERE
unions.osis IS NOT NULL ;
--[step 01.7] create a datasource table for ela: heggerty grade pk----
CREATE OR REPLACE TABLE
`harlemlinksy2122.datasources.ela_heggerty_gradepk` AS
SELECT
--start by pulling the osis on the combined results table
results.osis,
--pull these columns from the .demographics.students table
student,
sy_21_22_class,
sped,
enl,
hl_upk,
holdovers,
new_students,
ais,
--also pull these test-related columns from the results table
question_id,
ccls_standard,
standard_description,
question_text,
results.unit,
points_earned,
points_available
-- ela_pct_points,
-- ela_benchmark
FROM
`harlemlinksy2122.results.ela_heggerty_gradepk` results
LEFT JOIN
`harlemlinksy2122.demographics.students` students
ON results.osis = students.osis
WHERE results.osis IS NOT NULL ;
---END----------------------------------------------------------------------------