Skip to main content

Module credit_registrations

Module credit_registrations 

Source
Expand description

The credit registration ledger.

transition, and its batched twin transition_batch, are the only writers of state, stamping state_entered_at, the lifecycle timestamps and the audit event in one transaction. Which transition to make is the caller’s decision; whether it is one the machine has is decided here, from CreditRegistrationState::allowed_targets.

Structs§

AdminCreditRegistration
One ledger row as an admin sees it: every identifier support needs to answer “what happened to this student”, across courses.
AdminCreditRegistrationFilters
The narrowings the admin explorer applies, all of them in SQL.
AttentionRegistration
One row the Errors tab wants a human to look at, with the detectors that picked it.
BatchMove
One row’s move in a transition_batch.
CreditRegistration
CreditRegistrationErrorCodeCount
Live rows carrying an error code, split by whether the pipeline is still working on them.
CreditRegistrationThroughputDay
One day of terminal outcomes, for the throughput series.
ModuleRegistrationTotals
Live volumes per course module, for the Courses tab’s one row per module.
NewCreditRegistration
OldestNonTerminalRegistration
The row that has been waiting longest for the pipeline to do something with it.
PayloadSnapshot
Frozen copy of what we are about to submit. Written once, before the row leaves checking_enrolment: a later regrade must not alter a submitted row.
RegistrationLatency
How long registration took, in seconds, for rows that reached registered in a window.
RegistrationScope
Which rows a phase iteration may touch. Empty means every row, which is what production runs; a narrowed scope lets a test drive the pipeline for its own course on a shared database.
StuckRegistrationCount
StuckThresholds
How long a row may sit in one state before it counts as stuck. Seconds, per state.
StudentCreditRegistration
One ledger row with the course, module and enrolment facts every student view needs, so a status page is one query rather than a fan-out per row.
StudentRegistrationFilter
Narrows get_student_facing_by_user_id; the default returns every row of the user’s.
TeacherCreditRegistration
One ledger row as a teacher sees it: the raw state, the student’s identity and the unmasked verified student number, but never the study registry’s own error text.
TeacherCreditRegistrationFilters
The optional narrowings a teacher surface applies, all of them in SQL.
TerminalOutcomeTotals
What the pipeline finished in a window.
Transition

Enums§

AdminCreditRegistrationSort
How the explorer orders a page. Descending only: an ops table is read newest-worst first.
CreditRegistrationErrorCode
Why a ledger row is where it is; state says what happens to it next.
CreditRegistrationState
What the pipeline does next with a ledger row.
RequestPurpose
Which call a request item id addresses a row for.
ResubmissionRefusal
Why CreditRegistrationState::resubmission_refusal would not move a row.
ResubmissionStrictness
How far outside a failure CreditRegistrationState::resubmission_refusal will still allow a row to move back to ready_to_submit.
TransitionPolicy
Which (from → to) edges transition will write.

Constants§

ADMIN_ONLY_TARGETS
The edges only a hand transition may take, from any state [admin_transition_refusal] does not refuse: putting a row back on the pipeline, and writing one off.

Functions§

admin_facing_page 🔒
The one query behind both get_admin_facing and count_admin_facing, so a filter wired into one cannot be missed in the other. total_count is computed before the limit, which is why count_admin_facing reads it with limit = 1.
check_edge 🔒
Refuses an edge outside the policy. The one place (from → to) legality is decided, for the single-row transition and the batched transition_batch alike.
claim_due
Claims up to limit due rows in the given states for this worker.
count_admin_facing
How many rows get_admin_facing would return without a page limit.
count_by_error_code
The error-code breakdown the Overview shows.
count_by_module
failed_count is failed_permanent and misregistered only, so the columns do not add up to the total by design.
count_by_module_and_state_for_course
Live rows of one course per module and state, for the teacher’s per-module summary, with how many of each need a human folded in: both counts are read off the same scan, since the summary always wants them together.
count_by_state
Live rows per state, for the dashboard funnel. Superseded attempts are excluded, as in the per-course sibling, or a course that regrades counts every student twice.
count_entered_state_since
Live rows that entered one state within the window. misregistered is not terminal, so terminal_at cannot answer this.
count_needing_admin_attention
count_pending_by_reason
Live pending rows per blocker, for the surfaces that used to read the three collapsed states off the ledger. Derived from credit_registration_preconditions, so it cannot disagree with what the recompute is waiting for or with what the student is shown.
count_stuck
Rows the pipeline should have moved by now, per state. Only the four states with a threshold count: the rest wait on a student or a human, where an alert would fire on normal operation.
count_submission_uncertain_by_course_id
How many of a course’s live rows a bulk retry has to refuse, all for the one remaining reason: the submission may have landed, so only a human may move that row.
count_teacher_facing_by_course_id
How many rows get_teacher_facing_by_course_id would return without a page limit.
count_terminal_outcomes_since
dismiss_enrolment_banner
The student dismissed the in-course-material re-enrol banner for this registration.
exists_for_user_and_course
Whether this account has any attempt, live or replaced, on this course.
get_admin_facing
A page of the ledger for the admin explorer, cross-course.
get_attention_items
Rows at least one attention detector picked, worst-waiting first.
get_by_course_id
get_by_id
get_by_ids_for_update
The named rows, locked until the caller’s transaction ends. Must be called inside one.
get_by_user_id
get_live_by_states
Live rows in each of the given states, newest activity first within each state, for the Reconciliation lists. limit_per_state caps every state independently, via ROW_NUMBER, so one state with many rows cannot crowd another out of a shared LIMIT.
get_oldest_non_terminal
get_registration_latency_between
get_retryable_ids_by_course_id
The course’s live rows a bulk retry can actually move: failed for good. Oldest first, capped by limit.
get_student_facing_by_user_id
The user’s registrations as the student surfaces show them, newest completion first. Superseded attempts are included: the student is entitled to see an earlier attempt Sisu may still hold.
get_teacher_facing_attempts_for_completion
Every attempt for the same completion as row, that one included, newest attempt first.
get_teacher_facing_by_course_id
The course’s ledger rows as the teacher surfaces show them, newest completion first.
get_teacher_facing_by_id
One row for a teacher surface, by id. None when no such live row exists.
get_throughput_by_day
Daily terminal outcomes over the window. Withdrawn rows are in no column: they are neither a success nor a failure.
import_request_item_id
The item id Suotar sees for the import and resolve calls. Deterministic, so a Suotar log line maps to one ledger row without an id allocation table.
increment_submit_retry_count
increment_verify_attempt_counts
Counts one verify poll for every row of a batch and returns each row’s new count. The count is part of the poll’s request item id, so it has to be taken before the request goes out.
insert
Creates a ledger row at pending with a created event. The id is allocated here because request_item_id derives from it.
make_due_now_batch
Makes rows claimable again now, whatever backoff parked them.
mark_improvement_checked
Records that the grade-improvement scan looked at this accepted attempt against a completion in the given revision and found nothing better.
mark_superseded
Points an old attempt at the newer one that replaced it. The old row keeps its state and terminal_at: it really was registered.
recheck_no_usable_enrolment_now
Brings forward the recheck of rows parked for want of an enrolment, for students the study registry now lists as enrolled.
recovery_request_item_id
The item id Suotar sees for one look through a student’s attainments for a submission we lost track of.
request_item_id
What one registration is called in a request. The one place a sender picks an item id, so two calls about one row stay tellable apart in both logs.
requeue_retryable_now
Makes every due-later failed_retryable row due now; returns how many. The button pressed once the study registry says an outage is over.
schedule_next_attempt
Defers when the pipeline may next claim this row; the delay is the caller’s policy.
schedule_next_attempts
schedule_next_attempt for a whole batch, each row with its own time.
search_pattern_of 🔒
Lowercased and with metacharacters escaped, so a search for % matches a literal one.
set_first_failed_at_for_testing
Backdates first_failed_at for a registration, so a test can simulate a retry window that started long enough ago for its retry limit to have elapsed.
set_needs_admin_attention
set_payload_snapshot
set_sisu_attainment_if_unclaimed
Records the attainment the study registry holds, unless another live row already claims it.
set_state_entered_at_for_testing
Backdates state_entered_at for a registration, so a test can simulate a row that has been sitting in its state long enough for a backoff or timeout to fire.
set_submitted_attainment
set_test_exclusive_hold_for_testing
Excuses every one of a user’s rows (or, with course_id, just that course’s) from unscoped claim_due calls until held_until; a scoped call ignores every hold regardless (see claim_due). Keyed on identity rather than a row id so a spec can hold before materialize creates the row it means to protect, closing the window a row-id hold could only ever narrow: the live background worker ticks every 10s regardless of any single test, so a hold applied after the row exists still races the worker’s own next tick.
teacher_facing_page 🔒
The one query behind every teacher-facing read, so a filter wired into a page cannot be missed in its count. total_count is computed before the limit, which is why the count reads it with limit = 1.
transition
Moves a ledger row to a new state and appends the matching audit event, atomically.
transition_batch
transition for a whole batch: one lock, one update, one insert of events, whatever the size.
verify_request_item_id
The item id Suotar sees for one verify poll.