Skip to main content

Module exercise_answer_uploads

Module exercise_answer_uploads 

Source
Expand description

Files uploaded to be named in an exercise answer, bound to the exercise and user they were uploaded for.

The binding is what lets submit reject a file uploaded for a different exercise; ownership alone would let any exercise’s submission name any of the user’s uploads. It lives in its own table rather than as a nullable column on file_uploads because file_uploads is shared with CMS media, organization images and certificates, and the reaper’s safety depends on the distinction being structural.

Structs§

AnswerUpload
An answer upload as seen by submit validation. deleted distinguishes a reaped upload (answerable with upload_expired) from one that was never recorded.
AnswerUploadBinding
What an upload route recorded for one uploaded file.
ReapableUpload
An upload the reaper may remove: old enough, and named by no submission.

Enums§

AnswerUploadOrigin
The channel a file was uploaded through. Selects the reaper’s retention window: a native client uploads seconds before submitting, while an iframe student may hold an upload for the length of an exam.

Constants§

REAP_BATCH_LIMIT 🔒
Cap on one reaper run’s listing, bounding its object-store fan-out and its runtime under the CronJob deadline. A backlog is worked off over successive runs.

Functions§

backdate
Moves a binding’s creation time age into the past, to bring it within a retention window.
delete_by_file_upload_id
Soft-deletes the binding rows for an uploaded file, whatever their state.
get_by_file_upload_ids
The live bindings for the given uploaded files, in no particular order.
get_for_exercise_and_user
The requested uploads that belong to this exercise and user, soft-deleted ones included.
get_id_by_file_upload_id
The binding row’s own id for an uploaded file.
get_reapable
Answer uploads past their origin’s retention window that no submission was ever made from, oldest first, at most REAP_BATCH_LIMIT of them.
insert_many
Binds freshly uploaded files to the exercise and user they were uploaded for.
lock_for_exercise_and_user
Like get_for_exercise_and_user, but takes a row lock on the bindings so the reaper cannot retire them between this check and the caller’s exercise_task_submission_files insert.
mark_reaped
Retires an upload, keeping the row so a submit naming it answers upload_expired instead of the misleading unknown_upload. Idempotent, so a run retrying a failed object delete can call it again.