@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types-rn",
3
- "version": "2.4.17",
3
+ "version": "2.4.19",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",
@@ -42,6 +42,12 @@ exports.TOPICS = (0, client_1.gql) `
42
42
  topicId
43
43
  totalQuestions
44
44
  totalCards
45
+ correctQuestions
46
+ incorrectQuestions
47
+ greenCards
48
+ yellowCards
49
+ redCards
50
+ dailyFeedCards
45
51
  }
46
52
  }
47
53
  }
@@ -35,27 +35,26 @@ function mapPrescribeMarkToAnswer(obj) {
35
35
  }
36
36
  exports.mapPrescribeMarkToAnswer = mapPrescribeMarkToAnswer;
37
37
  function formatPrescribeAnswer(baseAnswer) {
38
- const obj = {
39
- ...baseAnswer,
40
- drug: {
41
- ...baseAnswer.drug,
42
- },
43
- dose: {
44
- ...baseAnswer.dose,
45
- },
46
- units: {
47
- ...baseAnswer.units,
48
- },
49
- route: {
50
- ...baseAnswer.route,
51
- },
52
- frequency: {
53
- ...baseAnswer.frequency,
54
- },
55
- duration: {
56
- ...baseAnswer.duration,
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) => answerRegex.exec(k)) || 'answer';
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 flatAttempt = mark.mark[0];
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(mark.mark) &&
189
- mark.mark.length === 2 &&
190
- Array.isArray(mark.mark[0]) &&
191
- Array.isArray(mark.mark[1])) {
192
- [attemptA, attemptB] = mark.mark.map((x) => x.sort());
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) {