@quesmed/types-rn 2.5.35 → 2.5.36

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/index.d.ts CHANGED
@@ -8,6 +8,20 @@ export declare const ERRORS: {
8
8
  SUBSCRIPTION_EXPIRED: string;
9
9
  PERMISSION_INVALID: string;
10
10
  };
11
+ export declare enum EGrammarType {
12
+ QUESTION = 0,
13
+ CARD = 1,
14
+ CONCEPT = 2,
15
+ PSA_MULTI_QA = 3,
16
+ PSA_PRESCRIBE = 4,
17
+ PSA_QA = 5,
18
+ PSA_SBA = 6,
19
+ OSCE = 7,
20
+ BOOK = 8,
21
+ EMQ_QUESTION = 9,
22
+ SJT_QUESTION = 10,
23
+ RA_QUESTION = 11
24
+ }
11
25
  export declare const FCM_TOPICS: {
12
26
  GLOBAL: string;
13
27
  QBANK: string;
package/index.js CHANGED
@@ -26,7 +26,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
26
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.generateDisplayName = exports.medicalWords = exports.termsAndConditions = exports.EPlatformId = exports.FCM_TOPICS = exports.ERRORS = exports.utils = exports.Models = void 0;
29
+ exports.generateDisplayName = exports.medicalWords = exports.termsAndConditions = exports.EPlatformId = exports.FCM_TOPICS = exports.EGrammarType = exports.ERRORS = exports.utils = exports.Models = void 0;
30
30
  const random_1 = require("./utils/random");
31
31
  exports.Models = __importStar(require("./models"));
32
32
  __exportStar(require("./resolvers"), exports);
@@ -38,6 +38,21 @@ exports.ERRORS = {
38
38
  SUBSCRIPTION_EXPIRED: 'Expired subscription.',
39
39
  PERMISSION_INVALID: 'Invalid permission.',
40
40
  };
41
+ var EGrammarType;
42
+ (function (EGrammarType) {
43
+ EGrammarType[EGrammarType["QUESTION"] = 0] = "QUESTION";
44
+ EGrammarType[EGrammarType["CARD"] = 1] = "CARD";
45
+ EGrammarType[EGrammarType["CONCEPT"] = 2] = "CONCEPT";
46
+ EGrammarType[EGrammarType["PSA_MULTI_QA"] = 3] = "PSA_MULTI_QA";
47
+ EGrammarType[EGrammarType["PSA_PRESCRIBE"] = 4] = "PSA_PRESCRIBE";
48
+ EGrammarType[EGrammarType["PSA_QA"] = 5] = "PSA_QA";
49
+ EGrammarType[EGrammarType["PSA_SBA"] = 6] = "PSA_SBA";
50
+ EGrammarType[EGrammarType["OSCE"] = 7] = "OSCE";
51
+ EGrammarType[EGrammarType["BOOK"] = 8] = "BOOK";
52
+ EGrammarType[EGrammarType["EMQ_QUESTION"] = 9] = "EMQ_QUESTION";
53
+ EGrammarType[EGrammarType["SJT_QUESTION"] = 10] = "SJT_QUESTION";
54
+ EGrammarType[EGrammarType["RA_QUESTION"] = 11] = "RA_QUESTION";
55
+ })(EGrammarType = exports.EGrammarType || (exports.EGrammarType = {}));
41
56
  exports.FCM_TOPICS = {
42
57
  GLOBAL: 'global',
43
58
  QBANK: 'qbank',
@@ -18,7 +18,12 @@ export declare enum EQuestionType {
18
18
  SINGLE_BEST_ANSWER = 1,
19
19
  QUESTION_ANSWER = 2,
20
20
  MULTIPLE_ANSWERS = 3,
21
- PRESCRIPTION_ANSWER = 4
21
+ PRESCRIPTION_ANSWER = 4,
22
+ EXTENDED_MATCHING_ANSWER = 5,
23
+ SELECT_THREE_ANSWER = 6,
24
+ RANKING_ANSWER = 7,
25
+ MRCP_PART_1 = 8,
26
+ MRCP_PART_2 = 9
22
27
  }
23
28
  export declare enum EQuestionLike {
24
29
  NONE = 0,
@@ -53,8 +58,8 @@ export interface IQuestionCommentLike {
53
58
  comment: IQuestionComment;
54
59
  likeTrueDislikeFalse: boolean;
55
60
  }
56
- export type IQuestionAnswer = string | [string] | [IQuestionQAAnswer] | [string[], string[]] | IPrescribeAnswer[];
57
- export type IQuestionAll = IQuestion | IQuestionSBA | IQuestionQA | IQuestionMultiQ | IQuestionPrescribe;
61
+ export type IQuestionAnswer = string | [string] | [IQuestionQAAnswer] | [string[], string[]] | IPrescribeAnswer[] | [string, string][] | [string, string, string] | string[];
62
+ export type IQuestionAll = IQuestion | IQuestionSBA | IQuestionQA | IQuestionMultiQ | IQuestionPrescribe | IQuestionEMQ | IQuestionSelect3 | IQuestionRanking;
58
63
  export interface IQuestion {
59
64
  id: Id;
60
65
  createdAt: Date | number;
@@ -70,6 +75,7 @@ export interface IQuestion {
70
75
  answer: IQuestionAnswer;
71
76
  totalVotes: number;
72
77
  choices: IQuestionChoice[];
78
+ cases?: IQuestionCase[];
73
79
  topic?: ITopic;
74
80
  pictures?: IPicture[];
75
81
  difficulty: EDifficultyType;
@@ -111,6 +117,14 @@ export interface IQuestionChoice {
111
117
  votes: number;
112
118
  picture?: IPicture | null;
113
119
  }
120
+ export interface IQuestionCase {
121
+ id: Id;
122
+ updatedAt: number | Date;
123
+ questionId: Id;
124
+ case: string;
125
+ explanation: string;
126
+ label: string;
127
+ }
114
128
  export interface IQuestionElo {
115
129
  id: Id;
116
130
  date: number | Date;
@@ -145,10 +159,25 @@ export interface IQuestionQA extends IQuestion {
145
159
  qaAnswer: [IQuestionQAAnswer];
146
160
  }
147
161
  export declare function isQuestionMultiQ(data: IQuestionAll): data is IQuestionMultiQ;
162
+ export declare function isQuestionEMQ(data: IQuestionAll): data is IQuestionEMQ;
163
+ export declare function isQuestionSelect3(data: IQuestionAll): data is IQuestionSelect3;
164
+ export declare function isQuestionRanking(data: IQuestionAll): data is IQuestionRanking;
148
165
  export interface IQuestionMultiQ extends IQuestion {
149
166
  answer: [string[], string[]];
150
167
  multiAnswer: [string[], string[]];
151
168
  }
169
+ export interface IQuestionEMQ extends IQuestion {
170
+ answer: [string, string][];
171
+ emqAnswer: [string, string][];
172
+ }
173
+ export interface IQuestionSelect3 extends IQuestion {
174
+ answer: [string, string, string];
175
+ answerSelect3: [string, string, string];
176
+ }
177
+ export interface IQuestionRanking extends IQuestion {
178
+ answer: string[];
179
+ answerRanking: string[];
180
+ }
152
181
  export declare function isQuestionPrescribe(data: IQuestionAll): data is IQuestionPrescribe;
153
182
  export interface IQuestionPrescribe extends IQuestion {
154
183
  answer: IPrescribeAnswer[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isQuestionPrescribe = exports.isQuestionMultiQ = exports.isQuestionQA = exports.isQuestionSBA = exports.EQuestionLike = exports.EQuestionType = exports.EPsaSectionType = void 0;
3
+ exports.isQuestionPrescribe = exports.isQuestionRanking = exports.isQuestionSelect3 = exports.isQuestionEMQ = exports.isQuestionMultiQ = exports.isQuestionQA = exports.isQuestionSBA = exports.EQuestionLike = exports.EQuestionType = exports.EPsaSectionType = void 0;
4
4
  var EPsaSectionType;
5
5
  (function (EPsaSectionType) {
6
6
  EPsaSectionType[EPsaSectionType["PRESCRIBING"] = 1] = "PRESCRIBING";
@@ -18,6 +18,11 @@ var EQuestionType;
18
18
  EQuestionType[EQuestionType["QUESTION_ANSWER"] = 2] = "QUESTION_ANSWER";
19
19
  EQuestionType[EQuestionType["MULTIPLE_ANSWERS"] = 3] = "MULTIPLE_ANSWERS";
20
20
  EQuestionType[EQuestionType["PRESCRIPTION_ANSWER"] = 4] = "PRESCRIPTION_ANSWER";
21
+ EQuestionType[EQuestionType["EXTENDED_MATCHING_ANSWER"] = 5] = "EXTENDED_MATCHING_ANSWER";
22
+ EQuestionType[EQuestionType["SELECT_THREE_ANSWER"] = 6] = "SELECT_THREE_ANSWER";
23
+ EQuestionType[EQuestionType["RANKING_ANSWER"] = 7] = "RANKING_ANSWER";
24
+ EQuestionType[EQuestionType["MRCP_PART_1"] = 8] = "MRCP_PART_1";
25
+ EQuestionType[EQuestionType["MRCP_PART_2"] = 9] = "MRCP_PART_2";
21
26
  })(EQuestionType = exports.EQuestionType || (exports.EQuestionType = {}));
22
27
  var EQuestionLike;
23
28
  (function (EQuestionLike) {
@@ -37,6 +42,18 @@ function isQuestionMultiQ(data) {
37
42
  return data.typeId === EQuestionType.MULTIPLE_ANSWERS;
38
43
  }
39
44
  exports.isQuestionMultiQ = isQuestionMultiQ;
45
+ function isQuestionEMQ(data) {
46
+ return data.typeId === EQuestionType.EXTENDED_MATCHING_ANSWER;
47
+ }
48
+ exports.isQuestionEMQ = isQuestionEMQ;
49
+ function isQuestionSelect3(data) {
50
+ return data.typeId === EQuestionType.SELECT_THREE_ANSWER;
51
+ }
52
+ exports.isQuestionSelect3 = isQuestionSelect3;
53
+ function isQuestionRanking(data) {
54
+ return data.typeId === EQuestionType.RANKING_ANSWER;
55
+ }
56
+ exports.isQuestionRanking = isQuestionRanking;
40
57
  function isQuestionPrescribe(data) {
41
58
  return data.typeId === EQuestionType.PRESCRIPTION_ANSWER;
42
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types-rn",
3
- "version": "2.5.35",
3
+ "version": "2.5.36",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",
@@ -140,6 +140,15 @@ function formatPrescribeAnswer(baseAnswer) {
140
140
  return obj;
141
141
  }
142
142
  exports.formatPrescribeAnswer = formatPrescribeAnswer;
143
+ function createHashMap(arr) {
144
+ const map = new Map();
145
+ for (const innerArr of arr) {
146
+ const sortedInnerArr = innerArr.slice().sort();
147
+ const key = sortedInnerArr.join('|');
148
+ map.set(key, (map.get(key) || 0) + 1);
149
+ }
150
+ return map;
151
+ }
143
152
  function correctMark(mark) {
144
153
  const data = {
145
154
  correct: false,
@@ -246,6 +255,65 @@ function correctMark(mark) {
246
255
  data.incorrect = true;
247
256
  }
248
257
  }
258
+ else if (models_1.EQuestionType.EXTENDED_MATCHING_ANSWER === mark.question.typeId) {
259
+ const extendedAnswer = answer;
260
+ const attempt = jsonAnswer;
261
+ if (extendedAnswer.length !== attempt.length) {
262
+ data.incorrect = true;
263
+ }
264
+ else {
265
+ const map1 = createHashMap(extendedAnswer);
266
+ const map2 = createHashMap(attempt);
267
+ for (const [key, value] of map1) {
268
+ if (map2.get(key) !== value) {
269
+ data.incorrect = true;
270
+ break;
271
+ }
272
+ }
273
+ if (!data.incorrect) {
274
+ data.correct = true;
275
+ }
276
+ }
277
+ }
278
+ else if (models_1.EQuestionType.SELECT_THREE_ANSWER === mark.question.typeId) {
279
+ const threeAnswer = answer;
280
+ const attempt = jsonAnswer;
281
+ if (threeAnswer.length !== 3) {
282
+ data.incorrect = true;
283
+ }
284
+ else {
285
+ const answerSet = new Set(threeAnswer);
286
+ for (const attemptLabel of attempt) {
287
+ if (!answerSet.has(attemptLabel)) {
288
+ data.incorrect = true;
289
+ break;
290
+ }
291
+ }
292
+ if (!data.incorrect) {
293
+ data.correct = true;
294
+ }
295
+ }
296
+ }
297
+ else if (models_1.EQuestionType.RANKING_ANSWER === mark.question.typeId) {
298
+ // Duplicate logic to Extended Matching, but they have different scoring systems
299
+ // which we may add at a later point
300
+ const rankAnswer = answer;
301
+ const attempt = jsonAnswer;
302
+ if (rankAnswer.length !== attempt.length) {
303
+ data.incorrect = true;
304
+ }
305
+ else {
306
+ for (let i = 0; i < rankAnswer.length; i++) {
307
+ if (rankAnswer[i] !== attempt[i]) {
308
+ data.incorrect = true;
309
+ break;
310
+ }
311
+ }
312
+ if (!data.incorrect) {
313
+ data.correct = true;
314
+ }
315
+ }
316
+ }
249
317
  }
250
318
  catch (e) {
251
319
  console.error(e);