eat-js-sdk 0.0.20 → 0.0.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/eat-prompt-builder.mjs +86 -51
- package/package.json +1 -1
|
@@ -2431,38 +2431,38 @@
|
|
|
2431
2431
|
textarea,
|
|
2432
2432
|
"input",
|
|
2433
2433
|
/*textarea_input_handler*/
|
|
2434
|
-
ctx[
|
|
2434
|
+
ctx[18]
|
|
2435
2435
|
),
|
|
2436
2436
|
listen(
|
|
2437
2437
|
textarea,
|
|
2438
2438
|
"mousedown",
|
|
2439
2439
|
/*mousedown_handler*/
|
|
2440
|
-
ctx[
|
|
2440
|
+
ctx[19]
|
|
2441
2441
|
),
|
|
2442
2442
|
listen(
|
|
2443
2443
|
textarea,
|
|
2444
2444
|
"touchstart",
|
|
2445
2445
|
/*touchstart_handler*/
|
|
2446
|
-
ctx[
|
|
2446
|
+
ctx[20],
|
|
2447
2447
|
{ passive: true }
|
|
2448
2448
|
),
|
|
2449
2449
|
listen(
|
|
2450
2450
|
textarea,
|
|
2451
2451
|
"focus",
|
|
2452
2452
|
/*focus_handler*/
|
|
2453
|
-
ctx[
|
|
2453
|
+
ctx[21]
|
|
2454
2454
|
),
|
|
2455
2455
|
listen(
|
|
2456
2456
|
textarea,
|
|
2457
2457
|
"focusout",
|
|
2458
2458
|
/*focusout_handler_1*/
|
|
2459
|
-
ctx[
|
|
2459
|
+
ctx[22]
|
|
2460
2460
|
),
|
|
2461
2461
|
listen(
|
|
2462
2462
|
textarea,
|
|
2463
2463
|
"keydown",
|
|
2464
2464
|
/*keydown_handler_1*/
|
|
2465
|
-
ctx[
|
|
2465
|
+
ctx[23]
|
|
2466
2466
|
),
|
|
2467
2467
|
action_destroyer(autosize_action = svelte_autosize_default.call(null, textarea))
|
|
2468
2468
|
];
|
|
@@ -2542,19 +2542,19 @@
|
|
|
2542
2542
|
input,
|
|
2543
2543
|
"input",
|
|
2544
2544
|
/*input_input_handler*/
|
|
2545
|
-
ctx[
|
|
2545
|
+
ctx[15]
|
|
2546
2546
|
),
|
|
2547
2547
|
listen(
|
|
2548
2548
|
input,
|
|
2549
2549
|
"focusout",
|
|
2550
2550
|
/*focusout_handler*/
|
|
2551
|
-
ctx[
|
|
2551
|
+
ctx[16]
|
|
2552
2552
|
),
|
|
2553
2553
|
listen(
|
|
2554
2554
|
input,
|
|
2555
2555
|
"keydown",
|
|
2556
2556
|
/*keydown_handler*/
|
|
2557
|
-
ctx[
|
|
2557
|
+
ctx[17]
|
|
2558
2558
|
)
|
|
2559
2559
|
];
|
|
2560
2560
|
mounted = true;
|
|
@@ -2603,7 +2603,7 @@
|
|
|
2603
2603
|
function select_block_type(ctx2, dirty) {
|
|
2604
2604
|
if (
|
|
2605
2605
|
/*typeinType*/
|
|
2606
|
-
ctx2[
|
|
2606
|
+
ctx2[8] === TYPEIN_TYPE_SHORT
|
|
2607
2607
|
)
|
|
2608
2608
|
return create_if_block_22;
|
|
2609
2609
|
return create_else_block_1;
|
|
@@ -2666,10 +2666,13 @@
|
|
|
2666
2666
|
ctx[2]
|
|
2667
2667
|
),
|
|
2668
2668
|
resultFeedbackTitle: (
|
|
2669
|
-
/*
|
|
2670
|
-
ctx[
|
|
2669
|
+
/*resultFeedbackTitle*/
|
|
2670
|
+
ctx[4]
|
|
2671
2671
|
),
|
|
2672
|
-
resultFeedback:
|
|
2672
|
+
resultFeedback: (
|
|
2673
|
+
/*resultFeedback*/
|
|
2674
|
+
ctx[5]
|
|
2675
|
+
)
|
|
2673
2676
|
}
|
|
2674
2677
|
});
|
|
2675
2678
|
return {
|
|
@@ -2686,7 +2689,7 @@
|
|
|
2686
2689
|
(ctx[2] ? "text-green-800" : "text-red-800") + " mr-2 p-0.5");
|
|
2687
2690
|
attr(span1, "class", "p2");
|
|
2688
2691
|
attr(div, "class", div_class_value = "flex items-center text-charcoal " + /*typeinType*/
|
|
2689
|
-
(ctx[
|
|
2692
|
+
(ctx[8] === TYPEIN_TYPE_SHORT ? "mt-2" : "mt-0.5"));
|
|
2690
2693
|
},
|
|
2691
2694
|
m(target, anchor) {
|
|
2692
2695
|
insert(target, div, anchor);
|
|
@@ -2731,10 +2734,14 @@
|
|
|
2731
2734
|
4)
|
|
2732
2735
|
promptresult_changes.isResultCorrect = /*isResultCorrect*/
|
|
2733
2736
|
ctx2[2];
|
|
2734
|
-
if (dirty & /*
|
|
2735
|
-
|
|
2736
|
-
promptresult_changes.resultFeedbackTitle = /*
|
|
2737
|
-
ctx2[
|
|
2737
|
+
if (dirty & /*resultFeedbackTitle*/
|
|
2738
|
+
16)
|
|
2739
|
+
promptresult_changes.resultFeedbackTitle = /*resultFeedbackTitle*/
|
|
2740
|
+
ctx2[4];
|
|
2741
|
+
if (dirty & /*resultFeedback*/
|
|
2742
|
+
32)
|
|
2743
|
+
promptresult_changes.resultFeedback = /*resultFeedback*/
|
|
2744
|
+
ctx2[5];
|
|
2738
2745
|
promptresult.$set(promptresult_changes);
|
|
2739
2746
|
},
|
|
2740
2747
|
i(local) {
|
|
@@ -2822,11 +2829,11 @@
|
|
|
2822
2829
|
props: {
|
|
2823
2830
|
rubric: (
|
|
2824
2831
|
/*rubric*/
|
|
2825
|
-
ctx[
|
|
2832
|
+
ctx[6].text
|
|
2826
2833
|
),
|
|
2827
2834
|
prompt: (
|
|
2828
2835
|
/*prompt*/
|
|
2829
|
-
ctx[
|
|
2836
|
+
ctx[7]
|
|
2830
2837
|
),
|
|
2831
2838
|
$$slots: { default: [create_default_slot2] },
|
|
2832
2839
|
$$scope: { ctx }
|
|
@@ -2855,7 +2862,7 @@
|
|
|
2855
2862
|
p(ctx2, [dirty]) {
|
|
2856
2863
|
const promptbody_changes = {};
|
|
2857
2864
|
if (dirty & /*$$scope, isFinished, isResultCorrect, isDataSaving, typeinAnswer*/
|
|
2858
|
-
|
|
2865
|
+
1073741839) {
|
|
2859
2866
|
promptbody_changes.$$scope = { dirty, ctx: ctx2 };
|
|
2860
2867
|
}
|
|
2861
2868
|
promptbody.$set(promptbody_changes);
|
|
@@ -2913,22 +2920,35 @@
|
|
|
2913
2920
|
let { isDataSaving } = $$props;
|
|
2914
2921
|
let { isFinished = false } = $$props;
|
|
2915
2922
|
let { isResultCorrect = false } = $$props;
|
|
2923
|
+
let { isPreviewMode = false } = $$props;
|
|
2916
2924
|
const dispatch = createEventDispatcher();
|
|
2917
2925
|
let typeinAnswer;
|
|
2918
2926
|
let latestAnswer = "";
|
|
2927
|
+
let resultFeedbackTitle = "";
|
|
2928
|
+
let resultFeedback = "";
|
|
2919
2929
|
let focusOrigin = "tab";
|
|
2920
|
-
const { rubric, interaction, metadata } = sessionData;
|
|
2930
|
+
const { rubric, interaction, metadata, scoringMetadata } = sessionData;
|
|
2921
2931
|
const { prompt, typein_type: typeinType } = interaction;
|
|
2922
2932
|
if (metadata) {
|
|
2923
2933
|
const events = metadata.interactions.events.pop();
|
|
2924
|
-
latestAnswer = typeinAnswer = events.answer;
|
|
2934
|
+
latestAnswer = typeinAnswer = events.answer[0];
|
|
2935
|
+
}
|
|
2936
|
+
if (isFinished) {
|
|
2937
|
+
const { answer, hasAnswer } = scoringMetadata;
|
|
2938
|
+
typeinAnswer = answer && hasAnswer ? answer : typeinAnswer;
|
|
2939
|
+
if (!isPreviewMode) {
|
|
2940
|
+
const { correct: correctFeeback, incorrect: incorrectFeedback } = interaction.feedback;
|
|
2941
|
+
const { header, text: text2 } = isResultCorrect ? correctFeeback : incorrectFeedback;
|
|
2942
|
+
resultFeedbackTitle = header;
|
|
2943
|
+
resultFeedback = text2;
|
|
2944
|
+
}
|
|
2925
2945
|
}
|
|
2926
2946
|
const saveAnswer = () => {
|
|
2927
2947
|
focusOrigin = "tab";
|
|
2928
2948
|
if (isDataSaving || typeinAnswer === latestAnswer || !typeinAnswer && !latestAnswer)
|
|
2929
2949
|
return;
|
|
2930
2950
|
latestAnswer = typeinAnswer;
|
|
2931
|
-
dispatch("saveAnswer", { answer: typeinAnswer || "" });
|
|
2951
|
+
dispatch("saveAnswer", { answer: [typeinAnswer || ""] });
|
|
2932
2952
|
};
|
|
2933
2953
|
const saveOnEnter = (event) => {
|
|
2934
2954
|
if (event.key === "Enter") {
|
|
@@ -2963,19 +2983,23 @@
|
|
|
2963
2983
|
const keydown_handler_1 = (event) => saveOnEnter(event);
|
|
2964
2984
|
$$self.$$set = ($$props2) => {
|
|
2965
2985
|
if ("sessionData" in $$props2)
|
|
2966
|
-
$$invalidate(
|
|
2986
|
+
$$invalidate(13, sessionData = $$props2.sessionData);
|
|
2967
2987
|
if ("isDataSaving" in $$props2)
|
|
2968
2988
|
$$invalidate(0, isDataSaving = $$props2.isDataSaving);
|
|
2969
2989
|
if ("isFinished" in $$props2)
|
|
2970
2990
|
$$invalidate(1, isFinished = $$props2.isFinished);
|
|
2971
2991
|
if ("isResultCorrect" in $$props2)
|
|
2972
2992
|
$$invalidate(2, isResultCorrect = $$props2.isResultCorrect);
|
|
2993
|
+
if ("isPreviewMode" in $$props2)
|
|
2994
|
+
$$invalidate(14, isPreviewMode = $$props2.isPreviewMode);
|
|
2973
2995
|
};
|
|
2974
2996
|
return [
|
|
2975
2997
|
isDataSaving,
|
|
2976
2998
|
isFinished,
|
|
2977
2999
|
isResultCorrect,
|
|
2978
3000
|
typeinAnswer,
|
|
3001
|
+
resultFeedbackTitle,
|
|
3002
|
+
resultFeedback,
|
|
2979
3003
|
rubric,
|
|
2980
3004
|
prompt,
|
|
2981
3005
|
typeinType,
|
|
@@ -2984,6 +3008,7 @@
|
|
|
2984
3008
|
handleFocus,
|
|
2985
3009
|
handleClick,
|
|
2986
3010
|
sessionData,
|
|
3011
|
+
isPreviewMode,
|
|
2987
3012
|
input_input_handler,
|
|
2988
3013
|
focusout_handler,
|
|
2989
3014
|
keydown_handler,
|
|
@@ -2999,14 +3024,15 @@
|
|
|
2999
3024
|
constructor(options) {
|
|
3000
3025
|
super();
|
|
3001
3026
|
init(this, options, instance4, create_fragment6, safe_not_equal, {
|
|
3002
|
-
sessionData:
|
|
3027
|
+
sessionData: 13,
|
|
3003
3028
|
isDataSaving: 0,
|
|
3004
3029
|
isFinished: 1,
|
|
3005
|
-
isResultCorrect: 2
|
|
3030
|
+
isResultCorrect: 2,
|
|
3031
|
+
isPreviewMode: 14
|
|
3006
3032
|
});
|
|
3007
3033
|
}
|
|
3008
3034
|
get sessionData() {
|
|
3009
|
-
return this.$$.ctx[
|
|
3035
|
+
return this.$$.ctx[13];
|
|
3010
3036
|
}
|
|
3011
3037
|
set sessionData(sessionData) {
|
|
3012
3038
|
this.$$set({ sessionData });
|
|
@@ -3033,8 +3059,15 @@
|
|
|
3033
3059
|
this.$$set({ isResultCorrect });
|
|
3034
3060
|
flush();
|
|
3035
3061
|
}
|
|
3062
|
+
get isPreviewMode() {
|
|
3063
|
+
return this.$$.ctx[14];
|
|
3064
|
+
}
|
|
3065
|
+
set isPreviewMode(isPreviewMode) {
|
|
3066
|
+
this.$$set({ isPreviewMode });
|
|
3067
|
+
flush();
|
|
3068
|
+
}
|
|
3036
3069
|
};
|
|
3037
|
-
customElements.define("prompt-typein", create_custom_element(PromptTypeIn, { "sessionData": {}, "isDataSaving": {}, "isFinished": { "type": "Boolean" }, "isResultCorrect": { "type": "Boolean" } }, [], [], true));
|
|
3070
|
+
customElements.define("prompt-typein", create_custom_element(PromptTypeIn, { "sessionData": {}, "isDataSaving": {}, "isFinished": { "type": "Boolean" }, "isResultCorrect": { "type": "Boolean" }, "isPreviewMode": { "type": "Boolean" } }, [], [], true));
|
|
3038
3071
|
var PromptTypeIn_default = PromptTypeIn;
|
|
3039
3072
|
|
|
3040
3073
|
// src/lib/components/prompt/skeleton/PromptSkeleton.svelte
|
|
@@ -3306,13 +3339,17 @@
|
|
|
3306
3339
|
isResultCorrect: (
|
|
3307
3340
|
/*isResultCorrect*/
|
|
3308
3341
|
ctx[5]
|
|
3342
|
+
),
|
|
3343
|
+
isPreviewMode: (
|
|
3344
|
+
/*isPreviewMode*/
|
|
3345
|
+
ctx[6]
|
|
3309
3346
|
)
|
|
3310
3347
|
}
|
|
3311
3348
|
});
|
|
3312
3349
|
prompttypein.$on(
|
|
3313
3350
|
"saveAnswer",
|
|
3314
3351
|
/*saveEvent*/
|
|
3315
|
-
ctx[
|
|
3352
|
+
ctx[7]
|
|
3316
3353
|
);
|
|
3317
3354
|
return {
|
|
3318
3355
|
c() {
|
|
@@ -3383,7 +3420,7 @@
|
|
|
3383
3420
|
promptmcq.$on(
|
|
3384
3421
|
"saveOption",
|
|
3385
3422
|
/*saveEvent*/
|
|
3386
|
-
ctx[
|
|
3423
|
+
ctx[7]
|
|
3387
3424
|
);
|
|
3388
3425
|
return {
|
|
3389
3426
|
c() {
|
|
@@ -3558,12 +3595,17 @@
|
|
|
3558
3595
|
try {
|
|
3559
3596
|
const { data } = await useGet(`sessions/${sessionId}/score`);
|
|
3560
3597
|
if (data) {
|
|
3561
|
-
const { metadata,
|
|
3562
|
-
const
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3598
|
+
const { metadata, scoring } = data[0];
|
|
3599
|
+
const { answer, has_answer: hasAnswer } = metadata;
|
|
3600
|
+
let scoringMetadata = { hasAnswer };
|
|
3601
|
+
switch (interactionType) {
|
|
3602
|
+
case INTERACTION_TYPE_MCQ:
|
|
3603
|
+
scoringMetadata = { ...scoringMetadata, answerId: answer[0] };
|
|
3604
|
+
break;
|
|
3605
|
+
case INTERACTION_TYPE_TYPEIN:
|
|
3606
|
+
default:
|
|
3607
|
+
scoringMetadata = { ...scoringMetadata, answer: answer[0] };
|
|
3608
|
+
}
|
|
3567
3609
|
$$invalidate(0, sessionData = { ...sessionData, scoringMetadata });
|
|
3568
3610
|
$$invalidate(5, isResultCorrect = scoring.score_earned);
|
|
3569
3611
|
}
|
|
@@ -3576,29 +3618,21 @@
|
|
|
3576
3618
|
await getItemData(itemId2, null);
|
|
3577
3619
|
};
|
|
3578
3620
|
const setPreviewData = (data) => {
|
|
3621
|
+
let scoringMetadata;
|
|
3579
3622
|
switch (interactionType) {
|
|
3580
3623
|
case INTERACTION_TYPE_MCQ:
|
|
3581
3624
|
const { options } = data.interaction;
|
|
3582
3625
|
const answerId = Object.values(options).filter((option) => option.correct_choice === true).map((option) => option.id);
|
|
3583
|
-
|
|
3584
|
-
hasAnswer: true,
|
|
3585
|
-
answerId: answerId[0],
|
|
3586
|
-
correctAnswerId: answerId[0]
|
|
3587
|
-
};
|
|
3626
|
+
scoringMetadata = { hasAnswer: true, answerId: answerId[0] };
|
|
3588
3627
|
$$invalidate(0, sessionData = { ...sessionData, scoringMetadata });
|
|
3589
3628
|
case INTERACTION_TYPE_TYPEIN:
|
|
3590
3629
|
default:
|
|
3591
3630
|
const { correct_answer: correctAnswer, typein_type: typeinType } = data.interaction;
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
{
|
|
3596
|
-
answer: typeinType === TYPEIN_TYPE_SHORT ? correctAnswer[0] : correctAnswer[0].answer[0]
|
|
3597
|
-
}
|
|
3598
|
-
]
|
|
3599
|
-
}
|
|
3631
|
+
scoringMetadata = {
|
|
3632
|
+
hasAnswer: true,
|
|
3633
|
+
answer: typeinType === TYPEIN_TYPE_SHORT ? correctAnswer[0][0] : correctAnswer[0].answer[0]
|
|
3600
3634
|
};
|
|
3601
|
-
$$invalidate(0, sessionData = { ...sessionData,
|
|
3635
|
+
$$invalidate(0, sessionData = { ...sessionData, scoringMetadata });
|
|
3602
3636
|
}
|
|
3603
3637
|
};
|
|
3604
3638
|
const saveEvent = async ({ detail }) => {
|
|
@@ -3633,6 +3667,7 @@
|
|
|
3633
3667
|
interactionType,
|
|
3634
3668
|
isFinished,
|
|
3635
3669
|
isResultCorrect,
|
|
3670
|
+
isPreviewMode,
|
|
3636
3671
|
saveEvent
|
|
3637
3672
|
];
|
|
3638
3673
|
}
|