@quesmed/types-rn 2.6.206 → 2.6.207

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.206",
3
+ "version": "2.6.207",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",
@@ -63,7 +63,7 @@ exports.UCAT_THEME_ANALYTICS = (0, client_1.gql) `
63
63
  query UcatThemeAnalytics(
64
64
  $entitlementId: Int
65
65
  $themeId: Int
66
- $updatedAt: Int
66
+ $updatedAt: Date
67
67
  ) {
68
68
  restricted {
69
69
  ucatThemeAnalytics(
@@ -3,6 +3,7 @@ export interface ICorrectMarkData {
3
3
  correct: boolean;
4
4
  incorrect: boolean;
5
5
  correctIndex: number;
6
+ partial: boolean;
6
7
  }
7
8
  export declare function isPrescribeAnswer(data: IPrescribeAnswer | IPrescribeMark): data is IPrescribeAnswer;
8
9
  export declare function mapPrescribeMarkToAnswer(obj: IPrescribeAnswer | IPrescribeMark): IPrescribeMark;
@@ -40,6 +40,7 @@ function correctMark(mark) {
40
40
  correct: false,
41
41
  incorrect: false,
42
42
  correctIndex: -1,
43
+ partial: false,
43
44
  };
44
45
  if (!mark || !mark.mark) {
45
46
  return data;
@@ -58,7 +59,6 @@ function correctMark(mark) {
58
59
  models_1.EQuestionType.VERBAL_READING_COMPREHENSION,
59
60
  models_1.EQuestionType.DECISION_MAKING_SBA,
60
61
  models_1.EQuestionType.QUANTITATIVE_REASONING_SBA,
61
- models_1.EQuestionType.SJT_SINGLE_CHOICE,
62
62
  ].includes(mark.question.typeId)) {
63
63
  const answer = flatAnswer;
64
64
  const attempt = flatAttempt;
@@ -84,10 +84,7 @@ function correctMark(mark) {
84
84
  data.incorrect = true;
85
85
  }
86
86
  }
87
- else if ([
88
- models_1.EQuestionType.MULTIPLE_ANSWERS,
89
- models_1.EQuestionType.DECISION_MAKING_YES_NO,
90
- ].includes(mark.question.typeId)) {
87
+ else if (models_1.EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
91
88
  const [answerA, answerB] = answer.map((x) => x.sort());
92
89
  let [attemptA, attemptB] = [[], []];
93
90
  if (Array.isArray(jsonAnswer) &&
@@ -108,6 +105,35 @@ function correctMark(mark) {
108
105
  data.incorrect = true;
109
106
  }
110
107
  }
108
+ else if (models_1.EQuestionType.DECISION_MAKING_YES_NO === mark.question.typeId) {
109
+ const [answerA, answerB] = answer.map((x) => [...x].sort());
110
+ let [attemptA, attemptB] = [[], []];
111
+ if (Array.isArray(jsonAnswer) &&
112
+ jsonAnswer.length === 2 &&
113
+ Array.isArray(jsonAnswer[0]) &&
114
+ Array.isArray(jsonAnswer[1])) {
115
+ [attemptA, attemptB] = jsonAnswer.map((x) => [...x].sort());
116
+ }
117
+ // Count correct matches
118
+ let correctCount = 0;
119
+ // Count matches in A
120
+ correctCount += attemptA.filter((x) => answerA.includes(x)).length;
121
+ // Count matches in B
122
+ correctCount += attemptB.filter((x) => answerB.includes(x)).length;
123
+ const totalStatements = answerA.length + answerB.length;
124
+ if (correctCount === totalStatements) {
125
+ // 5 / 5
126
+ data.correct = true;
127
+ }
128
+ else if (correctCount === totalStatements - 1) {
129
+ // 4 / 5
130
+ data.partial = true;
131
+ }
132
+ else {
133
+ // 3 or fewer
134
+ data.incorrect = true;
135
+ }
136
+ }
111
137
  else if (models_1.EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
112
138
  let foundCorrect = false;
113
139
  let index = 0;
@@ -203,6 +229,28 @@ function correctMark(mark) {
203
229
  data.correct = true;
204
230
  }
205
231
  }
232
+ else if (models_1.EQuestionType.SJT_SINGLE_CHOICE === mark.question.typeId) {
233
+ const answer = flatAnswer;
234
+ const attempt = flatAttempt;
235
+ const options = mark.question.choices.map((o) => o.label);
236
+ const answerIndex = options.indexOf(answer);
237
+ const attemptIndex = options.indexOf(attempt);
238
+ if (answerIndex === -1 || attemptIndex === -1) {
239
+ data.incorrect = true;
240
+ }
241
+ else {
242
+ const distance = Math.abs(answerIndex - attemptIndex);
243
+ if (distance === 0) {
244
+ data.correct = true;
245
+ }
246
+ else if (distance === 1) {
247
+ data.partial = true;
248
+ }
249
+ else {
250
+ data.incorrect = true;
251
+ }
252
+ }
253
+ }
206
254
  }
207
255
  catch (e) {
208
256
  console.error(e);