@project-sunbird/sunbird-questionset-editor-web-component-react 0.1.19 → 0.1.21
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/api/content.d.ts +4 -0
- package/dist/api/dynamicAssessApi.test.d.ts +1 -0
- package/dist/api/hierarchy.d.ts +24 -4
- package/dist/api/urls.d.ts +1 -0
- package/dist/components/SparkMetaForm/MinQuestionsPanel.d.ts +13 -0
- package/dist/components/SparkMetaForm/MinQuestionsPanel.test.d.ts +1 -0
- package/dist/components/SparkMetaForm/SparkMetaForm.d.ts +3 -1
- package/dist/components/SparkMetaForm/SparkMetaForm.test.d.ts +1 -0
- package/dist/components/shared/GeneratingOverlay.d.ts +6 -0
- package/dist/components/shared/GeneratingOverlay.test.d.ts +1 -0
- package/dist/components/shared/RegenerateButton.d.ts +4 -0
- package/dist/components/shared/StaleSettingsBanner.d.ts +8 -0
- package/dist/hooks/checkPool.test.d.ts +1 -0
- package/dist/hooks/useDynamicSkillField.d.ts +2 -0
- package/dist/hooks/useFramework.d.ts +13 -0
- package/dist/hooks/useFramework.test.d.ts +1 -0
- package/dist/hooks/useIsDynamicAssess.d.ts +2 -0
- package/dist/hooks/useRefreshQuestionSetBody.d.ts +62 -0
- package/dist/hooks/useRefreshQuestionSetBody.flow.test.d.ts +1 -0
- package/dist/hooks/useRefreshQuestionSetBody.test.d.ts +1 -0
- package/dist/hooks/useSaveHierarchy.d.ts +21 -0
- package/dist/hooks/useSaveHierarchy.test.d.ts +1 -0
- package/dist/hooks/useSaveQuestion.test.d.ts +1 -0
- package/dist/hooks/useValidateAndSave.d.ts +21 -3
- package/dist/index.js +8323 -7650
- package/dist/locales/label.config.ar.json.d.ts +49 -3
- package/dist/locales/label.config.fr.json.d.ts +49 -3
- package/dist/locales/label.config.hi.json.d.ts +53 -0
- package/dist/locales/label.config.json.d.ts +49 -3
- package/dist/locales/label.config.pt.json.d.ts +49 -3
- package/dist/store/copyRegistry.store.d.ts +2 -0
- package/dist/store/question.store.d.ts +2 -0
- package/dist/style.css +1 -1
- package/dist/types/editor.d.ts +3 -0
- package/dist/types/question.d.ts +2 -1
- package/dist/utils/context.d.ts +8 -0
- package/dist/utils/difficultyLevelField.d.ts +7 -0
- package/dist/utils/difficultyLevelField.test.d.ts +1 -0
- package/dist/utils/difficultyTarget.d.ts +8 -0
- package/dist/utils/dynamicAssessDraw.d.ts +19 -0
- package/dist/utils/dynamicAssessDraw.test.d.ts +1 -0
- package/dist/utils/dynamicAssessLabels.test.d.ts +1 -0
- package/dist/utils/poolPlan.d.ts +18 -0
- package/dist/utils/poolPlan.test.d.ts +1 -0
- package/package.json +1 -1
package/dist/api/content.d.ts
CHANGED
|
@@ -11,3 +11,7 @@ export declare function compositeSearch(params: {
|
|
|
11
11
|
content: IContent[];
|
|
12
12
|
count: number;
|
|
13
13
|
}>;
|
|
14
|
+
/** Live Question counts per skill x difficultyLevel, the availability the job allocates from (same channel + category filters, no visibility filter). */
|
|
15
|
+
export declare function questionBucketCounts(categoryField: string, skills: string[], channel?: string): Promise<Record<string, Record<'E' | 'M' | 'D', number>>>;
|
|
16
|
+
/** Live Question counts per skill, with the same filters knowlg-service uses to reject a refresh (no channel, any level). */
|
|
17
|
+
export declare function questionSkillCounts(categoryField: string, skills: string[]): Promise<Record<string, number>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/api/hierarchy.d.ts
CHANGED
|
@@ -7,10 +7,30 @@ export declare function readHierarchy(contentId: string): Promise<{
|
|
|
7
7
|
export declare function updateHierarchy(_contentId: string, nodesModified: Record<string, unknown>, hierarchy: Record<string, unknown>, lastUpdatedBy?: string): Promise<{
|
|
8
8
|
identifiers: Record<string, string>;
|
|
9
9
|
}>;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
/**
|
|
11
|
+
* `PATCH questionset/v2/add` — attaches existing questions to a collection; appends after maxIndex.
|
|
12
|
+
* `collectionId` is the target section id, or `null` to attach directly to the root QuestionSet
|
|
13
|
+
* (the backend's root-attach path, used when there is no section).
|
|
14
|
+
*
|
|
15
|
+
* `''` is rejected rather than treated as `null`: omitting collectionId routes to the backend's
|
|
16
|
+
* root path, so an accidental empty string would silently operate on the root instead of failing
|
|
17
|
+
* loudly with "collectionId ... does not exist". Only an explicit `null` may mean "the root".
|
|
18
|
+
*/
|
|
19
|
+
export declare function addQuestionsToSet(rootId: string, collectionId: string | null, children: string[]): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* `DELETE questionset/v2/remove` — detaches questions from a collection (never retires them).
|
|
22
|
+
* `collectionId` is the section id, or `null` to detach a question that sits directly under the
|
|
23
|
+
* root (the backend's root-remove path). A root-level question's parent IS the root, so passing it
|
|
24
|
+
* as `collectionId` is rejected by the backend — pass `null` instead.
|
|
25
|
+
*
|
|
26
|
+
* `''` is rejected here for the same reason as in addQuestionsToSet, and the stakes are higher on
|
|
27
|
+
* this path: the backend's root-remove runs `childNodes.removeAll(children)` on the root
|
|
28
|
+
* unconditionally, so an empty string for a question that actually lives in a section would strip
|
|
29
|
+
* it from the questionset's childNodes while leaving it in the section — silent corruption.
|
|
30
|
+
*/
|
|
31
|
+
export declare function removeQuestionsFromSet(rootId: string, collectionId: string | null, children: string[]): Promise<void>;
|
|
14
32
|
export declare function publishContent(contentId: string, lastPublishedBy?: string): Promise<void>;
|
|
33
|
+
/** POST questionset/v5/refresh/body/:id: queues pool-based question selection; a pool rejection throws like any other call. */
|
|
34
|
+
export declare function refreshQuestionSetBody(contentId: string): Promise<void>;
|
|
15
35
|
export declare function sendForReview(contentId: string): Promise<void>;
|
|
16
36
|
export declare function rejectContent(contentId: string, comment: string): Promise<void>;
|
package/dist/api/urls.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export declare const URLS: {
|
|
|
19
19
|
readonly reject: "questionset/v2/reject";
|
|
20
20
|
readonly publish: "questionset/v2/publish";
|
|
21
21
|
readonly systemUpdate: "questionset/v5/system/update";
|
|
22
|
+
readonly refreshBody: "questionset/v5/refresh/body";
|
|
22
23
|
readonly commentRead: "questionset/v2/comment/read";
|
|
23
24
|
readonly commentUpdate: "questionset/v2/comment/update";
|
|
24
25
|
/** Extra read fields absent from the hierarchy response. */
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DifficultyTarget } from '../../utils/difficultyTarget';
|
|
2
|
+
type Label = (key: string, fallback: string) => string;
|
|
3
|
+
/** The fixed example under "See an example": 2 skills and the set's own minCriteria per level, independent of what the creator entered. */
|
|
4
|
+
export declare function exampleLines(minCriteria: number, L: Label): {
|
|
5
|
+
intro: string;
|
|
6
|
+
points: string[];
|
|
7
|
+
};
|
|
8
|
+
/** Dynamic Assess: the set's own per-skill minimum against the live Difficulty Target, once a skill is selected; Save is still blocked by the pool check. */
|
|
9
|
+
export declare function MinQuestionsPanel({ values, target }: {
|
|
10
|
+
values: Record<string, unknown>;
|
|
11
|
+
target: DifficultyTarget;
|
|
12
|
+
}): import("react").JSX.Element | null;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { ICategoryField } from '../../api/categoryDefinition';
|
|
3
|
+
import { toDifficultyTarget, DifficultyTarget } from '../../utils/difficultyTarget';
|
|
3
4
|
/** Shape of a single framework term entry. */
|
|
4
5
|
export interface FrameworkTerm {
|
|
5
6
|
name: string;
|
|
@@ -58,6 +59,7 @@ export interface SparkMetaFormProps {
|
|
|
58
59
|
*/
|
|
59
60
|
isRoot?: boolean;
|
|
60
61
|
}
|
|
62
|
+
export { toDifficultyTarget, type DifficultyTarget };
|
|
61
63
|
/** Exported so callers (e.g. ContextualEditor's tab bar) can check whether a
|
|
62
64
|
* given tab's section has any required field, using the exact same
|
|
63
65
|
* matching rule the tab's own <SparkMetaForm section="..."/> render uses.
|
|
@@ -71,7 +73,7 @@ export interface SelectOption {
|
|
|
71
73
|
value: string;
|
|
72
74
|
label: string;
|
|
73
75
|
}
|
|
74
|
-
export declare function adaptFieldsForFramework(fields: ICategoryField[], frameworkTerms: Map<string, FrameworkTerm[]> | undefined, categoryOrder: string[] | undefined, isRoot: boolean): ICategoryField[];
|
|
76
|
+
export declare function adaptFieldsForFramework(fields: ICategoryField[], frameworkTerms: Map<string, FrameworkTerm[]> | undefined, categoryOrder: string[] | undefined, isRoot: boolean, isDynamicAssess: boolean): ICategoryField[];
|
|
75
77
|
export interface SingleSelectDropdownProps {
|
|
76
78
|
fieldId: string;
|
|
77
79
|
value: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** Blocking loader shown while Dynamic Assess questions generate, so a stale tree can't be edited and saved over the job's result. */
|
|
3
|
+
export declare function GeneratingOverlay({ open }: {
|
|
4
|
+
open: boolean;
|
|
5
|
+
}): React.JSX.Element | null;
|
|
6
|
+
export default GeneratingOverlay;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** Explains why review is blocked when the saved Skill/Difficulty Target don't match the questions (e.g. a failed or older generation); Save & Generate is the fix. */
|
|
3
|
+
export declare function StaleSettingsBanner({ open, canRegenerate, pending }: {
|
|
4
|
+
open: boolean;
|
|
5
|
+
canRegenerate: boolean;
|
|
6
|
+
pending?: boolean;
|
|
7
|
+
}): React.JSX.Element | null;
|
|
8
|
+
export default StaleSettingsBanner;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import { IFramework, ITerm } from '../types/framework';
|
|
2
|
+
import { IEditorConfig } from '../types/editor';
|
|
3
|
+
/** The backend's skill category rule (knowlg-service and the knowlg-publish job): highest `index`, a missing index counts as 0, the first wins on ties. */
|
|
4
|
+
export declare function highestIndexCategoryCode(categories: Array<{
|
|
5
|
+
code: string;
|
|
6
|
+
index?: number;
|
|
7
|
+
}>): string | undefined;
|
|
8
|
+
/** Category codes by ascending `index`, missing last; for Dynamic Assess the backend's skill category is moved last, since Skill binds to the last entry. */
|
|
9
|
+
export declare function orderCategoryCodes(categories: Array<{
|
|
10
|
+
code: string;
|
|
11
|
+
index?: number;
|
|
12
|
+
}>, isDynamicAssess: boolean): string[];
|
|
13
|
+
/** The set's framework id with useFramework's precedence: a live pick, then the set's own, then the host's context/config; shared so Dynamic Assess reads the same framework the form shows. */
|
|
14
|
+
export declare function resolveFrameworkId(config: IEditorConfig | null | undefined, rootFramework: unknown, liveFramework?: string | null): string;
|
|
2
15
|
/**
|
|
3
16
|
* @param overrideFrameworkId - Resolves categories against this framework
|
|
4
17
|
* instead of the root/live one, fully locally to the caller — e.g. a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { SaveOutcome } from './useSaveHierarchy';
|
|
2
|
+
import { DifficultyTarget } from '../utils/difficultyTarget';
|
|
3
|
+
import { DynamicAssessSettings } from '../utils/dynamicAssessDraw';
|
|
4
|
+
import { INode } from '../types/editor';
|
|
5
|
+
import { IFramework } from '../types/framework';
|
|
6
|
+
type Buckets = Record<string, Record<'E' | 'M' | 'D', number>>;
|
|
7
|
+
/** Why the job couldn't generate these settings (it mirrors the job's own allocation, with the set's own minCriteria/multiplier), plus knowlg-service's per-skill floor; empty when generation can go ahead. */
|
|
8
|
+
export declare function poolProblems(skills: string[], target: DifficultyTarget, buckets: Buckets, skillTotals: Record<string, number>, settings?: DynamicAssessSettings): string[];
|
|
9
|
+
/** The minimum-questions panel's rule (each selected skill gets at least minCriteria), checked without a search; the message when the target is below it, else null. */
|
|
10
|
+
export declare function belowSkillMinimum(skillCount: number, target: DifficultyTarget, settings: DynamicAssessSettings): string | null;
|
|
11
|
+
/** Skills below the minCriteria x multiplier Live questions knowlg-service requires before it accepts a refresh. */
|
|
12
|
+
export declare function skillShortfalls(skills: string[], counts: Record<string, number>, settings?: DynamicAssessSettings): string[];
|
|
13
|
+
/** Translates knowlg-service's per-skill rejection, whose message is English-only ("Fewer than 6 Live questions found for skill(s): A, B"). */
|
|
14
|
+
export declare function skillPoolErrorMessage(err: unknown): string | null;
|
|
15
|
+
/** The field the job's pool query filters on: the framework's highest-index category, else "skill". */
|
|
16
|
+
export declare function deepestCategoryCode(framework: IFramework | undefined): string;
|
|
17
|
+
export declare const GENERATE_POLL_MS = 3000;
|
|
18
|
+
export declare const GENERATE_POLL_MAX_ATTEMPTS = 40;
|
|
19
|
+
export type GenerateResult = 'generated' | 'pending' | 'failed' | 'cancelled';
|
|
20
|
+
export interface GenerateDeps {
|
|
21
|
+
contentId: string;
|
|
22
|
+
save: () => Promise<SaveOutcome>;
|
|
23
|
+
refresh: (contentId: string) => Promise<void>;
|
|
24
|
+
read: (contentId: string) => Promise<{
|
|
25
|
+
rootNode: INode;
|
|
26
|
+
}>;
|
|
27
|
+
sleep?: (ms: number) => Promise<void>;
|
|
28
|
+
pollMs?: number;
|
|
29
|
+
maxAttempts?: number;
|
|
30
|
+
/** True once the editor that started this generation has closed or reloaded; the wait then stops without touching the shared stores. */
|
|
31
|
+
isCancelled?: () => boolean;
|
|
32
|
+
}
|
|
33
|
+
/** Bumped whenever an editor opens or closes; the stores are shared, so a generation from an earlier session must not write into the current one. */
|
|
34
|
+
export declare function startEditorSession(): void;
|
|
35
|
+
/** Cancellation check for a generation started now: true once another session has begun. */
|
|
36
|
+
export declare function sessionCancelledCheck(): () => boolean;
|
|
37
|
+
export declare function generationPendingMessage(): string;
|
|
38
|
+
/** Whether a timed-out generation must pause saving, given the tree the editor would save: only children it could write back over the job's result need it. */
|
|
39
|
+
export declare function shouldPauseAfterPending(editorRoot: INode | undefined): boolean;
|
|
40
|
+
/** The framework through the shared query cache (same key and staleTime as useFramework), fetched if not loaded yet; undefined without an id. */
|
|
41
|
+
export declare function fetchFramework(frameworkId: string): Promise<IFramework | undefined>;
|
|
42
|
+
/** The job's allocation check plus knowlg-service's per-skill floor, against live counts and the set's own settings; throws if the searches fail. */
|
|
43
|
+
export declare function checkPool(skills: string[], target: DifficultyTarget, framework: IFramework | undefined, channel: string | undefined, settings: DynamicAssessSettings): Promise<string[]>;
|
|
44
|
+
/** Live counts the pool checks read: per skill x level (job allocation) and per skill (knowlg-service floor); throws if the searches fail. */
|
|
45
|
+
export declare function poolCounts(categoryField: string, skills: string[], channel?: string): Promise<[Record<string, Record<"E" | "M" | "D", number>>, Record<string, number>]>;
|
|
46
|
+
/** Refresh-body, then poll until the job has finished both its /add and /remove; stopping at the first change could keep the old children and a later save would re-attach them. */
|
|
47
|
+
export declare function generateAndWait(deps: Omit<GenerateDeps, 'save'>, baselineRoot: INode | undefined): Promise<{
|
|
48
|
+
result: GenerateResult;
|
|
49
|
+
rootNode?: INode;
|
|
50
|
+
}>;
|
|
51
|
+
/** Save, then generate: inputs only exist in treeCache until saved. */
|
|
52
|
+
export declare function saveThenGenerate(deps: GenerateDeps): Promise<{
|
|
53
|
+
result: GenerateResult;
|
|
54
|
+
rootNode?: INode;
|
|
55
|
+
}>;
|
|
56
|
+
/** Dynamic Assess generation (Save & Generate, Regenerate): failures toast and return false; a failed save has already toasted and reverted. */
|
|
57
|
+
export declare function useRefreshQuestionSetBody(): {
|
|
58
|
+
refresh: (opts?: {
|
|
59
|
+
saveIfBlocked?: boolean;
|
|
60
|
+
}) => Promise<boolean>;
|
|
61
|
+
};
|
|
62
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,26 @@
|
|
|
1
|
+
import { INode } from '../types/editor';
|
|
2
|
+
export declare function buildSavePayload(nodes: INode[], treeCache: Record<string, Record<string, unknown>>, channel: string, rootPrimaryCategory: string): {
|
|
3
|
+
nodesModified: Record<string, unknown>;
|
|
4
|
+
hierarchy: Record<string, unknown>;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Outcome of a hierarchy save, for callers that need to tell the three cases
|
|
8
|
+
* apart rather than collapsing them into a boolean:
|
|
9
|
+
* - `saved` — the backend accepted the payload.
|
|
10
|
+
* - `not-attempted` — no request went out (no editor config / content id, or
|
|
11
|
+
* another save was already in flight). Nothing was sent
|
|
12
|
+
* and nothing was reverted, so the caller still owns any
|
|
13
|
+
* optimistic change it made.
|
|
14
|
+
* - `failed` — the request went out and was rejected. save() has
|
|
15
|
+
* ALREADY surfaced an error toast and called
|
|
16
|
+
* revertToSaved(), which discards every unsaved change
|
|
17
|
+
* since the last successful save — including the
|
|
18
|
+
* caller's own. There is nothing left to roll back.
|
|
19
|
+
*/
|
|
20
|
+
export type SaveOutcome = 'saved' | 'not-attempted' | 'failed';
|
|
1
21
|
export declare function useSaveHierarchy(): {
|
|
2
22
|
save: () => Promise<boolean>;
|
|
23
|
+
saveWithOutcome: () => Promise<SaveOutcome>;
|
|
3
24
|
isSaving: boolean;
|
|
4
25
|
isDirty: boolean;
|
|
5
26
|
lastSaved: string | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Validates root + all sections' required fields (same check "Save as Draft"
|
|
3
|
-
* runs)
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* runs) and surfaces MissingRequiredFieldsModal via ui.store on failure.
|
|
4
|
+
* Purely local — never touches the network and never mutates the tree.
|
|
5
|
+
*
|
|
6
|
+
* Split out from useValidateAndSave so a caller can tell "the form isn't
|
|
7
|
+
* complete, so nothing was attempted" apart from "the save itself failed".
|
|
8
|
+
* useValidateAndSave collapses both into a single `false`, which is fine for
|
|
9
|
+
* validate-then-mutate callers but not for anything that has to decide
|
|
10
|
+
* whether there is something to roll back.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useValidateRequiredFields(): () => boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Required-field check followed by a hierarchy save. Shared by the toolbar's
|
|
15
|
+
* Save-as-Draft and OutlineTree's auto-save-on-click (Add Section / Add
|
|
16
|
+
* Question).
|
|
17
|
+
*
|
|
18
|
+
* NOTE for callers: `false` means EITHER "required fields are missing, so no
|
|
19
|
+
* save was attempted" OR "the save failed". Only use this where those two
|
|
20
|
+
* warrant the same handling — i.e. validate-then-mutate, with nothing done
|
|
21
|
+
* yet that would need undoing. If you have already mutated the tree or
|
|
22
|
+
* created a backend object, use useValidateRequiredFields() up front and
|
|
23
|
+
* useSaveHierarchy().saveWithOutcome() afterwards instead.
|
|
6
24
|
*/
|
|
7
25
|
export declare function useValidateAndSave(): () => Promise<boolean>;
|