@anantagnanam/lms 0.1.0 → 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 (40) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +23 -2
  3. package/astro/client.ts +73 -151
  4. package/astro/components/CourseOverview.astro +25 -3
  5. package/astro/components/LearnerDashboard.astro +6 -0
  6. package/astro/components/LearningShell.astro +10 -1
  7. package/astro/components/LessonAvailabilityNote.astro +26 -0
  8. package/astro/components/LessonContent.astro +53 -0
  9. package/astro/components/LessonPlayer.astro +40 -61
  10. package/astro/components/MediaPlayer.astro +55 -4
  11. package/astro/media-player.ts +99 -0
  12. package/astro/pages/author-preview.astro +71 -0
  13. package/astro/pages/course.astro +10 -0
  14. package/astro/pages/lesson.astro +3 -0
  15. package/astro/pages/library.astro +173 -0
  16. package/astro/pages/paths.astro +73 -0
  17. package/astro/quiz-drafts.ts +87 -0
  18. package/astro/quiz-player.ts +362 -0
  19. package/astro/styles.css +12 -0
  20. package/dist/admin.d.ts +3 -1
  21. package/dist/admin.js +585 -116
  22. package/dist/admin.js.map +1 -1
  23. package/dist/astro.js +3 -0
  24. package/dist/astro.js.map +1 -1
  25. package/dist/{constants-C0kT94tc.js → constants-Cnx7k82Z.js} +25 -3
  26. package/dist/constants-Cnx7k82Z.js.map +1 -0
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +1 -1
  29. package/dist/runtime.d.ts +104 -12
  30. package/dist/runtime.js +896 -116
  31. package/dist/runtime.js.map +1 -1
  32. package/dist/schemas.d.ts +68 -1
  33. package/dist/schemas.js +34 -2
  34. package/dist/schemas.js.map +1 -1
  35. package/dist/server.d.ts +11 -1
  36. package/dist/server.js +13 -2
  37. package/dist/server.js.map +1 -1
  38. package/dist/types.d.ts +107 -4
  39. package/package.json +1 -1
  40. package/dist/constants-C0kT94tc.js.map +0 -1
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Ananta Gnanam
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ananta Gnanam
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,13 +1,15 @@
1
1
  # @anantagnanam/lms
2
2
 
3
- A native LMS for EmDash 1.4 with Astro 7 and React 19. Version 0.1.0 provides free courses, flexible enrollment, cohorts, lessons, quizzes, assignments, progress, certificates, discussions, moderation, reporting, and notifications.
3
+ A native LMS for EmDash 1.4 with Astro 7 and React 19. Version 0.2.0 provides free courses, flexible enrollment, cohorts, lessons, quizzes, assignments, progress, certificates, discussions, moderation, reporting, notifications, published course editions, learning paths, a private library, and native media resume.
4
+
5
+ This is a free preview release. Before upgrading from 0.1.0, back up the full host database, rebuild the site, and run **LMS settings → Course edition migration** until complete. Do not downgrade after migration begins. Production database/auth/email verification, backup restoration, accessibility and capacity checks remain operator release gates. Payment processing is deferred.
4
6
 
5
7
  ## Installation
6
8
 
7
9
  Install the public npm release in an existing EmDash site:
8
10
 
9
11
  ```sh
10
- npm install @anantagnanam/lms
12
+ npm install --save-exact @anantagnanam/lms@0.2.0
11
13
  ```
12
14
 
13
15
  This is a trusted native dependency configured by the site developer. Local builds can also be installed from their release tarball.
@@ -41,11 +43,20 @@ After rebuilding the site, visit:
41
43
 
42
44
  - `/academy`: course catalog
43
45
  - `/academy/my-learning`: learner dashboard
46
+ - `/academy/my-learning/library`: saved courses, joined path progress, preferences and own-data downloads
47
+ - `/academy/paths`: published learning paths
44
48
  - `/academy/teach`: instructor course studio
49
+ - `/academy/teach/courses/<courseId>/lessons/<lessonId>`: private saved author preview
45
50
  - `/_emdash/admin/plugins/anantagnanam-lms`: administration
46
51
 
47
52
  The native plugin declares course, enrollment, cohort, certificate, discussion, review, notification, and audit storage. EmDash creates the plugin storage namespace. No LMS SQL migration or separate authentication store is needed.
48
53
 
54
+ The lesson editor identifies inline text, imported rich content, or linked published CMS content. Imported rich content is read-only in the studio; linked lessons can be edited and published in EmDash. Author previews show saved content. Quiz drafts expose save/retry/conflict state and use revisions to prevent stale overwrites. Older attempts are revision zero; integrations must send `expectedDraftRevision` after each acknowledged draft save.
55
+
56
+ Existing courses now have separate saved drafts and published editions. Save a draft, then use **Publish saved draft** to publish for new enrollments. **Saved revision history** can restore earlier material into a draft. Existing learners retain their original curriculum, grading rules, progress and certificates. Linked CMS lesson text is captured at course publication; media URLs remain references. Instructor assignments take effect when saved.
57
+
58
+ After upgrading, run **LMS settings → Course edition migration** batches until complete. Checkpoints survive interruption; courses also upgrade lazily before editing or enrollment. Keep a full database backup: course exports contain only draft curriculum, and this migration is not a full backup or cross-site import. Publication scheduling, editorial review and moving existing enrollments between editions remain future work.
59
+
49
60
  ## Enrollment and access
50
61
 
51
62
  `open` courses enroll learners immediately. `approval` courses create pending requests. `invite` courses require administrator enrollment. Cohort membership always requires an administrator decision. Administrators can reject, suspend, restore, cancel, and date access without deleting progress.
@@ -75,4 +86,14 @@ Private HTTP calls use an EmDash session and `X-EmDash-Request: 1`. API routes b
75
86
 
76
87
  Notifications always appear in the learner dashboard. Email is optional and disabled by default. Configure an EmDash email transport and working cron scheduler before enabling email or inactivity reminders. Certificates use the browser's print/save-as-PDF flow.
77
88
 
89
+ Learners can opt out of email from their library; this also suppresses queued email when maintenance next runs. Personal weekly lesson goals are stored targets, not measured activity reports. The library exports the learner's own records in pages of up to five records per section, with quiz answer keys and scoring snapshots removed. Continue through every page and section for a complete download; it is not a full database backup.
90
+
91
+ Administrators can publish ordered learning paths. Joining saves the path's original course list but does not enroll the learner in its courses or bypass approval, prerequisites or access dates. Course completion contributes to path progress even when access later expires. Course enrollment still pins the actual curriculum edition.
92
+
93
+ Native audio/video supports resume and playback speed, revision-fenced saves, WebVTT caption tracks and readable transcripts. Captions and media hosted elsewhere require appropriate CORS. YouTube/Vimeo controls and resume remain provider-managed. Playback reports never complete lessons or verify attendance. New caption/transcript fields have compatible defaults; enrollment playback fields are optional for existing records.
94
+
95
+ The studio can duplicate a saved course as a new draft, duplicate lessons and move lessons between modules. Review copied access/date settings before publishing. **LMS settings → Operational health** shows maintenance freshness, notification backlog/failures and migration status. A healthy heartbeat does not certify the deployment.
96
+
97
+ See the [release-readiness assessment](https://github.com/anantagnanam/anantagnanam-emdash-plugins/blob/main/docs/release-readiness.md), [platform feature matrix](https://github.com/anantagnanam/anantagnanam-emdash-plugins/blob/main/docs/platform-feature-matrix.md), and [security policy](https://github.com/anantagnanam/anantagnanam-emdash-plugins/blob/main/SECURITY.md) for remaining release gates and capabilities.
98
+
78
99
  Full documentation: [repository](https://github.com/anantagnanam/anantagnanam-emdash-plugins), [installation](https://github.com/anantagnanam/anantagnanam-emdash-plugins/blob/main/docs/installation.md), [architecture](https://github.com/anantagnanam/anantagnanam-emdash-plugins/blob/main/docs/architecture.md), and [release scope](https://github.com/anantagnanam/anantagnanam-emdash-plugins/blob/main/docs/release-scope.md).
package/astro/client.ts CHANGED
@@ -1,11 +1,7 @@
1
1
  import { API_BASE } from "@anantagnanam/lms";
2
- import type {
3
- Answers,
4
- Discussion,
5
- Notification,
6
- Page,
7
- PublicQuizAttempt,
8
- } from "@anantagnanam/lms/types";
2
+ import { renderQuiz } from "./quiz-player.js";
3
+ import { initializeMedia } from "./media-player.js";
4
+ import type { Discussion, Notification, Page, PublicQuizAttempt } from "@anantagnanam/lms/types";
9
5
 
10
6
  async function call<T>(route: string, input: Record<string, unknown>, method = "POST"): Promise<T> {
11
7
  let url = `${API_BASE}/${route}`;
@@ -18,6 +14,7 @@ async function call<T>(route: string, input: Record<string, unknown>, method = "
18
14
  } else headers["Content-Type"] = "application/json";
19
15
  const response = await fetch(url, {
20
16
  method,
17
+ signal: AbortSignal.timeout(20_000),
21
18
  credentials: "same-origin",
22
19
  headers,
23
20
  ...(method === "POST" ? { body: JSON.stringify(input) } : {}),
@@ -25,10 +22,13 @@ async function call<T>(route: string, input: Record<string, unknown>, method = "
25
22
  const result = (await response.json()) as {
26
23
  success: boolean;
27
24
  data?: T;
28
- error?: { message?: string };
25
+ error?: { message?: string; code?: string };
29
26
  };
30
27
  if (!response.ok || !result.success)
31
- throw new Error(result.error?.message ?? "Please try again.");
28
+ throw Object.assign(new Error(result.error?.message ?? "Please try again."), {
29
+ code: result.error?.code,
30
+ status: response.status,
31
+ });
32
32
  return result.data as T;
33
33
  }
34
34
  function node<K extends keyof HTMLElementTagNameMap>(
@@ -65,6 +65,16 @@ function forms() {
65
65
  const input: Record<string, unknown> = Object.fromEntries(new FormData(form));
66
66
  if ("rating" in input) input.rating = Number(input.rating);
67
67
  if ("shared" in input) input.shared = input.shared === "true";
68
+ if ("saved" in input) input.saved = input.saved === "true";
69
+ if (form.dataset.lmsRoute === "learner/preferences/save") {
70
+ input.data = {
71
+ emailNotifications: input.emailNotifications === "true",
72
+ weeklyGoalLessons: Number(input.weeklyGoalLessons),
73
+ };
74
+ input.expectedRevision = input.expectedRevision || null;
75
+ delete input.emailNotifications;
76
+ delete input.weeklyGoalLessons;
77
+ }
68
78
  if ("attachmentUrl" in input && input.attachmentUrl === "") input.attachmentUrl = null;
69
79
  if ("parentId" in input && input.parentId === "") input.parentId = null;
70
80
  const buttons = [...form.querySelectorAll<HTMLButtonElement>('button[type="submit"]')];
@@ -172,147 +182,6 @@ async function renderDiscussions(root: HTMLElement, cursor?: string, append = fa
172
182
  }
173
183
  }
174
184
 
175
- function readAnswers(form: HTMLFormElement, attempt: PublicQuizAttempt): Answers {
176
- const answers: Answers = {};
177
- const values = new FormData(form);
178
- for (const question of attempt.questions) {
179
- const picked = values.getAll(question.id).map(String);
180
- if (question.type === "multiple") answers[question.id] = picked;
181
- else if (picked[0]) answers[question.id] = picked[0];
182
- }
183
- return answers;
184
- }
185
- function renderQuiz(root: HTMLElement, attempt: PublicQuizAttempt) {
186
- const content = root.querySelector<HTMLElement>("[data-lms-quiz-content]")!;
187
- content.replaceChildren();
188
- const form = node("form");
189
- const timer = node("p", "", "lms-quiz-timer");
190
- timer.setAttribute("aria-live", "off");
191
- form.append(timer);
192
- for (const question of attempt.questions) {
193
- const fieldset = node("fieldset", undefined, "lms-quiz-question");
194
- fieldset.append(node("legend", question.prompt));
195
- if (question.type === "short") {
196
- const input = node("input");
197
- input.name = question.id;
198
- input.type = "text";
199
- input.maxLength = 2000;
200
- input.setAttribute("aria-label", "Your answer");
201
- const saved = attempt.answers?.[question.id];
202
- if (typeof saved === "string") input.value = saved;
203
- fieldset.append(input);
204
- } else
205
- for (const option of question.options) {
206
- const label = node("label", undefined, "lms-quiz-option");
207
- const input = node("input");
208
- input.name = question.id;
209
- input.type = question.type === "multiple" ? "checkbox" : "radio";
210
- input.value = option.id;
211
- const saved = attempt.answers?.[question.id];
212
- input.checked = Array.isArray(saved) ? saved.includes(option.id) : saved === option.id;
213
- label.append(input, node("span", option.text));
214
- fieldset.append(label);
215
- }
216
- form.append(fieldset);
217
- }
218
- const button = node("button", "Submit answers", "lms-btn");
219
- button.type = "submit";
220
- form.append(button);
221
- content.append(form);
222
- let interval: ReturnType<typeof setInterval> | undefined;
223
- let saving: ReturnType<typeof setTimeout> | undefined;
224
- let submitting = false;
225
- const stop = () => {
226
- if (interval) clearInterval(interval);
227
- if (saving) clearTimeout(saving);
228
- };
229
- form.addEventListener("input", () => {
230
- if (saving) clearTimeout(saving);
231
- saving = setTimeout(() => {
232
- if (!submitting && form.isConnected)
233
- void call("learner/quiz/draft", {
234
- ...data(root),
235
- attemptId: attempt.id,
236
- answers: readAnswers(form, attempt),
237
- }).catch(() => {});
238
- }, 700);
239
- });
240
- form.addEventListener("submit", async (event) => {
241
- event.preventDefault();
242
- if (submitting) return;
243
- submitting = true;
244
- button.disabled = true;
245
- stop();
246
- feedback(root, "Checking your answers…");
247
- try {
248
- const result = await call<{ attempt: PublicQuizAttempt }>("learner/quiz/submit", {
249
- ...data(root),
250
- attemptId: attempt.id,
251
- answers: readAnswers(form, attempt),
252
- });
253
- feedback(
254
- root,
255
- `${result.attempt.passed ? "Passed" : "Not passed yet"} · ${result.attempt.percent}%`,
256
- );
257
- const outcome = node("div");
258
- for (const item of result.attempt.feedback) {
259
- const section = node("div", undefined, "lms-notice");
260
- const question = attempt.questions.find((entry) => entry.id === item.questionId);
261
- section.append(
262
- node("strong", `${item.correct ? "✓" : "○"} ${question?.prompt ?? "Question"}`),
263
- );
264
- if (item.explanation) section.append(node("p", item.explanation));
265
- outcome.append(section);
266
- }
267
- content.replaceChildren(outcome);
268
- const start = root.querySelector<HTMLButtonElement>("[data-lms-quiz-start]");
269
- if (start) {
270
- start.hidden = result.attempt.passed;
271
- start.disabled = false;
272
- start.textContent = "Try another attempt";
273
- }
274
- if (result.attempt.passed) {
275
- const continueLink = node("a", "Continue learning →", "lms-btn");
276
- continueLink.href = root.dataset.nextUrl ?? window.location.pathname;
277
- content.append(continueLink);
278
- }
279
- } catch (cause) {
280
- feedback(
281
- root,
282
- cause instanceof Error ? cause.message : "Could not submit your answers.",
283
- true,
284
- );
285
- button.disabled = false;
286
- submitting = false;
287
- const start = root.querySelector<HTMLButtonElement>("[data-lms-quiz-start]");
288
- if (start) {
289
- start.disabled = false;
290
- start.hidden = false;
291
- start.textContent = "Start a new attempt";
292
- }
293
- }
294
- });
295
- if (attempt.expiresAt) {
296
- const tick = () => {
297
- if (!form.isConnected) {
298
- stop();
299
- return;
300
- }
301
- const remaining = Math.max(
302
- 0,
303
- Math.ceil((Date.parse(attempt.expiresAt!) - Date.now()) / 1000),
304
- );
305
- timer.textContent = `Time remaining ${Math.floor(remaining / 60)}:${String(remaining % 60).padStart(2, "0")}`;
306
- if (!remaining) {
307
- stop();
308
- form.requestSubmit();
309
- }
310
- };
311
- interval = setInterval(tick, 1000);
312
- tick();
313
- } else timer.textContent = "Take your time. This quiz is untimed.";
314
- }
315
-
316
185
  function quizzes() {
317
186
  for (const root of document.querySelectorAll<HTMLElement>(
318
187
  "[data-lms-quiz]:not([data-lms-bound])",
@@ -327,7 +196,7 @@ function quizzes() {
327
196
  const attempt = await call<PublicQuizAttempt>("learner/quiz/start", data(root));
328
197
  start.hidden = true;
329
198
  feedback(root, "Your attempt has started.");
330
- renderQuiz(root, attempt);
199
+ renderQuiz(root, attempt, call);
331
200
  } catch (cause) {
332
201
  start.disabled = false;
333
202
  feedback(root, cause instanceof Error ? cause.message : "Could not start quiz.", true);
@@ -382,6 +251,59 @@ async function updates(root: HTMLElement, cursor?: string, append = false) {
382
251
  function initialize() {
383
252
  forms();
384
253
  quizzes();
254
+ initializeMedia(call);
255
+ for (const root of document.querySelectorAll<HTMLElement>(
256
+ "[data-lms-export]:not([data-lms-bound])",
257
+ )) {
258
+ root.dataset.lmsBound = "true";
259
+ const select = root.querySelector<HTMLSelectElement>("[data-lms-export-section]")!;
260
+ const button = root.querySelector<HTMLButtonElement>("[data-lms-export-download]")!;
261
+ let cursor: string | undefined;
262
+ let pageNumber = 1;
263
+ select.addEventListener("change", () => {
264
+ cursor = undefined;
265
+ pageNumber = 1;
266
+ button.disabled = false;
267
+ button.textContent = "Download first page";
268
+ feedback(root, "");
269
+ });
270
+ button.addEventListener("click", async () => {
271
+ button.disabled = true;
272
+ select.disabled = true;
273
+ try {
274
+ const page = await call<Page<unknown>>(
275
+ "learner/export",
276
+ { section: select.value, cursor, limit: 5 },
277
+ "GET",
278
+ );
279
+ const url = URL.createObjectURL(
280
+ new Blob([JSON.stringify(page, null, 2)], { type: "application/json" }),
281
+ );
282
+ const link = node("a");
283
+ link.href = url;
284
+ link.download = `lms-${select.value}-${pageNumber}.json`;
285
+ document.body.append(link);
286
+ link.click();
287
+ link.remove();
288
+ setTimeout(() => URL.revokeObjectURL(url), 1000);
289
+ cursor = page.cursor;
290
+ pageNumber++;
291
+ button.disabled = !page.hasMore;
292
+ button.textContent = page.hasMore ? "Download next page" : "Section downloaded";
293
+ feedback(
294
+ root,
295
+ page.hasMore
296
+ ? "Page downloaded. Download the next page to continue."
297
+ : "All pages in this section downloaded. Choose another section to continue.",
298
+ );
299
+ } catch (error) {
300
+ button.disabled = false;
301
+ feedback(root, error instanceof Error ? error.message : "Export failed.", true);
302
+ } finally {
303
+ select.disabled = false;
304
+ }
305
+ });
306
+ }
385
307
  for (const root of document.querySelectorAll<HTMLElement>(
386
308
  "[data-lms-lesson]:not([data-lms-started])",
387
309
  )) {
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  import { Image } from "emdash/ui";
3
+ import LessonAvailabilityNote from "./LessonAvailabilityNote.astro";
3
4
  import type {
4
5
  CourseDetail,
5
6
  PublicEnrollment,
@@ -26,12 +27,17 @@ const {
26
27
  cohortId,
27
28
  cohortMembership = null,
28
29
  } = Astro.props;
29
- const firstLesson = course.modules.flatMap((module) => module.lessons)[0];
30
30
  const active =
31
31
  enrollment &&
32
32
  ["active", "completed"].includes(enrollment.status) &&
33
33
  enrollment.effectiveAccess === "granted";
34
- const next = progress?.nextLessonId ?? firstLesson?.id;
34
+ const next = progress?.nextLessonId;
35
+ const revisit =
36
+ !next && enrollment?.status === "completed"
37
+ ? course.modules
38
+ .flatMap((module) => module.lessons)
39
+ .find((lesson) => progress?.availability[lesson.id]?.available)
40
+ : undefined;
35
41
  ---
36
42
 
37
43
  <nav class="lms-breadcrumbs" aria-label="Breadcrumb">
@@ -73,6 +79,14 @@ const next = progress?.nextLessonId ?? firstLesson?.id;
73
79
  {enrollment.status === "completed" ? "Revisit lessons" : "Continue learning"} →
74
80
  </a>
75
81
  )}
82
+ {revisit && (
83
+ <a class="lms-btn" href={lessonUrl(basePath, course.slug, revisit.id)}>
84
+ Revisit lessons →
85
+ </a>
86
+ )}
87
+ {!next && progress.blockedLessonId && (
88
+ <LessonAvailabilityNote availability={progress.availability[progress.blockedLessonId]} />
89
+ )}
76
90
  {enrollment.certificate && (
77
91
  <a
78
92
  class="lms-btn lms-btn-outline"
@@ -97,6 +111,9 @@ const next = progress?.nextLessonId ?? firstLesson?.id;
97
111
  : enrollment.decisionReason || "Contact an administrator to manage your access."}
98
112
  </p>
99
113
  <a href={`${basePath}/my-learning`}>Open My Learning →</a>
114
+ {progress?.blockedLessonId && (
115
+ <LessonAvailabilityNote availability={progress.availability[progress.blockedLessonId]} />
116
+ )}
100
117
  </div>
101
118
  ) : !Astro.locals.user ? (
102
119
  <a class="lms-btn" href={loginUrl(loginPath, Astro.url.pathname + Astro.url.search)}>
@@ -222,7 +239,11 @@ const next = progress?.nextLessonId ?? firstLesson?.id;
222
239
  : String(index + 1).padStart(2, "0")}
223
240
  </span>
224
241
  <div>
225
- {active || lesson.preview ? (
242
+ {(
243
+ enrollment && ["active", "completed"].includes(enrollment.status)
244
+ ? progress?.availability[lesson.id]?.available
245
+ : lesson.preview
246
+ ) ? (
226
247
  <a href={lessonUrl(basePath, course.slug, lesson.id)}>{lesson.title}</a>
227
248
  ) : (
228
249
  <strong>{lesson.title}</strong>
@@ -231,6 +252,7 @@ const next = progress?.nextLessonId ?? firstLesson?.id;
231
252
  {lesson.kind} · {lesson.durationMinutes} min
232
253
  {!lesson.required ? " · optional" : ""}
233
254
  </small>
255
+ <LessonAvailabilityNote availability={progress?.availability[lesson.id]} />
234
256
  </div>
235
257
  {lesson.preview && <span class="lms-badge">Preview</span>}
236
258
  </li>
@@ -2,6 +2,7 @@
2
2
  import type { CourseCard, PublicEnrollment, ProgressSummary, Page } from "@anantagnanam/lms/types";
3
3
  import { courseUrl, lessonUrl, certificateUrl } from "@anantagnanam/lms/server";
4
4
  import { basePath } from "virtual:anantagnanam-lms/config";
5
+ import LessonAvailabilityNote from "./LessonAvailabilityNote.astro";
5
6
  interface Props {
6
7
  page: Page<{ course: CourseCard; enrollment: PublicEnrollment; progress: ProgressSummary }>;
7
8
  error?: string;
@@ -66,6 +67,11 @@ next.searchParams.set("cursor", page.cursor ?? "");
66
67
  </p>
67
68
  )}
68
69
  <div class="lms-actions">
70
+ {!progress.nextLessonId && progress.blockedLessonId && (
71
+ <LessonAvailabilityNote
72
+ availability={progress.availability[progress.blockedLessonId]}
73
+ />
74
+ )}
69
75
  {["active", "completed"].includes(enrollment.status) &&
70
76
  enrollment.effectiveAccess === "granted" &&
71
77
  progress.nextLessonId && (
@@ -9,9 +9,18 @@ const path = Astro.url.pathname;
9
9
  <a href={basePath} aria-current={path === basePath ? "page" : undefined}>
10
10
  Explore courses
11
11
  </a>
12
+ <a href={`${basePath}/paths`} aria-current={path === `${basePath}/paths` ? "page" : undefined}>
13
+ Learning paths
14
+ </a>
15
+ <a
16
+ href={`${basePath}/my-learning/library`}
17
+ aria-current={path === `${basePath}/my-learning/library` ? "page" : undefined}
18
+ >
19
+ My library &amp; preferences
20
+ </a>
12
21
  <a
13
22
  href={`${basePath}/my-learning`}
14
- aria-current={path.includes("/my-learning") ? "page" : undefined}
23
+ aria-current={path === `${basePath}/my-learning` ? "page" : undefined}
15
24
  >
16
25
  My learning
17
26
  </a>
@@ -0,0 +1,26 @@
1
+ ---
2
+ import type { LessonAvailability } from "@anantagnanam/lms/types";
3
+ interface Props {
4
+ availability?: LessonAvailability;
5
+ }
6
+ const { availability } = Astro.props;
7
+ ---
8
+
9
+ {availability && !availability.available && (
10
+ <small class="lms-lock-note">
11
+ {availability.reason}
12
+ {availability.releaseAt && (
13
+ <span>
14
+ {" "}
15
+ Available from{" "}
16
+ <time datetime={availability.releaseAt}>
17
+ {new Date(availability.releaseAt).toLocaleString("en-IN", {
18
+ timeZone: "UTC",
19
+ timeZoneName: "short",
20
+ })}
21
+ </time>
22
+ .
23
+ </span>
24
+ )}
25
+ </small>
26
+ )}
@@ -0,0 +1,53 @@
1
+ ---
2
+ import { PortableText, type TypedObject } from "emdash/ui";
3
+ import MediaPlayer from "./MediaPlayer.astro";
4
+ import type { PublicLesson } from "@anantagnanam/lms/types";
5
+ interface Props {
6
+ lesson: PublicLesson;
7
+ }
8
+ const { lesson } = Astro.props;
9
+ ---
10
+
11
+ {lesson.mediaUrl && ["video", "audio", "live"].includes(lesson.kind) && (
12
+ <MediaPlayer
13
+ url={lesson.mediaUrl}
14
+ kind={lesson.kind as "video" | "audio" | "live"}
15
+ title={lesson.title}
16
+ startsAt={lesson.liveStartsAt}
17
+ captions={lesson.captions ?? []}
18
+ />
19
+ )}
20
+ {lesson.transcript && (
21
+ <details class="lms-resources">
22
+ <summary>Read transcript</summary>
23
+ <p class="lms-text">{lesson.transcript}</p>
24
+ </details>
25
+ )}
26
+ <div class="lms-lesson-body">
27
+ {lesson.portableText.length > 0 ? (
28
+ <PortableText value={lesson.portableText as TypedObject[]} />
29
+ ) : (
30
+ lesson.body
31
+ .split(/\n\s*\n/)
32
+ .filter(Boolean)
33
+ .map((paragraph) => <p class="lms-text">{paragraph}</p>)
34
+ )}
35
+ </div>
36
+ {lesson.resources.length > 0 && (
37
+ <section class="lms-resources">
38
+ <h2>Keep exploring</h2>
39
+ <ul>
40
+ {lesson.resources.map((resource) => (
41
+ <li>
42
+ <a href={resource.url} target="_blank" rel="noopener noreferrer">
43
+ <span aria-hidden="true">↗</span>
44
+ <span>
45
+ {resource.title}
46
+ {resource.description && <small>{resource.description}</small>}
47
+ </span>
48
+ </a>
49
+ </li>
50
+ ))}
51
+ </ul>
52
+ </section>
53
+ )}