@anantagnanam/lms 0.2.0 → 0.3.0
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/README.md +19 -2
- package/astro/assignment-player.ts +231 -0
- package/astro/client.ts +24 -1
- package/astro/components/AssignmentFeedback.astro +32 -0
- package/astro/components/AssignmentRubric.astro +27 -0
- package/astro/components/LearnerDashboard.astro +3 -0
- package/astro/components/LearningShell.astro +6 -0
- package/astro/components/LessonContent.astro +16 -2
- package/astro/components/LessonPlayer.astro +126 -38
- package/astro/draft-queue.ts +95 -0
- package/astro/media-player.ts +26 -1
- package/astro/pages/author-preview.astro +2 -0
- package/astro/pages/study.astro +180 -0
- package/astro/quiz-drafts.ts +12 -76
- package/astro/study-tools.ts +386 -0
- package/astro/styles.css +18 -0
- package/astro/transcript-search.ts +56 -0
- package/dist/admin.js +172 -12
- package/dist/admin.js.map +1 -1
- package/dist/assignments-CsuAjxGO.js +75 -0
- package/dist/assignments-CsuAjxGO.js.map +1 -0
- package/dist/astro.js +1 -0
- package/dist/astro.js.map +1 -1
- package/dist/{constants-Cnx7k82Z.js → constants-DyQbwNbP.js} +2 -2
- package/dist/{constants-Cnx7k82Z.js.map → constants-DyQbwNbP.js.map} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/runtime.d.ts +26 -5
- package/dist/runtime.js +307 -16
- package/dist/runtime.js.map +1 -1
- package/dist/schemas.d.ts +69 -3
- package/dist/schemas.js +47 -6
- package/dist/schemas.js.map +1 -1
- package/dist/server.d.ts +9 -2
- package/dist/server.js +6 -3
- package/dist/server.js.map +1 -1
- package/dist/types.d.ts +67 -2
- package/package.json +1 -1
- package/dist/errors-ChzJS9al.js +0 -16
- package/dist/errors-ChzJS9al.js.map +0 -1
package/dist/schemas.d.ts
CHANGED
|
@@ -56,12 +56,29 @@ declare const quizSchema: z.ZodObject<{
|
|
|
56
56
|
after_submit: "after_submit";
|
|
57
57
|
}>>;
|
|
58
58
|
}, z.core.$strip>;
|
|
59
|
+
declare const rubricCriterionSchema: z.ZodObject<{
|
|
60
|
+
id: z.ZodString;
|
|
61
|
+
title: z.ZodString;
|
|
62
|
+
description: z.ZodDefault<z.ZodString>;
|
|
63
|
+
maxPoints: z.ZodNumber;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
declare const rubricScoreSchema: z.ZodObject<{
|
|
66
|
+
criterionId: z.ZodString;
|
|
67
|
+
points: z.ZodNumber;
|
|
68
|
+
feedback: z.ZodDefault<z.ZodString>;
|
|
69
|
+
}, z.core.$strip>;
|
|
59
70
|
declare const assignmentSchema: z.ZodObject<{
|
|
60
71
|
instructions: z.ZodString;
|
|
61
72
|
maxPoints: z.ZodDefault<z.ZodNumber>;
|
|
62
73
|
passingPoints: z.ZodDefault<z.ZodNumber>;
|
|
63
74
|
dueAt: z.ZodDefault<z.ZodNullable<z.ZodISODateTime>>;
|
|
64
75
|
allowResubmission: z.ZodDefault<z.ZodBoolean>;
|
|
76
|
+
rubric: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
77
|
+
id: z.ZodString;
|
|
78
|
+
title: z.ZodString;
|
|
79
|
+
description: z.ZodDefault<z.ZodString>;
|
|
80
|
+
maxPoints: z.ZodNumber;
|
|
81
|
+
}, z.core.$strip>>>;
|
|
65
82
|
}, z.core.$strip>;
|
|
66
83
|
declare const lessonSchema: z.ZodObject<{
|
|
67
84
|
id: z.ZodString;
|
|
@@ -135,6 +152,12 @@ declare const lessonSchema: z.ZodObject<{
|
|
|
135
152
|
passingPoints: z.ZodDefault<z.ZodNumber>;
|
|
136
153
|
dueAt: z.ZodDefault<z.ZodNullable<z.ZodISODateTime>>;
|
|
137
154
|
allowResubmission: z.ZodDefault<z.ZodBoolean>;
|
|
155
|
+
rubric: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
156
|
+
id: z.ZodString;
|
|
157
|
+
title: z.ZodString;
|
|
158
|
+
description: z.ZodDefault<z.ZodString>;
|
|
159
|
+
maxPoints: z.ZodNumber;
|
|
160
|
+
}, z.core.$strip>>>;
|
|
138
161
|
}, z.core.$strip>>>;
|
|
139
162
|
}, z.core.$strip>;
|
|
140
163
|
declare const moduleSchema: z.ZodObject<{
|
|
@@ -215,6 +238,12 @@ declare const moduleSchema: z.ZodObject<{
|
|
|
215
238
|
passingPoints: z.ZodDefault<z.ZodNumber>;
|
|
216
239
|
dueAt: z.ZodDefault<z.ZodNullable<z.ZodISODateTime>>;
|
|
217
240
|
allowResubmission: z.ZodDefault<z.ZodBoolean>;
|
|
241
|
+
rubric: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
242
|
+
id: z.ZodString;
|
|
243
|
+
title: z.ZodString;
|
|
244
|
+
description: z.ZodDefault<z.ZodString>;
|
|
245
|
+
maxPoints: z.ZodNumber;
|
|
246
|
+
}, z.core.$strip>>>;
|
|
218
247
|
}, z.core.$strip>>>;
|
|
219
248
|
}, z.core.$strip>>>;
|
|
220
249
|
}, z.core.$strip>;
|
|
@@ -343,6 +372,12 @@ declare const courseDataSchema: z.ZodObject<{
|
|
|
343
372
|
passingPoints: z.ZodDefault<z.ZodNumber>;
|
|
344
373
|
dueAt: z.ZodDefault<z.ZodNullable<z.ZodISODateTime>>;
|
|
345
374
|
allowResubmission: z.ZodDefault<z.ZodBoolean>;
|
|
375
|
+
rubric: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
376
|
+
id: z.ZodString;
|
|
377
|
+
title: z.ZodString;
|
|
378
|
+
description: z.ZodDefault<z.ZodString>;
|
|
379
|
+
maxPoints: z.ZodNumber;
|
|
380
|
+
}, z.core.$strip>>>;
|
|
346
381
|
}, z.core.$strip>>>;
|
|
347
382
|
}, z.core.$strip>>>;
|
|
348
383
|
}, z.core.$strip>>>;
|
|
@@ -475,6 +510,12 @@ declare const courseSaveSchema: z.ZodObject<{
|
|
|
475
510
|
passingPoints: z.ZodDefault<z.ZodNumber>;
|
|
476
511
|
dueAt: z.ZodDefault<z.ZodNullable<z.ZodISODateTime>>;
|
|
477
512
|
allowResubmission: z.ZodDefault<z.ZodBoolean>;
|
|
513
|
+
rubric: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
514
|
+
id: z.ZodString;
|
|
515
|
+
title: z.ZodString;
|
|
516
|
+
description: z.ZodDefault<z.ZodString>;
|
|
517
|
+
maxPoints: z.ZodNumber;
|
|
518
|
+
}, z.core.$strip>>>;
|
|
478
519
|
}, z.core.$strip>>>;
|
|
479
520
|
}, z.core.$strip>>>;
|
|
480
521
|
}, z.core.$strip>>>;
|
|
@@ -524,6 +565,15 @@ declare const assignmentSubmitSchema: z.ZodObject<{
|
|
|
524
565
|
lessonId: z.ZodString;
|
|
525
566
|
body: z.ZodString;
|
|
526
567
|
attachmentUrl: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
568
|
+
submissionId: z.ZodOptional<z.ZodString>;
|
|
569
|
+
expectedDraftRevision: z.ZodOptional<z.ZodNumber>;
|
|
570
|
+
}, z.core.$strip>;
|
|
571
|
+
declare const assignmentDraftSchema: z.ZodObject<{
|
|
572
|
+
courseId: z.ZodString;
|
|
573
|
+
lessonId: z.ZodString;
|
|
574
|
+
body: z.ZodDefault<z.ZodString>;
|
|
575
|
+
attachmentUrl: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
576
|
+
expectedDraftRevision: z.ZodNumber;
|
|
527
577
|
}, z.core.$strip>;
|
|
528
578
|
declare const enrollmentRequestSchema: z.ZodObject<{
|
|
529
579
|
courseId: z.ZodString;
|
|
@@ -533,9 +583,9 @@ declare const enrollmentAdminSchema: z.ZodObject<{
|
|
|
533
583
|
courseId: z.ZodString;
|
|
534
584
|
userId: z.ZodString;
|
|
535
585
|
status: z.ZodEnum<{
|
|
586
|
+
suspended: "suspended";
|
|
536
587
|
active: "active";
|
|
537
588
|
rejected: "rejected";
|
|
538
|
-
suspended: "suspended";
|
|
539
589
|
cancelled: "cancelled";
|
|
540
590
|
}>;
|
|
541
591
|
reason: z.ZodDefault<z.ZodString>;
|
|
@@ -548,7 +598,12 @@ declare const gradeSchema: z.ZodObject<{
|
|
|
548
598
|
lessonId: z.ZodString;
|
|
549
599
|
userId: z.ZodString;
|
|
550
600
|
submissionId: z.ZodString;
|
|
551
|
-
points: z.ZodNumber
|
|
601
|
+
points: z.ZodOptional<z.ZodNumber>;
|
|
602
|
+
rubricScores: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
603
|
+
criterionId: z.ZodString;
|
|
604
|
+
points: z.ZodNumber;
|
|
605
|
+
feedback: z.ZodDefault<z.ZodString>;
|
|
606
|
+
}, z.core.$strip>>>;
|
|
552
607
|
feedback: z.ZodDefault<z.ZodString>;
|
|
553
608
|
}, z.core.$strip>;
|
|
554
609
|
declare const discussionSchema: z.ZodObject<{
|
|
@@ -610,6 +665,17 @@ declare const noteSchema: z.ZodObject<{
|
|
|
610
665
|
courseId: z.ZodString;
|
|
611
666
|
lessonId: z.ZodString;
|
|
612
667
|
note: z.ZodString;
|
|
668
|
+
expectedRevision: z.ZodDefault<z.ZodNumber>;
|
|
669
|
+
}, z.core.$strip>;
|
|
670
|
+
declare const studyNoteSchema: z.ZodObject<{
|
|
671
|
+
courseId: z.ZodString;
|
|
672
|
+
lessonId: z.ZodString;
|
|
673
|
+
id: z.ZodString;
|
|
674
|
+
body: z.ZodString;
|
|
675
|
+
positionSeconds: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
676
|
+
starred: z.ZodDefault<z.ZodBoolean>;
|
|
677
|
+
archived: z.ZodDefault<z.ZodBoolean>;
|
|
678
|
+
expectedRevision: z.ZodNumber;
|
|
613
679
|
}, z.core.$strip>;
|
|
614
680
|
declare const preferencesSchema: z.ZodObject<{
|
|
615
681
|
emailNotifications: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -647,5 +713,5 @@ declare const pathSaveSchema: z.ZodObject<{
|
|
|
647
713
|
}, z.core.$strip>;
|
|
648
714
|
}, z.core.$strip>;
|
|
649
715
|
//#endregion
|
|
650
|
-
export { answersSchema, assignmentSchema, assignmentSubmitSchema, catalogSchema, certificateActionSchema, certificateRevokeSchema, cohortDataSchema, cohortSaveSchema, courseDataSchema, courseIdSchema, courseSaveSchema, discussionSchema, enrollmentAdminSchema, enrollmentRequestSchema, gradeSchema, idSchema, keySchema, lessonIdSchema, lessonSchema, moderateSchema, moduleSchema, noteSchema, pageSchema, pathDataSchema, pathSaveSchema, playbackSchema, preferencesSchema, questionSchema, quizDraftSchema, quizSchema, quizSubmitSchema, resourceSchema, reviewSchema, safeUrlSchema, settingsSchema };
|
|
716
|
+
export { answersSchema, assignmentDraftSchema, assignmentSchema, assignmentSubmitSchema, catalogSchema, certificateActionSchema, certificateRevokeSchema, cohortDataSchema, cohortSaveSchema, courseDataSchema, courseIdSchema, courseSaveSchema, discussionSchema, enrollmentAdminSchema, enrollmentRequestSchema, gradeSchema, idSchema, keySchema, lessonIdSchema, lessonSchema, moderateSchema, moduleSchema, noteSchema, pageSchema, pathDataSchema, pathSaveSchema, playbackSchema, preferencesSchema, questionSchema, quizDraftSchema, quizSchema, quizSubmitSchema, resourceSchema, reviewSchema, rubricCriterionSchema, rubricScoreSchema, safeUrlSchema, settingsSchema, studyNoteSchema };
|
|
651
717
|
//# sourceMappingURL=schemas.d.ts.map
|
package/dist/schemas.js
CHANGED
|
@@ -84,13 +84,35 @@ const quizSchema = z.object({
|
|
|
84
84
|
"never"
|
|
85
85
|
]).default("after_pass")
|
|
86
86
|
}).refine((quiz) => new Set(quiz.questions.map((question) => question.id)).size === quiz.questions.length, "Question IDs must be unique.");
|
|
87
|
+
const rubricCriterionSchema = z.object({
|
|
88
|
+
id: idSchema,
|
|
89
|
+
title,
|
|
90
|
+
description: z.string().max(2e3).default(""),
|
|
91
|
+
maxPoints: z.number().int().min(1).max(1e3)
|
|
92
|
+
});
|
|
93
|
+
const rubricScoreSchema = z.object({
|
|
94
|
+
criterionId: idSchema,
|
|
95
|
+
points: z.number().int().min(0).max(1e3),
|
|
96
|
+
feedback: z.string().max(2e3).default("")
|
|
97
|
+
});
|
|
87
98
|
const assignmentSchema = z.object({
|
|
88
99
|
instructions: z.string().trim().min(1).max(2e4),
|
|
89
100
|
maxPoints: z.number().int().min(1).max(1e3).default(100),
|
|
90
101
|
passingPoints: z.number().int().min(1).max(1e3).default(60),
|
|
91
102
|
dueAt: timestamp.nullable().default(null),
|
|
92
|
-
allowResubmission: z.boolean().default(true)
|
|
93
|
-
|
|
103
|
+
allowResubmission: z.boolean().default(true),
|
|
104
|
+
rubric: z.array(rubricCriterionSchema).max(20).optional()
|
|
105
|
+
}).refine((assignment) => assignment.passingPoints <= assignment.maxPoints, "Passing points cannot exceed maximum points.").superRefine((assignment, ctx) => {
|
|
106
|
+
const rubric = assignment.rubric ?? [];
|
|
107
|
+
if (new Set(rubric.map((item) => item.id)).size !== rubric.length) ctx.addIssue({
|
|
108
|
+
code: "custom",
|
|
109
|
+
message: "Rubric criterion IDs must be unique."
|
|
110
|
+
});
|
|
111
|
+
if (rubric.length && rubric.reduce((sum, item) => sum + item.maxPoints, 0) !== assignment.maxPoints) ctx.addIssue({
|
|
112
|
+
code: "custom",
|
|
113
|
+
message: "Rubric points must add up to the assignment maximum."
|
|
114
|
+
});
|
|
115
|
+
});
|
|
94
116
|
const lessonSchema = z.object({
|
|
95
117
|
id: idSchema,
|
|
96
118
|
title,
|
|
@@ -255,7 +277,14 @@ const quizSubmitSchema = lessonIdSchema.extend({
|
|
|
255
277
|
const quizDraftSchema = quizSubmitSchema.extend({ expectedDraftRevision: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER).default(0) });
|
|
256
278
|
const assignmentSubmitSchema = lessonIdSchema.extend({
|
|
257
279
|
body: z.string().trim().min(1).max(2e4),
|
|
258
|
-
attachmentUrl: safeUrlSchema.nullable().default(null)
|
|
280
|
+
attachmentUrl: safeUrlSchema.nullable().default(null),
|
|
281
|
+
submissionId: idSchema.optional(),
|
|
282
|
+
expectedDraftRevision: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER - 1).optional()
|
|
283
|
+
});
|
|
284
|
+
const assignmentDraftSchema = lessonIdSchema.extend({
|
|
285
|
+
body: z.string().max(2e4).default(""),
|
|
286
|
+
attachmentUrl: safeUrlSchema.nullable().default(null),
|
|
287
|
+
expectedDraftRevision: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER - 1)
|
|
259
288
|
});
|
|
260
289
|
const enrollmentRequestSchema = courseIdSchema.extend({ cohortId: idSchema.optional() });
|
|
261
290
|
const enrollmentAdminSchema = courseIdSchema.extend({
|
|
@@ -274,7 +303,8 @@ const enrollmentAdminSchema = courseIdSchema.extend({
|
|
|
274
303
|
const gradeSchema = lessonIdSchema.extend({
|
|
275
304
|
userId: idSchema,
|
|
276
305
|
submissionId: idSchema,
|
|
277
|
-
points: z.number().int().min(0).max(1e3),
|
|
306
|
+
points: z.number().int().min(0).max(1e3).optional(),
|
|
307
|
+
rubricScores: z.array(rubricScoreSchema).max(20).optional(),
|
|
278
308
|
feedback: z.string().max(1e4).default("")
|
|
279
309
|
});
|
|
280
310
|
const discussionSchema = lessonIdSchema.extend({
|
|
@@ -316,7 +346,18 @@ const certificateRevokeSchema = courseIdSchema.extend({
|
|
|
316
346
|
userId: idSchema,
|
|
317
347
|
reason: z.string().trim().min(1).max(1e3)
|
|
318
348
|
});
|
|
319
|
-
const noteSchema = lessonIdSchema.extend({
|
|
349
|
+
const noteSchema = lessonIdSchema.extend({
|
|
350
|
+
note: z.string().max(1e4),
|
|
351
|
+
expectedRevision: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER - 1).default(0)
|
|
352
|
+
});
|
|
353
|
+
const studyNoteSchema = lessonIdSchema.extend({
|
|
354
|
+
id: idSchema,
|
|
355
|
+
body: z.string().max(5e3),
|
|
356
|
+
positionSeconds: z.number().min(0).max(86400).nullable().default(null),
|
|
357
|
+
starred: z.boolean().default(false),
|
|
358
|
+
archived: z.boolean().default(false),
|
|
359
|
+
expectedRevision: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER - 1)
|
|
360
|
+
}).refine((note) => note.body.trim().length > 0 || note.positionSeconds !== null, "Write a note or choose a media timestamp.");
|
|
320
361
|
const preferencesSchema = z.object({
|
|
321
362
|
emailNotifications: z.boolean().default(true),
|
|
322
363
|
weeklyGoalLessons: z.number().int().min(0).max(100).default(3)
|
|
@@ -343,5 +384,5 @@ const pathSaveSchema = z.object({
|
|
|
343
384
|
});
|
|
344
385
|
|
|
345
386
|
//#endregion
|
|
346
|
-
export { answersSchema, assignmentSchema, assignmentSubmitSchema, catalogSchema, certificateActionSchema, certificateRevokeSchema, cohortDataSchema, cohortSaveSchema, courseDataSchema, courseIdSchema, courseSaveSchema, discussionSchema, enrollmentAdminSchema, enrollmentRequestSchema, gradeSchema, idSchema, keySchema, lessonIdSchema, lessonSchema, moderateSchema, moduleSchema, noteSchema, pageSchema, pathDataSchema, pathSaveSchema, playbackSchema, preferencesSchema, questionSchema, quizDraftSchema, quizSchema, quizSubmitSchema, resourceSchema, reviewSchema, safeUrlSchema, settingsSchema };
|
|
387
|
+
export { answersSchema, assignmentDraftSchema, assignmentSchema, assignmentSubmitSchema, catalogSchema, certificateActionSchema, certificateRevokeSchema, cohortDataSchema, cohortSaveSchema, courseDataSchema, courseIdSchema, courseSaveSchema, discussionSchema, enrollmentAdminSchema, enrollmentRequestSchema, gradeSchema, idSchema, keySchema, lessonIdSchema, lessonSchema, moderateSchema, moduleSchema, noteSchema, pageSchema, pathDataSchema, pathSaveSchema, playbackSchema, preferencesSchema, questionSchema, quizDraftSchema, quizSchema, quizSubmitSchema, resourceSchema, reviewSchema, rubricCriterionSchema, rubricScoreSchema, safeUrlSchema, settingsSchema, studyNoteSchema };
|
|
347
388
|
//# sourceMappingURL=schemas.js.map
|
package/dist/schemas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","names":[],"sources":["../src/schemas.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const idSchema = z\n .string()\n .min(1)\n .max(128)\n .regex(/^[a-zA-Z0-9_-]+$/, \"Use letters, numbers, underscores or hyphens.\")\n .refine(\n (value) => ![\"__proto__\", \"constructor\", \"prototype\"].includes(value),\n \"This identifier is reserved. Choose another ID.\",\n );\nexport const keySchema = z\n .string()\n .min(1)\n .max(1024)\n .regex(/^[a-zA-Z0-9_:.-]+$/);\nconst title = z.string().trim().min(1).max(200);\nconst text = z.string().max(50_000);\nconst timestamp = z.iso.datetime({ offset: true });\nexport const safeUrlSchema = z\n .string()\n .max(2048)\n .refine((value) => {\n if (/^\\/(?!\\/)[^\\s\\\\]*$/.test(value)) return true;\n try {\n const url = new URL(value);\n return url.protocol === \"https:\" && !url.username && !url.password;\n } catch {\n return false;\n }\n }, \"Use an HTTPS URL or a path on this site.\");\n\nexport const resourceSchema = z.object({\n id: idSchema,\n title,\n url: safeUrlSchema,\n description: z.string().max(1000).default(\"\"),\n});\nconst optionSchema = z.object({ id: idSchema, text: z.string().trim().min(1).max(2000) });\nexport const questionSchema = z\n .object({\n id: idSchema,\n type: z.enum([\"single\", \"multiple\", \"true_false\", \"short\"]),\n prompt: z.string().trim().min(1).max(5000),\n options: z.array(optionSchema).max(10).default([]),\n correctAnswers: z.array(z.string().trim().min(1).max(500)).min(1).max(10),\n points: z.number().int().min(1).max(100).default(1),\n explanation: z.string().max(5000).default(\"\"),\n })\n .superRefine((question, ctx) => {\n const optionIds = question.options.map((option) => option.id);\n if (new Set(optionIds).size !== optionIds.length)\n ctx.addIssue({ code: \"custom\", message: \"Option IDs must be unique.\" });\n if (new Set(question.correctAnswers).size !== question.correctAnswers.length)\n ctx.addIssue({ code: \"custom\", message: \"Correct answers must be unique.\" });\n if (question.type !== \"short\") {\n if (question.options.length < 2)\n ctx.addIssue({ code: \"custom\", message: \"Choice questions need at least two options.\" });\n if (question.correctAnswers.some((answer) => !optionIds.includes(answer)))\n ctx.addIssue({ code: \"custom\", message: \"Correct answers must refer to option IDs.\" });\n if (question.type !== \"multiple\" && question.correctAnswers.length !== 1)\n ctx.addIssue({ code: \"custom\", message: \"This question requires one correct answer.\" });\n if (\n question.type === \"true_false\" &&\n (question.options.length !== 2 ||\n !optionIds.includes(\"true\") ||\n !optionIds.includes(\"false\"))\n )\n ctx.addIssue({\n code: \"custom\",\n message: \"True/false options must have the IDs true and false.\",\n });\n }\n });\nexport const quizSchema = z\n .object({\n questions: z.array(questionSchema).min(1).max(50),\n passingPercent: z.number().int().min(1).max(100).default(70),\n maxAttempts: z.number().int().min(1).max(20).default(3),\n timeLimitMinutes: z.number().int().min(0).max(180).default(30),\n randomizeQuestions: z.boolean().default(true),\n randomizeOptions: z.boolean().default(false),\n showFeedback: z.enum([\"after_pass\", \"after_submit\", \"never\"]).default(\"after_pass\"),\n })\n .refine(\n (quiz) => new Set(quiz.questions.map((question) => question.id)).size === quiz.questions.length,\n \"Question IDs must be unique.\",\n );\n\nexport const assignmentSchema = z\n .object({\n instructions: z.string().trim().min(1).max(20_000),\n maxPoints: z.number().int().min(1).max(1000).default(100),\n passingPoints: z.number().int().min(1).max(1000).default(60),\n dueAt: timestamp.nullable().default(null),\n allowResubmission: z.boolean().default(true),\n })\n .refine(\n (assignment) => assignment.passingPoints <= assignment.maxPoints,\n \"Passing points cannot exceed maximum points.\",\n );\n\nexport const lessonSchema = z\n .object({\n id: idSchema,\n title,\n summary: z.string().max(2000).default(\"\"),\n kind: z.enum([\"text\", \"video\", \"audio\", \"quiz\", \"assignment\", \"live\"]).default(\"text\"),\n body: text.default(\"\"),\n portableText: z.array(z.record(z.string(), z.unknown())).max(1000).default([]),\n contentSource: z\n .object({ collection: idSchema, id: idSchema, field: idSchema.default(\"content\") })\n .nullable()\n .default(null),\n mediaUrl: safeUrlSchema.nullable().default(null),\n transcript: text.default(\"\"),\n captions: z\n .array(\n z.object({\n src: safeUrlSchema,\n language: z\n .string()\n .regex(/^[a-zA-Z]{2,3}(?:-[a-zA-Z0-9]{2,8})*$/)\n .max(35),\n label: title,\n }),\n )\n .max(20)\n .default([]),\n liveStartsAt: timestamp.nullable().default(null),\n durationMinutes: z.number().int().min(0).max(1440).default(10),\n minStudySeconds: z.number().int().min(0).max(86400).default(0),\n preview: z.boolean().default(false),\n required: z.boolean().default(true),\n resources: z.array(resourceSchema).max(30).default([]),\n quiz: quizSchema.nullable().default(null),\n assignment: assignmentSchema.nullable().default(null),\n })\n .superRefine((lesson, ctx) => {\n if (lesson.kind === \"quiz\" && !lesson.quiz)\n ctx.addIssue({ code: \"custom\", message: \"Quiz lessons need a quiz.\" });\n if (lesson.kind === \"assignment\" && !lesson.assignment)\n ctx.addIssue({ code: \"custom\", message: \"Assignment lessons need an assignment.\" });\n if ([\"video\", \"audio\", \"live\"].includes(lesson.kind) && !lesson.mediaUrl)\n ctx.addIssue({ code: \"custom\", message: \"Media and live lessons need a URL.\" });\n if (lesson.kind === \"live\" && !lesson.liveStartsAt)\n ctx.addIssue({ code: \"custom\", message: \"Live lessons need a start time.\" });\n if (new Set(lesson.resources.map((resource) => resource.id)).size !== lesson.resources.length)\n ctx.addIssue({ code: \"custom\", message: \"Resource IDs must be unique.\" });\n });\n\nexport const moduleSchema = z.object({\n id: idSchema,\n title,\n description: z.string().max(2000).default(\"\"),\n releaseDays: z.number().int().min(0).max(3650).default(0),\n unlockAt: timestamp.nullable().default(null),\n lessons: z.array(lessonSchema).max(100).default([]),\n});\n\nexport const courseDataSchema = z\n .object({\n slug: z\n .string()\n .trim()\n .min(1)\n .max(100)\n .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, \"Use lowercase words separated by hyphens.\"),\n title,\n summary: z.string().trim().max(1000).default(\"\"),\n description: text.default(\"\"),\n outcomes: z.array(z.string().trim().min(1).max(500)).max(30).default([]),\n requirements: z.array(z.string().trim().min(1).max(500)).max(30).default([]),\n category: z.string().trim().max(100).default(\"\"),\n tags: z.array(z.string().trim().min(1).max(60)).max(20).default([]),\n language: z.string().trim().min(2).max(35).default(\"en\"),\n level: z.enum([\"beginner\", \"intermediate\", \"advanced\", \"all\"]).default(\"all\"),\n featuredImage: z\n .object({\n id: z.string().max(128).default(\"\"),\n src: safeUrlSchema,\n alt: z.string().max(500).default(\"\"),\n })\n .nullable()\n .default(null),\n instructorName: z.string().trim().max(200).default(\"\"),\n instructorIds: z.array(idSchema).max(20).default([]),\n status: z.enum([\"draft\", \"published\", \"archived\"]).default(\"draft\"),\n enrollmentMode: z.enum([\"open\", \"approval\", \"invite\"]).default(\"open\"),\n commerce: z\n .object({\n accessModel: z.enum([\"free\", \"paid\"]).default(\"free\"),\n offerId: idSchema.nullable().default(null),\n priceMinor: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER).nullable().default(null),\n currency: z\n .string()\n .regex(/^[A-Z]{3}$/)\n .default(\"INR\"),\n })\n .default({ accessModel: \"free\", offerId: null, priceMinor: null, currency: \"INR\" }),\n prerequisiteCourseIds: z.array(idSchema).max(20).default([]),\n sequential: z.boolean().default(true),\n enrollmentClosesAt: timestamp.nullable().default(null),\n accessDays: z.number().int().min(0).max(3650).default(0),\n certificateEnabled: z.boolean().default(true),\n modules: z.array(moduleSchema).max(50).default([]),\n })\n .superRefine((course, ctx) => {\n const allIds = course.modules.flatMap((module) => [\n module.id,\n ...module.lessons.map((lesson) => lesson.id),\n ]);\n if (new Set(allIds).size !== allIds.length)\n ctx.addIssue({\n code: \"custom\",\n message: \"Module and lesson IDs must be unique across the course.\",\n });\n if (course.modules.flatMap((module) => module.lessons).length > 150)\n ctx.addIssue({ code: \"custom\", message: \"A course supports up to 150 lessons.\" });\n if (\n course.status === \"published\" &&\n !course.modules.some((module) => module.lessons.some((lesson) => lesson.required))\n )\n ctx.addIssue({\n code: \"custom\",\n message: \"Publish a course with at least one required lesson.\",\n });\n });\n\nexport const courseSaveSchema = z.object({\n id: idSchema.optional(),\n expectedRevision: z.string().max(128).nullable().default(null),\n data: courseDataSchema,\n});\nexport const pageSchema = z.object({\n cursor: z.string().max(4000).optional(),\n limit: z.coerce.number().int().min(1).max(100).default(24),\n});\nexport const catalogSchema = pageSchema.extend({\n q: z.string().max(100).default(\"\"),\n category: z.string().max(100).default(\"\"),\n level: z.enum([\"beginner\", \"intermediate\", \"advanced\", \"all\"]).optional(),\n language: z.string().max(35).optional(),\n});\nexport const courseIdSchema = z.object({ courseId: idSchema });\nexport const lessonIdSchema = courseIdSchema.extend({ lessonId: idSchema });\nexport const answersSchema = z.record(\n idSchema,\n z.union([z.string().max(2000), z.array(z.string().max(500)).max(10)]),\n);\nexport const quizSubmitSchema = lessonIdSchema.extend({\n attemptId: idSchema,\n answers: answersSchema,\n expectedDraftRevision: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER).optional(),\n});\nexport const quizDraftSchema = quizSubmitSchema.extend({\n expectedDraftRevision: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER).default(0),\n});\nexport const assignmentSubmitSchema = lessonIdSchema.extend({\n body: z.string().trim().min(1).max(20_000),\n attachmentUrl: safeUrlSchema.nullable().default(null),\n});\nexport const enrollmentRequestSchema = courseIdSchema.extend({ cohortId: idSchema.optional() });\nexport const enrollmentAdminSchema = courseIdSchema.extend({\n userId: idSchema,\n status: z.enum([\"active\", \"rejected\", \"suspended\", \"cancelled\"]),\n reason: z.string().max(1000).default(\"\"),\n cohortId: idSchema.nullable().optional(),\n accessStartsAt: timestamp.nullable().optional(),\n accessExpiresAt: timestamp.nullable().optional(),\n});\nexport const gradeSchema = lessonIdSchema.extend({\n userId: idSchema,\n submissionId: idSchema,\n points: z.number().int().min(0).max(1000),\n feedback: z.string().max(10_000).default(\"\"),\n});\nexport const discussionSchema = lessonIdSchema.extend({\n body: z.string().trim().min(1).max(5000),\n parentId: idSchema.nullable().default(null),\n});\nexport const reviewSchema = courseIdSchema.extend({\n rating: z.number().int().min(1).max(5),\n body: z.string().trim().min(1).max(3000),\n});\nexport const moderateSchema = z.object({\n id: keySchema,\n status: z.enum([\"published\", \"hidden\"]),\n expectedRevision: z.string().min(1).max(128),\n});\nexport const cohortDataSchema = z\n .object({\n title,\n courseIds: z.array(idSchema).min(1).max(20),\n memberIds: z.array(idSchema).max(1000).default([]),\n startsAt: timestamp.nullable().default(null),\n endsAt: timestamp.nullable().default(null),\n })\n .refine(\n (cohort) =>\n !cohort.startsAt || !cohort.endsAt || Date.parse(cohort.endsAt) > Date.parse(cohort.startsAt),\n \"Cohort end must follow its start.\",\n )\n .refine(\n (cohort) => new Set(cohort.memberIds).size === cohort.memberIds.length,\n \"Cohort members must be unique.\",\n )\n .refine(\n (cohort) => new Set(cohort.courseIds).size === cohort.courseIds.length,\n \"Cohort courses must be unique.\",\n );\nexport const cohortSaveSchema = z.object({\n id: idSchema.optional(),\n expectedRevision: z.string().max(128).nullable().default(null),\n data: cohortDataSchema,\n});\nexport const settingsSchema = z.object({\n academyTitle: title.default(\"Ananta Gnanam Academy\"),\n academyDescription: z.string().max(2000).default(\"Build knowledge, one lesson at a time.\"),\n issuerName: title.default(\"Ananta Gnanam\"),\n moderateDiscussions: z.boolean().default(true),\n moderateReviews: z.boolean().default(true),\n emailNotifications: z.boolean().default(false),\n reminderDays: z.number().int().min(0).max(90).default(7),\n});\nexport const certificateActionSchema = courseIdSchema.extend({ shared: z.boolean() });\nexport const certificateRevokeSchema = courseIdSchema.extend({\n userId: idSchema,\n reason: z.string().trim().min(1).max(1000),\n});\nexport const noteSchema = lessonIdSchema.extend({ note: z.string().max(10_000) });\n\nexport const preferencesSchema = z.object({\n emailNotifications: z.boolean().default(true),\n weeklyGoalLessons: z.number().int().min(0).max(100).default(3),\n});\nexport const playbackSchema = lessonIdSchema.extend({\n positionSeconds: z.number().finite().min(0).max(86_400),\n playbackRate: z.number().min(0.25).max(3),\n expectedRevision: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER),\n});\nexport const pathDataSchema = z.object({\n title,\n description: z.string().max(5000).default(\"\"),\n courseIds: z\n .array(idSchema)\n .min(1)\n .max(30)\n .refine((ids) => new Set(ids).size === ids.length, \"Courses must be unique.\"),\n status: z.enum([\"draft\", \"published\", \"archived\"]).default(\"draft\"),\n});\nexport const pathSaveSchema = z.object({\n id: idSchema.optional(),\n expectedRevision: z.string().max(128).nullable().default(null),\n data: pathDataSchema,\n});\n"],"mappings":";;;AAEA,MAAa,WAAW,EACrB,QAAQ,CACR,IAAI,EAAE,CACN,IAAI,IAAI,CACR,MAAM,oBAAoB,gDAAgD,CAC1E,QACE,UAAU,CAAC;CAAC;CAAa;CAAe;CAAY,CAAC,SAAS,MAAM,EACrE,kDACD;AACH,MAAa,YAAY,EACtB,QAAQ,CACR,IAAI,EAAE,CACN,IAAI,KAAK,CACT,MAAM,qBAAqB;AAC9B,MAAM,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI;AAC/C,MAAM,OAAO,EAAE,QAAQ,CAAC,IAAI,IAAO;AACnC,MAAM,YAAY,EAAE,IAAI,SAAS,EAAE,QAAQ,MAAM,CAAC;AAClD,MAAa,gBAAgB,EAC1B,QAAQ,CACR,IAAI,KAAK,CACT,QAAQ,UAAU;AACjB,KAAI,qBAAqB,KAAK,MAAM,CAAE,QAAO;AAC7C,KAAI;EACF,MAAM,MAAM,IAAI,IAAI,MAAM;AAC1B,SAAO,IAAI,aAAa,YAAY,CAAC,IAAI,YAAY,CAAC,IAAI;SACpD;AACN,SAAO;;GAER,2CAA2C;AAEhD,MAAa,iBAAiB,EAAE,OAAO;CACrC,IAAI;CACJ;CACA,KAAK;CACL,aAAa,EAAE,QAAQ,CAAC,IAAI,IAAK,CAAC,QAAQ,GAAG;CAC9C,CAAC;AACF,MAAM,eAAe,EAAE,OAAO;CAAE,IAAI;CAAU,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,IAAK;CAAE,CAAC;AACzF,MAAa,iBAAiB,EAC3B,OAAO;CACN,IAAI;CACJ,MAAM,EAAE,KAAK;EAAC;EAAU;EAAY;EAAc;EAAQ,CAAC;CAC3D,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,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,IAAI,IAAO,EAAE,CAAC;AAEjF,MAAa,oBAAoB,EAAE,OAAO;CACxC,oBAAoB,EAAE,SAAS,CAAC,QAAQ,KAAK;CAC7C,mBAAmB,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE;CAC/D,CAAC;AACF,MAAa,iBAAiB,eAAe,OAAO;CAClD,iBAAiB,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,MAAO;CACvD,cAAc,EAAE,QAAQ,CAAC,IAAI,IAAK,CAAC,IAAI,EAAE;CACzC,kBAAkB,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,OAAO,iBAAiB;CACvE,CAAC;AACF,MAAa,iBAAiB,EAAE,OAAO;CACrC;CACA,aAAa,EAAE,QAAQ,CAAC,IAAI,IAAK,CAAC,QAAQ,GAAG;CAC7C,WAAW,EACR,MAAM,SAAS,CACf,IAAI,EAAE,CACN,IAAI,GAAG,CACP,QAAQ,QAAQ,IAAI,IAAI,IAAI,CAAC,SAAS,IAAI,QAAQ,0BAA0B;CAC/E,QAAQ,EAAE,KAAK;EAAC;EAAS;EAAa;EAAW,CAAC,CAAC,QAAQ,QAAQ;CACpE,CAAC;AACF,MAAa,iBAAiB,EAAE,OAAO;CACrC,IAAI,SAAS,UAAU;CACvB,kBAAkB,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,KAAK;CAC9D,MAAM;CACP,CAAC"}
|
|
1
|
+
{"version":3,"file":"schemas.js","names":[],"sources":["../src/schemas.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const idSchema = z\n .string()\n .min(1)\n .max(128)\n .regex(/^[a-zA-Z0-9_-]+$/, \"Use letters, numbers, underscores or hyphens.\")\n .refine(\n (value) => ![\"__proto__\", \"constructor\", \"prototype\"].includes(value),\n \"This identifier is reserved. Choose another ID.\",\n );\nexport const keySchema = z\n .string()\n .min(1)\n .max(1024)\n .regex(/^[a-zA-Z0-9_:.-]+$/);\nconst title = z.string().trim().min(1).max(200);\nconst text = z.string().max(50_000);\nconst timestamp = z.iso.datetime({ offset: true });\nexport const safeUrlSchema = z\n .string()\n .max(2048)\n .refine((value) => {\n if (/^\\/(?!\\/)[^\\s\\\\]*$/.test(value)) return true;\n try {\n const url = new URL(value);\n return url.protocol === \"https:\" && !url.username && !url.password;\n } catch {\n return false;\n }\n }, \"Use an HTTPS URL or a path on this site.\");\n\nexport const resourceSchema = z.object({\n id: idSchema,\n title,\n url: safeUrlSchema,\n description: z.string().max(1000).default(\"\"),\n});\nconst optionSchema = z.object({ id: idSchema, text: z.string().trim().min(1).max(2000) });\nexport const questionSchema = z\n .object({\n id: idSchema,\n type: z.enum([\"single\", \"multiple\", \"true_false\", \"short\"]),\n prompt: z.string().trim().min(1).max(5000),\n options: z.array(optionSchema).max(10).default([]),\n correctAnswers: z.array(z.string().trim().min(1).max(500)).min(1).max(10),\n points: z.number().int().min(1).max(100).default(1),\n explanation: z.string().max(5000).default(\"\"),\n })\n .superRefine((question, ctx) => {\n const optionIds = question.options.map((option) => option.id);\n if (new Set(optionIds).size !== optionIds.length)\n ctx.addIssue({ code: \"custom\", message: \"Option IDs must be unique.\" });\n if (new Set(question.correctAnswers).size !== question.correctAnswers.length)\n ctx.addIssue({ code: \"custom\", message: \"Correct answers must be unique.\" });\n if (question.type !== \"short\") {\n if (question.options.length < 2)\n ctx.addIssue({ code: \"custom\", message: \"Choice questions need at least two options.\" });\n if (question.correctAnswers.some((answer) => !optionIds.includes(answer)))\n ctx.addIssue({ code: \"custom\", message: \"Correct answers must refer to option IDs.\" });\n if (question.type !== \"multiple\" && question.correctAnswers.length !== 1)\n ctx.addIssue({ code: \"custom\", message: \"This question requires one correct answer.\" });\n if (\n question.type === \"true_false\" &&\n (question.options.length !== 2 ||\n !optionIds.includes(\"true\") ||\n !optionIds.includes(\"false\"))\n )\n ctx.addIssue({\n code: \"custom\",\n message: \"True/false options must have the IDs true and false.\",\n });\n }\n });\nexport const quizSchema = z\n .object({\n questions: z.array(questionSchema).min(1).max(50),\n passingPercent: z.number().int().min(1).max(100).default(70),\n maxAttempts: z.number().int().min(1).max(20).default(3),\n timeLimitMinutes: z.number().int().min(0).max(180).default(30),\n randomizeQuestions: z.boolean().default(true),\n randomizeOptions: z.boolean().default(false),\n showFeedback: z.enum([\"after_pass\", \"after_submit\", \"never\"]).default(\"after_pass\"),\n })\n .refine(\n (quiz) => new Set(quiz.questions.map((question) => question.id)).size === quiz.questions.length,\n \"Question IDs must be unique.\",\n );\n\nexport const rubricCriterionSchema = z.object({\n id: idSchema,\n title,\n description: z.string().max(2000).default(\"\"),\n maxPoints: z.number().int().min(1).max(1000),\n});\nexport const rubricScoreSchema = z.object({\n criterionId: idSchema,\n points: z.number().int().min(0).max(1000),\n feedback: z.string().max(2000).default(\"\"),\n});\nexport const assignmentSchema = z\n .object({\n instructions: z.string().trim().min(1).max(20_000),\n maxPoints: z.number().int().min(1).max(1000).default(100),\n passingPoints: z.number().int().min(1).max(1000).default(60),\n dueAt: timestamp.nullable().default(null),\n allowResubmission: z.boolean().default(true),\n rubric: z.array(rubricCriterionSchema).max(20).optional(),\n })\n .refine(\n (assignment) => assignment.passingPoints <= assignment.maxPoints,\n \"Passing points cannot exceed maximum points.\",\n )\n .superRefine((assignment, ctx) => {\n const rubric = assignment.rubric ?? [];\n if (new Set(rubric.map((item) => item.id)).size !== rubric.length)\n ctx.addIssue({ code: \"custom\", message: \"Rubric criterion IDs must be unique.\" });\n if (\n rubric.length &&\n rubric.reduce((sum, item) => sum + item.maxPoints, 0) !== assignment.maxPoints\n )\n ctx.addIssue({\n code: \"custom\",\n message: \"Rubric points must add up to the assignment maximum.\",\n });\n });\n\nexport const lessonSchema = z\n .object({\n id: idSchema,\n title,\n summary: z.string().max(2000).default(\"\"),\n kind: z.enum([\"text\", \"video\", \"audio\", \"quiz\", \"assignment\", \"live\"]).default(\"text\"),\n body: text.default(\"\"),\n portableText: z.array(z.record(z.string(), z.unknown())).max(1000).default([]),\n contentSource: z\n .object({ collection: idSchema, id: idSchema, field: idSchema.default(\"content\") })\n .nullable()\n .default(null),\n mediaUrl: safeUrlSchema.nullable().default(null),\n transcript: text.default(\"\"),\n captions: z\n .array(\n z.object({\n src: safeUrlSchema,\n language: z\n .string()\n .regex(/^[a-zA-Z]{2,3}(?:-[a-zA-Z0-9]{2,8})*$/)\n .max(35),\n label: title,\n }),\n )\n .max(20)\n .default([]),\n liveStartsAt: timestamp.nullable().default(null),\n durationMinutes: z.number().int().min(0).max(1440).default(10),\n minStudySeconds: z.number().int().min(0).max(86400).default(0),\n preview: z.boolean().default(false),\n required: z.boolean().default(true),\n resources: z.array(resourceSchema).max(30).default([]),\n quiz: quizSchema.nullable().default(null),\n assignment: assignmentSchema.nullable().default(null),\n })\n .superRefine((lesson, ctx) => {\n if (lesson.kind === \"quiz\" && !lesson.quiz)\n ctx.addIssue({ code: \"custom\", message: \"Quiz lessons need a quiz.\" });\n if (lesson.kind === \"assignment\" && !lesson.assignment)\n ctx.addIssue({ code: \"custom\", message: \"Assignment lessons need an assignment.\" });\n if ([\"video\", \"audio\", \"live\"].includes(lesson.kind) && !lesson.mediaUrl)\n ctx.addIssue({ code: \"custom\", message: \"Media and live lessons need a URL.\" });\n if (lesson.kind === \"live\" && !lesson.liveStartsAt)\n ctx.addIssue({ code: \"custom\", message: \"Live lessons need a start time.\" });\n if (new Set(lesson.resources.map((resource) => resource.id)).size !== lesson.resources.length)\n ctx.addIssue({ code: \"custom\", message: \"Resource IDs must be unique.\" });\n });\n\nexport const moduleSchema = z.object({\n id: idSchema,\n title,\n description: z.string().max(2000).default(\"\"),\n releaseDays: z.number().int().min(0).max(3650).default(0),\n unlockAt: timestamp.nullable().default(null),\n lessons: z.array(lessonSchema).max(100).default([]),\n});\n\nexport const courseDataSchema = z\n .object({\n slug: z\n .string()\n .trim()\n .min(1)\n .max(100)\n .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, \"Use lowercase words separated by hyphens.\"),\n title,\n summary: z.string().trim().max(1000).default(\"\"),\n description: text.default(\"\"),\n outcomes: z.array(z.string().trim().min(1).max(500)).max(30).default([]),\n requirements: z.array(z.string().trim().min(1).max(500)).max(30).default([]),\n category: z.string().trim().max(100).default(\"\"),\n tags: z.array(z.string().trim().min(1).max(60)).max(20).default([]),\n language: z.string().trim().min(2).max(35).default(\"en\"),\n level: z.enum([\"beginner\", \"intermediate\", \"advanced\", \"all\"]).default(\"all\"),\n featuredImage: z\n .object({\n id: z.string().max(128).default(\"\"),\n src: safeUrlSchema,\n alt: z.string().max(500).default(\"\"),\n })\n .nullable()\n .default(null),\n instructorName: z.string().trim().max(200).default(\"\"),\n instructorIds: z.array(idSchema).max(20).default([]),\n status: z.enum([\"draft\", \"published\", \"archived\"]).default(\"draft\"),\n enrollmentMode: z.enum([\"open\", \"approval\", \"invite\"]).default(\"open\"),\n commerce: z\n .object({\n accessModel: z.enum([\"free\", \"paid\"]).default(\"free\"),\n offerId: idSchema.nullable().default(null),\n priceMinor: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER).nullable().default(null),\n currency: z\n .string()\n .regex(/^[A-Z]{3}$/)\n .default(\"INR\"),\n })\n .default({ accessModel: \"free\", offerId: null, priceMinor: null, currency: \"INR\" }),\n prerequisiteCourseIds: z.array(idSchema).max(20).default([]),\n sequential: z.boolean().default(true),\n enrollmentClosesAt: timestamp.nullable().default(null),\n accessDays: z.number().int().min(0).max(3650).default(0),\n certificateEnabled: z.boolean().default(true),\n modules: z.array(moduleSchema).max(50).default([]),\n })\n .superRefine((course, ctx) => {\n const allIds = course.modules.flatMap((module) => [\n module.id,\n ...module.lessons.map((lesson) => lesson.id),\n ]);\n if (new Set(allIds).size !== allIds.length)\n ctx.addIssue({\n code: \"custom\",\n message: \"Module and lesson IDs must be unique across the course.\",\n });\n if (course.modules.flatMap((module) => module.lessons).length > 150)\n ctx.addIssue({ code: \"custom\", message: \"A course supports up to 150 lessons.\" });\n if (\n course.status === \"published\" &&\n !course.modules.some((module) => module.lessons.some((lesson) => lesson.required))\n )\n ctx.addIssue({\n code: \"custom\",\n message: \"Publish a course with at least one required lesson.\",\n });\n });\n\nexport const courseSaveSchema = z.object({\n id: idSchema.optional(),\n expectedRevision: z.string().max(128).nullable().default(null),\n data: courseDataSchema,\n});\nexport const pageSchema = z.object({\n cursor: z.string().max(4000).optional(),\n limit: z.coerce.number().int().min(1).max(100).default(24),\n});\nexport const catalogSchema = pageSchema.extend({\n q: z.string().max(100).default(\"\"),\n category: z.string().max(100).default(\"\"),\n level: z.enum([\"beginner\", \"intermediate\", \"advanced\", \"all\"]).optional(),\n language: z.string().max(35).optional(),\n});\nexport const courseIdSchema = z.object({ courseId: idSchema });\nexport const lessonIdSchema = courseIdSchema.extend({ lessonId: idSchema });\nexport const answersSchema = z.record(\n idSchema,\n z.union([z.string().max(2000), z.array(z.string().max(500)).max(10)]),\n);\nexport const quizSubmitSchema = lessonIdSchema.extend({\n attemptId: idSchema,\n answers: answersSchema,\n expectedDraftRevision: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER).optional(),\n});\nexport const quizDraftSchema = quizSubmitSchema.extend({\n expectedDraftRevision: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER).default(0),\n});\nexport const assignmentSubmitSchema = lessonIdSchema.extend({\n body: z.string().trim().min(1).max(20_000),\n attachmentUrl: safeUrlSchema.nullable().default(null),\n submissionId: idSchema.optional(),\n expectedDraftRevision: z\n .number()\n .int()\n .min(0)\n .max(Number.MAX_SAFE_INTEGER - 1)\n .optional(),\n});\nexport const assignmentDraftSchema = lessonIdSchema.extend({\n body: z.string().max(20_000).default(\"\"),\n attachmentUrl: safeUrlSchema.nullable().default(null),\n expectedDraftRevision: z\n .number()\n .int()\n .min(0)\n .max(Number.MAX_SAFE_INTEGER - 1),\n});\nexport const enrollmentRequestSchema = courseIdSchema.extend({ cohortId: idSchema.optional() });\nexport const enrollmentAdminSchema = courseIdSchema.extend({\n userId: idSchema,\n status: z.enum([\"active\", \"rejected\", \"suspended\", \"cancelled\"]),\n reason: z.string().max(1000).default(\"\"),\n cohortId: idSchema.nullable().optional(),\n accessStartsAt: timestamp.nullable().optional(),\n accessExpiresAt: timestamp.nullable().optional(),\n});\nexport const gradeSchema = lessonIdSchema.extend({\n userId: idSchema,\n submissionId: idSchema,\n points: z.number().int().min(0).max(1000).optional(),\n rubricScores: z.array(rubricScoreSchema).max(20).optional(),\n feedback: z.string().max(10_000).default(\"\"),\n});\nexport const discussionSchema = lessonIdSchema.extend({\n body: z.string().trim().min(1).max(5000),\n parentId: idSchema.nullable().default(null),\n});\nexport const reviewSchema = courseIdSchema.extend({\n rating: z.number().int().min(1).max(5),\n body: z.string().trim().min(1).max(3000),\n});\nexport const moderateSchema = z.object({\n id: keySchema,\n status: z.enum([\"published\", \"hidden\"]),\n expectedRevision: z.string().min(1).max(128),\n});\nexport const cohortDataSchema = z\n .object({\n title,\n courseIds: z.array(idSchema).min(1).max(20),\n memberIds: z.array(idSchema).max(1000).default([]),\n startsAt: timestamp.nullable().default(null),\n endsAt: timestamp.nullable().default(null),\n })\n .refine(\n (cohort) =>\n !cohort.startsAt || !cohort.endsAt || Date.parse(cohort.endsAt) > Date.parse(cohort.startsAt),\n \"Cohort end must follow its start.\",\n )\n .refine(\n (cohort) => new Set(cohort.memberIds).size === cohort.memberIds.length,\n \"Cohort members must be unique.\",\n )\n .refine(\n (cohort) => new Set(cohort.courseIds).size === cohort.courseIds.length,\n \"Cohort courses must be unique.\",\n );\nexport const cohortSaveSchema = z.object({\n id: idSchema.optional(),\n expectedRevision: z.string().max(128).nullable().default(null),\n data: cohortDataSchema,\n});\nexport const settingsSchema = z.object({\n academyTitle: title.default(\"Ananta Gnanam Academy\"),\n academyDescription: z.string().max(2000).default(\"Build knowledge, one lesson at a time.\"),\n issuerName: title.default(\"Ananta Gnanam\"),\n moderateDiscussions: z.boolean().default(true),\n moderateReviews: z.boolean().default(true),\n emailNotifications: z.boolean().default(false),\n reminderDays: z.number().int().min(0).max(90).default(7),\n});\nexport const certificateActionSchema = courseIdSchema.extend({ shared: z.boolean() });\nexport const certificateRevokeSchema = courseIdSchema.extend({\n userId: idSchema,\n reason: z.string().trim().min(1).max(1000),\n});\nexport const noteSchema = lessonIdSchema.extend({\n note: z.string().max(10_000),\n expectedRevision: z\n .number()\n .int()\n .min(0)\n .max(Number.MAX_SAFE_INTEGER - 1)\n .default(0),\n});\nexport const studyNoteSchema = lessonIdSchema\n .extend({\n id: idSchema,\n body: z.string().max(5000),\n positionSeconds: z.number().min(0).max(86_400).nullable().default(null),\n starred: z.boolean().default(false),\n archived: z.boolean().default(false),\n expectedRevision: z\n .number()\n .int()\n .min(0)\n .max(Number.MAX_SAFE_INTEGER - 1),\n })\n .refine(\n (note) => note.body.trim().length > 0 || note.positionSeconds !== null,\n \"Write a note or choose a media timestamp.\",\n );\n\nexport const preferencesSchema = z.object({\n emailNotifications: z.boolean().default(true),\n weeklyGoalLessons: z.number().int().min(0).max(100).default(3),\n});\nexport const playbackSchema = lessonIdSchema.extend({\n positionSeconds: z.number().finite().min(0).max(86_400),\n playbackRate: z.number().min(0.25).max(3),\n expectedRevision: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER),\n});\nexport const pathDataSchema = z.object({\n title,\n description: z.string().max(5000).default(\"\"),\n courseIds: z\n .array(idSchema)\n .min(1)\n .max(30)\n .refine((ids) => new Set(ids).size === ids.length, \"Courses must be unique.\"),\n status: z.enum([\"draft\", \"published\", \"archived\"]).default(\"draft\"),\n});\nexport const pathSaveSchema = z.object({\n id: idSchema.optional(),\n expectedRevision: z.string().max(128).nullable().default(null),\n data: pathDataSchema,\n});\n"],"mappings":";;;AAEA,MAAa,WAAW,EACrB,QAAQ,CACR,IAAI,EAAE,CACN,IAAI,IAAI,CACR,MAAM,oBAAoB,gDAAgD,CAC1E,QACE,UAAU,CAAC;CAAC;CAAa;CAAe;CAAY,CAAC,SAAS,MAAM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AC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import { CourseDetail, PublicLesson } from "./types.js";
|
|
1
|
+
import { CourseDetail, Lesson, LessonProgress, PublicLesson } from "./types.js";
|
|
2
2
|
|
|
3
|
+
//#region src/assignments.d.ts
|
|
4
|
+
declare function assignmentBlock(assignment: NonNullable<Lesson["assignment"]>, progress: Pick<LessonProgress, "completedAt" | "assignments">, now: Date): {
|
|
5
|
+
code: string;
|
|
6
|
+
message: string;
|
|
7
|
+
status: number;
|
|
8
|
+
} | null;
|
|
9
|
+
//#endregion
|
|
3
10
|
//#region src/errors.d.ts
|
|
4
11
|
declare class LmsError extends Error {
|
|
5
12
|
readonly code: string;
|
|
@@ -36,5 +43,5 @@ declare function courseUrl(basePath: string, slug: string): string;
|
|
|
36
43
|
declare function lessonUrl(basePath: string, slug: string, lessonId: string): string;
|
|
37
44
|
declare function certificateUrl(basePath: string, id: string): string;
|
|
38
45
|
//#endregion
|
|
39
|
-
export { LmsError, certificateUrl, courseUrl, lessonUrl, lmsAuthorLessonPreview, lmsLearner, lmsPublic, loginUrl };
|
|
46
|
+
export { LmsError, assignmentBlock, certificateUrl, courseUrl, lessonUrl, lmsAuthorLessonPreview, lmsLearner, lmsPublic, loginUrl };
|
|
40
47
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as PLUGIN_ID } from "./constants-
|
|
2
|
-
import {
|
|
1
|
+
import { r as PLUGIN_ID } from "./constants-DyQbwNbP.js";
|
|
2
|
+
import { i as LmsError, t as assignmentBlock } from "./assignments-CsuAjxGO.js";
|
|
3
3
|
|
|
4
4
|
//#region src/server.ts
|
|
5
5
|
function requestUrl(route, input, origin) {
|
|
@@ -18,6 +18,9 @@ async function lmsPublic(locals, route, input, origin) {
|
|
|
18
18
|
return unwrap(await dispatch(PLUGIN_ID, "GET", route, new Request(requestUrl(route, input, origin))));
|
|
19
19
|
}
|
|
20
20
|
const READ_ROUTES = new Set([
|
|
21
|
+
"learner/study/courses",
|
|
22
|
+
"learner/notebook",
|
|
23
|
+
"learner/agenda",
|
|
21
24
|
"learner/paths",
|
|
22
25
|
"learner/saved",
|
|
23
26
|
"learner/preferences",
|
|
@@ -61,5 +64,5 @@ function certificateUrl(basePath, id) {
|
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
//#endregion
|
|
64
|
-
export { LmsError, certificateUrl, courseUrl, lessonUrl, lmsAuthorLessonPreview, lmsLearner, lmsPublic, loginUrl };
|
|
67
|
+
export { LmsError, assignmentBlock, certificateUrl, courseUrl, lessonUrl, lmsAuthorLessonPreview, lmsLearner, lmsPublic, loginUrl };
|
|
65
68
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":[],"sources":["../src/server.ts"],"sourcesContent":["import { PLUGIN_ID } from \"./constants.js\";\nimport { LmsError } from \"./errors.js\";\nimport type { CourseDetail, PublicLesson, RouteEnvelope } from \"./types.js\";\n\ninterface RuntimeLocals {\n user?: { id: string; email: string; name: string | null; role: number; createdAt: Date | string };\n emdash?: {\n handlePublicPluginApiRoute?: (\n pluginId: string,\n method: string,\n path: string,\n request: Request,\n ) => Promise<unknown>;\n handlePluginApiRoute?: (\n pluginId: string,\n method: string,\n path: string,\n request: Request,\n user?: RuntimeLocals[\"user\"] | null,\n ) => Promise<unknown>;\n };\n}\n\nfunction requestUrl(route: string, input: Record<string, unknown>, origin: string): URL {\n const url = new URL(`/_emdash/api/plugins/${PLUGIN_ID}/${route}`, origin);\n for (const [key, value] of Object.entries(input))\n if (value !== undefined && value !== null && value !== \"\")\n url.searchParams.set(key, String(value));\n return url;\n}\nfunction unwrap<T>(input: unknown): T {\n const result = input as RouteEnvelope<T>;\n if (!result?.success)\n throw new LmsError(\n result?.error?.code ?? \"LMS_UNAVAILABLE\",\n result?.error?.message ?? \"The learning service is unavailable.\",\n result?.status ?? 503,\n );\n return result.data as T;\n}\nexport async function lmsPublic<T>(\n locals: RuntimeLocals,\n route: string,\n input: Record<string, unknown>,\n origin: string,\n): Promise<T> {\n const dispatch = locals.emdash?.handlePublicPluginApiRoute;\n if (!dispatch) throw new LmsError(\"LMS_UNAVAILABLE\", \"The learning service is unavailable.\", 503);\n return unwrap<T>(\n await dispatch(PLUGIN_ID, \"GET\", route, new Request(requestUrl(route, input, origin))),\n );\n}\nconst READ_ROUTES = new Set([\n \"learner/paths\",\n \"learner/saved\",\n \"learner/preferences\",\n \"learner/dashboard\",\n \"learner/course\",\n \"learner/course-by-slug\",\n \"learner/lesson\",\n \"learner/certificate\",\n \"learner/certificate-by-id\",\n \"learner/cohort\",\n \"learner/notifications\",\n]);\nexport async function lmsLearner<T>(\n locals: RuntimeLocals,\n route: string,\n input: Record<string, unknown>,\n origin: string,\n): Promise<T> {\n if (!locals.user || locals.user.role < 10)\n throw new LmsError(\"UNAUTHORIZED\", \"Sign in to continue.\", 401);\n if (!READ_ROUTES.has(route))\n throw new LmsError(\"FORBIDDEN\", \"This route is not available to the learner renderer.\", 403);\n const dispatch = locals.emdash?.handlePluginApiRoute;\n if (!dispatch) throw new LmsError(\"LMS_UNAVAILABLE\", \"The learning service is unavailable.\", 503);\n return unwrap<T>(\n await dispatch(\n PLUGIN_ID,\n \"GET\",\n route,\n new Request(requestUrl(route, input, origin)),\n locals.user,\n ),\n );\n}\nexport function loginUrl(loginPath: string, returnTo: string): string {\n const url = new URL(loginPath, \"https://lms.invalid\");\n url.searchParams.set(\"redirect\", returnTo);\n return `${url.pathname}${url.search}${url.hash}`;\n}\n/** A fixed private read route; authorization remains at the EmDash runtime boundary. */\nexport async function lmsAuthorLessonPreview(\n locals: RuntimeLocals,\n input: { courseId: string; lessonId: string },\n origin: string,\n): Promise<{ course: CourseDetail; lesson: PublicLesson }> {\n if (!locals.user) throw new LmsError(\"UNAUTHORIZED\", \"Sign in to preview this lesson.\", 401);\n const dispatch = locals.emdash?.handlePluginApiRoute;\n if (!dispatch) throw new LmsError(\"LMS_UNAVAILABLE\", \"The learning service is unavailable.\", 503);\n const route = \"admin/lesson/preview\";\n return unwrap(\n await dispatch(\n PLUGIN_ID,\n \"GET\",\n route,\n new Request(requestUrl(route, input, origin)),\n locals.user,\n ),\n );\n}\nexport function courseUrl(basePath: string, slug: string): string {\n return `${basePath}/courses/${encodeURIComponent(slug)}`;\n}\nexport function lessonUrl(basePath: string, slug: string, lessonId: string): string {\n return `${courseUrl(basePath, slug)}/lessons/${encodeURIComponent(lessonId)}`;\n}\nexport function certificateUrl(basePath: string, id: string): string {\n return `${basePath}/certificates/${encodeURIComponent(id)}`;\n}\nexport { LmsError } from \"./errors.js\";\n"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"server.js","names":[],"sources":["../src/server.ts"],"sourcesContent":["import { PLUGIN_ID } from \"./constants.js\";\nexport { assignmentBlock } from \"./assignments.js\";\nimport { LmsError } from \"./errors.js\";\nimport type { CourseDetail, PublicLesson, RouteEnvelope } from \"./types.js\";\n\ninterface RuntimeLocals {\n user?: { id: string; email: string; name: string | null; role: number; createdAt: Date | string };\n emdash?: {\n handlePublicPluginApiRoute?: (\n pluginId: string,\n method: string,\n path: string,\n request: Request,\n ) => Promise<unknown>;\n handlePluginApiRoute?: (\n pluginId: string,\n method: string,\n path: string,\n request: Request,\n user?: RuntimeLocals[\"user\"] | null,\n ) => Promise<unknown>;\n };\n}\n\nfunction requestUrl(route: string, input: Record<string, unknown>, origin: string): URL {\n const url = new URL(`/_emdash/api/plugins/${PLUGIN_ID}/${route}`, origin);\n for (const [key, value] of Object.entries(input))\n if (value !== undefined && value !== null && value !== \"\")\n url.searchParams.set(key, String(value));\n return url;\n}\nfunction unwrap<T>(input: unknown): T {\n const result = input as RouteEnvelope<T>;\n if (!result?.success)\n throw new LmsError(\n result?.error?.code ?? \"LMS_UNAVAILABLE\",\n result?.error?.message ?? \"The learning service is unavailable.\",\n result?.status ?? 503,\n );\n return result.data as T;\n}\nexport async function lmsPublic<T>(\n locals: RuntimeLocals,\n route: string,\n input: Record<string, unknown>,\n origin: string,\n): Promise<T> {\n const dispatch = locals.emdash?.handlePublicPluginApiRoute;\n if (!dispatch) throw new LmsError(\"LMS_UNAVAILABLE\", \"The learning service is unavailable.\", 503);\n return unwrap<T>(\n await dispatch(PLUGIN_ID, \"GET\", route, new Request(requestUrl(route, input, origin))),\n );\n}\nconst READ_ROUTES = new Set([\n \"learner/study/courses\",\n \"learner/notebook\",\n \"learner/agenda\",\n \"learner/paths\",\n \"learner/saved\",\n \"learner/preferences\",\n \"learner/dashboard\",\n \"learner/course\",\n \"learner/course-by-slug\",\n \"learner/lesson\",\n \"learner/certificate\",\n \"learner/certificate-by-id\",\n \"learner/cohort\",\n \"learner/notifications\",\n]);\nexport async function lmsLearner<T>(\n locals: RuntimeLocals,\n route: string,\n input: Record<string, unknown>,\n origin: string,\n): Promise<T> {\n if (!locals.user || locals.user.role < 10)\n throw new LmsError(\"UNAUTHORIZED\", \"Sign in to continue.\", 401);\n if (!READ_ROUTES.has(route))\n throw new LmsError(\"FORBIDDEN\", \"This route is not available to the learner renderer.\", 403);\n const dispatch = locals.emdash?.handlePluginApiRoute;\n if (!dispatch) throw new LmsError(\"LMS_UNAVAILABLE\", \"The learning service is unavailable.\", 503);\n return unwrap<T>(\n await dispatch(\n PLUGIN_ID,\n \"GET\",\n route,\n new Request(requestUrl(route, input, origin)),\n locals.user,\n ),\n );\n}\nexport function loginUrl(loginPath: string, returnTo: string): string {\n const url = new URL(loginPath, \"https://lms.invalid\");\n url.searchParams.set(\"redirect\", returnTo);\n return `${url.pathname}${url.search}${url.hash}`;\n}\n/** A fixed private read route; authorization remains at the EmDash runtime boundary. */\nexport async function lmsAuthorLessonPreview(\n locals: RuntimeLocals,\n input: { courseId: string; lessonId: string },\n origin: string,\n): Promise<{ course: CourseDetail; lesson: PublicLesson }> {\n if (!locals.user) throw new LmsError(\"UNAUTHORIZED\", \"Sign in to preview this lesson.\", 401);\n const dispatch = locals.emdash?.handlePluginApiRoute;\n if (!dispatch) throw new LmsError(\"LMS_UNAVAILABLE\", \"The learning service is unavailable.\", 503);\n const route = \"admin/lesson/preview\";\n return unwrap(\n await dispatch(\n PLUGIN_ID,\n \"GET\",\n route,\n new Request(requestUrl(route, input, origin)),\n locals.user,\n ),\n );\n}\nexport function courseUrl(basePath: string, slug: string): string {\n return `${basePath}/courses/${encodeURIComponent(slug)}`;\n}\nexport function lessonUrl(basePath: string, slug: string, lessonId: string): string {\n return `${courseUrl(basePath, slug)}/lessons/${encodeURIComponent(lessonId)}`;\n}\nexport function certificateUrl(basePath: string, id: string): string {\n return `${basePath}/certificates/${encodeURIComponent(id)}`;\n}\nexport { LmsError } from \"./errors.js\";\n"],"mappings":";;;;AAwBA,SAAS,WAAW,OAAe,OAAgC,QAAqB;CACtF,MAAM,MAAM,IAAI,IAAI,wBAAwB,UAAU,GAAG,SAAS,OAAO;AACzE,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,CAC9C,KAAI,UAAU,UAAa,UAAU,QAAQ,UAAU,GACrD,KAAI,aAAa,IAAI,KAAK,OAAO,MAAM,CAAC;AAC5C,QAAO;;AAET,SAAS,OAAU,OAAmB;CACpC,MAAM,SAAS;AACf,KAAI,CAAC,QAAQ,QACX,OAAM,IAAI,SACR,QAAQ,OAAO,QAAQ,mBACvB,QAAQ,OAAO,WAAW,wCAC1B,QAAQ,UAAU,IACnB;AACH,QAAO,OAAO;;AAEhB,eAAsB,UACpB,QACA,OACA,OACA,QACY;CACZ,MAAM,WAAW,OAAO,QAAQ;AAChC,KAAI,CAAC,SAAU,OAAM,IAAI,SAAS,mBAAmB,wCAAwC,IAAI;AACjG,QAAO,OACL,MAAM,SAAS,WAAW,OAAO,OAAO,IAAI,QAAQ,WAAW,OAAO,OAAO,OAAO,CAAC,CAAC,CACvF;;AAEH,MAAM,cAAc,IAAI,IAAI;CAC1B;CACA;CACA;CAC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B,mBAAmB,GAAG"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cohortDataSchema, courseDataSchema, lessonSchema, moduleSchema, pathDataSchema, preferencesSchema, questionSchema, quizSchema, settingsSchema } from "./schemas.js";
|
|
1
|
+
import { cohortDataSchema, courseDataSchema, lessonSchema, moduleSchema, pathDataSchema, preferencesSchema, questionSchema, quizSchema, rubricCriterionSchema, rubricScoreSchema, settingsSchema } from "./schemas.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/types.d.ts
|
|
@@ -7,6 +7,8 @@ type CourseModule = z.infer<typeof moduleSchema>;
|
|
|
7
7
|
type Lesson = z.infer<typeof lessonSchema>;
|
|
8
8
|
type QuizQuestion = z.infer<typeof questionSchema>;
|
|
9
9
|
type Quiz = z.infer<typeof quizSchema>;
|
|
10
|
+
type RubricCriterion = z.infer<typeof rubricCriterionSchema>;
|
|
11
|
+
type RubricScore = z.infer<typeof rubricScoreSchema>;
|
|
10
12
|
type LmsSettings = z.infer<typeof settingsSchema>;
|
|
11
13
|
interface Course extends CourseData {
|
|
12
14
|
id: string;
|
|
@@ -99,13 +101,30 @@ interface AssignmentSubmission {
|
|
|
99
101
|
feedback: string;
|
|
100
102
|
gradedAt: string | null;
|
|
101
103
|
gradedBy: string | null;
|
|
104
|
+
/** Criteria are frozen from the learner's course edition at submission. */
|
|
105
|
+
rubric?: RubricCriterion[];
|
|
106
|
+
rubricScores?: RubricScore[];
|
|
107
|
+
}
|
|
108
|
+
interface AssignmentDraft {
|
|
109
|
+
body: string;
|
|
110
|
+
attachmentUrl: string | null;
|
|
111
|
+
revision: number;
|
|
112
|
+
updatedAt: string | null;
|
|
113
|
+
}
|
|
114
|
+
interface AssignmentState {
|
|
115
|
+
draft: AssignmentDraft;
|
|
116
|
+
submission: AssignmentSubmission | null;
|
|
117
|
+
canSubmit: boolean;
|
|
118
|
+
closedReason: string | null;
|
|
102
119
|
}
|
|
103
120
|
interface LessonProgress {
|
|
104
121
|
startedAt: string | null;
|
|
105
122
|
completedAt: string | null;
|
|
106
123
|
note: string;
|
|
124
|
+
noteRevision?: number;
|
|
107
125
|
quizAttempts: QuizAttempt[];
|
|
108
126
|
assignments: AssignmentSubmission[];
|
|
127
|
+
assignmentDraft?: AssignmentDraft;
|
|
109
128
|
playback?: Playback;
|
|
110
129
|
}
|
|
111
130
|
interface Playback {
|
|
@@ -114,6 +133,51 @@ interface Playback {
|
|
|
114
133
|
revision: number;
|
|
115
134
|
updatedAt: string;
|
|
116
135
|
}
|
|
136
|
+
interface StudyNote {
|
|
137
|
+
id: string;
|
|
138
|
+
lessonId: string;
|
|
139
|
+
lessonTitle: string;
|
|
140
|
+
body: string;
|
|
141
|
+
positionSeconds: number | null;
|
|
142
|
+
starred: boolean;
|
|
143
|
+
archived: boolean;
|
|
144
|
+
revision: number;
|
|
145
|
+
createdAt: string;
|
|
146
|
+
updatedAt: string;
|
|
147
|
+
}
|
|
148
|
+
interface Notebook {
|
|
149
|
+
course: {
|
|
150
|
+
id: string;
|
|
151
|
+
title: string;
|
|
152
|
+
slug: string;
|
|
153
|
+
};
|
|
154
|
+
notes: StudyNote[];
|
|
155
|
+
summaries: {
|
|
156
|
+
lessonId: string;
|
|
157
|
+
lessonTitle: string;
|
|
158
|
+
body: string;
|
|
159
|
+
}[];
|
|
160
|
+
availableLessonIds: string[];
|
|
161
|
+
}
|
|
162
|
+
interface CourseAgenda {
|
|
163
|
+
course: {
|
|
164
|
+
id: string;
|
|
165
|
+
title: string;
|
|
166
|
+
slug: string;
|
|
167
|
+
};
|
|
168
|
+
generatedAt: string;
|
|
169
|
+
events: {
|
|
170
|
+
id: string;
|
|
171
|
+
kind: "assignment" | "live" | "release";
|
|
172
|
+
lessonId: string;
|
|
173
|
+
title: string;
|
|
174
|
+
startsAt: string;
|
|
175
|
+
endsAt: string | null;
|
|
176
|
+
available: boolean;
|
|
177
|
+
reason: string | null;
|
|
178
|
+
status: "upcoming" | "overdue" | "submitted" | "completed" | "past";
|
|
179
|
+
}[];
|
|
180
|
+
}
|
|
117
181
|
type LearnerPreferences = z.infer<typeof preferencesSchema>;
|
|
118
182
|
interface SavedCourse {
|
|
119
183
|
userId: string;
|
|
@@ -200,6 +264,7 @@ interface Enrollment {
|
|
|
200
264
|
accessExpiresAt: string | null;
|
|
201
265
|
cohortId: string | null;
|
|
202
266
|
progress: Record<string, LessonProgress>;
|
|
267
|
+
studyNotes?: StudyNote[];
|
|
203
268
|
certificate: Certificate | null;
|
|
204
269
|
completionLessonIds: string[];
|
|
205
270
|
lastActivityAt: string;
|
|
@@ -383,5 +448,5 @@ interface RouteEnvelope<T> {
|
|
|
383
448
|
};
|
|
384
449
|
}
|
|
385
450
|
//#endregion
|
|
386
|
-
export { AccessGrant, Acquisition, Actor, Answers, AssignmentSubmission, AuditRecord, Certificate, CertificateIndex, Cohort, CohortMembership, Course, CourseCard, CourseData, CourseDetail, CourseEdition, CourseModule, CourseRevision, CurriculumLesson, CurriculumModule, Discussion, Enrollment, LearnerPath, LearnerPreferences, LearningPath, Lesson, LessonAvailability, LessonProgress, LmsHealth, LmsOptions, LmsSettings, MigrationState, Notification, Page, PathEnrollment, Playback, ProgressSummary, PublicEnrollment, PublicLesson, PublicPath, PublicQuestion, PublicQuizAttempt, QuestionResult, Quiz, QuizAttempt, QuizQuestion, Review, RevisionSummary, RouteEnvelope, SavedCourse, Versioned };
|
|
451
|
+
export { AccessGrant, Acquisition, Actor, Answers, AssignmentDraft, AssignmentState, AssignmentSubmission, AuditRecord, Certificate, CertificateIndex, Cohort, CohortMembership, Course, CourseAgenda, CourseCard, CourseData, CourseDetail, CourseEdition, CourseModule, CourseRevision, CurriculumLesson, CurriculumModule, Discussion, Enrollment, LearnerPath, LearnerPreferences, LearningPath, Lesson, LessonAvailability, LessonProgress, LmsHealth, LmsOptions, LmsSettings, MigrationState, Notebook, Notification, Page, PathEnrollment, Playback, ProgressSummary, PublicEnrollment, PublicLesson, PublicPath, PublicQuestion, PublicQuizAttempt, QuestionResult, Quiz, QuizAttempt, QuizQuestion, Review, RevisionSummary, RouteEnvelope, RubricCriterion, RubricScore, SavedCourse, StudyNote, Versioned };
|
|
387
452
|
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED
package/dist/errors-ChzJS9al.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//#region src/errors.ts
|
|
2
|
-
var LmsError = class extends Error {
|
|
3
|
-
constructor(code, message, status = 400) {
|
|
4
|
-
super(message);
|
|
5
|
-
this.code = code;
|
|
6
|
-
this.status = status;
|
|
7
|
-
this.name = "PluginRouteError";
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
function invariant(condition, code, message, status = 400) {
|
|
11
|
-
if (!condition) throw new LmsError(code, message, status);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
export { invariant as n, LmsError as t };
|
|
16
|
-
//# sourceMappingURL=errors-ChzJS9al.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors-ChzJS9al.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["export class LmsError extends Error {\n constructor(\n readonly code: string,\n message: string,\n readonly status = 400,\n ) {\n super(message);\n this.name = \"PluginRouteError\";\n }\n}\n\nexport function invariant(\n condition: unknown,\n code: string,\n message: string,\n status = 400,\n): asserts condition {\n if (!condition) throw new LmsError(code, message, status);\n}\n"],"mappings":";AAAA,IAAa,WAAb,cAA8B,MAAM;CAClC,YACE,AAAS,MACT,SACA,AAAS,SAAS,KAClB;AACA,QAAM,QAAQ;EAJL;EAEA;AAGT,OAAK,OAAO;;;AAIhB,SAAgB,UACd,WACA,MACA,SACA,SAAS,KACU;AACnB,KAAI,CAAC,UAAW,OAAM,IAAI,SAAS,MAAM,SAAS,OAAO"}
|