@digabi/exam-engine-mastering 19.15.4 → 19.15.5-alpha.1
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHvp.d.ts","sourceRoot":"","sources":["../../src/mastering/createHvp.js"],"names":[],"mappings":"AASyB,0FA+FxB"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ramda_1 = __importDefault(require("ramda"));
|
|
7
|
+
const schema_1 = require("./schema");
|
|
8
|
+
/**
|
|
9
|
+
* Generates HVP.
|
|
10
|
+
*
|
|
11
|
+
* @param {import("libxmljs2").Document} doc
|
|
12
|
+
* @param {string} targetLanguage
|
|
13
|
+
*/
|
|
14
|
+
exports.createHvp = (doc, targetLanguage) => {
|
|
15
|
+
const cleanString = (input) => input.trim().replace(/\s+/g, ' ');
|
|
16
|
+
const nodeContains = (elementName, node) => {
|
|
17
|
+
return node.find(`.//${elementName}`, schema_1.ns).length > 0;
|
|
18
|
+
};
|
|
19
|
+
const findQuestionTypes = (node) => {
|
|
20
|
+
const elementNamesToTypes = {
|
|
21
|
+
'fi-FI': {
|
|
22
|
+
'e:scored-text-answer': 'keskitetysti arvosteltava tekstivastaus',
|
|
23
|
+
'e:choice-answer': 'monivalintavastaus',
|
|
24
|
+
'e:dropdown-answer': 'monivalintavastaus',
|
|
25
|
+
'e:text-answer': 'tekstivastaus',
|
|
26
|
+
},
|
|
27
|
+
'sv-FI': {
|
|
28
|
+
'e:scored-text-answer': 'centraliserat bedömt textsvar',
|
|
29
|
+
'e:choice-answer': 'flervalssvar',
|
|
30
|
+
'e:dropdown-answer': 'flervalssvar',
|
|
31
|
+
'e:text-answer': 'textsvar',
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
const elementNamesToTypesInTargetLanguage = elementNamesToTypes[targetLanguage];
|
|
35
|
+
return Object.keys(elementNamesToTypesInTargetLanguage)
|
|
36
|
+
.map((elementName) => (nodeContains(elementName, node) ? elementNamesToTypesInTargetLanguage[elementName] : null))
|
|
37
|
+
.filter((x) => x !== null);
|
|
38
|
+
};
|
|
39
|
+
const optionsWithScoresString = function (node, optionElementName) {
|
|
40
|
+
const prefix = optionElementName === 'e:choice-answer-option' ? '-' : ramda_1.default.last(getDisplayNumber(node).split('.')) + '.';
|
|
41
|
+
return node
|
|
42
|
+
.find(`.//${optionElementName}[@score]`, schema_1.ns)
|
|
43
|
+
.map((o) => `${prefix} ${cleanString(o.text())} (${o.attr('score').value()} p.)`)
|
|
44
|
+
.join('\n');
|
|
45
|
+
};
|
|
46
|
+
const getAttributeValue = (attributeName) => (node) => node.attr(attributeName).value();
|
|
47
|
+
const getMaxScore = getAttributeValue('max-score');
|
|
48
|
+
const getScore = getAttributeValue('score');
|
|
49
|
+
const getDisplayNumber = getAttributeValue('display-number');
|
|
50
|
+
const nodeToStrings = function (node) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
switch (node.name()) {
|
|
53
|
+
case 'exam-title':
|
|
54
|
+
return [cleanString(node.text())];
|
|
55
|
+
case 'section': {
|
|
56
|
+
const sectionTitle = cleanString(node.get('./e:section-title', schema_1.ns).text());
|
|
57
|
+
return [
|
|
58
|
+
`\n### ${targetLanguage === 'sv-FI' ? 'Del' : 'Osa'} ${getDisplayNumber(node)}: ${sectionTitle} (${getMaxScore(node)} p.)`,
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
case 'question': {
|
|
62
|
+
const displayNumber = getDisplayNumber(node);
|
|
63
|
+
const isTopLevelQuestion = !displayNumber.includes('.');
|
|
64
|
+
const answerTypesInQuestion = findQuestionTypes(node);
|
|
65
|
+
const questionTitle = cleanString(node.find('e:question-title', schema_1.ns)[0].text());
|
|
66
|
+
return [
|
|
67
|
+
`\n${isTopLevelQuestion ? '#### ' : ''}${displayNumber}. ${questionTitle} (${getMaxScore(node)} p.) ${isTopLevelQuestion ? '' : '(' + answerTypesInQuestion.join(', ') + ')'}\n`,
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
case 'choice-answer': {
|
|
71
|
+
return [optionsWithScoresString(node, 'e:choice-answer-option')];
|
|
72
|
+
}
|
|
73
|
+
case 'scored-text-answer': {
|
|
74
|
+
return [
|
|
75
|
+
`- ${getDisplayNumber(node)}. ${(_b = (_a = node.get('./e:hint', schema_1.ns)) === null || _a === void 0 ? void 0 : _a.text().trim()) !== null && _b !== void 0 ? _b : ''}\n${node
|
|
76
|
+
.find('.//e:accepted-answer[@score]', schema_1.ns)
|
|
77
|
+
.map((elem) => ` - ${cleanString(elem.text())} (${getScore(elem)} p.)`)
|
|
78
|
+
.join('\n')}`,
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
case 'dropdown-answer': {
|
|
82
|
+
return [optionsWithScoresString(node, 'e:dropdown-answer-option')];
|
|
83
|
+
}
|
|
84
|
+
default:
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const processNode = (node) => {
|
|
89
|
+
if (node.type() !== 'element') {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
const childNodes = node.childNodes();
|
|
93
|
+
return childNodes.length !== 0 ? [...nodeToStrings(node), ...childNodes.map(processNode)] : [];
|
|
94
|
+
};
|
|
95
|
+
return ramda_1.default.flatten(doc.childNodes().map(processNode)).join('\n').trim();
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=createHvp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHvp.js","sourceRoot":"","sources":["../../src/mastering/createHvp.js"],"names":[],"mappings":";;;;;AAAA,kDAAqB;AACrB,qCAA6B;AAE7B;;;;;GAKG;AACU,QAAA,SAA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,OAAO,CAAC,uBAAuB,CAAC,IAAI,EAAE,0BAA0B,CAAC,CAAC,CAAA;aACnE;YACD;gBACE,OAAO,EAAE,CAAA;SACZ;IACH,CAAC,CAAA;IAED,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,EAAE;QAC3B,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,SAAS,EAAE;YAC7B,OAAO,EAAE,CAAA;SACV;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA;QACpC,OAAO,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAChG,CAAC,CAAA;IAED,OAAO,eAAC,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAA;AACvE,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digabi/exam-engine-mastering",
|
|
3
|
-
"version": "19.15.
|
|
3
|
+
"version": "19.15.5-alpha.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"author": "Matriculation Examination Board, Finland",
|
|
6
6
|
"license": "EUPL-1.1",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"schema"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@digabi/exam-engine-core": "19.15.
|
|
13
|
-
"@digabi/exam-engine-rendering": "19.15.
|
|
12
|
+
"@digabi/exam-engine-core": "19.15.5-alpha.1",
|
|
13
|
+
"@digabi/exam-engine-rendering": "19.15.5-alpha.1",
|
|
14
14
|
"@ffprobe-installer/ffprobe": "^2.0.0",
|
|
15
15
|
"cloneable-readable": "^3.0.0",
|
|
16
16
|
"compare-versions": "^6.0.0",
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"mathjax-node": "^2.1.1",
|
|
22
22
|
"yazl": "^2.5.1"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "c669efe79eda2d89d7d1a267df11e9692e7b5026"
|
|
25
25
|
}
|