@quesmed/types-rn 2.6.234 → 2.6.235
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/models/Blog.d.ts
CHANGED
package/models/Blog.js
CHANGED
package/models/Question.d.ts
CHANGED
|
@@ -204,7 +204,7 @@ export interface IQuestionRanking extends IQuestion {
|
|
|
204
204
|
}
|
|
205
205
|
export interface IQuestionSjtTwoAnswer extends IQuestion {
|
|
206
206
|
answer: [string, string];
|
|
207
|
-
|
|
207
|
+
sbaAnswer: [string, string];
|
|
208
208
|
}
|
|
209
209
|
export interface IQuestionPrescribe extends IQuestion {
|
|
210
210
|
answer: IPrescribeAnswer[];
|
package/package.json
CHANGED
|
@@ -81,10 +81,39 @@ exports.SAVE_MARKSHEET = (0, client_1.gql) `
|
|
|
81
81
|
flagged
|
|
82
82
|
mark
|
|
83
83
|
}
|
|
84
|
+
sections {
|
|
85
|
+
entitlementId
|
|
86
|
+
marks {
|
|
87
|
+
isAnswered
|
|
88
|
+
isInDailyStack
|
|
89
|
+
result
|
|
90
|
+
score
|
|
91
|
+
id
|
|
92
|
+
marksheetId
|
|
93
|
+
questionChoiceId
|
|
94
|
+
timeTaken
|
|
95
|
+
flagged
|
|
96
|
+
mark
|
|
97
|
+
}
|
|
98
|
+
}
|
|
84
99
|
}
|
|
85
100
|
}
|
|
86
101
|
}
|
|
87
102
|
`;
|
|
103
|
+
function getMarksFromMarksheet(marksheets, marksheetId) {
|
|
104
|
+
const marksheet = marksheets.find((m) => Number(m.id) === Number(marksheetId));
|
|
105
|
+
if (!marksheet)
|
|
106
|
+
return [];
|
|
107
|
+
// Case 1: direct marks
|
|
108
|
+
if (Array.isArray(marksheet.marks) && marksheet.marks.length > 0) {
|
|
109
|
+
return marksheet.marks;
|
|
110
|
+
}
|
|
111
|
+
// Case 2: nested sections → flatten marks
|
|
112
|
+
if (Array.isArray(marksheet.sections)) {
|
|
113
|
+
return marksheet.sections.flatMap((section) => section.marks || []);
|
|
114
|
+
}
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
88
117
|
const updateMarksheets = (cache, result, options) => {
|
|
89
118
|
const { saveMarksheets } = result?.data?.restricted || {};
|
|
90
119
|
const { variables } = options || {};
|
|
@@ -95,7 +124,7 @@ const updateMarksheets = (cache, result, options) => {
|
|
|
95
124
|
const { input } = variables;
|
|
96
125
|
for (let i = 0; i < input.length; i++) {
|
|
97
126
|
const inputData = input[i];
|
|
98
|
-
const savedMarks = saveMarksheets
|
|
127
|
+
const savedMarks = getMarksFromMarksheet(saveMarksheets, inputData.marksheetId);
|
|
99
128
|
const savedData = savedMarks?.find((m) => m.id === inputData.markId);
|
|
100
129
|
cache.writeFragment({
|
|
101
130
|
id: cache.identify({
|
|
@@ -121,43 +150,68 @@ const updateMarksheets = (cache, result, options) => {
|
|
|
121
150
|
exports.updateMarksheets = updateMarksheets;
|
|
122
151
|
const optimisticSaveMarksheets = (marksheet, marksheetInput, questionIndex) => {
|
|
123
152
|
const { timeTaken, choiceId, mark, marksheetId, markId } = marksheetInput;
|
|
124
|
-
const { marks = [], ...rest } = marksheet || {};
|
|
125
|
-
const
|
|
126
|
-
|
|
153
|
+
const { marks = [], sections = [], ...rest } = marksheet || {};
|
|
154
|
+
const updateMarksArray = (marksArr) => {
|
|
155
|
+
const currentMark = marksArr.find((m) => Number(m.id) === Number(markId));
|
|
156
|
+
if (!currentMark)
|
|
157
|
+
return marksArr;
|
|
158
|
+
const { psaSectionId, choices, typeId } = currentMark.question;
|
|
159
|
+
const { answerField } = (0, utils_1.getQuestionInfo)(typeId, psaSectionId);
|
|
160
|
+
const answer = currentMark.question[answerField];
|
|
161
|
+
const { result, score } = (0, utils_1.evaluateMark)({
|
|
162
|
+
mark: mark || '',
|
|
163
|
+
answer,
|
|
164
|
+
psaSectionId,
|
|
165
|
+
questionTypeId: typeId,
|
|
166
|
+
choices,
|
|
167
|
+
});
|
|
168
|
+
const updatedMark = {
|
|
169
|
+
...marksArr[questionIndex],
|
|
170
|
+
marksheetId,
|
|
171
|
+
timeTaken,
|
|
172
|
+
questionChoiceId: choiceId ?? null,
|
|
173
|
+
isAnswered: true,
|
|
174
|
+
mark: mark || null,
|
|
175
|
+
result,
|
|
176
|
+
score,
|
|
177
|
+
};
|
|
178
|
+
return [
|
|
179
|
+
...marksArr.slice(0, questionIndex),
|
|
180
|
+
updatedMark,
|
|
181
|
+
...marksArr.slice(questionIndex + 1),
|
|
182
|
+
];
|
|
183
|
+
};
|
|
184
|
+
// Case 1: marks
|
|
185
|
+
if (marks.length > 0) {
|
|
127
186
|
return {
|
|
128
187
|
restricted: {
|
|
129
|
-
saveMarksheets: [{ ...rest, marks }],
|
|
188
|
+
saveMarksheets: [{ ...rest, marks: updateMarksArray(marks), sections }],
|
|
130
189
|
},
|
|
131
190
|
};
|
|
132
191
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const updatedMarks = [
|
|
154
|
-
...marks.slice(0, questionIndex),
|
|
155
|
-
updatedMark,
|
|
156
|
-
...marks.slice(questionIndex + 1),
|
|
157
|
-
];
|
|
192
|
+
// Case 2: sections
|
|
193
|
+
if (sections.length > 0) {
|
|
194
|
+
const updatedSections = sections.map((section) => {
|
|
195
|
+
if (!Array.isArray(section.marks))
|
|
196
|
+
return section;
|
|
197
|
+
const hasMark = section.marks.some((m) => Number(m.id) === Number(markId));
|
|
198
|
+
if (!hasMark)
|
|
199
|
+
return section;
|
|
200
|
+
return {
|
|
201
|
+
...section,
|
|
202
|
+
marks: updateMarksArray(section.marks),
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
return {
|
|
206
|
+
restricted: {
|
|
207
|
+
saveMarksheets: [{ ...rest, sections: updatedSections, marks }],
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
// fallback
|
|
158
212
|
return {
|
|
159
213
|
restricted: {
|
|
160
|
-
saveMarksheets: [{ ...rest, marks
|
|
214
|
+
saveMarksheets: [{ ...rest, marks, sections }],
|
|
161
215
|
},
|
|
162
216
|
};
|
|
163
217
|
};
|
|
@@ -46,7 +46,7 @@ const getQuestionTypeName = (typeId) => {
|
|
|
46
46
|
[models_1.EQuestionType.DECISION_MAKING_SBA]: 'QuestionSBA',
|
|
47
47
|
[models_1.EQuestionType.DECISION_MAKING_YES_NO]: 'QuestionMultiA',
|
|
48
48
|
[models_1.EQuestionType.SJT_SINGLE_CHOICE]: 'QuestionSBA',
|
|
49
|
-
[models_1.EQuestionType.SJT_TWO_ANSWERS]: '
|
|
49
|
+
[models_1.EQuestionType.SJT_TWO_ANSWERS]: 'QuestionSBA',
|
|
50
50
|
};
|
|
51
51
|
return mappedObj[typeId] ?? 'QuestionSBA';
|
|
52
52
|
};
|
package/utils/evaluateMark.js
CHANGED
|
@@ -81,7 +81,7 @@ function getQuestionInfo(questionType, psaSectionId) {
|
|
|
81
81
|
case models_1.EQuestionType.SJT_SINGLE_CHOICE:
|
|
82
82
|
return { maxScore: 1, answerField: 'sbaAnswer' };
|
|
83
83
|
case models_1.EQuestionType.SJT_TWO_ANSWERS:
|
|
84
|
-
return { maxScore: 1, answerField: '
|
|
84
|
+
return { maxScore: 1, answerField: 'sbaAnswer' };
|
|
85
85
|
default:
|
|
86
86
|
return { maxScore: 1, answerField: 'answer' };
|
|
87
87
|
}
|