@pie-element/mc-populated-blank 0.2.7 → 0.2.9
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/README.md +10 -0
- package/controller.js +1 -0
- package/dist/controller/index.d.ts.map +1 -1
- package/dist/controller/index.js +3 -3
- package/dist/controller/index.js.map +1 -1
- package/dist/delivery/index.js +1 -6
- package/dist/delivery/index.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.iife.d.ts +13 -1
- package/dist/index.iife.d.ts.map +1 -1
- package/dist/index.iife.js +4 -4
- package/dist/index.js +4 -1019
- package/dist/index.js.map +1 -1
- package/package.json +5 -6
- package/src/controller/index.ts +8 -3
- package/src/delivery/McPopulatedBlank.svelte +2 -11
- package/src/index.iife.ts +5 -1
- package/src/index.ts +0 -1
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/mc-populated-blank",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "Multiple-choice option populates an inline blank in a sentence template (Svelte 5 PIE element)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"pie": {
|
|
9
|
-
"controller": "@pie-element/mc-populated-blank"
|
|
9
|
+
"controller": "@pie-element/mc-populated-blank/controller"
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
39
|
"dist",
|
|
40
|
-
"src"
|
|
40
|
+
"src",
|
|
41
|
+
"controller.js"
|
|
41
42
|
],
|
|
42
43
|
"sideEffects": false,
|
|
43
44
|
"scripts": {
|
|
@@ -46,15 +47,13 @@
|
|
|
46
47
|
"clean": "rm -rf dist tsconfig.tsbuildinfo"
|
|
47
48
|
},
|
|
48
49
|
"dependencies": {
|
|
49
|
-
"@pie-lib/styling-svelte": "0.1.2"
|
|
50
|
-
"lodash-es": "^4.17.21"
|
|
50
|
+
"@pie-lib/styling-svelte": "0.1.2"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"svelte": "^5.0.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
57
|
-
"@types/lodash-es": "^4.17.12",
|
|
58
57
|
"svelte": "^5.54.0",
|
|
59
58
|
"typescript": "^5.9.3",
|
|
60
59
|
"vite": "^8.0.1"
|
package/src/controller/index.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { isEmpty } from 'lodash-es';
|
|
2
1
|
import defaults, { BLANK_TOKEN, DEFAULT_LAYOUT_LIMITS } from './defaults';
|
|
3
2
|
|
|
3
|
+
const isEmptyObject = (value: unknown): boolean =>
|
|
4
|
+
!!value &&
|
|
5
|
+
typeof value === 'object' &&
|
|
6
|
+
!Array.isArray(value) &&
|
|
7
|
+
Object.keys(value as Record<string, unknown>).length === 0;
|
|
8
|
+
|
|
4
9
|
export function countBlankTokens(template: string): number {
|
|
5
10
|
if (!template) return 0;
|
|
6
11
|
const re = /\{\{blank\}\}/g;
|
|
@@ -19,7 +24,7 @@ export const getCorrectness = (question: any, session: any) => {
|
|
|
19
24
|
};
|
|
20
25
|
|
|
21
26
|
export const getPartialScore = (_question: any, session: any) => {
|
|
22
|
-
if (!session ||
|
|
27
|
+
if (!session || isEmptyObject(session) || !session.choiceId) {
|
|
23
28
|
return 0;
|
|
24
29
|
}
|
|
25
30
|
return 1;
|
|
@@ -41,7 +46,7 @@ export const isComplete = (question: any, session: any, audioComplete = false) =
|
|
|
41
46
|
|
|
42
47
|
export const outcome = (question: any, session: any, env: any) =>
|
|
43
48
|
new Promise((resolve) => {
|
|
44
|
-
if (!session ||
|
|
49
|
+
if (!session || isEmptyObject(session)) {
|
|
45
50
|
resolve({
|
|
46
51
|
score: 0,
|
|
47
52
|
empty: true,
|
|
@@ -336,17 +336,8 @@ const choiceCorrectnessById = $derived.by(() => {
|
|
|
336
336
|
}
|
|
337
337
|
|
|
338
338
|
if (showCorrectAnswer) {
|
|
339
|
-
//
|
|
340
|
-
|
|
341
|
-
// keep the correct option marked incorrect.
|
|
342
|
-
if (activeSelectedId === correctChoiceId) {
|
|
343
|
-
map.set(correctChoiceId, 'correct');
|
|
344
|
-
return map;
|
|
345
|
-
}
|
|
346
|
-
if (activeSelectedId) {
|
|
347
|
-
map.set(activeSelectedId, 'incorrect');
|
|
348
|
-
}
|
|
349
|
-
map.set(correctChoiceId, 'incorrect');
|
|
339
|
+
// Reveal mode should show only the canonical correct answer state.
|
|
340
|
+
map.set(correctChoiceId, 'correct');
|
|
350
341
|
return map;
|
|
351
342
|
}
|
|
352
343
|
|
package/src/index.iife.ts
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
* Registration is handled by PIE players/loaders, not by the element bundle itself.
|
|
4
4
|
*/
|
|
5
5
|
import Element from './delivery';
|
|
6
|
-
import * as
|
|
6
|
+
import * as controllerModule from './controller';
|
|
7
|
+
|
|
8
|
+
// Ensure the IIFE package exposes a plain controller object with callable
|
|
9
|
+
// `model`/`outcome` functions on the top-level `controller` property.
|
|
10
|
+
const controller = { ...controllerModule };
|
|
7
11
|
|
|
8
12
|
export { controller };
|
|
9
13
|
export default Element;
|
package/src/index.ts
CHANGED