Skip to content

Commit

Permalink
temp: add example model with average per month
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Dec 6, 2024
1 parent db64907 commit c2cea43
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions models/grading/avg_aproving_students_per_month.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{{
config(
materialized="materialized_view",
schema=env_var("ASPECTS_XAPI_DATABASE", "xapi"),
engine=get_engine("ReplacingMergeTree()"),
primary_key="(year, month)",
order_by="(year, month)",
partition_by="",
)
}}


with
grades_average as (
select
course_key,
monthName(emission_time) as month_name,
toYear(emission_time) as year,
case
when verb_id = 'http://adlnet.gov/expapi/verbs/passed' then 1 else 0
end as approving,
count(1) as total
from xapi.grading_events
where
verb_id in (
'http://adlnet.gov/expapi/verbs/passed',
'http://adlnet.gov/expapi/verbs/failed'
)
group by course_key, year, month_name, approving
having approving = 1
)

select year, month_name, avg(total)
from grades_average
group by year, month_name

0 comments on commit c2cea43

Please sign in to comment.