@quesmed/types 2.6.67 → 2.6.69

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.
@@ -7,7 +7,7 @@ import { IPresentation } from './Presentation';
7
7
  import { ITopic } from './Topic';
8
8
  import { Id } from './Type';
9
9
  import { IUkmlaTopic } from './UkmlaTopic';
10
- import { IUser } from './User';
10
+ import { EUserLearningPoint, IUser } from './User';
11
11
  export declare enum EPsaSectionType {
12
12
  PRESCRIBING = 1,
13
13
  PRESCRIPTION_REVIEW = 2,
@@ -77,6 +77,7 @@ export interface IQuestion {
77
77
  presentation?: IPresentation[];
78
78
  question: string;
79
79
  explanation?: string;
80
+ learningPoint?: string;
80
81
  answer: IQuestionAnswer;
81
82
  totalVotes: number;
82
83
  choices: IQuestionChoice[];
@@ -87,6 +88,7 @@ export interface IQuestion {
87
88
  difficulty: EDifficultyType;
88
89
  elo: number;
89
90
  psaSectionId: EPsaSectionType;
91
+ userPoint?: EUserLearningPoint | null;
90
92
  likes?: number;
91
93
  dislikes?: number;
92
94
  isLikedByMe?: EQuestionLike;
@@ -34,6 +34,10 @@ export declare enum EUserLearningStatus {
34
34
  REVISING = 3,
35
35
  URGENT = 4
36
36
  }
37
+ export declare enum EUserLearningPoint {
38
+ NOT_RELEVANT = 0,
39
+ RELEVANT = 1
40
+ }
37
41
  export declare const classYearGroup: {
38
42
  [key: string]: EClassYearGroup;
39
43
  };
@@ -248,3 +252,11 @@ export interface IUserStats {
248
252
  median: number;
249
253
  series: [x: number, y: number][];
250
254
  }
255
+ export interface IQuestionLearningPoint {
256
+ id: Id;
257
+ createdAt: number | Date;
258
+ updatedAt: number | Date;
259
+ userId: Id;
260
+ questionId: Id;
261
+ userPoint: EUserLearningPoint | null;
262
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.currentClassGroup = exports.currentClassYear = exports.EPracticeIntensity = exports.classYearGroup = exports.EUserLearningStatus = exports.EClassYearGroup = exports.dateProductMapping = exports.subscriptionDates = exports.classYears = exports.IAccessLevel = void 0;
3
+ exports.currentClassGroup = exports.currentClassYear = exports.EPracticeIntensity = exports.classYearGroup = exports.EUserLearningPoint = exports.EUserLearningStatus = exports.EClassYearGroup = exports.dateProductMapping = exports.subscriptionDates = exports.classYears = exports.IAccessLevel = void 0;
4
4
  const luxon_1 = require("luxon");
5
5
  const Product_1 = require("./Product");
6
6
  var IAccessLevel;
@@ -68,6 +68,11 @@ var EUserLearningStatus;
68
68
  EUserLearningStatus[EUserLearningStatus["REVISING"] = 3] = "REVISING";
69
69
  EUserLearningStatus[EUserLearningStatus["URGENT"] = 4] = "URGENT";
70
70
  })(EUserLearningStatus = exports.EUserLearningStatus || (exports.EUserLearningStatus = {}));
71
+ var EUserLearningPoint;
72
+ (function (EUserLearningPoint) {
73
+ EUserLearningPoint[EUserLearningPoint["NOT_RELEVANT"] = 0] = "NOT_RELEVANT";
74
+ EUserLearningPoint[EUserLearningPoint["RELEVANT"] = 1] = "RELEVANT";
75
+ })(EUserLearningPoint = exports.EUserLearningPoint || (exports.EUserLearningPoint = {}));
71
76
  exports.classYearGroup = {
72
77
  'Year 1': EClassYearGroup.PRECLINICAL,
73
78
  'Year 2': EClassYearGroup.PRECLINICAL,
@@ -3,3 +3,4 @@ export declare const QUESTION_CATEGORY_FIELDS: import("@apollo/client").Document
3
3
  export declare const QUESTION_FIELDS: import("@apollo/client").DocumentNode;
4
4
  export declare const QUESTION_WITH_HIGHLIGHT_FIELDS: import("@apollo/client").DocumentNode;
5
5
  export declare const QUESTION_WITH_COMMENT_FIELDS: import("@apollo/client").DocumentNode;
6
+ export declare const QUESTION_WITH_LEARNING_FIELDS: import("@apollo/client").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QUESTION_WITH_COMMENT_FIELDS = exports.QUESTION_WITH_HIGHLIGHT_FIELDS = exports.QUESTION_FIELDS = exports.QUESTION_CATEGORY_FIELDS = exports.QUESTION_COMMENT_FIELDS = void 0;
3
+ exports.QUESTION_WITH_LEARNING_FIELDS = exports.QUESTION_WITH_COMMENT_FIELDS = exports.QUESTION_WITH_HIGHLIGHT_FIELDS = exports.QUESTION_FIELDS = exports.QUESTION_CATEGORY_FIELDS = exports.QUESTION_COMMENT_FIELDS = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const concept_1 = require("./concept");
6
6
  const highlight_1 = require("./highlight");
@@ -110,7 +110,9 @@ exports.QUESTION_FIELDS = (0, client_1.gql) `
110
110
  difficulty
111
111
  dislikes
112
112
  explanation
113
+ learningPoint
113
114
  isLikedByMe
115
+ userPoint
114
116
  likes
115
117
  question
116
118
  totalVotes
@@ -170,3 +172,9 @@ exports.QUESTION_WITH_COMMENT_FIELDS = (0, client_1.gql) `
170
172
  }
171
173
  }
172
174
  `;
175
+ // used in cache updator
176
+ exports.QUESTION_WITH_LEARNING_FIELDS = (0, client_1.gql) `
177
+ fragment QuestionWithLearningFields on Question {
178
+ userPoint
179
+ }
180
+ `;
@@ -39,11 +39,11 @@ export declare const getChapterHighlightOptimisticResponse: (userId: number, hig
39
39
  updatedAt: number;
40
40
  deletedAt: number;
41
41
  highlights: {
42
+ part: string;
42
43
  start: number;
43
44
  end: number;
44
45
  text: string;
45
46
  color: string;
46
- part?: string | undefined;
47
47
  tag: string;
48
48
  __typename: string;
49
49
  }[];
@@ -7,9 +7,17 @@ const fragments_1 = require("../../fragments");
7
7
  * upsertChapterNote
8
8
  */
9
9
  exports.UPSERT_CHAPTER_NOTE = (0, client_1.gql) `
10
- mutation UpsertChapterNote($chapterId: Int!, $note: String!, $marksheetId: Int) {
10
+ mutation UpsertChapterNote(
11
+ $chapterId: Int!
12
+ $note: String!
13
+ $marksheetId: Int
14
+ ) {
11
15
  restricted {
12
- upsertChapterNote(chapterId: $chapterId, note: $note, marksheetId: $marksheetId) {
16
+ upsertChapterNote(
17
+ chapterId: $chapterId
18
+ note: $note
19
+ marksheetId: $marksheetId
20
+ ) {
13
21
  id
14
22
  chapterId
15
23
  userId
@@ -113,6 +121,7 @@ const getChapterHighlightOptimisticResponse = (userId, highlights, chapterId) =>
113
121
  tag: '',
114
122
  color: '',
115
123
  ...highlight,
124
+ part: highlight.part || '',
116
125
  })),
117
126
  __typename: 'ChapterHighlight',
118
127
  },
@@ -1,6 +1,6 @@
1
1
  import { ApolloCache } from '@apollo/client';
2
2
  import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../..';
3
- import { EQuestionLike, EQuestionType, IAccessLevel, IHighlightNode, IQuestion, IQuestionComment, IQuestionHighlight, Id } from '../../../models';
3
+ import { EQuestionLike, EQuestionType, EUserLearningPoint, IAccessLevel, IHighlightNode, IQuestion, IQuestionComment, IQuestionHighlight, IQuestionLearningPoint, Id } from '../../../models';
4
4
  import { RestrictedData, graphqlNormalize } from '../../types';
5
5
  interface LikeData {
6
6
  likes?: number;
@@ -62,6 +62,19 @@ export interface IAddQuestionHighlightVar {
62
62
  export type IAddQuestionHighlightData = RestrictedData<(graphqlNormalize & IQuestionHighlight)[], 'addQuestionHighlight'>;
63
63
  export declare const ADD_QUESTION_HIGHLIGHT: import("@apollo/client").DocumentNode;
64
64
  export declare const updateQuestionHighlights: (typeId: EQuestionType) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddQuestionHighlightData>, options: ApolloUpdateOptions<IAddQuestionHighlightVar>) => void;
65
+ /**
66
+ * addQuestionLearningPoint
67
+ */
68
+ export interface IAddQuestionLearningPointVar {
69
+ marksheetId?: number;
70
+ input: {
71
+ questionId: Id;
72
+ userPoint: EUserLearningPoint;
73
+ }[];
74
+ }
75
+ export type IAddQuestionLearningPointData = RestrictedData<(graphqlNormalize & IQuestionLearningPoint)[], 'addQuestionLearningPoint'>;
76
+ export declare const ADD_QUESTION_LEARNING_POINT: import("@apollo/client").DocumentNode;
77
+ export declare const updateQuestionLearningPoint: (typeId: EQuestionType) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddQuestionLearningPointData>, options: ApolloUpdateOptions<IAddQuestionLearningPointVar>) => void;
65
78
  export declare const getQuestionHighlightOptimisticResponse: (userId: number, highlights: IHighlightNode[], questionId: number) => {
66
79
  restricted: {
67
80
  addQuestionHighlight: {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getQuestionHighlightOptimisticResponse = exports.updateQuestionHighlights = exports.ADD_QUESTION_HIGHLIGHT = 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;
3
+ exports.getQuestionHighlightOptimisticResponse = exports.updateQuestionLearningPoint = exports.ADD_QUESTION_LEARNING_POINT = exports.updateQuestionHighlights = exports.ADD_QUESTION_HIGHLIGHT = 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
5
  const luxon_1 = require("luxon");
6
6
  const models_1 = require("../../../models");
@@ -378,6 +378,46 @@ const updateQuestionHighlights = (typeId) => (cache, result, options) => {
378
378
  }
379
379
  };
380
380
  exports.updateQuestionHighlights = updateQuestionHighlights;
381
+ exports.ADD_QUESTION_LEARNING_POINT = (0, client_1.gql) `
382
+ mutation AddQuestionLearningPoint(
383
+ $input: [AddQuestionLearningPointInput!]!
384
+ $marksheetId: Int
385
+ ) {
386
+ restricted {
387
+ addQuestionLearningPoint(input: $input, marksheetId: $marksheetId) {
388
+ id
389
+ questionId
390
+ userId
391
+ userPoint
392
+ }
393
+ }
394
+ }
395
+ `;
396
+ const updateQuestionLearningPoint = (typeId) => (cache, result, options) => {
397
+ const { addQuestionLearningPoint } = result?.data?.restricted ?? {};
398
+ const { variables } = options || {};
399
+ if (!variables || !addQuestionLearningPoint) {
400
+ return;
401
+ }
402
+ try {
403
+ for (const { id, userPoint } of addQuestionLearningPoint) {
404
+ cache.writeFragment({
405
+ id: cache.identify({
406
+ id,
407
+ __typename: (0, exports.getQuestionTypeName)(typeId),
408
+ }),
409
+ data: {
410
+ userPoint,
411
+ },
412
+ fragment: fragments_1.QUESTION_WITH_LEARNING_FIELDS,
413
+ });
414
+ }
415
+ }
416
+ catch (error) {
417
+ console.error(error);
418
+ }
419
+ };
420
+ exports.updateQuestionLearningPoint = updateQuestionLearningPoint;
381
421
  const getQuestionHighlightOptimisticResponse = (userId, highlights, questionId) => {
382
422
  const date = new Date().getTime();
383
423
  return {
@@ -1,5 +1,5 @@
1
1
  import { ApolloCache } from '@apollo/client';
2
- import { IVideo, Id } from '../../../models';
2
+ import { EEntitlementType, IVideo, Id } from '../../../models';
3
3
  import { ApolloUpdateResultRestricted } from '../../apollo';
4
4
  import { RestrictedData, graphqlNormalize } from '../../types';
5
5
  export declare const VIDEO_WATCHED: import("@apollo/client").DocumentNode;
@@ -7,4 +7,4 @@ export interface IVideoWatchedVar {
7
7
  id: Id;
8
8
  }
9
9
  export type IVideoWatchedData = RestrictedData<graphqlNormalize & IVideo, 'videoWatched'>;
10
- export declare const updateCacheOnVideoWatched: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IVideoWatchedData>) => void;
10
+ export declare const updateCacheOnVideoWatched: (entitlementId?: EEntitlementType | null) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IVideoWatchedData>) => void;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateCacheOnVideoWatched = exports.VIDEO_WATCHED = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const fragments_1 = require("../../fragments");
6
+ const osce_1 = require("../../query/restricted/osce");
6
7
  exports.VIDEO_WATCHED = (0, client_1.gql) `
7
8
  mutation VideoWatched($id: Int!) {
8
9
  restricted {
@@ -14,7 +15,7 @@ exports.VIDEO_WATCHED = (0, client_1.gql) `
14
15
  }
15
16
  }
16
17
  `;
17
- const updateCacheOnVideoWatched = (cache, result) => {
18
+ const updateCacheOnVideoWatched = (entitlementId) => (cache, result) => {
18
19
  const { videoWatched } = result?.data?.restricted || {};
19
20
  if (!videoWatched) {
20
21
  return;
@@ -27,5 +28,34 @@ const updateCacheOnVideoWatched = (cache, result) => {
27
28
  },
28
29
  fragment: fragments_1.VIDEO_USER_VIEWED_FRAGMENT,
29
30
  });
31
+ if (entitlementId) {
32
+ const prevOsceStats = cache?.readQuery({
33
+ query: osce_1.OSCE_STATS,
34
+ variables: { solo: true },
35
+ });
36
+ if (prevOsceStats) {
37
+ const { completed, types } = prevOsceStats.restricted.osceStats;
38
+ cache.writeQuery({
39
+ query: osce_1.OSCE_STATS,
40
+ data: {
41
+ ...prevOsceStats,
42
+ restricted: {
43
+ ...prevOsceStats.restricted,
44
+ osceStats: {
45
+ ...prevOsceStats.restricted.osceStats,
46
+ completed: Number(completed) + 1,
47
+ types: types?.map(({ id, completed, ...rest }) => ({
48
+ id,
49
+ completed: Number(id) === Number(entitlementId)
50
+ ? Number(completed) + 1
51
+ : completed,
52
+ ...rest,
53
+ })),
54
+ },
55
+ },
56
+ },
57
+ });
58
+ }
59
+ }
30
60
  };
31
61
  exports.updateCacheOnVideoWatched = updateCacheOnVideoWatched;
@@ -7,7 +7,7 @@ import { IPresentation } from './Presentation';
7
7
  import { ITopic } from './Topic';
8
8
  import { Id } from './Type';
9
9
  import { IUkmlaTopic } from './UkmlaTopic';
10
- import { IUser } from './User';
10
+ import { EUserLearningPoint, IUser } from './User';
11
11
  export declare enum EPsaSectionType {
12
12
  PRESCRIBING = 1,
13
13
  PRESCRIPTION_REVIEW = 2,
@@ -77,6 +77,7 @@ export interface IQuestion {
77
77
  presentation?: IPresentation[];
78
78
  question: string;
79
79
  explanation?: string;
80
+ learningPoint?: string;
80
81
  answer: IQuestionAnswer;
81
82
  totalVotes: number;
82
83
  choices: IQuestionChoice[];
@@ -87,6 +88,7 @@ export interface IQuestion {
87
88
  difficulty: EDifficultyType;
88
89
  elo: number;
89
90
  psaSectionId: EPsaSectionType;
91
+ userPoint?: EUserLearningPoint | null;
90
92
  likes?: number;
91
93
  dislikes?: number;
92
94
  isLikedByMe?: EQuestionLike;
@@ -34,6 +34,10 @@ export declare enum EUserLearningStatus {
34
34
  REVISING = 3,
35
35
  URGENT = 4
36
36
  }
37
+ export declare enum EUserLearningPoint {
38
+ NOT_RELEVANT = 0,
39
+ RELEVANT = 1
40
+ }
37
41
  export declare const classYearGroup: {
38
42
  [key: string]: EClassYearGroup;
39
43
  };
@@ -248,3 +252,11 @@ export interface IUserStats {
248
252
  median: number;
249
253
  series: [x: number, y: number][];
250
254
  }
255
+ export interface IQuestionLearningPoint {
256
+ id: Id;
257
+ createdAt: number | Date;
258
+ updatedAt: number | Date;
259
+ userId: Id;
260
+ questionId: Id;
261
+ userPoint: EUserLearningPoint | null;
262
+ }
@@ -65,6 +65,11 @@ export var EUserLearningStatus;
65
65
  EUserLearningStatus[EUserLearningStatus["REVISING"] = 3] = "REVISING";
66
66
  EUserLearningStatus[EUserLearningStatus["URGENT"] = 4] = "URGENT";
67
67
  })(EUserLearningStatus || (EUserLearningStatus = {}));
68
+ export var EUserLearningPoint;
69
+ (function (EUserLearningPoint) {
70
+ EUserLearningPoint[EUserLearningPoint["NOT_RELEVANT"] = 0] = "NOT_RELEVANT";
71
+ EUserLearningPoint[EUserLearningPoint["RELEVANT"] = 1] = "RELEVANT";
72
+ })(EUserLearningPoint || (EUserLearningPoint = {}));
68
73
  export const classYearGroup = {
69
74
  'Year 1': EClassYearGroup.PRECLINICAL,
70
75
  'Year 2': EClassYearGroup.PRECLINICAL,
@@ -3,3 +3,4 @@ export declare const QUESTION_CATEGORY_FIELDS: import("@apollo/client").Document
3
3
  export declare const QUESTION_FIELDS: import("@apollo/client").DocumentNode;
4
4
  export declare const QUESTION_WITH_HIGHLIGHT_FIELDS: import("@apollo/client").DocumentNode;
5
5
  export declare const QUESTION_WITH_COMMENT_FIELDS: import("@apollo/client").DocumentNode;
6
+ export declare const QUESTION_WITH_LEARNING_FIELDS: import("@apollo/client").DocumentNode;
@@ -107,7 +107,9 @@ export const QUESTION_FIELDS = gql `
107
107
  difficulty
108
108
  dislikes
109
109
  explanation
110
+ learningPoint
110
111
  isLikedByMe
112
+ userPoint
111
113
  likes
112
114
  question
113
115
  totalVotes
@@ -167,3 +169,9 @@ export const QUESTION_WITH_COMMENT_FIELDS = gql `
167
169
  }
168
170
  }
169
171
  `;
172
+ // used in cache updator
173
+ export const QUESTION_WITH_LEARNING_FIELDS = gql `
174
+ fragment QuestionWithLearningFields on Question {
175
+ userPoint
176
+ }
177
+ `;
@@ -39,11 +39,11 @@ export declare const getChapterHighlightOptimisticResponse: (userId: number, hig
39
39
  updatedAt: number;
40
40
  deletedAt: number;
41
41
  highlights: {
42
+ part: string;
42
43
  start: number;
43
44
  end: number;
44
45
  text: string;
45
46
  color: string;
46
- part?: string | undefined;
47
47
  tag: string;
48
48
  __typename: string;
49
49
  }[];
@@ -4,9 +4,17 @@ import { CHAPTER_WITH_HIGHLIGHT_FIELDS, HIGHLIGHT_FIELDS, UPSERT_CHAPTER_NOTE_FR
4
4
  * upsertChapterNote
5
5
  */
6
6
  export const UPSERT_CHAPTER_NOTE = gql `
7
- mutation UpsertChapterNote($chapterId: Int!, $note: String!, $marksheetId: Int) {
7
+ mutation UpsertChapterNote(
8
+ $chapterId: Int!
9
+ $note: String!
10
+ $marksheetId: Int
11
+ ) {
8
12
  restricted {
9
- upsertChapterNote(chapterId: $chapterId, note: $note, marksheetId: $marksheetId) {
13
+ upsertChapterNote(
14
+ chapterId: $chapterId
15
+ note: $note
16
+ marksheetId: $marksheetId
17
+ ) {
10
18
  id
11
19
  chapterId
12
20
  userId
@@ -107,6 +115,7 @@ export const getChapterHighlightOptimisticResponse = (userId, highlights, chapte
107
115
  tag: '',
108
116
  color: '',
109
117
  ...highlight,
118
+ part: highlight.part || '',
110
119
  })),
111
120
  __typename: 'ChapterHighlight',
112
121
  },
@@ -1,6 +1,6 @@
1
1
  import { ApolloCache } from '@apollo/client';
2
2
  import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../..';
3
- import { EQuestionLike, EQuestionType, IAccessLevel, IHighlightNode, IQuestion, IQuestionComment, IQuestionHighlight, Id } from '../../../models';
3
+ import { EQuestionLike, EQuestionType, EUserLearningPoint, IAccessLevel, IHighlightNode, IQuestion, IQuestionComment, IQuestionHighlight, IQuestionLearningPoint, Id } from '../../../models';
4
4
  import { RestrictedData, graphqlNormalize } from '../../types';
5
5
  interface LikeData {
6
6
  likes?: number;
@@ -62,6 +62,19 @@ export interface IAddQuestionHighlightVar {
62
62
  export type IAddQuestionHighlightData = RestrictedData<(graphqlNormalize & IQuestionHighlight)[], 'addQuestionHighlight'>;
63
63
  export declare const ADD_QUESTION_HIGHLIGHT: import("@apollo/client").DocumentNode;
64
64
  export declare const updateQuestionHighlights: (typeId: EQuestionType) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddQuestionHighlightData>, options: ApolloUpdateOptions<IAddQuestionHighlightVar>) => void;
65
+ /**
66
+ * addQuestionLearningPoint
67
+ */
68
+ export interface IAddQuestionLearningPointVar {
69
+ marksheetId?: number;
70
+ input: {
71
+ questionId: Id;
72
+ userPoint: EUserLearningPoint;
73
+ }[];
74
+ }
75
+ export type IAddQuestionLearningPointData = RestrictedData<(graphqlNormalize & IQuestionLearningPoint)[], 'addQuestionLearningPoint'>;
76
+ export declare const ADD_QUESTION_LEARNING_POINT: import("@apollo/client").DocumentNode;
77
+ export declare const updateQuestionLearningPoint: (typeId: EQuestionType) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddQuestionLearningPointData>, options: ApolloUpdateOptions<IAddQuestionLearningPointVar>) => void;
65
78
  export declare const getQuestionHighlightOptimisticResponse: (userId: number, highlights: IHighlightNode[], questionId: number) => {
66
79
  restricted: {
67
80
  addQuestionHighlight: {
@@ -1,7 +1,7 @@
1
1
  import { gql } from '@apollo/client';
2
2
  import { DateTime } from 'luxon';
3
3
  import { EQuestionLike, EQuestionType, } from '../../../models';
4
- import { HIGHLIGHT_FIELDS, QUESTION_COMMENT_FIELDS, QUESTION_WITH_COMMENT_FIELDS, QUESTION_WITH_HIGHLIGHT_FIELDS, } from '../../fragments';
4
+ import { HIGHLIGHT_FIELDS, QUESTION_COMMENT_FIELDS, QUESTION_WITH_COMMENT_FIELDS, QUESTION_WITH_HIGHLIGHT_FIELDS, QUESTION_WITH_LEARNING_FIELDS, } from '../../fragments';
5
5
  export const getLikeData = (like, item) => {
6
6
  let { likes = 0, dislikes = 0, isLikedByMe } = item;
7
7
  if (isLikedByMe === EQuestionLike.LIKE) {
@@ -366,6 +366,45 @@ export const updateQuestionHighlights = (typeId) => (cache, result, options) =>
366
366
  console.error(error);
367
367
  }
368
368
  };
369
+ export const ADD_QUESTION_LEARNING_POINT = gql `
370
+ mutation AddQuestionLearningPoint(
371
+ $input: [AddQuestionLearningPointInput!]!
372
+ $marksheetId: Int
373
+ ) {
374
+ restricted {
375
+ addQuestionLearningPoint(input: $input, marksheetId: $marksheetId) {
376
+ id
377
+ questionId
378
+ userId
379
+ userPoint
380
+ }
381
+ }
382
+ }
383
+ `;
384
+ export const updateQuestionLearningPoint = (typeId) => (cache, result, options) => {
385
+ const { addQuestionLearningPoint } = result?.data?.restricted ?? {};
386
+ const { variables } = options || {};
387
+ if (!variables || !addQuestionLearningPoint) {
388
+ return;
389
+ }
390
+ try {
391
+ for (const { id, userPoint } of addQuestionLearningPoint) {
392
+ cache.writeFragment({
393
+ id: cache.identify({
394
+ id,
395
+ __typename: getQuestionTypeName(typeId),
396
+ }),
397
+ data: {
398
+ userPoint,
399
+ },
400
+ fragment: QUESTION_WITH_LEARNING_FIELDS,
401
+ });
402
+ }
403
+ }
404
+ catch (error) {
405
+ console.error(error);
406
+ }
407
+ };
369
408
  export const getQuestionHighlightOptimisticResponse = (userId, highlights, questionId) => {
370
409
  const date = new Date().getTime();
371
410
  return {
@@ -1,5 +1,5 @@
1
1
  import { ApolloCache } from '@apollo/client';
2
- import { IVideo, Id } from '../../../models';
2
+ import { EEntitlementType, IVideo, Id } from '../../../models';
3
3
  import { ApolloUpdateResultRestricted } from '../../apollo';
4
4
  import { RestrictedData, graphqlNormalize } from '../../types';
5
5
  export declare const VIDEO_WATCHED: import("@apollo/client").DocumentNode;
@@ -7,4 +7,4 @@ export interface IVideoWatchedVar {
7
7
  id: Id;
8
8
  }
9
9
  export type IVideoWatchedData = RestrictedData<graphqlNormalize & IVideo, 'videoWatched'>;
10
- export declare const updateCacheOnVideoWatched: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IVideoWatchedData>) => void;
10
+ export declare const updateCacheOnVideoWatched: (entitlementId?: EEntitlementType | null) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IVideoWatchedData>) => void;
@@ -1,5 +1,6 @@
1
1
  import { gql } from '@apollo/client';
2
2
  import { VIDEO_USER_VIEWED_FRAGMENT } from '../../fragments';
3
+ import { OSCE_STATS, } from '../../query/restricted/osce';
3
4
  export const VIDEO_WATCHED = gql `
4
5
  mutation VideoWatched($id: Int!) {
5
6
  restricted {
@@ -11,7 +12,7 @@ export const VIDEO_WATCHED = gql `
11
12
  }
12
13
  }
13
14
  `;
14
- export const updateCacheOnVideoWatched = (cache, result) => {
15
+ export const updateCacheOnVideoWatched = (entitlementId) => (cache, result) => {
15
16
  const { videoWatched } = result?.data?.restricted || {};
16
17
  if (!videoWatched) {
17
18
  return;
@@ -24,4 +25,33 @@ export const updateCacheOnVideoWatched = (cache, result) => {
24
25
  },
25
26
  fragment: VIDEO_USER_VIEWED_FRAGMENT,
26
27
  });
28
+ if (entitlementId) {
29
+ const prevOsceStats = cache?.readQuery({
30
+ query: OSCE_STATS,
31
+ variables: { solo: true },
32
+ });
33
+ if (prevOsceStats) {
34
+ const { completed, types } = prevOsceStats.restricted.osceStats;
35
+ cache.writeQuery({
36
+ query: OSCE_STATS,
37
+ data: {
38
+ ...prevOsceStats,
39
+ restricted: {
40
+ ...prevOsceStats.restricted,
41
+ osceStats: {
42
+ ...prevOsceStats.restricted.osceStats,
43
+ completed: Number(completed) + 1,
44
+ types: types?.map(({ id, completed, ...rest }) => ({
45
+ id,
46
+ completed: Number(id) === Number(entitlementId)
47
+ ? Number(completed) + 1
48
+ : completed,
49
+ ...rest,
50
+ })),
51
+ },
52
+ },
53
+ },
54
+ });
55
+ }
56
+ }
27
57
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "2.6.67",
3
+ "version": "2.6.69",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",