@quesmed/types 2.6.206 → 2.6.207
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/resolvers/query/restricted/analytics.js +1 -1
- package/dist/cjs/utils/commonFunctions.d.ts +1 -0
- package/dist/cjs/utils/commonFunctions.js +53 -5
- package/dist/mjs/resolvers/query/restricted/analytics.js +1 -1
- package/dist/mjs/utils/commonFunctions.d.ts +1 -0
- package/dist/mjs/utils/commonFunctions.js +53 -5
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ export interface ICorrectMarkData {
|
|
|
3
3
|
correct: boolean;
|
|
4
4
|
incorrect: boolean;
|
|
5
5
|
correctIndex: number;
|
|
6
|
+
partial: boolean;
|
|
6
7
|
}
|
|
7
8
|
export declare function isPrescribeAnswer(data: IPrescribeAnswer | IPrescribeMark): data is IPrescribeAnswer;
|
|
8
9
|
export declare function mapPrescribeMarkToAnswer(obj: IPrescribeAnswer | IPrescribeMark): IPrescribeMark;
|
|
@@ -40,6 +40,7 @@ function correctMark(mark) {
|
|
|
40
40
|
correct: false,
|
|
41
41
|
incorrect: false,
|
|
42
42
|
correctIndex: -1,
|
|
43
|
+
partial: false,
|
|
43
44
|
};
|
|
44
45
|
if (!mark || !mark.mark) {
|
|
45
46
|
return data;
|
|
@@ -58,7 +59,6 @@ function correctMark(mark) {
|
|
|
58
59
|
models_1.EQuestionType.VERBAL_READING_COMPREHENSION,
|
|
59
60
|
models_1.EQuestionType.DECISION_MAKING_SBA,
|
|
60
61
|
models_1.EQuestionType.QUANTITATIVE_REASONING_SBA,
|
|
61
|
-
models_1.EQuestionType.SJT_SINGLE_CHOICE,
|
|
62
62
|
].includes(mark.question.typeId)) {
|
|
63
63
|
const answer = flatAnswer;
|
|
64
64
|
const attempt = flatAttempt;
|
|
@@ -84,10 +84,7 @@ function correctMark(mark) {
|
|
|
84
84
|
data.incorrect = true;
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
else if (
|
|
88
|
-
models_1.EQuestionType.MULTIPLE_ANSWERS,
|
|
89
|
-
models_1.EQuestionType.DECISION_MAKING_YES_NO,
|
|
90
|
-
].includes(mark.question.typeId)) {
|
|
87
|
+
else if (models_1.EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
|
|
91
88
|
const [answerA, answerB] = answer.map((x) => x.sort());
|
|
92
89
|
let [attemptA, attemptB] = [[], []];
|
|
93
90
|
if (Array.isArray(jsonAnswer) &&
|
|
@@ -108,6 +105,35 @@ function correctMark(mark) {
|
|
|
108
105
|
data.incorrect = true;
|
|
109
106
|
}
|
|
110
107
|
}
|
|
108
|
+
else if (models_1.EQuestionType.DECISION_MAKING_YES_NO === mark.question.typeId) {
|
|
109
|
+
const [answerA, answerB] = answer.map((x) => [...x].sort());
|
|
110
|
+
let [attemptA, attemptB] = [[], []];
|
|
111
|
+
if (Array.isArray(jsonAnswer) &&
|
|
112
|
+
jsonAnswer.length === 2 &&
|
|
113
|
+
Array.isArray(jsonAnswer[0]) &&
|
|
114
|
+
Array.isArray(jsonAnswer[1])) {
|
|
115
|
+
[attemptA, attemptB] = jsonAnswer.map((x) => [...x].sort());
|
|
116
|
+
}
|
|
117
|
+
// Count correct matches
|
|
118
|
+
let correctCount = 0;
|
|
119
|
+
// Count matches in A
|
|
120
|
+
correctCount += attemptA.filter((x) => answerA.includes(x)).length;
|
|
121
|
+
// Count matches in B
|
|
122
|
+
correctCount += attemptB.filter((x) => answerB.includes(x)).length;
|
|
123
|
+
const totalStatements = answerA.length + answerB.length;
|
|
124
|
+
if (correctCount === totalStatements) {
|
|
125
|
+
// 5 / 5
|
|
126
|
+
data.correct = true;
|
|
127
|
+
}
|
|
128
|
+
else if (correctCount === totalStatements - 1) {
|
|
129
|
+
// 4 / 5
|
|
130
|
+
data.partial = true;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
// 3 or fewer
|
|
134
|
+
data.incorrect = true;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
111
137
|
else if (models_1.EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
|
|
112
138
|
let foundCorrect = false;
|
|
113
139
|
let index = 0;
|
|
@@ -203,6 +229,28 @@ function correctMark(mark) {
|
|
|
203
229
|
data.correct = true;
|
|
204
230
|
}
|
|
205
231
|
}
|
|
232
|
+
else if (models_1.EQuestionType.SJT_SINGLE_CHOICE === mark.question.typeId) {
|
|
233
|
+
const answer = flatAnswer;
|
|
234
|
+
const attempt = flatAttempt;
|
|
235
|
+
const options = mark.question.choices.map((o) => o.label);
|
|
236
|
+
const answerIndex = options.indexOf(answer);
|
|
237
|
+
const attemptIndex = options.indexOf(attempt);
|
|
238
|
+
if (answerIndex === -1 || attemptIndex === -1) {
|
|
239
|
+
data.incorrect = true;
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
const distance = Math.abs(answerIndex - attemptIndex);
|
|
243
|
+
if (distance === 0) {
|
|
244
|
+
data.correct = true;
|
|
245
|
+
}
|
|
246
|
+
else if (distance === 1) {
|
|
247
|
+
data.partial = true;
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
data.incorrect = true;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
206
254
|
}
|
|
207
255
|
catch (e) {
|
|
208
256
|
console.error(e);
|
|
@@ -3,6 +3,7 @@ export interface ICorrectMarkData {
|
|
|
3
3
|
correct: boolean;
|
|
4
4
|
incorrect: boolean;
|
|
5
5
|
correctIndex: number;
|
|
6
|
+
partial: boolean;
|
|
6
7
|
}
|
|
7
8
|
export declare function isPrescribeAnswer(data: IPrescribeAnswer | IPrescribeMark): data is IPrescribeAnswer;
|
|
8
9
|
export declare function mapPrescribeMarkToAnswer(obj: IPrescribeAnswer | IPrescribeMark): IPrescribeMark;
|
|
@@ -35,6 +35,7 @@ export function correctMark(mark) {
|
|
|
35
35
|
correct: false,
|
|
36
36
|
incorrect: false,
|
|
37
37
|
correctIndex: -1,
|
|
38
|
+
partial: false,
|
|
38
39
|
};
|
|
39
40
|
if (!mark || !mark.mark) {
|
|
40
41
|
return data;
|
|
@@ -53,7 +54,6 @@ export function correctMark(mark) {
|
|
|
53
54
|
EQuestionType.VERBAL_READING_COMPREHENSION,
|
|
54
55
|
EQuestionType.DECISION_MAKING_SBA,
|
|
55
56
|
EQuestionType.QUANTITATIVE_REASONING_SBA,
|
|
56
|
-
EQuestionType.SJT_SINGLE_CHOICE,
|
|
57
57
|
].includes(mark.question.typeId)) {
|
|
58
58
|
const answer = flatAnswer;
|
|
59
59
|
const attempt = flatAttempt;
|
|
@@ -79,10 +79,7 @@ export function correctMark(mark) {
|
|
|
79
79
|
data.incorrect = true;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
else if (
|
|
83
|
-
EQuestionType.MULTIPLE_ANSWERS,
|
|
84
|
-
EQuestionType.DECISION_MAKING_YES_NO,
|
|
85
|
-
].includes(mark.question.typeId)) {
|
|
82
|
+
else if (EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
|
|
86
83
|
const [answerA, answerB] = answer.map((x) => x.sort());
|
|
87
84
|
let [attemptA, attemptB] = [[], []];
|
|
88
85
|
if (Array.isArray(jsonAnswer) &&
|
|
@@ -103,6 +100,35 @@ export function correctMark(mark) {
|
|
|
103
100
|
data.incorrect = true;
|
|
104
101
|
}
|
|
105
102
|
}
|
|
103
|
+
else if (EQuestionType.DECISION_MAKING_YES_NO === mark.question.typeId) {
|
|
104
|
+
const [answerA, answerB] = answer.map((x) => [...x].sort());
|
|
105
|
+
let [attemptA, attemptB] = [[], []];
|
|
106
|
+
if (Array.isArray(jsonAnswer) &&
|
|
107
|
+
jsonAnswer.length === 2 &&
|
|
108
|
+
Array.isArray(jsonAnswer[0]) &&
|
|
109
|
+
Array.isArray(jsonAnswer[1])) {
|
|
110
|
+
[attemptA, attemptB] = jsonAnswer.map((x) => [...x].sort());
|
|
111
|
+
}
|
|
112
|
+
// Count correct matches
|
|
113
|
+
let correctCount = 0;
|
|
114
|
+
// Count matches in A
|
|
115
|
+
correctCount += attemptA.filter((x) => answerA.includes(x)).length;
|
|
116
|
+
// Count matches in B
|
|
117
|
+
correctCount += attemptB.filter((x) => answerB.includes(x)).length;
|
|
118
|
+
const totalStatements = answerA.length + answerB.length;
|
|
119
|
+
if (correctCount === totalStatements) {
|
|
120
|
+
// 5 / 5
|
|
121
|
+
data.correct = true;
|
|
122
|
+
}
|
|
123
|
+
else if (correctCount === totalStatements - 1) {
|
|
124
|
+
// 4 / 5
|
|
125
|
+
data.partial = true;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// 3 or fewer
|
|
129
|
+
data.incorrect = true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
106
132
|
else if (EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
|
|
107
133
|
let foundCorrect = false;
|
|
108
134
|
let index = 0;
|
|
@@ -198,6 +224,28 @@ export function correctMark(mark) {
|
|
|
198
224
|
data.correct = true;
|
|
199
225
|
}
|
|
200
226
|
}
|
|
227
|
+
else if (EQuestionType.SJT_SINGLE_CHOICE === mark.question.typeId) {
|
|
228
|
+
const answer = flatAnswer;
|
|
229
|
+
const attempt = flatAttempt;
|
|
230
|
+
const options = mark.question.choices.map((o) => o.label);
|
|
231
|
+
const answerIndex = options.indexOf(answer);
|
|
232
|
+
const attemptIndex = options.indexOf(attempt);
|
|
233
|
+
if (answerIndex === -1 || attemptIndex === -1) {
|
|
234
|
+
data.incorrect = true;
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
const distance = Math.abs(answerIndex - attemptIndex);
|
|
238
|
+
if (distance === 0) {
|
|
239
|
+
data.correct = true;
|
|
240
|
+
}
|
|
241
|
+
else if (distance === 1) {
|
|
242
|
+
data.partial = true;
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
data.incorrect = true;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
201
249
|
}
|
|
202
250
|
catch (e) {
|
|
203
251
|
console.error(e);
|