@studious-lms/server 1.4.5 → 1.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/config/cors.d.ts.map +1 -1
- package/dist/lib/config/cors.js +8 -3
- package/dist/lib/config/cors.js.map +1 -1
- package/dist/models/access.d.ts +112 -0
- package/dist/models/access.d.ts.map +1 -0
- package/dist/models/access.js +49 -0
- package/dist/models/access.js.map +1 -0
- package/dist/models/announcement.d.ts +17 -2
- package/dist/models/announcement.d.ts.map +1 -1
- package/dist/models/announcement.js +21 -4
- package/dist/models/announcement.js.map +1 -1
- package/dist/models/assignment.d.ts +37 -37
- package/dist/models/assignment.d.ts.map +1 -1
- package/dist/models/assignment.js +15 -15
- package/dist/models/assignment.js.map +1 -1
- package/dist/models/attendance.d.ts +1 -1
- package/dist/models/attendance.d.ts.map +1 -1
- package/dist/models/attendance.js +6 -5
- package/dist/models/attendance.js.map +1 -1
- package/dist/models/auth.d.ts +5 -5
- package/dist/models/auth.d.ts.map +1 -1
- package/dist/models/auth.js +7 -11
- package/dist/models/auth.js.map +1 -1
- package/dist/models/class.d.ts +26 -26
- package/dist/models/class.d.ts.map +1 -1
- package/dist/models/class.js +7 -11
- package/dist/models/class.js.map +1 -1
- package/dist/models/comment.d.ts +233 -6
- package/dist/models/comment.d.ts.map +1 -1
- package/dist/models/comment.js +133 -3
- package/dist/models/comment.js.map +1 -1
- package/dist/models/conversation.d.ts +7 -7
- package/dist/models/event.d.ts +52 -3
- package/dist/models/event.d.ts.map +1 -1
- package/dist/models/event.js +56 -6
- package/dist/models/event.js.map +1 -1
- package/dist/models/file.d.ts +178 -103
- package/dist/models/file.d.ts.map +1 -1
- package/dist/models/file.js +54 -14
- package/dist/models/file.js.map +1 -1
- package/dist/models/folder.d.ts +22 -22
- package/dist/models/folder.d.ts.map +1 -1
- package/dist/models/folder.js +5 -4
- package/dist/models/folder.js.map +1 -1
- package/dist/models/labChat.d.ts +20 -20
- package/dist/models/labChat.d.ts.map +1 -1
- package/dist/models/labChat.js +8 -10
- package/dist/models/labChat.js.map +1 -1
- package/dist/models/marketing.d.ts +1 -1
- package/dist/models/message.d.ts +6 -6
- package/dist/models/newtonChat.d.ts +5 -5
- package/dist/models/school.d.ts +361 -0
- package/dist/models/school.d.ts.map +1 -0
- package/dist/models/school.js +314 -0
- package/dist/models/school.js.map +1 -0
- package/dist/models/section.d.ts +1 -1
- package/dist/models/section.d.ts.map +1 -1
- package/dist/models/section.js +5 -4
- package/dist/models/section.js.map +1 -1
- package/dist/models/user.d.ts +4 -4
- package/dist/models/worksheet.d.ts +67 -65
- package/dist/models/worksheet.d.ts.map +1 -1
- package/dist/models/worksheet.js +6 -14
- package/dist/models/worksheet.js.map +1 -1
- package/dist/pipelines/aiLabChat.d.ts.map +1 -1
- package/dist/pipelines/aiLabChat.js +4 -3
- package/dist/pipelines/aiLabChat.js.map +1 -1
- package/dist/pipelines/gradeWorksheet.d.ts +2 -2
- package/dist/pipelines/pdfToWorksheet.d.ts +1 -1
- package/dist/routers/_app.d.ts +2462 -1104
- package/dist/routers/_app.d.ts.map +1 -1
- package/dist/routers/_app.js +4 -2
- package/dist/routers/_app.js.map +1 -1
- package/dist/routers/announcement.d.ts +13 -5
- package/dist/routers/announcement.d.ts.map +1 -1
- package/dist/routers/announcement.js +25 -5
- package/dist/routers/announcement.js.map +1 -1
- package/dist/routers/assignment.d.ts +266 -36
- package/dist/routers/assignment.d.ts.map +1 -1
- package/dist/routers/assignment.js +221 -3
- package/dist/routers/assignment.js.map +1 -1
- package/dist/routers/class.d.ts +21 -20
- package/dist/routers/class.d.ts.map +1 -1
- package/dist/routers/class.js +3 -2
- package/dist/routers/class.js.map +1 -1
- package/dist/routers/comment.d.ts +40 -3
- package/dist/routers/comment.d.ts.map +1 -1
- package/dist/routers/comment.js +14 -5
- package/dist/routers/comment.js.map +1 -1
- package/dist/routers/conversation.d.ts +6 -6
- package/dist/routers/event.d.ts +21 -2
- package/dist/routers/event.d.ts.map +1 -1
- package/dist/routers/file.d.ts +2 -2
- package/dist/routers/folder.d.ts +24 -24
- package/dist/routers/labChat.d.ts +7 -7
- package/dist/routers/school.d.ts +384 -0
- package/dist/routers/school.d.ts.map +1 -0
- package/dist/routers/school.js +79 -0
- package/dist/routers/school.js.map +1 -0
- package/dist/routers/search.d.ts +1 -1
- package/dist/routers/worksheet.d.ts +23 -21
- package/dist/routers/worksheet.d.ts.map +1 -1
- package/dist/services/announcement.d.ts.map +1 -1
- package/dist/services/announcement.js +10 -6
- package/dist/services/announcement.js.map +1 -1
- package/dist/services/assignment.d.ts +36 -36
- package/dist/services/class.d.ts +20 -19
- package/dist/services/class.d.ts.map +1 -1
- package/dist/services/class.js +22 -3
- package/dist/services/class.js.map +1 -1
- package/dist/services/comment.d.ts +31 -5
- package/dist/services/comment.d.ts.map +1 -1
- package/dist/services/comment.js +102 -19
- package/dist/services/comment.js.map +1 -1
- package/dist/services/conversation.d.ts +6 -6
- package/dist/services/event.d.ts +21 -2
- package/dist/services/event.d.ts.map +1 -1
- package/dist/services/event.js +11 -7
- package/dist/services/event.js.map +1 -1
- package/dist/services/file.d.ts +2 -2
- package/dist/services/file.d.ts.map +1 -1
- package/dist/services/file.js +17 -8
- package/dist/services/file.js.map +1 -1
- package/dist/services/folder.d.ts +24 -24
- package/dist/services/labChat.d.ts +7 -7
- package/dist/services/school.d.ts +299 -0
- package/dist/services/school.d.ts.map +1 -0
- package/dist/services/school.js +225 -0
- package/dist/services/school.js.map +1 -0
- package/dist/services/worksheet.d.ts +23 -21
- package/dist/services/worksheet.d.ts.map +1 -1
- package/package.json +1 -1
- package/prisma/migrations/20260502230500_assignment_submission_comments/migration.sql +60 -0
- package/prisma/migrations/20260504071500_school_memberships/migration.sql +81 -0
- package/prisma/schema.prisma +75 -2
- package/src/lib/config/cors.ts +8 -1
- package/src/models/access.ts +48 -0
- package/src/models/announcement.ts +19 -2
- package/src/models/assignment.ts +17 -13
- package/src/models/attendance.ts +4 -3
- package/src/models/auth.ts +8 -9
- package/src/models/class.ts +8 -9
- package/src/models/comment.ts +137 -1
- package/src/models/event.ts +54 -4
- package/src/models/file.ts +53 -12
- package/src/models/folder.ts +3 -2
- package/src/models/labChat.ts +9 -8
- package/src/models/school.ts +361 -0
- package/src/models/section.ts +3 -2
- package/src/models/worksheet.ts +7 -12
- package/src/pipelines/aiLabChat.ts +2 -1
- package/src/routers/_app.ts +2 -0
- package/src/routers/announcement.ts +30 -4
- package/src/routers/assignment.ts +243 -2
- package/src/routers/class.ts +1 -0
- package/src/routers/comment.ts +19 -2
- package/src/routers/school.ts +122 -0
- package/src/services/announcement.ts +12 -4
- package/src/services/class.ts +25 -2
- package/src/services/comment.ts +122 -18
- package/src/services/event.ts +23 -6
- package/src/services/file.ts +20 -6
- package/src/services/school.ts +308 -0
- package/tests/lib/cors.test.ts +13 -1
- package/tests/routers/assignment.test.ts +68 -2
- package/tests/routers/comment.test.ts +42 -1
- package/vercel.json +8 -0
|
@@ -33,12 +33,6 @@ export declare function findAssignmentById(id: string): import(".prisma/client")
|
|
|
33
33
|
}>;
|
|
34
34
|
/** @returns Assignment with full details for get. */
|
|
35
35
|
export declare function findAssignmentWithDetails(id: string): import(".prisma/client").Prisma.Prisma__AssignmentClient<({
|
|
36
|
-
submissions: {
|
|
37
|
-
student: {
|
|
38
|
-
id: string;
|
|
39
|
-
username: string;
|
|
40
|
-
};
|
|
41
|
-
}[];
|
|
42
36
|
class: {
|
|
43
37
|
name: string;
|
|
44
38
|
id: string;
|
|
@@ -47,6 +41,12 @@ export declare function findAssignmentWithDetails(id: string): import(".prisma/c
|
|
|
47
41
|
name: string;
|
|
48
42
|
id: string;
|
|
49
43
|
} | null;
|
|
44
|
+
submissions: {
|
|
45
|
+
student: {
|
|
46
|
+
id: string;
|
|
47
|
+
username: string;
|
|
48
|
+
};
|
|
49
|
+
}[];
|
|
50
50
|
markScheme: {
|
|
51
51
|
id: string;
|
|
52
52
|
structured: string;
|
|
@@ -122,8 +122,8 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
122
122
|
type: string;
|
|
123
123
|
name: string;
|
|
124
124
|
id: string;
|
|
125
|
-
size: number | null;
|
|
126
125
|
userId: string | null;
|
|
126
|
+
size: number | null;
|
|
127
127
|
uploadedAt: Date | null;
|
|
128
128
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
129
129
|
uploadUrl: string | null;
|
|
@@ -150,8 +150,8 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
150
150
|
type: string;
|
|
151
151
|
name: string;
|
|
152
152
|
id: string;
|
|
153
|
-
size: number | null;
|
|
154
153
|
userId: string | null;
|
|
154
|
+
size: number | null;
|
|
155
155
|
uploadedAt: Date | null;
|
|
156
156
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
157
157
|
uploadUrl: string | null;
|
|
@@ -179,8 +179,8 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
179
179
|
type: string;
|
|
180
180
|
name: string;
|
|
181
181
|
id: string;
|
|
182
|
-
size: number | null;
|
|
183
182
|
userId: string | null;
|
|
183
|
+
size: number | null;
|
|
184
184
|
uploadedAt: Date | null;
|
|
185
185
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
186
186
|
uploadUrl: string | null;
|
|
@@ -207,8 +207,8 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
207
207
|
type: string;
|
|
208
208
|
name: string;
|
|
209
209
|
id: string;
|
|
210
|
-
size: number | null;
|
|
211
210
|
userId: string | null;
|
|
211
|
+
size: number | null;
|
|
212
212
|
uploadedAt: Date | null;
|
|
213
213
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
214
214
|
uploadUrl: string | null;
|
|
@@ -232,8 +232,8 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
232
232
|
})[];
|
|
233
233
|
} & {
|
|
234
234
|
id: string;
|
|
235
|
-
assignmentId: string;
|
|
236
235
|
createdAt: Date;
|
|
236
|
+
assignmentId: string;
|
|
237
237
|
modifiedAt: Date;
|
|
238
238
|
studentId: string;
|
|
239
239
|
extendedResponse: string | null;
|
|
@@ -253,8 +253,8 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
253
253
|
type: string;
|
|
254
254
|
name: string;
|
|
255
255
|
id: string;
|
|
256
|
-
size: number | null;
|
|
257
256
|
userId: string | null;
|
|
257
|
+
size: number | null;
|
|
258
258
|
uploadedAt: Date | null;
|
|
259
259
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
260
260
|
uploadUrl: string | null;
|
|
@@ -281,8 +281,8 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
281
281
|
type: string;
|
|
282
282
|
name: string;
|
|
283
283
|
id: string;
|
|
284
|
-
size: number | null;
|
|
285
284
|
userId: string | null;
|
|
285
|
+
size: number | null;
|
|
286
286
|
uploadedAt: Date | null;
|
|
287
287
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
288
288
|
uploadUrl: string | null;
|
|
@@ -404,8 +404,8 @@ export declare function findSubmissionByAssignmentAndStudent(assignmentId: strin
|
|
|
404
404
|
type: string;
|
|
405
405
|
name: string;
|
|
406
406
|
id: string;
|
|
407
|
-
size: number | null;
|
|
408
407
|
userId: string | null;
|
|
408
|
+
size: number | null;
|
|
409
409
|
uploadedAt: Date | null;
|
|
410
410
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
411
411
|
uploadUrl: string | null;
|
|
@@ -432,8 +432,8 @@ export declare function findSubmissionByAssignmentAndStudent(assignmentId: strin
|
|
|
432
432
|
type: string;
|
|
433
433
|
name: string;
|
|
434
434
|
id: string;
|
|
435
|
-
size: number | null;
|
|
436
435
|
userId: string | null;
|
|
436
|
+
size: number | null;
|
|
437
437
|
uploadedAt: Date | null;
|
|
438
438
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
439
439
|
uploadUrl: string | null;
|
|
@@ -460,10 +460,10 @@ export declare function findSubmissionByAssignmentAndStudent(assignmentId: strin
|
|
|
460
460
|
username: string;
|
|
461
461
|
profile: {
|
|
462
462
|
id: string;
|
|
463
|
-
userId: string;
|
|
464
463
|
createdAt: Date;
|
|
465
|
-
location: string | null;
|
|
466
464
|
updatedAt: Date;
|
|
465
|
+
userId: string;
|
|
466
|
+
location: string | null;
|
|
467
467
|
displayName: string | null;
|
|
468
468
|
bio: string | null;
|
|
469
469
|
website: string | null;
|
|
@@ -473,8 +473,8 @@ export declare function findSubmissionByAssignmentAndStudent(assignmentId: strin
|
|
|
473
473
|
};
|
|
474
474
|
} & {
|
|
475
475
|
id: string;
|
|
476
|
-
assignmentId: string;
|
|
477
476
|
createdAt: Date;
|
|
477
|
+
assignmentId: string;
|
|
478
478
|
modifiedAt: Date;
|
|
479
479
|
studentId: string;
|
|
480
480
|
extendedResponse: string | null;
|
|
@@ -549,8 +549,8 @@ export declare function findSubmissionByIdForClassMember(submissionId: string, c
|
|
|
549
549
|
type: string;
|
|
550
550
|
name: string;
|
|
551
551
|
id: string;
|
|
552
|
-
size: number | null;
|
|
553
552
|
userId: string | null;
|
|
553
|
+
size: number | null;
|
|
554
554
|
uploadedAt: Date | null;
|
|
555
555
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
556
556
|
uploadUrl: string | null;
|
|
@@ -577,8 +577,8 @@ export declare function findSubmissionByIdForClassMember(submissionId: string, c
|
|
|
577
577
|
type: string;
|
|
578
578
|
name: string;
|
|
579
579
|
id: string;
|
|
580
|
-
size: number | null;
|
|
581
580
|
userId: string | null;
|
|
581
|
+
size: number | null;
|
|
582
582
|
uploadedAt: Date | null;
|
|
583
583
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
584
584
|
uploadUrl: string | null;
|
|
@@ -605,10 +605,10 @@ export declare function findSubmissionByIdForClassMember(submissionId: string, c
|
|
|
605
605
|
username: string;
|
|
606
606
|
profile: {
|
|
607
607
|
id: string;
|
|
608
|
-
userId: string;
|
|
609
608
|
createdAt: Date;
|
|
610
|
-
location: string | null;
|
|
611
609
|
updatedAt: Date;
|
|
610
|
+
userId: string;
|
|
611
|
+
location: string | null;
|
|
612
612
|
displayName: string | null;
|
|
613
613
|
bio: string | null;
|
|
614
614
|
website: string | null;
|
|
@@ -618,8 +618,8 @@ export declare function findSubmissionByIdForClassMember(submissionId: string, c
|
|
|
618
618
|
};
|
|
619
619
|
} & {
|
|
620
620
|
id: string;
|
|
621
|
-
assignmentId: string;
|
|
622
621
|
createdAt: Date;
|
|
622
|
+
assignmentId: string;
|
|
623
623
|
modifiedAt: Date;
|
|
624
624
|
studentId: string;
|
|
625
625
|
extendedResponse: string | null;
|
|
@@ -691,8 +691,8 @@ export declare function findSubmissionForUpdate(submissionId: string, userId: st
|
|
|
691
691
|
type: string;
|
|
692
692
|
name: string;
|
|
693
693
|
id: string;
|
|
694
|
-
size: number | null;
|
|
695
694
|
userId: string | null;
|
|
695
|
+
size: number | null;
|
|
696
696
|
uploadedAt: Date | null;
|
|
697
697
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
698
698
|
uploadUrl: string | null;
|
|
@@ -719,8 +719,8 @@ export declare function findSubmissionForUpdate(submissionId: string, userId: st
|
|
|
719
719
|
type: string;
|
|
720
720
|
name: string;
|
|
721
721
|
id: string;
|
|
722
|
-
size: number | null;
|
|
723
722
|
userId: string | null;
|
|
723
|
+
size: number | null;
|
|
724
724
|
uploadedAt: Date | null;
|
|
725
725
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
726
726
|
uploadUrl: string | null;
|
|
@@ -744,8 +744,8 @@ export declare function findSubmissionForUpdate(submissionId: string, userId: st
|
|
|
744
744
|
})[];
|
|
745
745
|
} & {
|
|
746
746
|
id: string;
|
|
747
|
-
assignmentId: string;
|
|
748
747
|
createdAt: Date;
|
|
748
|
+
assignmentId: string;
|
|
749
749
|
modifiedAt: Date;
|
|
750
750
|
studentId: string;
|
|
751
751
|
extendedResponse: string | null;
|
|
@@ -820,8 +820,8 @@ export declare function createSubmission(assignmentId: string, studentId: string
|
|
|
820
820
|
type: string;
|
|
821
821
|
name: string;
|
|
822
822
|
id: string;
|
|
823
|
-
size: number | null;
|
|
824
823
|
userId: string | null;
|
|
824
|
+
size: number | null;
|
|
825
825
|
uploadedAt: Date | null;
|
|
826
826
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
827
827
|
uploadUrl: string | null;
|
|
@@ -848,8 +848,8 @@ export declare function createSubmission(assignmentId: string, studentId: string
|
|
|
848
848
|
type: string;
|
|
849
849
|
name: string;
|
|
850
850
|
id: string;
|
|
851
|
-
size: number | null;
|
|
852
851
|
userId: string | null;
|
|
852
|
+
size: number | null;
|
|
853
853
|
uploadedAt: Date | null;
|
|
854
854
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
855
855
|
uploadUrl: string | null;
|
|
@@ -877,8 +877,8 @@ export declare function createSubmission(assignmentId: string, studentId: string
|
|
|
877
877
|
};
|
|
878
878
|
} & {
|
|
879
879
|
id: string;
|
|
880
|
-
assignmentId: string;
|
|
881
880
|
createdAt: Date;
|
|
881
|
+
assignmentId: string;
|
|
882
882
|
modifiedAt: Date;
|
|
883
883
|
studentId: string;
|
|
884
884
|
extendedResponse: string | null;
|
|
@@ -998,8 +998,8 @@ export declare function findSubmissionsByAssignmentForTeacher(assignmentId: stri
|
|
|
998
998
|
type: string;
|
|
999
999
|
name: string;
|
|
1000
1000
|
id: string;
|
|
1001
|
-
size: number | null;
|
|
1002
1001
|
userId: string | null;
|
|
1002
|
+
size: number | null;
|
|
1003
1003
|
uploadedAt: Date | null;
|
|
1004
1004
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
1005
1005
|
uploadUrl: string | null;
|
|
@@ -1026,8 +1026,8 @@ export declare function findSubmissionsByAssignmentForTeacher(assignmentId: stri
|
|
|
1026
1026
|
type: string;
|
|
1027
1027
|
name: string;
|
|
1028
1028
|
id: string;
|
|
1029
|
-
size: number | null;
|
|
1030
1029
|
userId: string | null;
|
|
1030
|
+
size: number | null;
|
|
1031
1031
|
uploadedAt: Date | null;
|
|
1032
1032
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
1033
1033
|
uploadUrl: string | null;
|
|
@@ -1060,8 +1060,8 @@ export declare function findSubmissionsByAssignmentForTeacher(assignmentId: stri
|
|
|
1060
1060
|
};
|
|
1061
1061
|
} & {
|
|
1062
1062
|
id: string;
|
|
1063
|
-
assignmentId: string;
|
|
1064
1063
|
createdAt: Date;
|
|
1064
|
+
assignmentId: string;
|
|
1065
1065
|
modifiedAt: Date;
|
|
1066
1066
|
studentId: string;
|
|
1067
1067
|
extendedResponse: string | null;
|
|
@@ -1127,8 +1127,8 @@ export declare function findSubmissionForTeacherUpdate(submissionId: string, tea
|
|
|
1127
1127
|
type: string;
|
|
1128
1128
|
name: string;
|
|
1129
1129
|
id: string;
|
|
1130
|
-
size: number | null;
|
|
1131
1130
|
userId: string | null;
|
|
1131
|
+
size: number | null;
|
|
1132
1132
|
uploadedAt: Date | null;
|
|
1133
1133
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
1134
1134
|
uploadUrl: string | null;
|
|
@@ -1155,8 +1155,8 @@ export declare function findSubmissionForTeacherUpdate(submissionId: string, tea
|
|
|
1155
1155
|
type: string;
|
|
1156
1156
|
name: string;
|
|
1157
1157
|
id: string;
|
|
1158
|
-
size: number | null;
|
|
1159
1158
|
userId: string | null;
|
|
1159
|
+
size: number | null;
|
|
1160
1160
|
uploadedAt: Date | null;
|
|
1161
1161
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
1162
1162
|
uploadUrl: string | null;
|
|
@@ -1184,8 +1184,8 @@ export declare function findSubmissionForTeacherUpdate(submissionId: string, tea
|
|
|
1184
1184
|
type: string;
|
|
1185
1185
|
name: string;
|
|
1186
1186
|
id: string;
|
|
1187
|
-
size: number | null;
|
|
1188
1187
|
userId: string | null;
|
|
1188
|
+
size: number | null;
|
|
1189
1189
|
uploadedAt: Date | null;
|
|
1190
1190
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
1191
1191
|
uploadUrl: string | null;
|
|
@@ -1212,8 +1212,8 @@ export declare function findSubmissionForTeacherUpdate(submissionId: string, tea
|
|
|
1212
1212
|
type: string;
|
|
1213
1213
|
name: string;
|
|
1214
1214
|
id: string;
|
|
1215
|
-
size: number | null;
|
|
1216
1215
|
userId: string | null;
|
|
1216
|
+
size: number | null;
|
|
1217
1217
|
uploadedAt: Date | null;
|
|
1218
1218
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
1219
1219
|
uploadUrl: string | null;
|
|
@@ -1237,8 +1237,8 @@ export declare function findSubmissionForTeacherUpdate(submissionId: string, tea
|
|
|
1237
1237
|
})[];
|
|
1238
1238
|
} & {
|
|
1239
1239
|
id: string;
|
|
1240
|
-
assignmentId: string;
|
|
1241
1240
|
createdAt: Date;
|
|
1241
|
+
assignmentId: string;
|
|
1242
1242
|
modifiedAt: Date;
|
|
1243
1243
|
studentId: string;
|
|
1244
1244
|
extendedResponse: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assignment.d.ts","sourceRoot":"/","sources":["models/assignment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assignment.d.ts","sourceRoot":"/","sources":["models/assignment.ts"],"names":[],"mappings":"AA8CA,iCAAiC;AACjC,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAI5C;AAED,qDAAqD;AACrD,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAKnD;AAED,uDAAuD;AACvD,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAM7D"}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Assignment model – assignments, submissions, attachments.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
5
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="42061a1a-7f8e-55c4-a836-0e727f41fe0d")}catch(e){}}();
|
|
6
6
|
import { prisma } from "../lib/prisma.js";
|
|
7
|
+
import { classMemberOrSchoolAdminWhere, classTeacherOrSchoolAdminWhere, schoolAdminForClassWhere, } from "./access.js";
|
|
7
8
|
const assignmentGetInclude = {
|
|
8
9
|
submissions: {
|
|
9
10
|
select: {
|
|
@@ -55,7 +56,13 @@ export function findAssignmentWithDetails(id) {
|
|
|
55
56
|
/** @returns Assignment with attachments for delete. */
|
|
56
57
|
export function findAssignmentForDelete(id, teacherId) {
|
|
57
58
|
return prisma.assignment.findFirst({
|
|
58
|
-
where: {
|
|
59
|
+
where: {
|
|
60
|
+
id,
|
|
61
|
+
OR: [
|
|
62
|
+
{ teacherId },
|
|
63
|
+
{ class: schoolAdminForClassWhere(teacherId) },
|
|
64
|
+
],
|
|
65
|
+
},
|
|
59
66
|
include: {
|
|
60
67
|
attachments: { include: { thumbnail: true } },
|
|
61
68
|
submissions: {
|
|
@@ -110,12 +117,7 @@ export function findSubmissionByIdForClassMember(submissionId, classId, userId)
|
|
|
110
117
|
id: submissionId,
|
|
111
118
|
assignment: {
|
|
112
119
|
classId,
|
|
113
|
-
class:
|
|
114
|
-
OR: [
|
|
115
|
-
{ teachers: { some: { id: userId } } },
|
|
116
|
-
{ students: { some: { id: userId } } },
|
|
117
|
-
],
|
|
118
|
-
},
|
|
120
|
+
class: classMemberOrSchoolAdminWhere(userId),
|
|
119
121
|
},
|
|
120
122
|
},
|
|
121
123
|
include: {
|
|
@@ -142,9 +144,7 @@ export function findSubmissionForUpdate(submissionId, userId) {
|
|
|
142
144
|
{ studentId: userId },
|
|
143
145
|
{
|
|
144
146
|
assignment: {
|
|
145
|
-
class:
|
|
146
|
-
teachers: { some: { id: userId } },
|
|
147
|
-
},
|
|
147
|
+
class: classTeacherOrSchoolAdminWhere(userId),
|
|
148
148
|
},
|
|
149
149
|
},
|
|
150
150
|
],
|
|
@@ -195,7 +195,7 @@ export function findAssignmentWithClassForTeacher(assignmentId, teacherId) {
|
|
|
195
195
|
return prisma.assignment.findFirst({
|
|
196
196
|
where: {
|
|
197
197
|
id: assignmentId,
|
|
198
|
-
class:
|
|
198
|
+
class: classTeacherOrSchoolAdminWhere(teacherId),
|
|
199
199
|
},
|
|
200
200
|
include: { class: true },
|
|
201
201
|
});
|
|
@@ -206,7 +206,7 @@ export function findSubmissionsByAssignmentForTeacher(assignmentId, teacherId) {
|
|
|
206
206
|
where: {
|
|
207
207
|
assignment: {
|
|
208
208
|
id: assignmentId,
|
|
209
|
-
class:
|
|
209
|
+
class: classTeacherOrSchoolAdminWhere(teacherId),
|
|
210
210
|
},
|
|
211
211
|
},
|
|
212
212
|
include: {
|
|
@@ -240,7 +240,7 @@ export function findSubmissionForTeacherUpdate(submissionId, teacherId) {
|
|
|
240
240
|
where: {
|
|
241
241
|
id: submissionId,
|
|
242
242
|
assignment: {
|
|
243
|
-
class:
|
|
243
|
+
class: classTeacherOrSchoolAdminWhere(teacherId),
|
|
244
244
|
},
|
|
245
245
|
},
|
|
246
246
|
include: {
|
|
@@ -306,4 +306,4 @@ export function detachAssignmentFromEvent(assignmentId) {
|
|
|
306
306
|
});
|
|
307
307
|
}
|
|
308
308
|
//# sourceMappingURL=assignment.js.map
|
|
309
|
-
//# debugId=
|
|
309
|
+
//# debugId=42061a1a-7f8e-55c4-a836-0e727f41fe0d
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assignment.js","sources":["models/assignment.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Assignment model – assignments, submissions, attachments.\n */\nimport { prisma } from \"../lib/prisma.js\";\n\nconst assignmentGetInclude = {\n submissions: {\n select: {\n student: { select: { id: true, username: true } },\n },\n },\n attachments: {\n select: {\n id: true,\n name: true,\n type: true,\n size: true,\n path: true,\n uploadedAt: true,\n thumbnailId: true,\n },\n },\n section: { select: { id: true, name: true } },\n teacher: { select: { id: true, username: true } },\n worksheets: { select: { id: true, name: true } },\n class: { select: { id: true, name: true } },\n eventAttached: {\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n remarks: true,\n color: true,\n },\n },\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n} as const;\n\n/** @returns Assignment by ID. */\nexport function findAssignmentById(id: string) {\n return prisma.assignment.findUnique({\n where: { id },\n });\n}\n\n/** @returns Assignment with full details for get. */\nexport function findAssignmentWithDetails(id: string) {\n return prisma.assignment.findUnique({\n where: { id },\n include: assignmentGetInclude,\n });\n}\n\n/** @returns Assignment with attachments for delete. */\nexport function findAssignmentForDelete(id: string, teacherId: string) {\n return prisma.assignment.findFirst({\n where: { id, teacherId },\n include: {\n attachments: { include: { thumbnail: true } },\n submissions: {\n include: {\n attachments: { include: { thumbnail: true } },\n annotations: { include: { thumbnail: true } },\n },\n },\n },\n });\n}\n\n/** @returns Assignments due today. */\nexport function findAssignmentsDueToday() {\n return prisma.assignment.findMany({\n where: {\n dueDate: { equals: new Date() },\n },\n select: {\n id: true,\n title: true,\n dueDate: true,\n type: true,\n graded: true,\n maxGrade: true,\n class: { select: { id: true, name: true } },\n },\n });\n}\n\n/** @returns Submission by assignment and student. */\nexport function findSubmissionByAssignmentAndStudent(assignmentId: string, studentId: string) {\n return prisma.submission.findFirst({\n where: { assignmentId, studentId },\n include: {\n attachments: true,\n student: { select: { id: true, username: true, profile: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n worksheets: { select: { id: true, name: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n annotations: true,\n },\n });\n}\n\n/** @returns Submission by ID for class member. */\nexport function findSubmissionByIdForClassMember(submissionId: string, classId: string, userId: string) {\n return prisma.submission.findFirst({\n where: {\n id: submissionId,\n assignment: {\n classId,\n class: {\n OR: [\n { teachers: { some: { id: userId } } },\n { students: { some: { id: userId } } },\n ],\n },\n },\n },\n include: {\n attachments: true,\n annotations: true,\n student: { select: { id: true, username: true, profile: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n worksheets: { select: { id: true, name: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Submission by ID for update (student or teacher). */\nexport function findSubmissionForUpdate(submissionId: string, userId: string) {\n return prisma.submission.findFirst({\n where: {\n id: submissionId,\n OR: [\n { studentId: userId },\n {\n assignment: {\n class: {\n teachers: { some: { id: userId } },\n },\n },\n },\n ],\n },\n include: {\n attachments: { include: { thumbnail: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** Create a submission. */\nexport function createSubmission(assignmentId: string, studentId: string) {\n return prisma.submission.create({\n data: {\n assignment: { connect: { id: assignmentId } },\n student: { connect: { id: studentId } },\n },\n include: {\n attachments: true,\n annotations: true,\n student: { select: { id: true, username: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n worksheets: { select: { id: true, name: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Sections for a class. */\nexport function findSectionsByClassId(classId: string) {\n return prisma.section.findMany({\n where: { classId },\n select: { id: true, name: true },\n });\n}\n\n/** @returns Assignment with class for teacher (auth check). */\nexport function findAssignmentWithClassForTeacher(assignmentId: string, teacherId: string) {\n return prisma.assignment.findFirst({\n where: {\n id: assignmentId,\n class: { teachers: { some: { id: teacherId } } },\n },\n include: { class: true },\n });\n}\n\n/** @returns Submissions for assignment (teacher view). */\nexport function findSubmissionsByAssignmentForTeacher(assignmentId: string, teacherId: string) {\n return prisma.submission.findMany({\n where: {\n assignment: {\n id: assignmentId,\n class: { teachers: { some: { id: teacherId } } },\n },\n },\n include: {\n attachments: { include: { thumbnail: true } },\n student: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n },\n },\n },\n },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Submission by ID for teacher update. */\nexport function findSubmissionForTeacherUpdate(submissionId: string, teacherId: string) {\n return prisma.submission.findFirst({\n where: {\n id: submissionId,\n assignment: {\n class: { teachers: { some: { id: teacherId } } },\n },\n },\n include: {\n attachments: { include: { thumbnail: true } },\n annotations: { include: { thumbnail: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Events in class that don't have this assignment attached. */\nexport function findAvailableEventsForAssignment(classId: string, assignmentId: string) {\n return prisma.event.findMany({\n where: {\n classId,\n assignmentsAttached: { none: { id: assignmentId } },\n },\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n remarks: true,\n color: true,\n },\n orderBy: { startTime: \"asc\" },\n });\n}\n\nconst assignmentAttachEventInclude = {\n attachments: { select: { id: true, name: true, type: true } },\n section: { select: { id: true, name: true } },\n teacher: { select: { id: true, username: true } },\n eventAttached: {\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n color: true,\n },\n },\n};\n\n/** Attach assignment to event. */\nexport function attachAssignmentToEvent(assignmentId: string, eventId: string) {\n return prisma.assignment.update({\n where: { id: assignmentId },\n data: { eventAttached: { connect: { id: eventId } } },\n include: assignmentAttachEventInclude,\n });\n}\n\n/** Detach assignment from event. */\nexport function detachAssignmentFromEvent(assignmentId: string) {\n return prisma.assignment.update({\n where: { id: assignmentId },\n data: { eventAttached: { disconnect: true } },\n include: assignmentAttachEventInclude,\n });\n}\n"],"names":[],"mappings":"AAAA;;GAEG;;;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,MAAM,oBAAoB,GAAG;IAC3B,WAAW,EAAE;QACX,MAAM,EAAE;YACN,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;SAClD;KACF;IACD,WAAW,EAAE;QACX,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,IAAI;SAClB;KACF;IACD,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAC7C,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;IACjD,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAChD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAC3C,aAAa,EAAE;QACb,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,IAAI,EAAE,IAAI;YACV,SAA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E,EAAE,YAAY,EAAE;QAC3B,IAAI,EAAE,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE;QAC7C,OAAO,EAAE,4BAA4B;KACtC,CAAC,CAAC;AACL,CAAC","debug_id":"10c32a4f-1c74-5df0-80e6-79f3cc1525fa"}
|
|
1
|
+
{"version":3,"file":"assignment.js","sources":["models/assignment.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Assignment model – assignments, submissions, attachments.\n */\nimport { prisma } from \"../lib/prisma.js\";\nimport {\n classMemberOrSchoolAdminWhere,\n classTeacherOrSchoolAdminWhere,\n schoolAdminForClassWhere,\n} from \"./access.js\";\n\nconst assignmentGetInclude = {\n submissions: {\n select: {\n student: { select: { id: true, username: true } },\n },\n },\n attachments: {\n select: {\n id: true,\n name: true,\n type: true,\n size: true,\n path: true,\n uploadedAt: true,\n thumbnailId: true,\n },\n },\n section: { select: { id: true, name: true } },\n teacher: { select: { id: true, username: true } },\n worksheets: { select: { id: true, name: true } },\n class: { select: { id: true, name: true } },\n eventAttached: {\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n remarks: true,\n color: true,\n },\n },\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n} as const;\n\n/** @returns Assignment by ID. */\nexport function findAssignmentById(id: string) {\n return prisma.assignment.findUnique({\n where: { id },\n });\n}\n\n/** @returns Assignment with full details for get. */\nexport function findAssignmentWithDetails(id: string) {\n return prisma.assignment.findUnique({\n where: { id },\n include: assignmentGetInclude,\n });\n}\n\n/** @returns Assignment with attachments for delete. */\nexport function findAssignmentForDelete(id: string, teacherId: string) {\n return prisma.assignment.findFirst({\n where: {\n id,\n OR: [\n { teacherId },\n { class: schoolAdminForClassWhere(teacherId) },\n ],\n },\n include: {\n attachments: { include: { thumbnail: true } },\n submissions: {\n include: {\n attachments: { include: { thumbnail: true } },\n annotations: { include: { thumbnail: true } },\n },\n },\n },\n });\n}\n\n/** @returns Assignments due today. */\nexport function findAssignmentsDueToday() {\n return prisma.assignment.findMany({\n where: {\n dueDate: { equals: new Date() },\n },\n select: {\n id: true,\n title: true,\n dueDate: true,\n type: true,\n graded: true,\n maxGrade: true,\n class: { select: { id: true, name: true } },\n },\n });\n}\n\n/** @returns Submission by assignment and student. */\nexport function findSubmissionByAssignmentAndStudent(assignmentId: string, studentId: string) {\n return prisma.submission.findFirst({\n where: { assignmentId, studentId },\n include: {\n attachments: true,\n student: { select: { id: true, username: true, profile: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n worksheets: { select: { id: true, name: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n annotations: true,\n },\n });\n}\n\n/** @returns Submission by ID for class member. */\nexport function findSubmissionByIdForClassMember(submissionId: string, classId: string, userId: string) {\n return prisma.submission.findFirst({\n where: {\n id: submissionId,\n assignment: {\n classId,\n class: classMemberOrSchoolAdminWhere(userId),\n },\n },\n include: {\n attachments: true,\n annotations: true,\n student: { select: { id: true, username: true, profile: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n worksheets: { select: { id: true, name: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Submission by ID for update (student or teacher). */\nexport function findSubmissionForUpdate(submissionId: string, userId: string) {\n return prisma.submission.findFirst({\n where: {\n id: submissionId,\n OR: [\n { studentId: userId },\n {\n assignment: {\n class: classTeacherOrSchoolAdminWhere(userId),\n },\n },\n ],\n },\n include: {\n attachments: { include: { thumbnail: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** Create a submission. */\nexport function createSubmission(assignmentId: string, studentId: string) {\n return prisma.submission.create({\n data: {\n assignment: { connect: { id: assignmentId } },\n student: { connect: { id: studentId } },\n },\n include: {\n attachments: true,\n annotations: true,\n student: { select: { id: true, username: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n worksheets: { select: { id: true, name: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Sections for a class. */\nexport function findSectionsByClassId(classId: string) {\n return prisma.section.findMany({\n where: { classId },\n select: { id: true, name: true },\n });\n}\n\n/** @returns Assignment with class for teacher (auth check). */\nexport function findAssignmentWithClassForTeacher(assignmentId: string, teacherId: string) {\n return prisma.assignment.findFirst({\n where: {\n id: assignmentId,\n class: classTeacherOrSchoolAdminWhere(teacherId),\n },\n include: { class: true },\n });\n}\n\n/** @returns Submissions for assignment (teacher view). */\nexport function findSubmissionsByAssignmentForTeacher(assignmentId: string, teacherId: string) {\n return prisma.submission.findMany({\n where: {\n assignment: {\n id: assignmentId,\n class: classTeacherOrSchoolAdminWhere(teacherId),\n },\n },\n include: {\n attachments: { include: { thumbnail: true } },\n student: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n },\n },\n },\n },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Submission by ID for teacher update. */\nexport function findSubmissionForTeacherUpdate(submissionId: string, teacherId: string) {\n return prisma.submission.findFirst({\n where: {\n id: submissionId,\n assignment: {\n class: classTeacherOrSchoolAdminWhere(teacherId),\n },\n },\n include: {\n attachments: { include: { thumbnail: true } },\n annotations: { include: { thumbnail: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Events in class that don't have this assignment attached. */\nexport function findAvailableEventsForAssignment(classId: string, assignmentId: string) {\n return prisma.event.findMany({\n where: {\n classId,\n assignmentsAttached: { none: { id: assignmentId } },\n },\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n remarks: true,\n color: true,\n },\n orderBy: { startTime: \"asc\" },\n });\n}\n\nconst assignmentAttachEventInclude = {\n attachments: { select: { id: true, name: true, type: true } },\n section: { select: { id: true, name: true } },\n teacher: { select: { id: true, username: true } },\n eventAttached: {\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n color: true,\n },\n },\n};\n\n/** Attach assignment to event. */\nexport function attachAssignmentToEvent(assignmentId: string, eventId: string) {\n return prisma.assignment.update({\n where: { id: assignmentId },\n data: { eventAttached: { connect: { id: eventId } } },\n include: assignmentAttachEventInclude,\n });\n}\n\n/** Detach assignment from event. */\nexport function detachAssignmentFromEvent(assignmentId: string) {\n return prisma.assignment.update({\n where: { id: assignmentId },\n data: { eventAttached: { disconnect: true } },\n include: assignmentAttachEventInclude,\n });\n}\n"],"names":[],"mappings":"AAAA;;GAEG;;;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,EAC9B,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB,MAAM,oBAAoB,GAAG;IAC3B,WAAW,EAAE;QACX,MAAM,EAAE;YACN,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;SAClD;KACF;IACD,WAAW,EAAE;QACX,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,IAAI;SAClB;KACF;IACD,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAC7C,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;IACjD,UAA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C3B,IAAI,EAAE,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE;QAC7C,OAAO,EAAE,4BAA4B;KACtC,CAAC,CAAC;AACL,CAAC","debug_id":"42061a1a-7f8e-55c4-a836-0e727f41fe0d"}
|
|
@@ -20,7 +20,7 @@ export declare function findClassWithStudents(classId: string): import(".prisma/
|
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
}>;
|
|
23
|
-
/** @returns Class if user is a teacher. */
|
|
23
|
+
/** @returns Class if user is a teacher or school admin. */
|
|
24
24
|
export declare function findClassWithTeacher(classId: string, teacherId: string): import(".prisma/client").Prisma.Prisma__ClassClient<{
|
|
25
25
|
name: string;
|
|
26
26
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attendance.d.ts","sourceRoot":"/","sources":["models/attendance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"attendance.d.ts","sourceRoot":"/","sources":["models/attendance.ts"],"names":[],"mappings":"AAkFA,mDAAmD;AACnD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;GAuBpD;AAED,2DAA2D;AAC3D,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;;;;;;;;GAOtE;AAED,mCAAmC;AACnC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM;;;;;;;;;;KAIlD;AAED,+CAA+C;AAC/C,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM;;;;;;;;;;;GAItD;AAED,4EAA4E;AAC5E,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;;;;;;;;;;;GAOpF;AAED,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MASnE;AAED,mCAAmC;AACnC,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgBA;AAED,8CAA8C;AAC9C,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;;;;;;;;;;;GAQA;AAED,mDAAmD;AACnD,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAWvE"}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Attendance model – attendance records, present/late/absent students per event.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
5
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="311ac412-3d37-5b5d-9c46-79a70ef935e2")}catch(e){}}();
|
|
6
6
|
import { prisma } from "../lib/prisma.js";
|
|
7
|
+
import { classTeacherOrSchoolAdminWhere } from "./access.js";
|
|
7
8
|
const attendanceInclude = {
|
|
8
9
|
event: {
|
|
9
10
|
select: {
|
|
@@ -103,12 +104,12 @@ export function findClassWithStudents(classId) {
|
|
|
103
104
|
},
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
|
-
/** @returns Class if user is a teacher. */
|
|
107
|
+
/** @returns Class if user is a teacher or school admin. */
|
|
107
108
|
export function findClassWithTeacher(classId, teacherId) {
|
|
108
|
-
return prisma.class.
|
|
109
|
+
return prisma.class.findFirst({
|
|
109
110
|
where: {
|
|
110
111
|
id: classId,
|
|
111
|
-
|
|
112
|
+
...classTeacherOrSchoolAdminWhere(teacherId),
|
|
112
113
|
},
|
|
113
114
|
});
|
|
114
115
|
}
|
|
@@ -185,4 +186,4 @@ export function updateAttendance(id, data) {
|
|
|
185
186
|
});
|
|
186
187
|
}
|
|
187
188
|
//# sourceMappingURL=attendance.js.map
|
|
188
|
-
//# debugId=
|
|
189
|
+
//# debugId=311ac412-3d37-5b5d-9c46-79a70ef935e2
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attendance.js","sources":["models/attendance.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Attendance model – attendance records, present/late/absent students per event.\n */\nimport { prisma } from \"../lib/prisma.js\";\n\nconst attendanceInclude = {\n event: {\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n color: true,\n },\n },\n present: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n bio: true,\n location: true,\n website: true,\n },\n },\n },\n },\n late: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n bio: true,\n location: true,\n website: true,\n },\n },\n },\n },\n absent: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n bio: true,\n location: true,\n website: true,\n },\n },\n },\n },\n} as const;\n\nconst attendanceUpdateInclude = {\n event: {\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n },\n },\n present: { select: { id: true, username: true } },\n late: { select: { id: true, username: true } },\n absent: { select: { id: true, username: true } },\n} as const;\n\n/** @returns Class with students for attendance. */\nexport function findClassWithStudents(classId: string) {\n return prisma.class.findUnique({\n where: { id: classId },\n select: {\n id: true,\n students: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n bio: true,\n location: true,\n website: true,\n },\n },\n },\n },\n },\n });\n}\n\n/** @returns Class if user is a teacher. */\nexport function findClassWithTeacher(classId: string, teacherId: string) {\n return prisma.class.
|
|
1
|
+
{"version":3,"file":"attendance.js","sources":["models/attendance.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Attendance model – attendance records, present/late/absent students per event.\n */\nimport { prisma } from \"../lib/prisma.js\";\nimport { classTeacherOrSchoolAdminWhere } from \"./access.js\";\n\nconst attendanceInclude = {\n event: {\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n color: true,\n },\n },\n present: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n bio: true,\n location: true,\n website: true,\n },\n },\n },\n },\n late: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n bio: true,\n location: true,\n website: true,\n },\n },\n },\n },\n absent: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n bio: true,\n location: true,\n website: true,\n },\n },\n },\n },\n} as const;\n\nconst attendanceUpdateInclude = {\n event: {\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n },\n },\n present: { select: { id: true, username: true } },\n late: { select: { id: true, username: true } },\n absent: { select: { id: true, username: true } },\n} as const;\n\n/** @returns Class with students for attendance. */\nexport function findClassWithStudents(classId: string) {\n return prisma.class.findUnique({\n where: { id: classId },\n select: {\n id: true,\n students: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n bio: true,\n location: true,\n website: true,\n },\n },\n },\n },\n },\n });\n}\n\n/** @returns Class if user is a teacher or school admin. */\nexport function findClassWithTeacher(classId: string, teacherId: string) {\n return prisma.class.findFirst({\n where: {\n id: classId,\n ...classTeacherOrSchoolAdminWhere(teacherId),\n },\n });\n}\n\n/** @returns Events for a class. */\nexport function findEventsByClassId(classId: string) {\n return prisma.event.findMany({\n where: { classId },\n });\n}\n\n/** @returns Attendance record for an event. */\nexport function findAttendanceByEventId(eventId: string) {\n return prisma.attendance.findFirst({\n where: { eventId },\n });\n}\n\n/** @returns Attendance for class and event (eventId null = class-level). */\nexport function findAttendanceByClassAndEvent(classId: string, eventId: string | null) {\n return prisma.attendance.findFirst({\n where: {\n classId,\n eventId,\n },\n });\n}\n\n/** @returns Attendance records for class, optionally filtered by event. */\nexport function findManyAttendance(classId: string, eventId?: string) {\n return prisma.attendance.findMany({\n where: {\n classId,\n ...(eventId ? { eventId } : {}),\n },\n include: attendanceInclude,\n orderBy: { date: \"desc\" },\n });\n}\n\n/** Create an attendance record. */\nexport function createAttendance(data: {\n classId: string;\n eventId?: string | null;\n presentIds: string[];\n lateIds?: string[];\n absentIds?: string[];\n}) {\n return prisma.attendance.create({\n data: {\n classId: data.classId,\n eventId: data.eventId ?? undefined,\n date: new Date(),\n present: { connect: data.presentIds.map((id) => ({ id })) },\n late: data.lateIds?.length\n ? { connect: data.lateIds.map((id) => ({ id })) }\n : undefined,\n absent: data.absentIds?.length\n ? { connect: data.absentIds.map((id) => ({ id })) }\n : undefined,\n },\n include: attendanceUpdateInclude,\n });\n}\n\n/** Create attendance for a specific event. */\nexport function createAttendanceForEvent(data: {\n classId: string;\n eventId: string;\n presentIds: string[];\n}) {\n return prisma.attendance.create({\n data: {\n class: { connect: { id: data.classId } },\n event: { connect: { id: data.eventId } },\n present: { connect: data.presentIds.map((id) => ({ id })) },\n },\n });\n}\n\n/** Update attendance present/late/absent lists. */\nexport function updateAttendance(\n id: string,\n data: { presentIds: string[]; lateIds: string[]; absentIds: string[] }\n) {\n return prisma.attendance.update({\n where: { id },\n data: {\n present: { set: data.presentIds.map((id) => ({ id })) },\n late: { set: data.lateIds.map((id) => ({ id })) },\n absent: { set: data.absentIds.map((id) => ({ id })) },\n },\n include: attendanceUpdateInclude,\n });\n}\n"],"names":[],"mappings":"AAAA;;GAEG;;;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,iBAAiB,GAAG;IACxB,KAAK,EAAE;QACL,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,IAAI,EAAE,IAAI;YACV,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,IAAI;SACZ;KACF;IACD,OAAO,EAAE;QACP,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,MAAM,EAAE;oBACN,WAAW,EAAE,IAAI;oBACjB,cAAc,EAAE,IAAI;oBACpB,uBAAuB,EAAE,IAAI;oBAC7B,GAAG,EAAE,IAAI;oBACT,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,IAAI;iBACd;aACF;SACF;KACF;IACD,IAAI,EAAE;QACJ,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,MAAM,EAAE;oBACN,WAAW,EAAE,IAAI;oBACjB,cAAc,EAAE,IAAI;oBACpB,uBAAuB,EAAE,IAAI;oBAC7B,GAAG,EAAE,IAAI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AAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE;SAC5D;KACF,CAAC,CAAC;AACL,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,gBAAgB,CAC9B,EAAU,EACV,IAAsE;IAEtE,OAAO,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;QAC9B,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,IAAI,EAAE;YACJ,OAAO,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE;YACvD,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE;YACjD,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE;SACtD;QACD,OAAO,EAAE,uBAAuB;KACjC,CAAC,CAAC;AACL,CAAC","debug_id":"311ac412-3d37-5b5d-9c46-79a70ef935e2"}
|
package/dist/models/auth.d.ts
CHANGED
|
@@ -95,8 +95,8 @@ export declare function createSession(data: {
|
|
|
95
95
|
}): import(".prisma/client").Prisma.Prisma__SessionClient<{
|
|
96
96
|
type: import(".prisma/client").$Enums.SessionType;
|
|
97
97
|
id: string;
|
|
98
|
-
userId: string | null;
|
|
99
98
|
createdAt: Date | null;
|
|
99
|
+
userId: string | null;
|
|
100
100
|
expiresAt: Date | null;
|
|
101
101
|
classId: string | null;
|
|
102
102
|
}, never, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
@@ -130,8 +130,8 @@ export declare function deleteUserById(id: string): import(".prisma/client").Pri
|
|
|
130
130
|
export declare function findSessionByIdAndType(id: string, type: SessionType): import(".prisma/client").Prisma.Prisma__SessionClient<{
|
|
131
131
|
type: import(".prisma/client").$Enums.SessionType;
|
|
132
132
|
id: string;
|
|
133
|
-
userId: string | null;
|
|
134
133
|
createdAt: Date | null;
|
|
134
|
+
userId: string | null;
|
|
135
135
|
expiresAt: Date | null;
|
|
136
136
|
classId: string | null;
|
|
137
137
|
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
@@ -149,8 +149,8 @@ export declare function findSessionByIdWithUserAndType(id: string, type: Session
|
|
|
149
149
|
} & {
|
|
150
150
|
type: import(".prisma/client").$Enums.SessionType;
|
|
151
151
|
id: string;
|
|
152
|
-
userId: string | null;
|
|
153
152
|
createdAt: Date | null;
|
|
153
|
+
userId: string | null;
|
|
154
154
|
expiresAt: Date | null;
|
|
155
155
|
classId: string | null;
|
|
156
156
|
}) | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
@@ -196,8 +196,8 @@ export declare function updateUserPassword(userId: string, password: string): im
|
|
|
196
196
|
export declare function deleteSessionById(id: string): Promise<{
|
|
197
197
|
type: import(".prisma/client").$Enums.SessionType;
|
|
198
198
|
id: string;
|
|
199
|
-
userId: string | null;
|
|
200
199
|
createdAt: Date | null;
|
|
200
|
+
userId: string | null;
|
|
201
201
|
expiresAt: Date | null;
|
|
202
202
|
classId: string | null;
|
|
203
203
|
}>;
|
|
@@ -223,7 +223,7 @@ export declare function findClassWithMember(classId: string, userId: string): im
|
|
|
223
223
|
};
|
|
224
224
|
};
|
|
225
225
|
}>;
|
|
226
|
-
/** @returns Class if user is a teacher. */
|
|
226
|
+
/** @returns Class if user is a teacher or school admin. */
|
|
227
227
|
export declare function findClassWithTeacher(classId: string, teacherId: string): import(".prisma/client").Prisma.Prisma__ClassClient<{
|
|
228
228
|
name: string;
|
|
229
229
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"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