Index

public.moocfi_reportable_registrations

Description

The mooc.fi ledger rows that report-back tells mooc.fi about, one report each, since mooc.fi keeps every registration of a completion as history. Every registered row, a later grade improvement included. A duplicate or not_improved row puts nothing new in Sisu, so it is reported only when it is the first success of its mooc.fi completion: mooc.fi must still learn that the completion is registered. An earlier success deleted since still counts if it was reported.

Table Definition
CREATE VIEW moocfi_reportable_registrations AS (
 SELECT cr.id AS credit_registration_id,
    cr.external_completion_id,
    ec.moocfi_completion_id,
    COALESCE(cr.registered_at, cr.terminal_at, cr.state_entered_at) AS registration_date
   FROM (credit_registrations cr
     JOIN external_completions ec ON ((ec.id = cr.external_completion_id)))
  WHERE ((cr.deleted_at IS NULL) AND (ec.deleted_at IS NULL) AND (cr.student_number IS NOT NULL) AND ((cr.state = 'registered'::credit_registration_state) OR ((cr.state = ANY (ARRAY['duplicate'::credit_registration_state, 'not_improved'::credit_registration_state])) AND (NOT (EXISTS ( SELECT 1
           FROM (external_completions earlier_ec
             JOIN credit_registrations earlier ON ((earlier.subject_id = earlier_ec.id)))
          WHERE ((earlier_ec.moocfi_completion_id = ec.moocfi_completion_id) AND (earlier.id <> cr.id) AND (earlier.state = ANY (ARRAY['registered'::credit_registration_state, 'duplicate'::credit_registration_state, 'not_improved'::credit_registration_state])) AND ((earlier.deleted_at IS NULL) OR (EXISTS ( SELECT 1
                   FROM moocfi_registration_reports earlier_report
                  WHERE ((earlier_report.credit_registration_id = earlier.id) AND (earlier_report.reported_at IS NOT NULL))))) AND (ROW(COALESCE(earlier.registered_at, earlier.terminal_at, earlier.state_entered_at), earlier.id) < ROW(COALESCE(cr.registered_at, cr.terminal_at, cr.state_entered_at), cr.id)))))))))
)

Columns

Name Type Default Nullable Children Parents Comment
credit_registration_id uuid true
external_completion_id uuid true
moocfi_completion_id uuid true
registration_date timestamp with time zone true When the credit landed in the study registry. What moocfi_registration_reports.registration_date is fixed from.

Referenced Tables

Name Columns Comment Type
public.credit_registrations 69 The credit registration ledger: one row per attempt at registering one completion into the study registry via Suotar, either a course module completion or a mooc.fi completion (external_completions). Every state write goes through credit_registrations::transition, which stamps state_entered_at and appends an event row in the same transaction; nothing else may update state. BASE TABLE
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
public.moocfi_registration_reports 12 Report-back of one mooc.fi ledger row to mooc.fi. Created when report-back first claims the row; a row of moocfi_reportable_registrations without one has not been tried yet. BASE TABLE

Relations

er

Generated by tbls