coursekit-lms 0.1.1 → 0.2.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.
Files changed (174) hide show
  1. package/CHANGELOG.md +82 -1
  2. package/README.md +128 -27
  3. package/dist/cli/index.js +7140 -1634
  4. package/dist/cli/index.js.map +1 -1
  5. package/dist/server/index.js +7129 -1656
  6. package/dist/server/index.js.map +1 -1
  7. package/dist/types/server/config.d.ts +4 -0
  8. package/dist/types/server/db/migrations/002_email.d.ts +8 -0
  9. package/dist/types/server/db/migrations/003_groups_cohorts.d.ts +7 -0
  10. package/dist/types/server/db/migrations/004_completion_badges.d.ts +8 -0
  11. package/dist/types/server/db/migrations/005_question_bank.d.ts +11 -0
  12. package/dist/types/server/db/migrations/006_grade_categories.d.ts +11 -0
  13. package/dist/types/server/db/schema-completion.d.ts +79 -0
  14. package/dist/types/server/db/schema.d.ts +165 -5
  15. package/dist/types/server/index.d.ts +7 -0
  16. package/dist/types/server/lib/events.d.ts +105 -0
  17. package/dist/types/server/routes/badges.d.ts +4 -0
  18. package/dist/types/server/routes/certificates.d.ts +3 -0
  19. package/dist/types/server/routes/cohorts.d.ts +6 -0
  20. package/dist/types/server/routes/completion.d.ts +4 -0
  21. package/dist/types/server/routes/email.d.ts +13 -0
  22. package/dist/types/server/routes/grade-categories.d.ts +4 -0
  23. package/dist/types/server/routes/groups.d.ts +4 -0
  24. package/dist/types/server/routes/question-bank.d.ts +4 -0
  25. package/dist/types/server/seed/demo-completion.d.ts +2 -0
  26. package/dist/types/server/seed/demo-email.d.ts +2 -0
  27. package/dist/types/server/seed/demo-grade-categories.d.ts +6 -0
  28. package/dist/types/server/seed/demo-groups.d.ts +6 -0
  29. package/dist/types/server/seed/demo-question-bank.d.ts +20 -0
  30. package/dist/types/server/seed/demo.d.ts +2 -1
  31. package/dist/types/server/services/badges.d.ts +39 -0
  32. package/dist/types/server/services/certificates.d.ts +42 -0
  33. package/dist/types/server/services/cohorts.d.ts +64 -0
  34. package/dist/types/server/services/completion.d.ts +63 -0
  35. package/dist/types/server/services/course-total.d.ts +107 -0
  36. package/dist/types/server/services/email/config.d.ts +55 -0
  37. package/dist/types/server/services/email/digests.d.ts +57 -0
  38. package/dist/types/server/services/email/outbox.d.ts +61 -0
  39. package/dist/types/server/services/email/preferences.d.ts +25 -0
  40. package/dist/types/server/services/email/service.d.ts +116 -0
  41. package/dist/types/server/services/email/templates.d.ts +74 -0
  42. package/dist/types/server/services/email/tokens.d.ts +11 -0
  43. package/dist/types/server/services/email/transport.d.ts +29 -0
  44. package/dist/types/server/services/enrolments.d.ts +32 -0
  45. package/dist/types/server/services/grade-categories.d.ts +31 -0
  46. package/dist/types/server/services/gradebook.d.ts +18 -0
  47. package/dist/types/server/services/groups.d.ts +90 -0
  48. package/dist/types/server/services/notify.d.ts +4 -1
  49. package/dist/types/server/services/question-bank.d.ts +53 -0
  50. package/dist/types/server/services/question-types.d.ts +146 -0
  51. package/dist/types/server/services/quiz-slots.d.ts +33 -0
  52. package/dist/types/server/services/quiz.d.ts +45 -14
  53. package/dist/types/shared/completion.d.ts +214 -0
  54. package/dist/types/shared/email.d.ts +117 -0
  55. package/dist/types/shared/grades.d.ts +18 -0
  56. package/dist/types/shared/groups.d.ts +17 -0
  57. package/dist/types/shared/permissions.d.ts +1 -1
  58. package/dist/types/shared/types.d.ts +268 -2
  59. package/dist/web/assets/{ActivityEditor-BVSZUV8l.js → ActivityEditor-BNG3aTQa.js} +2 -2
  60. package/dist/web/assets/ActivityPage-i0XHYD2Q.js +1 -0
  61. package/dist/web/assets/AdminBadgesPage-DvpxIg1P.js +1 -0
  62. package/dist/web/assets/AdminCohortsPage-B5PWBkjp.js +3 -0
  63. package/dist/web/assets/AdminCoursesPage-Dm1ECbS-.js +1 -0
  64. package/dist/web/assets/AdminEmailPage-D3E_Db1_.js +1 -0
  65. package/dist/web/assets/AdminLayout-BVeduyCQ.js +1 -0
  66. package/dist/web/assets/{AdminOverviewPage-DnTrdGbr.js → AdminOverviewPage-BaCKvhgr.js} +1 -1
  67. package/dist/web/assets/{AdminSettingsPage-B82cX8xU.js → AdminSettingsPage-B5Ag5K15.js} +1 -1
  68. package/dist/web/assets/AdminUsersPage-BVCG65EK.js +1 -0
  69. package/dist/web/assets/{AnnouncementsPage-BKW30k0Z.js → AnnouncementsPage-C0OAzyvW.js} +1 -1
  70. package/dist/web/assets/BadgePage-B3Ecudas.js +1 -0
  71. package/dist/web/assets/CalendarPage-CEks5F4m.js +1 -0
  72. package/dist/web/assets/{CatalogPage-BiMgSSBR.js → CatalogPage-e7lVtwUN.js} +1 -1
  73. package/dist/web/assets/CertificatePage-_eSGt8R-.js +9 -0
  74. package/dist/web/assets/CompletionPage-Dxp-ulA_.js +1 -0
  75. package/dist/web/assets/CourseBadgesPage-Vi3P1Lnc.js +1 -0
  76. package/dist/web/assets/CourseContentPage-IFlhVsO5.js +1 -0
  77. package/dist/web/assets/CourseLayout-BqwXol8L.js +1 -0
  78. package/dist/web/assets/CourseSettingsPage-BIagLirb.js +1 -0
  79. package/dist/web/assets/CreateCoursePage-BBcdiTtz.js +1 -0
  80. package/dist/web/assets/{DiscussionPage-CWwVpFQV.js → DiscussionPage-C23QoCSw.js} +1 -1
  81. package/dist/web/assets/GradebookSetupPage-a5GH4xIk.js +1 -0
  82. package/dist/web/assets/GradesPage-CY6MtJxs.js +1 -0
  83. package/dist/web/assets/GroupsPage-DS3HFeC4.js +1 -0
  84. package/dist/web/assets/{MyCoursesPage-Dd-Oaygv.js → MyCoursesPage-Ckj-1SCA.js} +1 -1
  85. package/dist/web/assets/{NotFoundPage-BRquC7-l.js → NotFoundPage-BmwVsGAy.js} +1 -1
  86. package/dist/web/assets/NotificationsPage-DBRM37F1.js +1 -0
  87. package/dist/web/assets/ParticipantsPage-DV4Mjfxo.js +1 -0
  88. package/dist/web/assets/ProfilePage-BqG55_02.js +1 -0
  89. package/dist/web/assets/QuestionAnswer-CJIoWSz2.js +1 -0
  90. package/dist/web/assets/QuestionBankPage-BkI44c4K.js +1 -0
  91. package/dist/web/assets/QuizAttemptPage-DQVfbLKI.js +1 -0
  92. package/dist/web/assets/QuizEditorPage-muk-KVG1.js +1 -0
  93. package/dist/web/assets/SubmissionsPage-Dx97JOzE.js +1 -0
  94. package/dist/web/assets/UnsubscribePage-BPLiTiaG.js +1 -0
  95. package/dist/web/assets/VerifyCertificatePage-Cw9iXN3C.js +1 -0
  96. package/dist/web/assets/achievements-DaIfUTKU.js +1 -0
  97. package/dist/web/assets/{arrow-up-LHDup5m4.js → arrow-up-lI30bvj5.js} +1 -1
  98. package/dist/web/assets/badge-art-QPo-pYql.js +1 -0
  99. package/dist/web/assets/badge-card-ByT0wR6q.js +1 -0
  100. package/dist/web/assets/badge-dialog-p2zTk4h0.js +1 -0
  101. package/dist/web/assets/{ban-D3Vsxg_g.js → ban-DEiI8npI.js} +1 -1
  102. package/dist/web/assets/bank-S3XEFPfe.js +3 -0
  103. package/dist/web/assets/bell-off-Bo2RE0kn.js +1 -0
  104. package/dist/web/assets/calendar-range-Cfg-P4Md.js +1 -0
  105. package/dist/web/assets/certificate-sheet-DzW0lfzR.js +2 -0
  106. package/dist/web/assets/chevron-left-Bu6IJANV.js +1 -0
  107. package/dist/web/assets/circle-dashed-D34ZjnSx.js +1 -0
  108. package/dist/web/assets/clock-DPBmdKAi.js +1 -0
  109. package/dist/web/assets/cohorts-DL0Dsxva.js +1 -0
  110. package/dist/web/assets/completion-2z7I-ypT.js +1 -0
  111. package/dist/web/assets/contact-NCWQa7wc.js +1 -0
  112. package/dist/web/assets/{context-BLVW7NB7.js → context-D8W_QqNi.js} +1 -1
  113. package/dist/web/assets/{copy-Bxxjq6zo.js → copy-B5IKRMFo.js} +1 -1
  114. package/dist/web/assets/download-BrtK5sVk.js +1 -0
  115. package/dist/web/assets/{ellipsis-c2POIN-Y.js → ellipsis-BDmYLoyn.js} +1 -1
  116. package/dist/web/assets/email-BZ3kGs-R.js +1 -0
  117. package/dist/web/assets/flag-DOzXVys0.js +1 -0
  118. package/dist/web/assets/folder-input-M2p_UJZX.js +1 -0
  119. package/dist/web/assets/{library-3WG9oLCb.js → folder-tree-B-DoLXMB.js} +1 -1
  120. package/dist/web/assets/frame-DZh5g5b3.js +1 -0
  121. package/dist/web/assets/globe-DDTr53UY.js +1 -0
  122. package/dist/web/assets/grades-ogaD0MDO.js +1 -0
  123. package/dist/web/assets/groups-CrYV_AFp.js +1 -0
  124. package/dist/web/assets/{hooks-BBARn-DA.js → hooks-EFhyJ5yU.js} +1 -1
  125. package/dist/web/assets/hourglass-BKca6Cje.js +1 -0
  126. package/dist/web/assets/inbox-x1U4YU-c.js +1 -0
  127. package/dist/web/assets/index-BdPmMS6n.css +2 -0
  128. package/dist/web/assets/index-CEZdqKdi.js +50 -0
  129. package/dist/web/assets/{key-round-B_KI-brR.js → key-round-fzvV-etw.js} +1 -1
  130. package/dist/web/assets/library-Bcm33ouq.js +1 -0
  131. package/dist/web/assets/lightbulb-CjSpJ1_v.js +1 -0
  132. package/dist/web/assets/{lock-BjbqwA_0.js → lock-C2edVDOc.js} +1 -1
  133. package/dist/web/assets/mail-CQ9yiBph.js +1 -0
  134. package/dist/web/assets/mail-x-B6oBqlcw.js +1 -0
  135. package/dist/web/assets/{markdown-ykrkPMbn.js → markdown-HNlXovsL.js} +3 -3
  136. package/dist/web/assets/message-square-text-wvO9_guT.js +1 -0
  137. package/dist/web/assets/{misc-DvgDEI3I.js → misc-CyGhN6HT.js} +1 -1
  138. package/dist/web/assets/{pencil-p0GQmIMo.js → pencil-DFUpj3YP.js} +1 -1
  139. package/dist/web/assets/{pin-DlYC3uec.js → pin-DNUQ6-WX.js} +1 -1
  140. package/dist/web/assets/revoke-dialog-DjBKaFTV.js +1 -0
  141. package/dist/web/assets/rotate-ccw-yBj9Ri49.js +1 -0
  142. package/dist/web/assets/scroll-text-RmPlZi3F.js +1 -0
  143. package/dist/web/assets/{send-mxSHcdcD.js → send-BnVkFV8w.js} +1 -1
  144. package/dist/web/assets/{settings-DRKWzSHN.js → settings-BxdCrDf8.js} +1 -1
  145. package/dist/web/assets/shield-x-RpNHS0o8.js +1 -0
  146. package/dist/web/assets/shuffle-C1aB_4dp.js +1 -0
  147. package/dist/web/assets/target-G9Q_WQLB.js +1 -0
  148. package/dist/web/assets/trophy-BFFngFEh.js +1 -0
  149. package/dist/web/assets/user-minus-CkOPT3ak.js +1 -0
  150. package/dist/web/assets/users-round-CNhv0Whm.js +1 -0
  151. package/dist/web/index.html +4 -4
  152. package/package.json +6 -1
  153. package/dist/web/assets/ActivityPage-DPmSV_mU.js +0 -1
  154. package/dist/web/assets/AdminCoursesPage-uaSHNtzf.js +0 -1
  155. package/dist/web/assets/AdminLayout-DqoShZGn.js +0 -1
  156. package/dist/web/assets/AdminUsersPage-3d2F9AEl.js +0 -1
  157. package/dist/web/assets/CalendarPage-CLRWyTNT.js +0 -1
  158. package/dist/web/assets/CourseContentPage-BIDH0UbG.js +0 -1
  159. package/dist/web/assets/CourseLayout-ql01LEmj.js +0 -1
  160. package/dist/web/assets/CourseSettingsPage-CReoPqOa.js +0 -1
  161. package/dist/web/assets/CreateCoursePage-DFCHlq5M.js +0 -1
  162. package/dist/web/assets/GradesPage-Bu5vphcG.js +0 -1
  163. package/dist/web/assets/NotificationsPage-LJvqb6Dj.js +0 -1
  164. package/dist/web/assets/ParticipantsPage-wFxiphna.js +0 -1
  165. package/dist/web/assets/ProfilePage-CzfhacAX.js +0 -1
  166. package/dist/web/assets/QuizAttemptPage-CEAV6wAL.js +0 -1
  167. package/dist/web/assets/QuizEditorPage-DS_czQVM.js +0 -3
  168. package/dist/web/assets/SubmissionsPage-CQjcx09G.js +0 -1
  169. package/dist/web/assets/chevron-left-D6IMQD6N.js +0 -1
  170. package/dist/web/assets/frame-CGabirLa.js +0 -1
  171. package/dist/web/assets/index-B29bTBiJ.js +0 -50
  172. package/dist/web/assets/index-WxCvsbJq.css +0 -2
  173. package/dist/web/assets/message-square-text-fe24gbEU.js +0 -1
  174. package/dist/web/assets/trophy-Cch2iF1m.js +0 -1
@@ -0,0 +1,214 @@
1
+ /**
2
+ * Course completion, certificates and badges: API shapes and presets shared by the server and the web UI.
3
+ */
4
+ import type { ActivityType, CourseRef, PublicUser } from './types.js';
5
+ /** `all`: every activity that tracks completion. `selected`: a chosen set of required activities. */
6
+ export type CompletionCriteriaMode = 'all' | 'selected';
7
+ export interface CertificateSettings {
8
+ enabled: boolean;
9
+ title: string;
10
+ /** Text with placeholders such as {name}, {course}, {date} and {code}. */
11
+ body: string;
12
+ signatureName: string;
13
+ signatureTitle: string;
14
+ }
15
+ export interface CourseCompletionSettings {
16
+ enabled: boolean;
17
+ mode: CompletionCriteriaMode;
18
+ /** Required activities when `mode` is `selected`. */
19
+ activityIds: string[];
20
+ /** Minimum course total (percentage, 0-100), or null for no grade requirement. */
21
+ minGrade: number | null;
22
+ certificate: CertificateSettings;
23
+ updatedAt: string | null;
24
+ }
25
+ /** An activity as the completion settings list it. Only tracked activities count towards completion. */
26
+ export interface CompletionActivityOption {
27
+ id: string;
28
+ title: string;
29
+ type: ActivityType;
30
+ sectionTitle: string;
31
+ /** Visible, in a visible section and with completion tracking on. */
32
+ tracked: boolean;
33
+ visible: boolean;
34
+ completion: 'none' | 'manual' | 'auto';
35
+ }
36
+ export interface CourseCompletionSettingsResponse {
37
+ settings: CourseCompletionSettings;
38
+ activities: CompletionActivityOption[];
39
+ }
40
+ export interface SaveCompletionSettingsResult {
41
+ settings: CourseCompletionSettings;
42
+ /** Students who completed the course because of this change. */
43
+ newlyCompleted: number;
44
+ /** Certificates issued to people who had already completed the course. */
45
+ certificatesIssued: number;
46
+ }
47
+ export type CompletionCriterion = {
48
+ kind: 'activity';
49
+ activityId: string;
50
+ title: string;
51
+ type: ActivityType;
52
+ done: boolean;
53
+ } | {
54
+ kind: 'grade';
55
+ minGrade: number;
56
+ current: number | null;
57
+ met: boolean;
58
+ };
59
+ export interface CertificateRef {
60
+ id: string;
61
+ code: string;
62
+ revoked: boolean;
63
+ }
64
+ /** The signed-in student's completion status in one course. */
65
+ export interface CourseCompletionStatus {
66
+ enabled: boolean;
67
+ completed: boolean;
68
+ completedAt: string | null;
69
+ criteria: CompletionCriterion[];
70
+ /** Share of criteria met, 0-100. */
71
+ progress: number;
72
+ certificate: CertificateRef | null;
73
+ certificateEnabled: boolean;
74
+ }
75
+ export interface CompletionReportRow {
76
+ user: PublicUser & {
77
+ email: string;
78
+ };
79
+ activitiesDone: number;
80
+ activitiesTotal: number;
81
+ /** 0-100 over all criteria. */
82
+ progress: number;
83
+ /** Course total (percentage), or null when nothing is graded yet. */
84
+ grade: number | null;
85
+ gradeMet: boolean | null;
86
+ completedAt: string | null;
87
+ certificate: CertificateRef | null;
88
+ }
89
+ export interface CompletionReport {
90
+ enabled: boolean;
91
+ mode: CompletionCriteriaMode;
92
+ minGrade: number | null;
93
+ certificateEnabled: boolean;
94
+ activities: Array<{
95
+ id: string;
96
+ title: string;
97
+ type: ActivityType;
98
+ }>;
99
+ summary: {
100
+ students: number;
101
+ completed: number;
102
+ inProgress: number;
103
+ notStarted: number;
104
+ };
105
+ rows: CompletionReportRow[];
106
+ }
107
+ /** A certificate as listed for its owner or for teachers. */
108
+ export interface CertificateSummary {
109
+ id: string;
110
+ code: string;
111
+ course: CourseRef | null;
112
+ courseTitle: string;
113
+ recipient: PublicUser;
114
+ recipientName: string;
115
+ completedAt: string;
116
+ issuedAt: string;
117
+ revokedAt: string | null;
118
+ revokeReason: string | null;
119
+ }
120
+ /** Everything needed to render the printable certificate. */
121
+ export interface Certificate extends CertificateSummary {
122
+ title: string;
123
+ body: string;
124
+ signatureName: string;
125
+ signatureTitle: string;
126
+ siteName: string;
127
+ /** The viewer may revoke or restore it. */
128
+ canManage: boolean;
129
+ }
130
+ /** What the public verification page shows: nothing beyond name, course, date and validity. */
131
+ export interface CertificateVerification {
132
+ code: string;
133
+ valid: boolean;
134
+ status: 'valid' | 'revoked';
135
+ recipientName: string;
136
+ courseTitle: string;
137
+ completedAt: string;
138
+ }
139
+ export declare const BADGE_ICONS: readonly ['award', 'medal', 'trophy', 'star', 'rocket', 'flame', 'zap', 'crown', 'gem', 'heart', 'lightbulb', 'target', 'graduation-cap', 'book-open', 'code', 'puzzle', 'brain', 'sparkles', 'message-circle', 'globe'];
140
+ export type BadgeIcon = (typeof BADGE_ICONS)[number];
141
+ export declare const BADGE_COLORS: readonly ['gold', 'silver', 'bronze', 'indigo', 'violet', 'sky', 'teal', 'emerald', 'rose', 'fuchsia'];
142
+ export type BadgeColor = (typeof BADGE_COLORS)[number];
143
+ /** `manual`: awarded by staff. `completion`: completing the badge's course. `courses`: completing every listed course (site badges). */
144
+ export type BadgeCriteria = 'manual' | 'completion' | 'courses';
145
+ export interface BadgeSummary {
146
+ id: string;
147
+ /** null for site badges. */
148
+ course: CourseRef | null;
149
+ name: string;
150
+ description: string;
151
+ icon: BadgeIcon;
152
+ color: BadgeColor;
153
+ criteria: BadgeCriteria;
154
+ /** Courses to complete (site badges with `courses` criteria). */
155
+ criteriaCourses: CourseRef[];
156
+ /** Active awards; only counted for staff. */
157
+ recipientCount: number | null;
158
+ /** When the viewer (or the user asked about) earned it. */
159
+ earnedAt: string | null;
160
+ createdAt: string;
161
+ }
162
+ export interface BadgeRecipient {
163
+ user: PublicUser & {
164
+ email: string | null;
165
+ };
166
+ awardedAt: string;
167
+ /** null when it was awarded automatically. */
168
+ awardedBy: PublicUser | null;
169
+ note: string | null;
170
+ revokedAt: string | null;
171
+ }
172
+ export interface BadgeDetail extends BadgeSummary {
173
+ /** The viewer's own award note, when they earned it. */
174
+ earnedNote: string | null;
175
+ canManage: boolean;
176
+ canAward: boolean;
177
+ /** Only for staff (people who may award the badge). */
178
+ recipients: BadgeRecipient[] | null;
179
+ }
180
+ export interface EarnedBadge {
181
+ badge: BadgeSummary;
182
+ awardedAt: string;
183
+ note: string | null;
184
+ }
185
+ export declare const CERTIFICATE_PLACEHOLDERS: readonly [{
186
+ readonly key: '{name}';
187
+ readonly label: "Student's name";
188
+ }, {
189
+ readonly key: '{course}';
190
+ readonly label: 'Course title';
191
+ }, {
192
+ readonly key: '{date}';
193
+ readonly label: 'Completion date';
194
+ }, {
195
+ readonly key: '{code}';
196
+ readonly label: 'Verification code';
197
+ }, {
198
+ readonly key: '{site}';
199
+ readonly label: 'Site name';
200
+ }];
201
+ export declare const DEFAULT_CERTIFICATE: CertificateSettings;
202
+ export interface CertificateValues {
203
+ name: string;
204
+ course: string;
205
+ date: string;
206
+ code: string;
207
+ site: string;
208
+ }
209
+ /** Replaces {name}, {course}, {date}, {code} and {site}. Unknown placeholders are left as they are. */
210
+ export declare function fillCertificateText(template: string, values: CertificateValues): string;
211
+ /** Verification codes are 12 Crockford base32 characters, shown in groups of four: 7QK2-M9XD-4TPA. */
212
+ export declare function formatCertificateCode(code: string): string;
213
+ /** Normalises what someone typed (any case, spaces, dashes, O for 0, I or L for 1). Returns null if it can't be a code. */
214
+ export declare function normalizeCertificateCode(input: string): string | null;
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Email notifications: delivery preferences, notification categories and the shapes returned by the
3
+ * email API. Shared by the server and the web UI.
4
+ */
5
+ /** How often a person is emailed about their notifications. */
6
+ export type EmailFrequency = 'off' | 'immediately' | 'daily' | 'weekly';
7
+ export declare const EMAIL_FREQUENCIES: readonly EmailFrequency[];
8
+ export declare const EMAIL_FREQUENCY_LABELS: Record<EmailFrequency, string>;
9
+ /** User-facing groups of notification types that people can opt out of one by one. */
10
+ export type EmailCategoryId = 'announcements' | 'discussions' | 'grades' | 'courses' | 'achievements';
11
+ export interface EmailCategory {
12
+ id: EmailCategoryId;
13
+ label: string;
14
+ description: string;
15
+ }
16
+ export declare const EMAIL_CATEGORIES: readonly EmailCategory[];
17
+ export declare const EMAIL_CATEGORY_IDS: readonly EmailCategoryId[];
18
+ /**
19
+ * The category of each notification type (the `type` passed to notify()). A type is looked up whole first,
20
+ * then by its first word ("badge.awarded" and "badge_awarded" use "badge"); anything else is a course update.
21
+ * Map new notification types here.
22
+ */
23
+ export declare const NOTIFICATION_TYPE_CATEGORIES: Readonly<Record<string, EmailCategoryId>>;
24
+ export declare function emailCategoryOf(type: string): EmailCategoryId;
25
+ export declare const WEEKDAY_NAMES: readonly ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
26
+ /** Site-wide email settings an administrator can change. */
27
+ export interface EmailSiteSettings {
28
+ /** Delivery for everyone who has not chosen their own (new users included). */
29
+ defaultFrequency: EmailFrequency;
30
+ /** Hour of the day (0-23) when digests go out, in `timezone`. */
31
+ digestHour: number;
32
+ /** Day of the week (0 = Sunday) when weekly digests go out. */
33
+ digestWeekday: number;
34
+ /** IANA time zone for the digest schedule, e.g. "Europe/London". */
35
+ timezone: string;
36
+ }
37
+ /** GET /api/email/preferences */
38
+ export interface EmailPreferences {
39
+ /** The frequency in effect: the person's own choice, or the site default. */
40
+ frequency: EmailFrequency;
41
+ /** True until the person picks a frequency themselves. */
42
+ isDefault: boolean;
43
+ siteDefault: EmailFrequency;
44
+ disabledCategories: EmailCategoryId[];
45
+ /** Whether this site sends email at all. Preferences are kept either way. */
46
+ deliveryEnabled: boolean;
47
+ /** Where emails go. */
48
+ address: string;
49
+ /** When the next digests go out (ISO), so the UI can show them in local time. */
50
+ nextDigests: {
51
+ daily: string;
52
+ weekly: string;
53
+ };
54
+ }
55
+ /** GET /api/admin/email */
56
+ export interface EmailAdminStatus {
57
+ enabled: boolean;
58
+ transport: 'smtp' | 'log' | 'custom' | 'none';
59
+ /** e.g. "SMTP", "Log", or a custom transport's name. */
60
+ transportName: string;
61
+ /** e.g. "smtp.example.com:587" (never credentials) or the folder the log transport writes to. */
62
+ transportDetail: string | null;
63
+ /** Why the transport can't send right now, e.g. a missing package. */
64
+ transportError: string | null;
65
+ /** Whether this server process delivers queued email in the background. */
66
+ worker: boolean;
67
+ from: string;
68
+ /** True when no from address is configured and a fallback is used. */
69
+ fromIsDefault: boolean;
70
+ publicUrl: string | null;
71
+ settings: EmailSiteSettings;
72
+ outbox: {
73
+ pending: number;
74
+ sending: number;
75
+ sent: number;
76
+ failed: number;
77
+ };
78
+ lastSentAt: string | null;
79
+ lastError: {
80
+ message: string;
81
+ at: string;
82
+ to: string;
83
+ status: EmailMessageStatus;
84
+ } | null;
85
+ nextDigests: {
86
+ daily: string;
87
+ weekly: string;
88
+ };
89
+ }
90
+ export type EmailMessageStatus = 'pending' | 'sending' | 'sent' | 'failed';
91
+ /** GET /api/admin/email/messages/:id */
92
+ export interface EmailMessageInfo {
93
+ id: string;
94
+ kind: 'notification' | 'digest' | 'test';
95
+ to: string;
96
+ subject: string;
97
+ status: EmailMessageStatus;
98
+ attempts: number;
99
+ lastError: string | null;
100
+ createdAt: string;
101
+ sentAt: string | null;
102
+ }
103
+ /** GET/POST /api/email/unsubscribe */
104
+ export interface UnsubscribeInfo {
105
+ siteName: string;
106
+ /** The address the link was sent to, partly hidden. */
107
+ maskedEmail: string;
108
+ /** Set when the link came from an email about one category. */
109
+ category: {
110
+ id: EmailCategoryId;
111
+ label: string;
112
+ } | null;
113
+ /** True when the person gets no email at all. */
114
+ unsubscribed: boolean;
115
+ /** True when the link's category is switched off. */
116
+ categoryDisabled: boolean;
117
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Gradebook helpers shared by the server (CSV export) and the web UI, so both group
3
+ * columns by category the same way.
4
+ */
5
+ import type { GradeAggregation, GradeCategory } from './types.js';
6
+ /** Weighted courses always show categories; natural ones do once a teacher has added a category. */
7
+ export declare function usesCategories(book: {
8
+ aggregation: GradeAggregation;
9
+ categories: ReadonlyArray<Pick<GradeCategory, 'isDefault'>>;
10
+ }): boolean;
11
+ /** The categories that contain at least one of the items, in category order, with their item counts. */
12
+ export declare function categoriesWithItems<C extends {
13
+ id: string;
14
+ }>(categories: readonly C[], items: ReadonlyArray<{
15
+ categoryId: string;
16
+ }>): Array<C & {
17
+ itemCount: number;
18
+ }>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Group naming and sizing for "auto-create groups". Shared by the server, which makes the groups, and the
3
+ * web UI, which previews them.
4
+ */
5
+ export type GroupSplit = 'groups' | 'members';
6
+ /** Most groups one auto-create may make. */
7
+ export declare const MAX_AUTO_GROUPS = 200;
8
+ export declare const DEFAULT_GROUP_NAMING = "Group @";
9
+ /** Spreadsheet-style letters: 1 → A, 26 → Z, 27 → AA. */
10
+ export declare function letters(n: number): string;
11
+ /**
12
+ * Names for new groups from a naming scheme: `#` becomes a number and `@` a letter ("Group @" makes Group A,
13
+ * Group B, ...). A scheme with neither gets " #" added. Names already used in the course are skipped.
14
+ */
15
+ export declare function groupNames(scheme: string, count: number, taken: Iterable<string>): string[];
16
+ /** How many groups a split makes: `groups` makes `size` groups, `members` as few groups of at most `size` as possible. */
17
+ export declare function groupCount(split: GroupSplit, size: number, people: number): number;
@@ -3,7 +3,7 @@
3
3
  * The server enforces these; the UI uses the same table to decide what to show.
4
4
  */
5
5
  import type { CourseRole, SiteRole } from './types.js';
6
- export declare const COURSE_CAPABILITIES: readonly ['course:view', 'course:viewHidden', 'course:update', 'course:delete', 'course:manageContent', 'course:viewParticipants', 'course:manageParticipants', 'grades:viewAll', 'grades:edit', 'assignment:submit', 'quiz:attempt', 'quiz:viewAllAttempts', 'forum:post', 'forum:moderate', 'announcement:post'];
6
+ export declare const COURSE_CAPABILITIES: readonly ['course:view', 'course:viewHidden', 'course:update', 'course:delete', 'course:manageContent', 'course:viewParticipants', 'course:manageParticipants', 'grades:viewAll', 'grades:edit', 'assignment:submit', 'quiz:attempt', 'quiz:viewAllAttempts', 'forum:post', 'forum:moderate', 'announcement:post', 'course:manageGroups', 'completion:viewReport', 'completion:manage', 'badges:manage', 'badges:award', 'questionbank:manage', 'grades:manage'];
7
7
  export type CourseCapability = (typeof COURSE_CAPABILITIES)[number];
8
8
  export declare const ROLE_CAPABILITIES: Record<CourseRole, readonly CourseCapability[]>;
9
9
  /** Capabilities a user has in a course, given their site role and (optional) course role. */