@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
package/dist/services/class.d.ts
CHANGED
|
@@ -74,6 +74,11 @@ export declare function getClass(userId: string, classId: string): Promise<{
|
|
|
74
74
|
returned: boolean | null | undefined;
|
|
75
75
|
type: import(".prisma/client").$Enums.AssignmentType;
|
|
76
76
|
id: string;
|
|
77
|
+
createdAt: Date | null;
|
|
78
|
+
section: {
|
|
79
|
+
name: string;
|
|
80
|
+
id: string;
|
|
81
|
+
} | null;
|
|
77
82
|
submissions: {
|
|
78
83
|
id: string;
|
|
79
84
|
studentId: string;
|
|
@@ -84,11 +89,6 @@ export declare function getClass(userId: string, classId: string): Promise<{
|
|
|
84
89
|
submitted: boolean | null;
|
|
85
90
|
returned: boolean | null;
|
|
86
91
|
}[];
|
|
87
|
-
section: {
|
|
88
|
-
name: string;
|
|
89
|
-
id: string;
|
|
90
|
-
} | null;
|
|
91
|
-
createdAt: Date | null;
|
|
92
92
|
title: string;
|
|
93
93
|
instructions: string;
|
|
94
94
|
dueDate: Date;
|
|
@@ -121,7 +121,7 @@ export declare function getClass(userId: string, classId: string): Promise<{
|
|
|
121
121
|
} | null;
|
|
122
122
|
};
|
|
123
123
|
}[];
|
|
124
|
-
|
|
124
|
+
teachers: {
|
|
125
125
|
id: string;
|
|
126
126
|
username: string;
|
|
127
127
|
profile: {
|
|
@@ -130,7 +130,7 @@ export declare function getClass(userId: string, classId: string): Promise<{
|
|
|
130
130
|
profilePictureThumbnail: string | null;
|
|
131
131
|
} | null;
|
|
132
132
|
}[];
|
|
133
|
-
|
|
133
|
+
students: {
|
|
134
134
|
id: string;
|
|
135
135
|
username: string;
|
|
136
136
|
profile: {
|
|
@@ -167,6 +167,7 @@ export declare function createClass(userId: string, input: {
|
|
|
167
167
|
section: string;
|
|
168
168
|
subject: string;
|
|
169
169
|
color?: string;
|
|
170
|
+
schoolId?: string;
|
|
170
171
|
}): Promise<{
|
|
171
172
|
name: string;
|
|
172
173
|
id: string;
|
|
@@ -258,8 +259,8 @@ export declare function getGrades(userId: string, classId: string, targetUserId:
|
|
|
258
259
|
};
|
|
259
260
|
} & {
|
|
260
261
|
id: string;
|
|
261
|
-
assignmentId: string;
|
|
262
262
|
createdAt: Date;
|
|
263
|
+
assignmentId: string;
|
|
263
264
|
modifiedAt: Date;
|
|
264
265
|
studentId: string;
|
|
265
266
|
extendedResponse: string | null;
|
|
@@ -283,8 +284,8 @@ export declare function updateGrade(assignmentId: string, submissionId: string,
|
|
|
283
284
|
};
|
|
284
285
|
} & {
|
|
285
286
|
id: string;
|
|
286
|
-
assignmentId: string;
|
|
287
287
|
createdAt: Date;
|
|
288
|
+
assignmentId: string;
|
|
288
289
|
modifiedAt: Date;
|
|
289
290
|
studentId: string;
|
|
290
291
|
extendedResponse: string | null;
|
|
@@ -523,13 +524,13 @@ export declare function getFiles(classId: string): Promise<{
|
|
|
523
524
|
type: string;
|
|
524
525
|
name: string;
|
|
525
526
|
id: string;
|
|
526
|
-
size: number | null;
|
|
527
|
-
uploadedAt: Date | null;
|
|
528
|
-
thumbnailId: string | null;
|
|
529
527
|
user: {
|
|
530
528
|
id: string;
|
|
531
529
|
username: string;
|
|
532
530
|
} | null;
|
|
531
|
+
size: number | null;
|
|
532
|
+
uploadedAt: Date | null;
|
|
533
|
+
thumbnailId: string | null;
|
|
533
534
|
}[];
|
|
534
535
|
students: {
|
|
535
536
|
id: string;
|
|
@@ -539,26 +540,26 @@ export declare function getFiles(classId: string): Promise<{
|
|
|
539
540
|
type: string;
|
|
540
541
|
name: string;
|
|
541
542
|
id: string;
|
|
542
|
-
size: number | null;
|
|
543
|
-
uploadedAt: Date | null;
|
|
544
|
-
thumbnailId: string | null;
|
|
545
543
|
user: {
|
|
546
544
|
id: string;
|
|
547
545
|
username: string;
|
|
548
546
|
} | null;
|
|
547
|
+
size: number | null;
|
|
548
|
+
uploadedAt: Date | null;
|
|
549
|
+
thumbnailId: string | null;
|
|
549
550
|
}[];
|
|
550
551
|
annotations: {
|
|
551
552
|
path: string;
|
|
552
553
|
type: string;
|
|
553
554
|
name: string;
|
|
554
555
|
id: string;
|
|
555
|
-
size: number | null;
|
|
556
|
-
uploadedAt: Date | null;
|
|
557
|
-
thumbnailId: string | null;
|
|
558
556
|
user: {
|
|
559
557
|
id: string;
|
|
560
558
|
username: string;
|
|
561
559
|
} | null;
|
|
560
|
+
size: number | null;
|
|
561
|
+
uploadedAt: Date | null;
|
|
562
|
+
thumbnailId: string | null;
|
|
562
563
|
}[];
|
|
563
564
|
}[];
|
|
564
565
|
}[]>;
|
|
@@ -567,11 +568,11 @@ export declare function exportClass(classId: string, userId: string): Promise<{
|
|
|
567
568
|
assignments: {
|
|
568
569
|
type: import(".prisma/client").$Enums.AssignmentType;
|
|
569
570
|
id: string;
|
|
571
|
+
createdAt: Date | null;
|
|
570
572
|
section: {
|
|
571
573
|
name: string;
|
|
572
574
|
id: string;
|
|
573
575
|
} | null;
|
|
574
|
-
createdAt: Date | null;
|
|
575
576
|
classId: string;
|
|
576
577
|
title: string;
|
|
577
578
|
instructions: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.d.ts","sourceRoot":"/","sources":["services/class.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"class.d.ts","sourceRoot":"/","sources":["services/class.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE/C,sFAAsF;AACtF,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BjD;AAED,0EAA0E;AAC1E,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkC7D;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;GAa5D;AAED,wBAAsB,WAAW,CAC/B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE;IACL,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;;;;;;;;GAgDF;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM;;;;GAchD;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;;;;;GAoBlE;AAED,wBAAsB,UAAU,CAC9B,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AE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE;IACL,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;;;;;;;;;;;;;;;;;;;;;;;;;GA6BF;AAED,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAc7C;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAUhE;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,GAAG;IAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,mBAmBhI"}
|
package/dist/services/class.js
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
* syllabus, lab drafts, and invite codes.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
!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]="
|
|
6
|
+
!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]="c5ccb222-b8b2-53d6-9959-bb2ae34ed195")}catch(e){}}();
|
|
7
7
|
import { SessionType } from "@prisma/client";
|
|
8
8
|
import { TRPCError } from "@trpc/server";
|
|
9
9
|
import { prisma } from "../lib/prisma.js";
|
|
10
10
|
import { generateInviteCode } from "../utils/generateInviteCode.js";
|
|
11
11
|
import { findTeacherClasses, findStudentClasses, isTeacherInClass, findClassWithAssignments, findSectionsByClassId, findUserById, findSessionByClassCode, findSessionByClassId, findSubmissionsForGrades, findEventsByClassId, findMarkSchemesByClassId, findGradingBoundariesByClassId, findClassSyllabus, findLabDraftsByClass, findAssignmentsWithFiles, findFullExportableClass, createClassByImport, } from "../models/class.js";
|
|
12
|
+
import { listUserSchoolMemberships } from "../models/school.js";
|
|
12
13
|
/** Get all classes where user is teacher or student, with assignments and members. */
|
|
13
14
|
export async function getAllClasses(userId) {
|
|
14
15
|
const [teacherClasses, studentClasses] = await Promise.all([
|
|
@@ -79,7 +80,23 @@ export async function updateClass(classId, data) {
|
|
|
79
80
|
return { updatedClass };
|
|
80
81
|
}
|
|
81
82
|
export async function createClass(userId, input) {
|
|
82
|
-
const { students, teachers, name, section, subject, color } = input;
|
|
83
|
+
const { students, teachers, name, section, subject, color, schoolId } = input;
|
|
84
|
+
if (schoolId) {
|
|
85
|
+
const memberships = await listUserSchoolMemberships(userId);
|
|
86
|
+
const membership = memberships.find((item) => item.schoolId === schoolId);
|
|
87
|
+
if (!membership) {
|
|
88
|
+
throw new TRPCError({
|
|
89
|
+
code: "FORBIDDEN",
|
|
90
|
+
message: "You are not a member of this school",
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (membership.role === "STUDENT") {
|
|
94
|
+
throw new TRPCError({
|
|
95
|
+
code: "FORBIDDEN",
|
|
96
|
+
message: "Students cannot create school classes",
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
83
100
|
if (teachers && teachers.length > 0 && students && students.length > 0) {
|
|
84
101
|
return prisma.class.create({
|
|
85
102
|
data: {
|
|
@@ -87,6 +104,7 @@ export async function createClass(userId, input) {
|
|
|
87
104
|
section,
|
|
88
105
|
subject,
|
|
89
106
|
color,
|
|
107
|
+
schoolId,
|
|
90
108
|
teachers: { connect: teachers.map((id) => ({ id })) },
|
|
91
109
|
students: { connect: students.map((id) => ({ id })) },
|
|
92
110
|
},
|
|
@@ -99,6 +117,7 @@ export async function createClass(userId, input) {
|
|
|
99
117
|
section,
|
|
100
118
|
subject,
|
|
101
119
|
color,
|
|
120
|
+
schoolId,
|
|
102
121
|
teachers: { connect: { id: userId } },
|
|
103
122
|
},
|
|
104
123
|
});
|
|
@@ -486,4 +505,4 @@ export async function importClass(classId, userId, year, classData) {
|
|
|
486
505
|
}
|
|
487
506
|
}
|
|
488
507
|
//# sourceMappingURL=class.js.map
|
|
489
|
-
//# debugId=
|
|
508
|
+
//# debugId=c5ccb222-b8b2-53d6-9959-bb2ae34ed195
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.js","sources":["services/class.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Class service – CRUD for classes, members, grades, mark schemes, grading boundaries,\n * syllabus, lab drafts, and invite codes.\n */\nimport { SessionType } from \"@prisma/client\";\nimport { TRPCError } from \"@trpc/server\";\nimport { prisma } from \"../lib/prisma.js\";\nimport { generateInviteCode } from \"../utils/generateInviteCode.js\";\nimport {\n findTeacherClasses,\n findStudentClasses,\n isTeacherInClass,\n findClassWithAssignments,\n findSectionsByClassId,\n findUserById,\n findSessionByClassCode,\n findSessionByClassId,\n findSubmissionsForGrades,\n findEventsByClassId,\n findMarkSchemesByClassId,\n findGradingBoundariesByClassId,\n findClassSyllabus,\n findLabDraftsByClass,\n findAssignmentsWithFiles,\n findFullExportableClass,\n createClassByImport,\n} from \"../models/class.js\";\nimport { Class, Folder } from \"@prisma/client\";\n\n/** Get all classes where user is teacher or student, with assignments and members. */\nexport async function getAllClasses(userId: string) {\n const [teacherClasses, studentClasses] = await Promise.all([\n findTeacherClasses(userId),\n findStudentClasses(userId),\n ]);\n\n return {\n teacherInClass: teacherClasses.map((cls) => ({\n id: cls.id,\n name: cls.name,\n section: cls.section,\n subject: cls.subject,\n dueToday: cls.assignments,\n assignments: cls.assignments,\n members: [...cls.students, ...cls.teachers],\n color: cls.color,\n })),\n studentInClass: studentClasses.map((cls) => ({\n id: cls.id,\n name: cls.name,\n section: cls.section,\n subject: cls.subject,\n dueToday: cls.assignments,\n assignments: cls.assignments,\n members: [...cls.students, ...cls.teachers],\n color: cls.color,\n })),\n };\n}\n\n/** Get single class with assignments, sections, and submission status. */\nexport async function getClass(userId: string, classId: string) {\n const isTeacher = await isTeacherInClass(classId, userId ?? \"\");\n\n const classData = await findClassWithAssignments(classId, {\n isTeacher: !!isTeacher,\n userId: userId ?? undefined,\n });\n\n if (!classData) {\n throw new Error(\"Class not found\");\n }\n\n const formattedClassData = {\n ...classData,\n assignments: classData.assignments.map((assignment) => ({\n ...assignment,\n late: assignment.dueDate < new Date(),\n submitted: assignment.submissions.find(\n (s) => s.studentId === userId\n )?.submitted,\n returned: assignment.submissions.find(\n (s) => s.studentId === userId\n )?.returned,\n })),\n };\n\n const sections = await findSectionsByClassId(classId);\n\n return {\n class: {\n ...formattedClassData,\n sections,\n },\n };\n}\n\nexport async function updateClass(\n classId: string,\n data: { name?: string; section?: string; subject?: string }\n) {\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data,\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n },\n });\n return { updatedClass };\n}\n\nexport async function createClass(\n userId: string,\n input: {\n students?: string[];\n teachers?: string[];\n name: string;\n section: string;\n subject: string;\n color?: string;\n }\n) {\n const { students, teachers, name, section, subject, color } = input;\n\n if (teachers && teachers.length > 0 && students && students.length > 0) {\n return prisma.class.create({\n data: {\n name,\n section,\n subject,\n color,\n teachers: { connect: teachers.map((id) => ({ id })) },\n students: { connect: students.map((id) => ({ id })) },\n },\n include: { teachers: true, students: true },\n });\n }\n\n return prisma.class.create({\n data: {\n name,\n section,\n subject,\n color,\n teachers: { connect: { id: userId } },\n },\n });\n}\n\nexport async function deleteClass(classId: string) {\n const classToDelete = await prisma.class.findFirst({\n where: { id: classId },\n });\n\n if (!classToDelete) {\n throw new Error(\"Class not found or you don't have permission to delete it\");\n }\n\n await prisma.class.delete({\n where: { id: classId },\n });\n\n return { deletedClass: { id: classId } };\n}\n\nexport async function addStudent(classId: string, studentId: string) {\n const student = await findUserById(studentId);\n if (!student) {\n throw new Error(\"Student not found\");\n }\n\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data: {\n students: { connect: { id: studentId } },\n },\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n },\n });\n\n return { updatedClass, newStudent: student };\n}\n\nexport async function changeRole(\n classId: string,\n userId: string,\n type: \"teacher\" | \"student\"\n) {\n const user = await findUserById(userId);\n if (!user) {\n throw new Error(\"User not found\");\n }\n\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data: {\n [type === \"teacher\" ? \"teachers\" : \"students\"]: {\n connect: { id: userId },\n },\n [type === \"teacher\" ? \"students\" : \"teachers\"]: {\n disconnect: { id: userId },\n },\n },\n });\n\n return {\n updatedClass,\n user: { ...user, type },\n };\n}\n\nexport async function removeMember(classId: string, userId: string) {\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data: {\n teachers: { disconnect: { id: userId } },\n students: { disconnect: { id: userId } },\n },\n });\n return { updatedClass, removedUserId: userId };\n}\n\nexport async function leaveClass(userId: string, classId: string) {\n const classData = await prisma.class.findFirst({\n where: {\n id: classId,\n students: { some: { id: userId } },\n },\n });\n\n if (!classData) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Class not found or you are not a student in this class\",\n });\n }\n\n await prisma.class.update({\n where: { id: classId },\n data: {\n students: { disconnect: { id: userId } },\n },\n });\n\n return { success: true, leftClassId: classId };\n}\n\nexport async function joinClass(userId: string, classCode: string) {\n const session = await findSessionByClassCode(classCode);\n\n if (!session || !session.classId) {\n throw new Error(\"Class not found\");\n }\n\n if (session.expiresAt && session.expiresAt < new Date()) {\n throw new Error(\"Session expired\");\n }\n\n const updatedClass = await prisma.class.update({\n where: { id: session.classId },\n data: {\n students: { connect: { id: userId } },\n },\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n },\n });\n\n return { joinedClass: updatedClass };\n}\n\nexport async function getInviteCode(classId: string) {\n const session = await findSessionByClassId(classId);\n\n if ((session?.expiresAt && session.expiresAt < new Date()) || !session) {\n const newSession = await prisma.session.create({\n data: {\n id: generateInviteCode(),\n classId,\n type: SessionType.CLASS_INVITE,\n expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000),\n },\n });\n return { code: newSession.id };\n }\n\n return { code: session?.id };\n}\n\nexport async function createInviteCode(classId: string) {\n await prisma.session.deleteMany({\n where: { classId, type: SessionType.CLASS_INVITE },\n });\n\n const session = await prisma.session.create({\n data: {\n id: generateInviteCode(),\n classId,\n type: SessionType.CLASS_INVITE,\n expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000),\n },\n });\n\n return { code: session.id };\n}\n\nexport async function getGrades(\n userId: string,\n classId: string,\n targetUserId: string\n) {\n const isTeacher = await isTeacherInClass(classId, userId);\n if (userId !== targetUserId && !isTeacher) {\n throw new TRPCError({\n code: \"UNAUTHORIZED\",\n message: \"You can only view your own grades\",\n });\n }\n\n const grades = await findSubmissionsForGrades(targetUserId, classId);\n return { grades };\n}\n\nexport async function updateGrade(\n assignmentId: string,\n submissionId: string,\n gradeReceived: number | null\n) {\n const updatedSubmission = await prisma.submission.update({\n where: { id: submissionId, assignmentId },\n data: { gradeReceived },\n include: {\n assignment: {\n select: {\n id: true,\n title: true,\n maxGrade: true,\n weight: true,\n },\n },\n },\n });\n return updatedSubmission;\n}\n\nexport async function getEvents(classId: string) {\n return findEventsByClassId(classId);\n}\n\nexport async function listMarkSchemes(classId: string) {\n return findMarkSchemesByClassId(classId);\n}\n\nexport async function createMarkScheme(classId: string, structure: string) {\n const validatedStructure = structure.replace(/\\\\n/g, \"\\n\");\n return prisma.markScheme.create({\n data: {\n class: { connect: { id: classId } },\n structured: validatedStructure,\n },\n });\n}\n\nexport async function updateMarkScheme(\n markSchemeId: string,\n classId: string,\n structure: string\n) {\n const validatedStructure = structure.replace(/\\\\n/g, \"\\n\");\n return prisma.markScheme.update({\n where: { id: markSchemeId },\n data: {\n class: { connect: { id: classId } },\n structured: validatedStructure,\n },\n });\n}\n\nexport async function deleteMarkScheme(markSchemeId: string) {\n return prisma.markScheme.delete({\n where: { id: markSchemeId },\n });\n}\n\nexport async function listGradingBoundaries(classId: string) {\n return findGradingBoundariesByClassId(classId);\n}\n\nexport async function createGradingBoundary(classId: string, structure: string) {\n const validatedStructure = structure.replace(/\\\\n/g, \"\\n\");\n return prisma.gradingBoundary.create({\n data: {\n class: { connect: { id: classId } },\n structured: validatedStructure,\n },\n });\n}\n\nexport async function updateGradingBoundary(\n gradingBoundaryId: string,\n classId: string,\n structure: string\n) {\n const validatedStructure = structure.replace(/\\\\n/g, \"\\n\");\n return prisma.gradingBoundary.update({\n where: { id: gradingBoundaryId },\n data: {\n class: { connect: { id: classId } },\n structured: validatedStructure,\n },\n });\n}\n\nexport async function deleteGradingBoundary(gradingBoundaryId: string) {\n return prisma.gradingBoundary.delete({\n where: { id: gradingBoundaryId },\n });\n}\n\nexport async function getSyllabus(classId: string) {\n const classData = await findClassSyllabus(classId);\n const markSchemes = await findMarkSchemesByClassId(classId);\n const gradingBoundaries = await findGradingBoundariesByClassId(classId);\n return {\n syllabus: classData?.syllabus,\n gradingBoundaries,\n markSchemes,\n };\n}\n\nexport async function updateSyllabus(classId: string, contents: string) {\n if (!contents) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"Missing key contents\",\n });\n }\n return prisma.class.update({\n where: { id: classId },\n data: { syllabus: contents },\n });\n}\n\nexport async function listLabDrafts(classId: string, teacherId: string) {\n return findLabDraftsByClass(classId, teacherId);\n}\n\nexport async function createLabDraft(\n classId: string,\n teacherId: string,\n input: {\n title: string;\n type: string;\n instructions: string;\n dueDate?: Date;\n maxGrade?: number;\n weight?: number;\n graded?: boolean;\n sectionId?: string;\n markSchemeId?: string;\n gradingBoundaryId?: string;\n }\n) {\n return prisma.assignment.create({\n data: {\n classId,\n teacherId,\n inProgress: true,\n graded: input.graded ?? false,\n maxGrade: input.maxGrade ?? 0,\n weight: input.weight ?? 1,\n dueDate:\n input.dueDate ||\n new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),\n title: input.title,\n instructions: input.instructions,\n type: input.type as any,\n ...(input.sectionId && { sectionId: input.sectionId }),\n ...(input.markSchemeId && { markSchemeId: input.markSchemeId }),\n ...(input.gradingBoundaryId && {\n gradingBoundaryId: input.gradingBoundaryId,\n }),\n },\n });\n}\n\nexport async function updateLabDraft(\n classId: string,\n teacherId: string,\n draftId: string,\n input: Record<string, unknown>\n) {\n const updateData: Record<string, unknown> = {\n modifiedAt: new Date(),\n };\n if (input.title !== undefined) updateData.title = input.title;\n if (input.instructions !== undefined)\n updateData.instructions = input.instructions;\n if (input.dueDate !== undefined) updateData.dueDate = input.dueDate;\n if (input.maxGrade !== undefined) updateData.maxGrade = input.maxGrade;\n if (input.weight !== undefined) updateData.weight = input.weight;\n if (input.graded !== undefined) updateData.graded = input.graded;\n if (input.sectionId !== undefined) updateData.sectionId = input.sectionId;\n if (input.markSchemeId !== undefined)\n updateData.markSchemeId = input.markSchemeId;\n if (input.gradingBoundaryId !== undefined)\n updateData.gradingBoundaryId = input.gradingBoundaryId;\n\n return prisma.assignment.update({\n where: {\n id: draftId,\n classId,\n teacherId,\n inProgress: true,\n },\n data: updateData as any,\n });\n}\n\nexport async function deleteLabDraft(\n classId: string,\n teacherId: string,\n draftId: string\n) {\n return prisma.assignment.delete({\n where: {\n id: draftId,\n classId,\n teacherId,\n inProgress: true,\n },\n });\n}\n\nexport async function publishLabDraft(\n classId: string,\n teacherId: string,\n draftId: string,\n input: {\n dueDate?: Date;\n maxGrade?: number;\n weight?: number;\n graded?: boolean;\n }\n) {\n const labDraft = await prisma.assignment.findUnique({\n where: {\n id: draftId,\n classId,\n teacherId,\n inProgress: true,\n },\n });\n\n if (!labDraft) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Lab draft not found\",\n });\n }\n\n return prisma.assignment.update({\n where: { id: draftId },\n data: {\n inProgress: false,\n dueDate: input.dueDate || labDraft.dueDate,\n maxGrade: input.maxGrade || labDraft.maxGrade || 100,\n weight: input.weight || labDraft.weight || 1,\n graded: input.graded !== undefined ? input.graded : true,\n modifiedAt: new Date(),\n },\n });\n}\n\nexport async function getFiles(classId: string) {\n const assignments = await findAssignmentsWithFiles(classId);\n return assignments.map((assignment) => ({\n id: assignment.id,\n title: assignment.title,\n teacher: assignment.teacher,\n teacherAttachments: assignment.attachments,\n students: assignment.submissions.map((submission) => ({\n id: submission.student.id,\n username: submission.student.username,\n attachments: submission.attachments,\n annotations: submission.annotations,\n })),\n }));\n}\n\nexport async function exportClass(classId: string, userId: string) {\n const classExport = await findFullExportableClass(classId);\n if (!classExport) {\n throw new TRPCError({\n code: \"INTERNAL_SERVER_ERROR\",\n message: \"Failed to export class\",\n });\n }\n\n return classExport;\n}\n\nexport async function importClass(classId: string, userId: string, year: number, classData: Class & { classFiles: Folder | null }) {\n try {\n const newClassId = await createClassByImport(classId, userId, year, classData);\n if (!newClassId) {\n throw new TRPCError({\n code: \"INTERNAL_SERVER_ERROR\",\n message: \"Failed to import class\",\n });\n }\n return newClassId;\n } catch (err) {\n if (err instanceof TRPCError) throw err;\n const message = err instanceof Error ? err.message : \"Unknown error\";\n throw new TRPCError({\n code: \"INTERNAL_SERVER_ERROR\",\n message: `Failed to import class: ${message}`,\n cause: err,\n });\n }\n}"],"names":[],"mappings":"AAAA;;;GAGG;;;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EACL,kBAAkB,EACl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AAU,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;QAC/E,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,SAAS,CAAC;gBAClB,IAAI,EAAE,uBAAuB;gBAC7B,OAAO,EAAE,wBAAwB;aAClC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,SAAS;YAAE,MAAM,GAAG,CAAC;QACxC,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;QACrE,MAAM,IAAI,SAAS,CAAC;YAClB,IAAI,EAAE,uBAAuB;YAC7B,OAAO,EAAE,2BAA2B,OAAO,EAAE;YAC7C,KAAK,EAAE,GAAG;SACX,CAAC,CAAC;IACL,CAAC;AACH,CAAC","debug_id":"b0980742-2fbe-5c12-897f-ba5bf6ed98c4"}
|
|
1
|
+
{"version":3,"file":"class.js","sources":["services/class.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Class service – CRUD for classes, members, grades, mark schemes, grading boundaries,\n * syllabus, lab drafts, and invite codes.\n */\nimport { SessionType } from \"@prisma/client\";\nimport { TRPCError } from \"@trpc/server\";\nimport { prisma } from \"../lib/prisma.js\";\nimport { generateInviteCode } from \"../utils/generateInviteCode.js\";\nimport {\n findTeacherClasses,\n findStudentClasses,\n isTeacherInClass,\n findClassWithAssignments,\n findSectionsByClassId,\n findUserById,\n findSessionByClassCode,\n findSessionByClassId,\n findSubmissionsForGrades,\n findEventsByClassId,\n findMarkSchemesByClassId,\n findGradingBoundariesByClassId,\n findClassSyllabus,\n findLabDraftsByClass,\n findAssignmentsWithFiles,\n findFullExportableClass,\n createClassByImport,\n} from \"../models/class.js\";\nimport { listUserSchoolMemberships } from \"../models/school.js\";\nimport { Class, Folder } from \"@prisma/client\";\n\n/** Get all classes where user is teacher or student, with assignments and members. */\nexport async function getAllClasses(userId: string) {\n const [teacherClasses, studentClasses] = await Promise.all([\n findTeacherClasses(userId),\n findStudentClasses(userId),\n ]);\n\n return {\n teacherInClass: teacherClasses.map((cls) => ({\n id: cls.id,\n name: cls.name,\n section: cls.section,\n subject: cls.subject,\n dueToday: cls.assignments,\n assignments: cls.assignments,\n members: [...cls.students, ...cls.teachers],\n color: cls.color,\n })),\n studentInClass: studentClasses.map((cls) => ({\n id: cls.id,\n name: cls.name,\n section: cls.section,\n subject: cls.subject,\n dueToday: cls.assignments,\n assignments: cls.assignments,\n members: [...cls.students, ...cls.teachers],\n color: cls.color,\n })),\n };\n}\n\n/** Get single class with assignments, sections, and submission status. */\nexport async function getClass(userId: string, classId: string) {\n const isTeacher = await isTeacherInClass(classId, userId ?? \"\");\n\n const classData = await findClassWithAssignments(classId, {\n isTeacher: !!isTeacher,\n userId: userId ?? undefined,\n });\n\n if (!classData) {\n throw new Error(\"Class not found\");\n }\n\n const formattedClassData = {\n ...classData,\n assignments: classData.assignments.map((assignment) => ({\n ...assignment,\n late: assignment.dueDate < new Date(),\n submitted: assignment.submissions.find(\n (s) => s.studentId === userId\n )?.submitted,\n returned: assignment.submissions.find(\n (s) => s.studentId === userId\n )?.returned,\n })),\n };\n\n const sections = await findSectionsByClassId(classId);\n\n return {\n class: {\n ...formattedClassData,\n sections,\n },\n };\n}\n\nexport async function updateClass(\n classId: string,\n data: { name?: string; section?: string; subject?: string }\n) {\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data,\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n },\n });\n return { updatedClass };\n}\n\nexport async function createClass(\n userId: string,\n input: {\n students?: string[];\n teachers?: string[];\n name: string;\n section: string;\n subject: string;\n color?: string;\n schoolId?: string;\n }\n) {\n const { students, teachers, name, section, subject, color, schoolId } = input;\n\n if (schoolId) {\n const memberships = await listUserSchoolMemberships(userId);\n const membership = memberships.find((item) => item.schoolId === schoolId);\n\n if (!membership) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"You are not a member of this school\",\n });\n }\n\n if (membership.role === \"STUDENT\") {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Students cannot create school classes\",\n });\n }\n }\n\n if (teachers && teachers.length > 0 && students && students.length > 0) {\n return prisma.class.create({\n data: {\n name,\n section,\n subject,\n color,\n schoolId,\n teachers: { connect: teachers.map((id) => ({ id })) },\n students: { connect: students.map((id) => ({ id })) },\n },\n include: { teachers: true, students: true },\n });\n }\n\n return prisma.class.create({\n data: {\n name,\n section,\n subject,\n color,\n schoolId,\n teachers: { connect: { id: userId } },\n },\n });\n}\n\nexport async function deleteClass(classId: string) {\n const classToDelete = await prisma.class.findFirst({\n where: { id: classId },\n });\n\n if (!classToDelete) {\n throw new Error(\"Class not found or you don't have permission to delete it\");\n }\n\n await prisma.class.delete({\n where: { id: classId },\n });\n\n return { deletedClass: { id: classId } };\n}\n\nexport async function addStudent(classId: string, studentId: string) {\n const student = await findUserById(studentId);\n if (!student) {\n throw new Error(\"Student not found\");\n }\n\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data: {\n students: { connect: { id: studentId } },\n },\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n },\n });\n\n return { updatedClass, newStudent: student };\n}\n\nexport async function changeRole(\n classId: string,\n userId: string,\n type: \"teacher\" | \"student\"\n) {\n const user = await findUserById(userId);\n if (!user) {\n throw new Error(\"User not found\");\n }\n\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data: {\n [type === \"teacher\" ? \"teachers\" : \"students\"]: {\n connect: { id: userId },\n },\n [type === \"teacher\" ? \"students\" : \"teachers\"]: {\n disconnect: { id: userId },\n },\n },\n });\n\n return {\n updatedClass,\n user: { ...user, type },\n };\n}\n\nexport async function removeMember(classId: string, userId: string) {\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data: {\n teachers: { disconnect: { id: userId } },\n students: { disconnect: { id: userId } },\n },\n });\n return { updatedClass, removedUserId: userId };\n}\n\nexport async function leaveClass(userId: string, classId: string) {\n const classData = await prisma.class.findFirst({\n where: {\n id: classId,\n students: { some: { id: userId } },\n },\n });\n\n if (!classData) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Class not found or you are not a student in this class\",\n });\n }\n\n await prisma.class.update({\n where: { id: classId },\n data: {\n students: { disconnect: { id: userId } },\n },\n });\n\n return { success: true, leftClassId: classId };\n}\n\nexport async function joinClass(userId: string, classCode: string) {\n const session = await findSessionByClassCode(classCode);\n\n if (!session || !session.classId) {\n throw new Error(\"Class not found\");\n }\n\n if (session.expiresAt && session.expiresAt < new Date()) {\n throw new Error(\"Session expired\");\n }\n\n const updatedClass = await prisma.class.update({\n where: { id: session.classId },\n data: {\n students: { connect: { id: userId } },\n },\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n },\n });\n\n return { joinedClass: updatedClass };\n}\n\nexport async function getInviteCode(classId: string) {\n const session = await findSessionByClassId(classId);\n\n if ((session?.expiresAt && session.expiresAt < new Date()) || !session) {\n const newSession = await prisma.session.create({\n data: {\n id: generateInviteCode(),\n classId,\n type: SessionType.CLASS_INVITE,\n expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000),\n },\n });\n return { code: newSession.id };\n }\n\n return { code: session?.id };\n}\n\nexport async function createInviteCode(classId: string) {\n await prisma.session.deleteMany({\n where: { classId, type: SessionType.CLASS_INVITE },\n });\n\n const session = await prisma.session.create({\n data: {\n id: generateInviteCode(),\n classId,\n type: SessionType.CLASS_INVITE,\n expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000),\n },\n });\n\n return { code: session.id };\n}\n\nexport async function getGrades(\n userId: string,\n classId: string,\n targetUserId: string\n) {\n const isTeacher = await isTeacherInClass(classId, userId);\n if (userId !== targetUserId && !isTeacher) {\n throw new TRPCError({\n code: \"UNAUTHORIZED\",\n message: \"You can only view your own grades\",\n });\n }\n\n const grades = await findSubmissionsForGrades(targetUserId, classId);\n return { grades };\n}\n\nexport async function updateGrade(\n assignmentId: string,\n submissionId: string,\n gradeReceived: number | null\n) {\n const updatedSubmission = await prisma.submission.update({\n where: { id: submissionId, assignmentId },\n data: { gradeReceived },\n include: {\n assignment: {\n select: {\n id: true,\n title: true,\n maxGrade: true,\n weight: true,\n },\n },\n },\n });\n return updatedSubmission;\n}\n\nexport async function getEvents(classId: string) {\n return findEventsByClassId(classId);\n}\n\nexport async function listMarkSchemes(classId: string) {\n return findMarkSchemesByClassId(classId);\n}\n\nexport async function createMarkScheme(classId: string, structure: string) {\n const validatedStructure = structure.replace(/\\\\n/g, \"\\n\");\n return prisma.markScheme.create({\n data: {\n class: { connect: { id: classId } },\n structured: validatedStructure,\n },\n });\n}\n\nexport async function updateMarkScheme(\n markSchemeId: string,\n classId: string,\n structure: string\n) {\n const validatedStructure = structure.replace(/\\\\n/g, \"\\n\");\n return prisma.markScheme.update({\n where: { id: markSchemeId },\n data: {\n class: { connect: { id: classId } },\n structured: validatedStructure,\n },\n });\n}\n\nexport async function deleteMarkScheme(markSchemeId: string) {\n return prisma.markScheme.delete({\n where: { id: markSchemeId },\n });\n}\n\nexport async function listGradingBoundaries(classId: string) {\n return findGradingBoundariesByClassId(classId);\n}\n\nexport async function createGradingBoundary(classId: string, structure: string) {\n const validatedStructure = structure.replace(/\\\\n/g, \"\\n\");\n return prisma.gradingBoundary.create({\n data: {\n class: { connect: { id: classId } },\n structured: validatedStructure,\n },\n });\n}\n\nexport async function updateGradingBoundary(\n gradingBoundaryId: string,\n classId: string,\n structure: string\n) {\n const validatedStructure = structure.replace(/\\\\n/g, \"\\n\");\n return prisma.gradingBoundary.update({\n where: { id: gradingBoundaryId },\n data: {\n class: { connect: { id: classId } },\n structured: validatedStructure,\n },\n });\n}\n\nexport async function deleteGradingBoundary(gradingBoundaryId: string) {\n return prisma.gradingBoundary.delete({\n where: { id: gradingBoundaryId },\n });\n}\n\nexport async function getSyllabus(classId: string) {\n const classData = await findClassSyllabus(classId);\n const markSchemes = await findMarkSchemesByClassId(classId);\n const gradingBoundaries = await findGradingBoundariesByClassId(classId);\n return {\n syllabus: classData?.syllabus,\n gradingBoundaries,\n markSchemes,\n };\n}\n\nexport async function updateSyllabus(classId: string, contents: string) {\n if (!contents) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"Missing key contents\",\n });\n }\n return prisma.class.update({\n where: { id: classId },\n data: { syllabus: contents },\n });\n}\n\nexport async function listLabDrafts(classId: string, teacherId: string) {\n return findLabDraftsByClass(classId, teacherId);\n}\n\nexport async function createLabDraft(\n classId: string,\n teacherId: string,\n input: {\n title: string;\n type: string;\n instructions: string;\n dueDate?: Date;\n maxGrade?: number;\n weight?: number;\n graded?: boolean;\n sectionId?: string;\n markSchemeId?: string;\n gradingBoundaryId?: string;\n }\n) {\n return prisma.assignment.create({\n data: {\n classId,\n teacherId,\n inProgress: true,\n graded: input.graded ?? false,\n maxGrade: input.maxGrade ?? 0,\n weight: input.weight ?? 1,\n dueDate:\n input.dueDate ||\n new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),\n title: input.title,\n instructions: input.instructions,\n type: input.type as any,\n ...(input.sectionId && { sectionId: input.sectionId }),\n ...(input.markSchemeId && { markSchemeId: input.markSchemeId }),\n ...(input.gradingBoundaryId && {\n gradingBoundaryId: input.gradingBoundaryId,\n }),\n },\n });\n}\n\nexport async function updateLabDraft(\n classId: string,\n teacherId: string,\n draftId: string,\n input: Record<string, unknown>\n) {\n const updateData: Record<string, unknown> = {\n modifiedAt: new Date(),\n };\n if (input.title !== undefined) updateData.title = input.title;\n if (input.instructions !== undefined)\n updateData.instructions = input.instructions;\n if (input.dueDate !== undefined) updateData.dueDate = input.dueDate;\n if (input.maxGrade !== undefined) updateData.maxGrade = input.maxGrade;\n if (input.weight !== undefined) updateData.weight = input.weight;\n if (input.graded !== undefined) updateData.graded = input.graded;\n if (input.sectionId !== undefined) updateData.sectionId = input.sectionId;\n if (input.markSchemeId !== undefined)\n updateData.markSchemeId = input.markSchemeId;\n if (input.gradingBoundaryId !== undefined)\n updateData.gradingBoundaryId = input.gradingBoundaryId;\n\n return prisma.assignment.update({\n where: {\n id: draftId,\n classId,\n teacherId,\n inProgress: true,\n },\n data: updateData as any,\n });\n}\n\nexport async function deleteLabDraft(\n classId: string,\n teacherId: string,\n draftId: string\n) {\n return prisma.assignment.delete({\n where: {\n id: draftId,\n classId,\n teacherId,\n inProgress: true,\n },\n });\n}\n\nexport async function publishLabDraft(\n classId: string,\n teacherId: string,\n draftId: string,\n input: {\n dueDate?: Date;\n maxGrade?: number;\n weight?: number;\n graded?: boolean;\n }\n) {\n const labDraft = await prisma.assignment.findUnique({\n where: {\n id: draftId,\n classId,\n teacherId,\n inProgress: true,\n },\n });\n\n if (!labDraft) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Lab draft not found\",\n });\n }\n\n return prisma.assignment.update({\n where: { id: draftId },\n data: {\n inProgress: false,\n dueDate: input.dueDate || labDraft.dueDate,\n maxGrade: input.maxGrade || labDraft.maxGrade || 100,\n weight: input.weight || labDraft.weight || 1,\n graded: input.graded !== undefined ? input.graded : true,\n modifiedAt: new Date(),\n },\n });\n}\n\nexport async function getFiles(classId: string) {\n const assignments = await findAssignmentsWithFiles(classId);\n return assignments.map((assignment) => ({\n id: assignment.id,\n title: assignment.title,\n teacher: assignment.teacher,\n teacherAttachments: assignment.attachments,\n students: assignment.submissions.map((submission) => ({\n id: submission.student.id,\n username: submission.student.username,\n attachments: submission.attachments,\n annotations: submission.annotations,\n })),\n }));\n}\n\nexport async function exportClass(classId: string, userId: string) {\n const classExport = await findFullExportableClass(classId);\n if (!classExport) {\n throw new TRPCError({\n code: \"INTERNAL_SERVER_ERROR\",\n message: \"Failed to export class\",\n });\n }\n\n return classExport;\n}\n\nexport async function importClass(classId: string, userId: string, year: number, classData: Class & { classFiles: Folder | null }) {\n try {\n const newClassId = await createClassByImport(classId, userId, year, classData);\n if (!newClassId) {\n throw new TRPCError({\n code: \"INTERNAL_SERVER_ERROR\",\n message: \"Failed to import class\",\n });\n }\n return newClassId;\n } catch (err) {\n if (err instanceof TRPCError) throw err;\n const message = err instanceof Error ? err.message : \"Unknown error\";\n throw new TRPCError({\n code: \"INTERNAL_SERVER_ERROR\",\n message: `Failed to import class: ${message}`,\n cause: err,\n });\n }\n}\n"],"names":[],"mappings":"AAAA;;;GAGG;;;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB,EACrB,YAAY,EACZ,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,8BAA8B,EAC9B,iBAAiB,EACjB,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAGhE,sFAAsF;AACtF,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAc;IAChD,MAAM,CAAC,cAAc,EAAE,cAAc,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACzD,kBAAkB,CAAC,MAAM,CAAC;QAC1B,kBAAkB,CAAC,MAAM,CAAC;KAC3B,CAAC,CAAC;IAEH,OAAO;QACL,cAAc,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC3C,EAAE,EAAE,GAAG,CAAC,EAAE;YACV,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,OAAO,EAAE,GAAG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AC;YAChB,MAAM,IAAI,SAAS,CAAC;gBAClB,IAAI,EAAE,uBAAuB;gBAC7B,OAAO,EAAE,wBAAwB;aAClC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,SAAS;YAAE,MAAM,GAAG,CAAC;QACxC,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;QACrE,MAAM,IAAI,SAAS,CAAC;YAClB,IAAI,EAAE,uBAAuB;YAC7B,OAAO,EAAE,2BAA2B,OAAO,EAAE;YAC7C,KAAK,EAAE,GAAG;SACX,CAAC,CAAC;IACL,CAAC;AACH,CAAC","debug_id":"c5ccb222-b8b2-53d6-9959-bb2ae34ed195"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/** Get a comment by ID. */
|
|
2
|
-
export declare function getComment(id: string): Promise<{
|
|
2
|
+
export declare function getComment(userId: string, id: string): Promise<{
|
|
3
3
|
id: string;
|
|
4
|
+
createdAt: Date;
|
|
5
|
+
assignmentId: string | null;
|
|
6
|
+
submissionId: string | null;
|
|
7
|
+
announcementId: string | null;
|
|
4
8
|
reactions: {
|
|
5
9
|
type: import(".prisma/client").$Enums.ReactionType;
|
|
6
10
|
user: {
|
|
@@ -13,9 +17,9 @@ export declare function getComment(id: string): Promise<{
|
|
|
13
17
|
} | null;
|
|
14
18
|
};
|
|
15
19
|
}[];
|
|
16
|
-
createdAt: Date;
|
|
17
20
|
modifiedAt: Date | null;
|
|
18
21
|
content: string;
|
|
22
|
+
parentCommentId: string | null;
|
|
19
23
|
author: {
|
|
20
24
|
id: string;
|
|
21
25
|
username: string;
|
|
@@ -27,7 +31,7 @@ export declare function getComment(id: string): Promise<{
|
|
|
27
31
|
};
|
|
28
32
|
}>;
|
|
29
33
|
/** Get all replies to a comment. */
|
|
30
|
-
export declare function getReplies(commentId: string): Promise<({
|
|
34
|
+
export declare function getReplies(userId: string, commentId: string): Promise<({
|
|
31
35
|
author: {
|
|
32
36
|
id: string;
|
|
33
37
|
username: string;
|
|
@@ -40,8 +44,10 @@ export declare function getReplies(commentId: string): Promise<({
|
|
|
40
44
|
} & {
|
|
41
45
|
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
42
46
|
id: string;
|
|
43
|
-
announcementId: string | null;
|
|
44
47
|
createdAt: Date;
|
|
48
|
+
assignmentId: string | null;
|
|
49
|
+
submissionId: string | null;
|
|
50
|
+
announcementId: string | null;
|
|
45
51
|
modifiedAt: Date | null;
|
|
46
52
|
content: string;
|
|
47
53
|
authorId: string;
|
|
@@ -52,14 +58,34 @@ export declare function getReplies(commentId: string): Promise<({
|
|
|
52
58
|
export declare function replyToComment(userId: string, parentCommentId: string, content: string): Promise<{
|
|
53
59
|
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
54
60
|
id: string;
|
|
61
|
+
createdAt: Date;
|
|
62
|
+
assignmentId: string | null;
|
|
63
|
+
submissionId: string | null;
|
|
55
64
|
announcementId: string | null;
|
|
65
|
+
modifiedAt: Date | null;
|
|
66
|
+
content: string;
|
|
67
|
+
authorId: string;
|
|
68
|
+
parentCommentId: string | null;
|
|
69
|
+
studentQuestionProgressId: string | null;
|
|
70
|
+
}>;
|
|
71
|
+
/** Update a comment authored by the user. */
|
|
72
|
+
export declare function updateComment(userId: string, id: string, content: string): Promise<{
|
|
73
|
+
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
74
|
+
id: string;
|
|
56
75
|
createdAt: Date;
|
|
76
|
+
assignmentId: string | null;
|
|
77
|
+
submissionId: string | null;
|
|
78
|
+
announcementId: string | null;
|
|
57
79
|
modifiedAt: Date | null;
|
|
58
80
|
content: string;
|
|
59
81
|
authorId: string;
|
|
60
82
|
parentCommentId: string | null;
|
|
61
83
|
studentQuestionProgressId: string | null;
|
|
62
84
|
}>;
|
|
85
|
+
/** Delete a comment authored by the user or moderated by a class teacher. */
|
|
86
|
+
export declare function deleteComment(userId: string, id: string): Promise<{
|
|
87
|
+
success: boolean;
|
|
88
|
+
}>;
|
|
63
89
|
/** Add or update a reaction (emoji) on a comment. */
|
|
64
90
|
export declare function addReaction(userId: string, commentId: string, type: string): Promise<{
|
|
65
91
|
reaction: {
|
|
@@ -75,9 +101,9 @@ export declare function addReaction(userId: string, commentId: string, type: str
|
|
|
75
101
|
} & {
|
|
76
102
|
type: import(".prisma/client").$Enums.ReactionType;
|
|
77
103
|
id: string;
|
|
104
|
+
createdAt: Date;
|
|
78
105
|
userId: string;
|
|
79
106
|
announcementId: string | null;
|
|
80
|
-
createdAt: Date;
|
|
81
107
|
commentId: string | null;
|
|
82
108
|
};
|
|
83
109
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment.d.ts","sourceRoot":"/","sources":["services/comment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"comment.d.ts","sourceRoot":"/","sources":["services/comment.ts"],"names":[],"mappings":"AA6FA,2BAA2B;AAC3B,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAU1D;AAED,oCAAoC;AACpC,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;MAGjE;AAED,6CAA6C;AAC7C,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,MAAM;;;;;;;;;;;;GAYhB;AAED,6CAA6C;AAC7C,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;;;;;;;;;;;;GAa9E;AAED,6EAA6E;AAC7E,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;GAW7D;AAED,qDAAqD;AACrD,wBAAsB,WAAW,CAC/B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM;;;;;;;;;;;;;;;;;;;GAMb;AAED,6CAA6C;AAC7C,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;GAWrE;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;;;;;GAuBnE"}
|
package/dist/services/comment.js
CHANGED
|
@@ -1,12 +1,74 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Comment service – get comments, replies, and reactions.
|
|
2
|
+
* Comment service – get comments, replies, and reactions.
|
|
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]="3b159ee4-0b57-5fbd-abfa-06234f7273dd")}catch(e){}}();
|
|
6
6
|
import { TRPCError } from "@trpc/server";
|
|
7
|
-
import {
|
|
7
|
+
import { prisma } from "../lib/prisma.js";
|
|
8
|
+
import { findCommentById, findRepliesByCommentId, createComment, findReactionByUserAndComment, upsertReaction, deleteReactionById, findCommentWithContext, getReactionCountsByCommentId, } from "../models/comment.js";
|
|
9
|
+
function getCommentClass(comment) {
|
|
10
|
+
return (comment.announcement?.class ??
|
|
11
|
+
comment.assignment?.class ??
|
|
12
|
+
comment.submission?.assignment?.class ??
|
|
13
|
+
comment.studentQuestionProgress?.studentWorksheetResponse?.submission?.assignment?.class ??
|
|
14
|
+
comment.parentComment?.announcement?.class ??
|
|
15
|
+
comment.parentComment?.assignment?.class ??
|
|
16
|
+
comment.parentComment?.submission?.assignment?.class ??
|
|
17
|
+
comment.parentComment?.studentQuestionProgress?.studentWorksheetResponse?.submission?.assignment?.class ??
|
|
18
|
+
null);
|
|
19
|
+
}
|
|
20
|
+
function getPrivateStudentId(comment) {
|
|
21
|
+
return (comment.submission?.studentId ??
|
|
22
|
+
comment.studentQuestionProgress?.studentWorksheetResponse?.submission?.studentId ??
|
|
23
|
+
comment.studentQuestionProgress?.studentId ??
|
|
24
|
+
comment.parentComment?.submission?.studentId ??
|
|
25
|
+
comment.parentComment?.studentQuestionProgress?.studentWorksheetResponse?.submission?.studentId ??
|
|
26
|
+
comment.parentComment?.studentQuestionProgress?.studentId ??
|
|
27
|
+
null);
|
|
28
|
+
}
|
|
29
|
+
function isClassTeacher(comment, userId) {
|
|
30
|
+
const classData = getCommentClass(comment);
|
|
31
|
+
return Boolean(classData?.teachers?.some((teacher) => teacher.id === userId) ||
|
|
32
|
+
classData?.school?.memberships?.some((admin) => admin.userId === userId) ||
|
|
33
|
+
classData?.school?.users?.some((admin) => admin.id === userId));
|
|
34
|
+
}
|
|
35
|
+
function isClassMember(comment, userId) {
|
|
36
|
+
const classData = getCommentClass(comment);
|
|
37
|
+
return (classData?.teachers?.some((teacher) => teacher.id === userId) ||
|
|
38
|
+
classData?.students?.some((student) => student.id === userId) ||
|
|
39
|
+
classData?.school?.memberships?.some((admin) => admin.userId === userId) ||
|
|
40
|
+
classData?.school?.users?.some((admin) => admin.id === userId) ||
|
|
41
|
+
false);
|
|
42
|
+
}
|
|
43
|
+
function canReadComment(comment, userId) {
|
|
44
|
+
const privateStudentId = getPrivateStudentId(comment);
|
|
45
|
+
if (privateStudentId) {
|
|
46
|
+
return privateStudentId === userId || isClassTeacher(comment, userId);
|
|
47
|
+
}
|
|
48
|
+
return isClassMember(comment, userId);
|
|
49
|
+
}
|
|
50
|
+
function canDeleteComment(comment, userId) {
|
|
51
|
+
return comment.authorId === userId || isClassTeacher(comment, userId);
|
|
52
|
+
}
|
|
53
|
+
async function requireCommentAccess(commentId, userId) {
|
|
54
|
+
const comment = await findCommentWithContext(commentId);
|
|
55
|
+
if (!comment) {
|
|
56
|
+
throw new TRPCError({
|
|
57
|
+
code: "NOT_FOUND",
|
|
58
|
+
message: "Comment not found",
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (!canReadComment(comment, userId)) {
|
|
62
|
+
throw new TRPCError({
|
|
63
|
+
code: "FORBIDDEN",
|
|
64
|
+
message: "You do not have access to this comment",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return comment;
|
|
68
|
+
}
|
|
8
69
|
/** Get a comment by ID. */
|
|
9
|
-
export async function getComment(id) {
|
|
70
|
+
export async function getComment(userId, id) {
|
|
71
|
+
await requireCommentAccess(id, userId);
|
|
10
72
|
const comment = await findCommentById(id);
|
|
11
73
|
if (!comment) {
|
|
12
74
|
throw new TRPCError({
|
|
@@ -17,31 +79,58 @@ export async function getComment(id) {
|
|
|
17
79
|
return comment;
|
|
18
80
|
}
|
|
19
81
|
/** Get all replies to a comment. */
|
|
20
|
-
export async function getReplies(commentId) {
|
|
82
|
+
export async function getReplies(userId, commentId) {
|
|
83
|
+
await requireCommentAccess(commentId, userId);
|
|
21
84
|
return findRepliesByCommentId(commentId);
|
|
22
85
|
}
|
|
23
86
|
/** Create a reply to an existing comment. */
|
|
24
87
|
export async function replyToComment(userId, parentCommentId, content) {
|
|
88
|
+
const parentComment = await requireCommentAccess(parentCommentId, userId);
|
|
25
89
|
return createComment({
|
|
26
90
|
parentCommentId,
|
|
27
91
|
content,
|
|
28
92
|
authorId: userId,
|
|
93
|
+
announcementId: parentComment.announcementId,
|
|
94
|
+
assignmentId: parentComment.assignmentId,
|
|
95
|
+
submissionId: parentComment.submissionId,
|
|
96
|
+
studentQuestionProgressId: parentComment.studentQuestionProgressId,
|
|
29
97
|
});
|
|
30
98
|
}
|
|
31
|
-
/**
|
|
32
|
-
export async function
|
|
33
|
-
const comment = await
|
|
34
|
-
if (
|
|
99
|
+
/** Update a comment authored by the user. */
|
|
100
|
+
export async function updateComment(userId, id, content) {
|
|
101
|
+
const comment = await requireCommentAccess(id, userId);
|
|
102
|
+
if (comment.authorId !== userId) {
|
|
35
103
|
throw new TRPCError({
|
|
36
|
-
code: "
|
|
37
|
-
message: "
|
|
104
|
+
code: "FORBIDDEN",
|
|
105
|
+
message: "Only the comment author can update this comment",
|
|
38
106
|
});
|
|
39
107
|
}
|
|
108
|
+
return prisma.comment.update({
|
|
109
|
+
where: { id },
|
|
110
|
+
data: { content },
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/** Delete a comment authored by the user or moderated by a class teacher. */
|
|
114
|
+
export async function deleteComment(userId, id) {
|
|
115
|
+
const comment = await requireCommentAccess(id, userId);
|
|
116
|
+
if (!canDeleteComment(comment, userId)) {
|
|
117
|
+
throw new TRPCError({
|
|
118
|
+
code: "FORBIDDEN",
|
|
119
|
+
message: "Only the comment author or class teachers can delete comments",
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
await prisma.comment.delete({ where: { id } });
|
|
123
|
+
return { success: true };
|
|
124
|
+
}
|
|
125
|
+
/** Add or update a reaction (emoji) on a comment. */
|
|
126
|
+
export async function addReaction(userId, commentId, type) {
|
|
127
|
+
await requireCommentAccess(commentId, userId);
|
|
40
128
|
const reaction = await upsertReaction({ userId, commentId, type });
|
|
41
129
|
return { reaction };
|
|
42
130
|
}
|
|
43
131
|
/** Remove user's reaction from a comment. */
|
|
44
132
|
export async function removeReaction(userId, commentId) {
|
|
133
|
+
await requireCommentAccess(commentId, userId);
|
|
45
134
|
const reaction = await findReactionByUserAndComment(userId, commentId);
|
|
46
135
|
if (!reaction) {
|
|
47
136
|
throw new TRPCError({
|
|
@@ -53,13 +142,7 @@ export async function removeReaction(userId, commentId) {
|
|
|
53
142
|
return { success: true };
|
|
54
143
|
}
|
|
55
144
|
export async function getReactions(userId, commentId) {
|
|
56
|
-
|
|
57
|
-
if (!comment) {
|
|
58
|
-
throw new TRPCError({
|
|
59
|
-
code: "NOT_FOUND",
|
|
60
|
-
message: "Comment not found",
|
|
61
|
-
});
|
|
62
|
-
}
|
|
145
|
+
await requireCommentAccess(commentId, userId);
|
|
63
146
|
const reactionCounts = await getReactionCountsByCommentId(commentId);
|
|
64
147
|
const userReaction = await findReactionByUserAndComment(userId, commentId);
|
|
65
148
|
const counts = {
|
|
@@ -80,4 +163,4 @@ export async function getReactions(userId, commentId) {
|
|
|
80
163
|
};
|
|
81
164
|
}
|
|
82
165
|
//# sourceMappingURL=comment.js.map
|
|
83
|
-
//# debugId=
|
|
166
|
+
//# debugId=3b159ee4-0b57-5fbd-abfa-06234f7273dd
|