@quesmed/types 1.0.13 → 1.0.14

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",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "main": "index.js",
6
6
  "types": "dist/index.d.ts",
@@ -61,6 +61,7 @@ function formatPrescribeAnswer(obj) {
61
61
  }
62
62
  return obj;
63
63
  }
64
+ const answerRegex = /answer/gi;
64
65
  function correctMark(mark) {
65
66
  const data = {
66
67
  correct: false,
@@ -70,7 +71,10 @@ function correctMark(mark) {
70
71
  if (!mark || !mark.mark) {
71
72
  return data;
72
73
  }
73
- const flatAnswer = mark.question.answer[0];
74
+ const qKeys = Object.keys(mark.question);
75
+ const answerKey = qKeys.find((k) => answerRegex.exec(k)) || 'answer';
76
+ const answer = mark.question[answerKey];
77
+ const flatAnswer = answer[0];
74
78
  const flatAttempt = mark.mark[0];
75
79
  if (models_1.EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
76
80
  const answer = flatAnswer;
@@ -93,7 +97,7 @@ function correctMark(mark) {
93
97
  }
94
98
  }
95
99
  else if (models_1.EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
96
- const [answerA, answerB] = mark.question.answer.map((x) => x.sort());
100
+ const [answerA, answerB] = answer.map((x) => x.sort());
97
101
  const [attemptA, attemptB] = mark.mark.map((x) => x.sort());
98
102
  if (answerA.length !== attemptA.length || answerB.length !== attemptB.length) {
99
103
  data.incorrect = true;
@@ -106,7 +110,7 @@ function correctMark(mark) {
106
110
  }
107
111
  }
108
112
  else if (models_1.EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
109
- const answers = mark.question.answer.map(formatPrescribeAnswer);
113
+ const answers = answer.map(formatPrescribeAnswer);
110
114
  const attempt = formatPrescribeAnswer(flatAttempt);
111
115
  let foundCorrect = false;
112
116
  let index = 0;