@gmb/bitmark-parser-generator 1.0.16 → 1.1.0
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/dist/browser/bitmark-parser-generator-antlr.min.js +1 -1
- package/dist/browser/bitmark-parser-generator.min.js +1 -1
- package/dist/browser/bundle-report.html +2 -2
- package/dist/cjs/ast/BaseBuilder.js +63 -15
- package/dist/cjs/ast/BaseBuilder.js.map +1 -1
- package/dist/cjs/ast/Builder.js +345 -179
- package/dist/cjs/ast/Builder.js.map +1 -1
- package/dist/cjs/config/bits/articleBitConfig.js +66 -47
- package/dist/cjs/config/bits/articleBitConfig.js.map +1 -1
- package/dist/cjs/config/bits/essayBitConfig.js +2 -0
- package/dist/cjs/config/bits/essayBitConfig.js.map +1 -1
- package/dist/cjs/config/bits/imageBitConfig.js +3 -0
- package/dist/cjs/config/bits/imageBitConfig.js.map +1 -1
- package/dist/cjs/config/bits/sequenceBitConfig.js +2 -0
- package/dist/cjs/config/bits/sequenceBitConfig.js.map +1 -1
- package/dist/cjs/config/bits/trueFalse1BitConfig.js +2 -0
- package/dist/cjs/config/bits/trueFalse1BitConfig.js.map +1 -1
- package/dist/cjs/config/properties/examplePropertyConfig.js +1 -1
- package/dist/cjs/config/properties/examplePropertyConfig.js.map +1 -1
- package/dist/cjs/generated/build-info.js +1 -1
- package/dist/cjs/generated/build-info.js.map +1 -1
- package/dist/cjs/generator/bitmark/BitmarkGenerator.js +39 -20
- package/dist/cjs/generator/bitmark/BitmarkGenerator.js.map +1 -1
- package/dist/cjs/generator/json/JsonGenerator.js +157 -88
- package/dist/cjs/generator/json/JsonGenerator.js.map +1 -1
- package/dist/cjs/model/ast/NodeType.js +2 -1
- package/dist/cjs/model/ast/NodeType.js.map +1 -1
- package/dist/cjs/model/enum/BitType.js +21 -0
- package/dist/cjs/model/enum/BitType.js.map +1 -1
- package/dist/cjs/model/enum/ExampleType.js +11 -0
- package/dist/cjs/model/enum/ExampleType.js.map +1 -0
- package/dist/cjs/parser/bitmark/peg/BitmarkPegParserTypes.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/CardContentProcessor.js +23 -7
- package/dist/cjs/parser/bitmark/peg/contentProcessors/CardContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js +61 -0
- package/dist/cjs/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js.map +1 -0
- package/dist/cjs/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js +6 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js.map +1 -1
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js +1 -0
- package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js.map +1 -1
- package/dist/cjs/parser/json/JsonParser.js +35 -33
- package/dist/cjs/parser/json/JsonParser.js.map +1 -1
- package/dist/cjs/utils/ObjectUtils.js +10 -5
- package/dist/cjs/utils/ObjectUtils.js.map +1 -1
- package/dist/esm/ast/BaseBuilder.js +63 -15
- package/dist/esm/ast/BaseBuilder.js.map +1 -1
- package/dist/esm/ast/Builder.js +345 -179
- package/dist/esm/ast/Builder.js.map +1 -1
- package/dist/esm/config/bits/articleBitConfig.js +66 -47
- package/dist/esm/config/bits/articleBitConfig.js.map +1 -1
- package/dist/esm/config/bits/essayBitConfig.js +2 -0
- package/dist/esm/config/bits/essayBitConfig.js.map +1 -1
- package/dist/esm/config/bits/imageBitConfig.js +3 -0
- package/dist/esm/config/bits/imageBitConfig.js.map +1 -1
- package/dist/esm/config/bits/sequenceBitConfig.js +2 -0
- package/dist/esm/config/bits/sequenceBitConfig.js.map +1 -1
- package/dist/esm/config/bits/trueFalse1BitConfig.js +2 -0
- package/dist/esm/config/bits/trueFalse1BitConfig.js.map +1 -1
- package/dist/esm/config/properties/examplePropertyConfig.js +1 -1
- package/dist/esm/config/properties/examplePropertyConfig.js.map +1 -1
- package/dist/esm/generated/build-info.js +1 -1
- package/dist/esm/generated/build-info.js.map +1 -1
- package/dist/esm/generator/bitmark/BitmarkGenerator.js +39 -20
- package/dist/esm/generator/bitmark/BitmarkGenerator.js.map +1 -1
- package/dist/esm/generator/json/JsonGenerator.js +157 -88
- package/dist/esm/generator/json/JsonGenerator.js.map +1 -1
- package/dist/esm/model/ast/NodeType.js +2 -1
- package/dist/esm/model/ast/NodeType.js.map +1 -1
- package/dist/esm/model/enum/BitType.js +21 -0
- package/dist/esm/model/enum/BitType.js.map +1 -1
- package/dist/esm/model/enum/ExampleType.js +8 -0
- package/dist/esm/model/enum/ExampleType.js.map +1 -0
- package/dist/esm/parser/bitmark/peg/BitmarkPegParserTypes.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/CardContentProcessor.js +23 -7
- package/dist/esm/parser/bitmark/peg/contentProcessors/CardContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js +58 -0
- package/dist/esm/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js.map +1 -0
- package/dist/esm/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js +6 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js.map +1 -1
- package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js +1 -0
- package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js.map +1 -1
- package/dist/esm/parser/json/JsonParser.js +35 -33
- package/dist/esm/parser/json/JsonParser.js.map +1 -1
- package/dist/esm/utils/ObjectUtils.js +10 -5
- package/dist/esm/utils/ObjectUtils.js.map +1 -1
- package/dist/types/ast/BaseBuilder.d.ts +23 -4
- package/dist/types/ast/BaseBuilder.d.ts.map +1 -1
- package/dist/types/ast/Builder.d.ts +40 -15
- package/dist/types/ast/Builder.d.ts.map +1 -1
- package/dist/types/generator/bitmark/BitmarkGenerator.d.ts +3 -2
- package/dist/types/generator/bitmark/BitmarkGenerator.d.ts.map +1 -1
- package/dist/types/generator/json/JsonGenerator.d.ts +12 -5
- package/dist/types/generator/json/JsonGenerator.d.ts.map +1 -1
- package/dist/types/model/ast/NodeType.d.ts +4 -2
- package/dist/types/model/ast/NodeType.d.ts.map +1 -1
- package/dist/types/model/ast/Nodes.d.ts +31 -12
- package/dist/types/model/ast/Nodes.d.ts.map +1 -1
- package/dist/types/model/enum/BitType.d.ts +44 -0
- package/dist/types/model/enum/BitType.d.ts.map +1 -1
- package/dist/types/model/enum/ExampleType.d.ts +13 -0
- package/dist/types/model/enum/ExampleType.d.ts.map +1 -0
- package/dist/types/model/json/BitJson.d.ts +15 -15
- package/dist/types/model/json/BitJson.d.ts.map +1 -1
- package/dist/types/model/json/BodyBitJson.d.ts +12 -10
- package/dist/types/model/json/BodyBitJson.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/BitmarkPegParserTypes.d.ts +4 -1
- package/dist/types/parser/bitmark/peg/BitmarkPegParserTypes.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/CardContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.d.ts +5 -0
- package/dist/types/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.d.ts.map +1 -0
- package/dist/types/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.d.ts.map +1 -1
- package/dist/types/parser/json/JsonParser.d.ts.map +1 -1
- package/dist/types/utils/ObjectUtils.d.ts +5 -0
- package/dist/types/utils/ObjectUtils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/esm/ast/Builder.js
CHANGED
|
@@ -37,84 +37,55 @@ class Builder extends BaseBuilder {
|
|
|
37
37
|
*/
|
|
38
38
|
bit(data) {
|
|
39
39
|
var _a;
|
|
40
|
-
const { bitType, textFormat, resourceType, id, externalId, spaceId, padletId, aiGenerated, releaseVersion, ageRange, language, computerLanguage, subtype, coverImage, publisher, publications, author, subject, date, location, theme, kind, action, thumbImage, focusX, focusY, duration, referenceProperty, deeplink, externalLink, externalLinkText, videoCallLink, bot, list, textReference, isTracked, isInfoOnly, labelTrue, labelFalse, book, quotedPerson, partialAnswer, levelProperty, title, subtitle, level, toc, progress, anchor, reference, referenceEnd, item, lead, hint, instruction, example, partner, extraProperties, resource, body, sampleSolution,
|
|
40
|
+
const { bitType, textFormat, resourceType, id, externalId, spaceId, padletId, aiGenerated, releaseVersion, ageRange, language, computerLanguage, subtype, coverImage, publisher, publications, author, subject, date, location, theme, kind, action, thumbImage, focusX, focusY, duration, referenceProperty, deeplink, externalLink, externalLinkText, videoCallLink, bot, list, textReference, isTracked, isInfoOnly, labelTrue, labelFalse, book, quotedPerson, partialAnswer, levelProperty, title, subtitle, level, toc, progress, anchor, reference, referenceEnd, item, lead, hint, instruction, isDefaultExample, example, partner, extraProperties, resource, body, sampleSolution, footer, markup, parser, } = data;
|
|
41
|
+
// Set the card node data
|
|
42
|
+
const cardNode = this.cardNode(data);
|
|
41
43
|
// NOTE: Node order is important and is defined here
|
|
42
|
-
const node = {
|
|
43
|
-
|
|
44
|
-
textFormat: (_a = TextFormat.fromValue(textFormat)) !== null && _a !== void 0 ? _a : TextFormat.bitmarkMinusMinus,
|
|
45
|
-
resourceType: BitUtils.calculateValidResourceType(bitType, resourceType, resource),
|
|
46
|
-
id: this.toAstProperty(PropertyKey.id, id),
|
|
47
|
-
externalId: this.toAstProperty(PropertyKey.externalId, externalId),
|
|
48
|
-
spaceId: this.toAstProperty(PropertyKey.spaceId, spaceId),
|
|
49
|
-
padletId: this.toAstProperty(PropertyKey.padletId, padletId),
|
|
50
|
-
aiGenerated: this.toAstProperty(PropertyKey.aiGenerated, aiGenerated),
|
|
51
|
-
releaseVersion: this.toAstProperty(PropertyKey.releaseVersion, releaseVersion),
|
|
52
|
-
book,
|
|
53
|
-
ageRange: this.toAstProperty(PropertyKey.ageRange, ageRange),
|
|
54
|
-
language: this.toAstProperty(PropertyKey.language, language),
|
|
55
|
-
computerLanguage: this.toAstProperty(PropertyKey.computerLanguage, computerLanguage),
|
|
56
|
-
subtype: this.toAstProperty(PropertyKey.subtype, subtype),
|
|
57
|
-
coverImage: this.toAstProperty(PropertyKey.coverImage, coverImage),
|
|
58
|
-
publisher: this.toAstProperty(PropertyKey.publisher, publisher),
|
|
59
|
-
publications: this.toAstProperty(PropertyKey.publications, publications),
|
|
60
|
-
author: this.toAstProperty(PropertyKey.author, author),
|
|
61
|
-
subject: this.toAstProperty(PropertyKey.subject, subject),
|
|
62
|
-
date: this.toAstProperty(PropertyKey.date, date),
|
|
63
|
-
location: this.toAstProperty(PropertyKey.location, location),
|
|
64
|
-
theme: this.toAstProperty(PropertyKey.theme, theme),
|
|
65
|
-
kind: this.toAstProperty(PropertyKey.kind, kind),
|
|
66
|
-
action: this.toAstProperty(PropertyKey.action, action),
|
|
67
|
-
thumbImage: this.toAstProperty(PropertyKey.thumbImage, thumbImage),
|
|
68
|
-
focusX: this.toAstProperty(PropertyKey.focusX, focusX),
|
|
69
|
-
focusY: this.toAstProperty(PropertyKey.focusY, focusY),
|
|
70
|
-
deeplink: this.toAstProperty(PropertyKey.deeplink, deeplink),
|
|
71
|
-
externalLink: this.toAstProperty(PropertyKey.externalLink, externalLink),
|
|
72
|
-
externalLinkText: this.toAstProperty(PropertyKey.externalLinkText, externalLinkText),
|
|
73
|
-
videoCallLink: this.toAstProperty(PropertyKey.videoCallLink, videoCallLink),
|
|
74
|
-
bot: this.toAstProperty(PropertyKey.bot, bot),
|
|
75
|
-
duration: this.toAstProperty(PropertyKey.duration, duration),
|
|
76
|
-
referenceProperty: this.toAstProperty(PropertyKey.reference, referenceProperty),
|
|
77
|
-
list: this.toAstProperty(PropertyKey.list, list),
|
|
78
|
-
textReference: this.toAstProperty(PropertyKey.textReference, textReference),
|
|
79
|
-
isTracked: this.toAstProperty(PropertyKey.isTracked, isTracked),
|
|
80
|
-
isInfoOnly: this.toAstProperty(PropertyKey.isInfoOnly, isInfoOnly),
|
|
81
|
-
labelTrue: this.toAstProperty(PropertyKey.labelTrue, labelTrue),
|
|
82
|
-
labelFalse: this.toAstProperty(PropertyKey.labelFalse, labelFalse),
|
|
83
|
-
quotedPerson: this.toAstProperty(PropertyKey.quotedPerson, quotedPerson),
|
|
84
|
-
partialAnswer: this.toAstProperty(PropertyKey.partialAnswer, partialAnswer),
|
|
85
|
-
levelProperty: this.toAstProperty(PropertyKey.level, levelProperty),
|
|
86
|
-
title,
|
|
87
|
-
subtitle,
|
|
88
|
-
level: NumberUtils.asNumber(level),
|
|
89
|
-
toc: this.toAstProperty(PropertyKey.toc, toc),
|
|
90
|
-
progress: this.toAstProperty(PropertyKey.progress, progress),
|
|
91
|
-
anchor,
|
|
44
|
+
const node = Object.assign(Object.assign({ bitType, textFormat: (_a = TextFormat.fromValue(textFormat)) !== null && _a !== void 0 ? _a : TextFormat.bitmarkMinusMinus, resourceType: BitUtils.calculateValidResourceType(bitType, resourceType, resource), id: this.toAstProperty(PropertyKey.id, id), externalId: this.toAstProperty(PropertyKey.externalId, externalId), spaceId: this.toAstProperty(PropertyKey.spaceId, spaceId), padletId: this.toAstProperty(PropertyKey.padletId, padletId), aiGenerated: this.toAstProperty(PropertyKey.aiGenerated, aiGenerated), releaseVersion: this.toAstProperty(PropertyKey.releaseVersion, releaseVersion), book, ageRange: this.toAstProperty(PropertyKey.ageRange, ageRange), language: this.toAstProperty(PropertyKey.language, language), computerLanguage: this.toAstProperty(PropertyKey.computerLanguage, computerLanguage), subtype: this.toAstProperty(PropertyKey.subtype, subtype), coverImage: this.toAstProperty(PropertyKey.coverImage, coverImage), publisher: this.toAstProperty(PropertyKey.publisher, publisher), publications: this.toAstProperty(PropertyKey.publications, publications), author: this.toAstProperty(PropertyKey.author, author), subject: this.toAstProperty(PropertyKey.subject, subject), date: this.toAstProperty(PropertyKey.date, date), location: this.toAstProperty(PropertyKey.location, location), theme: this.toAstProperty(PropertyKey.theme, theme), kind: this.toAstProperty(PropertyKey.kind, kind), action: this.toAstProperty(PropertyKey.action, action), thumbImage: this.toAstProperty(PropertyKey.thumbImage, thumbImage), focusX: this.toAstProperty(PropertyKey.focusX, focusX), focusY: this.toAstProperty(PropertyKey.focusY, focusY), deeplink: this.toAstProperty(PropertyKey.deeplink, deeplink), externalLink: this.toAstProperty(PropertyKey.externalLink, externalLink), externalLinkText: this.toAstProperty(PropertyKey.externalLinkText, externalLinkText), videoCallLink: this.toAstProperty(PropertyKey.videoCallLink, videoCallLink), bot: this.toAstProperty(PropertyKey.bot, bot), duration: this.toAstProperty(PropertyKey.duration, duration), referenceProperty: this.toAstProperty(PropertyKey.reference, referenceProperty), list: this.toAstProperty(PropertyKey.list, list), textReference: this.toAstProperty(PropertyKey.textReference, textReference), isTracked: this.toAstProperty(PropertyKey.isTracked, isTracked), isInfoOnly: this.toAstProperty(PropertyKey.isInfoOnly, isInfoOnly), labelTrue: this.toAstProperty(PropertyKey.labelTrue, labelTrue), labelFalse: this.toAstProperty(PropertyKey.labelFalse, labelFalse), quotedPerson: this.toAstProperty(PropertyKey.quotedPerson, quotedPerson), partialAnswer: this.toAstProperty(PropertyKey.partialAnswer, partialAnswer), levelProperty: this.toAstProperty(PropertyKey.level, levelProperty), title,
|
|
45
|
+
subtitle, level: NumberUtils.asNumber(level), toc: this.toAstProperty(PropertyKey.toc, toc), progress: this.toAstProperty(PropertyKey.progress, progress), anchor,
|
|
92
46
|
reference,
|
|
93
|
-
referenceEnd,
|
|
94
|
-
|
|
95
|
-
hint,
|
|
96
|
-
instruction,
|
|
97
|
-
example: this.toExample(example),
|
|
98
|
-
partner,
|
|
47
|
+
referenceEnd, itemLead: this.itemLead(item, lead), hint,
|
|
48
|
+
instruction }, this.toExample(isDefaultExample, example)), { partner,
|
|
99
49
|
resource,
|
|
100
|
-
body,
|
|
101
|
-
sampleSolution: ArrayUtils.asArray(sampleSolution),
|
|
102
|
-
statement,
|
|
103
|
-
responses,
|
|
104
|
-
choices,
|
|
105
|
-
cardNode: this.cardNode(data),
|
|
50
|
+
body, sampleSolution: ArrayUtils.asArray(sampleSolution), cardNode,
|
|
106
51
|
footer,
|
|
107
52
|
markup,
|
|
108
|
-
parser,
|
|
53
|
+
parser,
|
|
109
54
|
// Must always be last in the AST so key clashes are avoided correctly with other properties
|
|
110
|
-
extraProperties: this.parseExtraProperties(extraProperties)
|
|
111
|
-
|
|
55
|
+
extraProperties: this.parseExtraProperties(extraProperties) });
|
|
56
|
+
// If isDefaultExample is set at the bit level, push the default example down the tree to the relevant nodes
|
|
57
|
+
if (isDefaultExample) {
|
|
58
|
+
if (cardNode) {
|
|
59
|
+
this.setDefaultExamplesFlags(true, cardNode.choices);
|
|
60
|
+
this.setDefaultExamplesFlags(false, cardNode.responses, cardNode.statements, cardNode.statement, cardNode.pairs);
|
|
61
|
+
if (cardNode.quizzes) {
|
|
62
|
+
for (const quiz of cardNode.quizzes) {
|
|
63
|
+
this.setDefaultExamplesFlags(true, quiz.choices);
|
|
64
|
+
this.setDefaultExamplesFlags(false, quiz.responses);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (cardNode.matrix) {
|
|
68
|
+
for (const m of cardNode.matrix) {
|
|
69
|
+
this.setDefaultExamplesFlags(false, m.cells);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (body) {
|
|
74
|
+
this.setDefaultExamplesBodyBits(body);
|
|
75
|
+
}
|
|
76
|
+
// this.setDefaultExampleBit(bitType, node);
|
|
77
|
+
}
|
|
112
78
|
// Set default values
|
|
113
79
|
this.setDefaultBitValues(node);
|
|
80
|
+
// Set the 'isExample' flags
|
|
81
|
+
this.setIsExampleFlags(node);
|
|
114
82
|
// Add the version to the parser info
|
|
115
83
|
this.addVersionToParserInfo(node);
|
|
116
84
|
// Remove Unset Optionals
|
|
117
|
-
ObjectUtils.removeUnwantedProperties(node
|
|
85
|
+
ObjectUtils.removeUnwantedProperties(node, {
|
|
86
|
+
ignoreAllFalse: true,
|
|
87
|
+
ignoreEmptyString: ['example'],
|
|
88
|
+
});
|
|
118
89
|
// Validate and correct invalid bits as much as possible
|
|
119
90
|
return NodeValidator.validateBit(node);
|
|
120
91
|
}
|
|
@@ -125,19 +96,14 @@ class Builder extends BaseBuilder {
|
|
|
125
96
|
* @returns
|
|
126
97
|
*/
|
|
127
98
|
choice(data) {
|
|
128
|
-
const { text, isCorrect, item, lead, hint, instruction,
|
|
99
|
+
const { text, isCorrect, item, lead, hint, instruction, isCaseSensitive, isDefaultExample, example } = data;
|
|
129
100
|
// NOTE: Node order is important and is defined here
|
|
130
|
-
const node = {
|
|
131
|
-
|
|
132
|
-
isCorrect,
|
|
133
|
-
itemLead: this.itemLead(item, lead),
|
|
134
|
-
hint,
|
|
135
|
-
instruction,
|
|
136
|
-
example: this.toExample(example),
|
|
137
|
-
isCaseSensitive,
|
|
138
|
-
};
|
|
101
|
+
const node = Object.assign(Object.assign({ text, isCorrect: !!isCorrect, itemLead: this.itemLead(item, lead), hint,
|
|
102
|
+
instruction }, this.toExampleBoolean(isDefaultExample, example)), { isCaseSensitive });
|
|
139
103
|
// Remove Unset Optionals
|
|
140
|
-
ObjectUtils.removeUnwantedProperties(node
|
|
104
|
+
ObjectUtils.removeUnwantedProperties(node, {
|
|
105
|
+
ignoreAllFalse: true,
|
|
106
|
+
});
|
|
141
107
|
return node;
|
|
142
108
|
}
|
|
143
109
|
/**
|
|
@@ -147,19 +113,14 @@ class Builder extends BaseBuilder {
|
|
|
147
113
|
* @returns
|
|
148
114
|
*/
|
|
149
115
|
response(data) {
|
|
150
|
-
const { text, isCorrect, item, lead, hint, instruction,
|
|
116
|
+
const { text, isCorrect, item, lead, hint, instruction, isCaseSensitive, isDefaultExample, example } = data;
|
|
151
117
|
// NOTE: Node order is important and is defined here
|
|
152
|
-
const node = {
|
|
153
|
-
|
|
154
|
-
isCorrect,
|
|
155
|
-
itemLead: this.itemLead(item, lead),
|
|
156
|
-
hint,
|
|
157
|
-
instruction,
|
|
158
|
-
example: this.toExample(example),
|
|
159
|
-
isCaseSensitive,
|
|
160
|
-
};
|
|
118
|
+
const node = Object.assign(Object.assign({ text, isCorrect: !!isCorrect, itemLead: this.itemLead(item, lead), hint,
|
|
119
|
+
instruction }, this.toExampleBoolean(isDefaultExample, example)), { isCaseSensitive });
|
|
161
120
|
// Remove Unset Optionals
|
|
162
|
-
ObjectUtils.removeUnwantedProperties(node
|
|
121
|
+
ObjectUtils.removeUnwantedProperties(node, {
|
|
122
|
+
ignoreAllFalse: true,
|
|
123
|
+
});
|
|
163
124
|
return node;
|
|
164
125
|
}
|
|
165
126
|
/**
|
|
@@ -191,13 +152,16 @@ class Builder extends BaseBuilder {
|
|
|
191
152
|
* @returns
|
|
192
153
|
*/
|
|
193
154
|
quiz(data) {
|
|
194
|
-
const { choices, responses, item, lead, hint, instruction,
|
|
155
|
+
const { choices, responses, item, lead, hint, instruction, isDefaultExample } = data;
|
|
156
|
+
if (isDefaultExample) {
|
|
157
|
+
this.setDefaultExamplesFlags(true, choices);
|
|
158
|
+
this.setDefaultExamplesFlags(false, responses);
|
|
159
|
+
}
|
|
195
160
|
// NOTE: Node order is important and is defined here
|
|
196
161
|
const node = {
|
|
197
162
|
itemLead: this.itemLead(item, lead),
|
|
198
163
|
hint,
|
|
199
164
|
instruction,
|
|
200
|
-
example: this.toExample(example),
|
|
201
165
|
choices,
|
|
202
166
|
responses,
|
|
203
167
|
};
|
|
@@ -232,22 +196,18 @@ class Builder extends BaseBuilder {
|
|
|
232
196
|
* @returns
|
|
233
197
|
*/
|
|
234
198
|
pair(data) {
|
|
235
|
-
const { key, keyAudio, keyImage, values, item, lead, hint, instruction,
|
|
199
|
+
const { key, keyAudio, keyImage, values, item, lead, hint, instruction, isCaseSensitive, isShortAnswer, isDefaultExample, example, } = data;
|
|
236
200
|
// NOTE: Node order is important and is defined here
|
|
237
|
-
const node = {
|
|
238
|
-
key,
|
|
201
|
+
const node = Object.assign(Object.assign({ key,
|
|
239
202
|
keyAudio,
|
|
240
|
-
keyImage,
|
|
241
|
-
|
|
242
|
-
hint,
|
|
243
|
-
instruction,
|
|
244
|
-
example: this.toExample(example),
|
|
245
|
-
isCaseSensitive,
|
|
203
|
+
keyImage, itemLead: this.itemLead(item, lead), hint,
|
|
204
|
+
instruction }, this.toExample(isDefaultExample, example)), { isCaseSensitive,
|
|
246
205
|
isShortAnswer,
|
|
247
|
-
values
|
|
248
|
-
};
|
|
206
|
+
values });
|
|
249
207
|
// Remove Unset Optionals
|
|
250
|
-
ObjectUtils.removeUnwantedProperties(node
|
|
208
|
+
ObjectUtils.removeUnwantedProperties(node, {
|
|
209
|
+
ignoreAllFalse: true,
|
|
210
|
+
});
|
|
251
211
|
return node;
|
|
252
212
|
}
|
|
253
213
|
/**
|
|
@@ -257,20 +217,31 @@ class Builder extends BaseBuilder {
|
|
|
257
217
|
* @returns
|
|
258
218
|
*/
|
|
259
219
|
matrix(data) {
|
|
260
|
-
const { key, cells, item, lead, hint, instruction,
|
|
220
|
+
const { key, cells, item, lead, hint, instruction, isCaseSensitive, isShortAnswer, isDefaultExample } = data;
|
|
221
|
+
let isExample = false;
|
|
222
|
+
// Set isExample for matrix based on isExample for cells
|
|
223
|
+
for (const c of cells !== null && cells !== void 0 ? cells : []) {
|
|
224
|
+
if (isDefaultExample && !c.isExample) {
|
|
225
|
+
c.isDefaultExample = true;
|
|
226
|
+
c.isExample = true;
|
|
227
|
+
}
|
|
228
|
+
isExample = c.isExample ? true : isExample;
|
|
229
|
+
}
|
|
261
230
|
// NOTE: Node order is important and is defined here
|
|
262
231
|
const node = {
|
|
263
232
|
key,
|
|
264
233
|
itemLead: this.itemLead(item, lead),
|
|
265
234
|
hint,
|
|
266
235
|
instruction,
|
|
267
|
-
example: this.toExample(example),
|
|
268
236
|
isCaseSensitive,
|
|
269
237
|
isShortAnswer,
|
|
238
|
+
isExample,
|
|
270
239
|
cells,
|
|
271
240
|
};
|
|
272
241
|
// Remove Unset Optionals
|
|
273
|
-
ObjectUtils.removeUnwantedProperties(node
|
|
242
|
+
ObjectUtils.removeUnwantedProperties(node, {
|
|
243
|
+
ignoreAllFalse: true,
|
|
244
|
+
});
|
|
274
245
|
return node;
|
|
275
246
|
}
|
|
276
247
|
/**
|
|
@@ -280,17 +251,14 @@ class Builder extends BaseBuilder {
|
|
|
280
251
|
* @returns
|
|
281
252
|
*/
|
|
282
253
|
matrixCell(data) {
|
|
283
|
-
const { values, item, lead, hint, instruction, example } = data;
|
|
254
|
+
const { values, item, lead, hint, instruction, isDefaultExample, example } = data;
|
|
284
255
|
// NOTE: Node order is important and is defined here
|
|
285
|
-
const node = {
|
|
286
|
-
|
|
287
|
-
itemLead: this.itemLead(item, lead),
|
|
288
|
-
hint,
|
|
289
|
-
instruction,
|
|
290
|
-
example: this.toExample(example),
|
|
291
|
-
};
|
|
256
|
+
const node = Object.assign({ values, itemLead: this.itemLead(item, lead), hint,
|
|
257
|
+
instruction }, this.toExample(isDefaultExample, example));
|
|
292
258
|
// Remove Unset Optionals
|
|
293
|
-
ObjectUtils.removeUnwantedProperties(node
|
|
259
|
+
ObjectUtils.removeUnwantedProperties(node, {
|
|
260
|
+
ignoreAllFalse: true,
|
|
261
|
+
});
|
|
294
262
|
return node;
|
|
295
263
|
}
|
|
296
264
|
/**
|
|
@@ -300,21 +268,19 @@ class Builder extends BaseBuilder {
|
|
|
300
268
|
* @returns
|
|
301
269
|
*/
|
|
302
270
|
question(data) {
|
|
303
|
-
const { question, partialAnswer, item, lead, hint, instruction,
|
|
271
|
+
const { question, partialAnswer, item, lead, hint, instruction, isCaseSensitive, isShortAnswer, sampleSolution, isDefaultExample, example, } = data;
|
|
304
272
|
// NOTE: Node order is important and is defined here
|
|
305
|
-
const node = {
|
|
306
|
-
itemLead: this.itemLead(item, lead),
|
|
307
|
-
question,
|
|
273
|
+
const node = Object.assign(Object.assign({ itemLead: this.itemLead(item, lead), question,
|
|
308
274
|
partialAnswer,
|
|
309
275
|
hint,
|
|
310
|
-
instruction,
|
|
311
|
-
example: this.toExample(example),
|
|
312
|
-
isCaseSensitive,
|
|
276
|
+
instruction }, this.toExample(isDefaultExample, example)), { isCaseSensitive,
|
|
313
277
|
isShortAnswer,
|
|
314
|
-
sampleSolution
|
|
315
|
-
};
|
|
278
|
+
sampleSolution });
|
|
316
279
|
// Remove Unset Optionals
|
|
317
|
-
ObjectUtils.removeUnwantedProperties(node, {
|
|
280
|
+
ObjectUtils.removeUnwantedProperties(node, {
|
|
281
|
+
ignoreEmptyString: ['question'],
|
|
282
|
+
ignoreAllFalse: true,
|
|
283
|
+
});
|
|
318
284
|
return node;
|
|
319
285
|
}
|
|
320
286
|
/**
|
|
@@ -368,21 +334,18 @@ class Builder extends BaseBuilder {
|
|
|
368
334
|
* @returns
|
|
369
335
|
*/
|
|
370
336
|
gap(data) {
|
|
371
|
-
const { solutions, item, lead, hint, instruction,
|
|
337
|
+
const { solutions, item, lead, hint, instruction, isCaseSensitive, isDefaultExample, example } = data;
|
|
338
|
+
// const defaultExample = Array.isArray(solutions) && solutions.length === 1 ? solutions[0] : null;
|
|
372
339
|
// NOTE: Node order is important and is defined here
|
|
373
340
|
const node = {
|
|
374
341
|
type: BodyBitType.gap,
|
|
375
|
-
data: {
|
|
376
|
-
|
|
377
|
-
itemLead: this.itemLead(item, lead),
|
|
378
|
-
hint,
|
|
379
|
-
instruction,
|
|
380
|
-
example: this.toExample(example),
|
|
381
|
-
isCaseSensitive,
|
|
382
|
-
},
|
|
342
|
+
data: Object.assign(Object.assign({ solutions, itemLead: this.itemLead(item, lead), hint,
|
|
343
|
+
instruction }, this.toExample(isDefaultExample, example)), { isCaseSensitive }),
|
|
383
344
|
};
|
|
384
345
|
// Remove Unset Optionals
|
|
385
|
-
ObjectUtils.removeUnwantedProperties(node
|
|
346
|
+
ObjectUtils.removeUnwantedProperties(node, {
|
|
347
|
+
ignoreAllFalse: true,
|
|
348
|
+
});
|
|
386
349
|
return node;
|
|
387
350
|
}
|
|
388
351
|
/**
|
|
@@ -392,7 +355,7 @@ class Builder extends BaseBuilder {
|
|
|
392
355
|
* @returns
|
|
393
356
|
*/
|
|
394
357
|
select(data) {
|
|
395
|
-
const { options, prefix, postfix, item, lead, hint, instruction,
|
|
358
|
+
const { options, prefix, postfix, item, lead, hint, instruction, isCaseSensitive } = data;
|
|
396
359
|
// NOTE: Node order is important and is defined here
|
|
397
360
|
const node = {
|
|
398
361
|
type: BodyBitType.select,
|
|
@@ -403,12 +366,13 @@ class Builder extends BaseBuilder {
|
|
|
403
366
|
itemLead: this.itemLead(item, lead),
|
|
404
367
|
hint,
|
|
405
368
|
instruction,
|
|
406
|
-
example: this.toExample(example),
|
|
407
369
|
isCaseSensitive,
|
|
408
370
|
},
|
|
409
371
|
};
|
|
410
372
|
// Remove Unset Optionals
|
|
411
|
-
ObjectUtils.removeUnwantedProperties(node
|
|
373
|
+
ObjectUtils.removeUnwantedProperties(node, {
|
|
374
|
+
ignoreAllFalse: true,
|
|
375
|
+
});
|
|
412
376
|
return node;
|
|
413
377
|
}
|
|
414
378
|
/**
|
|
@@ -418,19 +382,14 @@ class Builder extends BaseBuilder {
|
|
|
418
382
|
* @returns
|
|
419
383
|
*/
|
|
420
384
|
selectOption(data) {
|
|
421
|
-
const { text, isCorrect, item, lead, hint, instruction,
|
|
385
|
+
const { text, isCorrect, item, lead, hint, instruction, isCaseSensitive, isDefaultExample, example } = data;
|
|
422
386
|
// NOTE: Node order is important and is defined here
|
|
423
|
-
const node = {
|
|
424
|
-
|
|
425
|
-
isCorrect,
|
|
426
|
-
itemLead: this.itemLead(item, lead),
|
|
427
|
-
hint,
|
|
428
|
-
instruction,
|
|
429
|
-
example: this.toExample(example),
|
|
430
|
-
isCaseSensitive,
|
|
431
|
-
};
|
|
387
|
+
const node = Object.assign(Object.assign({ text, isCorrect: !!isCorrect, itemLead: this.itemLead(item, lead), hint,
|
|
388
|
+
instruction }, this.toExample(isDefaultExample, example)), { isCaseSensitive });
|
|
432
389
|
// Remove Unset Optionals
|
|
433
|
-
ObjectUtils.removeUnwantedProperties(node
|
|
390
|
+
ObjectUtils.removeUnwantedProperties(node, {
|
|
391
|
+
ignoreAllFalse: true,
|
|
392
|
+
});
|
|
434
393
|
return node;
|
|
435
394
|
}
|
|
436
395
|
/**
|
|
@@ -440,7 +399,7 @@ class Builder extends BaseBuilder {
|
|
|
440
399
|
* @returns
|
|
441
400
|
*/
|
|
442
401
|
highlight(data) {
|
|
443
|
-
const { texts, prefix, postfix, item, lead, hint, instruction,
|
|
402
|
+
const { texts, prefix, postfix, item, lead, hint, instruction, isCaseSensitive } = data;
|
|
444
403
|
// NOTE: Node order is important and is defined here
|
|
445
404
|
const node = {
|
|
446
405
|
type: BodyBitType.highlight,
|
|
@@ -451,12 +410,13 @@ class Builder extends BaseBuilder {
|
|
|
451
410
|
itemLead: this.itemLead(item, lead),
|
|
452
411
|
hint,
|
|
453
412
|
instruction,
|
|
454
|
-
example: this.toExample(example),
|
|
455
413
|
isCaseSensitive,
|
|
456
414
|
},
|
|
457
415
|
};
|
|
458
416
|
// Remove Unset Optionals
|
|
459
|
-
ObjectUtils.removeUnwantedProperties(node
|
|
417
|
+
ObjectUtils.removeUnwantedProperties(node, {
|
|
418
|
+
ignoreAllFalse: true,
|
|
419
|
+
});
|
|
460
420
|
return node;
|
|
461
421
|
}
|
|
462
422
|
/**
|
|
@@ -466,20 +426,14 @@ class Builder extends BaseBuilder {
|
|
|
466
426
|
* @returns
|
|
467
427
|
*/
|
|
468
428
|
highlightText(data) {
|
|
469
|
-
const { text, isCorrect, isHighlighted, item, lead, hint, instruction, example,
|
|
429
|
+
const { text, isCorrect, isHighlighted, item, lead, hint, instruction, isCaseSensitive, isDefaultExample, example, } = data;
|
|
470
430
|
// NOTE: Node order is important and is defined here
|
|
471
|
-
const node = {
|
|
472
|
-
|
|
473
|
-
isCorrect,
|
|
474
|
-
isHighlighted,
|
|
475
|
-
itemLead: this.itemLead(item, lead),
|
|
476
|
-
hint,
|
|
477
|
-
instruction,
|
|
478
|
-
example: this.toExample(example),
|
|
479
|
-
isCaseSensitive,
|
|
480
|
-
};
|
|
431
|
+
const node = Object.assign(Object.assign({ text, isCorrect: !!isCorrect, isHighlighted: !!isHighlighted, itemLead: this.itemLead(item, lead), hint,
|
|
432
|
+
instruction }, this.toExample(isDefaultExample, example)), { isCaseSensitive });
|
|
481
433
|
// Remove Unset Optionals
|
|
482
|
-
ObjectUtils.removeUnwantedProperties(node
|
|
434
|
+
ObjectUtils.removeUnwantedProperties(node, {
|
|
435
|
+
ignoreAllFalse: true,
|
|
436
|
+
});
|
|
483
437
|
return node;
|
|
484
438
|
}
|
|
485
439
|
/**
|
|
@@ -489,19 +443,14 @@ class Builder extends BaseBuilder {
|
|
|
489
443
|
* @returns
|
|
490
444
|
*/
|
|
491
445
|
statement(data) {
|
|
492
|
-
const { text, isCorrect, item, lead, hint, instruction,
|
|
446
|
+
const { text, isCorrect, item, lead, hint, instruction, isCaseSensitive, isDefaultExample, example } = data;
|
|
493
447
|
// NOTE: Node order is important and is defined here
|
|
494
|
-
const node = {
|
|
495
|
-
|
|
496
|
-
isCorrect,
|
|
497
|
-
itemLead: this.itemLead(item, lead),
|
|
498
|
-
hint,
|
|
499
|
-
instruction,
|
|
500
|
-
example: this.toExample(example),
|
|
501
|
-
isCaseSensitive,
|
|
502
|
-
};
|
|
448
|
+
const node = Object.assign(Object.assign({ text, isCorrect: !!isCorrect, itemLead: this.itemLead(item, lead), hint,
|
|
449
|
+
instruction }, this.toExampleBoolean(isDefaultExample, example)), { isCaseSensitive });
|
|
503
450
|
// Remove Unset Optionals
|
|
504
|
-
ObjectUtils.removeUnwantedProperties(node
|
|
451
|
+
ObjectUtils.removeUnwantedProperties(node, {
|
|
452
|
+
ignoreAllFalse: true,
|
|
453
|
+
});
|
|
505
454
|
return node;
|
|
506
455
|
}
|
|
507
456
|
/**
|
|
@@ -554,14 +503,27 @@ class Builder extends BaseBuilder {
|
|
|
554
503
|
}
|
|
555
504
|
cardNode(data) {
|
|
556
505
|
let node;
|
|
557
|
-
const {
|
|
558
|
-
if (
|
|
506
|
+
const { questions, elements, statement, statements, choices, responses, quizzes, heading, pairs, matrix, botResponses, } = data;
|
|
507
|
+
if (questions ||
|
|
508
|
+
elements ||
|
|
509
|
+
statement ||
|
|
510
|
+
statements ||
|
|
511
|
+
choices ||
|
|
512
|
+
responses ||
|
|
513
|
+
quizzes ||
|
|
514
|
+
heading ||
|
|
515
|
+
pairs ||
|
|
516
|
+
matrix ||
|
|
517
|
+
botResponses) {
|
|
559
518
|
node = {
|
|
560
|
-
heading,
|
|
561
|
-
elements,
|
|
562
519
|
questions,
|
|
520
|
+
elements,
|
|
521
|
+
statement,
|
|
563
522
|
statements,
|
|
523
|
+
choices,
|
|
524
|
+
responses,
|
|
564
525
|
quizzes,
|
|
526
|
+
heading,
|
|
565
527
|
pairs,
|
|
566
528
|
matrix,
|
|
567
529
|
botResponses,
|
|
@@ -571,6 +533,90 @@ class Builder extends BaseBuilder {
|
|
|
571
533
|
}
|
|
572
534
|
return node;
|
|
573
535
|
}
|
|
536
|
+
/**
|
|
537
|
+
* Set every correct answer as an example for Decision node(s)
|
|
538
|
+
*
|
|
539
|
+
* @param answers - array of answers
|
|
540
|
+
* @returns true if any of the answers has an example, otherwise undefined
|
|
541
|
+
*/
|
|
542
|
+
setDefaultExamplesFlags(onlyCorrect, ...nodes) {
|
|
543
|
+
if (Array.isArray(nodes)) {
|
|
544
|
+
for (const ds of nodes) {
|
|
545
|
+
if (Array.isArray(ds)) {
|
|
546
|
+
for (const d of ds) {
|
|
547
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
548
|
+
if (!d.isExample && (!onlyCorrect || d.isCorrect)) {
|
|
549
|
+
d.isDefaultExample = true;
|
|
550
|
+
d.isExample = true;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
else if (ds) {
|
|
555
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
556
|
+
if (!ds.isExample && (!onlyCorrect || ds.isCorrect)) {
|
|
557
|
+
ds.isDefaultExample = true;
|
|
558
|
+
ds.isExample = true;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
setDefaultExamplesBodyBits(body) {
|
|
565
|
+
if (!body || !body.bodyParts || body.bodyParts.length === 0)
|
|
566
|
+
return;
|
|
567
|
+
for (const part of body.bodyParts) {
|
|
568
|
+
if (part) {
|
|
569
|
+
switch (part.type) {
|
|
570
|
+
case BodyBitType.gap: {
|
|
571
|
+
const gap = part;
|
|
572
|
+
if (!gap.data.isExample) {
|
|
573
|
+
gap.data.isDefaultExample = true;
|
|
574
|
+
gap.data.isExample = true;
|
|
575
|
+
}
|
|
576
|
+
break;
|
|
577
|
+
}
|
|
578
|
+
case BodyBitType.select: {
|
|
579
|
+
const select = part;
|
|
580
|
+
for (const option of select.data.options) {
|
|
581
|
+
if (!option.isExample && option.isCorrect) {
|
|
582
|
+
option.isDefaultExample = true;
|
|
583
|
+
option.isExample = true;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
break;
|
|
587
|
+
}
|
|
588
|
+
case BodyBitType.highlight: {
|
|
589
|
+
const highlight = part;
|
|
590
|
+
for (const text of highlight.data.texts) {
|
|
591
|
+
if (!text.isExample && text.isCorrect) {
|
|
592
|
+
text.isDefaultExample = true;
|
|
593
|
+
text.isExample = true;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
// private setDefaultExampleBit(bitType: BitTypeType, node: Bit): void {
|
|
603
|
+
// const { example: exampleIn } = node;
|
|
604
|
+
// const meta = BitType.getMetadata<BitTypeMetadata>(bitType);
|
|
605
|
+
// if (!meta) return;
|
|
606
|
+
// if (exampleIn === null) {
|
|
607
|
+
// // Set the default for the specific bit
|
|
608
|
+
// switch (meta.exampleType) {
|
|
609
|
+
// case ExampleType.boolean:
|
|
610
|
+
// node.example = true;
|
|
611
|
+
// break;
|
|
612
|
+
// case ExampleType.string:
|
|
613
|
+
// node.example = '';
|
|
614
|
+
// break;
|
|
615
|
+
// default:
|
|
616
|
+
// // Ignore at this level
|
|
617
|
+
// }
|
|
618
|
+
// }
|
|
619
|
+
// }
|
|
574
620
|
parseExtraProperties(extraProperties) {
|
|
575
621
|
if (!extraProperties)
|
|
576
622
|
return undefined;
|
|
@@ -583,6 +629,126 @@ class Builder extends BaseBuilder {
|
|
|
583
629
|
}
|
|
584
630
|
return res;
|
|
585
631
|
}
|
|
632
|
+
/**
|
|
633
|
+
* Set the 'isExample' flags on the bit
|
|
634
|
+
*
|
|
635
|
+
* The flag is set if the bit has an example. The flag is set at each branch level up the tree from
|
|
636
|
+
* where the 'example' exists.
|
|
637
|
+
*
|
|
638
|
+
* @param bit
|
|
639
|
+
*/
|
|
640
|
+
setIsExampleFlags(bit) {
|
|
641
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
642
|
+
bit.isExample = false;
|
|
643
|
+
const checkIsExample = (example) => {
|
|
644
|
+
if (!example)
|
|
645
|
+
return false;
|
|
646
|
+
if (example.isDefaultExample || example.example != undefined) {
|
|
647
|
+
example.isExample = true;
|
|
648
|
+
bit.isExample = true;
|
|
649
|
+
}
|
|
650
|
+
else {
|
|
651
|
+
if (example === bit) {
|
|
652
|
+
example.isExample = !!bit.isExample;
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
example.isExample = false;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return example.isExample;
|
|
659
|
+
};
|
|
660
|
+
const { body, cardNode } = bit;
|
|
661
|
+
// Body bit level
|
|
662
|
+
if (body && body.bodyParts) {
|
|
663
|
+
for (const bodyPart of body.bodyParts) {
|
|
664
|
+
switch (bodyPart.type) {
|
|
665
|
+
case BodyBitType.gap: {
|
|
666
|
+
checkIsExample(bodyPart.data);
|
|
667
|
+
break;
|
|
668
|
+
}
|
|
669
|
+
case BodyBitType.select: {
|
|
670
|
+
const select = bodyPart;
|
|
671
|
+
let hasExample = false;
|
|
672
|
+
for (const option of select.data.options) {
|
|
673
|
+
hasExample = checkIsExample(option) ? true : hasExample;
|
|
674
|
+
}
|
|
675
|
+
select.data.isExample = hasExample;
|
|
676
|
+
break;
|
|
677
|
+
}
|
|
678
|
+
case BodyBitType.highlight: {
|
|
679
|
+
const highlight = bodyPart;
|
|
680
|
+
let hasExample = false;
|
|
681
|
+
for (const text of highlight.data.texts) {
|
|
682
|
+
hasExample = checkIsExample(text) ? true : hasExample;
|
|
683
|
+
}
|
|
684
|
+
highlight.data.isExample = hasExample;
|
|
685
|
+
break;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
// Card level
|
|
691
|
+
if (cardNode) {
|
|
692
|
+
// pairs
|
|
693
|
+
for (const v of (_a = cardNode.pairs) !== null && _a !== void 0 ? _a : []) {
|
|
694
|
+
checkIsExample(v);
|
|
695
|
+
}
|
|
696
|
+
// matrix
|
|
697
|
+
for (const mx of (_b = cardNode.matrix) !== null && _b !== void 0 ? _b : []) {
|
|
698
|
+
let hasExample = false;
|
|
699
|
+
// matrix cell
|
|
700
|
+
for (const v of (_c = mx.cells) !== null && _c !== void 0 ? _c : []) {
|
|
701
|
+
hasExample = checkIsExample(v) ? true : hasExample;
|
|
702
|
+
}
|
|
703
|
+
mx.isExample = hasExample;
|
|
704
|
+
}
|
|
705
|
+
// quizzes
|
|
706
|
+
for (const quiz of (_d = cardNode.quizzes) !== null && _d !== void 0 ? _d : []) {
|
|
707
|
+
let hasExample = false;
|
|
708
|
+
// responses
|
|
709
|
+
for (const v of (_e = quiz.responses) !== null && _e !== void 0 ? _e : []) {
|
|
710
|
+
hasExample = checkIsExample(v) ? true : hasExample;
|
|
711
|
+
}
|
|
712
|
+
// choices
|
|
713
|
+
for (const v of (_f = quiz.choices) !== null && _f !== void 0 ? _f : []) {
|
|
714
|
+
hasExample = checkIsExample(v) ? true : hasExample;
|
|
715
|
+
}
|
|
716
|
+
quiz.isExample = hasExample;
|
|
717
|
+
}
|
|
718
|
+
// responses
|
|
719
|
+
for (const v of (_g = cardNode.responses) !== null && _g !== void 0 ? _g : []) {
|
|
720
|
+
checkIsExample(v);
|
|
721
|
+
}
|
|
722
|
+
// choices
|
|
723
|
+
for (const v of (_h = cardNode.choices) !== null && _h !== void 0 ? _h : []) {
|
|
724
|
+
checkIsExample(v);
|
|
725
|
+
}
|
|
726
|
+
// statements
|
|
727
|
+
for (const v of (_j = cardNode.statements) !== null && _j !== void 0 ? _j : []) {
|
|
728
|
+
checkIsExample(v);
|
|
729
|
+
}
|
|
730
|
+
// statement
|
|
731
|
+
checkIsExample(cardNode.statement);
|
|
732
|
+
// NO: elements
|
|
733
|
+
// questions
|
|
734
|
+
for (const v of (_k = cardNode.questions) !== null && _k !== void 0 ? _k : []) {
|
|
735
|
+
checkIsExample(v);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
// Bit level
|
|
739
|
+
// statement
|
|
740
|
+
checkIsExample(bit.statement);
|
|
741
|
+
// responses
|
|
742
|
+
for (const v of (_l = bit.responses) !== null && _l !== void 0 ? _l : []) {
|
|
743
|
+
checkIsExample(v);
|
|
744
|
+
}
|
|
745
|
+
// choices
|
|
746
|
+
for (const v of (_m = bit.choices) !== null && _m !== void 0 ? _m : []) {
|
|
747
|
+
checkIsExample(v);
|
|
748
|
+
}
|
|
749
|
+
// Bit itself
|
|
750
|
+
checkIsExample(bit);
|
|
751
|
+
}
|
|
586
752
|
setDefaultBitValues(bit) {
|
|
587
753
|
// Set AIGenerated == true for all AI generated bits
|
|
588
754
|
switch (bit.bitType) {
|