@pie-element/shared-controller-utils 0.1.1-next.4 → 0.1.1-next.5
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.js +2 -2
- package/dist/persistence.d.ts +8 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -33,7 +33,7 @@ async function a(e, t, a, o = "value") {
|
|
|
33
33
|
let c = r(e);
|
|
34
34
|
if (a && typeof a == "function") try {
|
|
35
35
|
let e = n(c.map((e) => e[o]));
|
|
36
|
-
i(e) ? console.error(`shuffledValues is an empty array - refusing to call updateSession. shuffledChoices: ${JSON.stringify(c)}, key: ${o}`) :
|
|
36
|
+
i(e) ? console.error(`shuffledValues is an empty array - refusing to call updateSession. shuffledChoices: ${JSON.stringify(c)}, key: ${o}`) : await a(t.id, t.element, { shuffledValues: e });
|
|
37
37
|
} catch (e) {
|
|
38
38
|
console.warn("Unable to save shuffled order for choices"), console.error(e);
|
|
39
39
|
}
|
|
@@ -41,7 +41,7 @@ async function a(e, t, a, o = "value") {
|
|
|
41
41
|
return c;
|
|
42
42
|
}
|
|
43
43
|
function o(e, t, n) {
|
|
44
|
-
return !!(e.lockChoiceOrder || n["@pie-element"]?.lockChoiceOrder
|
|
44
|
+
return !!(e.lockChoiceOrder || n?.["@pie-element"]?.lockChoiceOrder);
|
|
45
45
|
}
|
|
46
46
|
//#endregion
|
|
47
47
|
//#region src/partial-scoring.ts
|
package/dist/persistence.d.ts
CHANGED
|
@@ -30,10 +30,11 @@ interface Environment {
|
|
|
30
30
|
* This function:
|
|
31
31
|
* 1. Checks if shuffled values already exist in the session
|
|
32
32
|
* 2. If they exist, returns choices in that order
|
|
33
|
-
* 3. If they don't exist, shuffles the choices and
|
|
33
|
+
* 3. If they don't exist, shuffles the choices and saves the order through `updateSession`
|
|
34
34
|
*
|
|
35
35
|
* @param choices - Array of choice objects to shuffle
|
|
36
|
-
* @param session - Current session object that may contain previous shuffle order
|
|
36
|
+
* @param session - Current session object that may contain previous shuffle order. An element
|
|
37
|
+
* that shuffles each of its parts passes a stand-in built for that part, with no id or element.
|
|
37
38
|
* @param updateSession - Optional function to persist the shuffle order
|
|
38
39
|
* @param choiceKey - Property name to use as the unique identifier (e.g., 'value', 'id')
|
|
39
40
|
* @returns Promise resolving to shuffled choices array
|
|
@@ -49,13 +50,15 @@ export declare function getShuffledChoices<T extends Choice>(choices: T[], sessi
|
|
|
49
50
|
* Logic:
|
|
50
51
|
* 1. If model.lockChoiceOrder is true, lock order
|
|
51
52
|
* 2. If env['@pie-element'].lockChoiceOrder is true, lock order
|
|
52
|
-
* 3.
|
|
53
|
-
*
|
|
53
|
+
* 3. Otherwise, allow shuffling
|
|
54
|
+
*
|
|
55
|
+
* The role plays no part (PIE-714): an instructor reviewing a session sees the order its
|
|
56
|
+
* student saw.
|
|
54
57
|
*
|
|
55
58
|
* @param model - Model configuration
|
|
56
59
|
* @param session - Current session (unused currently but kept for API compatibility)
|
|
57
60
|
* @param env - Environment configuration
|
|
58
61
|
* @returns Whether to lock choice order
|
|
59
62
|
*/
|
|
60
|
-
export declare function lockChoices(model: Model, _session: Session | undefined, env: Environment): boolean;
|
|
63
|
+
export declare function lockChoices(model: Model, _session: Session | undefined, env: Environment | undefined): boolean;
|
|
61
64
|
export {};
|