eat-js-sdk 0.0.25 → 0.0.26
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/eat-prompt-builder.mjs +156 -57
- package/package.json +1 -1
|
@@ -1573,8 +1573,7 @@
|
|
|
1573
1573
|
// src/lib/components/prompt/mcq/PromptMCQ.svelte
|
|
1574
1574
|
function get_each_context(ctx, list, i) {
|
|
1575
1575
|
const child_ctx = ctx.slice();
|
|
1576
|
-
child_ctx[
|
|
1577
|
-
child_ctx[17] = list[i][1];
|
|
1576
|
+
child_ctx[17] = list[i];
|
|
1578
1577
|
child_ctx[19] = i;
|
|
1579
1578
|
return child_ctx;
|
|
1580
1579
|
}
|
|
@@ -1584,7 +1583,7 @@
|
|
|
1584
1583
|
let div0_class_value;
|
|
1585
1584
|
let t2;
|
|
1586
1585
|
let current;
|
|
1587
|
-
let each_value = ensure_array_like(Object.
|
|
1586
|
+
let each_value = ensure_array_like(Object.values(
|
|
1588
1587
|
/*options*/
|
|
1589
1588
|
ctx[7]
|
|
1590
1589
|
));
|
|
@@ -1626,7 +1625,7 @@
|
|
|
1626
1625
|
}
|
|
1627
1626
|
if (dirty & /*selectedOption, Object, options, isFinished, isResultCorrect, handleOptionClick*/
|
|
1628
1627
|
398) {
|
|
1629
|
-
each_value = ensure_array_like(Object.
|
|
1628
|
+
each_value = ensure_array_like(Object.values(
|
|
1630
1629
|
/*options*/
|
|
1631
1630
|
ctx2[7]
|
|
1632
1631
|
));
|
|
@@ -1851,7 +1850,7 @@
|
|
|
1851
1850
|
function click_handler() {
|
|
1852
1851
|
return (
|
|
1853
1852
|
/*click_handler*/
|
|
1854
|
-
ctx[
|
|
1853
|
+
ctx[11](
|
|
1855
1854
|
/*option*/
|
|
1856
1855
|
ctx[17]
|
|
1857
1856
|
)
|
|
@@ -2210,10 +2209,10 @@
|
|
|
2210
2209
|
let { isDataSaving } = $$props;
|
|
2211
2210
|
let { isFinished = false } = $$props;
|
|
2212
2211
|
let { isResultCorrect = false } = $$props;
|
|
2212
|
+
let { isPreviewModeInteractive = false } = $$props;
|
|
2213
2213
|
const { rubric, interaction, metadata, scoringMetadata } = sessionData;
|
|
2214
2214
|
const { prompt, options } = interaction;
|
|
2215
2215
|
let selectedOption = null;
|
|
2216
|
-
let resultFeedbackTitle = null;
|
|
2217
2216
|
let resultFeedback = null;
|
|
2218
2217
|
const dispatch = createEventDispatcher();
|
|
2219
2218
|
if (metadata) {
|
|
@@ -2222,23 +2221,34 @@
|
|
|
2222
2221
|
const { answer_id: answerChoiceId } = currentOption;
|
|
2223
2222
|
selectedOption = answerChoiceId[0];
|
|
2224
2223
|
}
|
|
2224
|
+
const getFeedback = () => {
|
|
2225
|
+
if (!options || !selectedOption)
|
|
2226
|
+
return;
|
|
2227
|
+
const feedbackData = Object.values(options).filter((option) => option.id === selectedOption);
|
|
2228
|
+
$$invalidate(4, resultFeedback = feedbackData[0].feedback || resultFeedback);
|
|
2229
|
+
};
|
|
2225
2230
|
if (isFinished) {
|
|
2226
|
-
|
|
2227
|
-
const feedbackData = Object.values(options).filter((option) => option.id === selectedOption);
|
|
2228
|
-
resultFeedbackTitle = isResultCorrect ? "Well done!" : "Nice try!";
|
|
2229
|
-
resultFeedback = feedbackData[0].feedback || resultFeedback;
|
|
2230
|
-
}
|
|
2231
|
+
getFeedback();
|
|
2231
2232
|
const { answerId, hasAnswer } = scoringMetadata;
|
|
2232
2233
|
selectedOption = answerId && hasAnswer ? answerId : selectedOption;
|
|
2233
2234
|
}
|
|
2234
2235
|
const handleOptionClick = (optionId, option) => {
|
|
2235
|
-
if (isDataSaving || optionId === selectedOption || isFinished)
|
|
2236
|
+
if (isDataSaving || optionId === selectedOption || isFinished && !isPreviewModeInteractive)
|
|
2236
2237
|
return;
|
|
2237
2238
|
$$invalidate(3, selectedOption = optionId);
|
|
2238
2239
|
dispatch("saveOption", {
|
|
2239
2240
|
answer_id: [optionId],
|
|
2240
2241
|
answer_choice: [option]
|
|
2241
2242
|
});
|
|
2243
|
+
if (isPreviewModeInteractive) {
|
|
2244
|
+
setTimeout(
|
|
2245
|
+
() => {
|
|
2246
|
+
$$invalidate(4, resultFeedback = null);
|
|
2247
|
+
getFeedback();
|
|
2248
|
+
},
|
|
2249
|
+
50
|
|
2250
|
+
);
|
|
2251
|
+
}
|
|
2242
2252
|
};
|
|
2243
2253
|
const click_handler = (option) => handleOptionClick(option.id, option.answer);
|
|
2244
2254
|
$$self.$$set = ($$props2) => {
|
|
@@ -2250,6 +2260,8 @@
|
|
|
2250
2260
|
$$invalidate(1, isFinished = $$props2.isFinished);
|
|
2251
2261
|
if ("isResultCorrect" in $$props2)
|
|
2252
2262
|
$$invalidate(2, isResultCorrect = $$props2.isResultCorrect);
|
|
2263
|
+
if ("isPreviewModeInteractive" in $$props2)
|
|
2264
|
+
$$invalidate(10, isPreviewModeInteractive = $$props2.isPreviewModeInteractive);
|
|
2253
2265
|
};
|
|
2254
2266
|
return [
|
|
2255
2267
|
isDataSaving,
|
|
@@ -2262,6 +2274,7 @@
|
|
|
2262
2274
|
options,
|
|
2263
2275
|
handleOptionClick,
|
|
2264
2276
|
sessionData,
|
|
2277
|
+
isPreviewModeInteractive,
|
|
2265
2278
|
click_handler
|
|
2266
2279
|
];
|
|
2267
2280
|
}
|
|
@@ -2272,7 +2285,8 @@
|
|
|
2272
2285
|
sessionData: 9,
|
|
2273
2286
|
isDataSaving: 0,
|
|
2274
2287
|
isFinished: 1,
|
|
2275
|
-
isResultCorrect: 2
|
|
2288
|
+
isResultCorrect: 2,
|
|
2289
|
+
isPreviewModeInteractive: 10
|
|
2276
2290
|
});
|
|
2277
2291
|
}
|
|
2278
2292
|
get sessionData() {
|
|
@@ -2303,8 +2317,15 @@
|
|
|
2303
2317
|
this.$$set({ isResultCorrect });
|
|
2304
2318
|
flush();
|
|
2305
2319
|
}
|
|
2320
|
+
get isPreviewModeInteractive() {
|
|
2321
|
+
return this.$$.ctx[10];
|
|
2322
|
+
}
|
|
2323
|
+
set isPreviewModeInteractive(isPreviewModeInteractive) {
|
|
2324
|
+
this.$$set({ isPreviewModeInteractive });
|
|
2325
|
+
flush();
|
|
2326
|
+
}
|
|
2306
2327
|
};
|
|
2307
|
-
customElements.define("prompt-mcq", create_custom_element(PromptMCQ, { "sessionData": {}, "isDataSaving": {}, "isFinished": { "type": "Boolean" }, "isResultCorrect": { "type": "Boolean" } }, [], [], true));
|
|
2328
|
+
customElements.define("prompt-mcq", create_custom_element(PromptMCQ, { "sessionData": {}, "isDataSaving": {}, "isFinished": { "type": "Boolean" }, "isResultCorrect": { "type": "Boolean" }, "isPreviewModeInteractive": { "type": "Boolean" } }, [], [], true));
|
|
2308
2329
|
var PromptMCQ_default = PromptMCQ;
|
|
2309
2330
|
|
|
2310
2331
|
// node_modules/autosize/dist/autosize.esm.js
|
|
@@ -2416,8 +2437,8 @@
|
|
|
2416
2437
|
textarea.disabled = /*isDataSaving*/
|
|
2417
2438
|
ctx[0];
|
|
2418
2439
|
attr(textarea, "autocomplete", "off");
|
|
2419
|
-
textarea.readOnly = /*
|
|
2420
|
-
ctx[
|
|
2440
|
+
textarea.readOnly = /*isReadonlyText*/
|
|
2441
|
+
ctx[11];
|
|
2421
2442
|
},
|
|
2422
2443
|
m(target, anchor) {
|
|
2423
2444
|
insert(target, textarea, anchor);
|
|
@@ -2432,38 +2453,38 @@
|
|
|
2432
2453
|
textarea,
|
|
2433
2454
|
"input",
|
|
2434
2455
|
/*textarea_input_handler*/
|
|
2435
|
-
ctx[
|
|
2456
|
+
ctx[22]
|
|
2436
2457
|
),
|
|
2437
2458
|
listen(
|
|
2438
2459
|
textarea,
|
|
2439
2460
|
"mousedown",
|
|
2440
2461
|
/*mousedown_handler*/
|
|
2441
|
-
ctx[
|
|
2462
|
+
ctx[23]
|
|
2442
2463
|
),
|
|
2443
2464
|
listen(
|
|
2444
2465
|
textarea,
|
|
2445
2466
|
"touchstart",
|
|
2446
2467
|
/*touchstart_handler*/
|
|
2447
|
-
ctx[
|
|
2468
|
+
ctx[24],
|
|
2448
2469
|
{ passive: true }
|
|
2449
2470
|
),
|
|
2450
2471
|
listen(
|
|
2451
2472
|
textarea,
|
|
2452
2473
|
"focus",
|
|
2453
2474
|
/*focus_handler*/
|
|
2454
|
-
ctx[
|
|
2475
|
+
ctx[25]
|
|
2455
2476
|
),
|
|
2456
2477
|
listen(
|
|
2457
2478
|
textarea,
|
|
2458
2479
|
"focusout",
|
|
2459
2480
|
/*focusout_handler_1*/
|
|
2460
|
-
ctx[
|
|
2481
|
+
ctx[26]
|
|
2461
2482
|
),
|
|
2462
2483
|
listen(
|
|
2463
2484
|
textarea,
|
|
2464
2485
|
"keydown",
|
|
2465
2486
|
/*keydown_handler_1*/
|
|
2466
|
-
ctx[
|
|
2487
|
+
ctx[27]
|
|
2467
2488
|
),
|
|
2468
2489
|
action_destroyer(autosize_action = svelte_autosize_default.call(null, textarea))
|
|
2469
2490
|
];
|
|
@@ -2502,11 +2523,6 @@
|
|
|
2502
2523
|
textarea.disabled = /*isDataSaving*/
|
|
2503
2524
|
ctx2[0];
|
|
2504
2525
|
}
|
|
2505
|
-
if (dirty[0] & /*isFinished*/
|
|
2506
|
-
2) {
|
|
2507
|
-
textarea.readOnly = /*isFinished*/
|
|
2508
|
-
ctx2[1];
|
|
2509
|
-
}
|
|
2510
2526
|
if (dirty[0] & /*typeinAnswer*/
|
|
2511
2527
|
8) {
|
|
2512
2528
|
set_input_value(
|
|
@@ -2555,8 +2571,8 @@
|
|
|
2555
2571
|
input.disabled = /*isDataSaving*/
|
|
2556
2572
|
ctx[0];
|
|
2557
2573
|
attr(input, "autocomplete", "off");
|
|
2558
|
-
input.readOnly = /*
|
|
2559
|
-
ctx[
|
|
2574
|
+
input.readOnly = /*isReadonlyText*/
|
|
2575
|
+
ctx[11];
|
|
2560
2576
|
},
|
|
2561
2577
|
m(target, anchor) {
|
|
2562
2578
|
insert(target, input, anchor);
|
|
@@ -2571,19 +2587,19 @@
|
|
|
2571
2587
|
input,
|
|
2572
2588
|
"input",
|
|
2573
2589
|
/*input_input_handler*/
|
|
2574
|
-
ctx[
|
|
2590
|
+
ctx[19]
|
|
2575
2591
|
),
|
|
2576
2592
|
listen(
|
|
2577
2593
|
input,
|
|
2578
2594
|
"focusout",
|
|
2579
2595
|
/*focusout_handler*/
|
|
2580
|
-
ctx[
|
|
2596
|
+
ctx[20]
|
|
2581
2597
|
),
|
|
2582
2598
|
listen(
|
|
2583
2599
|
input,
|
|
2584
2600
|
"keydown",
|
|
2585
2601
|
/*keydown_handler*/
|
|
2586
|
-
ctx[
|
|
2602
|
+
ctx[21]
|
|
2587
2603
|
)
|
|
2588
2604
|
];
|
|
2589
2605
|
mounted = true;
|
|
@@ -2621,11 +2637,6 @@
|
|
|
2621
2637
|
input.disabled = /*isDataSaving*/
|
|
2622
2638
|
ctx2[0];
|
|
2623
2639
|
}
|
|
2624
|
-
if (dirty[0] & /*isFinished*/
|
|
2625
|
-
2) {
|
|
2626
|
-
input.readOnly = /*isFinished*/
|
|
2627
|
-
ctx2[1];
|
|
2628
|
-
}
|
|
2629
2640
|
if (dirty[0] & /*typeinAnswer*/
|
|
2630
2641
|
8 && input.value !== /*typeinAnswer*/
|
|
2631
2642
|
ctx2[3]) {
|
|
@@ -2905,7 +2916,7 @@
|
|
|
2905
2916
|
const promptbody_changes = {};
|
|
2906
2917
|
if (dirty[0] & /*textAriaLabel, placeholder, isFinished, isResultCorrect, isDataSaving, typeinAnswer*/
|
|
2907
2918
|
175 | dirty[1] & /*$$scope*/
|
|
2908
|
-
|
|
2919
|
+
32) {
|
|
2909
2920
|
promptbody_changes.$$scope = { dirty, ctx: ctx2 };
|
|
2910
2921
|
}
|
|
2911
2922
|
promptbody.$set(promptbody_changes);
|
|
@@ -2963,6 +2974,7 @@
|
|
|
2963
2974
|
let { isFinished = false } = $$props;
|
|
2964
2975
|
let { isResultCorrect = false } = $$props;
|
|
2965
2976
|
let { isPreviewMode = false } = $$props;
|
|
2977
|
+
let { isPreviewModeInteractive = false } = $$props;
|
|
2966
2978
|
const dispatch = createEventDispatcher();
|
|
2967
2979
|
let typeinAnswer;
|
|
2968
2980
|
let latestAnswer = "";
|
|
@@ -2977,15 +2989,22 @@
|
|
|
2977
2989
|
latestAnswer = typeinAnswer = events.answer[0];
|
|
2978
2990
|
}
|
|
2979
2991
|
let textAriaLabel = !latestAnswer ? "Answer input: Please type your response" : "Your response is";
|
|
2992
|
+
const isReadonlyText = isFinished && !isPreviewModeInteractive;
|
|
2993
|
+
const getFeedback = () => {
|
|
2994
|
+
const { correct: correctFeeback, incorrect: incorrectFeedback } = interaction.feedback;
|
|
2995
|
+
$$invalidate(4, resultFeedback = isResultCorrect ? correctFeeback : incorrectFeedback);
|
|
2996
|
+
};
|
|
2997
|
+
const getResultMessage = () => {
|
|
2998
|
+
$$invalidate(6, resultLabel = isResultCorrect ? "Correct" : "Incorrect");
|
|
2999
|
+
$$invalidate(7, textAriaLabel = `Submitted response is ${resultLabel.toLocaleLowerCase()}`);
|
|
3000
|
+
$$invalidate(5, placeholder = isResultCorrect ? placeholder : "No answer provided");
|
|
3001
|
+
};
|
|
2980
3002
|
if (isFinished) {
|
|
2981
3003
|
const { answer, hasAnswer } = scoringMetadata;
|
|
2982
3004
|
typeinAnswer = answer && hasAnswer ? answer : typeinAnswer;
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
if (!isPreviewMode) {
|
|
2987
|
-
const { correct: correctFeeback, incorrect: incorrectFeedback } = interaction.feedback;
|
|
2988
|
-
resultFeedback = isResultCorrect ? correctFeeback : incorrectFeedback;
|
|
3005
|
+
getResultMessage();
|
|
3006
|
+
if (!isPreviewMode || isPreviewModeInteractive) {
|
|
3007
|
+
getFeedback();
|
|
2989
3008
|
}
|
|
2990
3009
|
}
|
|
2991
3010
|
const saveAnswer = () => {
|
|
@@ -2994,6 +3013,18 @@
|
|
|
2994
3013
|
return;
|
|
2995
3014
|
latestAnswer = typeinAnswer;
|
|
2996
3015
|
dispatch("saveAnswer", { answer: [typeinAnswer || ""] });
|
|
3016
|
+
if (isPreviewModeInteractive) {
|
|
3017
|
+
setTimeout(
|
|
3018
|
+
() => {
|
|
3019
|
+
$$invalidate(6, resultLabel = "");
|
|
3020
|
+
$$invalidate(7, textAriaLabel = "");
|
|
3021
|
+
$$invalidate(5, placeholder = "");
|
|
3022
|
+
getResultMessage();
|
|
3023
|
+
getFeedback();
|
|
3024
|
+
},
|
|
3025
|
+
50
|
|
3026
|
+
);
|
|
3027
|
+
}
|
|
2997
3028
|
};
|
|
2998
3029
|
const saveOnEnter = (event) => {
|
|
2999
3030
|
if (event.key === "Enter") {
|
|
@@ -3028,7 +3059,7 @@
|
|
|
3028
3059
|
const keydown_handler_1 = (event) => saveOnEnter(event);
|
|
3029
3060
|
$$self.$$set = ($$props2) => {
|
|
3030
3061
|
if ("sessionData" in $$props2)
|
|
3031
|
-
$$invalidate(
|
|
3062
|
+
$$invalidate(16, sessionData = $$props2.sessionData);
|
|
3032
3063
|
if ("isDataSaving" in $$props2)
|
|
3033
3064
|
$$invalidate(0, isDataSaving = $$props2.isDataSaving);
|
|
3034
3065
|
if ("isFinished" in $$props2)
|
|
@@ -3036,7 +3067,9 @@
|
|
|
3036
3067
|
if ("isResultCorrect" in $$props2)
|
|
3037
3068
|
$$invalidate(2, isResultCorrect = $$props2.isResultCorrect);
|
|
3038
3069
|
if ("isPreviewMode" in $$props2)
|
|
3039
|
-
$$invalidate(
|
|
3070
|
+
$$invalidate(17, isPreviewMode = $$props2.isPreviewMode);
|
|
3071
|
+
if ("isPreviewModeInteractive" in $$props2)
|
|
3072
|
+
$$invalidate(18, isPreviewModeInteractive = $$props2.isPreviewModeInteractive);
|
|
3040
3073
|
};
|
|
3041
3074
|
return [
|
|
3042
3075
|
isDataSaving,
|
|
@@ -3050,12 +3083,14 @@
|
|
|
3050
3083
|
rubric,
|
|
3051
3084
|
prompt,
|
|
3052
3085
|
typeinType,
|
|
3086
|
+
isReadonlyText,
|
|
3053
3087
|
saveAnswer,
|
|
3054
3088
|
saveOnEnter,
|
|
3055
3089
|
handleFocus,
|
|
3056
3090
|
handleClick,
|
|
3057
3091
|
sessionData,
|
|
3058
3092
|
isPreviewMode,
|
|
3093
|
+
isPreviewModeInteractive,
|
|
3059
3094
|
input_input_handler,
|
|
3060
3095
|
focusout_handler,
|
|
3061
3096
|
keydown_handler,
|
|
@@ -3077,18 +3112,19 @@
|
|
|
3077
3112
|
create_fragment6,
|
|
3078
3113
|
safe_not_equal,
|
|
3079
3114
|
{
|
|
3080
|
-
sessionData:
|
|
3115
|
+
sessionData: 16,
|
|
3081
3116
|
isDataSaving: 0,
|
|
3082
3117
|
isFinished: 1,
|
|
3083
3118
|
isResultCorrect: 2,
|
|
3084
|
-
isPreviewMode:
|
|
3119
|
+
isPreviewMode: 17,
|
|
3120
|
+
isPreviewModeInteractive: 18
|
|
3085
3121
|
},
|
|
3086
3122
|
null,
|
|
3087
3123
|
[-1, -1]
|
|
3088
3124
|
);
|
|
3089
3125
|
}
|
|
3090
3126
|
get sessionData() {
|
|
3091
|
-
return this.$$.ctx[
|
|
3127
|
+
return this.$$.ctx[16];
|
|
3092
3128
|
}
|
|
3093
3129
|
set sessionData(sessionData) {
|
|
3094
3130
|
this.$$set({ sessionData });
|
|
@@ -3116,14 +3152,21 @@
|
|
|
3116
3152
|
flush();
|
|
3117
3153
|
}
|
|
3118
3154
|
get isPreviewMode() {
|
|
3119
|
-
return this.$$.ctx[
|
|
3155
|
+
return this.$$.ctx[17];
|
|
3120
3156
|
}
|
|
3121
3157
|
set isPreviewMode(isPreviewMode) {
|
|
3122
3158
|
this.$$set({ isPreviewMode });
|
|
3123
3159
|
flush();
|
|
3124
3160
|
}
|
|
3161
|
+
get isPreviewModeInteractive() {
|
|
3162
|
+
return this.$$.ctx[18];
|
|
3163
|
+
}
|
|
3164
|
+
set isPreviewModeInteractive(isPreviewModeInteractive) {
|
|
3165
|
+
this.$$set({ isPreviewModeInteractive });
|
|
3166
|
+
flush();
|
|
3167
|
+
}
|
|
3125
3168
|
};
|
|
3126
|
-
customElements.define("prompt-typein", create_custom_element(PromptTypeIn, { "sessionData": {}, "isDataSaving": {}, "isFinished": { "type": "Boolean" }, "isResultCorrect": { "type": "Boolean" }, "isPreviewMode": { "type": "Boolean" } }, [], [], true));
|
|
3169
|
+
customElements.define("prompt-typein", create_custom_element(PromptTypeIn, { "sessionData": {}, "isDataSaving": {}, "isFinished": { "type": "Boolean" }, "isResultCorrect": { "type": "Boolean" }, "isPreviewMode": { "type": "Boolean" }, "isPreviewModeInteractive": { "type": "Boolean" } }, [], [], true));
|
|
3127
3170
|
var PromptTypeIn_default = PromptTypeIn;
|
|
3128
3171
|
|
|
3129
3172
|
// src/lib/components/prompt/skeleton/PromptSkeleton.svelte
|
|
@@ -3398,6 +3441,10 @@
|
|
|
3398
3441
|
),
|
|
3399
3442
|
isPreviewMode: (
|
|
3400
3443
|
/*isPreviewMode*/
|
|
3444
|
+
ctx[7]
|
|
3445
|
+
),
|
|
3446
|
+
isPreviewModeInteractive: (
|
|
3447
|
+
/*isPreviewModeInteractive*/
|
|
3401
3448
|
ctx[6]
|
|
3402
3449
|
)
|
|
3403
3450
|
}
|
|
@@ -3405,7 +3452,7 @@
|
|
|
3405
3452
|
prompttypein.$on(
|
|
3406
3453
|
"saveAnswer",
|
|
3407
3454
|
/*saveEvent*/
|
|
3408
|
-
ctx[
|
|
3455
|
+
ctx[8]
|
|
3409
3456
|
);
|
|
3410
3457
|
return {
|
|
3411
3458
|
c() {
|
|
@@ -3470,13 +3517,17 @@
|
|
|
3470
3517
|
isResultCorrect: (
|
|
3471
3518
|
/*isResultCorrect*/
|
|
3472
3519
|
ctx[5]
|
|
3520
|
+
),
|
|
3521
|
+
isPreviewModeInteractive: (
|
|
3522
|
+
/*isPreviewModeInteractive*/
|
|
3523
|
+
ctx[6]
|
|
3473
3524
|
)
|
|
3474
3525
|
}
|
|
3475
3526
|
});
|
|
3476
3527
|
promptmcq.$on(
|
|
3477
3528
|
"saveOption",
|
|
3478
3529
|
/*saveEvent*/
|
|
3479
|
-
ctx[
|
|
3530
|
+
ctx[8]
|
|
3480
3531
|
);
|
|
3481
3532
|
return {
|
|
3482
3533
|
c() {
|
|
@@ -3595,8 +3646,11 @@
|
|
|
3595
3646
|
}
|
|
3596
3647
|
var bannerLabel = "Invalid session id.";
|
|
3597
3648
|
function instance6($$self, $$props, $$invalidate) {
|
|
3598
|
-
const { "session-id": sessionId, "preview-mode": previewMode, "item-id": itemId } = $$props;
|
|
3599
|
-
const
|
|
3649
|
+
const { "session-id": sessionId, "preview-mode": previewMode, "item-id": itemId, "preview-contentful": previewContentful } = $$props;
|
|
3650
|
+
const previewModeType = ["true", "interactive"];
|
|
3651
|
+
const isPreviewModeInteractive = Boolean(previewMode === "interactive" && itemId);
|
|
3652
|
+
const isPreviewMode = previewModeType.includes(previewMode);
|
|
3653
|
+
const isPreviewContentful = previewContentful === "true" && isPreviewMode;
|
|
3600
3654
|
useSetupAPI();
|
|
3601
3655
|
let sessionData;
|
|
3602
3656
|
let isDataFetching = true;
|
|
@@ -3605,6 +3659,8 @@
|
|
|
3605
3659
|
let isFinished = false;
|
|
3606
3660
|
let isLocked = false;
|
|
3607
3661
|
let isResultCorrect = false;
|
|
3662
|
+
let previewMcqCorrectAnswerId = null;
|
|
3663
|
+
let previewTypeinCorrectAnswers = [];
|
|
3608
3664
|
const skipUserValidationStr = get_store_value(skipUserValidation) ? "?skip_user_validation=true" : "";
|
|
3609
3665
|
const getSessionData = async (sessionId2) => {
|
|
3610
3666
|
try {
|
|
@@ -3621,7 +3677,8 @@
|
|
|
3621
3677
|
};
|
|
3622
3678
|
const getItemData = async (itemId2, metadata) => {
|
|
3623
3679
|
try {
|
|
3624
|
-
|
|
3680
|
+
let includeAnswer = isFinished && isLocked ? "?include=[correct_answer]" : "";
|
|
3681
|
+
includeAnswer = isPreviewContentful ? "?include=[correct_answer,unpublished]&is_contentful_preview=true" : includeAnswer;
|
|
3625
3682
|
const { data } = await useGet(`items/${itemId2}${includeAnswer}`);
|
|
3626
3683
|
$$invalidate(3, interactionType = getInteractionType(data));
|
|
3627
3684
|
$$invalidate(0, sessionData = { ...data, metadata });
|
|
@@ -3675,12 +3732,17 @@
|
|
|
3675
3732
|
};
|
|
3676
3733
|
const setPreviewData = (data) => {
|
|
3677
3734
|
let scoringMetadata;
|
|
3735
|
+
$$invalidate(4, isFinished = !isPreviewModeInteractive);
|
|
3678
3736
|
switch (interactionType) {
|
|
3679
3737
|
case INTERACTION_TYPE_MCQ:
|
|
3680
3738
|
const { options } = data.interaction;
|
|
3681
3739
|
const answerId = Object.values(options).filter((option) => option.correct_choice === true).map((option) => option.id);
|
|
3682
3740
|
scoringMetadata = { hasAnswer: true, answerId: answerId[0] };
|
|
3683
3741
|
$$invalidate(0, sessionData = { ...sessionData, scoringMetadata });
|
|
3742
|
+
if (isPreviewModeInteractive) {
|
|
3743
|
+
previewMcqCorrectAnswerId = answerId[0];
|
|
3744
|
+
}
|
|
3745
|
+
return;
|
|
3684
3746
|
case INTERACTION_TYPE_TYPEIN:
|
|
3685
3747
|
default:
|
|
3686
3748
|
const { correct_answer: correctAnswer, typein_type: typeinType } = data.interaction;
|
|
@@ -3689,9 +3751,42 @@
|
|
|
3689
3751
|
answer: typeinType === TYPEIN_TYPE_SHORT ? correctAnswer[0][0] : correctAnswer[0][0].answer[0]
|
|
3690
3752
|
};
|
|
3691
3753
|
$$invalidate(0, sessionData = { ...sessionData, scoringMetadata });
|
|
3754
|
+
if (isPreviewModeInteractive) {
|
|
3755
|
+
Object.values(correctAnswer).map((data2) => Object.values(data2).map((data3) => {
|
|
3756
|
+
if (typeinType === TYPEIN_TYPE_SHORT) {
|
|
3757
|
+
previewTypeinCorrectAnswers.push(data3);
|
|
3758
|
+
} else {
|
|
3759
|
+
data3.answer.map((answer) => previewTypeinCorrectAnswers.push(answer));
|
|
3760
|
+
}
|
|
3761
|
+
}));
|
|
3762
|
+
}
|
|
3763
|
+
return;
|
|
3764
|
+
}
|
|
3765
|
+
};
|
|
3766
|
+
const updatePreviewData = (data) => {
|
|
3767
|
+
const { scoringMetadata: metadata } = sessionData;
|
|
3768
|
+
let scoringMetadata;
|
|
3769
|
+
$$invalidate(4, isFinished = true);
|
|
3770
|
+
switch (interactionType) {
|
|
3771
|
+
case INTERACTION_TYPE_MCQ:
|
|
3772
|
+
const { answer_id: answerId } = data;
|
|
3773
|
+
scoringMetadata = { ...metadata, answerId: answerId[0] };
|
|
3774
|
+
$$invalidate(0, sessionData = { ...sessionData, scoringMetadata });
|
|
3775
|
+
$$invalidate(5, isResultCorrect = previewMcqCorrectAnswerId === answerId[0]);
|
|
3776
|
+
return;
|
|
3777
|
+
case INTERACTION_TYPE_TYPEIN:
|
|
3778
|
+
default:
|
|
3779
|
+
const { answer } = data;
|
|
3780
|
+
scoringMetadata = { ...metadata, answer: answer[0] };
|
|
3781
|
+
$$invalidate(0, sessionData = { ...sessionData, scoringMetadata });
|
|
3782
|
+
$$invalidate(5, isResultCorrect = previewTypeinCorrectAnswers.includes(answer[0].toLowerCase().trim().replace(/\s+/g, " ")));
|
|
3783
|
+
return;
|
|
3692
3784
|
}
|
|
3693
3785
|
};
|
|
3694
3786
|
const saveEvent = async ({ detail }) => {
|
|
3787
|
+
if (isPreviewModeInteractive && isPreviewMode) {
|
|
3788
|
+
updatePreviewData(detail);
|
|
3789
|
+
}
|
|
3695
3790
|
if (isLocked || isFinished)
|
|
3696
3791
|
return;
|
|
3697
3792
|
try {
|
|
@@ -3703,6 +3798,9 @@
|
|
|
3703
3798
|
$$invalidate(2, isDataSaving = false);
|
|
3704
3799
|
}
|
|
3705
3800
|
};
|
|
3801
|
+
if (!sessionId && !itemId || !sessionId && !isPreviewMode) {
|
|
3802
|
+
isDataFetching = false;
|
|
3803
|
+
}
|
|
3706
3804
|
if (isPreviewMode) {
|
|
3707
3805
|
isFinished = true;
|
|
3708
3806
|
isLocked = true;
|
|
@@ -3713,7 +3811,7 @@
|
|
|
3713
3811
|
getSessionData(sessionId);
|
|
3714
3812
|
}
|
|
3715
3813
|
$$self.$$set = ($$new_props) => {
|
|
3716
|
-
$$invalidate(
|
|
3814
|
+
$$invalidate(26, $$props = assign(assign({}, $$props), exclude_internal_props($$new_props)));
|
|
3717
3815
|
};
|
|
3718
3816
|
$$props = exclude_internal_props($$props);
|
|
3719
3817
|
return [
|
|
@@ -3723,6 +3821,7 @@
|
|
|
3723
3821
|
interactionType,
|
|
3724
3822
|
isFinished,
|
|
3725
3823
|
isResultCorrect,
|
|
3824
|
+
isPreviewModeInteractive,
|
|
3726
3825
|
isPreviewMode,
|
|
3727
3826
|
saveEvent
|
|
3728
3827
|
];
|