@lessonkit/lxpack 1.0.2 → 1.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.
package/dist/index.d.cts CHANGED
@@ -14,13 +14,52 @@ type LessonDescriptor = {
14
14
  /** Built SPA folder relative to the LXPack project root (`per-lesson-spa` only). */
15
15
  spaPath?: string;
16
16
  };
17
- type AssessmentDescriptor = {
17
+ type McqAssessmentDescriptor = {
18
+ kind?: "mcq";
18
19
  checkId: CheckId;
19
20
  question: string;
20
21
  choices: string[];
21
22
  answer: string;
22
23
  passingScore?: number;
23
24
  };
25
+ type TrueFalseAssessmentDescriptor = {
26
+ kind: "trueFalse";
27
+ checkId: CheckId;
28
+ question: string;
29
+ answer: boolean;
30
+ passingScore?: number;
31
+ };
32
+ type FillInBlanksAssessmentDescriptor = {
33
+ kind: "fillInBlanks";
34
+ checkId: CheckId;
35
+ question: string;
36
+ template: string;
37
+ blanks?: Array<{
38
+ id: string;
39
+ answer: string;
40
+ }>;
41
+ passingScore?: number;
42
+ };
43
+ type FindHotspotAssessmentDescriptor = {
44
+ kind: "findHotspot";
45
+ checkId: CheckId;
46
+ question: string;
47
+ src: string;
48
+ alt: string;
49
+ correctTargetId: string;
50
+ passingScore?: number;
51
+ };
52
+ type FindMultipleHotspotsAssessmentDescriptor = {
53
+ kind: "findMultipleHotspots";
54
+ checkId: CheckId;
55
+ question: string;
56
+ src: string;
57
+ alt: string;
58
+ correctTargetIds: string[];
59
+ passingScore?: number;
60
+ };
61
+ /** Discriminated assessment entries in lessonkit.json (defaults to MCQ when kind omitted). */
62
+ type AssessmentDescriptor = McqAssessmentDescriptor | TrueFalseAssessmentDescriptor | FillInBlanksAssessmentDescriptor | FindHotspotAssessmentDescriptor | FindMultipleHotspotsAssessmentDescriptor;
24
63
  type LessonkitCourseDescriptor = {
25
64
  courseId: CourseId;
26
65
  title: string;
@@ -120,7 +159,7 @@ type LxpackInjectedAssessment = {
120
159
  }>;
121
160
  }>;
122
161
  };
123
- declare function assessmentDescriptorToLxpack(assessment: AssessmentDescriptor): LxpackInjectedAssessment;
162
+ declare function assessmentDescriptorToLxpack(assessment: AssessmentDescriptor): LxpackInjectedAssessment | null;
124
163
  declare function extractAssessments(descriptor: LessonkitCourseDescriptor): LxpackInjectedAssessment[];
125
164
 
126
165
  type WriteLxpackProjectOptions = {
@@ -149,10 +188,6 @@ type WriteLxpackProjectResult = {
149
188
  */
150
189
  declare function writeLxpackProject(options: WriteLxpackProjectOptions): Promise<WriteLxpackProjectResult>;
151
190
 
152
- /**
153
- * Atomically replace `outDir` with the packaged tree at `stagingDir`.
154
- * Restores the previous `outDir` when promote fails after a backup rename.
155
- */
156
191
  declare function promoteStagingToOutDir(stagingDir: string, outDir: string): Promise<void>;
157
192
 
158
193
  type BuildStagingPackageOptions = WriteLxpackProjectOptions & {
@@ -273,4 +308,4 @@ type ParseManifestResult = {
273
308
  declare function parseLessonkitManifest(raw: unknown, label?: string, projectRoot?: string): ParseManifestResult;
274
309
  declare function loadLessonkitManifestFromFile(readJson: () => Promise<unknown>, label?: string, projectRoot?: string): Promise<ParseManifestResult>;
275
310
 
276
- export { type AssessmentDescriptor, type BuildLessonkitProjectOptions, type BuildStagingPackageOptions, type BuildStagingPackageResult, type DescriptorValidationIssue, type DescriptorValidationResult, type LessonDescriptor, type LessonkitCourseDescriptor, type LessonkitManifest, type LessonkitManifestPaths, type LxpackInjectedAssessment, type LxpackRuntimeTheme, type ManifestParseIssue, type MappedLessonkitIds, type PackageLessonkitCourseOptions, type PackageLessonkitCourseResult, type PackageValidationIssue, type ParseManifestResult, type ProjectPathsInput, type SpaLayout, type SpaLessonEntry, type ValidateLessonkitProjectOptions, type ValidatePackageInputsResult, type ValidationIssue, type WriteLxpackProjectOptions, type WriteLxpackProjectResult, assessmentDescriptorToLxpack, buildLessonkitProject, buildStagingPackage, descriptorToInterchange, ensureOutDirParent, extractAssessments, loadLessonkitManifestFromFile, mapLessonkitIds, packageLessonkitCourse, parseLessonkitManifest, promoteStagingToOutDir, remapArtifactPaths, resolveSafePackageOutputOverride, resolveSpaLessons, themeToLxpackRuntime, validateDescriptor, validateDescriptorForTarget, validateLessonkitProject, validatePackageInputs, validateProjectPaths, writeLxpackProject };
311
+ export { type AssessmentDescriptor, type BuildLessonkitProjectOptions, type BuildStagingPackageOptions, type BuildStagingPackageResult, type DescriptorValidationIssue, type DescriptorValidationResult, type FillInBlanksAssessmentDescriptor, type LessonDescriptor, type LessonkitCourseDescriptor, type LessonkitManifest, type LessonkitManifestPaths, type LxpackInjectedAssessment, type LxpackRuntimeTheme, type ManifestParseIssue, type MappedLessonkitIds, type McqAssessmentDescriptor, type PackageLessonkitCourseOptions, type PackageLessonkitCourseResult, type PackageValidationIssue, type ParseManifestResult, type ProjectPathsInput, type SpaLayout, type SpaLessonEntry, type TrueFalseAssessmentDescriptor, type ValidateLessonkitProjectOptions, type ValidatePackageInputsResult, type ValidationIssue, type WriteLxpackProjectOptions, type WriteLxpackProjectResult, assessmentDescriptorToLxpack, buildLessonkitProject, buildStagingPackage, descriptorToInterchange, ensureOutDirParent, extractAssessments, loadLessonkitManifestFromFile, mapLessonkitIds, packageLessonkitCourse, parseLessonkitManifest, promoteStagingToOutDir, remapArtifactPaths, resolveSafePackageOutputOverride, resolveSpaLessons, themeToLxpackRuntime, validateDescriptor, validateDescriptorForTarget, validateLessonkitProject, validatePackageInputs, validateProjectPaths, writeLxpackProject };
package/dist/index.d.ts CHANGED
@@ -14,13 +14,52 @@ type LessonDescriptor = {
14
14
  /** Built SPA folder relative to the LXPack project root (`per-lesson-spa` only). */
15
15
  spaPath?: string;
16
16
  };
17
- type AssessmentDescriptor = {
17
+ type McqAssessmentDescriptor = {
18
+ kind?: "mcq";
18
19
  checkId: CheckId;
19
20
  question: string;
20
21
  choices: string[];
21
22
  answer: string;
22
23
  passingScore?: number;
23
24
  };
25
+ type TrueFalseAssessmentDescriptor = {
26
+ kind: "trueFalse";
27
+ checkId: CheckId;
28
+ question: string;
29
+ answer: boolean;
30
+ passingScore?: number;
31
+ };
32
+ type FillInBlanksAssessmentDescriptor = {
33
+ kind: "fillInBlanks";
34
+ checkId: CheckId;
35
+ question: string;
36
+ template: string;
37
+ blanks?: Array<{
38
+ id: string;
39
+ answer: string;
40
+ }>;
41
+ passingScore?: number;
42
+ };
43
+ type FindHotspotAssessmentDescriptor = {
44
+ kind: "findHotspot";
45
+ checkId: CheckId;
46
+ question: string;
47
+ src: string;
48
+ alt: string;
49
+ correctTargetId: string;
50
+ passingScore?: number;
51
+ };
52
+ type FindMultipleHotspotsAssessmentDescriptor = {
53
+ kind: "findMultipleHotspots";
54
+ checkId: CheckId;
55
+ question: string;
56
+ src: string;
57
+ alt: string;
58
+ correctTargetIds: string[];
59
+ passingScore?: number;
60
+ };
61
+ /** Discriminated assessment entries in lessonkit.json (defaults to MCQ when kind omitted). */
62
+ type AssessmentDescriptor = McqAssessmentDescriptor | TrueFalseAssessmentDescriptor | FillInBlanksAssessmentDescriptor | FindHotspotAssessmentDescriptor | FindMultipleHotspotsAssessmentDescriptor;
24
63
  type LessonkitCourseDescriptor = {
25
64
  courseId: CourseId;
26
65
  title: string;
@@ -120,7 +159,7 @@ type LxpackInjectedAssessment = {
120
159
  }>;
121
160
  }>;
122
161
  };
123
- declare function assessmentDescriptorToLxpack(assessment: AssessmentDescriptor): LxpackInjectedAssessment;
162
+ declare function assessmentDescriptorToLxpack(assessment: AssessmentDescriptor): LxpackInjectedAssessment | null;
124
163
  declare function extractAssessments(descriptor: LessonkitCourseDescriptor): LxpackInjectedAssessment[];
125
164
 
126
165
  type WriteLxpackProjectOptions = {
@@ -149,10 +188,6 @@ type WriteLxpackProjectResult = {
149
188
  */
150
189
  declare function writeLxpackProject(options: WriteLxpackProjectOptions): Promise<WriteLxpackProjectResult>;
151
190
 
152
- /**
153
- * Atomically replace `outDir` with the packaged tree at `stagingDir`.
154
- * Restores the previous `outDir` when promote fails after a backup rename.
155
- */
156
191
  declare function promoteStagingToOutDir(stagingDir: string, outDir: string): Promise<void>;
157
192
 
158
193
  type BuildStagingPackageOptions = WriteLxpackProjectOptions & {
@@ -273,4 +308,4 @@ type ParseManifestResult = {
273
308
  declare function parseLessonkitManifest(raw: unknown, label?: string, projectRoot?: string): ParseManifestResult;
274
309
  declare function loadLessonkitManifestFromFile(readJson: () => Promise<unknown>, label?: string, projectRoot?: string): Promise<ParseManifestResult>;
275
310
 
276
- export { type AssessmentDescriptor, type BuildLessonkitProjectOptions, type BuildStagingPackageOptions, type BuildStagingPackageResult, type DescriptorValidationIssue, type DescriptorValidationResult, type LessonDescriptor, type LessonkitCourseDescriptor, type LessonkitManifest, type LessonkitManifestPaths, type LxpackInjectedAssessment, type LxpackRuntimeTheme, type ManifestParseIssue, type MappedLessonkitIds, type PackageLessonkitCourseOptions, type PackageLessonkitCourseResult, type PackageValidationIssue, type ParseManifestResult, type ProjectPathsInput, type SpaLayout, type SpaLessonEntry, type ValidateLessonkitProjectOptions, type ValidatePackageInputsResult, type ValidationIssue, type WriteLxpackProjectOptions, type WriteLxpackProjectResult, assessmentDescriptorToLxpack, buildLessonkitProject, buildStagingPackage, descriptorToInterchange, ensureOutDirParent, extractAssessments, loadLessonkitManifestFromFile, mapLessonkitIds, packageLessonkitCourse, parseLessonkitManifest, promoteStagingToOutDir, remapArtifactPaths, resolveSafePackageOutputOverride, resolveSpaLessons, themeToLxpackRuntime, validateDescriptor, validateDescriptorForTarget, validateLessonkitProject, validatePackageInputs, validateProjectPaths, writeLxpackProject };
311
+ export { type AssessmentDescriptor, type BuildLessonkitProjectOptions, type BuildStagingPackageOptions, type BuildStagingPackageResult, type DescriptorValidationIssue, type DescriptorValidationResult, type FillInBlanksAssessmentDescriptor, type LessonDescriptor, type LessonkitCourseDescriptor, type LessonkitManifest, type LessonkitManifestPaths, type LxpackInjectedAssessment, type LxpackRuntimeTheme, type ManifestParseIssue, type MappedLessonkitIds, type McqAssessmentDescriptor, type PackageLessonkitCourseOptions, type PackageLessonkitCourseResult, type PackageValidationIssue, type ParseManifestResult, type ProjectPathsInput, type SpaLayout, type SpaLessonEntry, type TrueFalseAssessmentDescriptor, type ValidateLessonkitProjectOptions, type ValidatePackageInputsResult, type ValidationIssue, type WriteLxpackProjectOptions, type WriteLxpackProjectResult, assessmentDescriptorToLxpack, buildLessonkitProject, buildStagingPackage, descriptorToInterchange, ensureOutDirParent, extractAssessments, loadLessonkitManifestFromFile, mapLessonkitIds, packageLessonkitCourse, parseLessonkitManifest, promoteStagingToOutDir, remapArtifactPaths, resolveSafePackageOutputOverride, resolveSpaLessons, themeToLxpackRuntime, validateDescriptor, validateDescriptorForTarget, validateLessonkitProject, validatePackageInputs, validateProjectPaths, writeLxpackProject };