@quesmed/types-rn 2.6.211 → 2.6.212

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types-rn",
3
- "version": "2.6.211",
3
+ "version": "2.6.212",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.evaluateMark = void 0;
4
4
  const models_1 = require("../models");
5
- const object_1 = require("./object");
6
5
  function isPrescribeAnswer(data) {
7
6
  return Object(data).hasOwnProperty('dose');
8
7
  }
@@ -153,21 +152,43 @@ function evaluateMark({ mark, answer, questionTypeId, psaSectionId, choices, })
153
152
  break;
154
153
  }
155
154
  case models_1.EQuestionType.PRESCRIPTION_ANSWER: {
156
- let foundCorrect = false;
157
- if (typeof flatAttempt === 'object' &&
158
- Object.keys(flatAttempt).length > 0) {
159
- const answers = answer.map(mapPrescribeMarkToAnswer);
160
- const attempt = mapPrescribeMarkToAnswer(flatAttempt);
161
- foundCorrect = answers.some((ans) => (0, object_1.compareObjects)(ans, attempt));
162
- }
163
- if (foundCorrect) {
164
- data.score = 1;
165
- data.result = models_1.EMarkResult.Correct;
155
+ if (typeof flatAttempt !== 'object' ||
156
+ !flatAttempt ||
157
+ Object.keys(flatAttempt).length === 0) {
158
+ data.score = 0;
159
+ data.result = models_1.EMarkResult.Incorrect;
160
+ break;
166
161
  }
167
- else {
162
+ const answers = answer.map(mapPrescribeMarkToAnswer);
163
+ const attempt = mapPrescribeMarkToAnswer(flatAttempt);
164
+ // Find all answers with matching drug
165
+ const matchingDrugAnswers = answers.filter((ans) => ans.drugId === attempt.drugId);
166
+ if (matchingDrugAnswers.length === 0) {
168
167
  data.score = 0;
169
168
  data.result = models_1.EMarkResult.Incorrect;
169
+ break;
170
+ }
171
+ // Base score for correct drug
172
+ const DRUG_SCORE = 5;
173
+ const COMPONENT_SCORES = {
174
+ 3: 5,
175
+ 2: 3,
176
+ 1: 2,
177
+ 0: 0, // no components are correct
178
+ };
179
+ // Find the best matching answer (highest component score)
180
+ let bestCorrectCount = -1;
181
+ for (const matchingDrugAnswer of matchingDrugAnswers) {
182
+ const correctCount = Number(matchingDrugAnswer.doseId === attempt.doseId) +
183
+ Number(matchingDrugAnswer.routeId === attempt.routeId) +
184
+ Number(matchingDrugAnswer.frequencyId === attempt.frequencyId);
185
+ if (correctCount > bestCorrectCount) {
186
+ bestCorrectCount = correctCount;
187
+ }
170
188
  }
189
+ data.score = DRUG_SCORE + COMPONENT_SCORES[bestCorrectCount];
190
+ data.result =
191
+ bestCorrectCount === 3 ? models_1.EMarkResult.Correct : models_1.EMarkResult.Partial;
171
192
  break;
172
193
  }
173
194
  case models_1.EQuestionType.EXTENDED_MATCHING_ANSWER: {