@quesmed/types-rn 2.6.73 → 2.6.75
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
package/resolvers/constants.d.ts
CHANGED
|
@@ -5,3 +5,7 @@ export declare const productMapping: Partial<Record<EProductType, {
|
|
|
5
5
|
topicType: ETopicType[];
|
|
6
6
|
mockType: EMockTestType[];
|
|
7
7
|
}>>;
|
|
8
|
+
export declare const getEntitlementFromTopicType: (topicType: ETopicType, productType: EProductType) => {
|
|
9
|
+
id: number;
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
package/resolvers/constants.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.productMapping = void 0;
|
|
3
|
+
exports.getEntitlementFromTopicType = exports.productMapping = void 0;
|
|
4
4
|
const models_1 = require("../models");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
5
6
|
const enums_1 = require("./enums");
|
|
6
7
|
const ALL_TOPIC_TYPE_WITHOUT_ANATOMY = [
|
|
7
8
|
models_1.ETopicType.CLINICAL,
|
|
@@ -40,7 +41,7 @@ exports.productMapping = {
|
|
|
40
41
|
},
|
|
41
42
|
[models_1.EProductType.MEDICAL_SCIENCES]: {
|
|
42
43
|
db: enums_1.DB_TYPE.FINALS,
|
|
43
|
-
topicType: [models_1.ETopicType.PRE_CLINICAL],
|
|
44
|
+
topicType: [models_1.ETopicType.PRE_CLINICAL, models_1.ETopicType.CLINICAL],
|
|
44
45
|
mockType: [models_1.EMockTestType.UNIVERSITY_SPECIFIC],
|
|
45
46
|
},
|
|
46
47
|
[models_1.EProductType.ANATOMY_BUNDLE]: {
|
|
@@ -102,3 +103,32 @@ exports.productMapping = {
|
|
|
102
103
|
mockType: ALL_MOCKS,
|
|
103
104
|
},
|
|
104
105
|
};
|
|
106
|
+
const topicEntitlementMap = {
|
|
107
|
+
[models_1.ETopicType.PRE_CLINICAL]: models_1.EEntitlementType.PRE_CLINICAL,
|
|
108
|
+
[models_1.ETopicType.CLINICAL]: models_1.EEntitlementType.CLINICAL,
|
|
109
|
+
[models_1.ETopicType.ANATOMY]: models_1.EEntitlementType.ANATOMY,
|
|
110
|
+
[models_1.ETopicType.DATA_INTERPRETATION]: models_1.EEntitlementType.DATA_INTERPRETATION,
|
|
111
|
+
[models_1.ETopicType.SJT]: models_1.EEntitlementType.PROFESSIONAL_DILEMMA,
|
|
112
|
+
[models_1.ETopicType.INTERVIEW_ANAESTHETICS]: models_1.EEntitlementType.INTERVIEW_ANAESTHETICS,
|
|
113
|
+
[models_1.ETopicType.INTERVIEW_CST]: models_1.EEntitlementType.INTERVIEW_CST,
|
|
114
|
+
[models_1.ETopicType.INTERVIEW_IMT]: models_1.EEntitlementType.INTERVIEW_IMT,
|
|
115
|
+
[models_1.ETopicType.INTERVIEW_RADIOLOGY]: models_1.EEntitlementType.INTERVIEW_RADIOLOGY,
|
|
116
|
+
};
|
|
117
|
+
const clinicalEntitlementMap = {
|
|
118
|
+
[models_1.EProductType.MEDICAL_SCIENCES]: models_1.EEntitlementType.CLINICAL_SUBSET,
|
|
119
|
+
[models_1.EProductType.QBANK]: models_1.EEntitlementType.CLINICAL,
|
|
120
|
+
[models_1.EProductType.MSRA]: models_1.EEntitlementType.CLINICAL_PROBLEM_SOLVING,
|
|
121
|
+
[models_1.EProductType.PLAB1]: models_1.EEntitlementType.PLAB_1,
|
|
122
|
+
[models_1.EProductType.MRCP_PART1]: models_1.EEntitlementType.MRCP_PART_1,
|
|
123
|
+
[models_1.EProductType.MRCP_PART2]: models_1.EEntitlementType.MRCP_PART_2,
|
|
124
|
+
};
|
|
125
|
+
const getEntitlementFromTopicType = (topicType, productType) => {
|
|
126
|
+
const entitlement = topicType === models_1.ETopicType.CLINICAL
|
|
127
|
+
? clinicalEntitlementMap[productType]
|
|
128
|
+
: topicEntitlementMap[topicType];
|
|
129
|
+
if (!entitlement) {
|
|
130
|
+
return { id: 0, name: 'Unknown' };
|
|
131
|
+
}
|
|
132
|
+
return { id: entitlement, name: (0, utils_1.titleCase)(models_1.EEntitlementType[entitlement]) };
|
|
133
|
+
};
|
|
134
|
+
exports.getEntitlementFromTopicType = getEntitlementFromTopicType;
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import { ApolloClient } from '@apollo/client';
|
|
2
|
-
import {
|
|
2
|
+
import { EQuestionType, IHighlightNode } from '../../models';
|
|
3
|
+
import { IEndOsceMarksheetVar, IMarkOsceMarksheetMarkVar, ISaveMarksheetInput, ITodoInput } from './restricted';
|
|
3
4
|
export declare const saveSampleMarksheets: (client: ApolloClient<any>, marksheetInput: ISaveMarksheetInput, questionIndex: number) => void;
|
|
4
5
|
export declare const saveSampleTodoMark: (client: ApolloClient<any>, todoInput: ITodoInput, markId: number) => void;
|
|
6
|
+
export interface ChangeSampleQuestionParams {
|
|
7
|
+
newMarkId?: number;
|
|
8
|
+
timeTaken?: number;
|
|
9
|
+
markId: number;
|
|
10
|
+
index: number;
|
|
11
|
+
marksheetId: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const changeSampleQuestion: (client: ApolloClient<any>, { newMarkId, timeTaken, markId, index, marksheetId, }: ChangeSampleQuestionParams) => void;
|
|
14
|
+
export declare const MARK_OSCE_MARK_FRAGMENT: import("@apollo/client").DocumentNode;
|
|
15
|
+
export declare const checkSampleOsceMark: (client: ApolloClient<any>, isPaces: boolean, payload?: IMarkOsceMarksheetMarkVar) => void;
|
|
16
|
+
export declare const endSampleMarksheet: (client: ApolloClient<any>, marksheetId: number) => void;
|
|
17
|
+
export declare const endSampleStation: (client: ApolloClient<any>, payload?: IEndOsceMarksheetVar) => void;
|
|
18
|
+
export declare const handleSampleChapterHighlights: (client: ApolloClient<any>, highlights: IHighlightNode[], chapterId: number) => void;
|
|
19
|
+
export declare const handleSampleQuestionHighlights: (client: ApolloClient<any>, highlights: IHighlightNode[], questionId: number, questionTypeId: EQuestionType) => void;
|
|
20
|
+
export declare const startSampleStationTimer: (client: ApolloClient<any>, osceMarkhseetId?: number) => void;
|
|
21
|
+
export declare const strikeSampleChoice: (client: ApolloClient<any>, id: number, striked: number[]) => void;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.saveSampleTodoMark = exports.saveSampleMarksheets = void 0;
|
|
3
|
+
exports.strikeSampleChoice = exports.startSampleStationTimer = exports.handleSampleQuestionHighlights = exports.handleSampleChapterHighlights = exports.endSampleStation = exports.endSampleMarksheet = exports.checkSampleOsceMark = exports.MARK_OSCE_MARK_FRAGMENT = exports.changeSampleQuestion = exports.saveSampleTodoMark = exports.saveSampleMarksheets = void 0;
|
|
4
4
|
const client_1 = require("@apollo/client");
|
|
5
|
+
const fragments_1 = require("../fragments");
|
|
6
|
+
const marksheet_1 = require("../fragments/marksheet");
|
|
5
7
|
const query_1 = require("../query");
|
|
8
|
+
const marksheet_2 = require("../query/restricted/marksheet");
|
|
9
|
+
const restricted_1 = require("./restricted");
|
|
6
10
|
const saveSampleMarksheets = (client, marksheetInput, questionIndex) => {
|
|
7
11
|
const { timeTaken, choiceId, mark, marksheetId } = marksheetInput;
|
|
8
12
|
const prevData = client.readQuery({
|
|
@@ -53,3 +57,192 @@ const saveSampleTodoMark = (client, todoInput, markId) => {
|
|
|
53
57
|
});
|
|
54
58
|
};
|
|
55
59
|
exports.saveSampleTodoMark = saveSampleTodoMark;
|
|
60
|
+
const changeSampleQuestion = (client, { newMarkId, timeTaken, markId, index, marksheetId, }) => {
|
|
61
|
+
client.writeFragment({
|
|
62
|
+
id: `MarksheetMark:${markId}`,
|
|
63
|
+
data: { index, timeTaken },
|
|
64
|
+
fragment: marksheet_1.MODIFY_CURRENT_MARKSHEET_MARK_FRAGMENT,
|
|
65
|
+
});
|
|
66
|
+
const prevData = client.readQuery({
|
|
67
|
+
variables: { id: marksheetId },
|
|
68
|
+
query: marksheet_2.MARKSHEET,
|
|
69
|
+
});
|
|
70
|
+
if (prevData) {
|
|
71
|
+
client.writeQuery({
|
|
72
|
+
query: marksheet_2.MARKSHEET,
|
|
73
|
+
variables: { id: marksheetId },
|
|
74
|
+
data: {
|
|
75
|
+
...prevData,
|
|
76
|
+
restricted: {
|
|
77
|
+
...prevData.restricted,
|
|
78
|
+
marksheet: {
|
|
79
|
+
...prevData.restricted.marksheet,
|
|
80
|
+
currentMarkId: newMarkId,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
exports.changeSampleQuestion = changeSampleQuestion;
|
|
88
|
+
exports.MARK_OSCE_MARK_FRAGMENT = (0, client_1.gql) `
|
|
89
|
+
fragment CurrentOsceMarksheetMark on OsceMarksheetMark {
|
|
90
|
+
mark
|
|
91
|
+
selectedChoice
|
|
92
|
+
}
|
|
93
|
+
`;
|
|
94
|
+
const checkSampleOsceMark = (client, isPaces, payload) => {
|
|
95
|
+
const { osceMarksheetMarkId, mark } = payload || {};
|
|
96
|
+
const data = {};
|
|
97
|
+
if (isPaces) {
|
|
98
|
+
data.selectedChoice = mark;
|
|
99
|
+
data.mark = null;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
data.mark = mark;
|
|
103
|
+
data.selectedChoice = null;
|
|
104
|
+
}
|
|
105
|
+
client.writeFragment({
|
|
106
|
+
id: `OsceMarksheetMark:${osceMarksheetMarkId}`,
|
|
107
|
+
data,
|
|
108
|
+
fragment: exports.MARK_OSCE_MARK_FRAGMENT,
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
exports.checkSampleOsceMark = checkSampleOsceMark;
|
|
112
|
+
const endSampleMarksheet = (client, marksheetId) => {
|
|
113
|
+
const prevData = client.readQuery({
|
|
114
|
+
variables: { marksheetId: Number(marksheetId) },
|
|
115
|
+
query: query_1.SAMPLE_MARKSHEET,
|
|
116
|
+
});
|
|
117
|
+
if (prevData) {
|
|
118
|
+
const { sampleMarksheet } = prevData;
|
|
119
|
+
const { startedAt = 0 } = sampleMarksheet || {};
|
|
120
|
+
const endedAt = Math.round(Date.now() / 1000);
|
|
121
|
+
client.writeQuery({
|
|
122
|
+
query: query_1.SAMPLE_MARKSHEET,
|
|
123
|
+
variables: { marksheetId: Number(marksheetId) },
|
|
124
|
+
data: {
|
|
125
|
+
...prevData,
|
|
126
|
+
sampleMarksheet: {
|
|
127
|
+
...sampleMarksheet,
|
|
128
|
+
completed: true,
|
|
129
|
+
endedAt,
|
|
130
|
+
timeTaken: endedAt - Number(startedAt),
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
exports.endSampleMarksheet = endSampleMarksheet;
|
|
137
|
+
const endSampleStation = (client, payload) => {
|
|
138
|
+
const { osceMarksheetId, ...rest } = payload || {};
|
|
139
|
+
if (osceMarksheetId) {
|
|
140
|
+
const prevData = client.readQuery({
|
|
141
|
+
variables: { osceMarksheetId: Number(osceMarksheetId) },
|
|
142
|
+
query: query_1.SAMPLE_OSCE_MARKSHEET,
|
|
143
|
+
});
|
|
144
|
+
if (prevData) {
|
|
145
|
+
client.writeQuery({
|
|
146
|
+
query: query_1.SAMPLE_OSCE_MARKSHEET,
|
|
147
|
+
variables: { osceMarksheetId: Number(osceMarksheetId) },
|
|
148
|
+
data: {
|
|
149
|
+
...prevData,
|
|
150
|
+
sampleOsceMarksheet: {
|
|
151
|
+
...prevData.sampleOsceMarksheet,
|
|
152
|
+
...rest,
|
|
153
|
+
completed: true,
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
exports.endSampleStation = endSampleStation;
|
|
161
|
+
const handleSampleChapterHighlights = (client, highlights, chapterId) => {
|
|
162
|
+
try {
|
|
163
|
+
client.cache.writeFragment({
|
|
164
|
+
id: client.cache.identify({
|
|
165
|
+
id: chapterId,
|
|
166
|
+
__typename: 'Chapter',
|
|
167
|
+
}),
|
|
168
|
+
data: {
|
|
169
|
+
highlights: highlights.map((highlight) => ({
|
|
170
|
+
__typename: 'HighlightNode',
|
|
171
|
+
tag: '',
|
|
172
|
+
color: '',
|
|
173
|
+
...highlight,
|
|
174
|
+
part: highlight.part || '',
|
|
175
|
+
})),
|
|
176
|
+
},
|
|
177
|
+
fragment: fragments_1.CHAPTER_WITH_HIGHLIGHT_FIELDS,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
console.error(error);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
exports.handleSampleChapterHighlights = handleSampleChapterHighlights;
|
|
185
|
+
const handleSampleQuestionHighlights = (client, highlights, questionId, questionTypeId) => {
|
|
186
|
+
try {
|
|
187
|
+
client.cache.writeFragment({
|
|
188
|
+
id: client.cache.identify({
|
|
189
|
+
id: questionId,
|
|
190
|
+
__typename: (0, restricted_1.getQuestionTypeName)(questionTypeId),
|
|
191
|
+
}),
|
|
192
|
+
data: {
|
|
193
|
+
highlights: highlights.map((highlight) => ({
|
|
194
|
+
__typename: 'HighlightNode',
|
|
195
|
+
tag: '',
|
|
196
|
+
color: '',
|
|
197
|
+
...highlight,
|
|
198
|
+
part: highlight.part || '',
|
|
199
|
+
})),
|
|
200
|
+
},
|
|
201
|
+
fragment: fragments_1.QUESTION_WITH_HIGHLIGHT_FIELDS,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
console.error(error);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
exports.handleSampleQuestionHighlights = handleSampleQuestionHighlights;
|
|
209
|
+
const DEFAULT_STATION_TIME_IN_SECONDS = 930;
|
|
210
|
+
const startSampleStationTimer = (client, osceMarkhseetId) => {
|
|
211
|
+
if (osceMarkhseetId) {
|
|
212
|
+
const prevData = client.readQuery({
|
|
213
|
+
variables: { osceMarksheetId: Number(osceMarkhseetId) },
|
|
214
|
+
query: query_1.SAMPLE_OSCE_MARKSHEET,
|
|
215
|
+
});
|
|
216
|
+
const startedAt = Math.floor(Date.now() / 1000);
|
|
217
|
+
if (prevData) {
|
|
218
|
+
client.writeQuery({
|
|
219
|
+
query: query_1.SAMPLE_OSCE_MARKSHEET,
|
|
220
|
+
variables: { osceMarkhseetId: Number(osceMarkhseetId) },
|
|
221
|
+
data: {
|
|
222
|
+
...prevData,
|
|
223
|
+
sampleOsceMarksheet: {
|
|
224
|
+
...prevData.sampleOsceMarksheet,
|
|
225
|
+
startedAt: startedAt,
|
|
226
|
+
endedAt: startedAt + DEFAULT_STATION_TIME_IN_SECONDS,
|
|
227
|
+
stage: 0,
|
|
228
|
+
state: 3,
|
|
229
|
+
timeRemaining: '15:30',
|
|
230
|
+
totalStationTime: '15:30',
|
|
231
|
+
stationTime: 10,
|
|
232
|
+
readingTime: 30,
|
|
233
|
+
feedbackTime: 5,
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
exports.startSampleStationTimer = startSampleStationTimer;
|
|
241
|
+
const strikeSampleChoice = (client, id, striked) => {
|
|
242
|
+
client.cache.writeFragment({
|
|
243
|
+
id: client.cache.identify({ id, __typename: 'MarksheetMark' }),
|
|
244
|
+
data: { striked },
|
|
245
|
+
fragment: marksheet_1.MODIFY_MARKSHEET_MARK_STRIKED_FRAGMENT,
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
exports.strikeSampleChoice = strikeSampleChoice;
|
package/utils/wordsToNumber.d.ts
CHANGED
package/utils/wordsToNumber.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wordsToNumber = void 0;
|
|
3
|
+
exports.titleCase = exports.wordsToNumber = void 0;
|
|
4
4
|
const Small = {
|
|
5
5
|
zero: 0,
|
|
6
6
|
one: 1,
|
|
@@ -49,3 +49,12 @@ function wordsToNumber(s, checkForDigits = false) {
|
|
|
49
49
|
return total;
|
|
50
50
|
}
|
|
51
51
|
exports.wordsToNumber = wordsToNumber;
|
|
52
|
+
function titleCase(input) {
|
|
53
|
+
return input
|
|
54
|
+
.split(' ')
|
|
55
|
+
.map((word) => {
|
|
56
|
+
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
57
|
+
})
|
|
58
|
+
.join(' ');
|
|
59
|
+
}
|
|
60
|
+
exports.titleCase = titleCase;
|