@pie-element/drag-in-the-blank 10.2.2-beta.5 → 10.2.2-beta.6
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.md +4 -0
- package/configure/CHANGELOG.md +4 -0
- package/configure/package.json +3 -3
- package/controller/CHANGELOG.md +4 -0
- package/controller/package.json +1 -1
- package/package.json +3 -3
- package/configure/lib/choice.js +0 -137
- package/configure/lib/choice.js.map +0 -1
- package/configure/lib/choices.js +0 -332
- package/configure/lib/choices.js.map +0 -1
- package/configure/lib/defaults.js +0 -169
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/index.js +0 -148
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/main.js +0 -440
- package/configure/lib/main.js.map +0 -1
- package/configure/lib/markupUtils.js +0 -83
- package/configure/lib/markupUtils.js.map +0 -1
- package/controller/lib/defaults.js +0 -24
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -251
- package/controller/lib/index.js.map +0 -1
- package/controller/lib/utils.js +0 -39
- package/controller/lib/utils.js.map +0 -1
- package/lib/index.js +0 -207
- package/lib/index.js.map +0 -1
- package/lib/main.js +0 -126
- package/lib/main.js.map +0 -1
package/controller/lib/index.js
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.getScore = exports.getLogTrace = exports.createCorrectResponseSession = void 0;
|
|
8
|
-
exports.model = model;
|
|
9
|
-
exports.normalize = void 0;
|
|
10
|
-
exports.outcome = outcome;
|
|
11
|
-
exports.validate = void 0;
|
|
12
|
-
var _lodashEs = require("lodash-es");
|
|
13
|
-
var _utils = require("./utils");
|
|
14
|
-
var _controllerUtils = require("@pie-lib/controller-utils");
|
|
15
|
-
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
16
|
-
const normalize = question => ({
|
|
17
|
-
..._defaults.default,
|
|
18
|
-
...question
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {*} question
|
|
24
|
-
* @param {*} session
|
|
25
|
-
* @param {*} env
|
|
26
|
-
* @param {*} updateSession - optional - a function that will set the properties passed into it on the session.
|
|
27
|
-
*/
|
|
28
|
-
exports.normalize = normalize;
|
|
29
|
-
async function model(question, session, env, updateSession) {
|
|
30
|
-
const normalizedQuestion = normalize(question);
|
|
31
|
-
let feedback = {};
|
|
32
|
-
if (env.mode === 'evaluate') {
|
|
33
|
-
const responses = (0, _utils.getAllCorrectResponses)(normalizedQuestion) || {};
|
|
34
|
-
const allCorrectResponses = responses.possibleResponses;
|
|
35
|
-
const numberOfPossibleResponses = responses.numberOfPossibleResponses || 0;
|
|
36
|
-
let correctResponses = undefined;
|
|
37
|
-
const {
|
|
38
|
-
value
|
|
39
|
-
} = session || {};
|
|
40
|
-
for (let i = 0; i < numberOfPossibleResponses; i++) {
|
|
41
|
-
const result = Object.keys(allCorrectResponses).reduce((obj, key) => {
|
|
42
|
-
const choices = allCorrectResponses[key];
|
|
43
|
-
const answer = value && value[key] || '';
|
|
44
|
-
obj.feedback[key] = choices[i] === answer;
|
|
45
|
-
if (obj.feedback[key]) {
|
|
46
|
-
obj.correctResponses += 1;
|
|
47
|
-
}
|
|
48
|
-
return obj;
|
|
49
|
-
}, {
|
|
50
|
-
correctResponses: 0,
|
|
51
|
-
feedback: {}
|
|
52
|
-
});
|
|
53
|
-
if (correctResponses === undefined || result.correctResponses > correctResponses) {
|
|
54
|
-
correctResponses = result.correctResponses;
|
|
55
|
-
feedback = result.feedback;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
let choices = normalizedQuestion.choices && normalizedQuestion.choices.filter(choice => !(0, _utils.choiceIsEmpty)(choice));
|
|
60
|
-
const lockChoiceOrder = (0, _controllerUtils.lockChoices)(normalizedQuestion, session, env);
|
|
61
|
-
if (!lockChoiceOrder) {
|
|
62
|
-
choices = await (0, _controllerUtils.getShuffledChoices)(choices, session, updateSession, 'id');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// we don't need to check for fewer areas to be filled in the alternateResponses
|
|
66
|
-
// because the alternates are an option in the default correct response (for scoring)
|
|
67
|
-
const responseAreasToBeFilled = Object.values(normalizedQuestion.correctResponse || {}).filter(value => !!value).length;
|
|
68
|
-
const shouldIncludeCorrectResponse = env.mode === 'evaluate';
|
|
69
|
-
const out = {
|
|
70
|
-
...normalizedQuestion,
|
|
71
|
-
prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,
|
|
72
|
-
choices,
|
|
73
|
-
feedback,
|
|
74
|
-
mode: env.mode,
|
|
75
|
-
disabled: env.mode !== 'gather',
|
|
76
|
-
responseCorrect: shouldIncludeCorrectResponse ? getScore(normalizedQuestion, session) === 1 : undefined,
|
|
77
|
-
correctResponse: shouldIncludeCorrectResponse ? normalizedQuestion.correctResponse : undefined,
|
|
78
|
-
responseAreasToBeFilled
|
|
79
|
-
};
|
|
80
|
-
if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
|
|
81
|
-
out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;
|
|
82
|
-
out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
|
|
83
|
-
} else {
|
|
84
|
-
out.rationale = null;
|
|
85
|
-
out.teacherInstructions = null;
|
|
86
|
-
}
|
|
87
|
-
return out;
|
|
88
|
-
}
|
|
89
|
-
const getScore = (config, session) => {
|
|
90
|
-
const responses = (0, _utils.getAllCorrectResponses)(config);
|
|
91
|
-
const allCorrectResponses = responses.possibleResponses;
|
|
92
|
-
const maxScore = Object.keys(config.correctResponse).length;
|
|
93
|
-
const numberOfPossibleResponses = responses.numberOfPossibleResponses || 0;
|
|
94
|
-
let correctCount = 0;
|
|
95
|
-
const {
|
|
96
|
-
value
|
|
97
|
-
} = session || {};
|
|
98
|
-
for (let i = 0; i < numberOfPossibleResponses; i++) {
|
|
99
|
-
const result = Object.keys(allCorrectResponses).reduce((total, key) => {
|
|
100
|
-
const choices = allCorrectResponses[key];
|
|
101
|
-
const answer = value && value[key] || '';
|
|
102
|
-
if (choices[i] === answer) {
|
|
103
|
-
return total;
|
|
104
|
-
}
|
|
105
|
-
return total - 1;
|
|
106
|
-
}, maxScore);
|
|
107
|
-
if (result > correctCount) {
|
|
108
|
-
correctCount = result;
|
|
109
|
-
}
|
|
110
|
-
if (result === maxScore) {
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
const str = maxScore ? (correctCount / maxScore).toFixed(2) : 0;
|
|
115
|
-
return parseFloat(str);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Generates detailed trace log for scoring evaluation
|
|
120
|
-
* @param {Object} model - the question model
|
|
121
|
-
* @param {Object} session - the student session
|
|
122
|
-
* @param {Object} env - the environment
|
|
123
|
-
* @returns {Array} traceLog - array of trace messages
|
|
124
|
-
*/
|
|
125
|
-
exports.getScore = getScore;
|
|
126
|
-
const getLogTrace = (model, session, env) => {
|
|
127
|
-
const traceLog = [];
|
|
128
|
-
const {
|
|
129
|
-
value
|
|
130
|
-
} = session || {};
|
|
131
|
-
const responseAreas = Object.keys(model.correctResponse || {});
|
|
132
|
-
const totalAreas = responseAreas.length;
|
|
133
|
-
traceLog.push(`${totalAreas} response area(s) defined in this question.`);
|
|
134
|
-
if (value && Object.keys(value).length > 0) {
|
|
135
|
-
const filledAreas = Object.entries(value).filter(([key, val]) => val && val.trim()).length;
|
|
136
|
-
traceLog.push(`Student added choices to ${filledAreas} out of ${totalAreas} response area(s).`);
|
|
137
|
-
responseAreas.forEach(areaKey => {
|
|
138
|
-
const studentAnswer = value && value[areaKey] || '';
|
|
139
|
-
const correctAnswer = model.correctResponse[areaKey] || '';
|
|
140
|
-
if (studentAnswer.trim()) {
|
|
141
|
-
traceLog.push(`Response area ${areaKey}: student placed '${studentAnswer}' (correct answer: '${correctAnswer}').`);
|
|
142
|
-
} else {
|
|
143
|
-
traceLog.push(`Response area ${areaKey}: left empty (correct answer: '${correctAnswer}').`);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
} else {
|
|
147
|
-
traceLog.push('Student did not add any choices to response areas.');
|
|
148
|
-
}
|
|
149
|
-
const responses = (0, _utils.getAllCorrectResponses)(model);
|
|
150
|
-
const allCorrectResponses = responses.possibleResponses;
|
|
151
|
-
const numberOfPossibleResponses = responses.numberOfPossibleResponses || 0;
|
|
152
|
-
if (numberOfPossibleResponses > 1) {
|
|
153
|
-
traceLog.push(`${numberOfPossibleResponses} alternate response combinations are accepted for this question.`);
|
|
154
|
-
}
|
|
155
|
-
const partialScoringEnabled = _controllerUtils.partialScoring.enabled(model, env);
|
|
156
|
-
const scoringMethod = partialScoringEnabled ? 'partial scoring' : 'all-or-nothing scoring';
|
|
157
|
-
traceLog.push(`Score calculated using ${scoringMethod}.`);
|
|
158
|
-
const score = getScore(model, session);
|
|
159
|
-
traceLog.push(`Final score: ${score}.`);
|
|
160
|
-
return traceLog;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
*
|
|
165
|
-
* The score is partial by default for checkbox mode, allOrNothing for radio mode.
|
|
166
|
-
* To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =
|
|
167
|
-
* false. the value in `env` will override the value in `model`.
|
|
168
|
-
* @param {Object} model - the main model
|
|
169
|
-
* @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)
|
|
170
|
-
* @param {*} session
|
|
171
|
-
* @param {Object} env
|
|
172
|
-
* @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides
|
|
173
|
-
* `model.partialScoring`.
|
|
174
|
-
*/
|
|
175
|
-
exports.getLogTrace = getLogTrace;
|
|
176
|
-
function outcome(model, session, env = {}) {
|
|
177
|
-
return new Promise(resolve => {
|
|
178
|
-
if (!session || (0, _lodashEs.isEmpty)(session)) {
|
|
179
|
-
resolve({
|
|
180
|
-
score: 0,
|
|
181
|
-
empty: true,
|
|
182
|
-
traceLog: ['Student did not add any choices to response areas. Score is 0.']
|
|
183
|
-
});
|
|
184
|
-
} else {
|
|
185
|
-
const traceLog = getLogTrace(model, session, env);
|
|
186
|
-
const score = getScore(model, session);
|
|
187
|
-
const partialScoringEnabled = _controllerUtils.partialScoring.enabled(model, env);
|
|
188
|
-
resolve({
|
|
189
|
-
score: partialScoringEnabled ? score : score === 1 ? 1 : 0,
|
|
190
|
-
empty: false,
|
|
191
|
-
traceLog
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
const createCorrectResponseSession = (question, env) => {
|
|
197
|
-
return new Promise(resolve => {
|
|
198
|
-
if (env.mode !== 'evaluate' && env.role === 'instructor') {
|
|
199
|
-
resolve({
|
|
200
|
-
value: question.correctResponse,
|
|
201
|
-
id: '1'
|
|
202
|
-
});
|
|
203
|
-
} else {
|
|
204
|
-
resolve(null);
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
// remove all html tags
|
|
210
|
-
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
211
|
-
const getInnerText = html => (html || '').replaceAll(/<[^>]*>/g, '');
|
|
212
|
-
|
|
213
|
-
// remove all html tags except img, iframe and source tag for audio
|
|
214
|
-
const getContent = html => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
|
|
215
|
-
const validate = (model = {}, config = {}) => {
|
|
216
|
-
const {
|
|
217
|
-
choices,
|
|
218
|
-
correctResponse,
|
|
219
|
-
markup
|
|
220
|
-
} = model;
|
|
221
|
-
const {
|
|
222
|
-
minChoices = 2,
|
|
223
|
-
maxChoices,
|
|
224
|
-
maxResponseAreas
|
|
225
|
-
} = config;
|
|
226
|
-
const errors = {};
|
|
227
|
-
['teacherInstructions', 'prompt', 'rationale'].forEach(field => {
|
|
228
|
-
if (config[field]?.required && !getContent(model[field])) {
|
|
229
|
-
errors[field] = 'This field is required.';
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
const nbOfResponseAreas = ((markup || '').match(/\{\{(\d+)\}\}/g) || []).length;
|
|
233
|
-
const nbOfChoices = (choices || []).length;
|
|
234
|
-
const emptyResponseAreas = Object.values(correctResponse)?.filter(response => !response);
|
|
235
|
-
if (emptyResponseAreas.length) {
|
|
236
|
-
errors.correctResponseError = 'There should be a choice defined for each response area.';
|
|
237
|
-
}
|
|
238
|
-
if (nbOfResponseAreas > maxResponseAreas) {
|
|
239
|
-
errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;
|
|
240
|
-
} else if (nbOfResponseAreas < 1) {
|
|
241
|
-
errors.responseAreasError = 'There should be at least 1 response area defined.';
|
|
242
|
-
}
|
|
243
|
-
if (nbOfChoices < minChoices) {
|
|
244
|
-
errors.choicesError = `There should be at least ${minChoices} tokens defined.`;
|
|
245
|
-
} else if (nbOfChoices > maxChoices) {
|
|
246
|
-
errors.choicesError = `No more than ${maxChoices} tokens should be defined.`;
|
|
247
|
-
}
|
|
248
|
-
return errors;
|
|
249
|
-
};
|
|
250
|
-
exports.validate = validate;
|
|
251
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_lodashEs","require","_utils","_controllerUtils","_defaults","_interopRequireDefault","normalize","question","defaults","exports","model","session","env","updateSession","normalizedQuestion","feedback","mode","responses","getAllCorrectResponses","allCorrectResponses","possibleResponses","numberOfPossibleResponses","correctResponses","undefined","value","i","result","Object","keys","reduce","obj","key","choices","answer","filter","choice","choiceIsEmpty","lockChoiceOrder","lockChoices","getShuffledChoices","responseAreasToBeFilled","values","correctResponse","length","shouldIncludeCorrectResponse","out","prompt","promptEnabled","disabled","responseCorrect","getScore","role","rationale","rationaleEnabled","teacherInstructions","teacherInstructionsEnabled","config","maxScore","correctCount","total","str","toFixed","parseFloat","getLogTrace","traceLog","responseAreas","totalAreas","push","filledAreas","entries","val","trim","forEach","areaKey","studentAnswer","correctAnswer","partialScoringEnabled","partialScoring","enabled","scoringMethod","score","outcome","Promise","resolve","isEmpty","empty","createCorrectResponseSession","id","getInnerText","html","replaceAll","getContent","replace","validate","markup","minChoices","maxChoices","maxResponseAreas","errors","field","required","nbOfResponseAreas","match","nbOfChoices","emptyResponseAreas","response","correctResponseError","responseAreasError","choicesError"],"sources":["../src/index.js"],"sourcesContent":["import { isEmpty } from 'lodash-es';\nimport { getAllCorrectResponses, choiceIsEmpty } from './utils';\nimport { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils';\nimport defaults from './defaults';\n\nexport const normalize = (question) => ({\n ...defaults,\n ...question,\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.\n */\nexport async function model(question, session, env, updateSession) {\n const normalizedQuestion = normalize(question);\n let feedback = {};\n\n if (env.mode === 'evaluate') {\n const responses = getAllCorrectResponses(normalizedQuestion) || {};\n const allCorrectResponses = responses.possibleResponses;\n const numberOfPossibleResponses = responses.numberOfPossibleResponses || 0;\n let correctResponses = undefined;\n const { value } = session || {};\n\n for (let i = 0; i < numberOfPossibleResponses; i++) {\n const result = Object.keys(allCorrectResponses).reduce(\n (obj, key) => {\n const choices = allCorrectResponses[key];\n const answer = (value && value[key]) || '';\n\n obj.feedback[key] = choices[i] === answer;\n\n if (obj.feedback[key]) {\n obj.correctResponses += 1;\n }\n\n return obj;\n },\n { correctResponses: 0, feedback: {} },\n );\n\n if (correctResponses === undefined || result.correctResponses > correctResponses) {\n correctResponses = result.correctResponses;\n feedback = result.feedback;\n }\n }\n }\n\n let choices = normalizedQuestion.choices && normalizedQuestion.choices.filter((choice) => !choiceIsEmpty(choice));\n\n const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);\n\n if (!lockChoiceOrder) {\n choices = await getShuffledChoices(choices, session, updateSession, 'id');\n }\n\n // we don't need to check for fewer areas to be filled in the alternateResponses\n // because the alternates are an option in the default correct response (for scoring)\n const responseAreasToBeFilled = Object.values(normalizedQuestion.correctResponse || {}).filter(\n (value) => !!value,\n ).length;\n\n const shouldIncludeCorrectResponse = env.mode === 'evaluate';\n\n const out = {\n ...normalizedQuestion,\n prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,\n choices,\n feedback,\n mode: env.mode,\n disabled: env.mode !== 'gather',\n responseCorrect: shouldIncludeCorrectResponse ? getScore(normalizedQuestion, session) === 1 : undefined,\n correctResponse: shouldIncludeCorrectResponse ? normalizedQuestion.correctResponse : undefined,\n responseAreasToBeFilled,\n };\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n out.rationale = null;\n out.teacherInstructions = null;\n }\n\n return out;\n}\n\nexport const getScore = (config, session) => {\n const responses = getAllCorrectResponses(config);\n const allCorrectResponses = responses.possibleResponses;\n const maxScore = Object.keys(config.correctResponse).length;\n const numberOfPossibleResponses = responses.numberOfPossibleResponses || 0;\n let correctCount = 0;\n const { value } = session || {};\n\n for (let i = 0; i < numberOfPossibleResponses; i++) {\n const result = Object.keys(allCorrectResponses).reduce((total, key) => {\n const choices = allCorrectResponses[key];\n const answer = (value && value[key]) || '';\n\n if (choices[i] === answer) {\n return total;\n }\n\n return total - 1;\n }, maxScore);\n\n if (result > correctCount) {\n correctCount = result;\n }\n\n if (result === maxScore) {\n break;\n }\n }\n\n const str = maxScore ? (correctCount / maxScore).toFixed(2) : 0;\n\n return parseFloat(str);\n};\n\n/**\n * Generates detailed trace log for scoring evaluation\n * @param {Object} model - the question model\n * @param {Object} session - the student session\n * @param {Object} env - the environment\n * @returns {Array} traceLog - array of trace messages\n */\nexport const getLogTrace = (model, session, env) => {\n const traceLog = [];\n const { value } = session || {};\n \n const responseAreas = Object.keys(model.correctResponse || {});\n const totalAreas = responseAreas.length;\n traceLog.push(`${totalAreas} response area(s) defined in this question.`);\n \n if (value && Object.keys(value).length > 0) {\n const filledAreas = Object.entries(value).filter(([key, val]) => val && val.trim()).length;\n traceLog.push(`Student added choices to ${filledAreas} out of ${totalAreas} response area(s).`);\n \n responseAreas.forEach((areaKey) => {\n const studentAnswer = (value && value[areaKey]) || '';\n const correctAnswer = model.correctResponse[areaKey] || '';\n \n if (studentAnswer.trim()) {\n traceLog.push(`Response area ${areaKey}: student placed '${studentAnswer}' (correct answer: '${correctAnswer}').`);\n } else {\n traceLog.push(`Response area ${areaKey}: left empty (correct answer: '${correctAnswer}').`);\n }\n });\n } else {\n traceLog.push('Student did not add any choices to response areas.');\n }\n\n const responses = getAllCorrectResponses(model);\n const allCorrectResponses = responses.possibleResponses;\n const numberOfPossibleResponses = responses.numberOfPossibleResponses || 0;\n \n if (numberOfPossibleResponses > 1) {\n traceLog.push(`${numberOfPossibleResponses} alternate response combinations are accepted for this question.`);\n }\n\n const partialScoringEnabled = partialScoring.enabled(model, env);\n const scoringMethod = partialScoringEnabled ? 'partial scoring' : 'all-or-nothing scoring';\n traceLog.push(`Score calculated using ${scoringMethod}.`);\n\n const score = getScore(model, session);\n traceLog.push(`Final score: ${score}.`);\n\n return traceLog;\n};\n\n/**\n *\n * The score is partial by default for checkbox mode, allOrNothing for radio mode.\n * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring =\n * false. the value in `env` will override the value in `model`.\n * @param {Object} model - the main model\n * @param {boolean} model.partialScoring - is partial scoring enabled (if undefined set to to true)\n * @param {*} session\n * @param {Object} env\n * @param {boolean} env.partialScoring - is partial scoring enabled (if undefined default to true) This overrides\n * `model.partialScoring`.\n */\nexport function outcome(model, session, env = {}) {\n return new Promise((resolve) => {\n if (!session || isEmpty(session)) {\n resolve({ \n score: 0, \n empty: true, \n traceLog: ['Student did not add any choices to response areas. Score is 0.'] \n });\n } else {\n const traceLog = getLogTrace(model, session, env);\n const score = getScore(model, session);\n const partialScoringEnabled = partialScoring.enabled(model, env);\n\n resolve({\n score: partialScoringEnabled ? score : score === 1 ? 1 : 0,\n empty: false,\n traceLog\n });\n }\n });\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n resolve({\n value: question.correctResponse,\n id: '1',\n });\n } else {\n resolve(null);\n }\n });\n};\n\n// remove all html tags\nconst getInnerText = (html) => (html || '').replaceAll(/<[^>]*>/g, '');\n\n// remove all html tags except img, iframe and source tag for audio\nconst getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');\n\nexport const validate = (model = {}, config = {}) => {\n const { choices, correctResponse, markup } = model;\n const { minChoices = 2, maxChoices, maxResponseAreas } = config;\n const errors = {};\n\n ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {\n if (config[field]?.required && !getContent(model[field])) {\n errors[field] = 'This field is required.';\n }\n });\n\n const nbOfResponseAreas = ((markup || '').match(/\\{\\{(\\d+)\\}\\}/g) || []).length;\n const nbOfChoices = (choices || []).length;\n const emptyResponseAreas = Object.values(correctResponse)?.filter((response) => !response);\n\n if (emptyResponseAreas.length) {\n errors.correctResponseError = 'There should be a choice defined for each response area.';\n }\n\n if (nbOfResponseAreas > maxResponseAreas) {\n errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;\n } else if (nbOfResponseAreas < 1) {\n errors.responseAreasError = 'There should be at least 1 response area defined.';\n }\n\n if (nbOfChoices < minChoices) {\n errors.choicesError = `There should be at least ${minChoices} tokens defined.`;\n } else if (nbOfChoices > maxChoices) {\n errors.choicesError = `No more than ${maxChoices} tokens should be defined.`;\n }\n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AK,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE3D,MAAM;EAC/E,MAAM4D,WAAW,GAAG,CAACvE,OAAO,IAAI,EAAE,EAAEW,MAAM;EAC1C,MAAM6D,kBAAkB,GAAG7E,MAAM,CAACc,MAAM,CAACC,eAAe,CAAC,EAAER,MAAM,CAAEuE,QAAQ,IAAK,CAACA,QAAQ,CAAC;EAE1F,IAAID,kBAAkB,CAAC7D,MAAM,EAAE;IAC7BuD,MAAM,CAACQ,oBAAoB,GAAG,0DAA0D;EAC1F;EAEA,IAAIL,iBAAiB,GAAGJ,gBAAgB,EAAE;IACxCC,MAAM,CAACS,kBAAkB,GAAG,gBAAgBV,gBAAgB,oCAAoC;EAClG,CAAC,MAAM,IAAII,iBAAiB,GAAG,CAAC,EAAE;IAChCH,MAAM,CAACS,kBAAkB,GAAG,mDAAmD;EACjF;EAEA,IAAIJ,WAAW,GAAGR,UAAU,EAAE;IAC5BG,MAAM,CAACU,YAAY,GAAG,4BAA4Bb,UAAU,kBAAkB;EAChF,CAAC,MAAM,IAAIQ,WAAW,GAAGP,UAAU,EAAE;IACnCE,MAAM,CAACU,YAAY,GAAG,gBAAgBZ,UAAU,4BAA4B;EAC9E;EAEA,OAAOE,MAAM;AACf,CAAC;AAACzF,OAAA,CAAAoF,QAAA,GAAAA,QAAA","ignoreList":[]}
|
package/controller/lib/utils.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getAllCorrectResponses = exports.choiceIsEmpty = void 0;
|
|
7
|
-
var _lodashEs = require("lodash-es");
|
|
8
|
-
const replaceHtmlRegex = /<(?!img)[^>]*>?/gm;
|
|
9
|
-
const getAllCorrectResponses = ({
|
|
10
|
-
correctResponse,
|
|
11
|
-
alternateResponses
|
|
12
|
-
}) => {
|
|
13
|
-
return (0, _lodashEs.reduce)(correctResponse || {}, (obj, val, key) => {
|
|
14
|
-
obj.possibleResponses[key] = [val];
|
|
15
|
-
if (alternateResponses && alternateResponses[key]) {
|
|
16
|
-
obj.possibleResponses[key] = [...obj.possibleResponses[key], ...(0, _lodashEs.cloneDeep)(alternateResponses[key])];
|
|
17
|
-
}
|
|
18
|
-
if (obj.numberOfPossibleResponses === undefined || obj.numberOfPossibleResponses > obj.possibleResponses[key].length) {
|
|
19
|
-
obj.numberOfPossibleResponses = obj.possibleResponses[key].length;
|
|
20
|
-
}
|
|
21
|
-
return obj;
|
|
22
|
-
}, {
|
|
23
|
-
possibleResponses: {},
|
|
24
|
-
numberOfPossibleResponses: undefined
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
exports.getAllCorrectResponses = getAllCorrectResponses;
|
|
28
|
-
const choiceIsEmpty = choice => {
|
|
29
|
-
if (choice) {
|
|
30
|
-
const {
|
|
31
|
-
value = ''
|
|
32
|
-
} = choice;
|
|
33
|
-
const withoutEmptyTags = value.replace(replaceHtmlRegex, '') || '';
|
|
34
|
-
return withoutEmptyTags.trim() === '';
|
|
35
|
-
}
|
|
36
|
-
return false;
|
|
37
|
-
};
|
|
38
|
-
exports.choiceIsEmpty = choiceIsEmpty;
|
|
39
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["_lodashEs","require","replaceHtmlRegex","getAllCorrectResponses","correctResponse","alternateResponses","reduce","obj","val","key","possibleResponses","cloneDeep","numberOfPossibleResponses","undefined","length","exports","choiceIsEmpty","choice","value","withoutEmptyTags","replace","trim"],"sources":["../src/utils.js"],"sourcesContent":["import { cloneDeep, reduce } from 'lodash-es';\n\nconst replaceHtmlRegex = /<(?!img)[^>]*>?/gm;\n\nexport const getAllCorrectResponses = ({ correctResponse, alternateResponses }) => {\n return reduce(\n correctResponse || {},\n (obj, val, key) => {\n obj.possibleResponses[key] = [val];\n\n if (alternateResponses && alternateResponses[key]) {\n obj.possibleResponses[key] = [...obj.possibleResponses[key], ...cloneDeep(alternateResponses[key])];\n }\n\n if (\n obj.numberOfPossibleResponses === undefined ||\n obj.numberOfPossibleResponses > obj.possibleResponses[key].length\n ) {\n obj.numberOfPossibleResponses = obj.possibleResponses[key].length;\n }\n\n return obj;\n },\n {\n possibleResponses: {},\n numberOfPossibleResponses: undefined,\n },\n );\n};\n\nexport const choiceIsEmpty = (choice) => {\n if (choice) {\n const { value = '' } = choice;\n const withoutEmptyTags = value.replace(replaceHtmlRegex, '') || '';\n\n return withoutEmptyTags.trim() === '';\n }\n\n return false;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,MAAMC,gBAAgB,GAAG,mBAAmB;AAErC,MAAMC,sBAAsB,GAAGA,CAAC;EAAEC,eAAe;EAAEC;AAAmB,CAAC,KAAK;EACjF,OAAO,IAAAC,gBAAM,EACXF,eAAe,IAAI,CAAC,CAAC,EACrB,CAACG,GAAG,EAAEC,GAAG,EAAEC,GAAG,KAAK;IACjBF,GAAG,CAACG,iBAAiB,CAACD,GAAG,CAAC,GAAG,CAACD,GAAG,CAAC;IAElC,IAAIH,kBAAkB,IAAIA,kBAAkB,CAACI,GAAG,CAAC,EAAE;MACjDF,GAAG,CAACG,iBAAiB,CAACD,GAAG,CAAC,GAAG,CAAC,GAAGF,GAAG,CAACG,iBAAiB,CAACD,GAAG,CAAC,EAAE,GAAG,IAAAE,mBAAS,EAACN,kBAAkB,CAACI,GAAG,CAAC,CAAC,CAAC;IACrG;IAEA,IACEF,GAAG,CAACK,yBAAyB,KAAKC,SAAS,IAC3CN,GAAG,CAACK,yBAAyB,GAAGL,GAAG,CAACG,iBAAiB,CAACD,GAAG,CAAC,CAACK,MAAM,EACjE;MACAP,GAAG,CAACK,yBAAyB,GAAGL,GAAG,CAACG,iBAAiB,CAACD,GAAG,CAAC,CAACK,MAAM;IACnE;IAEA,OAAOP,GAAG;EACZ,CAAC,EACD;IACEG,iBAAiB,EAAE,CAAC,CAAC;IACrBE,yBAAyB,EAAEC;EAC7B,CACF,CAAC;AACH,CAAC;AAACE,OAAA,CAAAZ,sBAAA,GAAAA,sBAAA;AAEK,MAAMa,aAAa,GAAIC,MAAM,IAAK;EACvC,IAAIA,MAAM,EAAE;IACV,MAAM;MAAEC,KAAK,GAAG;IAAG,CAAC,GAAGD,MAAM;IAC7B,MAAME,gBAAgB,GAAGD,KAAK,CAACE,OAAO,CAAClB,gBAAgB,EAAE,EAAE,CAAC,IAAI,EAAE;IAElE,OAAOiB,gBAAgB,CAACE,IAAI,CAAC,CAAC,KAAK,EAAE;EACvC;EAEA,OAAO,KAAK;AACd,CAAC;AAACN,OAAA,CAAAC,aAAA,GAAAA,aAAA","ignoreList":[]}
|
package/lib/index.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.isComplete = exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _client = require("react-dom/client");
|
|
11
|
-
var _mathRendering = require("@pie-lib/math-rendering");
|
|
12
|
-
var _renderUi = require("@pie-lib/render-ui");
|
|
13
|
-
var _piePlayerEvents = require("@pie-framework/pie-player-events");
|
|
14
|
-
var _main = _interopRequireDefault(require("./main"));
|
|
15
|
-
const isComplete = (session, model, audioComplete, elementContext) => {
|
|
16
|
-
const {
|
|
17
|
-
autoplayAudioEnabled,
|
|
18
|
-
completeAudioEnabled,
|
|
19
|
-
responseAreasToBeFilled
|
|
20
|
-
} = model || {};
|
|
21
|
-
if (autoplayAudioEnabled && completeAudioEnabled && !audioComplete) {
|
|
22
|
-
if (elementContext) {
|
|
23
|
-
const audio = elementContext.querySelector('audio');
|
|
24
|
-
const isInsidePrompt = audio && audio.closest('#preview-prompt');
|
|
25
|
-
|
|
26
|
-
// only require audio completion if audio exists and is inside the prompt
|
|
27
|
-
if (audio && isInsidePrompt) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (!session || !session.value) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
const filledResponseAreas = Object.values(session.value || {}).filter(val => !!val).length;
|
|
36
|
-
return filledResponseAreas >= responseAreasToBeFilled;
|
|
37
|
-
};
|
|
38
|
-
exports.isComplete = isComplete;
|
|
39
|
-
class DragInTheBlank extends HTMLElement {
|
|
40
|
-
constructor() {
|
|
41
|
-
super();
|
|
42
|
-
(0, _defineProperty2.default)(this, "_render", () => {
|
|
43
|
-
if (this._model && this._session) {
|
|
44
|
-
let elem = /*#__PURE__*/_react.default.createElement(_main.default, {
|
|
45
|
-
model: this._model,
|
|
46
|
-
value: this._session.value,
|
|
47
|
-
onChange: this.changeSession
|
|
48
|
-
});
|
|
49
|
-
if (!this._root) {
|
|
50
|
-
this._root = (0, _client.createRoot)(this);
|
|
51
|
-
}
|
|
52
|
-
this._root.render(elem);
|
|
53
|
-
setTimeout(() => (0, _mathRendering.renderMath)(this), 0);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
(0, _defineProperty2.default)(this, "dispatchChangedEvent", () => {
|
|
57
|
-
this.dispatchEvent(new _piePlayerEvents.SessionChangedEvent(this.tagName.toLowerCase(), isComplete(this._session, this._model, this.audioComplete, this)));
|
|
58
|
-
});
|
|
59
|
-
(0, _defineProperty2.default)(this, "changeSession", value => {
|
|
60
|
-
this.session.value = value;
|
|
61
|
-
this.session.selector = 'Mouse';
|
|
62
|
-
this.dispatchChangedEvent();
|
|
63
|
-
this._render();
|
|
64
|
-
});
|
|
65
|
-
this._model = null;
|
|
66
|
-
this._session = null;
|
|
67
|
-
this._audioInitialized = false;
|
|
68
|
-
this.audioComplete = false;
|
|
69
|
-
this._root = null;
|
|
70
|
-
}
|
|
71
|
-
set model(m) {
|
|
72
|
-
this._model = m;
|
|
73
|
-
this.dispatchEvent(new _piePlayerEvents.ModelSetEvent(this.tagName.toLowerCase(), isComplete(this._session, this._model, this.audioComplete, this), !!this._model));
|
|
74
|
-
// reset the audioInitialized to false since the model changed, and we might need to reinitialize the audio
|
|
75
|
-
this._audioInitialized = false;
|
|
76
|
-
this._render();
|
|
77
|
-
}
|
|
78
|
-
set session(s) {
|
|
79
|
-
this._session = s;
|
|
80
|
-
this._render();
|
|
81
|
-
}
|
|
82
|
-
get session() {
|
|
83
|
-
return this._session;
|
|
84
|
-
}
|
|
85
|
-
_createAudioInfoToast() {
|
|
86
|
-
const info = document.createElement('div');
|
|
87
|
-
info.id = 'play-audio-info';
|
|
88
|
-
Object.assign(info.style, {
|
|
89
|
-
position: 'absolute',
|
|
90
|
-
top: 0,
|
|
91
|
-
width: '100%',
|
|
92
|
-
height: '100%',
|
|
93
|
-
display: 'flex',
|
|
94
|
-
justifyContent: 'center',
|
|
95
|
-
alignItems: 'center',
|
|
96
|
-
background: 'white',
|
|
97
|
-
zIndex: '1000',
|
|
98
|
-
cursor: 'pointer'
|
|
99
|
-
});
|
|
100
|
-
const img = document.createElement('img');
|
|
101
|
-
img.src = _renderUi.EnableAudioAutoplayImage;
|
|
102
|
-
img.alt = 'Click anywhere to enable audio autoplay';
|
|
103
|
-
img.width = 500;
|
|
104
|
-
img.height = 300;
|
|
105
|
-
info.appendChild(img);
|
|
106
|
-
return info;
|
|
107
|
-
}
|
|
108
|
-
connectedCallback() {
|
|
109
|
-
this._render();
|
|
110
|
-
|
|
111
|
-
// Observation: audio in Chrome will have the autoplay attribute,
|
|
112
|
-
// while other browsers will not have the autoplay attribute and will need a user interaction to play the audio
|
|
113
|
-
// This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox
|
|
114
|
-
const observer = new MutationObserver((mutationsList, observer) => {
|
|
115
|
-
mutationsList.forEach(mutation => {
|
|
116
|
-
if (mutation.type === 'childList') {
|
|
117
|
-
if (this._audioInitialized) return;
|
|
118
|
-
const audio = this.querySelector('audio');
|
|
119
|
-
const isInsidePrompt = audio && audio.closest('#preview-prompt');
|
|
120
|
-
if (!this._model) return;
|
|
121
|
-
if (!this._model.autoplayAudioEnabled) return;
|
|
122
|
-
if (audio && !isInsidePrompt) return;
|
|
123
|
-
if (!audio) return;
|
|
124
|
-
const info = this._createAudioInfoToast();
|
|
125
|
-
const container = this.querySelector('#main-container');
|
|
126
|
-
const enableAudio = () => {
|
|
127
|
-
if (this.querySelector('#play-audio-info')) {
|
|
128
|
-
audio.play();
|
|
129
|
-
container.removeChild(info);
|
|
130
|
-
}
|
|
131
|
-
document.removeEventListener('click', enableAudio);
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
// if the audio is paused, it means the user has not interacted with the page yet and the audio will not play
|
|
135
|
-
// FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked
|
|
136
|
-
setTimeout(() => {
|
|
137
|
-
if (audio.paused && !this.querySelector('#play-audio-info')) {
|
|
138
|
-
// add info message as a toast to enable audio playback
|
|
139
|
-
container.appendChild(info);
|
|
140
|
-
document.addEventListener('click', enableAudio);
|
|
141
|
-
} else {
|
|
142
|
-
document.removeEventListener('click', enableAudio);
|
|
143
|
-
}
|
|
144
|
-
}, 500);
|
|
145
|
-
|
|
146
|
-
// we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering
|
|
147
|
-
const handlePlaying = () => {
|
|
148
|
-
//timestamp when auto-played audio started playing
|
|
149
|
-
this._session.audioStartTime = this._session.audioStartTime || new Date().getTime();
|
|
150
|
-
const info = this.querySelector('#play-audio-info');
|
|
151
|
-
if (info) {
|
|
152
|
-
container.removeChild(info);
|
|
153
|
-
}
|
|
154
|
-
audio.removeEventListener('playing', handlePlaying);
|
|
155
|
-
};
|
|
156
|
-
audio.addEventListener('playing', handlePlaying);
|
|
157
|
-
|
|
158
|
-
// we need to listen for the ended event to update the isComplete state
|
|
159
|
-
const handleEnded = () => {
|
|
160
|
-
//timestamp when auto-played audio completed playing
|
|
161
|
-
this._session.audioEndTime = this._session.audioEndTime || new Date().getTime();
|
|
162
|
-
let {
|
|
163
|
-
audioStartTime,
|
|
164
|
-
audioEndTime,
|
|
165
|
-
waitTime
|
|
166
|
-
} = this._session;
|
|
167
|
-
if (!waitTime && audioStartTime && audioEndTime) {
|
|
168
|
-
// waitTime is elapsed time the user waited for auto-played audio to finish
|
|
169
|
-
this._session.waitTime = audioEndTime - audioStartTime;
|
|
170
|
-
}
|
|
171
|
-
this.audioComplete = true;
|
|
172
|
-
this.dispatchChangedEvent();
|
|
173
|
-
audio.removeEventListener('ended', handleEnded);
|
|
174
|
-
};
|
|
175
|
-
audio.addEventListener('ended', handleEnded);
|
|
176
|
-
|
|
177
|
-
// store references to remove later
|
|
178
|
-
this._audio = audio;
|
|
179
|
-
this._handlePlaying = handlePlaying;
|
|
180
|
-
this._handleEnded = handleEnded;
|
|
181
|
-
this._enableAudio = enableAudio;
|
|
182
|
-
// set to true to prevent multiple initializations
|
|
183
|
-
this._audioInitialized = true;
|
|
184
|
-
observer.disconnect();
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
observer.observe(this, {
|
|
189
|
-
childList: true,
|
|
190
|
-
subtree: true
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
disconnectedCallback() {
|
|
194
|
-
document.removeEventListener('click', this._enableAudio);
|
|
195
|
-
if (this._audio) {
|
|
196
|
-
this._audio.removeEventListener('playing', this._handlePlaying);
|
|
197
|
-
this._audio.removeEventListener('ended', this._handleEnded);
|
|
198
|
-
this._audio = null;
|
|
199
|
-
}
|
|
200
|
-
if (this._root) {
|
|
201
|
-
this._root.unmount();
|
|
202
|
-
this._root = null;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
exports.default = DragInTheBlank;
|
|
207
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_mathRendering","_renderUi","_piePlayerEvents","_main","isComplete","session","model","audioComplete","elementContext","autoplayAudioEnabled","completeAudioEnabled","responseAreasToBeFilled","audio","querySelector","isInsidePrompt","closest","value","filledResponseAreas","Object","values","filter","val","length","exports","DragInTheBlank","HTMLElement","constructor","_defineProperty2","default","_model","_session","elem","React","createElement","Main","onChange","changeSession","_root","createRoot","render","setTimeout","renderMath","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","selector","dispatchChangedEvent","_render","_audioInitialized","m","ModelSetEvent","s","_createAudioInfoToast","info","document","id","assign","style","position","top","width","height","display","justifyContent","alignItems","background","zIndex","cursor","img","src","EnableAudioAutoplayImage","alt","appendChild","connectedCallback","observer","MutationObserver","mutationsList","forEach","mutation","type","container","enableAudio","play","removeChild","removeEventListener","paused","addEventListener","handlePlaying","audioStartTime","Date","getTime","handleEnded","audioEndTime","waitTime","_audio","_handlePlaying","_handleEnded","_enableAudio","disconnect","observe","childList","subtree","disconnectedCallback","unmount"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { EnableAudioAutoplayImage } from '@pie-lib/render-ui';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport Main from './main';\n\nexport const isComplete = (session, model, audioComplete, elementContext) => {\n const { autoplayAudioEnabled, completeAudioEnabled, responseAreasToBeFilled } = model || {};\n\n if (autoplayAudioEnabled && completeAudioEnabled && !audioComplete) {\n if (elementContext) {\n const audio = elementContext.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('#preview-prompt');\n\n // only require audio completion if audio exists and is inside the prompt\n if (audio && isInsidePrompt) {\n return false;\n }\n }\n }\n\n if (!session || !session.value) {\n return false;\n }\n\n const filledResponseAreas = Object.values(session.value || {}).filter((val) => !!val).length;\n\n return filledResponseAreas >= responseAreasToBeFilled;\n};\n\nexport default class DragInTheBlank extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n this._audioInitialized = false;\n this.audioComplete = false;\n this._root = null;\n }\n\n set model(m) {\n this._model = m;\n this.dispatchEvent(\n new ModelSetEvent(\n this.tagName.toLowerCase(),\n isComplete(this._session, this._model, this.audioComplete, this),\n !!this._model,\n ),\n );\n // reset the audioInitialized to false since the model changed, and we might need to reinitialize the audio\n this._audioInitialized = false;\n this._render();\n }\n\n set session(s) {\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n _render = () => {\n if (this._model && this._session) {\n let elem = React.createElement(Main, {\n model: this._model,\n value: this._session.value,\n onChange: this.changeSession,\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(elem);\n setTimeout(() => renderMath(this), 0);\n }\n };\n\n dispatchChangedEvent = () => {\n this.dispatchEvent(\n new SessionChangedEvent(\n this.tagName.toLowerCase(),\n isComplete(this._session, this._model, this.audioComplete, this),\n ),\n );\n };\n\n changeSession = (value) => {\n this.session.value = value;\n this.session.selector = 'Mouse';\n\n this.dispatchChangedEvent();\n this._render();\n };\n\n _createAudioInfoToast() {\n const info = document.createElement('div');\n info.id = 'play-audio-info';\n\n Object.assign(info.style, {\n position: 'absolute',\n top: 0,\n width: '100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n background: 'white',\n zIndex: '1000',\n cursor: 'pointer',\n });\n\n const img = document.createElement('img');\n img.src = EnableAudioAutoplayImage;\n img.alt = 'Click anywhere to enable audio autoplay';\n img.width = 500;\n img.height = 300;\n\n info.appendChild(img);\n return info;\n }\n\n connectedCallback() {\n this._render();\n\n // Observation: audio in Chrome will have the autoplay attribute,\n // while other browsers will not have the autoplay attribute and will need a user interaction to play the audio\n // This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox\n const observer = new MutationObserver((mutationsList, observer) => {\n mutationsList.forEach((mutation) => {\n if (mutation.type === 'childList') {\n if (this._audioInitialized) return;\n const audio = this.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('#preview-prompt');\n\n if (!this._model) return;\n if (!this._model.autoplayAudioEnabled) return;\n if (audio && !isInsidePrompt) return;\n if (!audio) return;\n\n const info = this._createAudioInfoToast();\n const container = this.querySelector('#main-container');\n const enableAudio = () => {\n if (this.querySelector('#play-audio-info')) {\n audio.play();\n container.removeChild(info);\n }\n\n document.removeEventListener('click', enableAudio);\n };\n\n // if the audio is paused, it means the user has not interacted with the page yet and the audio will not play\n // FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked\n setTimeout(() => {\n if (audio.paused && !this.querySelector('#play-audio-info')) {\n // add info message as a toast to enable audio playback\n container.appendChild(info);\n document.addEventListener('click', enableAudio);\n } else {\n document.removeEventListener('click', enableAudio);\n }\n }, 500);\n\n // we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering\n const handlePlaying = () => {\n //timestamp when auto-played audio started playing\n this._session.audioStartTime = this._session.audioStartTime || new Date().getTime();\n\n const info = this.querySelector('#play-audio-info');\n if (info) {\n container.removeChild(info);\n }\n\n audio.removeEventListener('playing', handlePlaying);\n };\n\n audio.addEventListener('playing', handlePlaying);\n\n // we need to listen for the ended event to update the isComplete state\n const handleEnded = () => {\n //timestamp when auto-played audio completed playing\n this._session.audioEndTime = this._session.audioEndTime || new Date().getTime();\n\n let { audioStartTime, audioEndTime, waitTime } = this._session;\n if (!waitTime && audioStartTime && audioEndTime) {\n // waitTime is elapsed time the user waited for auto-played audio to finish\n this._session.waitTime = audioEndTime - audioStartTime;\n }\n\n this.audioComplete = true;\n this.dispatchChangedEvent();\n audio.removeEventListener('ended', handleEnded);\n };\n\n audio.addEventListener('ended', handleEnded);\n\n // store references to remove later\n this._audio = audio;\n this._handlePlaying = handlePlaying;\n this._handleEnded = handleEnded;\n this._enableAudio = enableAudio;\n // set to true to prevent multiple initializations\n this._audioInitialized = true;\n\n observer.disconnect();\n }\n });\n });\n\n observer.observe(this, { childList: true, subtree: true });\n }\n\n disconnectedCallback() {\n document.removeEventListener('click', this._enableAudio);\n\n if (this._audio) {\n this._audio.removeEventListener('playing', this._handlePlaying);\n this._audio.removeEventListener('ended', this._handleEnded);\n this._audio = null;\n }\n\n if (this._root) {\n this._root.unmount();\n this._root = null;\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEO,MAAMM,UAAU,GAAGA,CAACC,OAAO,EAAEC,KAAK,EAAEC,aAAa,EAAEC,cAAc,KAAK;EAC3E,MAAM;IAAEC,oBAAoB;IAAEC,oBAAoB;IAAEC;EAAwB,CAAC,GAAGL,KAAK,IAAI,CAAC,CAAC;EAE3F,IAAIG,oBAAoB,IAAIC,oBAAoB,IAAI,CAACH,aAAa,EAAE;IAClE,IAAIC,cAAc,EAAE;MAClB,MAAMI,KAAK,GAAGJ,cAAc,CAACK,aAAa,CAAC,OAAO,CAAC;MACnD,MAAMC,cAAc,GAAGF,KAAK,IAAIA,KAAK,CAACG,OAAO,CAAC,iBAAiB,CAAC;;MAEhE;MACA,IAAIH,KAAK,IAAIE,cAAc,EAAE;QAC3B,OAAO,KAAK;MACd;IACF;EACF;EAEA,IAAI,CAACT,OAAO,IAAI,CAACA,OAAO,CAACW,KAAK,EAAE;IAC9B,OAAO,KAAK;EACd;EAEA,MAAMC,mBAAmB,GAAGC,MAAM,CAACC,MAAM,CAACd,OAAO,CAACW,KAAK,IAAI,CAAC,CAAC,CAAC,CAACI,MAAM,CAAEC,GAAG,IAAK,CAAC,CAACA,GAAG,CAAC,CAACC,MAAM;EAE5F,OAAOL,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