forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiB249dfedBurak Boduroğlu4 months ago164 commits

types.ts370 lines, 7.4 KiBHistoryRawDownload
1export type { Page, PageParams } from "./page";
2
3export type Role = "student" | "teacher" | "manager" | "admin";
4export type UserTheme = "light" | "dark";
5export type UserLanguage = "tr" | "en";
6export type CourseKind = "course" | "study" | "club" | string;
7export type CoreAttendanceStatus = "present" | "absent" | "late" | "excused";
8export type AttendanceStatus = CoreAttendanceStatus | string;
9export type KnownExamKind = "homework" | "quiz" | "midterm" | "final" | "project" | "oral";
10export type ExamKind = KnownExamKind | string;
11export type ExamMode = "sync" | "async" | "open";
12export type QuestionKind = "choice" | "text";
13export type AttemptStatus = "in_progress" | "submitted" | "expired";
14
15export type User = {
16 id: string;
17 username: string;
18 role: Role;
19 name: string | null;
20 surname: string | null;
21 email: string | null;
22 phone: string | null;
23 birth_date: string | null;
24 theme: UserTheme | null;
25 language: UserLanguage | null;
26};
27
28export type ProfileUpdate = {
29 name?: string | null;
30 surname?: string | null;
31 email?: string | null;
32 phone?: string | null;
33 birth_date?: string | null;
34};
35
36export type PersonRef = {
37 id: string;
38 username: string;
39 display_name: string | null;
40};
41
42export type Note = {
43 id: string;
44 title: string;
45 content: string;
46};
47
48export type NoteFile = {
49 id: string;
50 name: string;
51 content_type: string;
52 size: number;
53};
54
55export type EventAudience =
56 | { kind: "school" }
57 | { kind: "role"; role: Role }
58 | { kind: "course"; course: string }
59 | { kind: "registration"; capacity?: number | null };
60
61export type Event = {
62 id: string;
63 creator: string;
64 title: string;
65 description: string;
66 audience: EventAudience;
67 starts_at: number | null;
68 ends_at: number | null;
69};
70
71export type Attendance = {
72 id: string;
73 event: string;
74 user: PersonRef;
75 status: AttendanceStatus;
76 marked_by: PersonRef;
77};
78
79export type Course = {
80 id: string;
81 creator: string;
82 title: string;
83 description: string;
84 kind: CourseKind;
85 /** Academic term id from API (`CourseResponse.term`). */
86 term?: string | null;
87 capacity?: number | null;
88};
89
90export type Term = {
91 id: string;
92 name: string;
93 starts_at: number;
94 ends_at: number;
95};
96
97export type Enrollment = {
98 id: string;
99 course: string;
100 user: PersonRef;
101 enrolled_by: PersonRef;
102};
103
104export type CourseSession = {
105 id: string;
106 course: string;
107 teacher: PersonRef;
108 topic: string;
109 starts_at: number;
110 ends_at: number | null;
111};
112
113export type SessionAttendance = {
114 id: string;
115 session: string;
116 course: string;
117 user: PersonRef;
118 status: AttendanceStatus;
119 marked_by: PersonRef;
120};
121
122export type Exam = {
123 id: string;
124 creator: string;
125 course: string;
126 title: string;
127 description: string;
128 kind: ExamKind | string;
129 weight?: number | null;
130 kind_weight?: number | null;
131 type_weight?: number | null;
132 exam_type_weight?: number | null;
133 mode: ExamMode | string | null;
134 starts_at: number | null;
135 ends_at: number | null;
136 duration_ms: number | null;
137 max_attempts?: number | null;
138 allow_rejoin?: boolean | null;
139 draft?: boolean | null;
140};
141
142export type ImageMeta = {
143 content_type: string;
144 size: number;
145};
146
147export type ExamResult = {
148 id: string;
149 exam: string;
150 user: PersonRef;
151 mark: number;
152 graded_by: PersonRef;
153};
154
155export type ExamQuestion = {
156 id: string;
157 exam: string;
158 subject: string;
159 text: string;
160 kind: QuestionKind;
161 points: number;
162 choices: string[] | null;
163 correct: number | null;
164 image?: ImageMeta | null;
165 choice_images?: (ImageMeta | null)[] | null;
166};
167
168export type ExamAttempt = {
169 id?: string;
170 exam?: string;
171 user?: PersonRef;
172 status: AttemptStatus;
173 attempt?: number;
174 attempts_used?: number;
175 max_attempts?: number;
176 deadline: number | null;
177 remaining_ms: number | null;
178 left_at?: number | null;
179 mark: number | null;
180 answered: number;
181 question_count: number;
182 now: number;
183};
184
185export type AttemptAnswer = {
186 selected?: number | null;
187 text?: string | null;
188 updated_at?: number;
189};
190
191export type AttemptQuestion = {
192 id: string;
193 exam: string;
194 subject: string;
195 text: string;
196 kind: QuestionKind;
197 points: number;
198 choices: string[] | null;
199 image?: ImageMeta | null;
200 choice_images?: (ImageMeta | null)[] | null;
201 answer: AttemptAnswer | null;
202};
203
204export type PomodoroSession = {
205 id: string;
206 user: string;
207 started_at: number;
208 finished_at: number | null;
209 duration_ms: number | null;
210};
211
212export type PomodoroLog = {
213 items: PomodoroSession[];
214 total: number;
215 limit: number | null;
216 offset: number;
217 total_focus_ms: number;
218};
219
220export type Subject = {
221 id: string;
222 course: string;
223 name: string;
224 description: string;
225};
226
227export type MarkEntry = {
228 exam: string;
229 title: string;
230 kind: string;
231 weight?: number | null;
232 kind_weight?: number | null;
233 type_weight?: number | null;
234 exam_type_weight?: number | null;
235 mark: number;
236 grade?: string | null;
237 graded_by: string;
238};
239
240export type CourseMarks = {
241 course: Course;
242 results: MarkEntry[];
243 average: number | null;
244 average_grade?: string | null;
245};
246
247export type AttendanceCounts = {
248 present: number;
249 absent: number;
250 late: number;
251 excused: number;
252 custom: Record<string, number>;
253 total: number;
254 rate: number | null;
255};
256
257export type CourseAttendance = {
258 course: Course;
259 counts: AttendanceCounts;
260};
261
262export type AttendanceReport = {
263 user: string;
264 events: AttendanceCounts;
265 sessions: AttendanceCounts;
266 courses: CourseAttendance[];
267};
268
269export type WorkEntry = {
270 id: string;
271 user: string;
272 check_in: number;
273 check_out: number | null;
274 duration_ms: number | null;
275};
276
277export type MarksReport = {
278 user: string;
279 courses: CourseMarks[];
280 overall_average: number | null;
281 overall_grade?: string | null;
282};
283
284export type ExamStatistics = {
285 graded: number;
286 average: number | null;
287 min: number | null;
288 max: number | null;
289};
290
291export type GradedAnswer = {
292 question_id: string;
293 text: string;
294 kind: QuestionKind;
295 points: number;
296 choices: string[] | null;
297 correct: number | null;
298 selected: number | null;
299 text_answer: string | null;
300 is_correct: boolean | null;
301 auto_score: { earned: number; possible: number };
302};
303
304export type StudentAnswerSheet = {
305 user: PersonRef;
306 answers: GradedAnswer[];
307 auto_score: { earned: number; possible: number };
308};
309
310export type LiveRosterEntry = {
311 user: PersonRef;
312 status: AttemptStatus | "not_started" | "absent";
313 attempt?: number | null;
314 attempts_used?: number | null;
315 max_attempts?: number | null;
316 deadline: number | null;
317 remaining_ms: number | null;
318 left_at?: number | null;
319 mark: number | null;
320 answered: number;
321 started_at?: number | null;
322 finished_at?: number | null;
323 last_activity: number | null;
324};
325
326export type LiveMonitor = {
327 exam: Exam;
328 now: number;
329 question_count: number;
330 students: LiveRosterEntry[];
331 counts: {
332 enrolled?: number;
333 not_started: number;
334 absent?: number;
335 in_progress: number;
336 submitted: number;
337 expired: number;
338 graded?: number;
339 };
340};
341
342export type ExamKindSetting = {
343 name: string;
344 weight: number;
345};
346
347export type GradeBand = {
348 min: number;
349 label: string;
350};
351
352export type SchoolSettings = {
353 exam_kinds: ExamKindSetting[];
354 attendance_statuses: string[];
355 grade_bands: GradeBand[];
356 max_file_bytes: number;
357};
358
359export const EXAM_KINDS: KnownExamKind[] = [
360 "homework",
361 "quiz",
362 "midterm",
363 "final",
364 "project",
365 "oral",
366];
367
368export const EXAM_MODES: ExamMode[] = ["sync", "async", "open"];
369
370export const QUESTION_KINDS: QuestionKind[] = ["choice", "text"];