@quesmed/types-rn 2.4.17 → 2.4.19
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/package.json
CHANGED
package/utils/commonFunctions.js
CHANGED
|
@@ -35,27 +35,26 @@ function mapPrescribeMarkToAnswer(obj) {
|
|
|
35
35
|
}
|
|
36
36
|
exports.mapPrescribeMarkToAnswer = mapPrescribeMarkToAnswer;
|
|
37
37
|
function formatPrescribeAnswer(baseAnswer) {
|
|
38
|
-
const obj = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
};
|
|
38
|
+
const obj = Object.assign({}, baseAnswer, {
|
|
39
|
+
drug: Object.assign({}, baseAnswer.drug, {
|
|
40
|
+
value: baseAnswer.drug?.value ?? '',
|
|
41
|
+
}),
|
|
42
|
+
dose: Object.assign({}, baseAnswer.dose, {
|
|
43
|
+
value: baseAnswer.dose?.value ?? 0,
|
|
44
|
+
}),
|
|
45
|
+
units: Object.assign({}, baseAnswer.units, {
|
|
46
|
+
value: baseAnswer.units?.value ?? '',
|
|
47
|
+
}),
|
|
48
|
+
route: Object.assign({}, baseAnswer.route, {
|
|
49
|
+
value: baseAnswer.route?.value ?? '',
|
|
50
|
+
}),
|
|
51
|
+
frequency: Object.assign({}, baseAnswer.frequency, {
|
|
52
|
+
value: baseAnswer.frequency?.value ?? '',
|
|
53
|
+
}),
|
|
54
|
+
duration: Object.assign({}, baseAnswer.duration, {
|
|
55
|
+
value: baseAnswer.duration?.value ?? '',
|
|
56
|
+
}),
|
|
57
|
+
});
|
|
59
58
|
obj.drug.value = obj.drug.value.toLowerCase().replace(/\s/g, '');
|
|
60
59
|
obj.route.value = obj.route.value
|
|
61
60
|
.toLowerCase()
|
|
@@ -141,7 +140,6 @@ function formatPrescribeAnswer(baseAnswer) {
|
|
|
141
140
|
return obj;
|
|
142
141
|
}
|
|
143
142
|
exports.formatPrescribeAnswer = formatPrescribeAnswer;
|
|
144
|
-
const answerRegex = /answer/gi;
|
|
145
143
|
function correctMark(mark) {
|
|
146
144
|
const data = {
|
|
147
145
|
correct: false,
|
|
@@ -153,10 +151,11 @@ function correctMark(mark) {
|
|
|
153
151
|
}
|
|
154
152
|
try {
|
|
155
153
|
const qKeys = Object.keys(mark.question);
|
|
156
|
-
const answerKey = qKeys.find((k) =>
|
|
154
|
+
const answerKey = qKeys.find((k) => k.toLowerCase().indexOf('answer') !== -1) || 'answer';
|
|
157
155
|
const answer = mark.question[answerKey];
|
|
158
156
|
const flatAnswer = answer[0];
|
|
159
|
-
const
|
|
157
|
+
const jsonAnswer = typeof mark.mark === 'string' ? JSON.parse(mark.mark) : mark.mark;
|
|
158
|
+
const flatAttempt = jsonAnswer[0];
|
|
160
159
|
if (models_1.EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
|
|
161
160
|
const answer = flatAnswer;
|
|
162
161
|
const attempt = flatAttempt;
|
|
@@ -185,11 +184,11 @@ function correctMark(mark) {
|
|
|
185
184
|
else if (models_1.EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
|
|
186
185
|
const [answerA, answerB] = answer.map((x) => x.sort());
|
|
187
186
|
let [attemptA, attemptB] = [[], []];
|
|
188
|
-
if (Array.isArray(
|
|
189
|
-
|
|
190
|
-
Array.isArray(
|
|
191
|
-
Array.isArray(
|
|
192
|
-
[attemptA, attemptB] =
|
|
187
|
+
if (Array.isArray(jsonAnswer) &&
|
|
188
|
+
jsonAnswer.length === 2 &&
|
|
189
|
+
Array.isArray(jsonAnswer[0]) &&
|
|
190
|
+
Array.isArray(jsonAnswer[1])) {
|
|
191
|
+
[attemptA, attemptB] = jsonAnswer.map((x) => x.sort());
|
|
193
192
|
}
|
|
194
193
|
if (answerA.length !== attemptA.length ||
|
|
195
194
|
answerB.length !== attemptB.length) {
|