eat-js-sdk 1.0.52 → 1.0.54
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 +135 -121
- package/package.json +2 -2
|
@@ -332,89 +332,6 @@
|
|
|
332
332
|
function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
|
|
333
333
|
return new CustomEvent(type, { detail, bubbles, cancelable });
|
|
334
334
|
}
|
|
335
|
-
var HtmlTag = class {
|
|
336
|
-
/**
|
|
337
|
-
* @private
|
|
338
|
-
* @default false
|
|
339
|
-
*/
|
|
340
|
-
is_svg = false;
|
|
341
|
-
/** parent for creating node */
|
|
342
|
-
e = void 0;
|
|
343
|
-
/** html tag nodes */
|
|
344
|
-
n = void 0;
|
|
345
|
-
/** target */
|
|
346
|
-
t = void 0;
|
|
347
|
-
/** anchor */
|
|
348
|
-
a = void 0;
|
|
349
|
-
constructor(is_svg = false) {
|
|
350
|
-
this.is_svg = is_svg;
|
|
351
|
-
this.e = this.n = null;
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* @param {string} html
|
|
355
|
-
* @returns {void}
|
|
356
|
-
*/
|
|
357
|
-
c(html) {
|
|
358
|
-
this.h(html);
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* @param {string} html
|
|
362
|
-
* @param {HTMLElement | SVGElement} target
|
|
363
|
-
* @param {HTMLElement | SVGElement} anchor
|
|
364
|
-
* @returns {void}
|
|
365
|
-
*/
|
|
366
|
-
m(html, target, anchor = null) {
|
|
367
|
-
if (!this.e) {
|
|
368
|
-
if (this.is_svg)
|
|
369
|
-
this.e = svg_element(
|
|
370
|
-
/** @type {keyof SVGElementTagNameMap} */
|
|
371
|
-
target.nodeName
|
|
372
|
-
);
|
|
373
|
-
else
|
|
374
|
-
this.e = element(
|
|
375
|
-
/** @type {keyof HTMLElementTagNameMap} */
|
|
376
|
-
target.nodeType === 11 ? "TEMPLATE" : target.nodeName
|
|
377
|
-
);
|
|
378
|
-
this.t = target.tagName !== "TEMPLATE" ? target : (
|
|
379
|
-
/** @type {HTMLTemplateElement} */
|
|
380
|
-
target.content
|
|
381
|
-
);
|
|
382
|
-
this.c(html);
|
|
383
|
-
}
|
|
384
|
-
this.i(anchor);
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* @param {string} html
|
|
388
|
-
* @returns {void}
|
|
389
|
-
*/
|
|
390
|
-
h(html) {
|
|
391
|
-
this.e.innerHTML = html;
|
|
392
|
-
this.n = Array.from(
|
|
393
|
-
this.e.nodeName === "TEMPLATE" ? this.e.content.childNodes : this.e.childNodes
|
|
394
|
-
);
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* @returns {void} */
|
|
398
|
-
i(anchor) {
|
|
399
|
-
for (let i = 0; i < this.n.length; i += 1) {
|
|
400
|
-
insert(this.t, this.n[i], anchor);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
/**
|
|
404
|
-
* @param {string} html
|
|
405
|
-
* @returns {void}
|
|
406
|
-
*/
|
|
407
|
-
p(html) {
|
|
408
|
-
this.d();
|
|
409
|
-
this.h(html);
|
|
410
|
-
this.i(this.a);
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* @returns {void} */
|
|
414
|
-
d() {
|
|
415
|
-
this.n.forEach(detach);
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
335
|
function get_custom_elements_slots(element2) {
|
|
419
336
|
const result = {};
|
|
420
337
|
element2.childNodes.forEach(
|
|
@@ -17630,31 +17547,28 @@
|
|
|
17630
17547
|
// src/lib/components/prompt/dropdown/PromptDropdown.svelte
|
|
17631
17548
|
function get_each_context7(ctx, list, i) {
|
|
17632
17549
|
const child_ctx = ctx.slice();
|
|
17633
|
-
child_ctx[
|
|
17550
|
+
child_ctx[32] = list[i];
|
|
17551
|
+
return child_ctx;
|
|
17552
|
+
}
|
|
17553
|
+
function get_each_context_13(ctx, list, i) {
|
|
17554
|
+
const child_ctx = ctx.slice();
|
|
17555
|
+
child_ctx[35] = list[i];
|
|
17634
17556
|
return child_ctx;
|
|
17635
17557
|
}
|
|
17636
17558
|
function create_else_block7(ctx) {
|
|
17637
17559
|
let span;
|
|
17638
|
-
let html_tag;
|
|
17639
17560
|
let raw_value = (
|
|
17640
17561
|
/*item*/
|
|
17641
|
-
ctx[
|
|
17562
|
+
ctx[35].text + ""
|
|
17642
17563
|
);
|
|
17643
|
-
let t2;
|
|
17644
|
-
let span_aria_hidden_value;
|
|
17645
17564
|
return {
|
|
17646
17565
|
c() {
|
|
17647
17566
|
span = element("span");
|
|
17648
|
-
html_tag = new HtmlTag(false);
|
|
17649
|
-
t2 = space();
|
|
17650
|
-
html_tag.a = t2;
|
|
17651
17567
|
attr(span, "class", "dropdown-text text-xl font-semibold leading-12 text-blue-1000");
|
|
17652
|
-
attr(span, "aria-hidden", span_aria_hidden_value = false);
|
|
17653
17568
|
},
|
|
17654
17569
|
m(target, anchor) {
|
|
17655
17570
|
insert(target, span, anchor);
|
|
17656
|
-
|
|
17657
|
-
append(span, t2);
|
|
17571
|
+
span.innerHTML = raw_value;
|
|
17658
17572
|
},
|
|
17659
17573
|
p: noop,
|
|
17660
17574
|
i: noop,
|
|
@@ -17685,7 +17599,7 @@
|
|
|
17685
17599
|
),
|
|
17686
17600
|
options: (
|
|
17687
17601
|
/*item*/
|
|
17688
|
-
ctx[
|
|
17602
|
+
ctx[35]
|
|
17689
17603
|
),
|
|
17690
17604
|
answer: (
|
|
17691
17605
|
/*answer*/
|
|
@@ -17716,7 +17630,7 @@
|
|
|
17716
17630
|
promptdropdowncontainer.$on(
|
|
17717
17631
|
"select",
|
|
17718
17632
|
/*select_handler*/
|
|
17719
|
-
ctx[
|
|
17633
|
+
ctx[26]
|
|
17720
17634
|
);
|
|
17721
17635
|
return {
|
|
17722
17636
|
c() {
|
|
@@ -17773,7 +17687,7 @@
|
|
|
17773
17687
|
}
|
|
17774
17688
|
};
|
|
17775
17689
|
}
|
|
17776
|
-
function
|
|
17690
|
+
function create_each_block_13(ctx) {
|
|
17777
17691
|
let current_block_type_index;
|
|
17778
17692
|
let if_block;
|
|
17779
17693
|
let if_block_anchor;
|
|
@@ -17783,7 +17697,7 @@
|
|
|
17783
17697
|
function select_block_type(ctx2, dirty) {
|
|
17784
17698
|
if (
|
|
17785
17699
|
/*item*/
|
|
17786
|
-
ctx2[
|
|
17700
|
+
ctx2[35].type === "dropdown"
|
|
17787
17701
|
)
|
|
17788
17702
|
return 0;
|
|
17789
17703
|
return 1;
|
|
@@ -17821,6 +17735,96 @@
|
|
|
17821
17735
|
}
|
|
17822
17736
|
};
|
|
17823
17737
|
}
|
|
17738
|
+
function create_each_block7(ctx) {
|
|
17739
|
+
let p;
|
|
17740
|
+
let t2;
|
|
17741
|
+
let current;
|
|
17742
|
+
let each_value_1 = ensure_array_like(
|
|
17743
|
+
/*parseText*/
|
|
17744
|
+
ctx[22](
|
|
17745
|
+
/*promptLine*/
|
|
17746
|
+
ctx[32]
|
|
17747
|
+
)
|
|
17748
|
+
);
|
|
17749
|
+
let each_blocks = [];
|
|
17750
|
+
for (let i = 0; i < each_value_1.length; i += 1) {
|
|
17751
|
+
each_blocks[i] = create_each_block_13(get_each_context_13(ctx, each_value_1, i));
|
|
17752
|
+
}
|
|
17753
|
+
const out = (i) => transition_out(each_blocks[i], 1, 1, () => {
|
|
17754
|
+
each_blocks[i] = null;
|
|
17755
|
+
});
|
|
17756
|
+
return {
|
|
17757
|
+
c() {
|
|
17758
|
+
p = element("p");
|
|
17759
|
+
for (let i = 0; i < each_blocks.length; i += 1) {
|
|
17760
|
+
each_blocks[i].c();
|
|
17761
|
+
}
|
|
17762
|
+
t2 = space();
|
|
17763
|
+
attr(p, "class", "mb-4");
|
|
17764
|
+
},
|
|
17765
|
+
m(target, anchor) {
|
|
17766
|
+
insert(target, p, anchor);
|
|
17767
|
+
for (let i = 0; i < each_blocks.length; i += 1) {
|
|
17768
|
+
if (each_blocks[i]) {
|
|
17769
|
+
each_blocks[i].m(p, null);
|
|
17770
|
+
}
|
|
17771
|
+
}
|
|
17772
|
+
append(p, t2);
|
|
17773
|
+
current = true;
|
|
17774
|
+
},
|
|
17775
|
+
p(ctx2, dirty) {
|
|
17776
|
+
if (dirty[0] & /*sessionData, metadata, scoringMetadata, parseText, checkPromptLine, dropdownText, answer, isDataSaving, isFinished, isPreviewMode, isPreviewModeInteractive, previewInteractiveEvent, saveDropdownEvent*/
|
|
17777
|
+
31850877) {
|
|
17778
|
+
each_value_1 = ensure_array_like(
|
|
17779
|
+
/*parseText*/
|
|
17780
|
+
ctx2[22](
|
|
17781
|
+
/*promptLine*/
|
|
17782
|
+
ctx2[32]
|
|
17783
|
+
)
|
|
17784
|
+
);
|
|
17785
|
+
let i;
|
|
17786
|
+
for (i = 0; i < each_value_1.length; i += 1) {
|
|
17787
|
+
const child_ctx = get_each_context_13(ctx2, each_value_1, i);
|
|
17788
|
+
if (each_blocks[i]) {
|
|
17789
|
+
each_blocks[i].p(child_ctx, dirty);
|
|
17790
|
+
transition_in(each_blocks[i], 1);
|
|
17791
|
+
} else {
|
|
17792
|
+
each_blocks[i] = create_each_block_13(child_ctx);
|
|
17793
|
+
each_blocks[i].c();
|
|
17794
|
+
transition_in(each_blocks[i], 1);
|
|
17795
|
+
each_blocks[i].m(p, t2);
|
|
17796
|
+
}
|
|
17797
|
+
}
|
|
17798
|
+
group_outros();
|
|
17799
|
+
for (i = each_value_1.length; i < each_blocks.length; i += 1) {
|
|
17800
|
+
out(i);
|
|
17801
|
+
}
|
|
17802
|
+
check_outros();
|
|
17803
|
+
}
|
|
17804
|
+
},
|
|
17805
|
+
i(local) {
|
|
17806
|
+
if (current)
|
|
17807
|
+
return;
|
|
17808
|
+
for (let i = 0; i < each_value_1.length; i += 1) {
|
|
17809
|
+
transition_in(each_blocks[i]);
|
|
17810
|
+
}
|
|
17811
|
+
current = true;
|
|
17812
|
+
},
|
|
17813
|
+
o(local) {
|
|
17814
|
+
each_blocks = each_blocks.filter(Boolean);
|
|
17815
|
+
for (let i = 0; i < each_blocks.length; i += 1) {
|
|
17816
|
+
transition_out(each_blocks[i]);
|
|
17817
|
+
}
|
|
17818
|
+
current = false;
|
|
17819
|
+
},
|
|
17820
|
+
d(detaching) {
|
|
17821
|
+
if (detaching) {
|
|
17822
|
+
detach(p);
|
|
17823
|
+
}
|
|
17824
|
+
destroy_each(each_blocks, detaching);
|
|
17825
|
+
}
|
|
17826
|
+
};
|
|
17827
|
+
}
|
|
17824
17828
|
function create_if_block13(ctx) {
|
|
17825
17829
|
let div;
|
|
17826
17830
|
let t0;
|
|
@@ -17997,15 +18001,15 @@
|
|
|
17997
18001
|
};
|
|
17998
18002
|
}
|
|
17999
18003
|
function create_default_slot5(ctx) {
|
|
18000
|
-
let
|
|
18004
|
+
let div;
|
|
18001
18005
|
let t2;
|
|
18002
18006
|
let if_block_anchor;
|
|
18003
18007
|
let current;
|
|
18004
18008
|
let each_value = ensure_array_like(
|
|
18005
|
-
/*
|
|
18006
|
-
ctx[
|
|
18009
|
+
/*checkPromptLine*/
|
|
18010
|
+
ctx[23](
|
|
18007
18011
|
/*dropdownText*/
|
|
18008
|
-
ctx[
|
|
18012
|
+
ctx[21].prompt
|
|
18009
18013
|
)
|
|
18010
18014
|
);
|
|
18011
18015
|
let each_blocks = [];
|
|
@@ -18021,7 +18025,7 @@
|
|
|
18021
18025
|
);
|
|
18022
18026
|
return {
|
|
18023
18027
|
c() {
|
|
18024
|
-
|
|
18028
|
+
div = element("div");
|
|
18025
18029
|
for (let i = 0; i < each_blocks.length; i += 1) {
|
|
18026
18030
|
each_blocks[i].c();
|
|
18027
18031
|
}
|
|
@@ -18029,13 +18033,13 @@
|
|
|
18029
18033
|
if (if_block)
|
|
18030
18034
|
if_block.c();
|
|
18031
18035
|
if_block_anchor = empty();
|
|
18032
|
-
attr(
|
|
18036
|
+
attr(div, "class", "my-6");
|
|
18033
18037
|
},
|
|
18034
18038
|
m(target, anchor) {
|
|
18035
|
-
insert(target,
|
|
18039
|
+
insert(target, div, anchor);
|
|
18036
18040
|
for (let i = 0; i < each_blocks.length; i += 1) {
|
|
18037
18041
|
if (each_blocks[i]) {
|
|
18038
|
-
each_blocks[i].m(
|
|
18042
|
+
each_blocks[i].m(div, null);
|
|
18039
18043
|
}
|
|
18040
18044
|
}
|
|
18041
18045
|
insert(target, t2, anchor);
|
|
@@ -18045,13 +18049,13 @@
|
|
|
18045
18049
|
current = true;
|
|
18046
18050
|
},
|
|
18047
18051
|
p(ctx2, dirty) {
|
|
18048
|
-
if (dirty[0] & /*
|
|
18049
|
-
|
|
18052
|
+
if (dirty[0] & /*parseText, checkPromptLine, dropdownText, sessionData, metadata, scoringMetadata, answer, isDataSaving, isFinished, isPreviewMode, isPreviewModeInteractive, previewInteractiveEvent, saveDropdownEvent*/
|
|
18053
|
+
31850877) {
|
|
18050
18054
|
each_value = ensure_array_like(
|
|
18051
|
-
/*
|
|
18052
|
-
ctx2[
|
|
18055
|
+
/*checkPromptLine*/
|
|
18056
|
+
ctx2[23](
|
|
18053
18057
|
/*dropdownText*/
|
|
18054
|
-
ctx2[
|
|
18058
|
+
ctx2[21].prompt
|
|
18055
18059
|
)
|
|
18056
18060
|
);
|
|
18057
18061
|
let i;
|
|
@@ -18064,7 +18068,7 @@
|
|
|
18064
18068
|
each_blocks[i] = create_each_block7(child_ctx);
|
|
18065
18069
|
each_blocks[i].c();
|
|
18066
18070
|
transition_in(each_blocks[i], 1);
|
|
18067
|
-
each_blocks[i].m(
|
|
18071
|
+
each_blocks[i].m(div, null);
|
|
18068
18072
|
}
|
|
18069
18073
|
}
|
|
18070
18074
|
group_outros();
|
|
@@ -18116,7 +18120,7 @@
|
|
|
18116
18120
|
},
|
|
18117
18121
|
d(detaching) {
|
|
18118
18122
|
if (detaching) {
|
|
18119
|
-
detach(
|
|
18123
|
+
detach(div);
|
|
18120
18124
|
detach(t2);
|
|
18121
18125
|
detach(if_block_anchor);
|
|
18122
18126
|
}
|
|
@@ -18137,7 +18141,7 @@
|
|
|
18137
18141
|
),
|
|
18138
18142
|
prompt: (
|
|
18139
18143
|
/*prompt*/
|
|
18140
|
-
ctx[
|
|
18144
|
+
ctx[20]
|
|
18141
18145
|
),
|
|
18142
18146
|
interactionType: INTERACTION_TYPE_DROPDOWN,
|
|
18143
18147
|
stimulus: (
|
|
@@ -18161,7 +18165,7 @@
|
|
|
18161
18165
|
const promptbody_changes = {};
|
|
18162
18166
|
if (dirty[0] & /*getDropdownAnswerResult, getCorrectAnswers, sessionId, getSessionAnswer, isResultCorrect, resultFeedback, isSkipped, showSpecificFeedback, showFeedbackandTable, sessionData, answer, isDataSaving, isFinished, isPreviewMode, isPreviewModeInteractive, previewInteractiveEvent*/
|
|
18163
18167
|
65535 | dirty[1] & /*$$scope*/
|
|
18164
|
-
|
|
18168
|
+
128) {
|
|
18165
18169
|
promptbody_changes.$$scope = { dirty, ctx: ctx2 };
|
|
18166
18170
|
}
|
|
18167
18171
|
promptbody.$set(promptbody_changes);
|
|
@@ -18181,6 +18185,7 @@
|
|
|
18181
18185
|
}
|
|
18182
18186
|
};
|
|
18183
18187
|
}
|
|
18188
|
+
var pTagRegex = /<p[^>]*>.*?<\/p>/gi;
|
|
18184
18189
|
function instance16($$self, $$props, $$invalidate) {
|
|
18185
18190
|
let answer;
|
|
18186
18191
|
let getSessionFeedbackData;
|
|
@@ -18201,6 +18206,7 @@
|
|
|
18201
18206
|
const dispatch = createEventDispatcher();
|
|
18202
18207
|
const { rubric, interaction, metadata, scoringMetadata, stimulus } = sessionData;
|
|
18203
18208
|
let previewInteractiveEvent = false;
|
|
18209
|
+
const { prompt, text: dropdownText, options, feedback } = interaction;
|
|
18204
18210
|
const parseText = (dropdownText2) => {
|
|
18205
18211
|
return dropdownText2.split(/(<eat-contentful:[^>]+>)/g).map((part) => {
|
|
18206
18212
|
const match = part.match(/<eat-contentful:([^>]+)>/);
|
|
@@ -18226,7 +18232,14 @@
|
|
|
18226
18232
|
return item;
|
|
18227
18233
|
});
|
|
18228
18234
|
};
|
|
18229
|
-
const
|
|
18235
|
+
const checkPromptLine = (promptText) => {
|
|
18236
|
+
const pTags = promptText.match(pTagRegex);
|
|
18237
|
+
if (pTags && pTags.length > 0) {
|
|
18238
|
+
return pTags;
|
|
18239
|
+
} else {
|
|
18240
|
+
return [promptText];
|
|
18241
|
+
}
|
|
18242
|
+
};
|
|
18230
18243
|
const getDropdownAnswerEvent = () => {
|
|
18231
18244
|
const dropdownAnswerEvents = metadata.interactions.events;
|
|
18232
18245
|
return dropdownAnswerEvents[dropdownAnswerEvents.length - 1]?.answer;
|
|
@@ -18260,7 +18273,7 @@
|
|
|
18260
18273
|
if ($$self.$$.dirty[0] & /*isFinished, isPreviewModeInteractive, isPreviewMode, answer*/
|
|
18261
18274
|
284) {
|
|
18262
18275
|
$:
|
|
18263
|
-
$$invalidate(
|
|
18276
|
+
$$invalidate(25, getSessionFeedbackData = () => {
|
|
18264
18277
|
if (!isFinished && !isPreviewModeInteractive || isFinished && isPreviewMode)
|
|
18265
18278
|
return [];
|
|
18266
18279
|
const { answer: sessionAnswer, correctAnswer: sessionCorrectAnswer } = scoringMetadata;
|
|
@@ -18277,7 +18290,7 @@
|
|
|
18277
18290
|
});
|
|
18278
18291
|
}
|
|
18279
18292
|
if ($$self.$$.dirty[0] & /*isFinished, isPreviewModeInteractive, getSessionFeedbackData*/
|
|
18280
|
-
|
|
18293
|
+
33554452) {
|
|
18281
18294
|
$:
|
|
18282
18295
|
$$invalidate(15, isSkipped = () => {
|
|
18283
18296
|
if (!isFinished && !isPreviewModeInteractive)
|
|
@@ -18289,7 +18302,7 @@
|
|
|
18289
18302
|
});
|
|
18290
18303
|
}
|
|
18291
18304
|
if ($$self.$$.dirty[0] & /*getSessionFeedbackData*/
|
|
18292
|
-
|
|
18305
|
+
33554432) {
|
|
18293
18306
|
$:
|
|
18294
18307
|
$$invalidate(7, isResultCorrect = () => {
|
|
18295
18308
|
return getSessionFeedbackData().every((status) => status === "correct");
|
|
@@ -18391,9 +18404,10 @@
|
|
|
18391
18404
|
metadata,
|
|
18392
18405
|
scoringMetadata,
|
|
18393
18406
|
stimulus,
|
|
18394
|
-
parseText,
|
|
18395
18407
|
prompt,
|
|
18396
18408
|
dropdownText,
|
|
18409
|
+
parseText,
|
|
18410
|
+
checkPromptLine,
|
|
18397
18411
|
saveDropdownEvent,
|
|
18398
18412
|
getSessionFeedbackData,
|
|
18399
18413
|
select_handler
|
|
@@ -19216,7 +19230,7 @@
|
|
|
19216
19230
|
const { correct_answer: correctAnswer, typein_type: typeinType } = data.interaction;
|
|
19217
19231
|
scoringMetadata = {
|
|
19218
19232
|
hasAnswer: true,
|
|
19219
|
-
answer: typeinType === TYPEIN_TYPE_SHORT ? correctAnswer[0][0] : typeinType === TYPEIN_TYPE_INLINE ? correctAnswer : correctAnswer[0]
|
|
19233
|
+
answer: typeinType === TYPEIN_TYPE_SHORT ? correctAnswer[0][0] : typeinType === TYPEIN_TYPE_INLINE ? correctAnswer : correctAnswer[0].sample_answer[0]
|
|
19220
19234
|
};
|
|
19221
19235
|
$$invalidate(0, sessionData = { ...sessionData, scoringMetadata });
|
|
19222
19236
|
if (isPreviewModeInteractive) {
|