@quesmed/types 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.
|
@@ -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) {
|
|
@@ -31,27 +31,26 @@ export function mapPrescribeMarkToAnswer(obj) {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
export function formatPrescribeAnswer(baseAnswer) {
|
|
34
|
-
const obj = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
};
|
|
34
|
+
const obj = Object.assign({}, baseAnswer, {
|
|
35
|
+
drug: Object.assign({}, baseAnswer.drug, {
|
|
36
|
+
value: baseAnswer.drug?.value ?? '',
|
|
37
|
+
}),
|
|
38
|
+
dose: Object.assign({}, baseAnswer.dose, {
|
|
39
|
+
value: baseAnswer.dose?.value ?? 0,
|
|
40
|
+
}),
|
|
41
|
+
units: Object.assign({}, baseAnswer.units, {
|
|
42
|
+
value: baseAnswer.units?.value ?? '',
|
|
43
|
+
}),
|
|
44
|
+
route: Object.assign({}, baseAnswer.route, {
|
|
45
|
+
value: baseAnswer.route?.value ?? '',
|
|
46
|
+
}),
|
|
47
|
+
frequency: Object.assign({}, baseAnswer.frequency, {
|
|
48
|
+
value: baseAnswer.frequency?.value ?? '',
|
|
49
|
+
}),
|
|
50
|
+
duration: Object.assign({}, baseAnswer.duration, {
|
|
51
|
+
value: baseAnswer.duration?.value ?? '',
|
|
52
|
+
}),
|
|
53
|
+
});
|
|
55
54
|
obj.drug.value = obj.drug.value.toLowerCase().replace(/\s/g, '');
|
|
56
55
|
obj.route.value = obj.route.value
|
|
57
56
|
.toLowerCase()
|
|
@@ -136,7 +135,6 @@ export function formatPrescribeAnswer(baseAnswer) {
|
|
|
136
135
|
}
|
|
137
136
|
return obj;
|
|
138
137
|
}
|
|
139
|
-
const answerRegex = /answer/gi;
|
|
140
138
|
export function correctMark(mark) {
|
|
141
139
|
const data = {
|
|
142
140
|
correct: false,
|
|
@@ -148,10 +146,11 @@ export function correctMark(mark) {
|
|
|
148
146
|
}
|
|
149
147
|
try {
|
|
150
148
|
const qKeys = Object.keys(mark.question);
|
|
151
|
-
const answerKey = qKeys.find((k) =>
|
|
149
|
+
const answerKey = qKeys.find((k) => k.toLowerCase().indexOf('answer') !== -1) || 'answer';
|
|
152
150
|
const answer = mark.question[answerKey];
|
|
153
151
|
const flatAnswer = answer[0];
|
|
154
|
-
const
|
|
152
|
+
const jsonAnswer = typeof mark.mark === 'string' ? JSON.parse(mark.mark) : mark.mark;
|
|
153
|
+
const flatAttempt = jsonAnswer[0];
|
|
155
154
|
if (EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
|
|
156
155
|
const answer = flatAnswer;
|
|
157
156
|
const attempt = flatAttempt;
|
|
@@ -180,11 +179,11 @@ export function correctMark(mark) {
|
|
|
180
179
|
else if (EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
|
|
181
180
|
const [answerA, answerB] = answer.map((x) => x.sort());
|
|
182
181
|
let [attemptA, attemptB] = [[], []];
|
|
183
|
-
if (Array.isArray(
|
|
184
|
-
|
|
185
|
-
Array.isArray(
|
|
186
|
-
Array.isArray(
|
|
187
|
-
[attemptA, attemptB] =
|
|
182
|
+
if (Array.isArray(jsonAnswer) &&
|
|
183
|
+
jsonAnswer.length === 2 &&
|
|
184
|
+
Array.isArray(jsonAnswer[0]) &&
|
|
185
|
+
Array.isArray(jsonAnswer[1])) {
|
|
186
|
+
[attemptA, attemptB] = jsonAnswer.map((x) => x.sort());
|
|
188
187
|
}
|
|
189
188
|
if (answerA.length !== attemptA.length ||
|
|
190
189
|
answerB.length !== attemptB.length) {
|