@digabi/exam-engine-generator 16.1.2
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +13 -0
- package/dist/__tests__/testGenerateAnswers.d.ts +2 -0
- package/dist/__tests__/testGenerateAnswers.d.ts.map +1 -0
- package/dist/__tests__/testGenerateAnswers.js +59 -0
- package/dist/__tests__/testGenerateAnswers.js.map +1 -0
- package/dist/__tests__/testGenerateExam.d.ts +2 -0
- package/dist/__tests__/testGenerateExam.d.ts.map +1 -0
- package/dist/__tests__/testGenerateExam.js +250 -0
- package/dist/__tests__/testGenerateExam.js.map +1 -0
- package/dist/__tests__/tsconfig.tsbuildinfo +1 -0
- package/dist/generateAnswers.d.ts +3 -0
- package/dist/generateAnswers.d.ts.map +1 -0
- package/dist/generateAnswers.js +43 -0
- package/dist/generateAnswers.js.map +1 -0
- package/dist/generateExam.d.ts +117 -0
- package/dist/generateExam.d.ts.map +1 -0
- package/dist/generateExam.js +188 -0
- package/dist/generateExam.js.map +1 -0
- package/dist/generateExamOptions.d.ts +27 -0
- package/dist/generateExamOptions.d.ts.map +1 -0
- package/dist/generateExamOptions.js +88 -0
- package/dist/generateExamOptions.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/package.json +16 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"generateExam.d.ts","sourceRoot":"","sources":["../src/generateExam.ts"],"names":[],"mappings":"AAEA,oBAAY,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAA;AAExC,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,QAAQ,CAAA;IAClB,IAAI,CAAC,EAAE,QAAQ,GAAG,mBAAmB,GAAG,kBAAkB,CAAA;CAC3D;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,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AAE,iBAAiB,CAAA;IACvB,OAAO,EAAE,0BAA0B,EAAE,CAAA;CACtC;AAED,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CA6BjE"}
|
@@ -0,0 +1,188 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11
|
+
}) : function(o, v) {
|
12
|
+
o["default"] = v;
|
13
|
+
});
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
15
|
+
if (mod && mod.__esModule) return mod;
|
16
|
+
var result = {};
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18
|
+
__setModuleDefault(result, mod);
|
19
|
+
return result;
|
20
|
+
};
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
22
|
+
exports.generateExam = void 0;
|
23
|
+
const libxml = __importStar(require("libxmljs2"));
|
24
|
+
/**
|
25
|
+
* Generates an exam XML file (mostly for testing purposes) based on a
|
26
|
+
* description of the exam structure.
|
27
|
+
*
|
28
|
+
* - An exam is an object containing the array of sections and optional attributes.
|
29
|
+
* - A section is object containing the array of questions and optional attributes.
|
30
|
+
* - A question is an array of answers or subquestions.
|
31
|
+
* - An answer is an object describing the answer.
|
32
|
+
*
|
33
|
+
* ```
|
34
|
+
* generateExam({
|
35
|
+
* sections: [
|
36
|
+
* // Section I
|
37
|
+
* {
|
38
|
+
* questions: [
|
39
|
+
* // Question 1 containing a single text-answer.
|
40
|
+
* [textAnswer()],
|
41
|
+
* // Question 2 containing three choice-answers.
|
42
|
+
* [choiceAnswer(), choiceAnswer(), choiceAnswer()],
|
43
|
+
* // Question 3 containing subquestions
|
44
|
+
* [
|
45
|
+
* // Question 3.1, containing a single dropdown-answer
|
46
|
+
* [dropdownAnswer()],
|
47
|
+
* ]
|
48
|
+
* ]
|
49
|
+
* }
|
50
|
+
* ]
|
51
|
+
* })
|
52
|
+
* ```
|
53
|
+
*
|
54
|
+
* You can customize the exam and section elements by providing some of the
|
55
|
+
* optional attributes.
|
56
|
+
*
|
57
|
+
* ```
|
58
|
+
* generateExam({
|
59
|
+
* examCode: 'M',
|
60
|
+
* date: '2020-03-18',
|
61
|
+
* sections: [{
|
62
|
+
* casForbidden: true,
|
63
|
+
* maxAnswers: 5,
|
64
|
+
* questions: […]
|
65
|
+
* }, {
|
66
|
+
* casForbidden: false,
|
67
|
+
* maxAnswers: 5,
|
68
|
+
* questions: […]
|
69
|
+
* }]
|
70
|
+
* })
|
71
|
+
* ```
|
72
|
+
*
|
73
|
+
* It is also possible to customize the answer elements. For example, if you
|
74
|
+
* need a text-answer with a different max-score, you can override the default
|
75
|
+
* attributes in the various fooAnswer-functions.
|
76
|
+
*
|
77
|
+
* ```
|
78
|
+
* generateExam({ sections: [{ questions: [[textAnswer({ maxScore: 10 })]] }] })
|
79
|
+
* ```
|
80
|
+
*/
|
81
|
+
function generateExam(options) {
|
82
|
+
var _a;
|
83
|
+
const doc = new libxml.Document();
|
84
|
+
const exam = createElement(doc, 'exam', undefined, {
|
85
|
+
xmlns: 'http://www.w3.org/1999/xhtml',
|
86
|
+
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
87
|
+
'xsi:schemaLocation': 'http://ylioppilastutkinto.fi/exam.xsd https://abitti.dev/schema/exam.xsd',
|
88
|
+
'exam-schema-version': '0.3',
|
89
|
+
'exam-code': options.examCode,
|
90
|
+
'day-code': options.dayCode,
|
91
|
+
date: options.date,
|
92
|
+
'max-answers': options.maxAnswers,
|
93
|
+
});
|
94
|
+
const examVersions = (_a = options.examVersions) !== null && _a !== void 0 ? _a : [{ language: 'fi-FI' }];
|
95
|
+
const languages = examVersions.map((v) => v.language);
|
96
|
+
const examVersionsElement = createElement(exam, 'exam-versions');
|
97
|
+
for (const { language, type } of examVersions) {
|
98
|
+
createElement(examVersionsElement, 'exam-version', undefined, { lang: language, 'exam-type': type });
|
99
|
+
}
|
100
|
+
if (!options.examCode) {
|
101
|
+
createLocalizedElement(exam, 'exam-title', languages, { 'fi-FI': 'Kokeen otsikko', 'sv-FI': 'Provets titel' });
|
102
|
+
}
|
103
|
+
for (const section of options.sections) {
|
104
|
+
addSection(exam, languages, section);
|
105
|
+
}
|
106
|
+
return doc.toString(true);
|
107
|
+
}
|
108
|
+
exports.generateExam = generateExam;
|
109
|
+
function addSection(exam, languages, options) {
|
110
|
+
const section = createElement(exam, 'section', undefined, {
|
111
|
+
'max-answers': options.maxAnswers,
|
112
|
+
'cas-forbidden': options.casForbidden,
|
113
|
+
});
|
114
|
+
createLocalizedElement(section, 'section-title', languages, { 'fi-FI': 'Osan otsikko', 'sv-FI': 'Delens titel' });
|
115
|
+
for (const question of options.questions) {
|
116
|
+
addQuestion(section, languages, question);
|
117
|
+
}
|
118
|
+
}
|
119
|
+
function addQuestion(parent, languages, options) {
|
120
|
+
const question = createElement(parent, 'question', undefined, { 'max-answers': options.maxAnswers });
|
121
|
+
createLocalizedElement(question, 'question-title', languages, {
|
122
|
+
'fi-FI': 'Kysymyksen otsikko',
|
123
|
+
'sv-FI': 'Uppgiftens titel',
|
124
|
+
});
|
125
|
+
if ('questions' in options) {
|
126
|
+
for (const subQuestion of options.questions) {
|
127
|
+
addQuestion(question, languages, subQuestion);
|
128
|
+
}
|
129
|
+
}
|
130
|
+
else {
|
131
|
+
for (const answer of options.answers) {
|
132
|
+
switch (answer.name) {
|
133
|
+
case 'text-answer':
|
134
|
+
case 'scored-text-answer': {
|
135
|
+
addTextAnswer(question, answer);
|
136
|
+
break;
|
137
|
+
}
|
138
|
+
case 'choice-answer':
|
139
|
+
case 'dropdown-answer': {
|
140
|
+
addChoiceAnswer(question, answer);
|
141
|
+
break;
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
147
|
+
function addTextAnswer(question, options) {
|
148
|
+
const answer = createElement(question, options.name, undefined, {
|
149
|
+
'max-score': options.maxScore,
|
150
|
+
type: options.type,
|
151
|
+
});
|
152
|
+
if (options.hint) {
|
153
|
+
createElement(answer, 'hint', options.hint);
|
154
|
+
}
|
155
|
+
if (options.name === 'scored-text-answer' && options.acceptedAnswers) {
|
156
|
+
for (const { score, text } of options.acceptedAnswers) {
|
157
|
+
createElement(answer, 'accepted-answer', text, { score });
|
158
|
+
}
|
159
|
+
}
|
160
|
+
}
|
161
|
+
function addChoiceAnswer(question, options) {
|
162
|
+
const answer = createElement(question, options.name);
|
163
|
+
const optionType = options.name === 'choice-answer' ? 'choice-answer-option' : 'dropdown-answer-option';
|
164
|
+
for (const { text, score } of options.options) {
|
165
|
+
createElement(answer, optionType, text, { score });
|
166
|
+
}
|
167
|
+
}
|
168
|
+
function createElement(parent, localName, content, attrs) {
|
169
|
+
const element = parent.node(localName, content).namespace('e', 'http://ylioppilastutkinto.fi/exam.xsd');
|
170
|
+
if (attrs) {
|
171
|
+
Object.entries(attrs)
|
172
|
+
.filter(([, value]) => value != null)
|
173
|
+
.forEach(([name, value]) => element.attr(name, String(value)));
|
174
|
+
}
|
175
|
+
return element;
|
176
|
+
}
|
177
|
+
function createLocalizedElement(parent, localName, languages, content, attrs) {
|
178
|
+
if (languages.length === 1) {
|
179
|
+
const [language] = languages;
|
180
|
+
return createElement(parent, localName, content[language], attrs);
|
181
|
+
}
|
182
|
+
const element = createElement(parent, localName, undefined, attrs);
|
183
|
+
Object.entries(content)
|
184
|
+
.filter(([language]) => languages.includes(language))
|
185
|
+
.forEach(([lang, text]) => createElement(element, 'localization', text, { lang }));
|
186
|
+
return element;
|
187
|
+
}
|
188
|
+
//# sourceMappingURL=generateExam.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"generateExam.js","sourceRoot":"","sources":["../src/generateExam.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAmC;AA8EnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,SAAgB,YAAY,CAAC,OAA4B;;IACvD,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAA;IACjC,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE;QACjD,KAAK,EAAE,8BAA8B;QACrC,WAAW,EAAE,2CAA2C;QACxD,oBAAoB,EAAE,0EAA0E;QAChG,qBAAqB,EAAE,KAAK;QAC5B,WAAW,EAAE,OAAO,CAAC,QAAQ;QAC7B,UAAU,EAAE,OAAO,CAAC,OAAO;QAC3B,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,aAAa,EAAE,OAAO,CAAC,UAAU;KAClC,CAAC,CAAA;IACF,MAAM,YAAY,GAAG,MAAA,OAAO,CAAC,YAAY,mCAAI,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAA;IACpE,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;IACrD,MAAM,mBAAmB,GAAG,aAAa,CAAC,IAAI,EAAE,eAAe,CAAC,CAAA;IAEhE,KAAK,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IA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AAK,CAAC,CAAA;KAClE;IAED,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;IAElE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;SACpB,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAoB,CAAC,CAAC;SAChE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAEpF,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { GenerateAnswerOptions, GenerateChoiceAnswerOptions, GenerateDropdownAnswerOptions, GenerateQuestionOptions, GenerateScoredTextAnswerOptions, GenerateTextAnswerOptions } from './generateExam';
|
2
|
+
/**
|
3
|
+
* A shorthand version of the function for creating a question containing the specified answers.
|
4
|
+
*
|
5
|
+
* @param answers An array of answers.
|
6
|
+
* @example question([textAnswer()]) // Equivalent to question({ answers: [textAnswer()] })
|
7
|
+
*/
|
8
|
+
export declare function question(answers: GenerateAnswerOptions[]): GenerateQuestionOptions;
|
9
|
+
/**
|
10
|
+
* A shorthand version of the function for creating a question containing the specified child questions.
|
11
|
+
*
|
12
|
+
* @param questions An array of child questions.
|
13
|
+
* @example question([question(…)]) // Equivalent to question({ questions: [question(…)] })
|
14
|
+
*/
|
15
|
+
export declare function question(questions: GenerateQuestionOptions[]): GenerateQuestionOptions;
|
16
|
+
/**
|
17
|
+
* Create a question.
|
18
|
+
*
|
19
|
+
* @param options An object describing the structure of the question.
|
20
|
+
* @example question({ maxAnswers: 1, answers: [textAnswer(), textAnswer()] })
|
21
|
+
*/
|
22
|
+
export declare function question(options: GenerateQuestionOptions): GenerateQuestionOptions;
|
23
|
+
export declare function textAnswer(options?: Partial<GenerateTextAnswerOptions>): GenerateTextAnswerOptions;
|
24
|
+
export declare function scoredTextAnswer(options?: Partial<GenerateScoredTextAnswerOptions>): GenerateScoredTextAnswerOptions;
|
25
|
+
export declare function choiceAnswer(options?: Partial<GenerateChoiceAnswerOptions>): GenerateChoiceAnswerOptions;
|
26
|
+
export declare function dropdownAnswer(options?: Partial<GenerateDropdownAnswerOptions>): GenerateDropdownAnswerOptions;
|
27
|
+
//# sourceMappingURL=generateExamOptions.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"generateExamOptions.d.ts","sourceRoot":"","sources":["../src/generateExamOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAC3B,6BAA6B,EAC7B,uBAAuB,EACvB,+BAA+B,EAC/B,yBAAyB,EAC1B,MAAM,gBAAgB,CAAA;AAEvB;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,qBAAqB,EAAE,GAAG,uBAAuB,CAAA;AACnF;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,uBAAuB,EAAE,GAAG,uBAAuB,CAAA;AACvF;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,uBAAuB,GAAG,uBAAuB,CAAA;AAenF,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,GAAG,yBAAyB,CAOlG;AAED,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,+BAA+B,CAAC,GAAG,+BAA+B,CAiBpH;AAED,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,GAAG,2BAA2B,CAmBxG;AAED,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,6BAA6B,CAAC,GAAG,6BAA6B,CAmB9G"}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.dropdownAnswer = exports.choiceAnswer = exports.scoredTextAnswer = exports.textAnswer = exports.question = void 0;
|
4
|
+
function question(args) {
|
5
|
+
if (Array.isArray(args)) {
|
6
|
+
if ('answers' in args[0] || 'questions' in args[0]) {
|
7
|
+
return { questions: args };
|
8
|
+
}
|
9
|
+
else {
|
10
|
+
return { answers: args };
|
11
|
+
}
|
12
|
+
}
|
13
|
+
else {
|
14
|
+
return args;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
exports.question = question;
|
18
|
+
function textAnswer(options) {
|
19
|
+
return {
|
20
|
+
name: 'text-answer',
|
21
|
+
maxScore: 6,
|
22
|
+
type: 'rich-text',
|
23
|
+
...options,
|
24
|
+
};
|
25
|
+
}
|
26
|
+
exports.textAnswer = textAnswer;
|
27
|
+
function scoredTextAnswer(options) {
|
28
|
+
return {
|
29
|
+
name: 'scored-text-answer',
|
30
|
+
hint: 'Vihje',
|
31
|
+
acceptedAnswers: [
|
32
|
+
{
|
33
|
+
text: 'Oikea vaihtoehto',
|
34
|
+
score: 3,
|
35
|
+
},
|
36
|
+
// The legacy exam generator expects this to be the correct answer. (ノಠ益ಠ)ノ彡┻━┻
|
37
|
+
{
|
38
|
+
text: 'lol',
|
39
|
+
score: 3,
|
40
|
+
},
|
41
|
+
],
|
42
|
+
...options,
|
43
|
+
};
|
44
|
+
}
|
45
|
+
exports.scoredTextAnswer = scoredTextAnswer;
|
46
|
+
function choiceAnswer(options) {
|
47
|
+
return {
|
48
|
+
name: 'choice-answer',
|
49
|
+
options: [
|
50
|
+
{
|
51
|
+
text: 'Oikea vaihtoehto',
|
52
|
+
score: 3,
|
53
|
+
},
|
54
|
+
{
|
55
|
+
text: 'Väärä vaihtoehto',
|
56
|
+
score: 0,
|
57
|
+
},
|
58
|
+
{
|
59
|
+
text: 'Väärä vaihtoehto',
|
60
|
+
score: 0,
|
61
|
+
},
|
62
|
+
],
|
63
|
+
...options,
|
64
|
+
};
|
65
|
+
}
|
66
|
+
exports.choiceAnswer = choiceAnswer;
|
67
|
+
function dropdownAnswer(options) {
|
68
|
+
return {
|
69
|
+
name: 'dropdown-answer',
|
70
|
+
options: [
|
71
|
+
{
|
72
|
+
text: 'Oikea vaihtoehto',
|
73
|
+
score: 3,
|
74
|
+
},
|
75
|
+
{
|
76
|
+
text: 'Väärä vaihtoehto',
|
77
|
+
score: 0,
|
78
|
+
},
|
79
|
+
{
|
80
|
+
text: 'Väärä vaihtoehto',
|
81
|
+
score: 0,
|
82
|
+
},
|
83
|
+
],
|
84
|
+
...options,
|
85
|
+
};
|
86
|
+
}
|
87
|
+
exports.dropdownAnswer = dropdownAnswer;
|
88
|
+
//# sourceMappingURL=generateExamOptions.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"generateExamOptions.js","sourceRoot":"","sources":["../src/generateExamOptions.ts"],"names":[],"mappings":";;;AA8BA,SAAgB,QAAQ,CACtB,IAAmF;IAEnF,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACvB,IAAI,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE;YAClD,OAAO,EAAE,SAAS,EAAE,IAAiC,EAAE,CAAA;SACxD;aAAM;YACL,OAAO,EAAE,OAAO,EAAE,IAA+B,EAAE,CAAA;SACpD;KACF;SAAM;QACL,OAAO,IAAI,CAAA;KACZ;AACH,CAAC;AAZD,4BAYC;AAED,SAAgB,UAAU,CAAC,OAA4C;IACrE,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,CAAC;QACX,IAAI,EAAE,WAAW;QACjB,GAAG,OAAO;KACX,CAAA;AACH,CAAC;AAPD,gCAOC;AAED,SAAgB,gBAAgB,CAAC,OAAkD;IACjF,OAAO;QACL,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,OAAO;QACb,eAAe,EAAE;YACf;gBACE,IAAI,EAAE,kBAAkB;gBACxB,KAAK,EAAE,CAAC;aACT;YACD,+EAA+E;YAC/E;gBACE,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE,CAAC;aACT;SACF;QACD,GAAG,OAAO;KACX,CAAA;AACH,CAAC;AAjBD,4CAiBC;AAED,SAAgB,YAAY,CAAC,OAA8C;IACzE,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,kBAAkB;gBACxB,KAAK,EAAE,CAAC;aACT;YACD;gBACE,IAAI,EAAE,kBAAkB;gBACxB,KAAK,EAAE,CAAC;aACT;YACD;gBACE,IAAI,EAAE,kBAAkB;gBACxB,KAAK,EAAE,CAAC;aACT;SACF;QACD,GAAG,OAAO;KACX,CAAA;AACH,CAAC;AAnBD,oCAmBC;AAED,SAAgB,cAAc,CAAC,OAAgD;IAC7E,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,kBAAkB;gBACxB,KAAK,EAAE,CAAC;aACT;YACD;gBACE,IAAI,EAAE,kBAAkB;gBACxB,KAAK,EAAE,CAAC;aACT;YACD;gBACE,IAAI,EAAE,kBAAkB;gBACxB,KAAK,EAAE,CAAC;aACT;SACF;QACD,GAAG,OAAO;KACX,CAAA;AACH,CAAC;AAnBD,wCAmBC"}
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA"}
|
package/dist/index.js
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
11
|
+
};
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
+
__exportStar(require("./generateAnswers"), exports);
|
14
|
+
__exportStar(require("./generateExam"), exports);
|
15
|
+
__exportStar(require("./generateExamOptions"), exports);
|
16
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiC;AACjC,iDAA8B;AAC9B,wDAAqC"}
|
package/package.json
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"name": "@digabi/exam-engine-generator",
|
3
|
+
"version": "16.1.2",
|
4
|
+
"main": "dist/index.js",
|
5
|
+
"author": "Matriculation Examination Board, Finland",
|
6
|
+
"license": "EUPL-1.1",
|
7
|
+
"files": [
|
8
|
+
"dist"
|
9
|
+
],
|
10
|
+
"dependencies": {
|
11
|
+
"@digabi/exam-engine-core": "16.1.2",
|
12
|
+
"libxmljs2": "^0.28.0",
|
13
|
+
"lodash": "^4.17.15"
|
14
|
+
},
|
15
|
+
"gitHead": "190d0f49e0703fa2c6a03a336df3d8aae7764996"
|
16
|
+
}
|