@quesmed/types 2.6.30 → 2.6.32

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.
@@ -1,6 +1,7 @@
1
1
  export * from './blog';
2
2
  export * from './chapter';
3
3
  export * from './concept';
4
+ export * from './marksheet';
4
5
  export * from './mockTest';
5
6
  export * from './osce';
6
7
  export * from './picture';
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./blog"), exports);
18
18
  __exportStar(require("./chapter"), exports);
19
19
  __exportStar(require("./concept"), exports);
20
+ __exportStar(require("./marksheet"), exports);
20
21
  __exportStar(require("./mockTest"), exports);
21
22
  __exportStar(require("./osce"), exports);
22
23
  __exportStar(require("./picture"), exports);
@@ -1 +1,7 @@
1
1
  export declare const MOCK_TEST_FIELDS: import("@apollo/client").DocumentNode;
2
+ /**
3
+ * All below fragments are used in cache updator
4
+ */
5
+ export declare const MARK_FLAGGED_QUESTION: import("@apollo/client").DocumentNode;
6
+ export declare const COMPLETED_MOCK_TEST_MARKSHEET_FRAGMENT: import("@apollo/client").DocumentNode;
7
+ export declare const COMPLETED_MOCK_TESTS_FRAGMENT: import("@apollo/client").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MOCK_TEST_FIELDS = void 0;
3
+ exports.COMPLETED_MOCK_TESTS_FRAGMENT = exports.COMPLETED_MOCK_TEST_MARKSHEET_FRAGMENT = exports.MARK_FLAGGED_QUESTION = exports.MOCK_TEST_FIELDS = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  exports.MOCK_TEST_FIELDS = (0, client_1.gql) `
6
6
  fragment MockTestFields on MockTest {
@@ -17,3 +17,29 @@ exports.MOCK_TEST_FIELDS = (0, client_1.gql) `
17
17
  typeId
18
18
  }
19
19
  `;
20
+ /**
21
+ * All below fragments are used in cache updator
22
+ */
23
+ exports.MARK_FLAGGED_QUESTION = (0, client_1.gql) `
24
+ fragment MarksheetMarkFlagged on MarksheetMark {
25
+ flagged
26
+ }
27
+ `;
28
+ exports.COMPLETED_MOCK_TEST_MARKSHEET_FRAGMENT = (0, client_1.gql) `
29
+ fragment MockTestCompleted on Marksheet {
30
+ completed
31
+ correct
32
+ incorrect
33
+ duration
34
+ endedAt
35
+ }
36
+ `;
37
+ exports.COMPLETED_MOCK_TESTS_FRAGMENT = (0, client_1.gql) `
38
+ fragment CompletedMockTestFragment on MockTest {
39
+ correct
40
+ incorrect
41
+ lastMarksheetEndedAt
42
+ lastMarksheetStartedAt
43
+ lastMarksheetId
44
+ }
45
+ `;
@@ -4,3 +4,5 @@ export declare const OSCE_MARKSHEET_MARK_FIELDS: import("@apollo/client").Docume
4
4
  export declare const OSCE_MARKSHEET_FIELDS: import("@apollo/client").DocumentNode;
5
5
  export declare const OSCE_MATCHMAKING_ACTION_FIELDS: import("@apollo/client").DocumentNode;
6
6
  export declare const STATION_CONCEPT_FRAGMENT: import("@apollo/client").DocumentNode;
7
+ export declare const COMPLETED_OSCE_MARKSHEET_FRAGMENT: import("@apollo/client").DocumentNode;
8
+ export declare const COMPLETED_OSCE_STATION_FRAGMENT: import("@apollo/client").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STATION_CONCEPT_FRAGMENT = exports.OSCE_MATCHMAKING_ACTION_FIELDS = exports.OSCE_MARKSHEET_FIELDS = exports.OSCE_MARKSHEET_MARK_FIELDS = exports.OSCE_STATION_FIELDS = exports.OSCE_STATION_MARK_FIELDS = void 0;
3
+ exports.COMPLETED_OSCE_STATION_FRAGMENT = exports.COMPLETED_OSCE_MARKSHEET_FRAGMENT = exports.STATION_CONCEPT_FRAGMENT = exports.OSCE_MATCHMAKING_ACTION_FIELDS = exports.OSCE_MARKSHEET_FIELDS = exports.OSCE_MARKSHEET_MARK_FIELDS = exports.OSCE_STATION_FIELDS = exports.OSCE_STATION_MARK_FIELDS = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const picture_1 = require("./picture");
6
6
  exports.OSCE_STATION_MARK_FIELDS = (0, client_1.gql) `
@@ -164,3 +164,20 @@ exports.STATION_CONCEPT_FRAGMENT = (0, client_1.gql) `
164
164
  status
165
165
  }
166
166
  `;
167
+ exports.COMPLETED_OSCE_MARKSHEET_FRAGMENT = (0, client_1.gql) `
168
+ fragment CompletedOsceMarksheetFragment on OsceMarksheet {
169
+ completed
170
+ score
171
+ globalScore
172
+ state
173
+ timeTaken
174
+ endedAt
175
+ }
176
+ `;
177
+ exports.COMPLETED_OSCE_STATION_FRAGMENT = (0, client_1.gql) `
178
+ fragment CompletedOsceStationFragment on OsceStation {
179
+ score
180
+ completedMarks
181
+ lastOsceMarksheetId
182
+ }
183
+ `;
@@ -1,7 +1,7 @@
1
1
  import { ApolloCache } from '@apollo/client';
2
2
  import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../..';
3
- import { Id, IMarksheet, IMarksheetMark } from '../../../models';
4
- import { graphqlNormalize, RestrictedData } from '../../types';
3
+ import { IMarksheet, IMarksheetMark, Id } from '../../../models';
4
+ import { RestrictedData, graphqlNormalize } from '../../types';
5
5
  export declare const BUILD_MOCK_TEST_MARKSHEET: import("@apollo/client").DocumentNode;
6
6
  export interface IBuildMockTestMarksheetVar {
7
7
  mockTestId: Id;
@@ -9,7 +9,6 @@ export interface IBuildMockTestMarksheetVar {
9
9
  }
10
10
  export type IBuildMockTestMarksheetData = RestrictedData<graphqlNormalize & IMarksheet, 'buildMockTestMarksheet'>;
11
11
  export declare const TOGGLE_FLAGGED_MARK: import("@apollo/client").DocumentNode;
12
- export declare const MARK_FLAGGED_QUESTION: import("@apollo/client").DocumentNode;
13
12
  export declare const updateCacheToggleFlaggedQuestion: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IToggleFlaggedMarkData>) => void;
14
13
  export declare const optimisticToggleFlaggedQuestion: (mark: IMarksheetMark, flagged: boolean) => {
15
14
  restricted: {
@@ -40,7 +39,7 @@ export interface IToggleFlaggedMarkVar {
40
39
  }
41
40
  export type IToggleFlaggedMarkData = RestrictedData<graphqlNormalize & IMarksheetMark, 'toggleFlaggedMark'>;
42
41
  export declare const END_MOCK_TEST: import("@apollo/client").DocumentNode;
43
- export declare const updateCacheOnEndMockTest: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IEndMockTestData>, options: ApolloUpdateOptions) => void;
42
+ export declare const updateCacheOnEndMockTest: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IEndMockTestData>, options: ApolloUpdateOptions<IEndMockTestVar>) => void;
44
43
  export declare const optimisticEndMockTest: (marksheet: IMarksheet) => {
45
44
  restricted: {
46
45
  __typename: string;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.optimisticEndMockTest = exports.updateCacheOnEndMockTest = exports.END_MOCK_TEST = exports.optimisticToggleFlaggedQuestion = exports.updateCacheToggleFlaggedQuestion = exports.MARK_FLAGGED_QUESTION = exports.TOGGLE_FLAGGED_MARK = exports.BUILD_MOCK_TEST_MARKSHEET = void 0;
3
+ exports.optimisticEndMockTest = exports.updateCacheOnEndMockTest = exports.END_MOCK_TEST = exports.optimisticToggleFlaggedQuestion = exports.updateCacheToggleFlaggedQuestion = exports.TOGGLE_FLAGGED_MARK = exports.BUILD_MOCK_TEST_MARKSHEET = void 0;
4
4
  const client_1 = require("@apollo/client");
5
+ const fragments_1 = require("../../fragments");
5
6
  exports.BUILD_MOCK_TEST_MARKSHEET = (0, client_1.gql) `
6
7
  mutation BuildMockTestMarksheet($mockTestId: Int!, $duration: Int!) {
7
8
  restricted {
@@ -29,11 +30,6 @@ exports.TOGGLE_FLAGGED_MARK = (0, client_1.gql) `
29
30
  }
30
31
  }
31
32
  `;
32
- exports.MARK_FLAGGED_QUESTION = (0, client_1.gql) `
33
- fragment MarksheetMarkFlagged on MarksheetMark {
34
- flagged
35
- }
36
- `;
37
33
  const updateCacheToggleFlaggedQuestion = (cache, result) => {
38
34
  const { toggleFlaggedMark } = result?.data?.restricted || {};
39
35
  if (!toggleFlaggedMark) {
@@ -45,7 +41,7 @@ const updateCacheToggleFlaggedQuestion = (cache, result) => {
45
41
  data: {
46
42
  flagged,
47
43
  },
48
- fragment: exports.MARK_FLAGGED_QUESTION,
44
+ fragment: fragments_1.MARK_FLAGGED_QUESTION,
49
45
  });
50
46
  };
51
47
  exports.updateCacheToggleFlaggedQuestion = updateCacheToggleFlaggedQuestion;
@@ -64,6 +60,9 @@ exports.END_MOCK_TEST = (0, client_1.gql) `
64
60
  restricted {
65
61
  endMockTest(marksheetId: $marksheetId) {
66
62
  id
63
+ startedAt
64
+ endedAt
65
+ mockTestId
67
66
  completed
68
67
  correct
69
68
  incorrect
@@ -73,11 +72,6 @@ exports.END_MOCK_TEST = (0, client_1.gql) `
73
72
  }
74
73
  }
75
74
  `;
76
- const COMPLETED_MOCK_TEST_FRAGMENT = (0, client_1.gql) `
77
- fragment MockTestCompleted on Marksheet {
78
- completed
79
- }
80
- `;
81
75
  const updateCacheOnEndMockTest = (cache, result, options) => {
82
76
  const { endMockTest } = result?.data?.restricted || {};
83
77
  const { variables } = options || {};
@@ -89,8 +83,23 @@ const updateCacheOnEndMockTest = (cache, result, options) => {
89
83
  id: cache.identify({ id, __typename: 'Marksheet' }),
90
84
  data: {
91
85
  completed: true,
86
+ correct: endMockTest.correct,
87
+ incorrect: endMockTest.incorrect,
88
+ duration: endMockTest.duration,
89
+ endedAt: endMockTest.endedAt,
90
+ },
91
+ fragment: fragments_1.COMPLETED_MOCK_TEST_MARKSHEET_FRAGMENT,
92
+ });
93
+ cache.writeFragment({
94
+ id: cache.identify({ id: endMockTest.mockTestId, __typename: 'MockTest' }),
95
+ data: {
96
+ lastMarksheetId: endMockTest.id,
97
+ lastMarksheetStartedAt: endMockTest.startedAt,
98
+ lastMarksheetEndedAt: endMockTest.endedAt,
99
+ correct: endMockTest.correct,
100
+ incorrect: endMockTest.incorrect,
92
101
  },
93
- fragment: COMPLETED_MOCK_TEST_FRAGMENT,
102
+ fragment: fragments_1.COMPLETED_MOCK_TESTS_FRAGMENT,
94
103
  });
95
104
  };
96
105
  exports.updateCacheOnEndMockTest = updateCacheOnEndMockTest;
@@ -1,6 +1,8 @@
1
- import { EOsceMarksheetAction, EOsceMarksheetState, EOsceRoles, EPaceMarkType, EProductType, EStudyAction, Id, IOsceMarksheet, IOsceMarksheetMark } from '../../../models';
1
+ import { ApolloCache } from '@apollo/client';
2
+ import { EOsceMarksheetAction, EOsceMarksheetState, EOsceRoles, EPaceMarkType, EProductType, EStudyAction, IOsceMarksheet, IOsceMarksheetMark, Id } from '../../../models';
3
+ import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../../apollo';
2
4
  import { IOsceMatchmakingAction } from '../../subscription/osce';
3
- import { graphqlNormalize, RestrictedData } from '../../types';
5
+ import { RestrictedData, graphqlNormalize } from '../../types';
4
6
  export declare const START_OSCE_MATCHMAKING: import("@apollo/client").DocumentNode;
5
7
  export interface IStartOsceMatchmakingVar {
6
8
  sessionId: string;
@@ -89,6 +91,48 @@ export declare const END_OSCE_MARKSHEET: import("@apollo/client").DocumentNode;
89
91
  export interface IEndOsceMarksheetVar extends ISaveOsceMarksheetVar {
90
92
  }
91
93
  export type IEndOsceMarksheetData = RestrictedData<graphqlNormalize & IOsceMarksheet, 'endOsceMarksheet'>;
94
+ export declare const updateCacheOnEndOsceMarksheet: (productType: EProductType) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IEndOsceMarksheetData>, options: ApolloUpdateOptions<IEndOsceMarksheetVar>) => void;
95
+ export declare const optimisticEndOsceMarksheet: (marksheet: IOsceMarksheet) => {
96
+ restricted: {
97
+ __typename: string;
98
+ endOsceMarksheet: {
99
+ completed: boolean;
100
+ id: number;
101
+ createdAt: number | Date;
102
+ updatedAt: number | Date;
103
+ deletedAt: number | Date;
104
+ timeTaken: number;
105
+ osceStationId: number;
106
+ osceStation?: import("../../../models").IOsceStation | undefined;
107
+ role?: EOsceRoles | undefined;
108
+ solo: boolean;
109
+ score: number;
110
+ total: number;
111
+ correct: number;
112
+ globalScore: number;
113
+ feedback: string;
114
+ agoraId: string;
115
+ sessionId: string;
116
+ readingTime: number;
117
+ stationTime: number;
118
+ feedbackTime: number;
119
+ startedAt: number | Date;
120
+ endedAt: number | Date;
121
+ pausedAt: number | Date;
122
+ timeRemaining: string;
123
+ totalStationTime: string;
124
+ stageTime: string;
125
+ stage: import("../../../models").EOsceStage;
126
+ marks: IOsceMarksheetMark[];
127
+ users: import("../../../models").IUser[];
128
+ activeUsers?: import("../../../models").IUser[] | undefined;
129
+ members: import("../../../models").IOsceMarksheetMember[];
130
+ state: EOsceMarksheetState;
131
+ productId: EProductType;
132
+ __typename: string;
133
+ };
134
+ };
135
+ };
92
136
  export declare const LEAVE_OSCE_MARKSHEET: import("@apollo/client").DocumentNode;
93
137
  export interface ILeaveOsceMarksheetVar {
94
138
  osceMarksheetId: Id;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LEAVE_OSCE_MARKSHEET = exports.END_OSCE_MARKSHEET = exports.MODIFY_OSCE_MARKSHEET = exports.SAVE_OSCE_MARKSHEET = exports.PRESTART_OSCE_MARKSHEET = exports.START_OSCE_TIMER = exports.START_OSCE_MARKSHEET = exports.SELECT_OSCE_STATION = exports.optimisticMarkOsceMarksheetMark = exports.MARK_OSCE_MARKSHEET_MARK = exports.CHANGE_OSCE_ROLE = exports.BUILD_OSCE_MARKSHEET = exports.CREATE_OR_JOIN_OSCE_MARKSHEET = exports.CANCEL_OSCE_MATCHMAKING = exports.CHECK_OSCE_MATCHMAKING = exports.ACCEPT_OSCE_MATCHMAKING = exports.START_OSCE_MATCHMAKING = void 0;
3
+ exports.LEAVE_OSCE_MARKSHEET = exports.optimisticEndOsceMarksheet = exports.updateCacheOnEndOsceMarksheet = exports.END_OSCE_MARKSHEET = exports.MODIFY_OSCE_MARKSHEET = exports.SAVE_OSCE_MARKSHEET = exports.PRESTART_OSCE_MARKSHEET = exports.START_OSCE_TIMER = exports.START_OSCE_MARKSHEET = exports.SELECT_OSCE_STATION = exports.optimisticMarkOsceMarksheetMark = exports.MARK_OSCE_MARKSHEET_MARK = exports.CHANGE_OSCE_ROLE = exports.BUILD_OSCE_MARKSHEET = exports.CREATE_OR_JOIN_OSCE_MARKSHEET = exports.CANCEL_OSCE_MATCHMAKING = exports.CHECK_OSCE_MATCHMAKING = exports.ACCEPT_OSCE_MATCHMAKING = exports.START_OSCE_MATCHMAKING = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const models_1 = require("../../../models");
6
6
  const osce_1 = require("../../fragments/osce");
@@ -235,6 +235,54 @@ exports.END_OSCE_MARKSHEET = (0, client_1.gql) `
235
235
  }
236
236
  }
237
237
  `;
238
+ const updateCacheOnEndOsceMarksheet = (productType) => (cache, result, options) => {
239
+ const { endOsceMarksheet } = result?.data?.restricted || {};
240
+ const { variables } = options || {};
241
+ if (!variables || !endOsceMarksheet) {
242
+ return;
243
+ }
244
+ cache.writeFragment({
245
+ id: cache.identify({
246
+ id: endOsceMarksheet.id,
247
+ __typename: 'OsceMarksheet',
248
+ }),
249
+ data: {
250
+ completed: true,
251
+ score: endOsceMarksheet.score,
252
+ state: endOsceMarksheet.state,
253
+ globalScore: endOsceMarksheet.globalScore,
254
+ timeTaken: endOsceMarksheet.timeTaken,
255
+ endedAt: endOsceMarksheet.endedAt,
256
+ },
257
+ fragment: osce_1.COMPLETED_OSCE_MARKSHEET_FRAGMENT,
258
+ });
259
+ cache.writeFragment({
260
+ id: cache.identify({
261
+ id: endOsceMarksheet.osceStationId,
262
+ __typename: 'OsceStation',
263
+ }),
264
+ data: {
265
+ completedMarks: endOsceMarksheet.marks.filter((m) => productType === models_1.EProductType.OSCE
266
+ ? m.mark !== null
267
+ : m.selectedChoice !== null).length,
268
+ score: endOsceMarksheet.score,
269
+ lastOsceMarksheetId: endOsceMarksheet.id,
270
+ },
271
+ fragment: osce_1.COMPLETED_OSCE_STATION_FRAGMENT,
272
+ });
273
+ };
274
+ exports.updateCacheOnEndOsceMarksheet = updateCacheOnEndOsceMarksheet;
275
+ const optimisticEndOsceMarksheet = (marksheet) => ({
276
+ restricted: {
277
+ __typename: 'RestrictedMutation',
278
+ endOsceMarksheet: {
279
+ __typename: 'OsceMarksheet',
280
+ ...marksheet,
281
+ completed: true,
282
+ },
283
+ },
284
+ });
285
+ exports.optimisticEndOsceMarksheet = optimisticEndOsceMarksheet;
238
286
  exports.LEAVE_OSCE_MARKSHEET = (0, client_1.gql) `
239
287
  ${osce_1.OSCE_MARKSHEET_FIELDS}
240
288
  mutation LeaveOsceMarksheet($osceMarksheetId: Int!) {
@@ -1,6 +1,7 @@
1
1
  export * from './blog';
2
2
  export * from './chapter';
3
3
  export * from './concept';
4
+ export * from './marksheet';
4
5
  export * from './mockTest';
5
6
  export * from './osce';
6
7
  export * from './picture';
@@ -1,6 +1,7 @@
1
1
  export * from './blog';
2
2
  export * from './chapter';
3
3
  export * from './concept';
4
+ export * from './marksheet';
4
5
  export * from './mockTest';
5
6
  export * from './osce';
6
7
  export * from './picture';
@@ -1 +1,7 @@
1
1
  export declare const MOCK_TEST_FIELDS: import("@apollo/client").DocumentNode;
2
+ /**
3
+ * All below fragments are used in cache updator
4
+ */
5
+ export declare const MARK_FLAGGED_QUESTION: import("@apollo/client").DocumentNode;
6
+ export declare const COMPLETED_MOCK_TEST_MARKSHEET_FRAGMENT: import("@apollo/client").DocumentNode;
7
+ export declare const COMPLETED_MOCK_TESTS_FRAGMENT: import("@apollo/client").DocumentNode;
@@ -14,3 +14,29 @@ export const MOCK_TEST_FIELDS = gql `
14
14
  typeId
15
15
  }
16
16
  `;
17
+ /**
18
+ * All below fragments are used in cache updator
19
+ */
20
+ export const MARK_FLAGGED_QUESTION = gql `
21
+ fragment MarksheetMarkFlagged on MarksheetMark {
22
+ flagged
23
+ }
24
+ `;
25
+ export const COMPLETED_MOCK_TEST_MARKSHEET_FRAGMENT = gql `
26
+ fragment MockTestCompleted on Marksheet {
27
+ completed
28
+ correct
29
+ incorrect
30
+ duration
31
+ endedAt
32
+ }
33
+ `;
34
+ export const COMPLETED_MOCK_TESTS_FRAGMENT = gql `
35
+ fragment CompletedMockTestFragment on MockTest {
36
+ correct
37
+ incorrect
38
+ lastMarksheetEndedAt
39
+ lastMarksheetStartedAt
40
+ lastMarksheetId
41
+ }
42
+ `;
@@ -4,3 +4,5 @@ export declare const OSCE_MARKSHEET_MARK_FIELDS: import("@apollo/client").Docume
4
4
  export declare const OSCE_MARKSHEET_FIELDS: import("@apollo/client").DocumentNode;
5
5
  export declare const OSCE_MATCHMAKING_ACTION_FIELDS: import("@apollo/client").DocumentNode;
6
6
  export declare const STATION_CONCEPT_FRAGMENT: import("@apollo/client").DocumentNode;
7
+ export declare const COMPLETED_OSCE_MARKSHEET_FRAGMENT: import("@apollo/client").DocumentNode;
8
+ export declare const COMPLETED_OSCE_STATION_FRAGMENT: import("@apollo/client").DocumentNode;
@@ -161,3 +161,20 @@ export const STATION_CONCEPT_FRAGMENT = gql `
161
161
  status
162
162
  }
163
163
  `;
164
+ export const COMPLETED_OSCE_MARKSHEET_FRAGMENT = gql `
165
+ fragment CompletedOsceMarksheetFragment on OsceMarksheet {
166
+ completed
167
+ score
168
+ globalScore
169
+ state
170
+ timeTaken
171
+ endedAt
172
+ }
173
+ `;
174
+ export const COMPLETED_OSCE_STATION_FRAGMENT = gql `
175
+ fragment CompletedOsceStationFragment on OsceStation {
176
+ score
177
+ completedMarks
178
+ lastOsceMarksheetId
179
+ }
180
+ `;
@@ -1,7 +1,7 @@
1
1
  import { ApolloCache } from '@apollo/client';
2
2
  import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../..';
3
- import { Id, IMarksheet, IMarksheetMark } from '../../../models';
4
- import { graphqlNormalize, RestrictedData } from '../../types';
3
+ import { IMarksheet, IMarksheetMark, Id } from '../../../models';
4
+ import { RestrictedData, graphqlNormalize } from '../../types';
5
5
  export declare const BUILD_MOCK_TEST_MARKSHEET: import("@apollo/client").DocumentNode;
6
6
  export interface IBuildMockTestMarksheetVar {
7
7
  mockTestId: Id;
@@ -9,7 +9,6 @@ export interface IBuildMockTestMarksheetVar {
9
9
  }
10
10
  export type IBuildMockTestMarksheetData = RestrictedData<graphqlNormalize & IMarksheet, 'buildMockTestMarksheet'>;
11
11
  export declare const TOGGLE_FLAGGED_MARK: import("@apollo/client").DocumentNode;
12
- export declare const MARK_FLAGGED_QUESTION: import("@apollo/client").DocumentNode;
13
12
  export declare const updateCacheToggleFlaggedQuestion: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IToggleFlaggedMarkData>) => void;
14
13
  export declare const optimisticToggleFlaggedQuestion: (mark: IMarksheetMark, flagged: boolean) => {
15
14
  restricted: {
@@ -40,7 +39,7 @@ export interface IToggleFlaggedMarkVar {
40
39
  }
41
40
  export type IToggleFlaggedMarkData = RestrictedData<graphqlNormalize & IMarksheetMark, 'toggleFlaggedMark'>;
42
41
  export declare const END_MOCK_TEST: import("@apollo/client").DocumentNode;
43
- export declare const updateCacheOnEndMockTest: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IEndMockTestData>, options: ApolloUpdateOptions) => void;
42
+ export declare const updateCacheOnEndMockTest: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IEndMockTestData>, options: ApolloUpdateOptions<IEndMockTestVar>) => void;
44
43
  export declare const optimisticEndMockTest: (marksheet: IMarksheet) => {
45
44
  restricted: {
46
45
  __typename: string;
@@ -1,4 +1,5 @@
1
1
  import { gql } from '@apollo/client';
2
+ import { COMPLETED_MOCK_TESTS_FRAGMENT, COMPLETED_MOCK_TEST_MARKSHEET_FRAGMENT, MARK_FLAGGED_QUESTION, } from '../../fragments';
2
3
  export const BUILD_MOCK_TEST_MARKSHEET = gql `
3
4
  mutation BuildMockTestMarksheet($mockTestId: Int!, $duration: Int!) {
4
5
  restricted {
@@ -26,11 +27,6 @@ export const TOGGLE_FLAGGED_MARK = gql `
26
27
  }
27
28
  }
28
29
  `;
29
- export const MARK_FLAGGED_QUESTION = gql `
30
- fragment MarksheetMarkFlagged on MarksheetMark {
31
- flagged
32
- }
33
- `;
34
30
  export const updateCacheToggleFlaggedQuestion = (cache, result) => {
35
31
  const { toggleFlaggedMark } = result?.data?.restricted || {};
36
32
  if (!toggleFlaggedMark) {
@@ -59,6 +55,9 @@ export const END_MOCK_TEST = gql `
59
55
  restricted {
60
56
  endMockTest(marksheetId: $marksheetId) {
61
57
  id
58
+ startedAt
59
+ endedAt
60
+ mockTestId
62
61
  completed
63
62
  correct
64
63
  incorrect
@@ -68,11 +67,6 @@ export const END_MOCK_TEST = gql `
68
67
  }
69
68
  }
70
69
  `;
71
- const COMPLETED_MOCK_TEST_FRAGMENT = gql `
72
- fragment MockTestCompleted on Marksheet {
73
- completed
74
- }
75
- `;
76
70
  export const updateCacheOnEndMockTest = (cache, result, options) => {
77
71
  const { endMockTest } = result?.data?.restricted || {};
78
72
  const { variables } = options || {};
@@ -84,8 +78,23 @@ export const updateCacheOnEndMockTest = (cache, result, options) => {
84
78
  id: cache.identify({ id, __typename: 'Marksheet' }),
85
79
  data: {
86
80
  completed: true,
81
+ correct: endMockTest.correct,
82
+ incorrect: endMockTest.incorrect,
83
+ duration: endMockTest.duration,
84
+ endedAt: endMockTest.endedAt,
85
+ },
86
+ fragment: COMPLETED_MOCK_TEST_MARKSHEET_FRAGMENT,
87
+ });
88
+ cache.writeFragment({
89
+ id: cache.identify({ id: endMockTest.mockTestId, __typename: 'MockTest' }),
90
+ data: {
91
+ lastMarksheetId: endMockTest.id,
92
+ lastMarksheetStartedAt: endMockTest.startedAt,
93
+ lastMarksheetEndedAt: endMockTest.endedAt,
94
+ correct: endMockTest.correct,
95
+ incorrect: endMockTest.incorrect,
87
96
  },
88
- fragment: COMPLETED_MOCK_TEST_FRAGMENT,
97
+ fragment: COMPLETED_MOCK_TESTS_FRAGMENT,
89
98
  });
90
99
  };
91
100
  export const optimisticEndMockTest = (marksheet) => ({
@@ -1,6 +1,8 @@
1
- import { EOsceMarksheetAction, EOsceMarksheetState, EOsceRoles, EPaceMarkType, EProductType, EStudyAction, Id, IOsceMarksheet, IOsceMarksheetMark } from '../../../models';
1
+ import { ApolloCache } from '@apollo/client';
2
+ import { EOsceMarksheetAction, EOsceMarksheetState, EOsceRoles, EPaceMarkType, EProductType, EStudyAction, IOsceMarksheet, IOsceMarksheetMark, Id } from '../../../models';
3
+ import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../../apollo';
2
4
  import { IOsceMatchmakingAction } from '../../subscription/osce';
3
- import { graphqlNormalize, RestrictedData } from '../../types';
5
+ import { RestrictedData, graphqlNormalize } from '../../types';
4
6
  export declare const START_OSCE_MATCHMAKING: import("@apollo/client").DocumentNode;
5
7
  export interface IStartOsceMatchmakingVar {
6
8
  sessionId: string;
@@ -89,6 +91,48 @@ export declare const END_OSCE_MARKSHEET: import("@apollo/client").DocumentNode;
89
91
  export interface IEndOsceMarksheetVar extends ISaveOsceMarksheetVar {
90
92
  }
91
93
  export type IEndOsceMarksheetData = RestrictedData<graphqlNormalize & IOsceMarksheet, 'endOsceMarksheet'>;
94
+ export declare const updateCacheOnEndOsceMarksheet: (productType: EProductType) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IEndOsceMarksheetData>, options: ApolloUpdateOptions<IEndOsceMarksheetVar>) => void;
95
+ export declare const optimisticEndOsceMarksheet: (marksheet: IOsceMarksheet) => {
96
+ restricted: {
97
+ __typename: string;
98
+ endOsceMarksheet: {
99
+ completed: boolean;
100
+ id: number;
101
+ createdAt: number | Date;
102
+ updatedAt: number | Date;
103
+ deletedAt: number | Date;
104
+ timeTaken: number;
105
+ osceStationId: number;
106
+ osceStation?: import("../../../models").IOsceStation | undefined;
107
+ role?: EOsceRoles | undefined;
108
+ solo: boolean;
109
+ score: number;
110
+ total: number;
111
+ correct: number;
112
+ globalScore: number;
113
+ feedback: string;
114
+ agoraId: string;
115
+ sessionId: string;
116
+ readingTime: number;
117
+ stationTime: number;
118
+ feedbackTime: number;
119
+ startedAt: number | Date;
120
+ endedAt: number | Date;
121
+ pausedAt: number | Date;
122
+ timeRemaining: string;
123
+ totalStationTime: string;
124
+ stageTime: string;
125
+ stage: import("../../../models").EOsceStage;
126
+ marks: IOsceMarksheetMark[];
127
+ users: import("../../../models").IUser[];
128
+ activeUsers?: import("../../../models").IUser[] | undefined;
129
+ members: import("../../../models").IOsceMarksheetMember[];
130
+ state: EOsceMarksheetState;
131
+ productId: EProductType;
132
+ __typename: string;
133
+ };
134
+ };
135
+ };
92
136
  export declare const LEAVE_OSCE_MARKSHEET: import("@apollo/client").DocumentNode;
93
137
  export interface ILeaveOsceMarksheetVar {
94
138
  osceMarksheetId: Id;
@@ -1,6 +1,6 @@
1
1
  import { gql } from '@apollo/client';
2
2
  import { EProductType, } from '../../../models';
3
- import { OSCE_MARKSHEET_FIELDS, OSCE_MATCHMAKING_ACTION_FIELDS, } from '../../fragments/osce';
3
+ import { COMPLETED_OSCE_MARKSHEET_FRAGMENT, COMPLETED_OSCE_STATION_FRAGMENT, OSCE_MARKSHEET_FIELDS, OSCE_MATCHMAKING_ACTION_FIELDS, } from '../../fragments/osce';
4
4
  import { OSCE_STATION_FIELDS } from './../../fragments/osce';
5
5
  export const START_OSCE_MATCHMAKING = gql `
6
6
  mutation StartOsceMatchmaking($sessionId: String!) {
@@ -231,6 +231,52 @@ export const END_OSCE_MARKSHEET = gql `
231
231
  }
232
232
  }
233
233
  `;
234
+ export const updateCacheOnEndOsceMarksheet = (productType) => (cache, result, options) => {
235
+ const { endOsceMarksheet } = result?.data?.restricted || {};
236
+ const { variables } = options || {};
237
+ if (!variables || !endOsceMarksheet) {
238
+ return;
239
+ }
240
+ cache.writeFragment({
241
+ id: cache.identify({
242
+ id: endOsceMarksheet.id,
243
+ __typename: 'OsceMarksheet',
244
+ }),
245
+ data: {
246
+ completed: true,
247
+ score: endOsceMarksheet.score,
248
+ state: endOsceMarksheet.state,
249
+ globalScore: endOsceMarksheet.globalScore,
250
+ timeTaken: endOsceMarksheet.timeTaken,
251
+ endedAt: endOsceMarksheet.endedAt,
252
+ },
253
+ fragment: COMPLETED_OSCE_MARKSHEET_FRAGMENT,
254
+ });
255
+ cache.writeFragment({
256
+ id: cache.identify({
257
+ id: endOsceMarksheet.osceStationId,
258
+ __typename: 'OsceStation',
259
+ }),
260
+ data: {
261
+ completedMarks: endOsceMarksheet.marks.filter((m) => productType === EProductType.OSCE
262
+ ? m.mark !== null
263
+ : m.selectedChoice !== null).length,
264
+ score: endOsceMarksheet.score,
265
+ lastOsceMarksheetId: endOsceMarksheet.id,
266
+ },
267
+ fragment: COMPLETED_OSCE_STATION_FRAGMENT,
268
+ });
269
+ };
270
+ export const optimisticEndOsceMarksheet = (marksheet) => ({
271
+ restricted: {
272
+ __typename: 'RestrictedMutation',
273
+ endOsceMarksheet: {
274
+ __typename: 'OsceMarksheet',
275
+ ...marksheet,
276
+ completed: true,
277
+ },
278
+ },
279
+ });
234
280
  export const LEAVE_OSCE_MARKSHEET = gql `
235
281
  ${OSCE_MARKSHEET_FIELDS}
236
282
  mutation LeaveOsceMarksheet($osceMarksheetId: Int!) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "2.6.30",
3
+ "version": "2.6.32",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",