Eligible completions that have no ledger row and are not already in the study registry through the pull path or reported to mooc.fi as registered. A registration by us on mooc.fi does not count when a ledger row of ours for the completion under another target, left by a tier change, can have made it. Exactly the rows the materialiser creates a registration for, and so exactly the rows it may be accused of having missed. fully_eligible is not applied here: a completion still waiting on a prerequisite gets its row and waits in pending.
CREATE VIEW credit_registration_registrable_completions AS (
SELECT course_module_completion_id,
user_id,
course_id,
course_module_id,
completion_date,
created_at,
fully_eligible,
subject_id,
kind,
credit_unit_id,
external_completion_id,
external_credit_target_id
FROM credit_registration_eligible_completions e
WHERE ((NOT (EXISTS ( SELECT 1
FROM credit_registrations cr
WHERE ((cr.subject_id = e.subject_id) AND (cr.deleted_at IS NULL))))) AND (NOT (EXISTS ( SELECT 1
FROM course_module_completion_registered_to_study_registries r
WHERE ((r.course_module_completion_id = e.course_module_completion_id) AND (r.deleted_at IS NULL))))) AND (NOT (EXISTS ( SELECT 1
FROM external_completions ec
WHERE ((ec.id = e.external_completion_id) AND (ec.reported_at IS NOT NULL) AND (NOT (EXISTS ( SELECT 1
FROM (external_completions sibling
JOIN credit_registrations sibling_cr ON ((sibling_cr.external_completion_id = sibling.id)))
WHERE ((sibling.moocfi_completion_id = ec.moocfi_completion_id) AND (sibling.id <> ec.id))))))))))
)| Name | Type | Default | Nullable | Children | Parents | Comment |
|---|---|---|---|---|---|---|
| completion_date | timestamp with time zone | true | ||||
| course_id | uuid | true | ||||
| course_module_completion_id | uuid | true | ||||
| course_module_id | uuid | true | ||||
| created_at | timestamp with time zone | true | ||||
| credit_unit_id | uuid | true | ||||
| external_completion_id | uuid | true | ||||
| external_credit_target_id | uuid | true | ||||
| fully_eligible | boolean | true | ||||
| kind | text | true | ||||
| subject_id | uuid | true | ||||
| user_id | uuid | true |
| Name | Columns | Comment | Type |
|---|---|---|---|
| public.credit_registration_eligible_completions | 12 | Completions the push path is responsible for: live, passed, ECTS-eligible, on a live unit with a course code (and, for a module, credit_registration_route platform), and on the pipeline. For a course module completion that is the push-path mark set at creation; the pull path excludes exactly the rows carrying it. Membership is the hard half of the predicate, which nothing recovers from by waiting; fully_eligible is the soft half, which a prerequisite completed or a suspected-cheating review dismissed can turn true later. Deliberately silent about whether a completion is paused or already has a ledger row: pausing freezes rows where they stand rather than making them ineligible, and having a row is credit_registration_registrable_completions. | VIEW |
| 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.course_module_completion_registered_to_study_registries | 10 | Completed course module completion registrations to study registries. | 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 |
Generated by tbls