@project-sunbird/collection-editor-react 1.0.14 → 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/dist/api/competencyFramework.d.ts +32 -0
  2. package/dist/api/content.d.ts +1 -1
  3. package/dist/api/content.test.d.ts +1 -0
  4. package/dist/collection-editor.umd.js +112 -112
  5. package/dist/components/SparkMetaForm/fields/OptionSearch.d.ts +20 -0
  6. package/dist/components/SparkMetaForm/fields/OptionSearch.test.d.ts +1 -0
  7. package/dist/components/SparkMetaForm/hooks/useFieldPrepare.competency.test.d.ts +1 -0
  8. package/dist/components/SparkMetaForm/hooks/useFieldPrepare.d.ts +34 -1
  9. package/dist/components/SparkMetaForm/hooks/useFieldPrepare.skill.test.d.ts +1 -0
  10. package/dist/components/UnitContentList/LevelCourseItem.d.ts +2 -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/useLibrary.d.ts +88 -18
  15. package/dist/hooks/useLpCompetency.d.ts +13 -0
  16. package/dist/hooks/useSkillCategory.d.ts +15 -1
  17. package/dist/hooks/useSkillScope.d.ts +4 -3
  18. package/dist/hooks/useSkillsCoveredSync.d.ts +10 -0
  19. package/dist/hooks/useSkillsCoveredSync.test.d.ts +1 -0
  20. package/dist/i18n/locales/ar.json.d.ts +46 -28
  21. package/dist/i18n/locales/en.json.d.ts +46 -28
  22. package/dist/i18n/locales/fr.json.d.ts +46 -28
  23. package/dist/i18n/locales/pt.json.d.ts +46 -28
  24. package/dist/index.cjs +109 -109
  25. package/dist/index.js +9572 -9004
  26. package/dist/store/tree.store.d.ts +4 -1
  27. package/dist/store/tree.store.dirty.test.d.ts +1 -0
  28. package/dist/style.css +1 -1
  29. package/dist/types/content.d.ts +3 -1
  30. package/dist/types/content.test.d.ts +1 -0
  31. package/dist/types/editor.d.ts +1 -1
  32. package/dist/types/framework.d.ts +27 -0
  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 +21 -16
  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,4 +1,5 @@
1
1
  import { INode } from '../types/editor';
2
+ import { ITerm } from '../types/framework';
2
3
  export declare const EVALUATION_COURSE_CATEGORY = "Evaluation Course";
3
4
  /**
4
5
  * A course qualifies for the Prior/Outcome Assessment slots and a Level
@@ -27,6 +28,8 @@ export declare function isEvaluationCourse(course: {
27
28
  export declare function normalizeLearningPathTree(root: INode): INode;
28
29
  export type LevelRole = 'pre' | 'post' | 'levelAssessment' | 'content';
29
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;
30
33
  /** The at-most-one Level Exam course linked directly to a content Level, if
31
34
  * any — canAddCourseToLevel already caps this at one. Unlike
32
35
  * isAssessmentLevel, doesn't require it to be the Level's ONLY child (a
@@ -139,8 +142,16 @@ export declare function computePathShape(root: INode | undefined): {
139
142
  * own selection) read the SAME resolved skillCategoryCode metadata field —
140
143
  * never the reserved Sunbird `competencies` field, whose platform schema
141
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.
142
147
  */
143
- export declare function computeSkillsCovered(root: INode | undefined, skillCategoryCode: string | undefined): string[];
148
+ export declare function computeSkillsCovered(root: INode | undefined, skillCategoryCode: string | undefined, skillTerms?: ITerm[]): string[];
149
+ /**
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.
153
+ */
154
+ export declare function computeLevelSkills(level: INode | undefined, skillCategoryCode: string | undefined, skillTerms?: ITerm[]): string[];
144
155
  /**
145
156
  * The skills-covered union that should be persisted onto the LP root's OWN
146
157
  * skill-category metadata field, or null if it already matches what's
@@ -152,9 +163,11 @@ export declare function computeSkillsCovered(root: INode | undefined, skillCateg
152
163
  * actually covers — a Level's own selection (or the Prior/Outcome
153
164
  * Assessment's course tags) stays the single source of truth; this is a
154
165
  * read-through mirror onto root, never the other way around. Compares
155
- * 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.
156
169
  */
157
- 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;
158
171
  /**
159
172
  * Content Levels whose selected skills include at least one outside the
160
173
  * given scope — same rule as validateLearningPathStructure's
@@ -162,18 +175,7 @@ export declare function resolveSkillsCoveredForSync(root: INode | undefined, ski
162
175
  * (linking or changing the Prior Assessment) can proactively notify the
163
176
  * author instead of waiting for send-for-review/publish to surface it.
164
177
  */
165
- export declare function findLevelsWithOutOfScopeSkills(root: INode | undefined, skillCategoryCode: string | undefined, scope: string[]): INode[];
166
- /**
167
- * Which of a content Level's SELECTED skills currently have zero linked
168
- * course tagged with them. computeSkillsCovered (and the root "Skills
169
- * covered" summary) reads only the Level's own selection — it has no idea
170
- * whether any course under that Level actually carries a given skill tag,
171
- * so a Level can claim to cover a skill that nothing linked to it teaches.
172
- * Courses missing a skill tag entirely are already caught separately by
173
- * validateLearningPathStructure's courseMissingSkillTag rule; this is about
174
- * the Level's selection vs. what its courses are ACTUALLY tagged with.
175
- */
176
- 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[];
177
179
  export interface LpValidationIssue {
178
180
  code: string;
179
181
  message: string;
@@ -190,8 +192,11 @@ export declare const REQUIRES_PRIOR_POLICIES: Set<string>;
190
192
  * linked course carries a skill tag; no duplicate course across the path.
191
193
  * `skillScope` empty means "no scope constraint yet" (matches
192
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.
193
198
  */
194
- 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[];
195
200
  /**
196
201
  * Re-verifies the pre/post assessment courses are STILL categorized
197
202
  * Evaluation Course at publish time — an author could re-tag a linked
@@ -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.14",
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 {};