@quesmed/types-rn 2.1.7 → 2.1.10

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.1.7",
3
+ "version": "2.1.10",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",
@@ -1,5 +1,6 @@
1
1
  export * as admin from './admin';
2
2
  export * as restricted from './restricted';
3
+ export * from './sample';
3
4
  export * from './stripe';
4
5
  export * from './users';
5
6
  export * as validUserToken from './validUserToken';
@@ -25,6 +25,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.validUserToken = exports.restricted = exports.admin = void 0;
26
26
  exports.admin = __importStar(require("./admin"));
27
27
  exports.restricted = __importStar(require("./restricted"));
28
+ __exportStar(require("./sample"), exports);
28
29
  __exportStar(require("./stripe"), exports);
29
30
  __exportStar(require("./users"), exports);
30
31
  exports.validUserToken = __importStar(require("./validUserToken"));
@@ -1,3 +1,5 @@
1
+ import { ApolloCache, ApolloClient } from '@apollo/client';
2
+ import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../..';
1
3
  import { Id } from '../../../models';
2
4
  import { graphqlNormalize, RestrictedData } from '../../types';
3
5
  import { IMarksheet } from './../../../models/Marksheet';
@@ -29,6 +31,8 @@ export interface IMarksheetInput {
29
31
  timeTaken: number;
30
32
  }
31
33
  export declare const SAVE_MARKSHEET: import("@apollo/client").DocumentNode;
34
+ export declare const updateMarksheets: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<ISaveMarksheetsData>, options: ApolloUpdateOptions) => void;
35
+ export declare const optimisticSaveMarkseehts: (client: ApolloClient<any>, marksheetInput: IMarksheetInput, questionIndex: number) => ISaveMarksheetsData;
32
36
  export interface ISaveMarksheetsVar {
33
37
  marksheetInput: IMarksheetInput[];
34
38
  }
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.REMOVE_FLAGGED_QUESTION = exports.ADD_FLAGGED_QUESTION = exports.SAVE_MARKSHEET = exports.RE_BUILD_MARKSHEET = exports.BUILD_MARKSHEET = void 0;
3
+ exports.REMOVE_FLAGGED_QUESTION = exports.ADD_FLAGGED_QUESTION = exports.optimisticSaveMarkseehts = exports.updateMarksheets = exports.SAVE_MARKSHEET = exports.RE_BUILD_MARKSHEET = exports.BUILD_MARKSHEET = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const marksheet_1 = require("../../fragments/marksheet");
6
+ const restricted_1 = require("../../query/restricted");
6
7
  exports.BUILD_MARKSHEET = (0, client_1.gql) `
7
8
  mutation BuildMarksheet($buildMarksheet: BuildMarksheetInput) {
8
9
  restricted {
@@ -49,14 +50,6 @@ exports.SAVE_MARKSHEET = (0, client_1.gql) `
49
50
  createdAt
50
51
  startedAt
51
52
  endedAt
52
- topicIds
53
- topicNames
54
- source
55
- userId
56
- user {
57
- displayName
58
- id
59
- }
60
53
  marks {
61
54
  id
62
55
  marksheetId
@@ -65,15 +58,81 @@ exports.SAVE_MARKSHEET = (0, client_1.gql) `
65
58
  flagged
66
59
  mark
67
60
  }
68
- mockTestId
69
61
  correct
70
62
  incorrect
71
- totalQuestions
72
- isTestMarksheet
73
63
  }
74
64
  }
75
65
  }
76
66
  `;
67
+ const updateMarksheets = (cache, result, options) => {
68
+ const { saveMarksheets } = result?.data?.restricted || {};
69
+ const { variables } = options || {};
70
+ if (!options || !variables || !saveMarksheets) {
71
+ return;
72
+ }
73
+ try {
74
+ for (let i = 0; i < saveMarksheets.length; i++) {
75
+ const { marksheetInput } = variables;
76
+ const marksheet = marksheetInput[i];
77
+ cache.writeFragment({
78
+ id: cache.identify({
79
+ id: saveMarksheets[i],
80
+ __typename: 'MarksheetMark',
81
+ }),
82
+ data: {
83
+ timeTaken: marksheet.timeTaken || 0,
84
+ mark: marksheet.mark,
85
+ questionChoiceId: marksheet.choiceId,
86
+ },
87
+ fragment: (0, client_1.gql) `
88
+ fragment NewTodoMark on MarksheetMark {
89
+ timeTaken
90
+ questionChoiceId
91
+ mark
92
+ }
93
+ `,
94
+ });
95
+ }
96
+ }
97
+ catch (error) {
98
+ console.error(error);
99
+ }
100
+ };
101
+ exports.updateMarksheets = updateMarksheets;
102
+ const optimisticSaveMarkseehts = (client, marksheetInput, questionIndex) => {
103
+ const { timeTaken, choiceId, mark, marksheetId } = marksheetInput;
104
+ const data = client.readQuery({
105
+ variables: { id: marksheetId },
106
+ query: restricted_1.MARKSHEET,
107
+ });
108
+ const { marksheet } = data?.restricted || {};
109
+ if (marksheet) {
110
+ const { marks = [], ...rest } = marksheet || {};
111
+ const updatedMark = {
112
+ ...marks[questionIndex],
113
+ marksheetId,
114
+ timeTaken,
115
+ questionChoiceId: choiceId || null,
116
+ mark: mark || null,
117
+ };
118
+ const udatedMarks = [
119
+ ...marks.slice(0, questionIndex),
120
+ updatedMark,
121
+ ...marks.slice(questionIndex + 1),
122
+ ];
123
+ return {
124
+ restricted: {
125
+ saveMarksheets: [{ ...rest, marks: udatedMarks }],
126
+ },
127
+ };
128
+ }
129
+ return {
130
+ restricted: {
131
+ saveMarksheets: [],
132
+ },
133
+ };
134
+ };
135
+ exports.optimisticSaveMarkseehts = optimisticSaveMarkseehts;
77
136
  exports.ADD_FLAGGED_QUESTION = (0, client_1.gql) `
78
137
  mutation AddFlaggedQuestion($markId: Int!, $questionId: Int!) {
79
138
  restricted {
@@ -1,12 +1,27 @@
1
- import { EQuestionLike, Id, IQuestion, IQuestionComment } from '../../../models';
1
+ import { ApolloCache, ApolloClient } from '@apollo/client';
2
+ import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../..';
3
+ import { EQuestionLike, EQuestionType, Id, IQuestion, IQuestionComment } from '../../../models';
2
4
  import { graphqlNormalize, RestrictedData } from '../../types';
5
+ interface LikeData {
6
+ likes?: number;
7
+ dislikes?: number;
8
+ isLikedByMe?: EQuestionLike;
9
+ }
10
+ export declare const getLikeData: (like: EQuestionLike, item: LikeData) => LikeData;
11
+ export declare const getQuestionTypeName: (typeId: EQuestionType) => string;
3
12
  export declare const QUESTION_LIKE: import("@apollo/client").DocumentNode;
13
+ export declare const optimisticQuestionLike: (marksheetId: number, client: ApolloClient<any>, input: IQuestionLikeVar) => IQuestionLikeData;
4
14
  export interface IQuestionLikeVar {
5
15
  questionId: Id;
6
16
  like: EQuestionLike;
7
17
  }
8
18
  export declare type IQuestionLikeData = RestrictedData<graphqlNormalize & IQuestion, 'questionLike'>;
9
19
  export declare const QUESTION_COMMENTS: import("@apollo/client").DocumentNode;
20
+ export declare const updateQuestionComments: (marksheetId: number) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IQuestionCommentsData>, options: ApolloUpdateOptions) => void;
21
+ export declare const optimisticQuestionComment: (id: number, user: {
22
+ id: number;
23
+ displayName: string;
24
+ }, input: IQuestionCommentsVar) => IQuestionCommentsData;
10
25
  export interface IQuestionCommentsVar {
11
26
  questionId: Id;
12
27
  parentId?: Id;
@@ -14,13 +29,17 @@ export interface IQuestionCommentsVar {
14
29
  }
15
30
  export declare type IQuestionCommentsData = RestrictedData<graphqlNormalize & IQuestionComment, 'questionComments'>;
16
31
  export declare const QUESTION_COMMENT_LIKE: import("@apollo/client").DocumentNode;
32
+ export declare const optimisticCommentLike: (comments: IQuestionComment[], input: IQuestionCommentsLikeVar) => IQuestionCommentsLikeData;
17
33
  export interface IQuestionCommentsLikeVar {
18
34
  commentId: Id;
19
35
  like: EQuestionLike;
20
36
  }
21
37
  export declare type IQuestionCommentsLikeData = RestrictedData<graphqlNormalize & IQuestionComment, 'questionCommentLike'>;
22
38
  export declare const QUESTION_COMMENT_REMOVE: import("@apollo/client").DocumentNode;
39
+ export declare const updateQuestionCommentsRemove: (marksheetId: number) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IQuestionCommentRemoveData>, options: ApolloUpdateOptions) => void;
40
+ export declare const optimisticQuestionCommentRemove: (comments: IQuestionComment[], input: IQuestionCommentRemoveVar, parentId?: number | undefined) => IQuestionCommentRemoveData;
23
41
  export interface IQuestionCommentRemoveVar {
24
42
  commentId: Id;
25
43
  }
26
44
  export declare type IQuestionCommentRemoveData = RestrictedData<graphqlNormalize & IQuestionComment, 'questionCommentRemove'>;
45
+ export {};
@@ -1,45 +1,86 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QUESTION_COMMENT_REMOVE = exports.QUESTION_COMMENT_LIKE = exports.QUESTION_COMMENTS = exports.QUESTION_LIKE = void 0;
3
+ exports.optimisticQuestionCommentRemove = exports.updateQuestionCommentsRemove = exports.QUESTION_COMMENT_REMOVE = exports.optimisticCommentLike = exports.QUESTION_COMMENT_LIKE = exports.optimisticQuestionComment = exports.updateQuestionComments = exports.QUESTION_COMMENTS = exports.optimisticQuestionLike = exports.QUESTION_LIKE = exports.getQuestionTypeName = exports.getLikeData = void 0;
4
4
  const client_1 = require("@apollo/client");
5
+ const models_1 = require("../../../models");
6
+ const restricted_1 = require("../../query/restricted");
7
+ const getLikeData = (like, item) => {
8
+ let { likes = 0, dislikes = 0, isLikedByMe } = item;
9
+ if (isLikedByMe === models_1.EQuestionLike.LIKE) {
10
+ likes = likes - 1;
11
+ if (like === models_1.EQuestionLike.DISLIKE) {
12
+ dislikes = dislikes + 1;
13
+ }
14
+ }
15
+ else if (isLikedByMe === models_1.EQuestionLike.DISLIKE) {
16
+ dislikes = dislikes - 1;
17
+ if (like === models_1.EQuestionLike.LIKE) {
18
+ likes = likes + 1;
19
+ }
20
+ }
21
+ else {
22
+ if (like === models_1.EQuestionLike.LIKE) {
23
+ likes = likes + 1;
24
+ }
25
+ else if (like === models_1.EQuestionLike.DISLIKE) {
26
+ dislikes = dislikes + 1;
27
+ }
28
+ }
29
+ return { likes, dislikes, isLikedByMe: like };
30
+ };
31
+ exports.getLikeData = getLikeData;
32
+ const getQuestionTypeName = (typeId) => {
33
+ switch (typeId) {
34
+ case models_1.EQuestionType.QUESTION_ANSWER:
35
+ return 'QuestionQA';
36
+ case models_1.EQuestionType.PRESCRIPTION_ANSWER:
37
+ return 'QuestionPrescription';
38
+ case models_1.EQuestionType.MULTIPLE_ANSWERS:
39
+ return 'QuestionMultiA';
40
+ case models_1.EQuestionType.SINGLE_BEST_ANSWER:
41
+ default:
42
+ return 'QuestionSBA';
43
+ }
44
+ };
45
+ exports.getQuestionTypeName = getQuestionTypeName;
5
46
  exports.QUESTION_LIKE = (0, client_1.gql) `
6
47
  mutation QuestionLike($questionId: Int!, $like: Int!) {
7
48
  restricted {
8
49
  questionLike(questionId: $questionId, like: $like) {
9
50
  id
10
51
  likes
52
+ typeId
11
53
  dislikes
12
54
  isLikedByMe
13
- comments {
14
- id
15
- createdAt
16
- comment
17
- likes
18
- user {
19
- id
20
- displayName
21
- }
22
- dislikes
23
- isLikedByMe
24
- questionId
25
- replies {
26
- id
27
- createdAt
28
- comment
29
- user {
30
- id
31
- displayName
32
- }
33
- likes
34
- dislikes
35
- isLikedByMe
36
- questionId
37
- }
38
- }
39
55
  }
40
56
  }
41
57
  }
42
58
  `;
59
+ const optimisticQuestionLike = (marksheetId, client, input) => {
60
+ const { questionId, like } = input;
61
+ const data = client.readQuery({
62
+ variables: { id: marksheetId },
63
+ query: restricted_1.MARKSHEET,
64
+ });
65
+ const { marksheet } = data?.restricted || {};
66
+ const { marks = [] } = marksheet || {};
67
+ const { question } = marks.find(({ question }) => Number(question.id) === Number(questionId)) ||
68
+ {};
69
+ if (question) {
70
+ const { typeId } = question;
71
+ return {
72
+ restricted: {
73
+ questionLike: {
74
+ ...question,
75
+ __typename: (0, exports.getQuestionTypeName)(typeId),
76
+ ...(0, exports.getLikeData)(like, question),
77
+ },
78
+ },
79
+ };
80
+ }
81
+ return {};
82
+ };
83
+ exports.optimisticQuestionLike = optimisticQuestionLike;
43
84
  exports.QUESTION_COMMENTS = (0, client_1.gql) `
44
85
  mutation QuestionComments(
45
86
  $questionId: Int!
@@ -55,11 +96,12 @@ exports.QUESTION_COMMENTS = (0, client_1.gql) `
55
96
  id
56
97
  createdAt
57
98
  comment
58
- likes
99
+ parentId
59
100
  user {
60
101
  id
61
102
  displayName
62
103
  }
104
+ likes
63
105
  dislikes
64
106
  isLikedByMe
65
107
  questionId
@@ -67,6 +109,7 @@ exports.QUESTION_COMMENTS = (0, client_1.gql) `
67
109
  id
68
110
  createdAt
69
111
  comment
112
+ parentId
70
113
  user {
71
114
  id
72
115
  displayName
@@ -80,6 +123,90 @@ exports.QUESTION_COMMENTS = (0, client_1.gql) `
80
123
  }
81
124
  }
82
125
  `;
126
+ const updateQuestionComments = (marksheetId) => (cache, result, options) => {
127
+ const { questionComments } = result?.data?.restricted || {};
128
+ const { variables } = options || {};
129
+ if (!variables || !questionComments) {
130
+ return;
131
+ }
132
+ const { questionId, parentId } = variables;
133
+ try {
134
+ const prevData = cache.readQuery({
135
+ variables: { id: marksheetId },
136
+ query: restricted_1.MARKSHEET,
137
+ });
138
+ if (prevData) {
139
+ const { marksheet } = prevData.restricted || {};
140
+ const { marks, ...marksheetRest } = marksheet;
141
+ const index = marks.findIndex(({ question }) => Number(question.id) === Number(questionId));
142
+ const { question, ...markRest } = marks[index];
143
+ const { comments = [], ...questionRest } = question;
144
+ let newComments;
145
+ if (parentId) {
146
+ const commentIndex = comments.findIndex(({ id }) => Number(id) === parentId);
147
+ const { replies = [], ...commentRest } = comments[commentIndex];
148
+ newComments = [
149
+ ...comments.slice(0, commentIndex),
150
+ { ...commentRest, replies: [...replies, questionComments] },
151
+ ...comments.slice(commentIndex + 1),
152
+ ];
153
+ }
154
+ else {
155
+ newComments = [...comments, questionComments];
156
+ }
157
+ cache.writeQuery({
158
+ query: restricted_1.MARKSHEET,
159
+ variables: { id: marksheetId },
160
+ data: {
161
+ ...prevData,
162
+ restricted: {
163
+ ...prevData.restricted,
164
+ marksheet: {
165
+ ...marksheetRest,
166
+ marks: [
167
+ ...marks.slice(0, index),
168
+ {
169
+ ...markRest,
170
+ question: { ...questionRest, comments: newComments },
171
+ },
172
+ ...marks.slice(index + 1),
173
+ ],
174
+ },
175
+ },
176
+ },
177
+ });
178
+ }
179
+ }
180
+ catch (error) {
181
+ console.error(error);
182
+ }
183
+ };
184
+ exports.updateQuestionComments = updateQuestionComments;
185
+ const optimisticQuestionComment = (id, user, input) => {
186
+ const { parentId, questionId, comment } = input;
187
+ const { displayName, id: userId } = user || {};
188
+ const newComment = {
189
+ createdAt: new Date(),
190
+ id,
191
+ likes: 0,
192
+ questionId,
193
+ dislikes: 0,
194
+ isLikedByMe: models_1.EQuestionLike.NONE,
195
+ user: { displayName, id: userId },
196
+ comment,
197
+ parentId: parentId ? parentId : 0,
198
+ replies: [],
199
+ };
200
+ return {
201
+ restricted: {
202
+ questionComments: {
203
+ __typename: 'QuestionComments',
204
+ ...newComment,
205
+ },
206
+ },
207
+ };
208
+ };
209
+ exports.optimisticQuestionComment = optimisticQuestionComment;
83
210
  exports.QUESTION_COMMENT_LIKE = (0, client_1.gql) `
84
211
  mutation QuestionCommentLike($commentId: Int!, $like: Int!) {
85
212
  restricted {
@@ -87,11 +214,12 @@ exports.QUESTION_COMMENT_LIKE = (0, client_1.gql) `
87
214
  id
88
215
  createdAt
89
216
  comment
90
- likes
217
+ parentId
91
218
  user {
92
219
  id
93
220
  displayName
94
221
  }
222
+ likes
95
223
  dislikes
96
224
  isLikedByMe
97
225
  questionId
@@ -99,6 +227,7 @@ exports.QUESTION_COMMENT_LIKE = (0, client_1.gql) `
99
227
  id
100
228
  createdAt
101
229
  comment
230
+ parentId
102
231
  user {
103
232
  id
104
233
  displayName
@@ -112,6 +241,22 @@ exports.QUESTION_COMMENT_LIKE = (0, client_1.gql) `
112
241
  }
113
242
  }
114
243
  `;
244
+ const optimisticCommentLike = (comments, input) => {
245
+ const { commentId, like } = input;
246
+ const comment = comments.find(({ id }) => Number(id) === Number(commentId)) ||
247
+ {};
248
+ return {
249
+ restricted: {
250
+ questionCommentLike: {
251
+ ...comment,
252
+ parentId: comment.parentId ? comment.parentId : 0,
253
+ __typename: 'QuestionComment',
254
+ ...(0, exports.getLikeData)(like, comment),
255
+ },
256
+ },
257
+ };
258
+ };
259
+ exports.optimisticCommentLike = optimisticCommentLike;
115
260
  exports.QUESTION_COMMENT_REMOVE = (0, client_1.gql) `
116
261
  mutation QuestionCommentRemove($commentId: Int!) {
117
262
  restricted {
@@ -119,11 +264,12 @@ exports.QUESTION_COMMENT_REMOVE = (0, client_1.gql) `
119
264
  id
120
265
  createdAt
121
266
  comment
122
- likes
267
+ parentId
123
268
  user {
124
269
  id
125
270
  displayName
126
271
  }
272
+ likes
127
273
  dislikes
128
274
  isLikedByMe
129
275
  questionId
@@ -131,6 +277,7 @@ exports.QUESTION_COMMENT_REMOVE = (0, client_1.gql) `
131
277
  id
132
278
  createdAt
133
279
  comment
280
+ parentId
134
281
  user {
135
282
  id
136
283
  displayName
@@ -144,3 +291,92 @@ exports.QUESTION_COMMENT_REMOVE = (0, client_1.gql) `
144
291
  }
145
292
  }
146
293
  `;
294
+ const updateQuestionCommentsRemove = (marksheetId) => (cache, result, options) => {
295
+ const { questionCommentRemove } = result?.data?.restricted || {};
296
+ const { variables } = options || {};
297
+ if (!variables || !questionCommentRemove) {
298
+ return;
299
+ }
300
+ const { questionId, id: commentId, parentId } = questionCommentRemove;
301
+ try {
302
+ const prevData = cache.readQuery({
303
+ variables: { id: marksheetId },
304
+ query: restricted_1.MARKSHEET,
305
+ });
306
+ if (prevData) {
307
+ const { marksheet } = prevData.restricted || {};
308
+ const { marks, ...marksheetRest } = marksheet;
309
+ const index = marks.findIndex(({ question }) => Number(question.id) === Number(questionId));
310
+ const { question, ...markRest } = marks[index];
311
+ const { comments = [], ...questionRest } = question;
312
+ let newComments;
313
+ if (parentId) {
314
+ const commentIndex = comments.findIndex(({ id }) => Number(id) === Number(parentId));
315
+ const { replies = [], ...commentRest } = comments[commentIndex];
316
+ newComments = [
317
+ ...comments.slice(0, commentIndex),
318
+ {
319
+ ...commentRest,
320
+ replies: replies.filter(({ id }) => Number(id) !== Number(commentId)),
321
+ },
322
+ ...comments.slice(commentIndex + 1),
323
+ ];
324
+ }
325
+ else {
326
+ newComments = comments.filter(({ id }) => Number(id) !== Number(commentId));
327
+ }
328
+ cache.writeQuery({
329
+ query: restricted_1.MARKSHEET,
330
+ variables: { id: marksheetId },
331
+ data: {
332
+ ...prevData,
333
+ restricted: {
334
+ ...prevData.restricted,
335
+ marksheet: {
336
+ ...marksheetRest,
337
+ marks: [
338
+ ...marks.slice(0, index),
339
+ {
340
+ ...markRest,
341
+ question: { ...questionRest, comments: newComments },
342
+ },
343
+ ...marks.slice(index + 1),
344
+ ],
345
+ },
346
+ },
347
+ },
348
+ });
349
+ }
350
+ }
351
+ catch (error) {
352
+ console.error(error);
353
+ }
354
+ };
355
+ exports.updateQuestionCommentsRemove = updateQuestionCommentsRemove;
356
+ const optimisticQuestionCommentRemove = (comments, input, parentId) => {
357
+ const { commentId } = input;
358
+ let comment;
359
+ if (parentId) {
360
+ const parent = comments.find(({ id }) => Number(id) === Number(parentId)) ||
361
+ {};
362
+ comment =
363
+ parent?.replies?.find(({ id }) => Number(id) === Number(commentId)) ||
364
+ {};
365
+ }
366
+ else {
367
+ comment =
368
+ comments.find(({ id }) => Number(id) === Number(commentId)) ||
369
+ {};
370
+ }
371
+ return {
372
+ restricted: {
373
+ questionCommentRemove: {
374
+ __typename: 'QuestionComments',
375
+ ...comment,
376
+ parentId: parentId ? parentId : 0,
377
+ replies: comment.replies ? comment.replies : [],
378
+ },
379
+ },
380
+ };
381
+ };
382
+ exports.optimisticQuestionCommentRemove = optimisticQuestionCommentRemove;
@@ -0,0 +1,3 @@
1
+ import { ApolloClient } from '@apollo/client';
2
+ import { IMarksheetInput } from './restricted';
3
+ export declare const saveSampleMarkseehts: (client: ApolloClient<any>, marksheetInput: IMarksheetInput, questionIndex: number) => void;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.saveSampleMarkseehts = void 0;
4
+ const query_1 = require("../query");
5
+ const saveSampleMarkseehts = (client, marksheetInput, questionIndex) => {
6
+ const { timeTaken, choiceId, mark, marksheetId } = marksheetInput;
7
+ const prevData = client.readQuery({
8
+ variables: { marksheetId },
9
+ query: query_1.SAMPLE_MARKSHEET,
10
+ });
11
+ if (prevData) {
12
+ const { sampleMarksheet } = prevData;
13
+ const { marks = [], ...rest } = sampleMarksheet || {};
14
+ client.writeQuery({
15
+ query: query_1.SAMPLE_MARKSHEET,
16
+ variables: { marksheetId },
17
+ data: {
18
+ ...prevData,
19
+ sampleMarksheet: {
20
+ ...rest,
21
+ marks: [
22
+ ...marks.slice(0, questionIndex),
23
+ {
24
+ ...marks[questionIndex],
25
+ timeTaken,
26
+ questionChoiceId: choiceId || null,
27
+ mark: mark || null,
28
+ },
29
+ ...marks.slice(questionIndex + 1),
30
+ ],
31
+ },
32
+ },
33
+ });
34
+ }
35
+ };
36
+ exports.saveSampleMarkseehts = saveSampleMarkseehts;
@@ -8,14 +8,18 @@ exports.MARKSHEET = (0, client_1.gql) `
8
8
  marksheet(id: $id) {
9
9
  id
10
10
  createdAt
11
+ startedAt
11
12
  endedAt
12
13
  isTestMarksheet
13
14
  source
15
+ correct
16
+ incorrect
14
17
  marks {
15
18
  id
16
19
  flagged
17
20
  index
18
21
  questionChoiceId
22
+ marksheetId
19
23
  timeTaken
20
24
  mark
21
25
  question {