Index

public.credit_registration_subjects

Description

Every completion a ledger row can register, course module completions and mooc.fi completions alike, with the facts of the completion and of the unit (module or target) it registers for. Ledger rows join it on subject_id.

Table Definition
CREATE VIEW credit_registration_subjects AS (
 SELECT cmc.id AS subject_id,
    'course_module'::text AS kind,
    cmc.user_id,
    cmc.course_module_id AS credit_unit_id,
    cmc.course_id,
    cmc.course_module_id,
    NULL::uuid AS external_credit_target_id,
    NULL::uuid AS external_completion_id,
    cmc.id AS course_module_completion_id,
    cmc.passed,
    cmc.grade,
    cmc.completion_date,
    cmc.completion_language,
    cmc.eligible_for_ects,
    (cmc.passed AND cmc.eligible_for_ects AND cmc.prerequisite_modules_completed AND (NOT cmc.needs_to_be_reviewed)) AS fully_eligible,
    (cmc.deleted_at IS NOT NULL) AS is_withdrawn,
    cmc.register_credits_via_suotar AS is_on_pipeline,
    NULL::uuid AS registered_equivalent_moocfi_completion_id,
    cmc.created_at,
    cmc.updated_at,
    cmc.updated_at AS revised_at,
    ( SELECT cm.uh_course_code
           FROM course_modules cm
          WHERE (cm.id = cmc.course_module_id)) AS uh_course_code,
    ( SELECT cm.ects_credits
           FROM course_modules cm
          WHERE (cm.id = cmc.course_module_id)) AS ects_credits,
    ( SELECT NULLIF(TRIM(BOTH FROM cm.completion_registration_link_override), ''::text) AS "nullif"
           FROM course_modules cm
          WHERE (cm.id = cmc.course_module_id)) AS enrolment_link,
    ( SELECT c.language_code
           FROM courses c
          WHERE (c.id = cmc.course_id)) AS language_code,
    ( SELECT cm.name
           FROM course_modules cm
          WHERE (cm.id = cmc.course_module_id)) AS unit_name,
    ( SELECT c.name
           FROM courses c
          WHERE (c.id = cmc.course_id)) AS course_name
   FROM course_module_completions cmc
UNION ALL
 SELECT ec.id AS subject_id,
    'mooc_fi'::text AS kind,
    ec.user_id,
    ec.external_credit_target_id AS credit_unit_id,
    NULL::uuid AS course_id,
    NULL::uuid AS course_module_id,
    ec.external_credit_target_id,
    ec.id AS external_completion_id,
    NULL::uuid AS course_module_completion_id,
    ec.passed,
    ec.grade,
    ec.completion_date,
    COALESCE(ec.completion_language, ( SELECT t.language_code
           FROM external_credit_targets t
          WHERE (t.id = ec.external_credit_target_id))) AS completion_language,
    ec.eligible_for_ects,
    ((ec.passed IS TRUE) AND ec.eligible_for_ects) AS fully_eligible,
    ((ec.deleted_at IS NOT NULL) OR (ec.upstream_missing_at IS NOT NULL) OR (ec.registered_upstream_at IS NOT NULL) OR (moocfi_registered_equivalent(ec.*) IS NOT NULL) OR (EXISTS ( SELECT 1
           FROM external_credit_targets t
          WHERE ((t.id = ec.external_credit_target_id) AND ((ec.completion_date < t.delegated_at) OR (t.deleted_at IS NOT NULL) OR ((t.tiers IS NOT NULL) AND ((t.tiers @> ec.tier) IS NOT TRUE))))))) AS is_withdrawn,
    true AS is_on_pipeline,
    moocfi_registered_equivalent(ec.*) AS registered_equivalent_moocfi_completion_id,
    ec.created_at,
    ec.updated_at,
    ec.revised_at,
    ( SELECT t.uh_course_code
           FROM external_credit_targets t
          WHERE (t.id = ec.external_credit_target_id)) AS uh_course_code,
    ( SELECT t.ects_credits
           FROM external_credit_targets t
          WHERE (t.id = ec.external_credit_target_id)) AS ects_credits,
    ( SELECT NULLIF(TRIM(BOTH FROM t.enrolment_link), ''::text) AS "nullif"
           FROM external_credit_targets t
          WHERE (t.id = ec.external_credit_target_id)) AS enrolment_link,
    ( SELECT t.language_code
           FROM external_credit_targets t
          WHERE (t.id = ec.external_credit_target_id)) AS language_code,
    ( SELECT t.name
           FROM external_credit_targets t
          WHERE (t.id = ec.external_credit_target_id)) AS unit_name,
    NULL::character varying AS course_name
   FROM external_completions ec
)

Columns

Name Type Default Nullable Children Parents Comment
completion_date timestamp with time zone true
completion_language varchar(15) true
course_id uuid true
course_module_completion_id uuid true
course_module_id uuid true
course_name varchar true NULL for a mooc.fi completion; unit_name names it.
created_at timestamp with time zone true
credit_unit_id uuid true
ects_credits real true
eligible_for_ects boolean true
enrolment_link text true
external_completion_id uuid true
external_credit_target_id uuid true
fully_eligible boolean true Passed and ECTS-eligible, and for a course module completion also not waiting on a prerequisite module or a suspected-cheating review.
grade integer true
is_on_pipeline boolean true Registered by this pipeline rather than the pull path. Always true for mooc.fi completions: the pull already excludes everything at or after the cutoff.
is_withdrawn boolean true The completion is no longer ours to register: deleted, or for mooc.fi also gone upstream, registered by another organization or through a registered equivalent, dated before the cutoff, on a deleted target, or with a tier outside the target’s range. Withdrawal cancels rows not yet submitted.
kind text true ‘course_module’ or ‘mooc_fi’.
language_code varchar(15) true
passed boolean true NULL for a mooc.fi completion whose grade was not recognised.
registered_equivalent_moocfi_completion_id uuid true See moocfi_registered_equivalent. Always NULL for a course module completion.
revised_at timestamp with time zone true When the completion last changed in a way that could matter to its registration. For a course module completion its updated_at.
subject_id uuid true
uh_course_code varchar(255) true
unit_name varchar(255) true
updated_at timestamp with time zone true
user_id uuid true

Referenced Tables

Name Columns Comment Type
public.course_modules 18 A module is a collection of chapters which can be used to categorise the chapters of a course. BASE TABLE
cm.completion_registration_link_override 0
public.courses 29 Collection of course materials and exercises that define a online course. BASE TABLE
public.course_module_completions 18 Internal student completions for course modules. BASE TABLE
public.external_credit_targets 29 A mooc.fi course whose credits courses registers into the study registry, standing in for both course_modules and course_module_suotar_configurations for mooc.fi ledger rows. Each tier of a course maps to at most one live target, enforced by the external_credit_targets_tier_overlap trigger, so a completion registers one course code per tier it has had. BASE TABLE
t.enrolment_link 0
public.external_completions 21 A mooc.fi completion as courses last read it, one row per completion and the target its tier maps to. The subject of a mooc.fi ledger row, as course_module_completions is of a native one. Facts are copied from mooc.fi when the student opens the registration page and on re-check; mooc.fi stays the source of truth. BASE TABLE

Relations

er

Generated by tbls