Skip to main content

librus_rs/structs/
grades.rs

1//! Grade-related data types.
2
3use serde::Deserialize;
4
5/// A student's grade.
6#[derive(Debug, Deserialize)]
7#[serde(rename_all = "PascalCase")]
8pub struct Grade {
9    /// Unique grade identifier.
10    pub id: i64,
11    /// Reference to the lesson this grade is from.
12    pub lesson: GradesRedirect,
13    /// Reference to the subject.
14    pub subject: GradesRedirect,
15    /// Reference to the student who received this grade.
16    pub student: GradesRedirect,
17    /// Reference to the grade category (e.g., test, quiz).
18    pub category: GradesRedirect,
19    /// Reference to the teacher who added this grade.
20    pub added_by: GradesRedirect,
21    /// The grade value (e.g., "5", "4+", "A").
22    pub grade: String,
23    /// Date when the grade was given.
24    pub date: String,
25    /// Date when the grade was added to the system.
26    pub add_date: String,
27    /// Semester number (1 or 2).
28    pub semester: i64,
29    /// Whether this grade counts toward the average.
30    pub is_constituent: bool,
31    /// Whether this is a semester grade.
32    pub is_semester: bool,
33    /// Whether this is a proposed semester grade.
34    pub is_semester_proposition: bool,
35    /// Whether this is a final grade.
36    pub is_final: bool,
37    /// Whether this is a proposed final grade.
38    pub is_final_proposition: bool,
39    /// References to comments on this grade.
40    pub comments: Option<Vec<GradesRedirect>>,
41    /// Reference to an improvement grade.
42    pub improvement: Option<GradesRedirect>,
43    /// Reference to a resit grade.
44    pub resit: Option<GradesRedirect>,
45}
46
47/// A reference to another resource with ID and URL.
48#[derive(Debug, Deserialize)]
49#[serde(rename_all = "PascalCase")]
50pub struct GradesRedirect {
51    /// Resource ID.
52    pub id: i32,
53    /// API URL to fetch the resource.
54    pub url: String,
55}
56
57#[derive(Debug, Deserialize)]
58#[serde(rename_all = "PascalCase")]
59pub struct GradesUrl {
60    pub url: String,
61}
62
63#[derive(Debug, Deserialize)]
64#[serde(rename_all = "PascalCase")]
65pub struct GradesResources {
66    #[serde(rename = "Grades\\Averages")]
67    pub grades_averages: GradesUrl,
68    #[serde(rename = "Grades\\StudentsAverages")]
69    pub grades_students_averages: GradesUrl,
70    #[serde(rename = "Grades\\CategoriesAverages")]
71    pub grades_categories_averages: GradesUrl,
72    #[serde(rename = "Grades\\Categories")]
73    pub grades_categories: GradesUrl,
74    #[serde(rename = "Grades\\Comments")]
75    pub grades_comments: GradesUrl,
76    #[serde(rename = "Grades\\Scales")]
77    pub grades_scales: GradesUrl,
78    #[serde(rename = "Grades\\Types")]
79    pub grades_types: GradesUrl,
80    #[serde(rename = "Grades\\UnpreparednessPerSemesterAndSubject")]
81    pub grades_unpreparedness_per_semester_and_subject: GradesUrl,
82    #[serde(rename = "..")]
83    pub root: GradesUrl,
84}
85
86/// Response containing all grades.
87#[derive(Debug, Deserialize)]
88#[serde(rename_all = "PascalCase")]
89pub struct ResponseGrades {
90    /// List of grades.
91    pub grades: Vec<Grade>,
92    /// Related API resources.
93    pub resources: GradesResources,
94    /// API URL for this response.
95    pub url: String,
96}
97
98#[derive(Debug, Deserialize)]
99#[serde(rename_all = "PascalCase")]
100pub struct GradeColor {
101    pub id: i64,
102    pub url: String,
103}
104
105/// A grade category describing the type of assessment.
106#[derive(Debug, Deserialize)]
107#[serde(rename_all = "PascalCase")]
108pub struct GradeCategory {
109    /// Unique category identifier.
110    pub id: i64,
111    /// Color for display purposes.
112    pub color: GradeColor,
113    /// Category name (e.g., "Test", "Quiz", "Homework").
114    pub name: String,
115    /// Whether applicable to adult extramural students.
116    pub adults_extramural: bool,
117    /// Whether applicable to adult daily students.
118    pub adults_daily: bool,
119    /// Whether this is a standard category.
120    pub standard: bool,
121    /// Whether this category is read-only.
122    pub is_read_only: String,
123    /// Whether grades in this category count toward average.
124    pub count_to_the_average: bool,
125    /// Whether this category blocks other grades.
126    pub block_any_grades: bool,
127    /// Whether this assessment is mandatory.
128    pub obligation_to_perform: bool,
129}
130
131#[derive(Debug, Deserialize)]
132#[serde(rename_all = "PascalCase")]
133pub struct GradesCategoryResources {
134    #[serde(rename = "..")]
135    pub root: GradesUrl,
136}
137
138/// A comment attached to a grade.
139#[derive(Debug, Deserialize)]
140#[serde(rename_all = "PascalCase")]
141pub struct GradeComment {
142    /// Unique comment identifier.
143    pub id: i32,
144    /// Reference to the teacher who added the comment.
145    pub added_by: GradeDetails,
146    /// Reference to the grade this comment is attached to.
147    pub grade: GradeDetails,
148    /// The comment text.
149    pub text: String,
150}
151
152#[derive(Debug, Deserialize)]
153#[serde(rename_all = "PascalCase")]
154pub struct GradeDetails {
155    pub id: i64,
156    pub url: String,
157}
158
159/// Response containing a single grade category.
160#[derive(Debug, Deserialize)]
161#[serde(rename_all = "PascalCase")]
162pub struct ResponseGradesCategories {
163    /// The grade category.
164    pub category: GradeCategory,
165    /// Related API resources.
166    pub resources: GradesCategoryResources,
167}
168
169/// Response containing a single grade comment.
170#[derive(Debug, Deserialize)]
171#[serde(rename_all = "PascalCase")]
172pub struct ResponseGradesComments {
173    /// The grade comment, if it exists.
174    pub comment: Option<GradeComment>,
175    /// Related API resources.
176    pub resources: GradesCategoryResources,
177    /// API URL for this response.
178    pub url: String,
179}