@pie-element/placement-ordering 14.1.2-next.5 → 14.1.3
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 +1312 -0
- package/CHANGELOG.md +2444 -0
- package/LICENSE.md +5 -0
- package/README.md +57 -0
- package/configure/CHANGELOG.json +952 -0
- package/configure/CHANGELOG.md +2139 -0
- package/configure/lib/choice-editor.js +252 -0
- package/configure/lib/choice-editor.js.map +1 -0
- package/configure/lib/choice-tile.js +205 -0
- package/configure/lib/choice-tile.js.map +1 -0
- package/configure/lib/defaults.js +211 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/design.js +427 -0
- package/configure/lib/design.js.map +1 -0
- package/configure/lib/help.js +14 -0
- package/configure/lib/help.js.map +1 -0
- package/configure/lib/index.js +155 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/utils.js +108 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +26 -0
- package/controller/CHANGELOG.json +517 -0
- package/controller/CHANGELOG.md +1518 -0
- package/controller/lib/defaults.js +29 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +285 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/lib/scoring.js +109 -0
- package/controller/lib/scoring.js.map +1 -0
- package/controller/package.json +15 -0
- package/docs/config-schema.json +2964 -0
- package/docs/config-schema.json.md +2190 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +50 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +7 -0
- package/docs/pie-schema.json +1613 -0
- package/docs/pie-schema.json.md +973 -0
- package/icon.png +0 -0
- package/lib/index.js +122 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +32 -0
- package/lib/main.js.map +1 -0
- package/lib/ordering.js +165 -0
- package/lib/ordering.js.map +1 -0
- package/lib/placement-ordering.js +419 -0
- package/lib/placement-ordering.js.map +1 -0
- package/lib/tile.js +259 -0
- package/lib/tile.js.map +1 -0
- package/lib/tiler.js +165 -0
- package/lib/tiler.js.map +1 -0
- package/lib/utils.js +18 -0
- package/lib/utils.js.map +1 -0
- package/package.json +21 -88
- package/configure.js +0 -2
- package/controller.js +0 -1
- package/dist/author/choice-editor.d.ts +0 -39
- package/dist/author/choice-editor.js +0 -156
- package/dist/author/choice-tile.d.ts +0 -40
- package/dist/author/choice-tile.js +0 -132
- package/dist/author/defaults.d.ts +0 -213
- package/dist/author/defaults.js +0 -159
- package/dist/author/design.d.ts +0 -21
- package/dist/author/design.js +0 -273
- package/dist/author/help.d.ts +0 -11
- package/dist/author/index.d.ts +0 -45
- package/dist/author/index.js +0 -85
- package/dist/author/utils.d.ts +0 -15
- package/dist/author/utils.js +0 -62
- package/dist/browser/author/index.js +0 -46600
- package/dist/browser/author/index.js.map +0 -1
- package/dist/browser/browser-DHPggtaA.js +0 -376
- package/dist/browser/browser-DHPggtaA.js.map +0 -1
- package/dist/browser/controller/index.js +0 -242
- package/dist/browser/controller/index.js.map +0 -1
- package/dist/browser/delivery/index.js +0 -1035
- package/dist/browser/delivery/index.js.map +0 -1
- package/dist/browser/dist-D9ARZhQk.js +0 -1426
- package/dist/browser/dist-D9ARZhQk.js.map +0 -1
- package/dist/browser/drag-provider-C1slTlsc.js +0 -10555
- package/dist/browser/drag-provider-C1slTlsc.js.map +0 -1
- package/dist/browser/placement-ordering.css +0 -2
- package/dist/controller/defaults.d.ts +0 -31
- package/dist/controller/defaults.js +0 -25
- package/dist/controller/index.d.ts +0 -29
- package/dist/controller/index.js +0 -123
- package/dist/controller/scoring.d.ts +0 -27
- package/dist/controller/scoring.js +0 -30
- package/dist/delivery/index.d.ts +0 -26
- package/dist/delivery/index.js +0 -70
- package/dist/delivery/main.d.ts +0 -19
- package/dist/delivery/main.js +0 -22
- package/dist/delivery/ordering.d.ts +0 -18
- package/dist/delivery/ordering.js +0 -93
- package/dist/delivery/placement-ordering.d.ts +0 -28
- package/dist/delivery/placement-ordering.js +0 -213
- package/dist/delivery/tile.d.ts +0 -28
- package/dist/delivery/tile.js +0 -165
- package/dist/delivery/tiler.d.ts +0 -42
- package/dist/delivery/tiler.js +0 -89
- package/dist/delivery/utils.d.ts +0 -9
- package/dist/delivery/utils.js +0 -8
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.d.ts +0 -8
- package/dist/index.iife.js +0 -152
- package/dist/index.js +0 -2
- package/dist/runtime-support.d.ts +0 -12
- package/dist/runtime-support.js +0 -12
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = exports.default = {
|
|
8
|
+
choiceLabel: '',
|
|
9
|
+
choiceLabelEnabled: true,
|
|
10
|
+
choices: [],
|
|
11
|
+
correctResponse: [],
|
|
12
|
+
feedbackEnabled: false,
|
|
13
|
+
numberedGuides: false,
|
|
14
|
+
orientation: 'vertical',
|
|
15
|
+
partialScoring: true,
|
|
16
|
+
placementArea: false,
|
|
17
|
+
prompt: '',
|
|
18
|
+
promptEnabled: true,
|
|
19
|
+
rationale: '',
|
|
20
|
+
rationaleEnabled: true,
|
|
21
|
+
removeTilesAfterPlacing: true,
|
|
22
|
+
scoringType: 'auto',
|
|
23
|
+
studentInstructionsEnabled: true,
|
|
24
|
+
targetLabel: '',
|
|
25
|
+
teacherInstructions: '',
|
|
26
|
+
teacherInstructionsEnabled: true,
|
|
27
|
+
toolbarEditorPosition: 'bottom'
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","names":["choiceLabel","choiceLabelEnabled","choices","correctResponse","feedbackEnabled","numberedGuides","orientation","partialScoring","placementArea","prompt","promptEnabled","rationale","rationaleEnabled","removeTilesAfterPlacing","scoringType","studentInstructionsEnabled","targetLabel","teacherInstructions","teacherInstructionsEnabled","toolbarEditorPosition"],"sources":["../src/defaults.js"],"sourcesContent":["export default {\n choiceLabel: '',\n choiceLabelEnabled: true,\n choices: [],\n correctResponse: [],\n feedbackEnabled: false,\n numberedGuides: false,\n orientation: 'vertical',\n partialScoring: true,\n placementArea: false,\n prompt: '',\n promptEnabled: true,\n rationale: '',\n rationaleEnabled: true,\n removeTilesAfterPlacing: true,\n scoringType: 'auto',\n studentInstructionsEnabled: true,\n targetLabel: '',\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n};\n"],"mappings":";;;;;;iCAAe;EACbA,WAAW,EAAE,EAAE;EACfC,kBAAkB,EAAE,IAAI;EACxBC,OAAO,EAAE,EAAE;EACXC,eAAe,EAAE,EAAE;EACnBC,eAAe,EAAE,KAAK;EACtBC,cAAc,EAAE,KAAK;EACrBC,WAAW,EAAE,UAAU;EACvBC,cAAc,EAAE,IAAI;EACpBC,aAAa,EAAE,KAAK;EACpBC,MAAM,EAAE,EAAE;EACVC,aAAa,EAAE,IAAI;EACnBC,SAAS,EAAE,EAAE;EACbC,gBAAgB,EAAE,IAAI;EACtBC,uBAAuB,EAAE,IAAI;EAC7BC,WAAW,EAAE,MAAM;EACnBC,0BAA0B,EAAE,IAAI;EAChCC,WAAW,EAAE,EAAE;EACfC,mBAAmB,EAAE,EAAE;EACvBC,0BAA0B,EAAE,IAAI;EAChCC,qBAAqB,EAAE;AACzB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createCorrectResponseSession = void 0;
|
|
8
|
+
exports.createDefaultModel = createDefaultModel;
|
|
9
|
+
exports.getLogTrace = void 0;
|
|
10
|
+
exports.model = model;
|
|
11
|
+
exports.normalize = void 0;
|
|
12
|
+
exports.outcome = outcome;
|
|
13
|
+
exports.validate = exports.questionError = void 0;
|
|
14
|
+
var _scoring = require("./scoring");
|
|
15
|
+
var _lodashEs = require("lodash-es");
|
|
16
|
+
var _feedback = require("@pie-lib/feedback");
|
|
17
|
+
var _controllerUtils = require("@pie-lib/controller-utils");
|
|
18
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
19
|
+
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
20
|
+
var _translator = _interopRequireDefault(require("@pie-lib/translator"));
|
|
21
|
+
const log = (0, _debug.default)('@pie-element:placement-ordering:controller');
|
|
22
|
+
const {
|
|
23
|
+
translator
|
|
24
|
+
} = _translator.default;
|
|
25
|
+
const questionError = () => new Error('Question is missing required array: correctResponse');
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Generates detailed trace log for placement-ordering scoring evaluation
|
|
29
|
+
* @param {Object} question - the question model
|
|
30
|
+
* @param {Object} session - the student session
|
|
31
|
+
* @param {Object} env - the environment
|
|
32
|
+
* @returns {Array<string>} traceLog
|
|
33
|
+
*/
|
|
34
|
+
exports.questionError = questionError;
|
|
35
|
+
const getLogTrace = (question, session, env) => {
|
|
36
|
+
const traceLog = [];
|
|
37
|
+
const value = session?.value || [];
|
|
38
|
+
const correctResponse = question?.correctResponse || [];
|
|
39
|
+
const hasPlacementArea = question?.placementArea === true;
|
|
40
|
+
if (!value.length) {
|
|
41
|
+
if (hasPlacementArea) {
|
|
42
|
+
traceLog.push('Student did not place any tiles in the target area.');
|
|
43
|
+
} else {
|
|
44
|
+
traceLog.push('Student did not reorder any tiles.');
|
|
45
|
+
}
|
|
46
|
+
traceLog.push('Final score: 0.');
|
|
47
|
+
return traceLog;
|
|
48
|
+
}
|
|
49
|
+
const allCorrectResponses = (0, _scoring.getAllCorrectResponses)(question);
|
|
50
|
+
let bestMatch = {
|
|
51
|
+
score: 0,
|
|
52
|
+
response: []
|
|
53
|
+
};
|
|
54
|
+
allCorrectResponses.forEach(cr => {
|
|
55
|
+
let matchCount = 0;
|
|
56
|
+
value.forEach((v, idx) => {
|
|
57
|
+
if (cr[idx] === v) {
|
|
58
|
+
matchCount++;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
if (matchCount > bestMatch.score) {
|
|
62
|
+
bestMatch = {
|
|
63
|
+
score: matchCount,
|
|
64
|
+
response: cr
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const correctCount = bestMatch.score;
|
|
69
|
+
const incorrectCount = value.length - correctCount;
|
|
70
|
+
if (correctCount > 0) {
|
|
71
|
+
traceLog.push(`${correctCount} tile(s) placed in the correct order.`);
|
|
72
|
+
}
|
|
73
|
+
if (incorrectCount > 0) {
|
|
74
|
+
traceLog.push(`${incorrectCount} tile(s) placed in an incorrect order.`);
|
|
75
|
+
}
|
|
76
|
+
const isFullyCorrect = allCorrectResponses.some(cr => (0, _lodashEs.isEqual)(cr, value));
|
|
77
|
+
const partialScoringEnabled = _controllerUtils.partialScoring.enabled(question, env || {});
|
|
78
|
+
if (partialScoringEnabled) {
|
|
79
|
+
traceLog.push('Score calculated using partial scoring.');
|
|
80
|
+
traceLog.push('Each tile placed in the correct position contributes to the score.');
|
|
81
|
+
} else {
|
|
82
|
+
traceLog.push('Score calculated using all-or-nothing scoring.');
|
|
83
|
+
if (hasPlacementArea) {
|
|
84
|
+
traceLog.push('Student must place all tiles in the correct positions within the target area to receive full credit.');
|
|
85
|
+
} else {
|
|
86
|
+
traceLog.push('Student must arrange all tiles in the correct order to receive full credit.');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const rawScore = (0, _scoring.score)(question, session);
|
|
90
|
+
const finalScore = partialScoringEnabled ? rawScore : rawScore === 1 ? 1 : 0;
|
|
91
|
+
traceLog.push(`Final score: ${finalScore}.`);
|
|
92
|
+
return traceLog;
|
|
93
|
+
};
|
|
94
|
+
exports.getLogTrace = getLogTrace;
|
|
95
|
+
function outcome(question, session, env) {
|
|
96
|
+
return new Promise((resolve, reject) => {
|
|
97
|
+
if (!session || (0, _lodashEs.isEmpty)(session)) {
|
|
98
|
+
resolve({
|
|
99
|
+
score: 0,
|
|
100
|
+
empty: true,
|
|
101
|
+
logTrace: ['Student did not interact with the placement-ordering item.']
|
|
102
|
+
});
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (!question || !question.correctResponse || (0, _lodashEs.isEmpty)(question.correctResponse)) {
|
|
106
|
+
reject(questionError());
|
|
107
|
+
} else {
|
|
108
|
+
try {
|
|
109
|
+
const s = (0, _scoring.score)(question, session);
|
|
110
|
+
const finalScore = _controllerUtils.partialScoring.enabled(question, env || {}) ? s : s === 1 ? 1 : 0;
|
|
111
|
+
resolve({
|
|
112
|
+
score: finalScore,
|
|
113
|
+
logTrace: getLogTrace(question, session, env)
|
|
114
|
+
});
|
|
115
|
+
} catch (e) {
|
|
116
|
+
reject(e);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function createDefaultModel(model = {}) {
|
|
122
|
+
return new Promise(resolve => {
|
|
123
|
+
resolve({
|
|
124
|
+
..._defaults.default,
|
|
125
|
+
...model
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const normalize = question => ({
|
|
130
|
+
..._defaults.default,
|
|
131
|
+
rationaleEnabled: true,
|
|
132
|
+
feedbackEnabled: false,
|
|
133
|
+
promptEnabled: true,
|
|
134
|
+
teacherInstructionsEnabled: true,
|
|
135
|
+
studentInstructionsEnabled: true,
|
|
136
|
+
...question
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
*
|
|
141
|
+
* @param {*} question
|
|
142
|
+
* @param {*} session
|
|
143
|
+
* @param {*} env
|
|
144
|
+
*/
|
|
145
|
+
exports.normalize = normalize;
|
|
146
|
+
async function model(question, session, env) {
|
|
147
|
+
const normalizedQuestion = normalize(question);
|
|
148
|
+
const base = {};
|
|
149
|
+
if (question.alternateResponses && (0, _lodashEs.every)(question.alternateResponses, _lodashEs.isArray)) {
|
|
150
|
+
log('Deprecated structure of alternateResponses is in use');
|
|
151
|
+
// eslint-disable-next-line no-console
|
|
152
|
+
console.error('Deprecated structure of alternateResponses is in use');
|
|
153
|
+
}
|
|
154
|
+
base.env = env;
|
|
155
|
+
base.extraCSSRules = normalizedQuestion.extraCSSRules;
|
|
156
|
+
base.outcomes = [];
|
|
157
|
+
base.completeLength = (normalizedQuestion.correctResponse || []).length;
|
|
158
|
+
base.choices = (normalizedQuestion.choices || []).filter(choice => choice.label);
|
|
159
|
+
base.note = normalizedQuestion.note;
|
|
160
|
+
base.showNote = normalizedQuestion.alternateResponses && normalizedQuestion.alternateResponses.length > 0;
|
|
161
|
+
base.language = normalizedQuestion.language;
|
|
162
|
+
log('[model] removing tileSize for the moment.');
|
|
163
|
+
base.prompt = normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null;
|
|
164
|
+
base.config = {
|
|
165
|
+
orientation: normalizedQuestion.orientation || 'vertical',
|
|
166
|
+
includeTargets: normalizedQuestion.placementArea,
|
|
167
|
+
choiceLabelEnabled: normalizedQuestion.choiceLabelEnabled,
|
|
168
|
+
targetLabel: normalizedQuestion.targetLabel,
|
|
169
|
+
choiceLabel: normalizedQuestion.choiceLabel,
|
|
170
|
+
showOrdering: normalizedQuestion.numberedGuides,
|
|
171
|
+
allowSameChoiceInTargets: !normalizedQuestion.removeTilesAfterPlacing
|
|
172
|
+
};
|
|
173
|
+
base.disabled = env.mode !== 'gather';
|
|
174
|
+
if (!base.note) {
|
|
175
|
+
base.note = translator.t('common:commonCorrectAnswerWithAlternates', {
|
|
176
|
+
lng: normalizedQuestion.language
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
|
|
180
|
+
base.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;
|
|
181
|
+
base.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
|
|
182
|
+
} else {
|
|
183
|
+
base.rationale = null;
|
|
184
|
+
base.teacherInstructions = null;
|
|
185
|
+
}
|
|
186
|
+
if (env.mode === 'evaluate') {
|
|
187
|
+
const value = session && session.value || [];
|
|
188
|
+
const allCorrectResponses = (0, _scoring.getAllCorrectResponses)(normalizedQuestion);
|
|
189
|
+
const bestSetOfResponses = allCorrectResponses.reduce((info, cr) => {
|
|
190
|
+
const currentScore = (0, _lodashEs.reduce)(value, (acc, c, idx) => acc + (Array.isArray(cr) && cr[idx] === c ? 1 : 0), 0);
|
|
191
|
+
if (currentScore > info.score) {
|
|
192
|
+
return {
|
|
193
|
+
arr: cr,
|
|
194
|
+
score: currentScore
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return info;
|
|
198
|
+
}, {
|
|
199
|
+
arr: [],
|
|
200
|
+
score: 0
|
|
201
|
+
});
|
|
202
|
+
base.outcomes = (0, _lodashEs.map)(value, (c, idx) => {
|
|
203
|
+
return {
|
|
204
|
+
id: c,
|
|
205
|
+
outcome: bestSetOfResponses.arr[idx] === c ? 'correct' : 'incorrect'
|
|
206
|
+
};
|
|
207
|
+
});
|
|
208
|
+
const isResponseCorrect = allCorrectResponses.some(response => (0, _lodashEs.isEqual)(response, value));
|
|
209
|
+
const responseScore = (0, _scoring.score)(question, session);
|
|
210
|
+
const isCorrect = responseScore === 1;
|
|
211
|
+
const isPartialCorrect = !isCorrect && _controllerUtils.partialScoring.enabled(normalizedQuestion, env || {}) && responseScore !== 0;
|
|
212
|
+
base.correctness = isCorrect ? 'correct' : isPartialCorrect ? 'partial' : 'incorrect';
|
|
213
|
+
if (!isResponseCorrect) {
|
|
214
|
+
base.correctResponse = (0, _scoring.flattenCorrect)(normalizedQuestion);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// requirement made in PD-2182
|
|
218
|
+
if (!normalizedQuestion.feedback) {
|
|
219
|
+
normalizedQuestion.feedbackEnabled = false;
|
|
220
|
+
}
|
|
221
|
+
const feedback = normalizedQuestion.feedbackEnabled ? await (0, _feedback.getFeedbackForCorrectness)(base.correctness, normalizedQuestion.feedback) : undefined;
|
|
222
|
+
base.feedback = feedback;
|
|
223
|
+
return base;
|
|
224
|
+
} else {
|
|
225
|
+
return base;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
const createCorrectResponseSession = (question, env) => {
|
|
229
|
+
return new Promise(resolve => {
|
|
230
|
+
if (env.mode !== 'evaluate' && env.role === 'instructor') {
|
|
231
|
+
resolve({
|
|
232
|
+
id: '1',
|
|
233
|
+
value: (0, _scoring.flattenCorrect)(question)
|
|
234
|
+
});
|
|
235
|
+
} else {
|
|
236
|
+
resolve(null);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
// remove all html tags
|
|
242
|
+
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
243
|
+
const getInnerText = html => (html || '').replaceAll(/<[^>]*>/g, '');
|
|
244
|
+
|
|
245
|
+
// remove all html tags except img, iframe and source tag for audio
|
|
246
|
+
const getContent = html => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
|
|
247
|
+
const validate = (model = {}, config = {}) => {
|
|
248
|
+
const {
|
|
249
|
+
choices,
|
|
250
|
+
correctResponse
|
|
251
|
+
} = model;
|
|
252
|
+
const errors = {};
|
|
253
|
+
['teacherInstructions', 'prompt', 'rationale'].forEach(field => {
|
|
254
|
+
if (config[field]?.required && !getContent(model[field])) {
|
|
255
|
+
errors[field] = 'This field is required.';
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
const reversedChoices = [...(choices || [])].reverse();
|
|
259
|
+
const choicesErrors = {};
|
|
260
|
+
reversedChoices.forEach((choice, index) => {
|
|
261
|
+
const {
|
|
262
|
+
id,
|
|
263
|
+
label
|
|
264
|
+
} = choice;
|
|
265
|
+
if (!getContent(label)) {
|
|
266
|
+
choicesErrors[id] = 'Content should not be empty.';
|
|
267
|
+
} else {
|
|
268
|
+
const identicalAnswer = reversedChoices.slice(index + 1).some(c => c.label === label);
|
|
269
|
+
if (identicalAnswer) {
|
|
270
|
+
choicesErrors[id] = 'Content should be unique.';
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
const choicesIds = (choices || []).map(choice => choice.id);
|
|
275
|
+
const correctResponseIds = (correctResponse || []).map(response => response.id || response);
|
|
276
|
+
if ((0, _lodashEs.isEqual)(choicesIds, correctResponseIds)) {
|
|
277
|
+
errors.orderError = 'The correct ordering should not be identical to the initial ordering.';
|
|
278
|
+
}
|
|
279
|
+
if (!(0, _lodashEs.isEmpty)(choicesErrors)) {
|
|
280
|
+
errors.choicesErrors = choicesErrors;
|
|
281
|
+
}
|
|
282
|
+
return errors;
|
|
283
|
+
};
|
|
284
|
+
exports.validate = validate;
|
|
285
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_scoring","require","_lodashEs","_feedback","_controllerUtils","_debug","_interopRequireDefault","_defaults","_translator","log","debug","translator","Translator","questionError","Error","exports","getLogTrace","question","session","env","traceLog","value","correctResponse","hasPlacementArea","placementArea","length","push","allCorrectResponses","getAllCorrectResponses","bestMatch","score","response","forEach","cr","matchCount","v","idx","correctCount","incorrectCount","isFullyCorrect","some","isEqual","partialScoringEnabled","partialScoring","enabled","rawScore","finalScore","outcome","Promise","resolve","reject","isEmpty","empty","logTrace","s","e","createDefaultModel","model","defaults","normalize","rationaleEnabled","feedbackEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","normalizedQuestion","base","alternateResponses","every","isArray","console","error","extraCSSRules","outcomes","completeLength","choices","filter","choice","label","note","showNote","language","prompt","config","orientation","includeTargets","choiceLabelEnabled","targetLabel","choiceLabel","showOrdering","numberedGuides","allowSameChoiceInTargets","removeTilesAfterPlacing","disabled","mode","t","lng","role","rationale","teacherInstructions","bestSetOfResponses","reduce","info","currentScore","acc","c","Array","arr","map","id","isResponseCorrect","responseScore","isCorrect","isPartialCorrect","correctness","flattenCorrect","feedback","getFeedbackForCorrectness","undefined","createCorrectResponseSession","getInnerText","html","replaceAll","getContent","replace","validate","errors","field","required","reversedChoices","reverse","choicesErrors","index","identicalAnswer","slice","choicesIds","correctResponseIds","orderError"],"sources":["../src/index.js"],"sourcesContent":["import { flattenCorrect, getAllCorrectResponses, score } from './scoring';\n\nimport { every, isArray, isEmpty, isEqual, map, reduce } from 'lodash-es';\nimport { getFeedbackForCorrectness } from '@pie-lib/feedback';\nimport { partialScoring } from '@pie-lib/controller-utils';\nimport debug from 'debug';\n\nimport defaults from './defaults';\n\nconst log = debug('@pie-element:placement-ordering:controller');\nimport Translator from '@pie-lib/translator';\n\nconst { translator } = Translator;\n\nexport const questionError = () => new Error('Question is missing required array: correctResponse');\n\n/**\n * Generates detailed trace log for placement-ordering scoring evaluation\n * @param {Object} question - the question model\n * @param {Object} session - the student session\n * @param {Object} env - the environment\n * @returns {Array<string>} traceLog\n */\nexport const getLogTrace = (question, session, env) => {\n const traceLog = [];\n\n const value = session?.value || [];\n const correctResponse = question?.correctResponse || [];\n const hasPlacementArea = question?.placementArea === true;\n\n if (!value.length) {\n if (hasPlacementArea) {\n traceLog.push('Student did not place any tiles in the target area.');\n } else {\n traceLog.push('Student did not reorder any tiles.');\n }\n traceLog.push('Final score: 0.');\n return traceLog;\n }\n\n const allCorrectResponses = getAllCorrectResponses(question);\n\n let bestMatch = { score: 0, response: [] };\n\n allCorrectResponses.forEach((cr) => {\n let matchCount = 0;\n value.forEach((v, idx) => {\n if (cr[idx] === v) {\n matchCount++;\n }\n });\n\n if (matchCount > bestMatch.score) {\n bestMatch = { score: matchCount, response: cr };\n }\n });\n\n const correctCount = bestMatch.score;\n const incorrectCount = value.length - correctCount;\n\n if (correctCount > 0) {\n traceLog.push(`${correctCount} tile(s) placed in the correct order.`);\n }\n\n if (incorrectCount > 0) {\n traceLog.push(`${incorrectCount} tile(s) placed in an incorrect order.`);\n }\n\n const isFullyCorrect = allCorrectResponses.some((cr) => isEqual(cr, value));\n\n const partialScoringEnabled = partialScoring.enabled(question, env || {});\n\n if (partialScoringEnabled) {\n traceLog.push('Score calculated using partial scoring.');\n traceLog.push(\n 'Each tile placed in the correct position contributes to the score.',\n );\n } else {\n traceLog.push('Score calculated using all-or-nothing scoring.');\n if (hasPlacementArea) {\n traceLog.push(\n 'Student must place all tiles in the correct positions within the target area to receive full credit.',\n );\n } else {\n traceLog.push(\n 'Student must arrange all tiles in the correct order to receive full credit.',\n );\n }\n }\n\n const rawScore = score(question, session);\n const finalScore = partialScoringEnabled ? rawScore : rawScore === 1 ? 1 : 0;\n\n traceLog.push(`Final score: ${finalScore}.`);\n\n return traceLog;\n};\n\nexport function outcome(question, session, env) {\n return new Promise((resolve, reject) => {\n if (!session || isEmpty(session)) {\n resolve({ \n score: 0, \n empty: true, \n logTrace: ['Student did not interact with the placement-ordering item.'] \n });\n return;\n }\n\n if (!question || !question.correctResponse || isEmpty(question.correctResponse)) {\n reject(questionError());\n } else {\n try {\n const s = score(question, session);\n const finalScore = partialScoring.enabled(question, env || {}) ? s : s === 1 ? 1 : 0;\n resolve({\n score: finalScore,\n logTrace: getLogTrace(question, session, env)\n });\n } catch (e) {\n reject(e);\n }\n }\n });\n}\n\nexport function createDefaultModel(model = {}) {\n return new Promise((resolve) => {\n resolve({\n ...defaults,\n ...model,\n });\n });\n}\n\nexport const normalize = (question) => ({\n ...defaults,\n rationaleEnabled: true,\n feedbackEnabled: false,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n ...question,\n});\n\n/**\n *\n * @param {*} question\n * @param {*} session\n * @param {*} env\n */\nexport async function model(question, session, env) {\n const normalizedQuestion = normalize(question);\n const base = {};\n\n if (question.alternateResponses && every(question.alternateResponses, isArray)) {\n log('Deprecated structure of alternateResponses is in use');\n // eslint-disable-next-line no-console\n console.error('Deprecated structure of alternateResponses is in use');\n }\n\n base.env = env;\n base.extraCSSRules = normalizedQuestion.extraCSSRules;\n base.outcomes = [];\n base.completeLength = (normalizedQuestion.correctResponse || []).length;\n base.choices = (normalizedQuestion.choices || []).filter((choice) => choice.label);\n base.note = normalizedQuestion.note;\n base.showNote = normalizedQuestion.alternateResponses && normalizedQuestion.alternateResponses.length > 0;\n base.language = normalizedQuestion.language;\n\n log('[model] removing tileSize for the moment.');\n\n base.prompt = normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null;\n base.config = {\n orientation: normalizedQuestion.orientation || 'vertical',\n includeTargets: normalizedQuestion.placementArea,\n choiceLabelEnabled: normalizedQuestion.choiceLabelEnabled,\n targetLabel: normalizedQuestion.targetLabel,\n choiceLabel: normalizedQuestion.choiceLabel,\n showOrdering: normalizedQuestion.numberedGuides,\n allowSameChoiceInTargets: !normalizedQuestion.removeTilesAfterPlacing,\n };\n\n base.disabled = env.mode !== 'gather';\n\n if (!base.note) {\n base.note = translator.t('common:commonCorrectAnswerWithAlternates', { lng: normalizedQuestion.language });\n }\n\n if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {\n base.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;\n base.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled\n ? normalizedQuestion.teacherInstructions\n : null;\n } else {\n base.rationale = null;\n base.teacherInstructions = null;\n }\n\n if (env.mode === 'evaluate') {\n const value = (session && session.value) || [];\n const allCorrectResponses = getAllCorrectResponses(normalizedQuestion);\n\n const bestSetOfResponses = allCorrectResponses.reduce(\n (info, cr) => {\n const currentScore = reduce(value, (acc, c, idx) => acc + (Array.isArray(cr) && cr[idx] === c ? 1 : 0), 0);\n\n if (currentScore > info.score) {\n return {\n arr: cr,\n score: currentScore,\n };\n }\n\n return info;\n },\n { arr: [], score: 0 },\n );\n\n base.outcomes = map(value, (c, idx) => {\n return {\n id: c,\n outcome: bestSetOfResponses.arr[idx] === c ? 'correct' : 'incorrect',\n };\n });\n\n const isResponseCorrect = allCorrectResponses.some((response) => isEqual(response, value));\n const responseScore = score(question, session);\n const isCorrect = responseScore === 1;\n const isPartialCorrect = !isCorrect && partialScoring.enabled(normalizedQuestion, env || {}) && responseScore !== 0;\n\n base.correctness = isCorrect ? 'correct' : isPartialCorrect ? 'partial' : 'incorrect';\n\n if (!isResponseCorrect) {\n base.correctResponse = flattenCorrect(normalizedQuestion);\n }\n\n // requirement made in PD-2182\n if (!normalizedQuestion.feedback) {\n normalizedQuestion.feedbackEnabled = false;\n }\n\n const feedback = normalizedQuestion.feedbackEnabled\n ? await getFeedbackForCorrectness(base.correctness, normalizedQuestion.feedback)\n : undefined;\n\n base.feedback = feedback;\n return base;\n } else {\n return base;\n }\n}\n\nexport const createCorrectResponseSession = (question, env) => {\n return new Promise((resolve) => {\n if (env.mode !== 'evaluate' && env.role === 'instructor') {\n resolve({\n id: '1',\n value: flattenCorrect(question),\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 } = model;\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 reversedChoices = [...(choices || [])].reverse();\n const choicesErrors = {};\n\n reversedChoices.forEach((choice, index) => {\n const { id, label } = choice;\n\n if (!getContent(label)) {\n choicesErrors[id] = 'Content should not be empty.';\n } else {\n const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);\n\n if (identicalAnswer) {\n choicesErrors[id] = 'Content should be unique.';\n }\n }\n });\n\n const choicesIds = (choices || []).map((choice) => choice.id);\n const correctResponseIds = (correctResponse || []).map((response) => response.id || response);\n\n if (isEqual(choicesIds, correctResponseIds)) {\n errors.orderError = 'The correct ordering should not be identical to the initial ordering.';\n }\n\n if (!isEmpty(choicesErrors)) {\n errors.choicesErrors = choicesErrors;\n }\n\n return errors;\n};\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAC,sBAAA,CAAAL,OAAA;AAEA,IAAAM,SAAA,GAAAD,sBAAA,CAAAL,OAAA;AAGA,IAAAO,WAAA,GAAAF,sBAAA,CAAAL,OAAA;AADA,MAAMQ,GAAG,GAAG,IAAAC,cAAK,EAAC,4CAA4C,CAAC;AAG/D,MAAM;EAAEC;AAAW,CAAC,GAAGC,mBAAU;AAE1B,MAAMC,aAAa,GAAGA,CAAA,KAAM,IAAIC,KAAK,CAAC,qDAAqD,CAAC;;AAEnG;AACA;AACA;AACA;AACA;AACA;AACA;AANAC,OAAA,CAAAF,aAAA,GAAAA,aAAA;AAOO,MAAMG,WAAW,GAAGA,CAACC,QAAQ,EAAEC,OAAO,EAAEC,GAAG,KAAK;EACrD,MAAMC,QAAQ,GAAG,EAAE;EAEnB,MAAMC,KAAK,GAAGH,OAAO,EAAEG,KAAK,IAAI,EAAE;EAClC,MAAMC,eAAe,GAAGL,QAAQ,EAAEK,eAAe,IAAI,EAAE;EACvD,MAAMC,gBAAgB,GAAGN,QAAQ,EAAEO,aAAa,KAAK,IAAI;EAEzD,IAAI,CAACH,KAAK,CAACI,MAAM,EAAE;IACjB,IAAIF,gBAAgB,EAAE;MACpBH,QAAQ,CAACM,IAAI,CAAC,qDAAqD,CAAC;IACtE,CAAC,MAAM;MACLN,QAAQ,CAACM,IAAI,CAAC,oCAAoC,CAAC;IACrD;IACAN,QAAQ,CAACM,IAAI,CAAC,iBAAiB,CAAC;IAChC,OAAON,QAA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C,aAAa,GAAG,CAAC,CAAC;EAExBF,eAAe,CAACjG,OAAO,CAAC,CAAC6C,MAAM,EAAEuD,KAAK,KAAK;IACzC,MAAM;MAAEvB,EAAE;MAAE/B;IAAM,CAAC,GAAGD,MAAM;IAE5B,IAAI,CAAC8C,UAAU,CAAC7C,KAAK,CAAC,EAAE;MACtBqD,aAAa,CAACtB,EAAE,CAAC,GAAG,8BAA8B;IACpD,CAAC,MAAM;MACL,MAAMwB,eAAe,GAAGJ,eAAe,CAACK,KAAK,CAACF,KAAK,GAAG,CAAC,CAAC,CAAC5F,IAAI,CAAEiE,CAAC,IAAKA,CAAC,CAAC3B,KAAK,KAAKA,KAAK,CAAC;MAEvF,IAAIuD,eAAe,EAAE;QACnBF,aAAa,CAACtB,EAAE,CAAC,GAAG,2BAA2B;MACjD;IACF;EACF,CAAC,CAAC;EAEF,MAAM0B,UAAU,GAAG,CAAC5D,OAAO,IAAI,EAAE,EAAEiC,GAAG,CAAE/B,MAAM,IAAKA,MAAM,CAACgC,EAAE,CAAC;EAC7D,MAAM2B,kBAAkB,GAAG,CAAClH,eAAe,IAAI,EAAE,EAAEsF,GAAG,CAAE7E,QAAQ,IAAKA,QAAQ,CAAC8E,EAAE,IAAI9E,QAAQ,CAAC;EAE7F,IAAI,IAAAU,iBAAO,EAAC8F,UAAU,EAAEC,kBAAkB,CAAC,EAAE;IAC3CV,MAAM,CAACW,UAAU,GAAG,uEAAuE;EAC7F;EAEA,IAAI,CAAC,IAAAtF,iBAAO,EAACgF,aAAa,CAAC,EAAE;IAC3BL,MAAM,CAACK,aAAa,GAAGA,aAAa;EACtC;EAEA,OAAOL,MAAM;AACf,CAAC;AAAC/G,OAAA,CAAA8G,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.score = exports.pairwiseCombinationScore = exports.illegalArgumentError = exports.getAllCorrectResponses = exports.flattenCorrect = void 0;
|
|
8
|
+
var _lodashEs = require("lodash-es");
|
|
9
|
+
var _jsCombinatorics = require("js-combinatorics");
|
|
10
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
11
|
+
const log = (0, _debug.default)('pie-elements:placement-ordering:controller');
|
|
12
|
+
const illegalArgumentError = answer => new Error(`Cant score answer: ${answer} it has duplicates and allowDuplicates is false`);
|
|
13
|
+
exports.illegalArgumentError = illegalArgumentError;
|
|
14
|
+
const pairwiseCombinationScore = (correct, answer, opts) => {
|
|
15
|
+
opts = {
|
|
16
|
+
allowDuplicates: false,
|
|
17
|
+
orderMustBeComplete: false,
|
|
18
|
+
...opts
|
|
19
|
+
};
|
|
20
|
+
if (!opts.allowDuplicates && !(0, _lodashEs.isEqual)((0, _lodashEs.uniq)(correct), correct)) {
|
|
21
|
+
throw illegalArgumentError(answer);
|
|
22
|
+
}
|
|
23
|
+
if (opts.allowDuplicates === false && answer.length !== (0, _lodashEs.uniq)(answer).length) {
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
answer = opts.allowDuplicates !== false ? answer : (0, _lodashEs.uniq)(answer);
|
|
27
|
+
log('answer:', answer);
|
|
28
|
+
if (!Array.isArray(correct) || correct.length === 0) {
|
|
29
|
+
throw new Error('correct must be non empty an array');
|
|
30
|
+
}
|
|
31
|
+
if (correct.length === 1) {
|
|
32
|
+
return (0, _lodashEs.isEqual)(correct, answer) ? 1 : 0;
|
|
33
|
+
}
|
|
34
|
+
if (!Array.isArray(answer) || answer.length < 2) {
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
if (answer.length > correct.length) {
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
if (correct.length !== answer.length && opts.orderMustBeComplete) {
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
const correctCombo = (0, _jsCombinatorics.combination)(correct, 2).toArray();
|
|
44
|
+
const answerCombo = (0, _jsCombinatorics.combination)(answer, 2).toArray();
|
|
45
|
+
const diff = (0, _lodashEs.differenceWith)(answerCombo, correctCombo, _lodashEs.isEqual);
|
|
46
|
+
const comboLengthDiff = correctCombo.length - answerCombo.length;
|
|
47
|
+
const total = correctCombo.length;
|
|
48
|
+
const actual = total - diff.length - comboLengthDiff;
|
|
49
|
+
const n = (actual / total).toFixed(2);
|
|
50
|
+
return parseFloat(n);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Flattens the correctResponse into an array of ordered identifiers representing the
|
|
55
|
+
* correct response.
|
|
56
|
+
*/
|
|
57
|
+
exports.pairwiseCombinationScore = pairwiseCombinationScore;
|
|
58
|
+
const flattenCorrect = question => question.correctResponse ? question.correctResponse.map(r => r && r.id ? r.id : r) : [];
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Returns all correct responses for this question
|
|
62
|
+
* @param question - array
|
|
63
|
+
*/
|
|
64
|
+
exports.flattenCorrect = flattenCorrect;
|
|
65
|
+
const getAllCorrectResponses = question => {
|
|
66
|
+
const alternates = (question.alternateResponses || []).map(alternate => {
|
|
67
|
+
if (Array.isArray(alternate)) {
|
|
68
|
+
return alternate;
|
|
69
|
+
}
|
|
70
|
+
return alternate.response;
|
|
71
|
+
}).filter(item => item !== undefined);
|
|
72
|
+
return [flattenCorrect(question), ...alternates];
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Returns the score for a session. If weighted scoring is present in the correctResponse
|
|
77
|
+
* field for the question, this will be used. If partial scoring is present in the question
|
|
78
|
+
* model, this will be used. Otherwise the default scoring mechanism (0 for any incorrect, 1
|
|
79
|
+
* for all correct) will be used.
|
|
80
|
+
*/
|
|
81
|
+
exports.getAllCorrectResponses = getAllCorrectResponses;
|
|
82
|
+
const score = (question, session) => {
|
|
83
|
+
const {
|
|
84
|
+
value
|
|
85
|
+
} = session || {};
|
|
86
|
+
if (!value) {
|
|
87
|
+
return 0;
|
|
88
|
+
}
|
|
89
|
+
const allCorrectResponse = getAllCorrectResponses(question);
|
|
90
|
+
const allowDuplicates = (question.configure && question.configure.removeTilesAfterPlacing) !== false;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* We require this to be the case - locking
|
|
94
|
+
*/
|
|
95
|
+
//const orderMustBeComplete = true;
|
|
96
|
+
|
|
97
|
+
let bestScore = 0;
|
|
98
|
+
allCorrectResponse.forEach(cr => {
|
|
99
|
+
const currentScore = pairwiseCombinationScore(cr, value, {
|
|
100
|
+
allowDuplicates
|
|
101
|
+
});
|
|
102
|
+
if (currentScore >= bestScore) {
|
|
103
|
+
bestScore = currentScore;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
return bestScore;
|
|
107
|
+
};
|
|
108
|
+
exports.score = score;
|
|
109
|
+
//# sourceMappingURL=scoring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoring.js","names":["_lodashEs","require","_jsCombinatorics","_debug","_interopRequireDefault","log","debug","illegalArgumentError","answer","Error","exports","pairwiseCombinationScore","correct","opts","allowDuplicates","orderMustBeComplete","isEqual","uniq","length","Array","isArray","correctCombo","combination","toArray","answerCombo","diff","differenceWith","comboLengthDiff","total","actual","n","toFixed","parseFloat","flattenCorrect","question","correctResponse","map","r","id","getAllCorrectResponses","alternates","alternateResponses","alternate","response","filter","item","undefined","score","session","value","allCorrectResponse","configure","removeTilesAfterPlacing","bestScore","forEach","cr","currentScore"],"sources":["../src/scoring.js"],"sourcesContent":["import { differenceWith, isEqual, uniq } from 'lodash-es';\nimport { combination } from 'js-combinatorics';\nimport debug from 'debug';\n\nconst log = debug('pie-elements:placement-ordering:controller');\n\nexport const illegalArgumentError = (answer) =>\n new Error(`Cant score answer: ${answer} it has duplicates and allowDuplicates is false`);\nexport const pairwiseCombinationScore = (correct, answer, opts) => {\n opts = { allowDuplicates: false, orderMustBeComplete: false, ...opts };\n\n if (!opts.allowDuplicates && !isEqual(uniq(correct), correct)) {\n throw illegalArgumentError(answer);\n }\n\n if (opts.allowDuplicates === false && answer.length !== uniq(answer).length) {\n return 0;\n }\n\n answer = opts.allowDuplicates !== false ? answer : uniq(answer);\n\n log('answer:', answer);\n if (!Array.isArray(correct) || correct.length === 0) {\n throw new Error('correct must be non empty an array');\n }\n\n if (correct.length === 1) {\n return isEqual(correct, answer) ? 1 : 0;\n }\n\n if (!Array.isArray(answer) || answer.length < 2) {\n return 0;\n }\n\n if (answer.length > correct.length) {\n return 0;\n }\n\n if (correct.length !== answer.length && opts.orderMustBeComplete) {\n return 0;\n }\n\n const correctCombo = combination(correct, 2).toArray();\n const answerCombo = combination(answer, 2).toArray();\n\n const diff = differenceWith(answerCombo, correctCombo, isEqual);\n\n const comboLengthDiff = correctCombo.length - answerCombo.length;\n\n const total = correctCombo.length;\n const actual = total - diff.length - comboLengthDiff;\n\n const n = (actual / total).toFixed(2);\n\n return parseFloat(n);\n};\n\n/**\n * Flattens the correctResponse into an array of ordered identifiers representing the\n * correct response.\n */\nexport const flattenCorrect = (question) =>\n question.correctResponse ? question.correctResponse.map((r) => (r && r.id ? r.id : r)) : [];\n\n/**\n * Returns all correct responses for this question\n * @param question - array\n */\nexport const getAllCorrectResponses = (question) => {\n const alternates = (question.alternateResponses || [])\n .map((alternate) => {\n if (Array.isArray(alternate)) {\n return alternate;\n }\n\n return alternate.response;\n })\n .filter((item) => item !== undefined);\n\n return [flattenCorrect(question), ...alternates];\n};\n\n/**\n * Returns the score for a session. If weighted scoring is present in the correctResponse\n * field for the question, this will be used. If partial scoring is present in the question\n * model, this will be used. Otherwise the default scoring mechanism (0 for any incorrect, 1\n * for all correct) will be used.\n */\n\nexport const score = (question, session) => {\n const { value } = session || {};\n\n if (!value) {\n return 0;\n }\n\n const allCorrectResponse = getAllCorrectResponses(question);\n const allowDuplicates = (question.configure && question.configure.removeTilesAfterPlacing) !== false;\n\n /**\n * We require this to be the case - locking\n */\n //const orderMustBeComplete = true;\n\n let bestScore = 0;\n\n allCorrectResponse.forEach((cr) => {\n const currentScore = pairwiseCombinationScore(cr, value, {\n allowDuplicates,\n });\n\n if (currentScore >= bestScore) {\n bestScore = currentScore;\n }\n });\n\n return bestScore;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,MAAMI,GAAG,GAAG,IAAAC,cAAK,EAAC,4CAA4C,CAAC;AAExD,MAAMC,oBAAoB,GAAIC,MAAM,IACzC,IAAIC,KAAK,CAAC,sBAAsBD,MAAM,iDAAiD,CAAC;AAACE,OAAA,CAAAH,oBAAA,GAAAA,oBAAA;AACpF,MAAMI,wBAAwB,GAAGA,CAACC,OAAO,EAAEJ,MAAM,EAAEK,IAAI,KAAK;EACjEA,IAAI,GAAG;IAAEC,eAAe,EAAE,KAAK;IAAEC,mBAAmB,EAAE,KAAK;IAAE,GAAGF;EAAK,CAAC;EAEtE,IAAI,CAACA,IAAI,CAACC,eAAe,IAAI,CAAC,IAAAE,iBAAO,EAAC,IAAAC,cAAI,EAACL,OAAO,CAAC,EAAEA,OAAO,CAAC,EAAE;IAC7D,MAAML,oBAAoB,CAACC,MAAM,CAAC;EACpC;EAEA,IAAIK,IAAI,CAACC,eAAe,KAAK,KAAK,IAAIN,MAAM,CAACU,MAAM,KAAK,IAAAD,cAAI,EAACT,MAAM,CAAC,CAACU,MAAM,EAAE;IAC3E,OAAO,CAAC;EACV;EAEAV,MAAM,GAAGK,IAAI,CAACC,eAAe,KAAK,KAAK,GAAGN,MAAM,GAAG,IAAAS,cAAI,EAACT,MAAM,CAAC;EAE/DH,GAAG,CAAC,SAAS,EAAEG,MAAM,CAAC;EACtB,IAAI,CAACW,KAAK,CAACC,OAAO,CAACR,OAAO,CAAC,IAAIA,OAAO,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,KAAK,EAAE;MACvDnC;IACF,CAAC,CAAC;IAEF,IAAI0C,YAAY,IAAIH,SAAS,EAAE;MAC7BA,SAAS,GAAGG,YAAY;IAC1B;EACF,CAAC,CAAC;EAEF,OAAOH,SAAS;AAClB,CAAC;AAAC3C,OAAA,CAAAqC,KAAA,GAAAA,KAAA","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pie-element/placement-ordering-controller",
|
|
3
|
+
"version": "11.1.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"module": "src/index.js",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@pie-lib/controller-utils": "2.0.2",
|
|
9
|
+
"@pie-lib/feedback": "2.0.2",
|
|
10
|
+
"@pie-lib/translator": "4.0.2",
|
|
11
|
+
"debug": "^4.1.1",
|
|
12
|
+
"js-combinatorics": "^0.5.4",
|
|
13
|
+
"lodash-es": "^4.17.23"
|
|
14
|
+
}
|
|
15
|
+
}
|