@pie-element/select-text 13.1.2-next.2 → 13.1.2
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/CHANGELOG.json +1422 -0
- package/CHANGELOG.md +2288 -0
- package/LICENSE.md +5 -0
- package/README.md +5 -0
- package/configure/CHANGELOG.json +1032 -0
- package/configure/CHANGELOG.md +2023 -0
- package/configure/lib/defaultConfiguration.js +177 -0
- package/configure/lib/defaultConfiguration.js.map +1 -0
- package/configure/lib/design.js +406 -0
- package/configure/lib/design.js.map +1 -0
- package/configure/lib/index.js +128 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/utils.js +92 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +25 -0
- package/controller/CHANGELOG.json +442 -0
- package/controller/CHANGELOG.md +1468 -0
- package/controller/lib/defaults.js +25 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +258 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/package.json +16 -0
- package/docs/config-schema.json +2135 -0
- package/docs/config-schema.json.md +1579 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +823 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +24 -0
- package/docs/pie-schema.json +1248 -0
- package/docs/pie-schema.json.md +711 -0
- package/lib/index.js +103 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +191 -0
- package/lib/main.js.map +1 -0
- package/lib/print.js +87 -0
- package/lib/print.js.map +1 -0
- package/lib/utils.js +80 -0
- package/lib/utils.js.map +1 -0
- package/package.json +21 -90
- package/configure.js +0 -2
- package/controller.js +0 -1
- package/dist/author/defaultConfiguration.d.ts +0 -179
- package/dist/author/defaultConfiguration.js +0 -141
- package/dist/author/design.d.ts +0 -38
- package/dist/author/design.js +0 -263
- package/dist/author/index.d.ts +0 -27
- package/dist/author/index.js +0 -74
- package/dist/author/utils.d.ts +0 -10
- package/dist/author/utils.js +0 -50
- package/dist/browser/Check-BMR_1cO0.js +0 -9261
- package/dist/browser/Check-BMR_1cO0.js.map +0 -1
- package/dist/browser/author/index.js +0 -41129
- package/dist/browser/author/index.js.map +0 -1
- package/dist/browser/controller/index.js +0 -194
- package/dist/browser/controller/index.js.map +0 -1
- package/dist/browser/delivery/index.js +0 -89
- package/dist/browser/delivery/index.js.map +0 -1
- package/dist/browser/dist-SG92p6xV.js +0 -319
- package/dist/browser/dist-SG92p6xV.js.map +0 -1
- package/dist/browser/main-jVjbBKTM.js +0 -4804
- package/dist/browser/main-jVjbBKTM.js.map +0 -1
- package/dist/browser/print/index.js +0 -41
- package/dist/browser/print/index.js.map +0 -1
- package/dist/browser/select-text.css +0 -2
- package/dist/controller/defaults.d.ts +0 -27
- package/dist/controller/defaults.js +0 -21
- package/dist/controller/index.d.ts +0 -25
- package/dist/controller/index.js +0 -121
- package/dist/delivery/index.d.ts +0 -19
- package/dist/delivery/index.js +0 -60
- package/dist/delivery/main.d.ts +0 -34
- package/dist/delivery/main.js +0 -136
- package/dist/delivery/utils.d.ts +0 -10
- package/dist/delivery/utils.js +0 -47
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.d.ts +0 -8
- package/dist/index.iife.js +0 -167
- package/dist/index.js +0 -2
- package/dist/print/index.d.ts +0 -15
- package/dist/print/index.js +0 -41
- package/dist/runtime-support.d.ts +0 -12
- package/dist/runtime-support.js +0 -12
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/select-text/controller/src/defaults.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
declare const _default: {
|
|
10
|
-
feedbackEnabled: boolean;
|
|
11
|
-
highlightChoices: boolean;
|
|
12
|
-
maxSelections: number;
|
|
13
|
-
mode: string;
|
|
14
|
-
partialScoring: boolean;
|
|
15
|
-
prompt: string;
|
|
16
|
-
promptEnabled: boolean;
|
|
17
|
-
rationale: string;
|
|
18
|
-
rationaleEnabled: boolean;
|
|
19
|
-
scoringType: string;
|
|
20
|
-
studentInstructionsEnabled: boolean;
|
|
21
|
-
teacherInstructions: string;
|
|
22
|
-
teacherInstructionsEnabled: boolean;
|
|
23
|
-
text: string;
|
|
24
|
-
tokens: never[];
|
|
25
|
-
toolbarEditorPosition: string;
|
|
26
|
-
};
|
|
27
|
-
export default _default;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//#region src/controller/defaults.ts
|
|
2
|
-
var e = {
|
|
3
|
-
feedbackEnabled: !1,
|
|
4
|
-
highlightChoices: !1,
|
|
5
|
-
maxSelections: 0,
|
|
6
|
-
mode: "sentence",
|
|
7
|
-
partialScoring: !1,
|
|
8
|
-
prompt: "",
|
|
9
|
-
promptEnabled: !0,
|
|
10
|
-
rationale: "",
|
|
11
|
-
rationaleEnabled: !0,
|
|
12
|
-
scoringType: "auto",
|
|
13
|
-
studentInstructionsEnabled: !0,
|
|
14
|
-
teacherInstructions: "",
|
|
15
|
-
teacherInstructionsEnabled: !0,
|
|
16
|
-
text: "",
|
|
17
|
-
tokens: [],
|
|
18
|
-
toolbarEditorPosition: "bottom"
|
|
19
|
-
};
|
|
20
|
-
//#endregion
|
|
21
|
-
export { e as default };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/select-text/controller/src/index.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
export declare const getCorrectness: (tokens: any, selected: any) => "unknown" | "correct" | "partially-correct" | "incorrect";
|
|
10
|
-
export declare const getPartialScore: (question: any, session: any, totalCorrect: any) => number;
|
|
11
|
-
/**
|
|
12
|
-
* Generates detailed trace log for select-text scoring evaluation
|
|
13
|
-
* @param {Object} question - the question model
|
|
14
|
-
* @param {Object} session - the student session
|
|
15
|
-
* @param {Object} env - the environment
|
|
16
|
-
* @returns {Array<string>} traceLog
|
|
17
|
-
*/
|
|
18
|
-
export declare const getLogTrace: (question: any, session: any, env: any) => string[];
|
|
19
|
-
export declare const outcome: (question: any, session: any, env: any) => Promise<unknown>;
|
|
20
|
-
export declare function createDefaultModel(model?: {}): Promise<unknown>;
|
|
21
|
-
export declare const normalizeSession: (session: any) => any;
|
|
22
|
-
export declare const normalize: (question: any) => any;
|
|
23
|
-
export declare const model: (question: any, session: any, env: any) => Promise<unknown>;
|
|
24
|
-
export declare const createCorrectResponseSession: (question: any, env: any) => Promise<unknown>;
|
|
25
|
-
export declare const validate: (model?: {}, config?: {}) => {};
|
package/dist/controller/index.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import e from "./defaults.js";
|
|
2
|
-
import t from "debug";
|
|
3
|
-
import { isEmpty as n } from "@pie-element/shared-lodash";
|
|
4
|
-
import { getFeedbackForCorrectness as r } from "@pie-element/shared-feedback";
|
|
5
|
-
import { partialScoring as i } from "@pie-element/shared-controller-utils";
|
|
6
|
-
//#region src/controller/index.ts
|
|
7
|
-
var a = t("@pie-element:select-text:controller"), o = (e = {}, t = {}) => e?.start === t?.start && e?.end === t?.end || e?.start === t?.oldStart && e?.end === t?.oldEnd, s = (e = [], t = [], n = !1) => (e || []).map((e) => {
|
|
8
|
-
let r = !!e.correct, i = r && !(t || []).find((t) => o(e, t));
|
|
9
|
-
return {
|
|
10
|
-
...e,
|
|
11
|
-
correct: n ? r : void 0,
|
|
12
|
-
isMissing: n ? i : void 0
|
|
13
|
-
};
|
|
14
|
-
}), c = (e, t) => {
|
|
15
|
-
let n = e.filter((e) => e.correct === !0);
|
|
16
|
-
if (n.length === 0) return "unknown";
|
|
17
|
-
let r = l(e, t);
|
|
18
|
-
if (r.length === t.length) {
|
|
19
|
-
if (r.length === n.length) return "correct";
|
|
20
|
-
if (r.length > 0) return "partially-correct";
|
|
21
|
-
}
|
|
22
|
-
return r.length > 0 ? "partially-correct" : "incorrect";
|
|
23
|
-
}, l = (e, t) => (t || []).filter((t) => e.findIndex((e) => e.correct && o(e, t)) !== -1), u = (e, t, r) => {
|
|
24
|
-
if (!t || n(t)) return 0;
|
|
25
|
-
let i = l(e.tokens, t.selectedTokens).length, a = (e.tokens || []).filter((e) => e.correct === !0), o = i - (t.selectedTokens && t.selectedTokens.length > a.length ? t.selectedTokens && t.selectedTokens.length - i : 0), s = o < 0 ? 0 : o;
|
|
26
|
-
return r.length ? parseFloat((s / r.length).toFixed(2)) : 0;
|
|
27
|
-
}, d = (e, t, n) => {
|
|
28
|
-
let r = [], a = t?.selectedTokens || [], s = e?.tokens || [];
|
|
29
|
-
if (a.length === 0) return r.push("Student did not select any token."), r;
|
|
30
|
-
r.push(`Student selected ${a.length} token(s).`);
|
|
31
|
-
let c = 0, l = 0, d = 0;
|
|
32
|
-
for (let e = 0; e < s.length; e++) {
|
|
33
|
-
let t = s[e];
|
|
34
|
-
t.correct && (c++, a.some((e) => o(t, e)) ? l++ : d++);
|
|
35
|
-
}
|
|
36
|
-
let f = a.length - l;
|
|
37
|
-
l > 0 && r.push(`${l} correct token(s) selected.`), f > 0 && r.push(`${f} incorrect token(s) selected.`), d > 0 && r.push(`${d} required correct token(s) were not selected.`);
|
|
38
|
-
let p = i.enabled(e, n, !0);
|
|
39
|
-
p ? (r.push("Score calculated using partial scoring."), r.push("Score is based on the number of correct minus incorrect selections, divided by the total number of correct tokens."), f > 0 && a.length > c && r.push("Extra selected tokens beyond the correct set reduce the score.")) : (r.push("Score calculated using all-or-nothing scoring."), r.push("Student must select all correct tokens and no incorrect tokens to receive full credit."));
|
|
40
|
-
let m = u(e, t, s.filter((e) => e.correct)), h = p ? m : +(m === 1);
|
|
41
|
-
return r.push(`Final score: ${h}.`), r;
|
|
42
|
-
}, f = (e, t, r) => new Promise((a) => {
|
|
43
|
-
if ((!t || n(t)) && a({
|
|
44
|
-
score: 0,
|
|
45
|
-
empty: !0,
|
|
46
|
-
logTrace: ["Student did not select any token."]
|
|
47
|
-
}), t = m(t), r.mode !== "evaluate") a({
|
|
48
|
-
score: void 0,
|
|
49
|
-
completed: void 0,
|
|
50
|
-
logTrace: []
|
|
51
|
-
});
|
|
52
|
-
else {
|
|
53
|
-
let n = i.enabled(e, r, !0), o = e.tokens.filter((e) => e.correct), s = u(e, t, o);
|
|
54
|
-
a({
|
|
55
|
-
score: n ? s : +(s === 1),
|
|
56
|
-
logTrace: d(e, t, r)
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
function p(t = {}) {
|
|
61
|
-
return new Promise((n) => {
|
|
62
|
-
n({
|
|
63
|
-
...e,
|
|
64
|
-
...t
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
var m = (e) => ({
|
|
69
|
-
selectedTokens: [],
|
|
70
|
-
...e
|
|
71
|
-
}), h = (t) => ({
|
|
72
|
-
...e,
|
|
73
|
-
...t
|
|
74
|
-
}), g = (e, t, n) => {
|
|
75
|
-
t ||= { selectedToken: [] }, t.selectedTokens = t.selectedTokens || [];
|
|
76
|
-
let i = h(e);
|
|
77
|
-
return new Promise((e) => {
|
|
78
|
-
a("[model]", "normalizedQuestion: ", i), a("[model]", "session: ", t);
|
|
79
|
-
let o = s(i.tokens, t.selectedTokens, n.mode === "evaluate");
|
|
80
|
-
a("[model] tokens:", o);
|
|
81
|
-
let l = n.mode === "evaluate" ? c(i.tokens, t.selectedTokens) : void 0;
|
|
82
|
-
(n.mode === "evaluate" && i.feedbackEnabled ? r(l, i.feedback) : Promise.resolve(void 0)).then((t) => {
|
|
83
|
-
let r = {
|
|
84
|
-
tokens: o,
|
|
85
|
-
highlightChoices: i.highlightChoices,
|
|
86
|
-
prompt: i.promptEnabled ? i.prompt : null,
|
|
87
|
-
text: i.text,
|
|
88
|
-
disabled: n.mode !== "gather",
|
|
89
|
-
maxSelections: i.maxSelections,
|
|
90
|
-
correctness: l,
|
|
91
|
-
env: n,
|
|
92
|
-
feedback: t,
|
|
93
|
-
incorrect: n.mode === "evaluate" ? l !== "correct" : void 0,
|
|
94
|
-
language: i.language,
|
|
95
|
-
extraCSSRules: i.extraCSSRules
|
|
96
|
-
};
|
|
97
|
-
n.role === "instructor" && (n.mode === "view" || n.mode === "evaluate") ? (r.rationale = i.rationaleEnabled ? i.rationale : null, r.teacherInstructions = i.teacherInstructionsEnabled ? i.teacherInstructions : null) : (r.rationale = null, r.teacherInstructions = null), e(r);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
}, _ = (e, t) => new Promise((n) => {
|
|
101
|
-
if (t.mode !== "evaluate" && t.role === "instructor") {
|
|
102
|
-
let { tokens: t } = e;
|
|
103
|
-
n({
|
|
104
|
-
id: "1",
|
|
105
|
-
selectedTokens: t.filter((e) => e.correct)
|
|
106
|
-
});
|
|
107
|
-
} else n(null);
|
|
108
|
-
}), v = (e) => (e || "").replace(/(<(?!img|iframe|source)([^>]+)>)/gi, ""), y = (e = {}, t = {}) => {
|
|
109
|
-
let { tokens: n } = e, { minTokens: r = 2, maxTokens: i, maxSelections: a } = t, o = {}, s = (n || []).length;
|
|
110
|
-
[
|
|
111
|
-
"teacherInstructions",
|
|
112
|
-
"prompt",
|
|
113
|
-
"rationale"
|
|
114
|
-
].forEach((n) => {
|
|
115
|
-
t[n]?.required && !v(e[n]) && (o[n] = "This field is required.");
|
|
116
|
-
});
|
|
117
|
-
let c = (n || []).reduce((e, t) => t.correct ? e + 1 : e, 0);
|
|
118
|
-
return s < r ? o.tokensError = `There should be at least ${r} tokens defined.` : s > i && (o.tokensError = `No more than ${i} tokens should be defined.`), c < 1 ? o.selectionsError = "There should be at least 1 token selected." : c > a && (o.selectionsError = `No more than ${a} tokens should be selected.`), o;
|
|
119
|
-
};
|
|
120
|
-
//#endregion
|
|
121
|
-
export { _ as createCorrectResponseSession, p as createDefaultModel, c as getCorrectness, d as getLogTrace, u as getPartialScore, g as model, h as normalize, m as normalizeSession, f as outcome, y as validate };
|
package/dist/delivery/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/select-text/src/index.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
export default class SelectText extends HTMLElement {
|
|
10
|
-
constructor();
|
|
11
|
-
set model(m: any);
|
|
12
|
-
set session(s: any);
|
|
13
|
-
get session(): any;
|
|
14
|
-
isSessionComplete(): boolean;
|
|
15
|
-
selectionChanged(selection: any): void;
|
|
16
|
-
connectedCallback(): void;
|
|
17
|
-
render(): void;
|
|
18
|
-
disconnectedCallback(): void;
|
|
19
|
-
}
|
package/dist/delivery/index.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import e from "./utils.js";
|
|
2
|
-
import t from "./main.js";
|
|
3
|
-
import n from "react";
|
|
4
|
-
import { createRoot as r } from "react-dom/client";
|
|
5
|
-
import { ModelSetEvent as i, SessionChangedEvent as a } from "@pie-element/shared-player-events";
|
|
6
|
-
import { renderMath as o } from "@pie-element/shared-math-rendering-mathjax";
|
|
7
|
-
//#region src/delivery/index.ts
|
|
8
|
-
var s = class extends HTMLElement {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(), this._root = null;
|
|
11
|
-
}
|
|
12
|
-
set model(e) {
|
|
13
|
-
this._model = e, this.render(), this.dispatchEvent(new i(this.tagName.toLowerCase(), this.isSessionComplete(), this._model !== void 0));
|
|
14
|
-
}
|
|
15
|
-
set session(t) {
|
|
16
|
-
if (this._session = t, this._model) {
|
|
17
|
-
let { tokens: n } = e(this._model) || {}, { selectedTokens: r } = t || {};
|
|
18
|
-
r ||= [];
|
|
19
|
-
let i = (e) => n.find(({ start: t, end: n }) => e.start === t && e.end === n);
|
|
20
|
-
if (!r.reduce((e, t) => e && i(t), !0)) {
|
|
21
|
-
let { tokens: t } = e({
|
|
22
|
-
...this._model,
|
|
23
|
-
tokens: r
|
|
24
|
-
}) || {};
|
|
25
|
-
t && (this._session.selectedTokens = t);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
Array.isArray(this._session.selectedTokens) || (this._session.selectedTokens = []), this.render();
|
|
29
|
-
}
|
|
30
|
-
get session() {
|
|
31
|
-
return this._session;
|
|
32
|
-
}
|
|
33
|
-
isSessionComplete() {
|
|
34
|
-
let { selectedTokens: e } = this._session || {};
|
|
35
|
-
return Array.isArray(e) && e.length > 0;
|
|
36
|
-
}
|
|
37
|
-
selectionChanged(e) {
|
|
38
|
-
this._session.selectedTokens = e, this.dispatchEvent(new a(this.tagName.toLowerCase(), this.isSessionComplete()));
|
|
39
|
-
}
|
|
40
|
-
connectedCallback() {
|
|
41
|
-
this.render();
|
|
42
|
-
}
|
|
43
|
-
render() {
|
|
44
|
-
if (this._model && this._session) {
|
|
45
|
-
let e = n.createElement(t, {
|
|
46
|
-
model: this._model,
|
|
47
|
-
session: this._session,
|
|
48
|
-
onSelectionChange: this.selectionChanged.bind(this)
|
|
49
|
-
});
|
|
50
|
-
this._root ||= r(this), this._root.render(e), queueMicrotask(() => {
|
|
51
|
-
o(this);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
disconnectedCallback() {
|
|
56
|
-
this._root && this._root.unmount();
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
//#endregion
|
|
60
|
-
export { s as default };
|
package/dist/delivery/main.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/select-text/src/main.jsx
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
export declare class Main extends React.Component {
|
|
12
|
-
static propTypes: {
|
|
13
|
-
model: PropTypes.Requireable<object>;
|
|
14
|
-
session: PropTypes.Requireable<object>;
|
|
15
|
-
onSelectionChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
16
|
-
};
|
|
17
|
-
static defaultProps: {};
|
|
18
|
-
constructor(props: any);
|
|
19
|
-
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
20
|
-
toggleShowCorrect: any;
|
|
21
|
-
correctAnswer: any;
|
|
22
|
-
render(): React.JSX.Element;
|
|
23
|
-
}
|
|
24
|
-
export default class Stateful extends React.Component {
|
|
25
|
-
static propTypes: {
|
|
26
|
-
model: PropTypes.Requireable<object>;
|
|
27
|
-
session: PropTypes.Requireable<object>;
|
|
28
|
-
onSelectionChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
29
|
-
};
|
|
30
|
-
constructor(props: any);
|
|
31
|
-
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
32
|
-
change: any;
|
|
33
|
-
render(): React.JSX.Element;
|
|
34
|
-
}
|
package/dist/delivery/main.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import e from "./utils.js";
|
|
2
|
-
import t from "react";
|
|
3
|
-
import n from "prop-types";
|
|
4
|
-
import { Legend as r, TextSelect as i } from "@pie-lib/text-select";
|
|
5
|
-
import a from "@pie-lib/correct-answer-toggle";
|
|
6
|
-
import * as o from "@pie-lib/render-ui";
|
|
7
|
-
import { Collapsible as s, Feedback as c, PreviewPrompt as l, UiLayout as u, color as d, hasMedia as f, hasText as p } from "@pie-lib/render-ui";
|
|
8
|
-
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
9
|
-
import { styled as g } from "@mui/material/styles";
|
|
10
|
-
import _ from "debug";
|
|
11
|
-
//#region src/delivery/main.tsx
|
|
12
|
-
function v(e) {
|
|
13
|
-
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
14
|
-
}
|
|
15
|
-
function y(e, t) {
|
|
16
|
-
return !e || v(e) ? e : v(e.default) ? e.default : t && v(e[t]) ? e[t] : t && v(e[t]?.default) ? e[t].default : e;
|
|
17
|
-
}
|
|
18
|
-
var b = y(u, "UiLayout") || y(E.UiLayout, "UiLayout"), x = y(l, "PreviewPrompt") || y(E.PreviewPrompt, "PreviewPrompt"), S = y(s, "Collapsible") || y(E.Collapsible, "Collapsible"), C = y(c, "Feedback") || y(E.Feedback, "Feedback"), w = o, T = w.default, E = T && typeof T == "object" ? T : w, D = _("@pie-ui:select-text"), O = g(b)({
|
|
19
|
-
color: d.text(),
|
|
20
|
-
backgroundColor: d.background()
|
|
21
|
-
}), k = g(i)(({ theme: e }) => ({
|
|
22
|
-
marginBottom: e.spacing(1),
|
|
23
|
-
marginTop: e.spacing(2),
|
|
24
|
-
whiteSpace: "normal"
|
|
25
|
-
})), A = g("div")(({ theme: e }) => ({
|
|
26
|
-
verticalAlign: "middle",
|
|
27
|
-
marginBottom: e.spacing(1)
|
|
28
|
-
})), j = g(S)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), M = {
|
|
29
|
-
model: n.object,
|
|
30
|
-
session: n.object,
|
|
31
|
-
onSelectionChange: n.func.isRequired
|
|
32
|
-
}, N = class extends t.Component {
|
|
33
|
-
static propTypes = M;
|
|
34
|
-
static defaultProps = {};
|
|
35
|
-
constructor(t) {
|
|
36
|
-
super(t), this.state = {
|
|
37
|
-
showCorrectAnswer: this.props.model.alwaysShowCorrect || !1,
|
|
38
|
-
model: e(t.model)
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
UNSAFE_componentWillReceiveProps(t) {
|
|
42
|
-
this.setState({
|
|
43
|
-
showCorrectAnswer: !!t.model.alwaysShowCorrect,
|
|
44
|
-
model: e(t.model)
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
toggleShowCorrect = () => {
|
|
48
|
-
this.setState({ showCorrectAnswer: !this.state.showCorrectAnswer });
|
|
49
|
-
};
|
|
50
|
-
correctAnswer = () => {
|
|
51
|
-
let { model: e } = this.state;
|
|
52
|
-
return e.tokens.filter((e) => e.correct);
|
|
53
|
-
};
|
|
54
|
-
render() {
|
|
55
|
-
let { session: e, onSelectionChange: t } = this.props, { showCorrectAnswer: n, model: i } = this.state, { env: o, extraCSSRules: s } = i, { mode: c } = o || {}, l = n ? this.correctAnswer() : e.selectedTokens, u = i.rationale && (p(i.rationale) || f(i.rationale)), d = i.teacherInstructions && (p(i.teacherInstructions) || f(i.teacherInstructions));
|
|
56
|
-
return D("[render] selectedTokens:", l), /* @__PURE__ */ h(O, {
|
|
57
|
-
extraCSSRules: s,
|
|
58
|
-
children: [
|
|
59
|
-
d && (i.animationsDisabled ? /* @__PURE__ */ m(A, { children: /* @__PURE__ */ m(x, { prompt: i.teacherInstructions }) }) : /* @__PURE__ */ m(j, {
|
|
60
|
-
labels: {
|
|
61
|
-
hidden: "Show Teacher Instructions",
|
|
62
|
-
visible: "Hide Teacher Instructions"
|
|
63
|
-
},
|
|
64
|
-
children: /* @__PURE__ */ m(x, { prompt: i.teacherInstructions })
|
|
65
|
-
})),
|
|
66
|
-
/* @__PURE__ */ m(A, { children: /* @__PURE__ */ m(x, { prompt: i.prompt }) }),
|
|
67
|
-
!i.alwaysShowCorrect && /* @__PURE__ */ m(a, {
|
|
68
|
-
show: i.disabled && i.incorrect,
|
|
69
|
-
toggled: n,
|
|
70
|
-
onToggle: this.toggleShowCorrect,
|
|
71
|
-
language: i.language
|
|
72
|
-
}),
|
|
73
|
-
/* @__PURE__ */ m(k, {
|
|
74
|
-
disabled: i.disabled,
|
|
75
|
-
text: i.text,
|
|
76
|
-
tokens: i.tokens,
|
|
77
|
-
selectedTokens: l,
|
|
78
|
-
onChange: (e) => {
|
|
79
|
-
t(e.map((e) => i.tokens.find(({ start: t, end: n }) => e.start === t && e.end === n) || e));
|
|
80
|
-
},
|
|
81
|
-
highlightChoices: i.highlightChoices,
|
|
82
|
-
maxNoOfSelections: i.maxSelections,
|
|
83
|
-
animationsDisabled: i.animationsDisabled
|
|
84
|
-
}),
|
|
85
|
-
c === "evaluate" && /* @__PURE__ */ m(r, {
|
|
86
|
-
language: i.language,
|
|
87
|
-
showOnlyCorrect: n
|
|
88
|
-
}),
|
|
89
|
-
u && (i.animationsDisabled ? /* @__PURE__ */ m(A, { children: /* @__PURE__ */ m(x, { prompt: i.rationale }) }) : /* @__PURE__ */ m(j, {
|
|
90
|
-
labels: {
|
|
91
|
-
hidden: "Show Rationale",
|
|
92
|
-
visible: "Hide Rationale"
|
|
93
|
-
},
|
|
94
|
-
children: /* @__PURE__ */ m(x, { prompt: i.rationale })
|
|
95
|
-
})),
|
|
96
|
-
i.correctness && i.feedback && !n && /* @__PURE__ */ m(C, {
|
|
97
|
-
correctness: i.correctness,
|
|
98
|
-
feedback: i.feedback
|
|
99
|
-
})
|
|
100
|
-
]
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}, P = class extends t.Component {
|
|
104
|
-
static propTypes = M;
|
|
105
|
-
constructor(e) {
|
|
106
|
-
super(e), this.state = {
|
|
107
|
-
model: e.model,
|
|
108
|
-
session: e.session
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
UNSAFE_componentWillReceiveProps(e) {
|
|
112
|
-
this.setState({
|
|
113
|
-
model: e.model,
|
|
114
|
-
session: e.session
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
change = (e) => {
|
|
118
|
-
let t = {
|
|
119
|
-
...this.state.session,
|
|
120
|
-
selectedTokens: e
|
|
121
|
-
};
|
|
122
|
-
this.setState({ session: t }, () => {
|
|
123
|
-
this.props.onSelectionChange(this.state.session.selectedTokens);
|
|
124
|
-
});
|
|
125
|
-
};
|
|
126
|
-
render() {
|
|
127
|
-
let { model: e, session: t } = this.state;
|
|
128
|
-
return /* @__PURE__ */ m(N, {
|
|
129
|
-
model: e,
|
|
130
|
-
session: t,
|
|
131
|
-
onSelectionChange: this.change
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
//#endregion
|
|
136
|
-
export { P as default };
|
package/dist/delivery/utils.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @synced-from pie-elements/packages/select-text/src/utils.js
|
|
3
|
-
* @auto-generated
|
|
4
|
-
*
|
|
5
|
-
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
-
* Manual edits will be overwritten on next sync.
|
|
7
|
-
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
-
*/
|
|
9
|
-
declare const _default: (model: any) => any;
|
|
10
|
-
export default _default;
|
package/dist/delivery/utils.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
//#region src/delivery/utils.tsx
|
|
2
|
-
var e = function() {
|
|
3
|
-
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", t = document.createElement("div");
|
|
4
|
-
return t.innerHTML = e.trim(), t;
|
|
5
|
-
}, t = function(e, t) {
|
|
6
|
-
return t ? e.innerHTML : `${e.innerHTML}
|
|
7
|
-
|
|
8
|
-
`;
|
|
9
|
-
}, n = function(e) {
|
|
10
|
-
var n = e.querySelectorAll("div[separator=true]"), r = "";
|
|
11
|
-
return n.forEach(function(e, i) {
|
|
12
|
-
r += t(e, i === n.length - 1);
|
|
13
|
-
}), r || null;
|
|
14
|
-
}, r = function(t) {
|
|
15
|
-
var r = e(t), i = document.createElement("div");
|
|
16
|
-
return i.innerHTML = `<div separator='true'>${r.innerHTML}</div>`, r = i, Array.from(r.querySelectorAll("*")).length === 0 ? t : n(r);
|
|
17
|
-
}, i = (e) => {
|
|
18
|
-
if (!e) return e;
|
|
19
|
-
let t = r(e.text || ""), n = (e.tokens || []).reduce((n, i = {}) => {
|
|
20
|
-
let a = r((e.text || "").slice(i.start, i.end));
|
|
21
|
-
if (!a) return [...n, i];
|
|
22
|
-
let o = (e) => {
|
|
23
|
-
let n = e;
|
|
24
|
-
for (; n >= 0;) {
|
|
25
|
-
let e = t.slice(n).indexOf(a);
|
|
26
|
-
if (e >= 0) return e + n;
|
|
27
|
-
n--;
|
|
28
|
-
}
|
|
29
|
-
return 0;
|
|
30
|
-
}, s = n[n.length - 1], c = o(s ? s.end : i.start), l = c + a.length;
|
|
31
|
-
return [...n, {
|
|
32
|
-
...i,
|
|
33
|
-
text: a,
|
|
34
|
-
start: c,
|
|
35
|
-
end: l,
|
|
36
|
-
oldStart: i.start,
|
|
37
|
-
oldEnd: i.end
|
|
38
|
-
}];
|
|
39
|
-
}, []);
|
|
40
|
-
return {
|
|
41
|
-
...e,
|
|
42
|
-
tokens: n,
|
|
43
|
-
text: t
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
//#endregion
|
|
47
|
-
export { i as default };
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './delivery/index.js';
|
package/dist/index.iife.d.ts
DELETED