@project-sunbird/collection-editor-react 1.0.15 → 1.0.16-alpha

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 (43) hide show
  1. package/README.md +25 -0
  2. package/dist/api/competencyFramework.d.ts +32 -0
  3. package/dist/collection-editor.umd.js +109 -109
  4. package/dist/components/SparkMetaForm/fields/OptionSearch.d.ts +20 -0
  5. package/dist/components/SparkMetaForm/fields/OptionSearch.test.d.ts +1 -0
  6. package/dist/components/SparkMetaForm/hooks/useFieldPrepare.competency.test.d.ts +1 -0
  7. package/dist/components/SparkMetaForm/hooks/useFieldPrepare.d.ts +34 -1
  8. package/dist/components/SparkMetaForm/hooks/useFieldPrepare.skill.test.d.ts +1 -0
  9. package/dist/components/UnitContentList/LevelCourseItem.d.ts +11 -0
  10. package/dist/components/UnitContentList/LevelExamItem.d.ts +7 -0
  11. package/dist/hooks/useCompetencyFrameworks.d.ts +27 -0
  12. package/dist/hooks/useCourseCompetency.d.ts +31 -0
  13. package/dist/hooks/useCourseCompetency.test.d.ts +1 -0
  14. package/dist/hooks/useLevelExam.d.ts +18 -0
  15. package/dist/hooks/useLibrary.d.ts +98 -16
  16. package/dist/hooks/useLpCompetency.d.ts +13 -0
  17. package/dist/hooks/useSkillCategory.d.ts +15 -1
  18. package/dist/hooks/useSkillScope.d.ts +4 -3
  19. package/dist/hooks/useSkillsCoveredSync.d.ts +10 -0
  20. package/dist/hooks/useSkillsCoveredSync.test.d.ts +1 -0
  21. package/dist/i18n/locales/ar.json.d.ts +59 -27
  22. package/dist/i18n/locales/en.json.d.ts +59 -27
  23. package/dist/i18n/locales/fr.json.d.ts +59 -27
  24. package/dist/i18n/locales/pt.json.d.ts +59 -27
  25. package/dist/index.cjs +112 -112
  26. package/dist/index.js +10882 -10103
  27. package/dist/store/tree.store.d.ts +5 -2
  28. package/dist/store/tree.store.dirty.test.d.ts +1 -0
  29. package/dist/store/ui.store.d.ts +2 -0
  30. package/dist/style.css +1 -1
  31. package/dist/types/framework.d.ts +27 -0
  32. package/dist/types/profile.d.ts +8 -1
  33. package/dist/utils/competencyLeaves.d.ts +44 -0
  34. package/dist/utils/competencyLeaves.test.d.ts +1 -0
  35. package/dist/utils/libraryCardMeta.d.ts +33 -0
  36. package/dist/utils/libraryCardMeta.test.d.ts +1 -0
  37. package/dist/utils/lpCompetency.d.ts +32 -0
  38. package/dist/utils/lpCompetency.test.d.ts +1 -0
  39. package/dist/utils/lpStructure.d.ts +78 -55
  40. package/dist/utils/skillTerms.d.ts +22 -0
  41. package/dist/utils/skillTerms.test.d.ts +1 -0
  42. package/package.json +1 -1
  43. package/dist/components/UnitContentList/SkillPicker.d.ts +0 -19
@@ -0,0 +1,32 @@
1
+ import { INode } from '../types/editor';
2
+ import { ITerm } from '../types/framework';
3
+ /**
4
+ * A course or Learning Path names its competency (skill) framework, and a Learning Path optionally
5
+ * a target role. lern reads both straight off the collection (`competencyFramework`, `targetRole`)
6
+ * for skill coverage, so the editor stores them under those exact field names.
7
+ */
8
+ export declare const COMPETENCY_FRAMEWORK_FIELD = "competencyFramework";
9
+ export declare const TARGET_ROLE_FIELD = "targetRole";
10
+ /**
11
+ * Fallback skill field, for when the skill framework hasn't loaded yet. The real field is the
12
+ * framework's last category code (competencySkillField) — `skill` for some frameworks, `cuisine`
13
+ * for another — which is the field lern credits skills from.
14
+ */
15
+ export declare const SKILL_FIELD = "skill";
16
+ export declare function getRootCompetencyFramework(root: INode | undefined, treeCache: Record<string, Record<string, unknown>>): string | undefined;
17
+ export declare function getRootTargetRole(root: INode | undefined, treeCache: Record<string, Record<string, unknown>>): string | undefined;
18
+ /**
19
+ * A course's skill tags as term codes, from its own metadata under the skill framework's field.
20
+ * Older content tags by skill name; `terms` resolves those to codes like every other skill check.
21
+ */
22
+ export declare function courseSkills(course: Pick<INode, 'metadata'> | Record<string, unknown> | undefined, skillField?: string, terms?: ITerm[]): string[];
23
+ /** The skills among `skills` that the role doesn't require. Empty for an untagged course. */
24
+ export declare function skillsOutsideRole(skills: string[], roleSkills: string[]): string[];
25
+ /**
26
+ * Regular courses under content Levels that teach a skill outside the role. With a target role a
27
+ * path may only carry courses that stay within the role's skills. Untagged courses aren't counted:
28
+ * validation reports them separately as missing a skill tag.
29
+ */
30
+ export declare function coursesOutsideRole(root: INode | undefined, roleSkills: string[], skillField?: string, terms?: ITerm[]): INode[];
31
+ /** Role skills no linked regular course teaches yet (the coverage hint). */
32
+ export declare function roleSkillsNotTaught(root: INode | undefined, roleSkills: string[], skillField?: string, terms?: ITerm[]): string[];
@@ -0,0 +1 @@
1
+ export {};
@@ -1,28 +1,18 @@
1
1
  import { INode } from '../types/editor';
2
- export interface HierarchyLeafLike {
3
- objectType?: string;
4
- mimeType?: string;
5
- children?: HierarchyLeafLike[];
6
- }
2
+ import { ITerm } from '../types/framework';
3
+ export declare const EVALUATION_COURSE_CATEGORY = "Evaluation Course";
7
4
  /**
8
- * True iff the course has at least one leaf and every leaf is a QuML
9
- * QuestionSet — legacy ECML assessment resources
10
- * (application/vnd.ekstep.ecml-archive) do NOT qualify even though they're
11
- * historically labelled "assessment" content. An empty course (no leaves at
12
- * all) is not an assessment course.
13
- */
14
- export declare function isAssessmentCourse(course: HierarchyLeafLike): boolean;
15
- export interface AssessmentCourseInfo {
16
- qualifies: boolean;
17
- /** The course's full metadata from its own hierarchy read (children stripped).
18
- * Needed because composite-search results only carry the LP framework's
19
- * skill field — a course tagged under a different framework (e.g. USF)
20
- * would otherwise land in the tree without its framework or skill tags. */
21
- meta: Record<string, unknown>;
22
- }
23
- export declare function getAssessmentCourseInfo(courseId: string): Promise<AssessmentCourseInfo>;
24
- export declare function checkAssessmentCourse(courseId: string): Promise<boolean>;
25
- export declare function clearAssessmentCourseCache(): void;
5
+ * A course qualifies for the Prior/Outcome Assessment slots and a Level
6
+ * Exam only by being explicitly authored under the Evaluation Course
7
+ * primaryCategory (whose own profile restricts its content to Question
8
+ * Sets/Course Assessment — see evaluationCourseProfile) — never by
9
+ * inspecting its content shape. This is a synchronous, no-network check:
10
+ * every course node (from a search result or a loaded hierarchy) already
11
+ * carries its own primaryCategory.
12
+ */
13
+ export declare function isEvaluationCourse(course: {
14
+ primaryCategory?: string;
15
+ } | undefined): boolean;
26
16
  /**
27
17
  * Repairs a freshly-loaded LP tree (useEditorInit, after readHierarchy).
28
18
  * The hierarchy read undoes two editor-local invariants:
@@ -31,13 +21,21 @@ export declare function clearAssessmentCourseCache(): void;
31
21
  * leaves, so re-flatten them;
32
22
  * - the isAssessmentCourse flag is local-only (stripped from saves), so
33
23
  * without it no Level is recognized as a pre/post slot and "Skills
34
- * covered"/slot rules read the path as having no assessments. Recompute
35
- * it from the course's expanded subtree when the read included one, else
36
- * (single-course first/last Levels only) via a checkAssessmentCourse read.
24
+ * covered"/slot rules read the path as having no assessments. Recomputed
25
+ * from the course's OWN primaryCategory — always present on the loaded
26
+ * node, no network read needed.
37
27
  */
38
- export declare function normalizeLearningPathTree(root: INode): Promise<INode>;
28
+ export declare function normalizeLearningPathTree(root: INode): INode;
39
29
  export type LevelRole = 'pre' | 'post' | 'levelAssessment' | 'content';
40
30
  export declare function isAssessmentLevel(level: INode | undefined): boolean;
31
+ /** The Prior Assessment course: the one course of the first Level, when that is an assessment Level. */
32
+ export declare function getPriorAssessmentCourse(root: INode | undefined): INode | undefined;
33
+ /** The at-most-one Level Exam course linked directly to a content Level, if
34
+ * any — canAddCourseToLevel already caps this at one. Unlike
35
+ * isAssessmentLevel, doesn't require it to be the Level's ONLY child (a
36
+ * Level Exam course sits alongside however many regular courses that
37
+ * Level also has). */
38
+ export declare function getLevelExamCourse(level: INode | undefined): INode | undefined;
41
39
  /**
42
40
  * getLevelRole(levelIndex, levelCount, hasAssessmentCourse) → role.
43
41
  * Level[0] wrapping an assessment course is Prior/diagnostic ("pre");
@@ -65,6 +63,20 @@ export declare function isAssessmentSlotFilled(levels: INode[], slot: 'pre' | 'p
65
63
  * For callers (outside this module) that hold the level object rather
66
64
  * than its index. */
67
65
  export declare function isPrePostSlot(levels: INode[], level: INode | undefined): boolean;
66
+ /**
67
+ * True iff `levelNode` sits at index 0 or the last index among root's
68
+ * Levels AND currently has no courses at all — i.e. adding a single
69
+ * QuestionSet-only course here next would leave it indistinguishable from
70
+ * a genuine Prior/Outcome Assessment slot (isAssessmentLevel: exactly one
71
+ * course, and that one flagged isAssessmentCourse — there's no separate
72
+ * marker recording *why* a Level ended up in that shape). A Level anywhere
73
+ * else, or one that already has ≥1 course, never hits this ambiguity — a
74
+ * second course makes children.length !== 1, so isAssessmentLevel can't
75
+ * match regardless of shape (this is also why a Level Exam Course paired
76
+ * with other regular content in the same Level is unaffected: only a
77
+ * Level reduced to just the one QuestionSet-only course is at risk).
78
+ */
79
+ export declare function wouldBecomeAmbiguousSlot(rootLevels: INode[], levelNode: INode): boolean;
68
80
  /**
69
81
  * Which pre/post assessment slot (if any) is open to receive a newly-linked
70
82
  * assessment course, given root's current Level children. Pre is checked
@@ -80,6 +92,13 @@ export declare function resolveOpenAssessmentSlot(levels: INode[]): 'pre' | 'pos
80
92
  * content Levels between them. Simulates the same splice-based move
81
93
  * `reorderInParent` performs and checks the pinned Levels didn't shift,
82
94
  * rather than hand-deriving index-shift arithmetic.
95
+ *
96
+ * Also blocks moving a content Level (one that ISN'T already a pinned pre/
97
+ * post slot) into index 0 or the last index if it would land there already
98
+ * shaped like one (isAssessmentLevel — exactly one course, flagged) — e.g. a
99
+ * content Level whose only remaining course is its Level Exam course. Same
100
+ * ambiguity wouldBecomeAmbiguousSlot guards on add; without this, reordering
101
+ * could produce the identical shape without ever going through that check.
83
102
  */
84
103
  export declare function canReorderLevel(levels: INode[], fromIndex: number, toIndex: number): boolean;
85
104
  /**
@@ -106,6 +125,15 @@ export declare function canAddCourseToLevel(level: INode | undefined, incomingIs
106
125
  */
107
126
  export declare function getExplicitCurriculum(root: INode | undefined, treeCache: Record<string, Record<string, unknown>>): string | undefined;
108
127
  export declare function hasExplicitCurriculum(root: INode | undefined, treeCache: Record<string, Record<string, unknown>>): boolean;
128
+ /**
129
+ * "Path shape" (root summary, Phase 4): level count excludes the pre/post
130
+ * assessment slots (design: "Neither counts as a level"); course count
131
+ * includes every linked course, assessment courses included.
132
+ */
133
+ export declare function computePathShape(root: INode | undefined): {
134
+ levelCount: number;
135
+ courseCount: number;
136
+ };
109
137
  /**
110
138
  * "Skills covered" (root summary, Phase 4): the union of skills tagged
111
139
  * across the Prior Assessment, each Level's *selected* skills, and the
@@ -114,17 +142,16 @@ export declare function hasExplicitCurriculum(root: INode | undefined, treeCache
114
142
  * own selection) read the SAME resolved skillCategoryCode metadata field —
115
143
  * never the reserved Sunbird `competencies` field, whose platform schema
116
144
  * expects competency-ontology objects, not plain framework-term strings.
145
+ * Returned as term codes (legacy name tags normalised via `skillTerms`) so a
146
+ * skill tagged by name in one place and by code in another counts once.
117
147
  */
148
+ export declare function computeSkillsCovered(root: INode | undefined, skillCategoryCode: string | undefined, skillTerms?: ITerm[]): string[];
118
149
  /**
119
- * "Path shape" (root summary, Phase 4): level count excludes the pre/post
120
- * assessment slots (design: "Neither counts as a level"); course count
121
- * includes every linked course, assessment courses included.
150
+ * A content Level's skills: everything its regular courses teach (the Level Exam course tests
151
+ * skills, it doesn't add any). Worked out from the courses, never picked by hand, so a Level's
152
+ * skills can't disagree with what it actually teaches. As term codes.
122
153
  */
123
- export declare function computePathShape(root: INode | undefined): {
124
- levelCount: number;
125
- courseCount: number;
126
- };
127
- export declare function computeSkillsCovered(root: INode | undefined, skillCategoryCode: string | undefined): string[];
154
+ export declare function computeLevelSkills(level: INode | undefined, skillCategoryCode: string | undefined, skillTerms?: ITerm[]): string[];
128
155
  /**
129
156
  * The skills-covered union that should be persisted onto the LP root's OWN
130
157
  * skill-category metadata field, or null if it already matches what's
@@ -136,9 +163,11 @@ export declare function computeSkillsCovered(root: INode | undefined, skillCateg
136
163
  * actually covers — a Level's own selection (or the Prior/Outcome
137
164
  * Assessment's course tags) stays the single source of truth; this is a
138
165
  * read-through mirror onto root, never the other way around. Compares
139
- * order-insensitively so re-syncing an unchanged set doesn't loop.
166
+ * order-insensitively so re-syncing an unchanged set doesn't loop. The
167
+ * stored value is compared RAW (not normalised), so a root still holding
168
+ * legacy skill names is rewritten once with codes.
140
169
  */
141
- export declare function resolveSkillsCoveredForSync(root: INode | undefined, skillCategoryCode: string | undefined, treeCache: Record<string, Record<string, unknown>>): string[] | null;
170
+ export declare function resolveSkillsCoveredForSync(root: INode | undefined, skillCategoryCode: string | undefined, treeCache: Record<string, Record<string, unknown>>, skillTerms?: ITerm[], roleSkills?: string[]): string[] | null;
142
171
  /**
143
172
  * Content Levels whose selected skills include at least one outside the
144
173
  * given scope — same rule as validateLearningPathStructure's
@@ -146,18 +175,7 @@ export declare function resolveSkillsCoveredForSync(root: INode | undefined, ski
146
175
  * (linking or changing the Prior Assessment) can proactively notify the
147
176
  * author instead of waiting for send-for-review/publish to surface it.
148
177
  */
149
- export declare function findLevelsWithOutOfScopeSkills(root: INode | undefined, skillCategoryCode: string | undefined, scope: string[]): INode[];
150
- /**
151
- * Which of a content Level's SELECTED skills currently have zero linked
152
- * course tagged with them. computeSkillsCovered (and the root "Skills
153
- * covered" summary) reads only the Level's own selection — it has no idea
154
- * whether any course under that Level actually carries a given skill tag,
155
- * so a Level can claim to cover a skill that nothing linked to it teaches.
156
- * Courses missing a skill tag entirely are already caught separately by
157
- * validateLearningPathStructure's courseMissingSkillTag rule; this is about
158
- * the Level's selection vs. what its courses are ACTUALLY tagged with.
159
- */
160
- export declare function computeUncoveredSkills(level: INode | undefined, selectedSkills: string[], skillCategoryCode: string | undefined): string[];
178
+ export declare function findLevelsWithOutOfScopeSkills(root: INode | undefined, skillCategoryCode: string | undefined, scope: string[], skillTerms?: ITerm[]): INode[];
161
179
  export interface LpValidationIssue {
162
180
  code: string;
163
181
  message: string;
@@ -174,13 +192,18 @@ export declare const REQUIRES_PRIOR_POLICIES: Set<string>;
174
192
  * linked course carries a skill tag; no duplicate course across the path.
175
193
  * `skillScope` empty means "no scope constraint yet" (matches
176
194
  * useSkillScope's manual-fallback catalog, not an empty scope).
195
+ * With a target role (`roleSkills` non-empty) the path must teach every one
196
+ * of the role's skills, and only those: each role skill is taught by some
197
+ * regular course, and no regular course teaches a skill outside the role.
177
198
  */
178
- export declare function validateLearningPathStructure(root: INode | undefined, skillCategoryCode: string | undefined, skillScope: string[], treeCache?: Record<string, Record<string, unknown>>): LpValidationIssue[];
199
+ export declare function validateLearningPathStructure(root: INode | undefined, skillCategoryCode: string | undefined, skillScope: string[], treeCache?: Record<string, Record<string, unknown>>, skillTerms?: ITerm[], roleSkills?: string[]): LpValidationIssue[];
179
200
  /**
180
- * Re-verifies the pre/post assessment courses are STILL question-set-only at
181
- * publish time (Phase 1 item 6 / Phase 5: "the course may have changed since
182
- * it was linked"). Separate from validateLearningPathStructure because it
183
- * requires a network read; callers should run it alongside the sync checks,
184
- * not instead of them.
201
+ * Re-verifies the pre/post assessment courses are STILL categorized
202
+ * Evaluation Course at publish time — an author could re-tag a linked
203
+ * course's category after it was added to the path. A lightweight
204
+ * collection read (not a hierarchy walk — qualification is a single
205
+ * metadata field now) suffices. Separate from validateLearningPathStructure
206
+ * because it requires a network read; callers should run it alongside the
207
+ * sync checks, not instead of them.
185
208
  */
186
209
  export declare function revalidateAssessmentSlots(root: INode | undefined): Promise<LpValidationIssue[]>;
@@ -0,0 +1,22 @@
1
+ import { ITerm } from '../types/framework';
2
+ /** Anything with a skill's code and name: a framework term, or a competency framework's leaf skill. */
3
+ export type SkillTermLike = Pick<ITerm, 'code' | 'name'>;
4
+ /**
5
+ * Skill values are SAVED as framework term codes, but older content carries
6
+ * term names (e.g. 'Data literacy'). Resolve either form to its term the same
7
+ * way lern-service and the portal do: exact code first, then a
8
+ * case-insensitive name match. Names are ambiguous when two terms share one,
9
+ * which is why the editor normalises to codes on write.
10
+ */
11
+ export declare function findSkillTerm<T extends SkillTermLike>(value: string, terms: T[] | undefined): T | undefined;
12
+ /** A stored skill value as its term code — unchanged when no term matches
13
+ * (e.g. the framework hasn't loaded yet), so nothing is silently dropped. */
14
+ export declare function toSkillCode(value: string, terms: SkillTermLike[] | undefined): string;
15
+ /** A stored skill field (array, scalar or empty) as de-duplicated term codes. */
16
+ export declare function toSkillCodes(raw: unknown, terms: SkillTermLike[] | undefined): string[];
17
+ /** Display label for a stored skill value: the term name, whether the value
18
+ * is a code or a legacy name; falls back to the raw value. */
19
+ export declare function skillLabel(value: string, terms: SkillTermLike[] | undefined): string;
20
+ /** Search-filter values for the given skills: each term's code AND name, so
21
+ * courses tagged either way (legacy names, or codes going forward) match. */
22
+ export declare function skillFilterValues(values: string[], terms: SkillTermLike[] | undefined): string[];
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@project-sunbird/collection-editor-react",
3
- "version": "1.0.15",
3
+ "version": "1.0.16-alpha",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -1,19 +0,0 @@
1
- import { default as React } from 'react';
2
- interface SkillPickerProps {
3
- options: string[];
4
- selected: string[];
5
- /** Selected skills that fell outside the scope after the prior assessment changed —
6
- * flagged for re-selection rather than silently dropped. */
7
- outOfScope: string[];
8
- /** Selected skills with zero linked course under this Level actually
9
- * tagged for them — covered in name only. Independent of outOfScope; a
10
- * skill can be flagged for both at once. */
11
- uncovered: string[];
12
- onChange: (skills: string[]) => void;
13
- isEditable: boolean;
14
- /** Explains where the options come from — prior assessment scope, or the
15
- * manual-selection fallback. Rendered directly under the heading. */
16
- description: string;
17
- }
18
- export declare const SkillPicker: React.FC<SkillPickerProps>;
19
- export {};