@quesmed/types-rn 2.6.74 → 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
|
@@ -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;
|