@studious-lms/server 1.2.32 → 1.2.33
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/routers/_app.d.ts +116 -88
- package/dist/routers/_app.d.ts.map +1 -1
- package/dist/routers/assignment.d.ts +32 -18
- package/dist/routers/assignment.d.ts.map +1 -1
- package/dist/routers/assignment.js +337 -219
- package/dist/routers/class.d.ts +7 -7
- package/dist/routers/class.d.ts.map +1 -1
- package/dist/routers/class.js +18 -2
- package/dist/routers/event.d.ts +2 -2
- package/dist/routers/worksheet.d.ts +17 -17
- package/dist/routers/worksheet.d.ts.map +1 -1
- package/dist/routers/worksheet.js +30 -7
- package/package.json +1 -1
- package/prisma/schema.prisma +4 -3
- package/src/routers/assignment.ts +443 -310
- package/src/routers/class.ts +18 -2
- package/src/routers/worksheet.ts +33 -7
package/src/routers/class.ts
CHANGED
|
@@ -154,6 +154,22 @@ export const classRouter = createTRPCRouter({
|
|
|
154
154
|
},
|
|
155
155
|
},
|
|
156
156
|
assignments: {
|
|
157
|
+
...(!isTeacher && {
|
|
158
|
+
where: {OR: [
|
|
159
|
+
{
|
|
160
|
+
assignedTo: {
|
|
161
|
+
some: {
|
|
162
|
+
id: ctx.user?.id,
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
assignedTo: {
|
|
168
|
+
none: {},
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
],}
|
|
172
|
+
}),
|
|
157
173
|
select: {
|
|
158
174
|
type: true,
|
|
159
175
|
id: true,
|
|
@@ -217,8 +233,8 @@ export const classRouter = createTRPCRouter({
|
|
|
217
233
|
assignments: classData.assignments.map(assignment => ({
|
|
218
234
|
...assignment,
|
|
219
235
|
late: assignment.dueDate < new Date(),
|
|
220
|
-
submitted: assignment.submissions.
|
|
221
|
-
returned: assignment.submissions.
|
|
236
|
+
submitted: assignment.submissions.find(submission => submission.studentId === ctx.user?.id)?.submitted,
|
|
237
|
+
returned: assignment.submissions.find(submission => submission.studentId === ctx.user?.id)?.returned,
|
|
222
238
|
})),
|
|
223
239
|
}
|
|
224
240
|
|
package/src/routers/worksheet.ts
CHANGED
|
@@ -223,6 +223,7 @@ export const worksheetRouter = createTRPCRouter({
|
|
|
223
223
|
...(answer !== undefined && { answer }),
|
|
224
224
|
...(markScheme !== undefined && { markScheme }),
|
|
225
225
|
...(type !== undefined && { type }),
|
|
226
|
+
...(options !== undefined && { options }),
|
|
226
227
|
},
|
|
227
228
|
});
|
|
228
229
|
|
|
@@ -267,11 +268,36 @@ export const worksheetRouter = createTRPCRouter({
|
|
|
267
268
|
throw new TRPCError({ code: 'NOT_FOUND', message: 'Submission not found' });
|
|
268
269
|
}
|
|
269
270
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
271
|
+
// Find or create worksheet response for this submission
|
|
272
|
+
const worksheetResponses = await prisma.$transaction(async (tx) => {
|
|
273
|
+
// First check if a response exists
|
|
274
|
+
const existing = await tx.studentWorksheetResponse.findFirst({
|
|
275
|
+
where: {
|
|
276
|
+
submissionId,
|
|
277
|
+
worksheetId
|
|
278
|
+
},
|
|
279
|
+
include: {
|
|
280
|
+
responses: true,
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
if (existing) {
|
|
285
|
+
return existing;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Create new response if it doesn't exist
|
|
289
|
+
const created = await tx.studentWorksheetResponse.create({
|
|
290
|
+
data: {
|
|
291
|
+
worksheetId,
|
|
292
|
+
submissionId,
|
|
293
|
+
studentId: submission.studentId,
|
|
294
|
+
},
|
|
295
|
+
include: {
|
|
296
|
+
responses: true,
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
return created;
|
|
275
301
|
});
|
|
276
302
|
|
|
277
303
|
return worksheetResponses;
|
|
@@ -421,14 +447,14 @@ export const worksheetRouter = createTRPCRouter({
|
|
|
421
447
|
}),
|
|
422
448
|
|
|
423
449
|
// Get all student responses for a worksheet (teacher view)
|
|
424
|
-
|
|
450
|
+
getWorksheetResponse: protectedProcedure
|
|
425
451
|
.input(z.object({
|
|
426
452
|
worksheetId: z.string(),
|
|
427
453
|
}))
|
|
428
454
|
.query(async ({ ctx, input }) => {
|
|
429
455
|
const { worksheetId } = input;
|
|
430
456
|
|
|
431
|
-
const responses = await prisma.studentWorksheetResponse.
|
|
457
|
+
const responses = await prisma.studentWorksheetResponse.findFirst({
|
|
432
458
|
where: { worksheetId },
|
|
433
459
|
include: {
|
|
434
460
|
student: {
|