-- Staging model: Ofsted Parent View survey responses
-- The tap computes positive percentages (Strongly agree + Agree) per question.

with source as (
    select * from {{ source('raw', 'parent_view') }}
),

renamed as (
    select
        cast(urn as integer)                       as urn,
        cast(survey_date as date)                  as survey_date,
        cast(total_responses as integer)           as total_responses,
        cast(q_happy_pct as numeric)               as q_happy_pct,
        cast(q_safe_pct as numeric)                as q_safe_pct,
        cast(q_behaviour_pct as numeric)           as q_behaviour_pct,
        cast(q_bullying_pct as numeric)            as q_bullying_pct,
        cast(q_communication_pct as numeric)       as q_communication_pct,
        cast(q_progress_pct as numeric)            as q_progress_pct,
        cast(q_teaching_pct as numeric)            as q_teaching_pct,
        cast(q_information_pct as numeric)         as q_information_pct,
        cast(q_curriculum_pct as numeric)           as q_curriculum_pct,
        cast(q_future_pct as numeric)              as q_future_pct,
        cast(q_leadership_pct as numeric)          as q_leadership_pct,
        cast(q_wellbeing_pct as numeric)           as q_wellbeing_pct,
        cast(q_recommend_pct as numeric)           as q_recommend_pct
    from source
    where urn is not null
)

select * from renamed
