headless_lms_server/mock_suotar/
ids.rs1use crate::prelude::*;
8
9use super::world::RealisationKind;
10
11const MOCK_NAMESPACE: Uuid = Uuid::from_u128(0x005c_07a2_0001_4a5e_9e6e_c0de_0000_0001);
13
14pub fn person_id(student_number: &str) -> String {
15 format!("hy-hlo-{student_number}")
16}
17
18pub fn course_unit_id(course_code: &str) -> String {
19 format!("hy-CU-{course_code}")
20}
21
22pub fn assessment_item_id(course_code: &str, kind: RealisationKind) -> String {
23 format!("hy-AI-{course_code}-{}", kind.as_str())
24}
25
26pub fn realisation_id(course_code: &str, kind: RealisationKind) -> String {
29 format!(
30 "hy-opt-cur-{}-{}",
31 course_code.to_lowercase(),
32 kind.as_str()
33 )
34}
35
36pub fn enrolment_id(student_number: &str, course_code: &str, kind: RealisationKind) -> String {
38 derived(
39 "otm-enrolment",
40 &format!("enrolment|{student_number}|{course_code}|{}", kind.as_str()),
41 )
42}
43
44pub fn study_right_id(student_number: &str, kind: RealisationKind) -> String {
46 let prefix = match kind {
47 RealisationKind::Degree => "otm-degree-sr",
48 RealisationKind::OpenUniversity => "otm-avoin-sr",
49 };
50 derived(
51 prefix,
52 &format!("study-right|{student_number}|{}", kind.as_str()),
53 )
54}
55
56pub fn submitted_attainment_id() -> String {
58 format!("hy-kur-{}", Uuid::new_v4())
59}
60
61pub fn final_attainment_id(submitted_attainment_id: &str) -> String {
62 derived(
63 "otm-attainment",
64 &format!("attainment|{submitted_attainment_id}"),
65 )
66}
67
68pub fn pushed_attainment_id(student_number: &str, course_code: &str, grade_id: &str) -> String {
69 derived(
70 "otm-attainment",
71 &format!("existing-attainment|{student_number}|{course_code}|{grade_id}"),
72 )
73}
74
75fn derived(prefix: &str, name: &str) -> String {
76 format!(
77 "{prefix}-{}",
78 Uuid::new_v5(&MOCK_NAMESPACE, name.as_bytes())
79 )
80}