@quesmed/types-rn 2.6.211 → 2.6.213

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.
@@ -86,6 +86,10 @@ export interface IMarksheet {
86
86
  users: IUser[];
87
87
  activeUsers?: IUser[];
88
88
  state: EMarksheetState;
89
+ /**
90
+ * @deprecated Use !!endedAt instead
91
+ * And for timed tests, check if (parent.endedAt && new Date(parent.endedAt) <= new Date());
92
+ */
89
93
  completed: boolean;
90
94
  timeTaken: number;
91
95
  currentMarkId?: number;
@@ -114,10 +118,14 @@ export interface IMarksheetMark {
114
118
  question: IQuestion;
115
119
  mark: IMarksheetMarkJSONB;
116
120
  marksheet?: IMarksheet;
117
- isAnswered: boolean;
118
121
  striked: number[];
119
122
  score: number;
120
123
  result: EMarkResult;
124
+ /**
125
+ * @deprecated Use !!mark instead
126
+ */
127
+ isAnswered: boolean;
128
+ isInDailyStack: boolean;
121
129
  }
122
130
  export interface IPreBuildMarksheetRef {
123
131
  createdAt: number | Date;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types-rn",
3
- "version": "2.6.211",
3
+ "version": "2.6.213",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",
@@ -13,3 +13,4 @@ export declare const MODIFY_CURRENT_MARK_FRAGMENT: import("@apollo/client").Docu
13
13
  export declare const MARK_FLAGGED_FIELD: import("@apollo/client").DocumentNode;
14
14
  export declare const MODIFY_MARKSHEET_COMPLETED_FRAGMENT: import("@apollo/client").DocumentNode;
15
15
  export declare const NEW_MARK_FIELDS: import("@apollo/client").DocumentNode;
16
+ export declare const DAILY_STACK_FIELDS: import("@apollo/client").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NEW_MARK_FIELDS = exports.MODIFY_MARKSHEET_COMPLETED_FRAGMENT = exports.MARK_FLAGGED_FIELD = exports.MODIFY_CURRENT_MARK_FRAGMENT = exports.MODIFY_TOPIC_SELECTION_FRAGMENT = exports.MODIFY_MARKSHEET_STATE_FRAGMENT = exports.MODIFY_MARKSHEET_MARK_STRIKED_FRAGMENT = exports.MODIFY_MARKSHEET_MARK_QUESTIONCHOICEID_FRAGMENT = exports.MODIFY_CURRENT_MARKSHEET_MARK_FRAGMENT = exports.MARKSHEET_FIELDS = exports.BUILDER_CONFIG_FIELDS = exports.MARKSHEET_MARK_FIELDS = void 0;
3
+ exports.DAILY_STACK_FIELDS = exports.NEW_MARK_FIELDS = exports.MODIFY_MARKSHEET_COMPLETED_FRAGMENT = exports.MARK_FLAGGED_FIELD = exports.MODIFY_CURRENT_MARK_FRAGMENT = exports.MODIFY_TOPIC_SELECTION_FRAGMENT = exports.MODIFY_MARKSHEET_STATE_FRAGMENT = exports.MODIFY_MARKSHEET_MARK_STRIKED_FRAGMENT = exports.MODIFY_MARKSHEET_MARK_QUESTIONCHOICEID_FRAGMENT = exports.MODIFY_CURRENT_MARKSHEET_MARK_FRAGMENT = exports.MARKSHEET_FIELDS = exports.BUILDER_CONFIG_FIELDS = exports.MARKSHEET_MARK_FIELDS = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const question_1 = require("./question");
6
6
  exports.MARKSHEET_MARK_FIELDS = (0, client_1.gql) `
@@ -12,6 +12,7 @@ exports.MARKSHEET_MARK_FIELDS = (0, client_1.gql) `
12
12
  questionChoiceId
13
13
  marksheetId
14
14
  timeTaken
15
+ isInDailyStack
15
16
  isAnswered
16
17
  striked
17
18
  mark
@@ -150,3 +151,8 @@ exports.NEW_MARK_FIELDS = (0, client_1.gql) `
150
151
  score
151
152
  }
152
153
  `;
154
+ exports.DAILY_STACK_FIELDS = (0, client_1.gql) `
155
+ fragment DailyStackField on MarksheetMark {
156
+ isInDailyStack
157
+ }
158
+ `;
@@ -70,6 +70,7 @@ exports.SAVE_MARKSHEET = (0, client_1.gql) `
70
70
  state
71
71
  marks {
72
72
  isAnswered
73
+ isInDailyStack
73
74
  result
74
75
  score
75
76
  id
@@ -356,6 +357,7 @@ exports.MODIFY_MARKSHEET_MARK = (0, client_1.gql) `
356
357
  result
357
358
  score
358
359
  isAnswered
360
+ isInDailyStack
359
361
  striked
360
362
  }
361
363
  }
@@ -462,6 +464,7 @@ exports.TOGGLE_STRIKE_OPTIONS = (0, client_1.gql) `
462
464
  id
463
465
  index
464
466
  isAnswered
467
+ isInDailyStack
465
468
  mark
466
469
  result
467
470
  score
@@ -27,10 +27,11 @@ export declare const optimisticToggleFlaggedQuestion: (mark: IMarksheetMark, fla
27
27
  question: import("../../../models").IQuestion;
28
28
  mark: import("../../../models").IMarksheetMarkJSONB;
29
29
  marksheet?: IMarksheet | undefined;
30
- isAnswered: boolean;
31
30
  striked: number[];
32
31
  score: number;
33
32
  result: import("../../../models").EMarkResult;
33
+ isAnswered: boolean;
34
+ isInDailyStack: boolean;
34
35
  };
35
36
  };
36
37
  };
@@ -1,5 +1,5 @@
1
1
  import { ApolloCache } from '@apollo/client';
2
- import { ITodo, Id } from '../../../models';
2
+ import { IMarksheet, ITodo, Id } from '../../../models';
3
3
  import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../../apollo';
4
4
  import { RestrictedData, graphqlNormalize } from '../../types';
5
5
  import { IUserCompletedCard } from './../../../models/User';
@@ -30,20 +30,24 @@ export declare const optimisticSaveTodos: (todo: ITodo, cardIndex: number, todoI
30
30
  export declare const ADD_TO_DAILY_STACK: import("@apollo/client").DocumentNode;
31
31
  export interface IAddToDailyStackVar {
32
32
  conceptIds: Id[];
33
+ marksheetId?: Id;
33
34
  }
34
35
  export type IAddToDailyStackData = RestrictedData<graphqlNormalize & {
35
36
  addedUserCompletedCards: (graphqlNormalize & IUserCompletedCard)[];
36
37
  dailyFeed: graphqlNormalize & ITodo;
38
+ marks: graphqlNormalize & IMarksheet['marks'];
37
39
  }, 'addToDailyStack'>;
38
40
  export declare const REMOVE_FROM_DAILY_STACK: import("@apollo/client").DocumentNode;
39
41
  export interface IRemoveFromDailyStackVar {
40
42
  cardId?: Id;
41
43
  todoId?: Id;
42
44
  conceptId?: Id;
45
+ marksheetId?: Id;
43
46
  }
44
47
  export type IRemoveFromDailyStackData = RestrictedData<graphqlNormalize & {
45
48
  removedUserCompletedCards: (graphqlNormalize & IUserCompletedCard)[];
46
49
  dailyFeed: graphqlNormalize & ITodo;
50
+ marks: graphqlNormalize & IMarksheet['marks'];
47
51
  }, 'removeFromDailyStack'>;
48
52
  export declare const updateCacheOnRemoveFromDailyStack: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IRemoveFromDailyStackData>, options: ApolloUpdateOptions) => void;
49
53
  export declare const updateCacheOnAddToDailyStack: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddToDailyStackData>) => void;
@@ -117,9 +117,9 @@ const optimisticSaveTodos = (todo, cardIndex, todoInput) => {
117
117
  exports.optimisticSaveTodos = optimisticSaveTodos;
118
118
  exports.ADD_TO_DAILY_STACK = (0, client_1.gql) `
119
119
  ${fragments_1.PICTURE_FIELDS}
120
- mutation AddToDailyStack($conceptIds: [Int!]!) {
120
+ mutation AddToDailyStack($conceptIds: [Int!]!, $marksheetId: Int) {
121
121
  restricted {
122
- addToDailyStack(conceptIds: $conceptIds) {
122
+ addToDailyStack(conceptIds: $conceptIds, marksheetId: $marksheetId) {
123
123
  addedUserCompletedCards {
124
124
  id
125
125
  createdAt
@@ -152,6 +152,10 @@ exports.ADD_TO_DAILY_STACK = (0, client_1.gql) `
152
152
  }
153
153
  }
154
154
  }
155
+ marks {
156
+ id
157
+ isInDailyStack
158
+ }
155
159
  dailyFeed {
156
160
  id
157
161
  marks {
@@ -163,12 +167,18 @@ exports.ADD_TO_DAILY_STACK = (0, client_1.gql) `
163
167
  }
164
168
  `;
165
169
  exports.REMOVE_FROM_DAILY_STACK = (0, client_1.gql) `
166
- mutation RemoveFromDailyStack($cardId: Int, $todoId: Int, $conceptId: Int) {
170
+ mutation RemoveFromDailyStack(
171
+ $cardId: Int
172
+ $todoId: Int
173
+ $conceptId: Int
174
+ $marksheetId: Int
175
+ ) {
167
176
  restricted {
168
177
  removeFromDailyStack(
169
178
  cardId: $cardId
170
179
  todoId: $todoId
171
180
  conceptId: $conceptId
181
+ marksheetId: $marksheetId
172
182
  ) {
173
183
  removedUserCompletedCards {
174
184
  id
@@ -178,6 +188,10 @@ exports.REMOVE_FROM_DAILY_STACK = (0, client_1.gql) `
178
188
  name
179
189
  }
180
190
  }
191
+ marks {
192
+ id
193
+ isInDailyStack
194
+ }
181
195
  dailyFeed {
182
196
  id
183
197
  marks {
@@ -217,6 +231,20 @@ const updateCacheOnRemoveFromDailyStack = (cache, result, options) => {
217
231
  },
218
232
  });
219
233
  }
234
+ if (data.marks?.length) {
235
+ for (const mark of data.marks) {
236
+ cache.writeFragment({
237
+ id: cache.identify({
238
+ id: mark.id,
239
+ __typename: 'MarksheetMark',
240
+ }),
241
+ data: {
242
+ isInDailyStack: mark.isInDailyStack,
243
+ },
244
+ fragment: fragments_1.DAILY_STACK_FIELDS,
245
+ });
246
+ }
247
+ }
220
248
  if (todoId) {
221
249
  const prevData = cache.readQuery({
222
250
  variables: { id: todoId },
@@ -267,6 +295,20 @@ const updateCacheOnAddToDailyStack = (cache, result) => {
267
295
  },
268
296
  });
269
297
  }
298
+ if (data?.marks?.length) {
299
+ for (const mark of data.marks) {
300
+ cache.writeFragment({
301
+ id: cache.identify({
302
+ id: mark.id,
303
+ __typename: 'MarksheetMark',
304
+ }),
305
+ data: {
306
+ isInDailyStack: mark.isInDailyStack,
307
+ },
308
+ fragment: fragments_1.DAILY_STACK_FIELDS,
309
+ });
310
+ }
311
+ }
270
312
  };
271
313
  exports.updateCacheOnAddToDailyStack = updateCacheOnAddToDailyStack;
272
314
  exports.REFRESH_DAILY_TASK = (0, client_1.gql) `
@@ -8,12 +8,11 @@ export interface IMarksheetVar {
8
8
  export type IMarksheetData = RestrictedData<graphqlNormalize & IMarksheet, 'marksheet'>;
9
9
  export declare const MARKSHEET: import("@apollo/client").DocumentNode;
10
10
  export interface IMarksheetsVar {
11
- filter: {
11
+ options: {
12
12
  limit: number;
13
13
  order?: ESortOrder;
14
- offset?: number;
14
+ lastId?: number;
15
15
  solo?: boolean;
16
- period?: number;
17
16
  };
18
17
  }
19
18
  export interface IMarksheetsWindowVar {
@@ -14,14 +14,18 @@ exports.MARKSHEET = (0, client_1.gql) `
14
14
  }
15
15
  `;
16
16
  exports.MARKSHEETS = (0, client_1.gql) `
17
- query Marksheets($filter: MarksheetFilterInput!) {
17
+ query Marksheets($options: MarksheetOptions!) {
18
18
  restricted {
19
- marksheets(filter: $filter) {
19
+ marksheets(options: $options) {
20
20
  results {
21
21
  id
22
22
  source
23
23
  endedAt
24
24
  topicNames
25
+ entitlement {
26
+ id
27
+ name
28
+ }
25
29
  correct
26
30
  incorrect
27
31
  totalQuestions
@@ -45,7 +49,6 @@ exports.MARKSHEETS = (0, client_1.gql) `
45
49
  }
46
50
  }
47
51
  total
48
- score
49
52
  }
50
53
  }
51
54
  }
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.USER_ACTIVITY = exports.USER_STATS = exports.DAILY_FEED = exports.USER_COMPLETED_DATA = exports.REFERRALS = exports.GET_USER_SUBSCRIPTIONS = exports.USER = void 0;
4
4
  const client_1 = require("@apollo/client");
5
- const fragments_1 = require("../../fragments");
6
5
  const user_1 = require("../../fragments/user");
7
6
  exports.USER = (0, client_1.gql) `
8
7
  ${user_1.USER_FIELDS}
@@ -50,11 +49,10 @@ exports.REFERRALS = (0, client_1.gql) `
50
49
  }
51
50
  `;
52
51
  exports.USER_COMPLETED_DATA = (0, client_1.gql) `
53
- ${fragments_1.PICTURE_FIELDS}
54
- query CompletedQuestionCards {
52
+ query CompletedQuestionCards($marksheetId: Int) {
55
53
  restricted {
56
54
  user {
57
- completedCards {
55
+ completedCards(marksheetId: $marksheetId) {
58
56
  id
59
57
  createdAt
60
58
  updatedAt
@@ -62,31 +60,7 @@ exports.USER_COMPLETED_DATA = (0, client_1.gql) `
62
60
  id
63
61
  name
64
62
  }
65
- lastSeen
66
- reviewDate
67
- score
68
- iteration
69
- optimalFactor
70
- cardId
71
- card {
72
- id
73
- conceptId
74
- concept {
75
- id
76
- name
77
- }
78
- topic {
79
- id
80
- name
81
- }
82
- question
83
- explanation
84
- pictures {
85
- ...PictureFields
86
- }
87
- }
88
63
  }
89
- completedCardsCount
90
64
  }
91
65
  }
92
66
  }
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.evaluateMark = void 0;
4
4
  const models_1 = require("../models");
5
- const object_1 = require("./object");
6
5
  function isPrescribeAnswer(data) {
7
6
  return Object(data).hasOwnProperty('dose');
8
7
  }
@@ -153,21 +152,43 @@ function evaluateMark({ mark, answer, questionTypeId, psaSectionId, choices, })
153
152
  break;
154
153
  }
155
154
  case models_1.EQuestionType.PRESCRIPTION_ANSWER: {
156
- let foundCorrect = false;
157
- if (typeof flatAttempt === 'object' &&
158
- Object.keys(flatAttempt).length > 0) {
159
- const answers = answer.map(mapPrescribeMarkToAnswer);
160
- const attempt = mapPrescribeMarkToAnswer(flatAttempt);
161
- foundCorrect = answers.some((ans) => (0, object_1.compareObjects)(ans, attempt));
162
- }
163
- if (foundCorrect) {
164
- data.score = 1;
165
- data.result = models_1.EMarkResult.Correct;
155
+ if (typeof flatAttempt !== 'object' ||
156
+ !flatAttempt ||
157
+ Object.keys(flatAttempt).length === 0) {
158
+ data.score = 0;
159
+ data.result = models_1.EMarkResult.Incorrect;
160
+ break;
166
161
  }
167
- else {
162
+ const answers = answer.map(mapPrescribeMarkToAnswer);
163
+ const attempt = mapPrescribeMarkToAnswer(flatAttempt);
164
+ // Find all answers with matching drug
165
+ const matchingDrugAnswers = answers.filter((ans) => ans.drugId === attempt.drugId);
166
+ if (matchingDrugAnswers.length === 0) {
168
167
  data.score = 0;
169
168
  data.result = models_1.EMarkResult.Incorrect;
169
+ break;
170
+ }
171
+ // Base score for correct drug
172
+ const DRUG_SCORE = 5;
173
+ const COMPONENT_SCORES = {
174
+ 3: 5,
175
+ 2: 3,
176
+ 1: 2,
177
+ 0: 0, // no components are correct
178
+ };
179
+ // Find the best matching answer (highest component score)
180
+ let bestCorrectCount = -1;
181
+ for (const matchingDrugAnswer of matchingDrugAnswers) {
182
+ const correctCount = Number(matchingDrugAnswer.doseId === attempt.doseId) +
183
+ Number(matchingDrugAnswer.routeId === attempt.routeId) +
184
+ Number(matchingDrugAnswer.frequencyId === attempt.frequencyId);
185
+ if (correctCount > bestCorrectCount) {
186
+ bestCorrectCount = correctCount;
187
+ }
170
188
  }
189
+ data.score = DRUG_SCORE + COMPONENT_SCORES[bestCorrectCount];
190
+ data.result =
191
+ bestCorrectCount === 3 ? models_1.EMarkResult.Correct : models_1.EMarkResult.Partial;
171
192
  break;
172
193
  }
173
194
  case models_1.EQuestionType.EXTENDED_MATCHING_ANSWER: {