@quesmed/types 2.6.66 → 2.6.68
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/dist/cjs/models/Question.d.ts +3 -1
- package/dist/cjs/models/User.d.ts +12 -0
- package/dist/cjs/models/User.js +6 -1
- package/dist/cjs/resolvers/fragments/question.d.ts +1 -0
- package/dist/cjs/resolvers/fragments/question.js +9 -1
- package/dist/cjs/resolvers/mutation/restricted/chapter.d.ts +22 -0
- package/dist/cjs/resolvers/mutation/restricted/chapter.js +26 -1
- package/dist/cjs/resolvers/mutation/restricted/questionDiscussion.d.ts +36 -1
- package/dist/cjs/resolvers/mutation/restricted/questionDiscussion.js +66 -1
- package/dist/mjs/models/Question.d.ts +3 -1
- package/dist/mjs/models/User.d.ts +12 -0
- package/dist/mjs/models/User.js +5 -0
- package/dist/mjs/resolvers/fragments/question.d.ts +1 -0
- package/dist/mjs/resolvers/fragments/question.js +8 -0
- package/dist/mjs/resolvers/mutation/restricted/chapter.d.ts +22 -0
- package/dist/mjs/resolvers/mutation/restricted/chapter.js +24 -0
- package/dist/mjs/resolvers/mutation/restricted/questionDiscussion.d.ts +36 -1
- package/dist/mjs/resolvers/mutation/restricted/questionDiscussion.js +64 -1
- package/package.json +1 -1
|
@@ -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
|
+
}
|
package/dist/cjs/models/User.js
CHANGED
|
@@ -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
|
+
`;
|
|
@@ -29,3 +29,25 @@ export interface IAddChapterHighlightVar {
|
|
|
29
29
|
export type IAddChapterHighlightData = RestrictedData<(graphqlNormalize & IChapterHighlight)[], 'addChapterHighlight'>;
|
|
30
30
|
export declare const ADD_CHAPTER_HIGHLIGHT: import("@apollo/client").DocumentNode;
|
|
31
31
|
export declare const updateChapterHighlights: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddChapterHighlightData>, options: ApolloUpdateOptions<IAddChapterHighlightVar>) => void;
|
|
32
|
+
export declare const getChapterHighlightOptimisticResponse: (userId: number, highlights: IHighlightNode[], chapterId: number) => {
|
|
33
|
+
restricted: {
|
|
34
|
+
addChapterHighlight: {
|
|
35
|
+
chapterId: number;
|
|
36
|
+
id: number;
|
|
37
|
+
userId: number;
|
|
38
|
+
createdAt: number;
|
|
39
|
+
updatedAt: number;
|
|
40
|
+
deletedAt: number;
|
|
41
|
+
highlights: {
|
|
42
|
+
start: number;
|
|
43
|
+
end: number;
|
|
44
|
+
text: string;
|
|
45
|
+
color: string;
|
|
46
|
+
part?: string | undefined;
|
|
47
|
+
tag: string;
|
|
48
|
+
__typename: string;
|
|
49
|
+
}[];
|
|
50
|
+
__typename: string;
|
|
51
|
+
}[];
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateChapterHighlights = exports.ADD_CHAPTER_HIGHLIGHT = exports.optimisticUpsertChapterNote = exports.updateCacheOnUpsertChapterNote = exports.UPSERT_CHAPTER_NOTE = void 0;
|
|
3
|
+
exports.getChapterHighlightOptimisticResponse = exports.updateChapterHighlights = exports.ADD_CHAPTER_HIGHLIGHT = exports.optimisticUpsertChapterNote = exports.updateCacheOnUpsertChapterNote = exports.UPSERT_CHAPTER_NOTE = void 0;
|
|
4
4
|
const client_1 = require("@apollo/client");
|
|
5
5
|
const fragments_1 = require("../../fragments");
|
|
6
6
|
/**
|
|
@@ -96,3 +96,28 @@ const updateChapterHighlights = (cache, result, options) => {
|
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
98
|
exports.updateChapterHighlights = updateChapterHighlights;
|
|
99
|
+
const getChapterHighlightOptimisticResponse = (userId, highlights, chapterId) => {
|
|
100
|
+
const date = new Date().getTime();
|
|
101
|
+
return {
|
|
102
|
+
restricted: {
|
|
103
|
+
addChapterHighlight: [
|
|
104
|
+
{
|
|
105
|
+
chapterId,
|
|
106
|
+
id: date,
|
|
107
|
+
userId,
|
|
108
|
+
createdAt: date,
|
|
109
|
+
updatedAt: date,
|
|
110
|
+
deletedAt: date,
|
|
111
|
+
highlights: highlights.map((highlight) => ({
|
|
112
|
+
__typename: 'HighlightNode',
|
|
113
|
+
tag: '',
|
|
114
|
+
color: '',
|
|
115
|
+
...highlight,
|
|
116
|
+
})),
|
|
117
|
+
__typename: 'ChapterHighlight',
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
exports.getChapterHighlightOptimisticResponse = getChapterHighlightOptimisticResponse;
|
|
@@ -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,4 +62,39 @@ 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;
|
|
78
|
+
export declare const getQuestionHighlightOptimisticResponse: (userId: number, highlights: IHighlightNode[], questionId: number) => {
|
|
79
|
+
restricted: {
|
|
80
|
+
addQuestionHighlight: {
|
|
81
|
+
questionId: number;
|
|
82
|
+
id: number;
|
|
83
|
+
userId: number;
|
|
84
|
+
createdAt: number;
|
|
85
|
+
updatedAt: number;
|
|
86
|
+
deletedAt: number;
|
|
87
|
+
highlights: {
|
|
88
|
+
start: number;
|
|
89
|
+
end: number;
|
|
90
|
+
text: string;
|
|
91
|
+
color: string;
|
|
92
|
+
part?: string | undefined;
|
|
93
|
+
tag: string;
|
|
94
|
+
__typename: string;
|
|
95
|
+
}[];
|
|
96
|
+
__typename: string;
|
|
97
|
+
}[];
|
|
98
|
+
};
|
|
99
|
+
};
|
|
65
100
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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,3 +378,68 @@ 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;
|
|
421
|
+
const getQuestionHighlightOptimisticResponse = (userId, highlights, questionId) => {
|
|
422
|
+
const date = new Date().getTime();
|
|
423
|
+
return {
|
|
424
|
+
restricted: {
|
|
425
|
+
addQuestionHighlight: [
|
|
426
|
+
{
|
|
427
|
+
questionId,
|
|
428
|
+
id: date,
|
|
429
|
+
userId,
|
|
430
|
+
createdAt: date,
|
|
431
|
+
updatedAt: date,
|
|
432
|
+
deletedAt: date,
|
|
433
|
+
highlights: highlights.map((highlight) => ({
|
|
434
|
+
__typename: 'HighlightNode',
|
|
435
|
+
tag: '',
|
|
436
|
+
color: '',
|
|
437
|
+
...highlight,
|
|
438
|
+
})),
|
|
439
|
+
__typename: 'ChapterHighlight',
|
|
440
|
+
},
|
|
441
|
+
],
|
|
442
|
+
},
|
|
443
|
+
};
|
|
444
|
+
};
|
|
445
|
+
exports.getQuestionHighlightOptimisticResponse = getQuestionHighlightOptimisticResponse;
|
|
@@ -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
|
+
}
|
package/dist/mjs/models/User.js
CHANGED
|
@@ -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
|
+
`;
|
|
@@ -29,3 +29,25 @@ export interface IAddChapterHighlightVar {
|
|
|
29
29
|
export type IAddChapterHighlightData = RestrictedData<(graphqlNormalize & IChapterHighlight)[], 'addChapterHighlight'>;
|
|
30
30
|
export declare const ADD_CHAPTER_HIGHLIGHT: import("@apollo/client").DocumentNode;
|
|
31
31
|
export declare const updateChapterHighlights: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddChapterHighlightData>, options: ApolloUpdateOptions<IAddChapterHighlightVar>) => void;
|
|
32
|
+
export declare const getChapterHighlightOptimisticResponse: (userId: number, highlights: IHighlightNode[], chapterId: number) => {
|
|
33
|
+
restricted: {
|
|
34
|
+
addChapterHighlight: {
|
|
35
|
+
chapterId: number;
|
|
36
|
+
id: number;
|
|
37
|
+
userId: number;
|
|
38
|
+
createdAt: number;
|
|
39
|
+
updatedAt: number;
|
|
40
|
+
deletedAt: number;
|
|
41
|
+
highlights: {
|
|
42
|
+
start: number;
|
|
43
|
+
end: number;
|
|
44
|
+
text: string;
|
|
45
|
+
color: string;
|
|
46
|
+
part?: string | undefined;
|
|
47
|
+
tag: string;
|
|
48
|
+
__typename: string;
|
|
49
|
+
}[];
|
|
50
|
+
__typename: string;
|
|
51
|
+
}[];
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -90,3 +90,27 @@ export const updateChapterHighlights = (cache, result, options) => {
|
|
|
90
90
|
console.error(error);
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
|
+
export const getChapterHighlightOptimisticResponse = (userId, highlights, chapterId) => {
|
|
94
|
+
const date = new Date().getTime();
|
|
95
|
+
return {
|
|
96
|
+
restricted: {
|
|
97
|
+
addChapterHighlight: [
|
|
98
|
+
{
|
|
99
|
+
chapterId,
|
|
100
|
+
id: date,
|
|
101
|
+
userId,
|
|
102
|
+
createdAt: date,
|
|
103
|
+
updatedAt: date,
|
|
104
|
+
deletedAt: date,
|
|
105
|
+
highlights: highlights.map((highlight) => ({
|
|
106
|
+
__typename: 'HighlightNode',
|
|
107
|
+
tag: '',
|
|
108
|
+
color: '',
|
|
109
|
+
...highlight,
|
|
110
|
+
})),
|
|
111
|
+
__typename: 'ChapterHighlight',
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
};
|
|
@@ -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,4 +62,39 @@ 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;
|
|
78
|
+
export declare const getQuestionHighlightOptimisticResponse: (userId: number, highlights: IHighlightNode[], questionId: number) => {
|
|
79
|
+
restricted: {
|
|
80
|
+
addQuestionHighlight: {
|
|
81
|
+
questionId: number;
|
|
82
|
+
id: number;
|
|
83
|
+
userId: number;
|
|
84
|
+
createdAt: number;
|
|
85
|
+
updatedAt: number;
|
|
86
|
+
deletedAt: number;
|
|
87
|
+
highlights: {
|
|
88
|
+
start: number;
|
|
89
|
+
end: number;
|
|
90
|
+
text: string;
|
|
91
|
+
color: string;
|
|
92
|
+
part?: string | undefined;
|
|
93
|
+
tag: string;
|
|
94
|
+
__typename: string;
|
|
95
|
+
}[];
|
|
96
|
+
__typename: string;
|
|
97
|
+
}[];
|
|
98
|
+
};
|
|
99
|
+
};
|
|
65
100
|
export {};
|
|
@@ -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,3 +366,66 @@ 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
|
+
};
|
|
408
|
+
export const getQuestionHighlightOptimisticResponse = (userId, highlights, questionId) => {
|
|
409
|
+
const date = new Date().getTime();
|
|
410
|
+
return {
|
|
411
|
+
restricted: {
|
|
412
|
+
addQuestionHighlight: [
|
|
413
|
+
{
|
|
414
|
+
questionId,
|
|
415
|
+
id: date,
|
|
416
|
+
userId,
|
|
417
|
+
createdAt: date,
|
|
418
|
+
updatedAt: date,
|
|
419
|
+
deletedAt: date,
|
|
420
|
+
highlights: highlights.map((highlight) => ({
|
|
421
|
+
__typename: 'HighlightNode',
|
|
422
|
+
tag: '',
|
|
423
|
+
color: '',
|
|
424
|
+
...highlight,
|
|
425
|
+
})),
|
|
426
|
+
__typename: 'ChapterHighlight',
|
|
427
|
+
},
|
|
428
|
+
],
|
|
429
|
+
},
|
|
430
|
+
};
|
|
431
|
+
};
|