@quesmed/types-rn 2.6.208 → 2.6.210
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/Marksheet.d.ts +9 -1
- package/models/Marksheet.js +7 -1
- package/models/Question.d.ts +2 -2
- package/models/Video.d.ts +2 -0
- package/package.json +1 -1
- package/resolvers/fragments/marksheet.js +4 -0
- package/resolvers/fragments/record.d.ts +0 -1
- package/resolvers/fragments/record.js +14 -19
- package/resolvers/mutation/restricted/marksheet.d.ts +2 -0
- package/resolvers/mutation/restricted/marksheet.js +10 -0
- package/resolvers/mutation/restricted/mockTest.d.ts +3 -0
- package/resolvers/query/admin/record.js +2 -2
- package/resolvers/query/restricted/analytics.js +2 -0
- package/resolvers/query/restricted/video.js +2 -0
- package/resolvers/query/video.js +2 -0
- package/resolvers/subscription/marksheet.d.ts +6 -4
- package/resolvers/subscription/marksheet.js +2 -0
- package/utils/evaluateMark.d.ts +14 -0
- package/utils/evaluateMark.js +310 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
package/models/Marksheet.d.ts
CHANGED
|
@@ -76,6 +76,7 @@ export interface IMarksheet {
|
|
|
76
76
|
isTestMarksheet: boolean;
|
|
77
77
|
correct?: number;
|
|
78
78
|
incorrect?: number;
|
|
79
|
+
partial?: number;
|
|
79
80
|
totalQuestions?: number;
|
|
80
81
|
sessionId: string;
|
|
81
82
|
passingMark: number;
|
|
@@ -93,7 +94,12 @@ export interface IMarksheet {
|
|
|
93
94
|
builderConfig?: IBuildConfigData;
|
|
94
95
|
entitlementId: EProductType | EEntitlementType;
|
|
95
96
|
}
|
|
96
|
-
export type IMarksheetMarkJSONB = string | [string] | [IQuestionQAAnswer] | [string[], string[]] | [IPrescribeMark] | null;
|
|
97
|
+
export type IMarksheetMarkJSONB = string | [string] | string[] | [IQuestionQAAnswer] | [string[], string[]] | [IPrescribeMark] | [string, string, string] | [string, string] | [string, string][] | null;
|
|
98
|
+
export declare enum EMarkResult {
|
|
99
|
+
Incorrect = 0,
|
|
100
|
+
Correct = 1,
|
|
101
|
+
Partial = 2
|
|
102
|
+
}
|
|
97
103
|
export interface IMarksheetMark {
|
|
98
104
|
id: Id;
|
|
99
105
|
createdAt: number | Date;
|
|
@@ -110,6 +116,8 @@ export interface IMarksheetMark {
|
|
|
110
116
|
marksheet?: IMarksheet;
|
|
111
117
|
isAnswered: boolean;
|
|
112
118
|
striked: number[];
|
|
119
|
+
score: number;
|
|
120
|
+
result: EMarkResult;
|
|
113
121
|
}
|
|
114
122
|
export interface IPreBuildMarksheetRef {
|
|
115
123
|
createdAt: number | Date;
|
package/models/Marksheet.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EMarksheetAction = exports.EMarksheetType = exports.EStudyAction = exports.MARKSHEET_SOURCE = exports.EMarksheetState = void 0;
|
|
3
|
+
exports.EMarkResult = exports.EMarksheetAction = exports.EMarksheetType = exports.EStudyAction = exports.MARKSHEET_SOURCE = exports.EMarksheetState = void 0;
|
|
4
4
|
var EMarksheetState;
|
|
5
5
|
(function (EMarksheetState) {
|
|
6
6
|
EMarksheetState[EMarksheetState["LOBBY"] = 0] = "LOBBY";
|
|
@@ -50,3 +50,9 @@ var EMarksheetAction;
|
|
|
50
50
|
EMarksheetAction[EMarksheetAction["ANSWER_SELECTED"] = 15] = "ANSWER_SELECTED";
|
|
51
51
|
EMarksheetAction[EMarksheetAction["MARK_CHECK_UNCHECK"] = 16] = "MARK_CHECK_UNCHECK";
|
|
52
52
|
})(EMarksheetAction = exports.EMarksheetAction || (exports.EMarksheetAction = {}));
|
|
53
|
+
var EMarkResult;
|
|
54
|
+
(function (EMarkResult) {
|
|
55
|
+
EMarkResult[EMarkResult["Incorrect"] = 0] = "Incorrect";
|
|
56
|
+
EMarkResult[EMarkResult["Correct"] = 1] = "Correct";
|
|
57
|
+
EMarkResult[EMarkResult["Partial"] = 2] = "Partial";
|
|
58
|
+
})(EMarkResult = exports.EMarkResult || (exports.EMarkResult = {}));
|
package/models/Question.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ export interface IQuestionCommentLike {
|
|
|
77
77
|
comment: IQuestionComment;
|
|
78
78
|
likeTrueDislikeFalse: boolean;
|
|
79
79
|
}
|
|
80
|
-
export type IQuestionAnswer = string | [string] | [IQuestionQAAnswer] | [string[], string[]] |
|
|
80
|
+
export type IQuestionAnswer = string | [string] | [IQuestionQAAnswer] | [string[], string[]] | IPrescribeAnswer[] | [string, string][] | [string, string, string] | string[] | [string, string];
|
|
81
81
|
export type IQuestionAll = IQuestion | IQuestionSBA | IQuestionQA | IQuestionMultiQ | IQuestionPrescribe | IQuestionEMQ | IQuestionSelect3 | IQuestionRanking | IQuestionSjtTwoAnswer;
|
|
82
82
|
export interface IQuestion {
|
|
83
83
|
id: Id;
|
|
@@ -207,7 +207,7 @@ export interface IQuestionSjtTwoAnswer extends IQuestion {
|
|
|
207
207
|
sjtTwoAnswer: [string, string];
|
|
208
208
|
}
|
|
209
209
|
export interface IQuestionPrescribe extends IQuestion {
|
|
210
|
-
answer:
|
|
210
|
+
answer: IPrescribeAnswer[];
|
|
211
211
|
prescribeAnswer: IPrescribeAnswer[];
|
|
212
212
|
}
|
|
213
213
|
export type IPrescribeAnswerData = {
|
package/models/Video.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -15,6 +15,8 @@ exports.MARKSHEET_MARK_FIELDS = (0, client_1.gql) `
|
|
|
15
15
|
isAnswered
|
|
16
16
|
striked
|
|
17
17
|
mark
|
|
18
|
+
result
|
|
19
|
+
score
|
|
18
20
|
questionId
|
|
19
21
|
question {
|
|
20
22
|
...QuestionFields
|
|
@@ -144,5 +146,7 @@ exports.NEW_MARK_FIELDS = (0, client_1.gql) `
|
|
|
144
146
|
questionChoiceId
|
|
145
147
|
mark
|
|
146
148
|
isAnswered
|
|
149
|
+
result
|
|
150
|
+
score
|
|
147
151
|
}
|
|
148
152
|
`;
|
|
@@ -3,7 +3,6 @@ export declare const JOB_REMARK_FRAGMENT: import("@apollo/client").DocumentNode;
|
|
|
3
3
|
export declare const JOB_ASSET_FRAGMENT: import("@apollo/client").DocumentNode;
|
|
4
4
|
export declare const JOB_RECORD_METRICS_SUMMARY_FRAGMENT: import("@apollo/client").DocumentNode;
|
|
5
5
|
export declare const JOB_RECORD_CHOICE_SUMMARY_FRAGMENT: import("@apollo/client").DocumentNode;
|
|
6
|
-
export declare const JOB_RECORD_STATISTICS_FRAGMENT: import("@apollo/client").DocumentNode;
|
|
7
6
|
export declare const JOB_RECORD_QUESTION_FRAGMENT: import("@apollo/client").DocumentNode;
|
|
8
7
|
export declare const JOB_RECORD_CHAPTER_FRAGMENT: import("@apollo/client").DocumentNode;
|
|
9
8
|
export declare const JOB_RECORD_STATION_FRAGMENT: import("@apollo/client").DocumentNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JOB_RECORD_FRAGMENT = exports.JOB_RECORD_STATUS_FRAGMENT = exports.JOB_RECORD_MOCK_TEST_FRAGMENT = exports.JOB_RECORD_STATION_FRAGMENT = exports.JOB_RECORD_CHAPTER_FRAGMENT = exports.JOB_RECORD_QUESTION_FRAGMENT = exports.
|
|
3
|
+
exports.JOB_RECORD_FRAGMENT = exports.JOB_RECORD_STATUS_FRAGMENT = exports.JOB_RECORD_MOCK_TEST_FRAGMENT = exports.JOB_RECORD_STATION_FRAGMENT = exports.JOB_RECORD_CHAPTER_FRAGMENT = exports.JOB_RECORD_QUESTION_FRAGMENT = exports.JOB_RECORD_CHOICE_SUMMARY_FRAGMENT = exports.JOB_RECORD_METRICS_SUMMARY_FRAGMENT = exports.JOB_ASSET_FRAGMENT = exports.JOB_REMARK_FRAGMENT = exports.JOB_USER_FRAGMENT = void 0;
|
|
4
4
|
const client_1 = require("@apollo/client");
|
|
5
5
|
exports.JOB_USER_FRAGMENT = (0, client_1.gql) `
|
|
6
6
|
fragment JobUser on User {
|
|
@@ -63,10 +63,6 @@ exports.JOB_RECORD_METRICS_SUMMARY_FRAGMENT = (0, client_1.gql) `
|
|
|
63
63
|
correct
|
|
64
64
|
incorrect
|
|
65
65
|
percentage
|
|
66
|
-
commentCount
|
|
67
|
-
likes
|
|
68
|
-
dislikes
|
|
69
|
-
public
|
|
70
66
|
}
|
|
71
67
|
`;
|
|
72
68
|
exports.JOB_RECORD_CHOICE_SUMMARY_FRAGMENT = (0, client_1.gql) `
|
|
@@ -78,18 +74,18 @@ exports.JOB_RECORD_CHOICE_SUMMARY_FRAGMENT = (0, client_1.gql) `
|
|
|
78
74
|
questionId
|
|
79
75
|
}
|
|
80
76
|
`;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
`;
|
|
77
|
+
// export const JOB_RECORD_STATISTICS_FRAGMENT = gql`
|
|
78
|
+
// ${JOB_RECORD_METRICS_SUMMARY_FRAGMENT}
|
|
79
|
+
// ${JOB_RECORD_CHOICE_SUMMARY_FRAGMENT}
|
|
80
|
+
// fragment JobRecordStatistics on JobRecord {
|
|
81
|
+
// metricsSummary {
|
|
82
|
+
// ...JobRecordMetricsSummary
|
|
83
|
+
// }
|
|
84
|
+
// choiceSummary {
|
|
85
|
+
// ...JobRecordChoiceSummary
|
|
86
|
+
// }
|
|
87
|
+
// }
|
|
88
|
+
// `;
|
|
93
89
|
exports.JOB_RECORD_QUESTION_FRAGMENT = (0, client_1.gql) `
|
|
94
90
|
fragment JobRecordQuestion on JobRecordQuestion {
|
|
95
91
|
question
|
|
@@ -170,7 +166,6 @@ exports.JOB_RECORD_FRAGMENT = (0, client_1.gql) `
|
|
|
170
166
|
${exports.JOB_RECORD_CHAPTER_FRAGMENT}
|
|
171
167
|
${exports.JOB_RECORD_STATION_FRAGMENT}
|
|
172
168
|
${exports.JOB_RECORD_MOCK_TEST_FRAGMENT}
|
|
173
|
-
${exports.JOB_RECORD_STATISTICS_FRAGMENT}
|
|
174
169
|
${exports.JOB_ASSET_FRAGMENT}
|
|
175
170
|
fragment JobRecord on JobRecord {
|
|
176
171
|
id
|
|
@@ -208,6 +203,6 @@ exports.JOB_RECORD_FRAGMENT = (0, client_1.gql) `
|
|
|
208
203
|
updatedAt
|
|
209
204
|
publishedAt
|
|
210
205
|
...JobRecordStatus
|
|
211
|
-
...JobRecordStatistics
|
|
206
|
+
# ...JobRecordStatistics
|
|
212
207
|
}
|
|
213
208
|
`;
|
|
@@ -190,6 +190,7 @@ export declare const optimisticModifyMarksheetBuilderConfig: (marksheetId: numbe
|
|
|
190
190
|
isTestMarksheet: boolean;
|
|
191
191
|
correct?: number | undefined;
|
|
192
192
|
incorrect?: number | undefined;
|
|
193
|
+
partial?: number | undefined;
|
|
193
194
|
totalQuestions?: number | undefined;
|
|
194
195
|
sessionId: string;
|
|
195
196
|
passingMark: number;
|
|
@@ -283,6 +284,7 @@ export declare const optimisticEndMarksheet: (marksheet: IMarksheet) => {
|
|
|
283
284
|
isTestMarksheet: boolean;
|
|
284
285
|
correct?: number | undefined;
|
|
285
286
|
incorrect?: number | undefined;
|
|
287
|
+
partial?: number | undefined;
|
|
286
288
|
totalQuestions?: number | undefined;
|
|
287
289
|
sessionId: string;
|
|
288
290
|
passingMark: number;
|
|
@@ -70,6 +70,8 @@ exports.SAVE_MARKSHEET = (0, client_1.gql) `
|
|
|
70
70
|
state
|
|
71
71
|
marks {
|
|
72
72
|
isAnswered
|
|
73
|
+
result
|
|
74
|
+
score
|
|
73
75
|
id
|
|
74
76
|
marksheetId
|
|
75
77
|
questionChoiceId
|
|
@@ -103,6 +105,8 @@ const updateMarksheets = (cache, result, options) => {
|
|
|
103
105
|
mark: marksheet.mark,
|
|
104
106
|
questionChoiceId: marksheet.choiceId,
|
|
105
107
|
isAnswered: true,
|
|
108
|
+
result: 0,
|
|
109
|
+
score: 0,
|
|
106
110
|
},
|
|
107
111
|
fragment: marksheet_1.NEW_MARK_FIELDS,
|
|
108
112
|
});
|
|
@@ -123,6 +127,8 @@ const optimisticSaveMarksheets = (marksheet, marksheetInput, questionIndex) => {
|
|
|
123
127
|
questionChoiceId: choiceId ?? null,
|
|
124
128
|
isAnswered: true,
|
|
125
129
|
mark: mark || null,
|
|
130
|
+
result: 0,
|
|
131
|
+
score: 0,
|
|
126
132
|
};
|
|
127
133
|
const updatedMarks = [
|
|
128
134
|
...marks.slice(0, questionIndex),
|
|
@@ -345,6 +351,8 @@ exports.MODIFY_MARKSHEET_MARK = (0, client_1.gql) `
|
|
|
345
351
|
questionChoiceId
|
|
346
352
|
timeTaken
|
|
347
353
|
mark
|
|
354
|
+
result
|
|
355
|
+
score
|
|
348
356
|
isAnswered
|
|
349
357
|
striked
|
|
350
358
|
}
|
|
@@ -453,6 +461,8 @@ exports.TOGGLE_STRIKE_OPTIONS = (0, client_1.gql) `
|
|
|
453
461
|
index
|
|
454
462
|
isAnswered
|
|
455
463
|
mark
|
|
464
|
+
result
|
|
465
|
+
score
|
|
456
466
|
marksheetId
|
|
457
467
|
question {
|
|
458
468
|
id
|
|
@@ -29,6 +29,8 @@ export declare const optimisticToggleFlaggedQuestion: (mark: IMarksheetMark, fla
|
|
|
29
29
|
marksheet?: IMarksheet | undefined;
|
|
30
30
|
isAnswered: boolean;
|
|
31
31
|
striked: number[];
|
|
32
|
+
score: number;
|
|
33
|
+
result: import("../../../models").EMarkResult;
|
|
32
34
|
};
|
|
33
35
|
};
|
|
34
36
|
};
|
|
@@ -64,6 +66,7 @@ export declare const optimisticEndMockTest: (marksheet: IMarksheet) => {
|
|
|
64
66
|
isTestMarksheet: boolean;
|
|
65
67
|
correct?: number | undefined;
|
|
66
68
|
incorrect?: number | undefined;
|
|
69
|
+
partial?: number | undefined;
|
|
67
70
|
totalQuestions?: number | undefined;
|
|
68
71
|
sessionId: string;
|
|
69
72
|
passingMark: number;
|
|
@@ -5,9 +5,9 @@ const client_1 = require("@apollo/client");
|
|
|
5
5
|
const fragments_1 = require("../../fragments");
|
|
6
6
|
exports.GET_JOB_RECORDS = (0, client_1.gql) `
|
|
7
7
|
${fragments_1.JOB_RECORD_FRAGMENT}
|
|
8
|
-
query GetJobRecords($jobId: ID
|
|
8
|
+
query GetJobRecords($jobId: ID!) {
|
|
9
9
|
admin {
|
|
10
|
-
getJobRecords(jobId: $jobId
|
|
10
|
+
getJobRecords(jobId: $jobId) {
|
|
11
11
|
...JobRecord
|
|
12
12
|
}
|
|
13
13
|
}
|
package/resolvers/query/video.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EMarksheetAction, EMarksheetState, Id,
|
|
1
|
+
import { EMarksheetAction, EMarksheetState, Id, IMarksheetMark, IUser } from '../../models';
|
|
2
2
|
import { IBuildConfigData, IPreBuildMarksheet } from '../mutation/restricted';
|
|
3
3
|
import { RootData } from '../types';
|
|
4
4
|
export interface IMarksheetGroupMember {
|
|
@@ -58,12 +58,14 @@ export interface IMarksheetMarkData {
|
|
|
58
58
|
newMarkId?: Id;
|
|
59
59
|
markIndex?: number;
|
|
60
60
|
questionChoiceId?: Id;
|
|
61
|
-
mark?:
|
|
61
|
+
mark?: IMarksheetMark['mark'];
|
|
62
62
|
isAnswered?: boolean;
|
|
63
|
-
|
|
63
|
+
score?: IMarksheetMark['score'];
|
|
64
|
+
result?: IMarksheetMark['result'];
|
|
65
|
+
timeTaken?: IMarksheetMark['timeTaken'];
|
|
64
66
|
updatedAt?: Date;
|
|
65
67
|
user: IUser;
|
|
66
|
-
striked?:
|
|
68
|
+
striked?: IMarksheetMark['striked'];
|
|
67
69
|
}
|
|
68
70
|
export type IOnMarksheetMarkChangeData = RootData<IMarksheetMarkData, 'onMarksheetMarkChange'>;
|
|
69
71
|
export declare const ON_MARKSHEET_MARK_CHANGE_KEY = "ON_MARKSHEET_CHANGE_KEY";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EMarkResult, EPsaSectionType, EQuestionType, IMarksheetMarkJSONB, IQuestionAnswer } from '../models';
|
|
2
|
+
export interface IEvaluateMarkData {
|
|
3
|
+
score: number;
|
|
4
|
+
result: EMarkResult;
|
|
5
|
+
}
|
|
6
|
+
export declare function evaluateMark({ mark, answer, questionTypeId, psaSectionId, choices, }: {
|
|
7
|
+
mark: IMarksheetMarkJSONB;
|
|
8
|
+
answer: IQuestionAnswer;
|
|
9
|
+
questionTypeId: EQuestionType;
|
|
10
|
+
psaSectionId: EPsaSectionType | null;
|
|
11
|
+
choices?: Array<{
|
|
12
|
+
label: string;
|
|
13
|
+
}>;
|
|
14
|
+
}): IEvaluateMarkData;
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.evaluateMark = void 0;
|
|
4
|
+
const models_1 = require("../models");
|
|
5
|
+
const object_1 = require("./object");
|
|
6
|
+
function isPrescribeAnswer(data) {
|
|
7
|
+
return Object(data).hasOwnProperty('dose');
|
|
8
|
+
}
|
|
9
|
+
function mapPrescribeMarkToAnswer(obj) {
|
|
10
|
+
if (isPrescribeAnswer(obj)) {
|
|
11
|
+
return {
|
|
12
|
+
drugId: obj.drug.value,
|
|
13
|
+
doseId: obj.dose.value,
|
|
14
|
+
durationId: obj.duration.value,
|
|
15
|
+
frequencyId: obj.frequency.value,
|
|
16
|
+
routeId: obj.route.value,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
drugId: obj.drugId,
|
|
21
|
+
doseId: obj.doseId,
|
|
22
|
+
durationId: obj.durationId,
|
|
23
|
+
frequencyId: obj.frequencyId,
|
|
24
|
+
routeId: obj.routeId,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function createHashMap(arr) {
|
|
28
|
+
const map = new Map();
|
|
29
|
+
for (const innerArr of arr) {
|
|
30
|
+
const sortedInnerArr = innerArr.slice().sort();
|
|
31
|
+
const key = sortedInnerArr.join('|');
|
|
32
|
+
map.set(key, (map.get(key) || 0) + 1);
|
|
33
|
+
}
|
|
34
|
+
return map;
|
|
35
|
+
}
|
|
36
|
+
function deepParse(data) {
|
|
37
|
+
let parsed = data;
|
|
38
|
+
while (typeof parsed === 'string') {
|
|
39
|
+
try {
|
|
40
|
+
parsed = JSON.parse(parsed);
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return parsed;
|
|
47
|
+
}
|
|
48
|
+
function evaluateMark({ mark, answer, questionTypeId, psaSectionId, choices, }) {
|
|
49
|
+
const data = {
|
|
50
|
+
score: 0,
|
|
51
|
+
result: models_1.EMarkResult.Incorrect,
|
|
52
|
+
};
|
|
53
|
+
if (!mark || !answer) {
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const flatAnswer = answer[0];
|
|
58
|
+
const jsonAnswer = deepParse(mark);
|
|
59
|
+
const flatAttempt = jsonAnswer[0];
|
|
60
|
+
switch (questionTypeId) {
|
|
61
|
+
case models_1.EQuestionType.SINGLE_BEST_ANSWER:
|
|
62
|
+
case models_1.EQuestionType.SBA_WITH_MULTIPLE_CHOICES:
|
|
63
|
+
case models_1.EQuestionType.VERBAL_VERACITY:
|
|
64
|
+
case models_1.EQuestionType.VERBAL_READING_COMPREHENSION:
|
|
65
|
+
case models_1.EQuestionType.DECISION_MAKING_SBA:
|
|
66
|
+
case models_1.EQuestionType.QUANTITATIVE_REASONING_SBA: {
|
|
67
|
+
if (flatAnswer === flatAttempt) {
|
|
68
|
+
data.score = psaSectionId ? 2 : 1;
|
|
69
|
+
data.result = models_1.EMarkResult.Correct;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
data.score = 0;
|
|
73
|
+
data.result = models_1.EMarkResult.Incorrect;
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case models_1.EQuestionType.QUESTION_ANSWER: {
|
|
78
|
+
const normalizedAnswer = flatAnswer.dose
|
|
79
|
+
.toLowerCase()
|
|
80
|
+
.replace(/\s/g, '');
|
|
81
|
+
const normalizedAttempt = flatAttempt
|
|
82
|
+
? flatAttempt.toLowerCase().replace(/\s/g, '')
|
|
83
|
+
: '';
|
|
84
|
+
if (normalizedAnswer === normalizedAttempt) {
|
|
85
|
+
// for psa section, we give 2 marks for correct answer
|
|
86
|
+
data.score = psaSectionId ? 2 : 1;
|
|
87
|
+
data.result = models_1.EMarkResult.Correct;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
data.score = 0;
|
|
91
|
+
data.result = models_1.EMarkResult.Incorrect;
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
case models_1.EQuestionType.MULTIPLE_ANSWERS: {
|
|
96
|
+
const [answerA, answerB] = answer.map((x) => x.sort());
|
|
97
|
+
let [attemptA, attemptB] = [[], []];
|
|
98
|
+
if (Array.isArray(jsonAnswer) &&
|
|
99
|
+
jsonAnswer.length === 2 &&
|
|
100
|
+
Array.isArray(jsonAnswer[0]) &&
|
|
101
|
+
Array.isArray(jsonAnswer[1])) {
|
|
102
|
+
[attemptA, attemptB] = jsonAnswer.map((x) => x.sort());
|
|
103
|
+
}
|
|
104
|
+
const isAMatch = answerA.length === attemptA.length &&
|
|
105
|
+
attemptA.every((x, i) => x === answerA[i]);
|
|
106
|
+
const isBMatch = answerB.length === attemptB.length &&
|
|
107
|
+
attemptB.every((x, i) => x === answerB[i]);
|
|
108
|
+
if (isAMatch && isBMatch) {
|
|
109
|
+
data.score = 4;
|
|
110
|
+
data.result = models_1.EMarkResult.Correct;
|
|
111
|
+
}
|
|
112
|
+
else if (isAMatch || isBMatch) {
|
|
113
|
+
data.score = 2;
|
|
114
|
+
data.result = models_1.EMarkResult.Partial;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
data.score = 0;
|
|
118
|
+
data.result = models_1.EMarkResult.Incorrect;
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
case models_1.EQuestionType.DECISION_MAKING_YES_NO: {
|
|
123
|
+
const [answerA, answerB] = answer.map((x) => [...x].sort());
|
|
124
|
+
let [attemptA, attemptB] = [[], []];
|
|
125
|
+
if (Array.isArray(jsonAnswer) &&
|
|
126
|
+
jsonAnswer.length === 2 &&
|
|
127
|
+
Array.isArray(jsonAnswer[0]) &&
|
|
128
|
+
Array.isArray(jsonAnswer[1])) {
|
|
129
|
+
[attemptA, attemptB] = jsonAnswer.map((x) => [...x].sort());
|
|
130
|
+
}
|
|
131
|
+
// Count correct matches
|
|
132
|
+
let correctCount = 0;
|
|
133
|
+
// Count matches in A
|
|
134
|
+
correctCount += attemptA.filter((x) => answerA.includes(x)).length;
|
|
135
|
+
// Count matches in B
|
|
136
|
+
correctCount += attemptB.filter((x) => answerB.includes(x)).length;
|
|
137
|
+
const totalStatements = answerA.length + answerB.length;
|
|
138
|
+
if (correctCount === totalStatements) {
|
|
139
|
+
// 5 / 5
|
|
140
|
+
data.score = 2;
|
|
141
|
+
data.result = models_1.EMarkResult.Correct;
|
|
142
|
+
}
|
|
143
|
+
else if (correctCount === totalStatements - 1) {
|
|
144
|
+
// 4 / 5
|
|
145
|
+
data.score = 1;
|
|
146
|
+
data.result = models_1.EMarkResult.Partial;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
// 3 or fewer
|
|
150
|
+
data.score = 0;
|
|
151
|
+
data.result = models_1.EMarkResult.Incorrect;
|
|
152
|
+
}
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
case models_1.EQuestionType.PRESCRIPTION_ANSWER: {
|
|
156
|
+
let foundCorrect = false;
|
|
157
|
+
if (typeof flatAttempt === 'object' &&
|
|
158
|
+
Object.keys(flatAttempt).length > 0) {
|
|
159
|
+
const answers = answer.map(mapPrescribeMarkToAnswer);
|
|
160
|
+
const attempt = mapPrescribeMarkToAnswer(flatAttempt);
|
|
161
|
+
foundCorrect = answers.some((ans) => (0, object_1.compareObjects)(ans, attempt));
|
|
162
|
+
}
|
|
163
|
+
if (foundCorrect) {
|
|
164
|
+
data.score = 1;
|
|
165
|
+
data.result = models_1.EMarkResult.Correct;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
data.score = 0;
|
|
169
|
+
data.result = models_1.EMarkResult.Incorrect;
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
case models_1.EQuestionType.EXTENDED_MATCHING_ANSWER: {
|
|
174
|
+
const extendedAnswer = answer;
|
|
175
|
+
const attempt = jsonAnswer;
|
|
176
|
+
if (extendedAnswer.length !== attempt.length) {
|
|
177
|
+
data.score = 0;
|
|
178
|
+
data.result = models_1.EMarkResult.Incorrect;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
const map1 = createHashMap(extendedAnswer);
|
|
182
|
+
const map2 = createHashMap(attempt);
|
|
183
|
+
let isCorrect = true;
|
|
184
|
+
for (const [key, value] of map1) {
|
|
185
|
+
if (map2.get(key) !== value) {
|
|
186
|
+
isCorrect = false;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (isCorrect) {
|
|
191
|
+
data.score = 1;
|
|
192
|
+
data.result = models_1.EMarkResult.Correct;
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
data.score = 0;
|
|
196
|
+
data.result = models_1.EMarkResult.Incorrect;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
case models_1.EQuestionType.SELECT_THREE_ANSWER: {
|
|
202
|
+
const threeAnswer = answer;
|
|
203
|
+
const attempt = jsonAnswer;
|
|
204
|
+
if (threeAnswer.length !== 3) {
|
|
205
|
+
data.score = 0;
|
|
206
|
+
data.result = models_1.EMarkResult.Incorrect;
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
const answerSet = new Set(threeAnswer);
|
|
210
|
+
let isCorrect = true;
|
|
211
|
+
for (const attemptLabel of attempt) {
|
|
212
|
+
if (!answerSet.has(attemptLabel)) {
|
|
213
|
+
isCorrect = false;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (isCorrect) {
|
|
218
|
+
data.score = 1;
|
|
219
|
+
data.result = models_1.EMarkResult.Correct;
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
data.score = 0;
|
|
223
|
+
data.result = models_1.EMarkResult.Incorrect;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
case models_1.EQuestionType.RANKING_ANSWER: {
|
|
229
|
+
// Duplicate logic to Extended Matching, but they have different scoring systems
|
|
230
|
+
// which we may add at a later point
|
|
231
|
+
const rankAnswer = answer;
|
|
232
|
+
const attempt = jsonAnswer;
|
|
233
|
+
if (rankAnswer.length !== attempt.length) {
|
|
234
|
+
data.score = 0;
|
|
235
|
+
data.result = models_1.EMarkResult.Incorrect;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
let isCorrect = true;
|
|
239
|
+
for (let i = 0; i < rankAnswer.length; i++) {
|
|
240
|
+
if (rankAnswer[i] !== attempt[i]) {
|
|
241
|
+
isCorrect = false;
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (isCorrect) {
|
|
246
|
+
data.score = 1;
|
|
247
|
+
data.result = models_1.EMarkResult.Correct;
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
data.score = 0;
|
|
251
|
+
data.result = models_1.EMarkResult.Incorrect;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
case models_1.EQuestionType.SJT_TWO_ANSWERS: {
|
|
257
|
+
const twoAnswer = answer;
|
|
258
|
+
const attempt = jsonAnswer;
|
|
259
|
+
if (twoAnswer.length === 2 &&
|
|
260
|
+
attempt.length === 2 &&
|
|
261
|
+
twoAnswer.join(',') === attempt.join(',')) {
|
|
262
|
+
data.score = 1;
|
|
263
|
+
data.result = models_1.EMarkResult.Correct;
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
data.score = 0;
|
|
267
|
+
data.result = models_1.EMarkResult.Incorrect;
|
|
268
|
+
}
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
case models_1.EQuestionType.SJT_SINGLE_CHOICE: {
|
|
272
|
+
const answer = flatAnswer;
|
|
273
|
+
const attempt = flatAttempt;
|
|
274
|
+
if (!choices) {
|
|
275
|
+
data.score = 0;
|
|
276
|
+
data.result = models_1.EMarkResult.Incorrect;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
const options = choices.map((o) => o.label);
|
|
280
|
+
const answerIndex = options.indexOf(answer);
|
|
281
|
+
const attemptIndex = options.indexOf(attempt);
|
|
282
|
+
if (answerIndex === -1 || attemptIndex === -1) {
|
|
283
|
+
data.score = 0;
|
|
284
|
+
data.result = models_1.EMarkResult.Incorrect;
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
const distance = Math.abs(answerIndex - attemptIndex);
|
|
288
|
+
if (distance === 0) {
|
|
289
|
+
data.score = 1;
|
|
290
|
+
data.result = models_1.EMarkResult.Correct;
|
|
291
|
+
}
|
|
292
|
+
else if (distance === 1) {
|
|
293
|
+
data.score = 0.5;
|
|
294
|
+
data.result = models_1.EMarkResult.Partial;
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
data.score = 0;
|
|
298
|
+
data.result = models_1.EMarkResult.Incorrect;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
catch (e) {
|
|
306
|
+
console.error(e);
|
|
307
|
+
}
|
|
308
|
+
return data;
|
|
309
|
+
}
|
|
310
|
+
exports.evaluateMark = evaluateMark;
|
package/utils/index.d.ts
CHANGED
package/utils/index.js
CHANGED
|
@@ -19,6 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.printDuration = exports.Uuid4 = void 0;
|
|
21
21
|
__exportStar(require("./commonFunctions"), exports);
|
|
22
|
+
__exportStar(require("./evaluateMark"), exports);
|
|
22
23
|
__exportStar(require("./lightgallery"), exports);
|
|
23
24
|
__exportStar(require("./object"), exports);
|
|
24
25
|
__exportStar(require("./offlineLink"), exports);
|