Index

public.user_exercise_states

Description

Keeps track of state related to a user and to an exercise. Each course instance run has their own entries in the table. It is the source of truth for activity status, points etc.

Columns

Name Type Default Nullable Children Parents Comment
activity_progress activity_progress ‘initialized’::activity_progress false Tells how close the activity required from the user is from completion. See: https://rage.github.io/secret-project-331/headless_lms_actix/models/exercises/enum.ActivityProgress.html. The activity is not done before the student has completed everything that is required of them (like giving a peer review).
course_instance_id uuid true public.course_instances The course instance related to this state. All course instances have their separate states so that students can take courses multiple times in different instances. Part of the primary key.
created_at timestamp with time zone now() false Timestamp when the record was created.
deleted_at timestamp with time zone true Timestamp when the record was deleted. If null, the record is not deleted.
exam_id uuid true public.exams The exam the user exercise state is associated with.
exercise_id uuid false public.exercises The exercise which the exercise state is about. Part of the primary key.
grading_progress grading_progress ‘not-ready’::grading_progress false Tells how grading of this exercise is progressing towards completion. See https://rage.github.io/secret-project-331/headless_lms_actix/models/exercises/enum.GradingProgress.html. Takes into account more holistic picture of the grading progress than gradings.grading_progress. For example, this takes peer reviews into account and other extra requirements into account.
id uuid uuid_generate_v4() false public.teacher_grading_decisions public.user_exercise_slide_states A unique, stable identifier for the record.
reviewing_stage reviewing_stage ‘not_started’::reviewing_stage false Tells what stage of reviewing the user is currently in. Used for for peer review and self review. If the user has started or completed some kind of review, it is assumed that they no longer can answer the exercise. See https://rage.github.io/secret-project-331/headless_lms_models/user_exercise_states/enum.ReviewingStage.html for more info.
score_given real true If not null, it indicates how many points the student has gotten from this exercise.
selected_exercise_slide_id uuid true public.exercise_slides The current exercise slide of the exercise that has been chosen for the student. It is also used for checking during submission to ensure the user can not post an answer to a task that has not been given to them.
updated_at timestamp with time zone now() false Timestamp when the record was last updated. The field is updated automatically by the set_timestamp trigger.
user_id uuid false public.users The user whose exercise state is defined in this row. Part of the primary key.

Constraints

Name Type Definition Comment
course_instance_or_exam_id_set CHECK CHECK (((course_instance_id IS NULL) <> (exam_id IS NULL))) A user exercise state must be associated with either a course instance or an exam.
user_exercise_states_course_instance_id_fkey FOREIGN KEY FOREIGN KEY (course_instance_id) REFERENCES course_instances(id)
user_exercise_states_exam_id_fkey FOREIGN KEY FOREIGN KEY (exam_id) REFERENCES exams(id)
user_exercise_states_exercise_id_fkey FOREIGN KEY FOREIGN KEY (exercise_id) REFERENCES exercises(id)
user_exercise_states_pkey PRIMARY KEY PRIMARY KEY (id)
user_exercise_states_selected_exercise_slide_id_fkey FOREIGN KEY FOREIGN KEY (selected_exercise_slide_id) REFERENCES exercise_slides(id)
user_exercise_states_user_id_fkey FOREIGN KEY FOREIGN KEY (user_id) REFERENCES users(id)

Indexes

Name Definition
user_exercise_states_fast_search CREATE INDEX user_exercise_states_fast_search ON public.user_exercise_states USING btree (user_id, exercise_id, course_instance_id, exam_id, deleted_at)
user_exercise_states_pkey CREATE UNIQUE INDEX user_exercise_states_pkey ON public.user_exercise_states USING btree (id)

Triggers

Name Definition
set_timestamp CREATE TRIGGER set_timestamp BEFORE UPDATE ON public.user_exercise_states FOR EACH ROW EXECUTE FUNCTION trigger_set_timestamp()

Relations

er

Generated by tbls