@studious-lms/server 1.4.1 → 1.4.3
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/.coderabbit.yaml +4 -1
- package/.env.example +6 -0
- package/.env.test.example +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +101 -76
- package/dist/index.js.map +1 -1
- package/dist/lib/config/cors.d.ts +16 -0
- package/dist/lib/config/cors.d.ts.map +1 -0
- package/dist/lib/config/cors.js +75 -0
- package/dist/lib/config/cors.js.map +1 -0
- package/dist/lib/config/env.d.ts +14 -0
- package/dist/lib/config/env.d.ts.map +1 -1
- package/dist/lib/config/env.js +9 -2
- package/dist/lib/config/env.js.map +1 -1
- package/dist/lib/fileUpload.d.ts +10 -2
- package/dist/lib/fileUpload.d.ts.map +1 -1
- package/dist/lib/fileUpload.js +38 -6
- package/dist/lib/fileUpload.js.map +1 -1
- package/dist/lib/prisma.d.ts +14 -2
- package/dist/lib/prisma.d.ts.map +1 -1
- package/dist/lib/prisma.js +27 -8
- package/dist/lib/prisma.js.map +1 -1
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +18 -5
- package/dist/middleware/auth.js.map +1 -1
- package/dist/middleware/security.d.ts.map +1 -1
- package/dist/middleware/security.js +3 -3
- package/dist/middleware/security.js.map +1 -1
- package/dist/models/agenda.d.ts +16 -16
- package/dist/models/announcement.d.ts +59 -23
- package/dist/models/announcement.d.ts.map +1 -1
- package/dist/models/assignment.d.ts +363 -276
- package/dist/models/assignment.d.ts.map +1 -1
- package/dist/models/attendance.d.ts +63 -21
- package/dist/models/attendance.d.ts.map +1 -1
- package/dist/models/auth.d.ts +115 -26
- package/dist/models/auth.d.ts.map +1 -1
- package/dist/models/auth.js +53 -30
- package/dist/models/auth.js.map +1 -1
- package/dist/models/class.d.ts +115 -65
- package/dist/models/class.d.ts.map +1 -1
- package/dist/models/class.js +16 -4
- package/dist/models/class.js.map +1 -1
- package/dist/models/comment.d.ts +52 -16
- package/dist/models/comment.d.ts.map +1 -1
- package/dist/models/conversation.d.ts +46 -16
- package/dist/models/conversation.d.ts.map +1 -1
- package/dist/models/event.d.ts +107 -53
- package/dist/models/event.d.ts.map +1 -1
- package/dist/models/file.d.ts +213 -165
- package/dist/models/file.d.ts.map +1 -1
- package/dist/models/folder.d.ts +161 -77
- package/dist/models/folder.d.ts.map +1 -1
- package/dist/models/labChat.d.ts +73 -31
- package/dist/models/labChat.d.ts.map +1 -1
- package/dist/models/marketing.d.ts +25 -7
- package/dist/models/marketing.d.ts.map +1 -1
- package/dist/models/message.d.ts +31 -13
- package/dist/models/message.d.ts.map +1 -1
- package/dist/models/newtonChat.d.ts +34 -10
- package/dist/models/newtonChat.d.ts.map +1 -1
- package/dist/models/notification.d.ts +29 -10
- package/dist/models/notification.d.ts.map +1 -1
- package/dist/models/notification.js +13 -9
- package/dist/models/notification.js.map +1 -1
- package/dist/models/section.d.ts +71 -23
- package/dist/models/section.d.ts.map +1 -1
- package/dist/models/user.d.ts +27 -9
- package/dist/models/user.d.ts.map +1 -1
- package/dist/models/worksheet.d.ts +606 -106
- package/dist/models/worksheet.d.ts.map +1 -1
- package/dist/models/worksheet.js +168 -2
- package/dist/models/worksheet.js.map +1 -1
- package/dist/pipelines/aiLabChat.d.ts +22 -2
- package/dist/pipelines/aiLabChat.d.ts.map +1 -1
- package/dist/pipelines/aiLabChat.js +133 -95
- package/dist/pipelines/aiLabChat.js.map +1 -1
- package/dist/pipelines/aiLabChatContract.d.ts +25 -25
- package/dist/pipelines/aiNewtonChat.d.ts.map +1 -1
- package/dist/pipelines/aiNewtonChat.js +25 -14
- package/dist/pipelines/aiNewtonChat.js.map +1 -1
- package/dist/pipelines/gradeWorksheet.d.ts +8 -8
- package/dist/pipelines/gradeWorksheet.d.ts.map +1 -1
- package/dist/pipelines/gradeWorksheet.js +12 -5
- package/dist/pipelines/gradeWorksheet.js.map +1 -1
- package/dist/pipelines/labChatPrompt.d.ts +27 -0
- package/dist/pipelines/labChatPrompt.d.ts.map +1 -1
- package/dist/pipelines/labChatPrompt.js +143 -69
- package/dist/pipelines/labChatPrompt.js.map +1 -1
- package/dist/routers/_app.d.ts +1579 -1257
- package/dist/routers/_app.d.ts.map +1 -1
- package/dist/routers/agenda.d.ts +16 -16
- package/dist/routers/announcement.d.ts +19 -19
- package/dist/routers/assignment.d.ts +307 -291
- package/dist/routers/assignment.d.ts.map +1 -1
- package/dist/routers/assignment.js +3 -2
- package/dist/routers/assignment.js.map +1 -1
- package/dist/routers/attendance.d.ts +7 -7
- package/dist/routers/auth.d.ts +1 -1
- package/dist/routers/class.d.ts +79 -72
- package/dist/routers/class.d.ts.map +1 -1
- package/dist/routers/class.js +3 -3
- package/dist/routers/class.js.map +1 -1
- package/dist/routers/comment.d.ts +6 -6
- package/dist/routers/conversation.d.ts +11 -11
- package/dist/routers/event.d.ts +35 -35
- package/dist/routers/file.d.ts +12 -12
- package/dist/routers/folder.d.ts +54 -54
- package/dist/routers/labChat.d.ts +18 -12
- package/dist/routers/labChat.d.ts.map +1 -1
- package/dist/routers/labChat.js +5 -3
- package/dist/routers/labChat.js.map +1 -1
- package/dist/routers/marketing.d.ts +2 -2
- package/dist/routers/message.d.ts +33 -2
- package/dist/routers/message.d.ts.map +1 -1
- package/dist/routers/message.js +27 -4
- package/dist/routers/message.js.map +1 -1
- package/dist/routers/newtonChat.d.ts +7 -1
- package/dist/routers/newtonChat.d.ts.map +1 -1
- package/dist/routers/newtonChat.js +5 -4
- package/dist/routers/newtonChat.js.map +1 -1
- package/dist/routers/notifications.d.ts +13 -6
- package/dist/routers/notifications.d.ts.map +1 -1
- package/dist/routers/notifications.js +4 -4
- package/dist/routers/notifications.js.map +1 -1
- package/dist/routers/section.d.ts +7 -7
- package/dist/routers/studentProgress.d.ts +86 -0
- package/dist/routers/studentProgress.d.ts.map +1 -1
- package/dist/routers/studentProgress.js +14 -4
- package/dist/routers/studentProgress.js.map +1 -1
- package/dist/routers/user.d.ts +1 -1
- package/dist/routers/worksheet.d.ts +64 -62
- package/dist/routers/worksheet.d.ts.map +1 -1
- package/dist/routers/worksheet.js +18 -16
- package/dist/routers/worksheet.js.map +1 -1
- package/dist/seedDatabase.d.ts +1 -1
- package/dist/services/agenda.d.ts +16 -16
- package/dist/services/announcement.d.ts +8 -8
- package/dist/services/assignment.d.ts +299 -283
- package/dist/services/assignment.d.ts.map +1 -1
- package/dist/services/assignment.js +24 -5
- package/dist/services/assignment.js.map +1 -1
- package/dist/services/attendance.d.ts +7 -7
- package/dist/services/auth.d.ts +2 -2
- package/dist/services/auth.d.ts.map +1 -1
- package/dist/services/auth.js +19 -12
- package/dist/services/auth.js.map +1 -1
- package/dist/services/class.d.ts +74 -68
- package/dist/services/class.d.ts.map +1 -1
- package/dist/services/class.js +6 -3
- package/dist/services/class.js.map +1 -1
- package/dist/services/comment.d.ts +6 -6
- package/dist/services/conversation.d.ts +11 -11
- package/dist/services/event.d.ts +31 -31
- package/dist/services/file.d.ts +12 -12
- package/dist/services/file.d.ts.map +1 -1
- package/dist/services/file.js +7 -2
- package/dist/services/file.js.map +1 -1
- package/dist/services/folder.d.ts +52 -52
- package/dist/services/labChat.d.ts +18 -12
- package/dist/services/labChat.d.ts.map +1 -1
- package/dist/services/labChat.js +30 -18
- package/dist/services/labChat.js.map +1 -1
- package/dist/services/marketing.d.ts +2 -2
- package/dist/services/message.d.ts +30 -0
- package/dist/services/message.d.ts.map +1 -1
- package/dist/services/message.js +97 -21
- package/dist/services/message.js.map +1 -1
- package/dist/services/newtonChat.d.ts +6 -1
- package/dist/services/newtonChat.d.ts.map +1 -1
- package/dist/services/newtonChat.js +36 -18
- package/dist/services/newtonChat.js.map +1 -1
- package/dist/services/notification.d.ts +16 -9
- package/dist/services/notification.d.ts.map +1 -1
- package/dist/services/notification.js +24 -9
- package/dist/services/notification.js.map +1 -1
- package/dist/services/section.d.ts +6 -6
- package/dist/services/studentProgress.d.ts +75 -0
- package/dist/services/studentProgress.d.ts.map +1 -1
- package/dist/services/studentProgress.js +300 -107
- package/dist/services/studentProgress.js.map +1 -1
- package/dist/services/worksheet.d.ts +64 -64
- package/dist/services/worksheet.d.ts.map +1 -1
- package/dist/services/worksheet.js +138 -54
- package/dist/services/worksheet.js.map +1 -1
- package/dist/trpc.d.ts.map +1 -1
- package/dist/trpc.js +11 -17
- package/dist/trpc.js.map +1 -1
- package/dist/utils/inference.d.ts +9 -12
- package/dist/utils/inference.d.ts.map +1 -1
- package/dist/utils/inference.js +135 -95
- package/dist/utils/inference.js.map +1 -1
- package/package.json +1 -1
- package/prisma/migrations/20260410124000_add_submission_recommendation_state/migration.sql +14 -0
- package/prisma/migrations/20260415103500_add_session_type/migration.sql +33 -0
- package/prisma/migrations/20260415133000_add_ai_usage_logs/migration.sql +19 -0
- package/prisma/schema.prisma +41 -1
- package/scripts/test-pre-push.ts +6 -2
- package/src/index.ts +119 -79
- package/src/lib/config/cors.ts +96 -0
- package/src/lib/config/env.ts +12 -1
- package/src/lib/fileUpload.ts +55 -5
- package/src/lib/prisma.ts +25 -6
- package/src/middleware/auth.ts +19 -4
- package/src/middleware/security.ts +1 -1
- package/src/models/auth.ts +59 -29
- package/src/models/class.ts +15 -4
- package/src/models/notification.ts +13 -7
- package/src/models/worksheet.ts +202 -0
- package/src/pipelines/aiLabChat.ts +183 -104
- package/src/pipelines/aiNewtonChat.ts +24 -14
- package/src/pipelines/gradeWorksheet.ts +10 -2
- package/src/pipelines/labChatPrompt.ts +196 -68
- package/src/routers/assignment.ts +1 -0
- package/src/routers/class.ts +2 -2
- package/src/routers/labChat.ts +3 -1
- package/src/routers/message.ts +38 -1
- package/src/routers/newtonChat.ts +4 -2
- package/src/routers/notifications.ts +2 -2
- package/src/routers/studentProgress.ts +25 -1
- package/src/routers/worksheet.ts +31 -19
- package/src/services/assignment.ts +30 -2
- package/src/services/auth.ts +26 -12
- package/src/services/class.ts +4 -1
- package/src/services/file.ts +6 -0
- package/src/services/labChat.ts +42 -18
- package/src/services/message.ts +163 -18
- package/src/services/newtonChat.ts +49 -18
- package/src/services/notification.ts +27 -8
- package/src/services/studentProgress.ts +425 -121
- package/src/services/worksheet.ts +191 -51
- package/src/trpc.ts +12 -18
- package/src/utils/inference.ts +205 -112
- package/tests/globalSetup.ts +13 -4
- package/tests/lib/cors.test.ts +103 -0
- package/tests/pipelines/aiLabChat.test.ts +64 -84
- package/tests/routers/auth.test.ts +120 -17
- package/tests/routers/class.test.ts +7 -1
- package/tests/routers/message.test.ts +236 -9
- package/tests/routers/newtonChat.test.ts +81 -0
- package/tests/routers/notification.test.ts +12 -0
- package/tests/routers/studentProgress.test.ts +2 -31
- package/tests/routers/worksheet.test.ts +194 -0
- package/tests/setup.ts +22 -5
- package/tests/utils/aiLabChatPrompt.test.ts +114 -6
- package/tests/utils/inference.test.ts +218 -0
- package/tests/utils/studentProgress.test.ts +361 -0
- package/vitest.unit.config.ts +1 -0
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
import { type WorksheetQuestionType } from "@prisma/client";
|
|
2
2
|
/** Get worksheet with questions and mark schemes. */
|
|
3
|
-
export declare function getWorksheet(worksheetId: string): Promise<{
|
|
3
|
+
export declare function getWorksheet(worksheetId: string, userId: string): Promise<{
|
|
4
4
|
class: {
|
|
5
|
+
name: string;
|
|
5
6
|
id: string;
|
|
6
7
|
schoolId: string | null;
|
|
7
|
-
name: string;
|
|
8
8
|
subject: string;
|
|
9
9
|
color: string | null;
|
|
10
10
|
section: string;
|
|
11
11
|
syllabus: string | null;
|
|
12
12
|
} | null;
|
|
13
13
|
questions: {
|
|
14
|
-
options: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
15
14
|
type: import(".prisma/client").$Enums.WorksheetQuestionType;
|
|
15
|
+
options: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
16
16
|
id: string;
|
|
17
17
|
createdAt: Date;
|
|
18
|
-
updatedAt: Date;
|
|
19
18
|
order: number | null;
|
|
20
|
-
|
|
19
|
+
points: number;
|
|
20
|
+
updatedAt: Date;
|
|
21
21
|
worksheetId: string;
|
|
22
|
+
markScheme: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
22
23
|
question: string;
|
|
23
24
|
answer: string;
|
|
24
|
-
points: number;
|
|
25
25
|
}[];
|
|
26
26
|
} & {
|
|
27
|
+
name: string;
|
|
27
28
|
id: string;
|
|
28
29
|
createdAt: Date;
|
|
29
|
-
updatedAt: Date;
|
|
30
30
|
classId: string;
|
|
31
|
-
|
|
31
|
+
updatedAt: Date;
|
|
32
32
|
}>;
|
|
33
33
|
/** Check if worksheet exists. */
|
|
34
34
|
export declare function worksheetExists(id: string): Promise<boolean>;
|
|
@@ -37,36 +37,36 @@ export declare function listWorksheets(classId: string): Promise<{
|
|
|
37
37
|
questions: {
|
|
38
38
|
id: string;
|
|
39
39
|
}[];
|
|
40
|
+
name: string;
|
|
40
41
|
id: string;
|
|
41
42
|
createdAt: Date;
|
|
42
|
-
updatedAt: Date;
|
|
43
43
|
classId: string;
|
|
44
|
-
|
|
44
|
+
updatedAt: Date;
|
|
45
45
|
}[]>;
|
|
46
|
-
export declare function updateWorksheetRecord(worksheetId: string, data: {
|
|
46
|
+
export declare function updateWorksheetRecord(worksheetId: string, userId: string, data: {
|
|
47
47
|
name?: string;
|
|
48
48
|
}): Promise<{
|
|
49
|
+
name: string;
|
|
49
50
|
id: string;
|
|
50
51
|
createdAt: Date;
|
|
51
|
-
updatedAt: Date;
|
|
52
52
|
classId: string;
|
|
53
|
-
|
|
53
|
+
updatedAt: Date;
|
|
54
54
|
}>;
|
|
55
|
-
export declare function deleteWorksheetRecord(worksheetId: string): Promise<{
|
|
55
|
+
export declare function deleteWorksheetRecord(worksheetId: string, userId: string): Promise<{
|
|
56
|
+
name: string;
|
|
56
57
|
id: string;
|
|
57
58
|
createdAt: Date;
|
|
58
|
-
updatedAt: Date;
|
|
59
59
|
classId: string;
|
|
60
|
-
|
|
60
|
+
updatedAt: Date;
|
|
61
61
|
}>;
|
|
62
62
|
export declare function createWorksheetRecord(classId: string, name: string): Promise<{
|
|
63
|
+
name: string;
|
|
63
64
|
id: string;
|
|
64
65
|
createdAt: Date;
|
|
65
|
-
updatedAt: Date;
|
|
66
66
|
classId: string;
|
|
67
|
-
|
|
67
|
+
updatedAt: Date;
|
|
68
68
|
}>;
|
|
69
|
-
export declare function addQuestionToWorksheet(worksheetId: string, data: {
|
|
69
|
+
export declare function addQuestionToWorksheet(worksheetId: string, userId: string, data: {
|
|
70
70
|
question: string;
|
|
71
71
|
answer: string;
|
|
72
72
|
points?: number;
|
|
@@ -74,22 +74,22 @@ export declare function addQuestionToWorksheet(worksheetId: string, data: {
|
|
|
74
74
|
markScheme?: object;
|
|
75
75
|
type: WorksheetQuestionType;
|
|
76
76
|
}): Promise<{
|
|
77
|
-
options: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
78
77
|
type: import(".prisma/client").$Enums.WorksheetQuestionType;
|
|
78
|
+
options: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
79
79
|
id: string;
|
|
80
80
|
createdAt: Date;
|
|
81
|
-
updatedAt: Date;
|
|
82
81
|
order: number | null;
|
|
83
|
-
|
|
82
|
+
points: number;
|
|
83
|
+
updatedAt: Date;
|
|
84
84
|
worksheetId: string;
|
|
85
|
+
markScheme: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
85
86
|
question: string;
|
|
86
87
|
answer: string;
|
|
87
|
-
points: number;
|
|
88
88
|
}>;
|
|
89
|
-
export declare function reorderWorksheetQuestions(worksheetId: string, movedId: string, position: "before" | "after", targetId: string): Promise<{
|
|
89
|
+
export declare function reorderWorksheetQuestions(worksheetId: string, userId: string, movedId: string, position: "before" | "after", targetId: string): Promise<{
|
|
90
90
|
id: string;
|
|
91
91
|
}[]>;
|
|
92
|
-
export declare function updateWorksheetQuestionRecord(worksheetId: string, questionId: string, data: {
|
|
92
|
+
export declare function updateWorksheetQuestionRecord(worksheetId: string, questionId: string, userId: string, data: {
|
|
93
93
|
question?: string;
|
|
94
94
|
answer?: string;
|
|
95
95
|
points?: number;
|
|
@@ -97,32 +97,32 @@ export declare function updateWorksheetQuestionRecord(worksheetId: string, quest
|
|
|
97
97
|
markScheme?: object;
|
|
98
98
|
type?: WorksheetQuestionType;
|
|
99
99
|
}): Promise<{
|
|
100
|
-
options: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
101
100
|
type: import(".prisma/client").$Enums.WorksheetQuestionType;
|
|
101
|
+
options: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
102
102
|
id: string;
|
|
103
103
|
createdAt: Date;
|
|
104
|
-
updatedAt: Date;
|
|
105
104
|
order: number | null;
|
|
106
|
-
|
|
105
|
+
points: number;
|
|
106
|
+
updatedAt: Date;
|
|
107
107
|
worksheetId: string;
|
|
108
|
+
markScheme: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
108
109
|
question: string;
|
|
109
110
|
answer: string;
|
|
110
|
-
points: number;
|
|
111
111
|
}>;
|
|
112
|
-
export declare function deleteWorksheetQuestionRecord(worksheetId: string, questionId: string): Promise<{
|
|
113
|
-
options: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
112
|
+
export declare function deleteWorksheetQuestionRecord(worksheetId: string, questionId: string, userId: string): Promise<{
|
|
114
113
|
type: import(".prisma/client").$Enums.WorksheetQuestionType;
|
|
114
|
+
options: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
115
115
|
id: string;
|
|
116
116
|
createdAt: Date;
|
|
117
|
-
updatedAt: Date;
|
|
118
117
|
order: number | null;
|
|
119
|
-
|
|
118
|
+
points: number;
|
|
119
|
+
updatedAt: Date;
|
|
120
120
|
worksheetId: string;
|
|
121
|
+
markScheme: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
121
122
|
question: string;
|
|
122
123
|
answer: string;
|
|
123
|
-
points: number;
|
|
124
124
|
}>;
|
|
125
|
-
export declare function getWorksheetSubmission(worksheetId: string, submissionId: string): Promise<{
|
|
125
|
+
export declare function getWorksheetSubmission(worksheetId: string, submissionId: string, userId: string): Promise<{
|
|
126
126
|
responses: ({
|
|
127
127
|
comments: {
|
|
128
128
|
id: string;
|
|
@@ -131,24 +131,24 @@ export declare function getWorksheetSubmission(worksheetId: string, submissionId
|
|
|
131
131
|
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
132
132
|
id: string;
|
|
133
133
|
createdAt: Date;
|
|
134
|
-
updatedAt: Date | null;
|
|
135
|
-
feedback: string | null;
|
|
136
134
|
studentId: string;
|
|
137
|
-
|
|
135
|
+
questionId: string;
|
|
138
136
|
response: string;
|
|
139
137
|
isCorrect: boolean;
|
|
140
138
|
markschemeState: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
139
|
+
points: number;
|
|
140
|
+
feedback: string | null;
|
|
141
|
+
updatedAt: Date | null;
|
|
141
142
|
studentWorksheetResponseId: string | null;
|
|
142
|
-
questionId: string;
|
|
143
143
|
})[];
|
|
144
144
|
} & {
|
|
145
145
|
id: string;
|
|
146
|
-
createdAt: Date;
|
|
147
|
-
updatedAt: Date;
|
|
148
146
|
submissionId: string | null;
|
|
147
|
+
createdAt: Date;
|
|
149
148
|
studentId: string;
|
|
150
149
|
submittedAt: Date | null;
|
|
151
150
|
submitted: boolean;
|
|
151
|
+
updatedAt: Date;
|
|
152
152
|
worksheetId: string;
|
|
153
153
|
}>;
|
|
154
154
|
export declare function answerWorksheetQuestion(worksheetResponseId: string, questionId: string, response: string, userId: string): Promise<{
|
|
@@ -156,55 +156,55 @@ export declare function answerWorksheetQuestion(worksheetResponseId: string, que
|
|
|
156
156
|
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
157
157
|
id: string;
|
|
158
158
|
createdAt: Date;
|
|
159
|
-
updatedAt: Date | null;
|
|
160
|
-
feedback: string | null;
|
|
161
159
|
studentId: string;
|
|
162
|
-
|
|
160
|
+
questionId: string;
|
|
163
161
|
response: string;
|
|
164
162
|
isCorrect: boolean;
|
|
165
163
|
markschemeState: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
164
|
+
points: number;
|
|
165
|
+
feedback: string | null;
|
|
166
|
+
updatedAt: Date | null;
|
|
166
167
|
studentWorksheetResponseId: string | null;
|
|
167
|
-
questionId: string;
|
|
168
168
|
}[];
|
|
169
169
|
} & {
|
|
170
170
|
id: string;
|
|
171
|
-
createdAt: Date;
|
|
172
|
-
updatedAt: Date;
|
|
173
171
|
submissionId: string | null;
|
|
172
|
+
createdAt: Date;
|
|
174
173
|
studentId: string;
|
|
175
174
|
submittedAt: Date | null;
|
|
176
175
|
submitted: boolean;
|
|
176
|
+
updatedAt: Date;
|
|
177
177
|
worksheetId: string;
|
|
178
178
|
}>;
|
|
179
|
-
export declare function cancelGrading(worksheetResponseId: string, progressId: string): Promise<{
|
|
179
|
+
export declare function cancelGrading(worksheetResponseId: string, progressId: string, userId: string): Promise<{
|
|
180
180
|
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
181
181
|
id: string;
|
|
182
182
|
createdAt: Date;
|
|
183
|
-
updatedAt: Date | null;
|
|
184
|
-
feedback: string | null;
|
|
185
183
|
studentId: string;
|
|
186
|
-
|
|
184
|
+
questionId: string;
|
|
187
185
|
response: string;
|
|
188
186
|
isCorrect: boolean;
|
|
189
187
|
markschemeState: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
188
|
+
points: number;
|
|
189
|
+
feedback: string | null;
|
|
190
|
+
updatedAt: Date | null;
|
|
190
191
|
studentWorksheetResponseId: string | null;
|
|
191
|
-
questionId: string;
|
|
192
192
|
}>;
|
|
193
|
-
export declare function regradeQuestion(worksheetResponseId: string, progressId: string): Promise<{
|
|
193
|
+
export declare function regradeQuestion(worksheetResponseId: string, progressId: string, userId: string): Promise<{
|
|
194
194
|
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
195
195
|
id: string;
|
|
196
196
|
createdAt: Date;
|
|
197
|
-
updatedAt: Date | null;
|
|
198
|
-
feedback: string | null;
|
|
199
197
|
studentId: string;
|
|
200
|
-
|
|
198
|
+
questionId: string;
|
|
201
199
|
response: string;
|
|
202
200
|
isCorrect: boolean;
|
|
203
201
|
markschemeState: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
202
|
+
points: number;
|
|
203
|
+
feedback: string | null;
|
|
204
|
+
updatedAt: Date | null;
|
|
204
205
|
studentWorksheetResponseId: string | null;
|
|
205
|
-
questionId: string;
|
|
206
206
|
}>;
|
|
207
|
-
export declare function gradeAnswer(questionId: string, studentWorksheetResponseId: string, data: {
|
|
207
|
+
export declare function gradeAnswer(questionId: string, studentWorksheetResponseId: string, userId: string, data: {
|
|
208
208
|
responseId?: string;
|
|
209
209
|
response?: string;
|
|
210
210
|
isCorrect: boolean;
|
|
@@ -215,23 +215,23 @@ export declare function gradeAnswer(questionId: string, studentWorksheetResponse
|
|
|
215
215
|
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
216
216
|
id: string;
|
|
217
217
|
createdAt: Date;
|
|
218
|
-
updatedAt: Date | null;
|
|
219
|
-
feedback: string | null;
|
|
220
218
|
studentId: string;
|
|
221
|
-
|
|
219
|
+
questionId: string;
|
|
222
220
|
response: string;
|
|
223
221
|
isCorrect: boolean;
|
|
224
222
|
markschemeState: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
223
|
+
points: number;
|
|
224
|
+
feedback: string | null;
|
|
225
|
+
updatedAt: Date | null;
|
|
225
226
|
studentWorksheetResponseId: string | null;
|
|
226
|
-
questionId: string;
|
|
227
227
|
}>;
|
|
228
228
|
export declare function addCommentToResponse(responseId: string, comment: string, authorId: string): Promise<{
|
|
229
229
|
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
230
230
|
id: string;
|
|
231
|
+
announcementId: string | null;
|
|
231
232
|
createdAt: Date;
|
|
232
|
-
content: string;
|
|
233
233
|
modifiedAt: Date | null;
|
|
234
|
-
|
|
234
|
+
content: string;
|
|
235
235
|
authorId: string;
|
|
236
236
|
parentCommentId: string | null;
|
|
237
237
|
studentQuestionProgressId: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worksheet.d.ts","sourceRoot":"/","sources":["services/worksheet.ts"],"names":[],"mappings":"AAKA,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"worksheet.d.ts","sourceRoot":"/","sources":["services/worksheet.ts"],"names":[],"mappings":"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"}
|
|
@@ -3,22 +3,45 @@
|
|
|
3
3
|
* Integrates with gradeWorksheet pipeline for auto-grading.
|
|
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]="772e1458-6d16-5c53-ba42-60d34dff6ea1")}catch(e){}}();
|
|
7
7
|
import { TRPCError } from "@trpc/server";
|
|
8
8
|
import { GenerationStatus } from "@prisma/client";
|
|
9
9
|
import { prisma } from "../lib/prisma.js";
|
|
10
10
|
import { cancelGradePipeline, regradeWorksheetPipeline } from "../pipelines/gradeWorksheet.js";
|
|
11
|
-
import {
|
|
11
|
+
import { findWorksheetByIdMinimal, findWorksheetByIdForClassMember, findWorksheetByIdForTeacher, findWorksheetsByClassId, createWorksheet, updateWorksheet, deleteWorksheet, findQuestionsByWorksheetId, createWorksheetQuestion, updateWorksheetQuestion, deleteWorksheetQuestion, findSubmissionByIdForWorksheetAccess, findOrCreateWorksheetResponse, findWorksheetResponseByIdForTeacher, findWorksheetResponseWithResponsesForStudent, findWorksheetQuestionByIdForTeacher, findWorksheetQuestionByIdInWorksheet, updateStudentQuestionProgress, createStudentQuestionProgress, findStudentQuestionProgress, updateStudentQuestionProgressForGrading, createStudentQuestionProgressForGrading, createComment, findStudentQuestionProgressByIdForTeacher, findStudentQuestionProgressByIdForTeacherAndResponse, } from "../models/worksheet.js";
|
|
12
|
+
const sanitizeQuestionOptionsForStudent = (options) => {
|
|
13
|
+
if (!Array.isArray(options))
|
|
14
|
+
return options;
|
|
15
|
+
return options.map((option) => {
|
|
16
|
+
if (!option || typeof option !== "object")
|
|
17
|
+
return option;
|
|
18
|
+
const { isCorrect: _isCorrect, ...rest } = option;
|
|
19
|
+
return rest;
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const sanitizeWorksheetForStudent = (worksheet) => ({
|
|
23
|
+
...worksheet,
|
|
24
|
+
questions: worksheet.questions.map((question) => ({
|
|
25
|
+
...question,
|
|
26
|
+
answer: "",
|
|
27
|
+
markScheme: null,
|
|
28
|
+
options: sanitizeQuestionOptionsForStudent(question.options),
|
|
29
|
+
})),
|
|
30
|
+
});
|
|
12
31
|
/** Get worksheet with questions and mark schemes. */
|
|
13
|
-
export async function getWorksheet(worksheetId) {
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
32
|
+
export async function getWorksheet(worksheetId, userId) {
|
|
33
|
+
const teacherWorksheet = await findWorksheetByIdForTeacher(worksheetId, userId);
|
|
34
|
+
if (teacherWorksheet) {
|
|
35
|
+
return teacherWorksheet;
|
|
36
|
+
}
|
|
37
|
+
const studentWorksheet = await findWorksheetByIdForClassMember(worksheetId, userId);
|
|
38
|
+
if (!studentWorksheet) {
|
|
16
39
|
throw new TRPCError({
|
|
17
|
-
code: "
|
|
18
|
-
message: "
|
|
40
|
+
code: "FORBIDDEN",
|
|
41
|
+
message: "You do not have access to this worksheet",
|
|
19
42
|
});
|
|
20
43
|
}
|
|
21
|
-
return
|
|
44
|
+
return sanitizeWorksheetForStudent(studentWorksheet);
|
|
22
45
|
}
|
|
23
46
|
/** Check if worksheet exists. */
|
|
24
47
|
export async function worksheetExists(id) {
|
|
@@ -32,21 +55,35 @@ export async function listWorksheets(classId) {
|
|
|
32
55
|
questionCount: w.questions.length,
|
|
33
56
|
}));
|
|
34
57
|
}
|
|
35
|
-
export async function updateWorksheetRecord(worksheetId, data) {
|
|
58
|
+
export async function updateWorksheetRecord(worksheetId, userId, data) {
|
|
59
|
+
const worksheet = await findWorksheetByIdForTeacher(worksheetId, userId);
|
|
60
|
+
if (!worksheet) {
|
|
61
|
+
throw new TRPCError({
|
|
62
|
+
code: "FORBIDDEN",
|
|
63
|
+
message: "Only class teachers can update worksheets",
|
|
64
|
+
});
|
|
65
|
+
}
|
|
36
66
|
return updateWorksheet(worksheetId, data);
|
|
37
67
|
}
|
|
38
|
-
export async function deleteWorksheetRecord(worksheetId) {
|
|
68
|
+
export async function deleteWorksheetRecord(worksheetId, userId) {
|
|
69
|
+
const worksheet = await findWorksheetByIdForTeacher(worksheetId, userId);
|
|
70
|
+
if (!worksheet) {
|
|
71
|
+
throw new TRPCError({
|
|
72
|
+
code: "FORBIDDEN",
|
|
73
|
+
message: "Only class teachers can delete worksheets",
|
|
74
|
+
});
|
|
75
|
+
}
|
|
39
76
|
return deleteWorksheet(worksheetId);
|
|
40
77
|
}
|
|
41
78
|
export async function createWorksheetRecord(classId, name) {
|
|
42
79
|
return createWorksheet({ classId, name });
|
|
43
80
|
}
|
|
44
|
-
export async function addQuestionToWorksheet(worksheetId, data) {
|
|
45
|
-
const worksheet = await
|
|
81
|
+
export async function addQuestionToWorksheet(worksheetId, userId, data) {
|
|
82
|
+
const worksheet = await findWorksheetByIdForTeacher(worksheetId, userId);
|
|
46
83
|
if (!worksheet) {
|
|
47
84
|
throw new TRPCError({
|
|
48
|
-
code: "
|
|
49
|
-
message: "
|
|
85
|
+
code: "FORBIDDEN",
|
|
86
|
+
message: "Only class teachers can modify worksheet questions",
|
|
50
87
|
});
|
|
51
88
|
}
|
|
52
89
|
return createWorksheetQuestion({
|
|
@@ -54,12 +91,12 @@ export async function addQuestionToWorksheet(worksheetId, data) {
|
|
|
54
91
|
...data,
|
|
55
92
|
});
|
|
56
93
|
}
|
|
57
|
-
export async function reorderWorksheetQuestions(worksheetId, movedId, position, targetId) {
|
|
58
|
-
const worksheet = await
|
|
94
|
+
export async function reorderWorksheetQuestions(worksheetId, userId, movedId, position, targetId) {
|
|
95
|
+
const worksheet = await findWorksheetByIdForTeacher(worksheetId, userId);
|
|
59
96
|
if (!worksheet) {
|
|
60
97
|
throw new TRPCError({
|
|
61
|
-
code: "
|
|
62
|
-
message: "
|
|
98
|
+
code: "FORBIDDEN",
|
|
99
|
+
message: "Only class teachers can reorder worksheet questions",
|
|
63
100
|
});
|
|
64
101
|
}
|
|
65
102
|
const questions = await findQuestionsByWorksheetId(worksheetId);
|
|
@@ -99,51 +136,64 @@ export async function reorderWorksheetQuestions(worksheetId, movedId, position,
|
|
|
99
136
|
})));
|
|
100
137
|
return next;
|
|
101
138
|
}
|
|
102
|
-
export async function updateWorksheetQuestionRecord(worksheetId, questionId, data) {
|
|
103
|
-
const
|
|
104
|
-
if (!
|
|
139
|
+
export async function updateWorksheetQuestionRecord(worksheetId, questionId, userId, data) {
|
|
140
|
+
const question = await findWorksheetQuestionByIdForTeacher(questionId, userId);
|
|
141
|
+
if (!question || question.worksheetId !== worksheetId) {
|
|
105
142
|
throw new TRPCError({
|
|
106
|
-
code: "
|
|
107
|
-
message: "
|
|
143
|
+
code: "FORBIDDEN",
|
|
144
|
+
message: "Only class teachers can update worksheet questions",
|
|
108
145
|
});
|
|
109
146
|
}
|
|
110
147
|
return updateWorksheetQuestion(questionId, data);
|
|
111
148
|
}
|
|
112
|
-
export async function deleteWorksheetQuestionRecord(worksheetId, questionId) {
|
|
113
|
-
const
|
|
114
|
-
if (!
|
|
149
|
+
export async function deleteWorksheetQuestionRecord(worksheetId, questionId, userId) {
|
|
150
|
+
const question = await findWorksheetQuestionByIdForTeacher(questionId, userId);
|
|
151
|
+
if (!question || question.worksheetId !== worksheetId) {
|
|
115
152
|
throw new TRPCError({
|
|
116
|
-
code: "
|
|
117
|
-
message: "
|
|
153
|
+
code: "FORBIDDEN",
|
|
154
|
+
message: "Only class teachers can delete worksheet questions",
|
|
118
155
|
});
|
|
119
156
|
}
|
|
120
157
|
return deleteWorksheetQuestion(questionId);
|
|
121
158
|
}
|
|
122
|
-
export async function getWorksheetSubmission(worksheetId, submissionId) {
|
|
123
|
-
const
|
|
159
|
+
export async function getWorksheetSubmission(worksheetId, submissionId, userId) {
|
|
160
|
+
const worksheet = await findWorksheetByIdForClassMember(worksheetId, userId);
|
|
161
|
+
if (!worksheet) {
|
|
162
|
+
throw new TRPCError({
|
|
163
|
+
code: "FORBIDDEN",
|
|
164
|
+
message: "You do not have access to this worksheet",
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
const submission = await findSubmissionByIdForWorksheetAccess(submissionId, worksheetId, worksheet.classId, userId);
|
|
124
168
|
if (!submission) {
|
|
125
169
|
throw new TRPCError({
|
|
126
|
-
code: "
|
|
127
|
-
message: "
|
|
170
|
+
code: "FORBIDDEN",
|
|
171
|
+
message: "You do not have access to this worksheet submission",
|
|
128
172
|
});
|
|
129
173
|
}
|
|
130
174
|
return findOrCreateWorksheetResponse(submissionId, worksheetId, submission.studentId);
|
|
131
175
|
}
|
|
132
176
|
export async function answerWorksheetQuestion(worksheetResponseId, questionId, response, userId) {
|
|
133
|
-
const worksheetResponse = await
|
|
177
|
+
const worksheetResponse = await findWorksheetResponseWithResponsesForStudent(worksheetResponseId, userId, questionId);
|
|
134
178
|
if (!worksheetResponse) {
|
|
179
|
+
throw new TRPCError({
|
|
180
|
+
code: "FORBIDDEN",
|
|
181
|
+
message: "You can only answer your own worksheet responses",
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
const question = await findWorksheetQuestionByIdInWorksheet(questionId, worksheetResponse.worksheetId);
|
|
185
|
+
if (!question) {
|
|
135
186
|
throw new TRPCError({
|
|
136
187
|
code: "NOT_FOUND",
|
|
137
|
-
message: "Worksheet
|
|
188
|
+
message: "Worksheet question not found",
|
|
138
189
|
});
|
|
139
190
|
}
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
const marksAwardedIfCorrect = question?.points || 0;
|
|
191
|
+
const isMarkableByAlgo = question.type === "MULTIPLE_CHOICE" || question.type === "TRUE_FALSE";
|
|
192
|
+
const marksAwardedIfCorrect = question.points || 0;
|
|
143
193
|
const correctAnswer = isMarkableByAlgo
|
|
144
|
-
? question
|
|
145
|
-
? question
|
|
146
|
-
: question
|
|
194
|
+
? question.type === "MULTIPLE_CHOICE"
|
|
195
|
+
? question.options?.find((o) => o.isCorrect)?.id
|
|
196
|
+
: question.answer?.toString()
|
|
147
197
|
: null;
|
|
148
198
|
const existingResponse = worksheetResponse.responses[0];
|
|
149
199
|
if (existingResponse) {
|
|
@@ -178,14 +228,51 @@ export async function answerWorksheetQuestion(worksheetResponseId, questionId, r
|
|
|
178
228
|
});
|
|
179
229
|
return updated;
|
|
180
230
|
}
|
|
181
|
-
export async function cancelGrading(worksheetResponseId, progressId) {
|
|
231
|
+
export async function cancelGrading(worksheetResponseId, progressId, userId) {
|
|
232
|
+
const progress = await findStudentQuestionProgressByIdForTeacherAndResponse(progressId, worksheetResponseId, userId);
|
|
233
|
+
if (!progress) {
|
|
234
|
+
throw new TRPCError({
|
|
235
|
+
code: "FORBIDDEN",
|
|
236
|
+
message: "Only class teachers can cancel worksheet grading",
|
|
237
|
+
});
|
|
238
|
+
}
|
|
182
239
|
return cancelGradePipeline(worksheetResponseId, progressId);
|
|
183
240
|
}
|
|
184
|
-
export async function regradeQuestion(worksheetResponseId, progressId) {
|
|
241
|
+
export async function regradeQuestion(worksheetResponseId, progressId, userId) {
|
|
242
|
+
const progress = await findStudentQuestionProgressByIdForTeacherAndResponse(progressId, worksheetResponseId, userId);
|
|
243
|
+
if (!progress) {
|
|
244
|
+
throw new TRPCError({
|
|
245
|
+
code: "FORBIDDEN",
|
|
246
|
+
message: "Only class teachers can regrade worksheet answers",
|
|
247
|
+
});
|
|
248
|
+
}
|
|
185
249
|
return regradeWorksheetPipeline(worksheetResponseId, progressId);
|
|
186
250
|
}
|
|
187
|
-
export async function gradeAnswer(questionId, studentWorksheetResponseId, data) {
|
|
251
|
+
export async function gradeAnswer(questionId, studentWorksheetResponseId, userId, data) {
|
|
252
|
+
const worksheetResponse = await findWorksheetResponseByIdForTeacher(studentWorksheetResponseId, userId);
|
|
253
|
+
if (!worksheetResponse) {
|
|
254
|
+
throw new TRPCError({
|
|
255
|
+
code: "FORBIDDEN",
|
|
256
|
+
message: "Only class teachers can grade worksheet answers",
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
const question = await findWorksheetQuestionByIdInWorksheet(questionId, worksheetResponse.worksheetId);
|
|
260
|
+
if (!question) {
|
|
261
|
+
throw new TRPCError({
|
|
262
|
+
code: "NOT_FOUND",
|
|
263
|
+
message: "Worksheet question not found",
|
|
264
|
+
});
|
|
265
|
+
}
|
|
188
266
|
if (data.responseId) {
|
|
267
|
+
const existingProgress = await findStudentQuestionProgressByIdForTeacher(data.responseId, userId);
|
|
268
|
+
if (!existingProgress ||
|
|
269
|
+
existingProgress.studentWorksheetResponseId !== studentWorksheetResponseId ||
|
|
270
|
+
existingProgress.questionId !== questionId) {
|
|
271
|
+
throw new TRPCError({
|
|
272
|
+
code: "FORBIDDEN",
|
|
273
|
+
message: "Only class teachers can grade worksheet answers",
|
|
274
|
+
});
|
|
275
|
+
}
|
|
189
276
|
return updateStudentQuestionProgressForGrading(data.responseId, {
|
|
190
277
|
isCorrect: data.isCorrect,
|
|
191
278
|
feedback: data.feedback,
|
|
@@ -193,16 +280,6 @@ export async function gradeAnswer(questionId, studentWorksheetResponseId, data)
|
|
|
193
280
|
points: data.points,
|
|
194
281
|
});
|
|
195
282
|
}
|
|
196
|
-
const worksheetResponse = await prisma.studentWorksheetResponse.findUnique({
|
|
197
|
-
where: { id: studentWorksheetResponseId },
|
|
198
|
-
select: { studentId: true },
|
|
199
|
-
});
|
|
200
|
-
if (!worksheetResponse) {
|
|
201
|
-
throw new TRPCError({
|
|
202
|
-
code: "NOT_FOUND",
|
|
203
|
-
message: "Student worksheet response not found",
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
283
|
const existing = await findStudentQuestionProgress(worksheetResponse.studentId, questionId, studentWorksheetResponseId);
|
|
207
284
|
if (existing) {
|
|
208
285
|
return updateStudentQuestionProgressForGrading(existing.id, {
|
|
@@ -225,6 +302,13 @@ export async function gradeAnswer(questionId, studentWorksheetResponseId, data)
|
|
|
225
302
|
});
|
|
226
303
|
}
|
|
227
304
|
export async function addCommentToResponse(responseId, comment, authorId) {
|
|
305
|
+
const progress = await findStudentQuestionProgressByIdForTeacher(responseId, authorId);
|
|
306
|
+
if (!progress) {
|
|
307
|
+
throw new TRPCError({
|
|
308
|
+
code: "FORBIDDEN",
|
|
309
|
+
message: "Only class teachers can comment on worksheet responses",
|
|
310
|
+
});
|
|
311
|
+
}
|
|
228
312
|
return createComment({
|
|
229
313
|
studentQuestionProgressId: responseId,
|
|
230
314
|
content: comment,
|
|
@@ -232,4 +316,4 @@ export async function addCommentToResponse(responseId, comment, authorId) {
|
|
|
232
316
|
});
|
|
233
317
|
}
|
|
234
318
|
//# sourceMappingURL=worksheet.js.map
|
|
235
|
-
//# debugId=
|
|
319
|
+
//# debugId=772e1458-6d16-5c53-ba42-60d34dff6ea1
|