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