eat-js-sdk 0.0.12 → 0.0.13
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 +273 -78
- package/package.json +1 -1
|
@@ -1586,16 +1586,16 @@
|
|
|
1586
1586
|
function instance2($$self, $$props, $$invalidate) {
|
|
1587
1587
|
let { resultFeedback = null } = $$props;
|
|
1588
1588
|
let { resultFeedbackTitle = null } = $$props;
|
|
1589
|
-
let { isResultCorrect
|
|
1589
|
+
let { isResultCorrect = true } = $$props;
|
|
1590
1590
|
$$self.$$set = ($$props2) => {
|
|
1591
1591
|
if ("resultFeedback" in $$props2)
|
|
1592
1592
|
$$invalidate(0, resultFeedback = $$props2.resultFeedback);
|
|
1593
1593
|
if ("resultFeedbackTitle" in $$props2)
|
|
1594
1594
|
$$invalidate(1, resultFeedbackTitle = $$props2.resultFeedbackTitle);
|
|
1595
1595
|
if ("isResultCorrect" in $$props2)
|
|
1596
|
-
$$invalidate(2,
|
|
1596
|
+
$$invalidate(2, isResultCorrect = $$props2.isResultCorrect);
|
|
1597
1597
|
};
|
|
1598
|
-
return [resultFeedback, resultFeedbackTitle,
|
|
1598
|
+
return [resultFeedback, resultFeedbackTitle, isResultCorrect];
|
|
1599
1599
|
}
|
|
1600
1600
|
var PromptResultFeedback = class extends SvelteComponent {
|
|
1601
1601
|
constructor(options) {
|
|
@@ -1623,8 +1623,8 @@
|
|
|
1623
1623
|
get isResultCorrect() {
|
|
1624
1624
|
return this.$$.ctx[2];
|
|
1625
1625
|
}
|
|
1626
|
-
set isResultCorrect(
|
|
1627
|
-
this.$$set({ isResultCorrect
|
|
1626
|
+
set isResultCorrect(isResultCorrect) {
|
|
1627
|
+
this.$$set({ isResultCorrect });
|
|
1628
1628
|
flush();
|
|
1629
1629
|
}
|
|
1630
1630
|
};
|
|
@@ -2299,8 +2299,8 @@
|
|
|
2299
2299
|
function instance3($$self, $$props, $$invalidate) {
|
|
2300
2300
|
let { sessionData } = $$props;
|
|
2301
2301
|
let { isDataSaving } = $$props;
|
|
2302
|
-
let { isFinished
|
|
2303
|
-
let { isResultCorrect
|
|
2302
|
+
let { isFinished = false } = $$props;
|
|
2303
|
+
let { isResultCorrect = false } = $$props;
|
|
2304
2304
|
const { rubric, interaction, metadata, scoringMetadata } = sessionData;
|
|
2305
2305
|
const { prompt, options } = interaction;
|
|
2306
2306
|
let selectedOption = null;
|
|
@@ -2312,16 +2312,16 @@
|
|
|
2312
2312
|
const { answer_id: answerChoiceId } = currentOption;
|
|
2313
2313
|
selectedOption = answerChoiceId[0];
|
|
2314
2314
|
}
|
|
2315
|
-
if (
|
|
2315
|
+
if (isFinished) {
|
|
2316
2316
|
if (options && selectedOption) {
|
|
2317
2317
|
const feedbackData = Object.values(options).filter((option) => option.id === selectedOption);
|
|
2318
2318
|
resultFeedback = feedbackData[0].feedback || resultFeedback;
|
|
2319
2319
|
}
|
|
2320
|
-
const { answerId,
|
|
2321
|
-
selectedOption = answerId &&
|
|
2320
|
+
const { answerId, hasAnswer } = scoringMetadata;
|
|
2321
|
+
selectedOption = answerId && hasAnswer ? answerId : selectedOption;
|
|
2322
2322
|
}
|
|
2323
2323
|
const handleOptionClick = (optionId, option) => {
|
|
2324
|
-
if (isDataSaving || optionId === selectedOption ||
|
|
2324
|
+
if (isDataSaving || optionId === selectedOption || isFinished)
|
|
2325
2325
|
return;
|
|
2326
2326
|
$$invalidate(3, selectedOption = optionId);
|
|
2327
2327
|
dispatch("saveOption", {
|
|
@@ -2336,14 +2336,14 @@
|
|
|
2336
2336
|
if ("isDataSaving" in $$props2)
|
|
2337
2337
|
$$invalidate(0, isDataSaving = $$props2.isDataSaving);
|
|
2338
2338
|
if ("isFinished" in $$props2)
|
|
2339
|
-
$$invalidate(1,
|
|
2339
|
+
$$invalidate(1, isFinished = $$props2.isFinished);
|
|
2340
2340
|
if ("isResultCorrect" in $$props2)
|
|
2341
|
-
$$invalidate(2,
|
|
2341
|
+
$$invalidate(2, isResultCorrect = $$props2.isResultCorrect);
|
|
2342
2342
|
};
|
|
2343
2343
|
return [
|
|
2344
2344
|
isDataSaving,
|
|
2345
|
-
|
|
2346
|
-
|
|
2345
|
+
isFinished,
|
|
2346
|
+
isResultCorrect,
|
|
2347
2347
|
selectedOption,
|
|
2348
2348
|
resultFeedback,
|
|
2349
2349
|
rubric,
|
|
@@ -2381,15 +2381,15 @@
|
|
|
2381
2381
|
get isFinished() {
|
|
2382
2382
|
return this.$$.ctx[1];
|
|
2383
2383
|
}
|
|
2384
|
-
set isFinished(
|
|
2385
|
-
this.$$set({ isFinished
|
|
2384
|
+
set isFinished(isFinished) {
|
|
2385
|
+
this.$$set({ isFinished });
|
|
2386
2386
|
flush();
|
|
2387
2387
|
}
|
|
2388
2388
|
get isResultCorrect() {
|
|
2389
2389
|
return this.$$.ctx[2];
|
|
2390
2390
|
}
|
|
2391
|
-
set isResultCorrect(
|
|
2392
|
-
this.$$set({ isResultCorrect
|
|
2391
|
+
set isResultCorrect(isResultCorrect) {
|
|
2392
|
+
this.$$set({ isResultCorrect });
|
|
2393
2393
|
flush();
|
|
2394
2394
|
}
|
|
2395
2395
|
};
|
|
@@ -2487,17 +2487,23 @@
|
|
|
2487
2487
|
attr(textarea, "aria-label", "Answer input: Please type your response");
|
|
2488
2488
|
attr(textarea, "placeholder", placeholder);
|
|
2489
2489
|
attr(textarea, "rows", "3");
|
|
2490
|
-
attr(textarea, "class", textarea_class_value = "typein-textbox overflow-hidden " + (
|
|
2490
|
+
attr(textarea, "class", textarea_class_value = "typein-textbox overflow-hidden " + (!/*isFinished*/
|
|
2491
|
+
ctx[1] ? "" : (
|
|
2492
|
+
/*isResultCorrect*/
|
|
2493
|
+
ctx[2] ? "border-2 border-green-800" : "border-2 border-red-800"
|
|
2494
|
+
)));
|
|
2491
2495
|
textarea.disabled = /*isDataSaving*/
|
|
2492
2496
|
ctx[0];
|
|
2493
2497
|
attr(textarea, "autocomplete", "off");
|
|
2498
|
+
textarea.readOnly = /*isFinished*/
|
|
2499
|
+
ctx[1];
|
|
2494
2500
|
},
|
|
2495
2501
|
m(target, anchor) {
|
|
2496
2502
|
insert(target, textarea, anchor);
|
|
2497
2503
|
set_input_value(
|
|
2498
2504
|
textarea,
|
|
2499
2505
|
/*typeinAnswer*/
|
|
2500
|
-
ctx[
|
|
2506
|
+
ctx[3]
|
|
2501
2507
|
);
|
|
2502
2508
|
if (!mounted) {
|
|
2503
2509
|
dispose = [
|
|
@@ -2505,38 +2511,38 @@
|
|
|
2505
2511
|
textarea,
|
|
2506
2512
|
"input",
|
|
2507
2513
|
/*textarea_input_handler*/
|
|
2508
|
-
ctx[
|
|
2514
|
+
ctx[15]
|
|
2509
2515
|
),
|
|
2510
2516
|
listen(
|
|
2511
2517
|
textarea,
|
|
2512
2518
|
"mousedown",
|
|
2513
2519
|
/*mousedown_handler*/
|
|
2514
|
-
ctx[
|
|
2520
|
+
ctx[16]
|
|
2515
2521
|
),
|
|
2516
2522
|
listen(
|
|
2517
2523
|
textarea,
|
|
2518
2524
|
"touchstart",
|
|
2519
2525
|
/*touchstart_handler*/
|
|
2520
|
-
ctx[
|
|
2526
|
+
ctx[17],
|
|
2521
2527
|
{ passive: true }
|
|
2522
2528
|
),
|
|
2523
2529
|
listen(
|
|
2524
2530
|
textarea,
|
|
2525
2531
|
"focus",
|
|
2526
2532
|
/*focus_handler*/
|
|
2527
|
-
ctx[
|
|
2533
|
+
ctx[18]
|
|
2528
2534
|
),
|
|
2529
2535
|
listen(
|
|
2530
2536
|
textarea,
|
|
2531
2537
|
"focusout",
|
|
2532
2538
|
/*focusout_handler_1*/
|
|
2533
|
-
ctx[
|
|
2539
|
+
ctx[19]
|
|
2534
2540
|
),
|
|
2535
2541
|
listen(
|
|
2536
2542
|
textarea,
|
|
2537
2543
|
"keydown",
|
|
2538
2544
|
/*keydown_handler_1*/
|
|
2539
|
-
ctx[
|
|
2545
|
+
ctx[20]
|
|
2540
2546
|
),
|
|
2541
2547
|
action_destroyer(autosize_action = svelte_autosize_default.call(null, textarea))
|
|
2542
2548
|
];
|
|
@@ -2544,17 +2550,30 @@
|
|
|
2544
2550
|
}
|
|
2545
2551
|
},
|
|
2546
2552
|
p(ctx2, dirty) {
|
|
2553
|
+
if (dirty & /*isFinished, isResultCorrect*/
|
|
2554
|
+
6 && textarea_class_value !== (textarea_class_value = "typein-textbox overflow-hidden " + (!/*isFinished*/
|
|
2555
|
+
ctx2[1] ? "" : (
|
|
2556
|
+
/*isResultCorrect*/
|
|
2557
|
+
ctx2[2] ? "border-2 border-green-800" : "border-2 border-red-800"
|
|
2558
|
+
)))) {
|
|
2559
|
+
attr(textarea, "class", textarea_class_value);
|
|
2560
|
+
}
|
|
2547
2561
|
if (dirty & /*isDataSaving*/
|
|
2548
2562
|
1) {
|
|
2549
2563
|
textarea.disabled = /*isDataSaving*/
|
|
2550
2564
|
ctx2[0];
|
|
2551
2565
|
}
|
|
2552
|
-
if (dirty & /*
|
|
2566
|
+
if (dirty & /*isFinished*/
|
|
2553
2567
|
2) {
|
|
2568
|
+
textarea.readOnly = /*isFinished*/
|
|
2569
|
+
ctx2[1];
|
|
2570
|
+
}
|
|
2571
|
+
if (dirty & /*typeinAnswer*/
|
|
2572
|
+
8) {
|
|
2554
2573
|
set_input_value(
|
|
2555
2574
|
textarea,
|
|
2556
2575
|
/*typeinAnswer*/
|
|
2557
|
-
ctx2[
|
|
2576
|
+
ctx2[3]
|
|
2558
2577
|
);
|
|
2559
2578
|
}
|
|
2560
2579
|
},
|
|
@@ -2579,17 +2598,23 @@
|
|
|
2579
2598
|
attr(input, "id", idLabel);
|
|
2580
2599
|
attr(input, "aria-label", placeholder);
|
|
2581
2600
|
attr(input, "placeholder", placeholder);
|
|
2582
|
-
attr(input, "class", input_class_value = "typein-textbox " + (
|
|
2601
|
+
attr(input, "class", input_class_value = "typein-textbox " + (!/*isFinished*/
|
|
2602
|
+
ctx[1] ? "" : (
|
|
2603
|
+
/*isResultCorrect*/
|
|
2604
|
+
ctx[2] ? "border-2 border-green-800" : "border-2 border-red-800"
|
|
2605
|
+
)));
|
|
2583
2606
|
input.disabled = /*isDataSaving*/
|
|
2584
2607
|
ctx[0];
|
|
2585
2608
|
attr(input, "autocomplete", "off");
|
|
2609
|
+
input.readOnly = /*isFinished*/
|
|
2610
|
+
ctx[1];
|
|
2586
2611
|
},
|
|
2587
2612
|
m(target, anchor) {
|
|
2588
2613
|
insert(target, input, anchor);
|
|
2589
2614
|
set_input_value(
|
|
2590
2615
|
input,
|
|
2591
2616
|
/*typeinAnswer*/
|
|
2592
|
-
ctx[
|
|
2617
|
+
ctx[3]
|
|
2593
2618
|
);
|
|
2594
2619
|
if (!mounted) {
|
|
2595
2620
|
dispose = [
|
|
@@ -2597,37 +2622,50 @@
|
|
|
2597
2622
|
input,
|
|
2598
2623
|
"input",
|
|
2599
2624
|
/*input_input_handler*/
|
|
2600
|
-
ctx[
|
|
2625
|
+
ctx[12]
|
|
2601
2626
|
),
|
|
2602
2627
|
listen(
|
|
2603
2628
|
input,
|
|
2604
2629
|
"focusout",
|
|
2605
2630
|
/*focusout_handler*/
|
|
2606
|
-
ctx[
|
|
2631
|
+
ctx[13]
|
|
2607
2632
|
),
|
|
2608
2633
|
listen(
|
|
2609
2634
|
input,
|
|
2610
2635
|
"keydown",
|
|
2611
2636
|
/*keydown_handler*/
|
|
2612
|
-
ctx[
|
|
2637
|
+
ctx[14]
|
|
2613
2638
|
)
|
|
2614
2639
|
];
|
|
2615
2640
|
mounted = true;
|
|
2616
2641
|
}
|
|
2617
2642
|
},
|
|
2618
2643
|
p(ctx2, dirty) {
|
|
2644
|
+
if (dirty & /*isFinished, isResultCorrect*/
|
|
2645
|
+
6 && input_class_value !== (input_class_value = "typein-textbox " + (!/*isFinished*/
|
|
2646
|
+
ctx2[1] ? "" : (
|
|
2647
|
+
/*isResultCorrect*/
|
|
2648
|
+
ctx2[2] ? "border-2 border-green-800" : "border-2 border-red-800"
|
|
2649
|
+
)))) {
|
|
2650
|
+
attr(input, "class", input_class_value);
|
|
2651
|
+
}
|
|
2619
2652
|
if (dirty & /*isDataSaving*/
|
|
2620
2653
|
1) {
|
|
2621
2654
|
input.disabled = /*isDataSaving*/
|
|
2622
2655
|
ctx2[0];
|
|
2623
2656
|
}
|
|
2657
|
+
if (dirty & /*isFinished*/
|
|
2658
|
+
2) {
|
|
2659
|
+
input.readOnly = /*isFinished*/
|
|
2660
|
+
ctx2[1];
|
|
2661
|
+
}
|
|
2624
2662
|
if (dirty & /*typeinAnswer*/
|
|
2625
|
-
|
|
2626
|
-
ctx2[
|
|
2663
|
+
8 && input.value !== /*typeinAnswer*/
|
|
2664
|
+
ctx2[3]) {
|
|
2627
2665
|
set_input_value(
|
|
2628
2666
|
input,
|
|
2629
2667
|
/*typeinAnswer*/
|
|
2630
|
-
ctx2[
|
|
2668
|
+
ctx2[3]
|
|
2631
2669
|
);
|
|
2632
2670
|
}
|
|
2633
2671
|
},
|
|
@@ -2645,7 +2683,7 @@
|
|
|
2645
2683
|
function select_block_type(ctx2, dirty) {
|
|
2646
2684
|
if (
|
|
2647
2685
|
/*typeinType*/
|
|
2648
|
-
ctx2[
|
|
2686
|
+
ctx2[6] === TYPEIN_TYPE_SHORT
|
|
2649
2687
|
)
|
|
2650
2688
|
return create_if_block_22;
|
|
2651
2689
|
return create_else_block_1;
|
|
@@ -2680,6 +2718,11 @@
|
|
|
2680
2718
|
let span0_class_value;
|
|
2681
2719
|
let t0;
|
|
2682
2720
|
let span1;
|
|
2721
|
+
let t1_value = (
|
|
2722
|
+
/*isResultCorrect*/
|
|
2723
|
+
ctx[2] ? "[Generic \u201Ccorrect\u201D message]" : "[Generic \u201Cincorrect\u201D message]"
|
|
2724
|
+
);
|
|
2725
|
+
let t1;
|
|
2683
2726
|
let div_class_value;
|
|
2684
2727
|
let t2;
|
|
2685
2728
|
let promptresult;
|
|
@@ -2687,7 +2730,10 @@
|
|
|
2687
2730
|
const if_block_creators = [create_if_block_14, create_else_block3];
|
|
2688
2731
|
const if_blocks = [];
|
|
2689
2732
|
function select_block_type_1(ctx2, dirty) {
|
|
2690
|
-
if (
|
|
2733
|
+
if (
|
|
2734
|
+
/*isResultCorrect*/
|
|
2735
|
+
ctx2[2]
|
|
2736
|
+
)
|
|
2691
2737
|
return 0;
|
|
2692
2738
|
return 1;
|
|
2693
2739
|
}
|
|
@@ -2695,9 +2741,15 @@
|
|
|
2695
2741
|
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
|
|
2696
2742
|
promptresult = new PromptResultFeedback_default({
|
|
2697
2743
|
props: {
|
|
2698
|
-
isResultCorrect
|
|
2699
|
-
|
|
2700
|
-
|
|
2744
|
+
isResultCorrect: (
|
|
2745
|
+
/*isResultCorrect*/
|
|
2746
|
+
ctx[2]
|
|
2747
|
+
),
|
|
2748
|
+
resultFeedbackTitle: (
|
|
2749
|
+
/*isResultCorrect*/
|
|
2750
|
+
ctx[2] ? "Well done!" : "Not quite, but you\u2019re close!"
|
|
2751
|
+
),
|
|
2752
|
+
resultFeedback: null
|
|
2701
2753
|
}
|
|
2702
2754
|
});
|
|
2703
2755
|
return {
|
|
@@ -2707,13 +2759,14 @@
|
|
|
2707
2759
|
if_block.c();
|
|
2708
2760
|
t0 = space();
|
|
2709
2761
|
span1 = element("span");
|
|
2710
|
-
|
|
2762
|
+
t1 = text(t1_value);
|
|
2711
2763
|
t2 = space();
|
|
2712
2764
|
create_component(promptresult.$$.fragment);
|
|
2713
|
-
attr(span0, "class", span0_class_value =
|
|
2765
|
+
attr(span0, "class", span0_class_value = /*isResultCorrect*/
|
|
2766
|
+
(ctx[2] ? "text-green-800" : "text-red-800") + " mr-2 p-0.5");
|
|
2714
2767
|
attr(span1, "class", "p2");
|
|
2715
2768
|
attr(div, "class", div_class_value = "flex items-center text-charcoal " + /*typeinType*/
|
|
2716
|
-
(ctx[
|
|
2769
|
+
(ctx[6] === TYPEIN_TYPE_SHORT ? "mt-2" : "mt-0.5"));
|
|
2717
2770
|
},
|
|
2718
2771
|
m(target, anchor) {
|
|
2719
2772
|
insert(target, div, anchor);
|
|
@@ -2721,11 +2774,49 @@
|
|
|
2721
2774
|
if_blocks[current_block_type_index].m(span0, null);
|
|
2722
2775
|
append(div, t0);
|
|
2723
2776
|
append(div, span1);
|
|
2777
|
+
append(span1, t1);
|
|
2724
2778
|
insert(target, t2, anchor);
|
|
2725
2779
|
mount_component(promptresult, target, anchor);
|
|
2726
2780
|
current = true;
|
|
2727
2781
|
},
|
|
2728
|
-
p
|
|
2782
|
+
p(ctx2, dirty) {
|
|
2783
|
+
let previous_block_index = current_block_type_index;
|
|
2784
|
+
current_block_type_index = select_block_type_1(ctx2, dirty);
|
|
2785
|
+
if (current_block_type_index !== previous_block_index) {
|
|
2786
|
+
group_outros();
|
|
2787
|
+
transition_out(if_blocks[previous_block_index], 1, 1, () => {
|
|
2788
|
+
if_blocks[previous_block_index] = null;
|
|
2789
|
+
});
|
|
2790
|
+
check_outros();
|
|
2791
|
+
if_block = if_blocks[current_block_type_index];
|
|
2792
|
+
if (!if_block) {
|
|
2793
|
+
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
|
|
2794
|
+
if_block.c();
|
|
2795
|
+
} else {
|
|
2796
|
+
}
|
|
2797
|
+
transition_in(if_block, 1);
|
|
2798
|
+
if_block.m(span0, null);
|
|
2799
|
+
}
|
|
2800
|
+
if (!current || dirty & /*isResultCorrect*/
|
|
2801
|
+
4 && span0_class_value !== (span0_class_value = /*isResultCorrect*/
|
|
2802
|
+
(ctx2[2] ? "text-green-800" : "text-red-800") + " mr-2 p-0.5")) {
|
|
2803
|
+
attr(span0, "class", span0_class_value);
|
|
2804
|
+
}
|
|
2805
|
+
if ((!current || dirty & /*isResultCorrect*/
|
|
2806
|
+
4) && t1_value !== (t1_value = /*isResultCorrect*/
|
|
2807
|
+
ctx2[2] ? "[Generic \u201Ccorrect\u201D message]" : "[Generic \u201Cincorrect\u201D message]"))
|
|
2808
|
+
set_data(t1, t1_value);
|
|
2809
|
+
const promptresult_changes = {};
|
|
2810
|
+
if (dirty & /*isResultCorrect*/
|
|
2811
|
+
4)
|
|
2812
|
+
promptresult_changes.isResultCorrect = /*isResultCorrect*/
|
|
2813
|
+
ctx2[2];
|
|
2814
|
+
if (dirty & /*isResultCorrect*/
|
|
2815
|
+
4)
|
|
2816
|
+
promptresult_changes.resultFeedbackTitle = /*isResultCorrect*/
|
|
2817
|
+
ctx2[2] ? "Well done!" : "Not quite, but you\u2019re close!";
|
|
2818
|
+
promptresult.$set(promptresult_changes);
|
|
2819
|
+
},
|
|
2729
2820
|
i(local) {
|
|
2730
2821
|
if (current)
|
|
2731
2822
|
return;
|
|
@@ -2811,17 +2902,20 @@
|
|
|
2811
2902
|
props: {
|
|
2812
2903
|
rubric: (
|
|
2813
2904
|
/*rubric*/
|
|
2814
|
-
ctx[
|
|
2905
|
+
ctx[4].text
|
|
2815
2906
|
),
|
|
2816
2907
|
prompt: (
|
|
2817
2908
|
/*prompt*/
|
|
2818
|
-
ctx[
|
|
2909
|
+
ctx[5]
|
|
2819
2910
|
),
|
|
2820
2911
|
$$slots: { default: [create_default_slot2] },
|
|
2821
2912
|
$$scope: { ctx }
|
|
2822
2913
|
}
|
|
2823
2914
|
});
|
|
2824
|
-
let if_block =
|
|
2915
|
+
let if_block = (
|
|
2916
|
+
/*isFinished*/
|
|
2917
|
+
ctx[1] && create_if_block4(ctx)
|
|
2918
|
+
);
|
|
2825
2919
|
return {
|
|
2826
2920
|
c() {
|
|
2827
2921
|
create_component(promptbody.$$.fragment);
|
|
@@ -2840,13 +2934,34 @@
|
|
|
2840
2934
|
},
|
|
2841
2935
|
p(ctx2, [dirty]) {
|
|
2842
2936
|
const promptbody_changes = {};
|
|
2843
|
-
if (dirty & /*$$scope, isDataSaving, typeinAnswer*/
|
|
2844
|
-
|
|
2937
|
+
if (dirty & /*$$scope, isFinished, isResultCorrect, isDataSaving, typeinAnswer*/
|
|
2938
|
+
67108879) {
|
|
2845
2939
|
promptbody_changes.$$scope = { dirty, ctx: ctx2 };
|
|
2846
2940
|
}
|
|
2847
2941
|
promptbody.$set(promptbody_changes);
|
|
2848
|
-
if (
|
|
2849
|
-
|
|
2942
|
+
if (
|
|
2943
|
+
/*isFinished*/
|
|
2944
|
+
ctx2[1]
|
|
2945
|
+
) {
|
|
2946
|
+
if (if_block) {
|
|
2947
|
+
if_block.p(ctx2, dirty);
|
|
2948
|
+
if (dirty & /*isFinished*/
|
|
2949
|
+
2) {
|
|
2950
|
+
transition_in(if_block, 1);
|
|
2951
|
+
}
|
|
2952
|
+
} else {
|
|
2953
|
+
if_block = create_if_block4(ctx2);
|
|
2954
|
+
if_block.c();
|
|
2955
|
+
transition_in(if_block, 1);
|
|
2956
|
+
if_block.m(if_block_anchor.parentNode, if_block_anchor);
|
|
2957
|
+
}
|
|
2958
|
+
} else if (if_block) {
|
|
2959
|
+
group_outros();
|
|
2960
|
+
transition_out(if_block, 1, 1, () => {
|
|
2961
|
+
if_block = null;
|
|
2962
|
+
});
|
|
2963
|
+
check_outros();
|
|
2964
|
+
}
|
|
2850
2965
|
},
|
|
2851
2966
|
i(local) {
|
|
2852
2967
|
if (current)
|
|
@@ -2873,11 +2988,11 @@
|
|
|
2873
2988
|
}
|
|
2874
2989
|
var idLabel = "answerText";
|
|
2875
2990
|
var placeholder = "Type your answer here";
|
|
2876
|
-
var isFinished = false;
|
|
2877
|
-
var isResultCorrect = false;
|
|
2878
2991
|
function instance4($$self, $$props, $$invalidate) {
|
|
2879
2992
|
let { sessionData } = $$props;
|
|
2880
2993
|
let { isDataSaving } = $$props;
|
|
2994
|
+
let { isFinished = false } = $$props;
|
|
2995
|
+
let { isResultCorrect = false } = $$props;
|
|
2881
2996
|
const dispatch = createEventDispatcher();
|
|
2882
2997
|
let typeinAnswer;
|
|
2883
2998
|
let latestAnswer = "";
|
|
@@ -2913,13 +3028,13 @@
|
|
|
2913
3028
|
};
|
|
2914
3029
|
function input_input_handler() {
|
|
2915
3030
|
typeinAnswer = this.value;
|
|
2916
|
-
$$invalidate(
|
|
3031
|
+
$$invalidate(3, typeinAnswer);
|
|
2917
3032
|
}
|
|
2918
3033
|
const focusout_handler = () => saveAnswer();
|
|
2919
3034
|
const keydown_handler = (event) => saveOnEnter(event);
|
|
2920
3035
|
function textarea_input_handler() {
|
|
2921
3036
|
typeinAnswer = this.value;
|
|
2922
|
-
$$invalidate(
|
|
3037
|
+
$$invalidate(3, typeinAnswer);
|
|
2923
3038
|
}
|
|
2924
3039
|
const mousedown_handler = () => handleClick();
|
|
2925
3040
|
const touchstart_handler = () => handleClick();
|
|
@@ -2928,12 +3043,18 @@
|
|
|
2928
3043
|
const keydown_handler_1 = (event) => saveOnEnter(event);
|
|
2929
3044
|
$$self.$$set = ($$props2) => {
|
|
2930
3045
|
if ("sessionData" in $$props2)
|
|
2931
|
-
$$invalidate(
|
|
3046
|
+
$$invalidate(11, sessionData = $$props2.sessionData);
|
|
2932
3047
|
if ("isDataSaving" in $$props2)
|
|
2933
3048
|
$$invalidate(0, isDataSaving = $$props2.isDataSaving);
|
|
3049
|
+
if ("isFinished" in $$props2)
|
|
3050
|
+
$$invalidate(1, isFinished = $$props2.isFinished);
|
|
3051
|
+
if ("isResultCorrect" in $$props2)
|
|
3052
|
+
$$invalidate(2, isResultCorrect = $$props2.isResultCorrect);
|
|
2934
3053
|
};
|
|
2935
3054
|
return [
|
|
2936
3055
|
isDataSaving,
|
|
3056
|
+
isFinished,
|
|
3057
|
+
isResultCorrect,
|
|
2937
3058
|
typeinAnswer,
|
|
2938
3059
|
rubric,
|
|
2939
3060
|
prompt,
|
|
@@ -2957,10 +3078,15 @@
|
|
|
2957
3078
|
var PromptTypeIn = class extends SvelteComponent {
|
|
2958
3079
|
constructor(options) {
|
|
2959
3080
|
super();
|
|
2960
|
-
init(this, options, instance4, create_fragment7, safe_not_equal, {
|
|
3081
|
+
init(this, options, instance4, create_fragment7, safe_not_equal, {
|
|
3082
|
+
sessionData: 11,
|
|
3083
|
+
isDataSaving: 0,
|
|
3084
|
+
isFinished: 1,
|
|
3085
|
+
isResultCorrect: 2
|
|
3086
|
+
});
|
|
2961
3087
|
}
|
|
2962
3088
|
get sessionData() {
|
|
2963
|
-
return this.$$.ctx[
|
|
3089
|
+
return this.$$.ctx[11];
|
|
2964
3090
|
}
|
|
2965
3091
|
set sessionData(sessionData) {
|
|
2966
3092
|
this.$$set({ sessionData });
|
|
@@ -2973,8 +3099,22 @@
|
|
|
2973
3099
|
this.$$set({ isDataSaving });
|
|
2974
3100
|
flush();
|
|
2975
3101
|
}
|
|
3102
|
+
get isFinished() {
|
|
3103
|
+
return this.$$.ctx[1];
|
|
3104
|
+
}
|
|
3105
|
+
set isFinished(isFinished) {
|
|
3106
|
+
this.$$set({ isFinished });
|
|
3107
|
+
flush();
|
|
3108
|
+
}
|
|
3109
|
+
get isResultCorrect() {
|
|
3110
|
+
return this.$$.ctx[2];
|
|
3111
|
+
}
|
|
3112
|
+
set isResultCorrect(isResultCorrect) {
|
|
3113
|
+
this.$$set({ isResultCorrect });
|
|
3114
|
+
flush();
|
|
3115
|
+
}
|
|
2976
3116
|
};
|
|
2977
|
-
customElements.define("prompt-typein", create_custom_element(PromptTypeIn, { "sessionData": {}, "isDataSaving": {} }, [], [], true));
|
|
3117
|
+
customElements.define("prompt-typein", create_custom_element(PromptTypeIn, { "sessionData": {}, "isDataSaving": {}, "isFinished": { "type": "Boolean" }, "isResultCorrect": { "type": "Boolean" } }, [], [], true));
|
|
2978
3118
|
var PromptTypeIn_default = PromptTypeIn;
|
|
2979
3119
|
|
|
2980
3120
|
// src/lib/components/prompt/skeleton/PromptSkeleton.svelte
|
|
@@ -3238,6 +3378,14 @@
|
|
|
3238
3378
|
isDataSaving: (
|
|
3239
3379
|
/*isDataSaving*/
|
|
3240
3380
|
ctx[2]
|
|
3381
|
+
),
|
|
3382
|
+
isFinished: (
|
|
3383
|
+
/*isFinished*/
|
|
3384
|
+
ctx[4]
|
|
3385
|
+
),
|
|
3386
|
+
isResultCorrect: (
|
|
3387
|
+
/*isResultCorrect*/
|
|
3388
|
+
ctx[5]
|
|
3241
3389
|
)
|
|
3242
3390
|
}
|
|
3243
3391
|
});
|
|
@@ -3264,6 +3412,14 @@
|
|
|
3264
3412
|
4)
|
|
3265
3413
|
prompttypein_changes.isDataSaving = /*isDataSaving*/
|
|
3266
3414
|
ctx2[2];
|
|
3415
|
+
if (dirty & /*isFinished*/
|
|
3416
|
+
16)
|
|
3417
|
+
prompttypein_changes.isFinished = /*isFinished*/
|
|
3418
|
+
ctx2[4];
|
|
3419
|
+
if (dirty & /*isResultCorrect*/
|
|
3420
|
+
32)
|
|
3421
|
+
prompttypein_changes.isResultCorrect = /*isResultCorrect*/
|
|
3422
|
+
ctx2[5];
|
|
3267
3423
|
prompttypein.$set(prompttypein_changes);
|
|
3268
3424
|
},
|
|
3269
3425
|
i(local) {
|
|
@@ -3426,38 +3582,42 @@
|
|
|
3426
3582
|
}
|
|
3427
3583
|
var bannerLabel = "Invalid session id.";
|
|
3428
3584
|
function instance6($$self, $$props, $$invalidate) {
|
|
3429
|
-
const { "session-id": sessionId } = $$props;
|
|
3585
|
+
const { "session-id": sessionId, "preview-mode": previewMode, "item-id": itemId } = $$props;
|
|
3586
|
+
const isPreviewMode = previewMode === "true" && itemId;
|
|
3430
3587
|
useSetupAPI();
|
|
3431
3588
|
let sessionData;
|
|
3432
3589
|
let isDataFetching = true;
|
|
3433
3590
|
let isDataSaving = false;
|
|
3434
3591
|
let interactionType = null;
|
|
3435
|
-
let
|
|
3592
|
+
let isFinished = false;
|
|
3436
3593
|
let isLocked = false;
|
|
3437
|
-
let
|
|
3594
|
+
let isResultCorrect = false;
|
|
3438
3595
|
const skipUserValidationStr = get_store_value(skipUserValidation) ? "?skip_user_validation=true" : "";
|
|
3439
3596
|
const getSessionData = async (sessionId2) => {
|
|
3440
3597
|
try {
|
|
3441
3598
|
const { data } = await useGet(`sessions/${sessionId2}${skipUserValidationStr}`);
|
|
3442
|
-
const { item_id:
|
|
3599
|
+
const { item_id: itemId2, metadata, is_finished: isSessionFinished, is_locked: isSessionLocked } = data;
|
|
3443
3600
|
isLocked = isSessionLocked;
|
|
3444
|
-
$$invalidate(4,
|
|
3445
|
-
if (
|
|
3446
|
-
await getItemData(
|
|
3601
|
+
$$invalidate(4, isFinished = isSessionFinished);
|
|
3602
|
+
if (itemId2) {
|
|
3603
|
+
await getItemData(itemId2, metadata);
|
|
3447
3604
|
}
|
|
3448
3605
|
} catch (error) {
|
|
3449
3606
|
$$invalidate(1, isDataFetching = false);
|
|
3450
3607
|
}
|
|
3451
3608
|
};
|
|
3452
|
-
const getItemData = async (
|
|
3609
|
+
const getItemData = async (itemId2, metadata) => {
|
|
3453
3610
|
try {
|
|
3454
|
-
const includeAnswer =
|
|
3455
|
-
const { data } = await useGet(`items/${
|
|
3611
|
+
const includeAnswer = isFinished && isLocked ? "?include=[correct_answer]" : "";
|
|
3612
|
+
const { data } = await useGet(`items/${itemId2}${includeAnswer}`);
|
|
3456
3613
|
$$invalidate(3, interactionType = getInteractionType(data));
|
|
3457
3614
|
$$invalidate(0, sessionData = { ...data, metadata });
|
|
3458
|
-
if (
|
|
3615
|
+
if (isFinished && isLocked && !isPreviewMode) {
|
|
3459
3616
|
await getSessionScore();
|
|
3460
3617
|
}
|
|
3618
|
+
if (isPreviewMode) {
|
|
3619
|
+
setPreviewData(data);
|
|
3620
|
+
}
|
|
3461
3621
|
} catch (error) {
|
|
3462
3622
|
} finally {
|
|
3463
3623
|
$$invalidate(1, isDataFetching = false);
|
|
@@ -3485,15 +3645,44 @@
|
|
|
3485
3645
|
correctAnswerId: metadata.correctAnswerId[0]
|
|
3486
3646
|
};
|
|
3487
3647
|
$$invalidate(0, sessionData = { ...sessionData, scoringMetadata });
|
|
3488
|
-
$$invalidate(5,
|
|
3648
|
+
$$invalidate(5, isResultCorrect = scoring.score_earned);
|
|
3489
3649
|
}
|
|
3490
3650
|
} catch (error) {
|
|
3491
3651
|
} finally {
|
|
3492
3652
|
$$invalidate(1, isDataFetching = false);
|
|
3493
3653
|
}
|
|
3494
3654
|
};
|
|
3655
|
+
const getPreviewData = async (itemId2) => {
|
|
3656
|
+
await getItemData(itemId2, null);
|
|
3657
|
+
};
|
|
3658
|
+
const setPreviewData = (data) => {
|
|
3659
|
+
switch (interactionType) {
|
|
3660
|
+
case INTERACTION_TYPE_MCQ:
|
|
3661
|
+
const { options } = data.interaction;
|
|
3662
|
+
const answerId = Object.values(options).filter((option) => option.correct_choice === true).map((option) => option.id);
|
|
3663
|
+
const scoringMetadata = {
|
|
3664
|
+
hasAnswer: true,
|
|
3665
|
+
answerId: answerId[0],
|
|
3666
|
+
correctAnswerId: answerId[0]
|
|
3667
|
+
};
|
|
3668
|
+
$$invalidate(0, sessionData = { ...sessionData, scoringMetadata });
|
|
3669
|
+
case INTERACTION_TYPE_TYPEIN:
|
|
3670
|
+
default:
|
|
3671
|
+
const { correct_answer: correctAnswer, typein_type: typeinType } = data.interaction;
|
|
3672
|
+
const metadata = {
|
|
3673
|
+
interactions: {
|
|
3674
|
+
events: [
|
|
3675
|
+
{
|
|
3676
|
+
answer: typeinType === TYPEIN_TYPE_SHORT ? correctAnswer[0] : correctAnswer[0].answer[0]
|
|
3677
|
+
}
|
|
3678
|
+
]
|
|
3679
|
+
}
|
|
3680
|
+
};
|
|
3681
|
+
$$invalidate(0, sessionData = { ...sessionData, metadata });
|
|
3682
|
+
}
|
|
3683
|
+
};
|
|
3495
3684
|
const saveEvent = async ({ detail }) => {
|
|
3496
|
-
if (isLocked ||
|
|
3685
|
+
if (isLocked || isFinished)
|
|
3497
3686
|
return;
|
|
3498
3687
|
try {
|
|
3499
3688
|
$$invalidate(2, isDataSaving = true);
|
|
@@ -3504,11 +3693,17 @@
|
|
|
3504
3693
|
$$invalidate(2, isDataSaving = false);
|
|
3505
3694
|
}
|
|
3506
3695
|
};
|
|
3507
|
-
if (
|
|
3696
|
+
if (isPreviewMode) {
|
|
3697
|
+
isFinished = true;
|
|
3698
|
+
isLocked = true;
|
|
3699
|
+
isResultCorrect = true;
|
|
3700
|
+
getPreviewData(itemId);
|
|
3701
|
+
}
|
|
3702
|
+
if (sessionId && !isPreviewMode) {
|
|
3508
3703
|
getSessionData(sessionId);
|
|
3509
3704
|
}
|
|
3510
3705
|
$$self.$$set = ($$new_props) => {
|
|
3511
|
-
$$invalidate(
|
|
3706
|
+
$$invalidate(19, $$props = assign(assign({}, $$props), exclude_internal_props($$new_props)));
|
|
3512
3707
|
};
|
|
3513
3708
|
$$props = exclude_internal_props($$props);
|
|
3514
3709
|
return [
|
|
@@ -3516,8 +3711,8 @@
|
|
|
3516
3711
|
isDataFetching,
|
|
3517
3712
|
isDataSaving,
|
|
3518
3713
|
interactionType,
|
|
3519
|
-
|
|
3520
|
-
|
|
3714
|
+
isFinished,
|
|
3715
|
+
isResultCorrect,
|
|
3521
3716
|
saveEvent
|
|
3522
3717
|
];
|
|
3523
3718
|
}
|