@quesmed/types 2.6.205 → 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.
@@ -263,6 +263,7 @@ export interface IJob {
263
263
  createdAt: Date | number;
264
264
  updatedAt: Date | number;
265
265
  recordCount: number;
266
+ setCount: number;
266
267
  remarkCount: number;
267
268
  resolvedCount: number;
268
269
  memberCount: number;
@@ -164,6 +164,7 @@ exports.FULL_JOB_FRAGMENT = (0, client_1.gql) `
164
164
  createdAt
165
165
  trial
166
166
  recordCount
167
+ setCount
167
168
  publishedCount
168
169
  resolvedCount
169
170
  remarkCount
@@ -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);
@@ -263,6 +263,7 @@ export interface IJob {
263
263
  createdAt: Date | number;
264
264
  updatedAt: Date | number;
265
265
  recordCount: number;
266
+ setCount: number;
266
267
  remarkCount: number;
267
268
  resolvedCount: number;
268
269
  memberCount: number;
@@ -161,6 +161,7 @@ export const FULL_JOB_FRAGMENT = gql `
161
161
  createdAt
162
162
  trial
163
163
  recordCount
164
+ setCount
164
165
  publishedCount
165
166
  resolvedCount
166
167
  remarkCount
@@ -60,7 +60,7 @@ export const UCAT_THEME_ANALYTICS = gql `
60
60
  query UcatThemeAnalytics(
61
61
  $entitlementId: Int
62
62
  $themeId: Int
63
- $updatedAt: Int
63
+ $updatedAt: Date
64
64
  ) {
65
65
  restricted {
66
66
  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;
@@ -35,6 +35,7 @@ export function correctMark(mark) {
35
35
  correct: false,
36
36
  incorrect: false,
37
37
  correctIndex: -1,
38
+ partial: false,
38
39
  };
39
40
  if (!mark || !mark.mark) {
40
41
  return data;
@@ -53,7 +54,6 @@ export function correctMark(mark) {
53
54
  EQuestionType.VERBAL_READING_COMPREHENSION,
54
55
  EQuestionType.DECISION_MAKING_SBA,
55
56
  EQuestionType.QUANTITATIVE_REASONING_SBA,
56
- EQuestionType.SJT_SINGLE_CHOICE,
57
57
  ].includes(mark.question.typeId)) {
58
58
  const answer = flatAnswer;
59
59
  const attempt = flatAttempt;
@@ -79,10 +79,7 @@ export function correctMark(mark) {
79
79
  data.incorrect = true;
80
80
  }
81
81
  }
82
- else if ([
83
- EQuestionType.MULTIPLE_ANSWERS,
84
- EQuestionType.DECISION_MAKING_YES_NO,
85
- ].includes(mark.question.typeId)) {
82
+ else if (EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
86
83
  const [answerA, answerB] = answer.map((x) => x.sort());
87
84
  let [attemptA, attemptB] = [[], []];
88
85
  if (Array.isArray(jsonAnswer) &&
@@ -103,6 +100,35 @@ export function correctMark(mark) {
103
100
  data.incorrect = true;
104
101
  }
105
102
  }
103
+ else if (EQuestionType.DECISION_MAKING_YES_NO === mark.question.typeId) {
104
+ const [answerA, answerB] = answer.map((x) => [...x].sort());
105
+ let [attemptA, attemptB] = [[], []];
106
+ if (Array.isArray(jsonAnswer) &&
107
+ jsonAnswer.length === 2 &&
108
+ Array.isArray(jsonAnswer[0]) &&
109
+ Array.isArray(jsonAnswer[1])) {
110
+ [attemptA, attemptB] = jsonAnswer.map((x) => [...x].sort());
111
+ }
112
+ // Count correct matches
113
+ let correctCount = 0;
114
+ // Count matches in A
115
+ correctCount += attemptA.filter((x) => answerA.includes(x)).length;
116
+ // Count matches in B
117
+ correctCount += attemptB.filter((x) => answerB.includes(x)).length;
118
+ const totalStatements = answerA.length + answerB.length;
119
+ if (correctCount === totalStatements) {
120
+ // 5 / 5
121
+ data.correct = true;
122
+ }
123
+ else if (correctCount === totalStatements - 1) {
124
+ // 4 / 5
125
+ data.partial = true;
126
+ }
127
+ else {
128
+ // 3 or fewer
129
+ data.incorrect = true;
130
+ }
131
+ }
106
132
  else if (EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
107
133
  let foundCorrect = false;
108
134
  let index = 0;
@@ -198,6 +224,28 @@ export function correctMark(mark) {
198
224
  data.correct = true;
199
225
  }
200
226
  }
227
+ else if (EQuestionType.SJT_SINGLE_CHOICE === mark.question.typeId) {
228
+ const answer = flatAnswer;
229
+ const attempt = flatAttempt;
230
+ const options = mark.question.choices.map((o) => o.label);
231
+ const answerIndex = options.indexOf(answer);
232
+ const attemptIndex = options.indexOf(attempt);
233
+ if (answerIndex === -1 || attemptIndex === -1) {
234
+ data.incorrect = true;
235
+ }
236
+ else {
237
+ const distance = Math.abs(answerIndex - attemptIndex);
238
+ if (distance === 0) {
239
+ data.correct = true;
240
+ }
241
+ else if (distance === 1) {
242
+ data.partial = true;
243
+ }
244
+ else {
245
+ data.incorrect = true;
246
+ }
247
+ }
248
+ }
201
249
  }
202
250
  catch (e) {
203
251
  console.error(e);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "2.6.205",
3
+ "version": "2.6.207",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",