@quesmed/types 1.0.9 → 1.0.13
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 +7 -3
- package/models/Question.d.ts +2 -1
- package/package.json +1 -1
- package/resolvers/mutation/restricted/osce.d.ts +1 -1
- package/resolvers/query/restricted/marksheet.d.ts +2 -0
- package/resolvers/subscription/osce.d.ts +2 -2
- package/resolvers/subscription/osce.js +2 -2
- package/utils/commonFunctions.d.ts +7 -0
- package/utils/commonFunctions.js +135 -0
package/models/Marksheet.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IQuestion } from './Question';
|
|
1
|
+
import { IPrescribeAnswer, IQuestion } from './Question';
|
|
2
2
|
import { Id } from './Type';
|
|
3
3
|
export interface IMarksheet {
|
|
4
4
|
id: Id;
|
|
@@ -6,20 +6,24 @@ export interface IMarksheet {
|
|
|
6
6
|
endedAt: Date | string;
|
|
7
7
|
source: string;
|
|
8
8
|
marks: IMarksheetMark[];
|
|
9
|
+
mockTestId: number | null;
|
|
9
10
|
}
|
|
10
11
|
export declare enum EQuestionLike {
|
|
11
12
|
LIKE = 0,
|
|
12
13
|
DISLIKE = 1,
|
|
13
14
|
REMOVE = 2
|
|
14
15
|
}
|
|
16
|
+
export declare type IMarksheetMarkJSONB = string | [string] | [string[], string[]] | [IPrescribeAnswer] | null;
|
|
15
17
|
export interface IMarksheetMark {
|
|
16
18
|
id: Id;
|
|
17
19
|
index: number;
|
|
20
|
+
marksheetId: Id;
|
|
18
21
|
questionChoiceId: Id;
|
|
19
22
|
timeTaken: number;
|
|
20
|
-
question: IQuestion;
|
|
21
|
-
mark?: string;
|
|
22
23
|
flagged: boolean;
|
|
24
|
+
questionId: Id;
|
|
25
|
+
question: IQuestion;
|
|
26
|
+
mark: IMarksheetMarkJSONB;
|
|
23
27
|
like: number;
|
|
24
28
|
dislike: number;
|
|
25
29
|
isLikeByMe: string;
|
package/models/Question.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare enum EQuestionType {
|
|
|
7
7
|
MULTIPLE_ANSWERS = 3,
|
|
8
8
|
PRESCRIPTION_ANSWER = 4
|
|
9
9
|
}
|
|
10
|
+
export declare type IQuestionAnswer = [string] | [string[], string[]] | IPrescribeAnswer[];
|
|
10
11
|
export interface IQuestion {
|
|
11
12
|
id: Id;
|
|
12
13
|
typeId: Id;
|
|
@@ -15,7 +16,7 @@ export interface IQuestion {
|
|
|
15
16
|
concept?: IConcept;
|
|
16
17
|
question: string;
|
|
17
18
|
explanation?: string;
|
|
18
|
-
answer:
|
|
19
|
+
answer: IQuestionAnswer;
|
|
19
20
|
totalVotes: number;
|
|
20
21
|
choices: IQuestionChoice[];
|
|
21
22
|
pictures: IQuestionPicture[];
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EOsceMarksheetAction, EOsceRoles, Id, IOsceMarksheet, IOsceMarksheetMark } from
|
|
1
|
+
import { EOsceMarksheetAction, EOsceRoles, Id, IOsceMarksheet, IOsceMarksheetMark } from '../../../models';
|
|
2
2
|
export interface IBuildOsceMarksheetVar {
|
|
3
3
|
osceStationId?: Id;
|
|
4
4
|
solo?: boolean;
|
|
@@ -24,6 +24,7 @@ export interface IDashboardPastQuizzesInfoVar {
|
|
|
24
24
|
}
|
|
25
25
|
export interface IDashboardPastQuizzesInfoRes {
|
|
26
26
|
marksheetId: number;
|
|
27
|
+
mockTestId: number;
|
|
27
28
|
topicName: string[];
|
|
28
29
|
correct: number;
|
|
29
30
|
incorrect: number;
|
|
@@ -49,6 +50,7 @@ export interface IMarksheetTopicFeedback {
|
|
|
49
50
|
}
|
|
50
51
|
export interface IMarksheetFeedbackData {
|
|
51
52
|
marksheetId: Id;
|
|
53
|
+
mockTestId: number;
|
|
52
54
|
correct: number;
|
|
53
55
|
incorrect: number;
|
|
54
56
|
total: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EOsceMarksheetAction, EOsceRoles, Id, IUser } from
|
|
1
|
+
import { EOsceMarksheetAction, EOsceRoles, Id, IUser } from '../../models';
|
|
2
2
|
export declare const ROLE_CHANGED = "ROLE_CHANGED";
|
|
3
3
|
export declare const OSCE_MARKSHEET_ACTION = "OSCE_MARKSHEET_ACTION";
|
|
4
4
|
export interface IOsceGroupMember {
|
|
@@ -26,7 +26,7 @@ export interface IOsceGroup {
|
|
|
26
26
|
}
|
|
27
27
|
];
|
|
28
28
|
}
|
|
29
|
-
export declare const OsceGroupInit: IOsceGroup[
|
|
29
|
+
export declare const OsceGroupInit: IOsceGroup['members'];
|
|
30
30
|
export interface IRoleChangedVar {
|
|
31
31
|
agoraId: string;
|
|
32
32
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OsceGroupInit = exports.OSCE_MARKSHEET_ACTION = exports.ROLE_CHANGED = void 0;
|
|
4
4
|
const models_1 = require("../../models");
|
|
5
|
-
exports.ROLE_CHANGED =
|
|
6
|
-
exports.OSCE_MARKSHEET_ACTION =
|
|
5
|
+
exports.ROLE_CHANGED = 'ROLE_CHANGED';
|
|
6
|
+
exports.OSCE_MARKSHEET_ACTION = 'OSCE_MARKSHEET_ACTION';
|
|
7
7
|
exports.OsceGroupInit = [
|
|
8
8
|
{
|
|
9
9
|
role: models_1.EOsceRoles.CANDIDATE,
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.correctMark = void 0;
|
|
4
|
+
const models_1 = require("../models");
|
|
5
|
+
function formatPrescribeAnswer(obj) {
|
|
6
|
+
obj.drug = obj.drug.toLowerCase().replace(/\s/g, '');
|
|
7
|
+
obj.route = obj.route.toLowerCase().replace(/\s/g, '');
|
|
8
|
+
if (obj.route === 'oral') {
|
|
9
|
+
obj.route = 'po';
|
|
10
|
+
}
|
|
11
|
+
else if (obj.route.includes('intravenous')) {
|
|
12
|
+
obj.route = 'iv';
|
|
13
|
+
}
|
|
14
|
+
else if (obj.route.includes('intramuscular')) {
|
|
15
|
+
obj.route = 'im';
|
|
16
|
+
}
|
|
17
|
+
else if (obj.route.includes('subcutaneous')) {
|
|
18
|
+
obj.route = 'sc';
|
|
19
|
+
}
|
|
20
|
+
else if (obj.route.includes('inhale')) {
|
|
21
|
+
obj.route = 'inh';
|
|
22
|
+
}
|
|
23
|
+
else if (obj.route.includes('nebuli')) {
|
|
24
|
+
obj.route = 'neb';
|
|
25
|
+
}
|
|
26
|
+
obj.units = obj.units.toLowerCase().replace(/\s/g, '');
|
|
27
|
+
if (obj.units === 'milligram' || obj.units === 'milligrams') {
|
|
28
|
+
obj.units = 'mg';
|
|
29
|
+
}
|
|
30
|
+
else if (obj.units === 'microgram' || obj.units === 'micrograms') {
|
|
31
|
+
obj.units = 'mcg';
|
|
32
|
+
}
|
|
33
|
+
else if (obj.units === 'gram' || obj.units === 'grams') {
|
|
34
|
+
obj.units = 'g';
|
|
35
|
+
}
|
|
36
|
+
else if (obj.units === 'unit') {
|
|
37
|
+
obj.units = 'units';
|
|
38
|
+
}
|
|
39
|
+
let m;
|
|
40
|
+
const regex = /\d/gm;
|
|
41
|
+
const durationMatches = [];
|
|
42
|
+
while ((m = regex.exec(obj.duration)) !== null) {
|
|
43
|
+
if (m.index === regex.lastIndex) {
|
|
44
|
+
regex.lastIndex++;
|
|
45
|
+
}
|
|
46
|
+
m.forEach((match) => durationMatches.push(match));
|
|
47
|
+
}
|
|
48
|
+
obj.duration = durationMatches.join(',');
|
|
49
|
+
obj.frequency = obj.frequency.toLowerCase().replace(/\s/g, '');
|
|
50
|
+
if (obj.frequency === 'once-off') {
|
|
51
|
+
obj.frequency = 'stat';
|
|
52
|
+
}
|
|
53
|
+
else if (obj.frequency.includes('once')) {
|
|
54
|
+
obj.frequency = 'po';
|
|
55
|
+
}
|
|
56
|
+
else if (obj.frequency.includes('twice')) {
|
|
57
|
+
obj.frequency = 'bd';
|
|
58
|
+
}
|
|
59
|
+
else if (obj.frequency.includes('trice')) {
|
|
60
|
+
obj.frequency = 'tds';
|
|
61
|
+
}
|
|
62
|
+
return obj;
|
|
63
|
+
}
|
|
64
|
+
function correctMark(mark) {
|
|
65
|
+
const data = {
|
|
66
|
+
correct: false,
|
|
67
|
+
incorrect: false,
|
|
68
|
+
correctIndex: -1,
|
|
69
|
+
};
|
|
70
|
+
if (!mark || !mark.mark) {
|
|
71
|
+
return data;
|
|
72
|
+
}
|
|
73
|
+
const flatAnswer = mark.question.answer[0];
|
|
74
|
+
const flatAttempt = mark.mark[0];
|
|
75
|
+
if (models_1.EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
|
|
76
|
+
const answer = flatAnswer;
|
|
77
|
+
const attempt = flatAttempt;
|
|
78
|
+
if (answer === attempt) {
|
|
79
|
+
data.correct = true;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
data.incorrect = true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else if (models_1.EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
|
|
86
|
+
const answer = flatAnswer.toLowerCase().replace(/\s/g, '');
|
|
87
|
+
const attempt = flatAttempt.toLowerCase().replace(/\s/g, '');
|
|
88
|
+
if (answer === attempt) {
|
|
89
|
+
data.correct = true;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
data.incorrect = true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else if (models_1.EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
|
|
96
|
+
const [answerA, answerB] = mark.question.answer.map((x) => x.sort());
|
|
97
|
+
const [attemptA, attemptB] = mark.mark.map((x) => x.sort());
|
|
98
|
+
if (answerA.length !== attemptA.length || answerB.length !== attemptB.length) {
|
|
99
|
+
data.incorrect = true;
|
|
100
|
+
}
|
|
101
|
+
else if (attemptA.every((x, i) => x === answerA[i]) && attemptB.every((x, i) => answerB[i])) {
|
|
102
|
+
data.correct = true;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
data.incorrect = true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else if (models_1.EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
|
|
109
|
+
const answers = mark.question.answer.map(formatPrescribeAnswer);
|
|
110
|
+
const attempt = formatPrescribeAnswer(flatAttempt);
|
|
111
|
+
let foundCorrect = false;
|
|
112
|
+
let index = 0;
|
|
113
|
+
for (const answer of answers) {
|
|
114
|
+
if (answer.dose === attempt.dose &&
|
|
115
|
+
answer.drug === attempt.drug &&
|
|
116
|
+
answer.duration.split(',').includes(attempt.duration) &&
|
|
117
|
+
answer.frequency === attempt.frequency &&
|
|
118
|
+
answer.route === attempt.route &&
|
|
119
|
+
answer.units === attempt.units) {
|
|
120
|
+
foundCorrect = true;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
index++;
|
|
124
|
+
}
|
|
125
|
+
if (foundCorrect) {
|
|
126
|
+
data.correct = true;
|
|
127
|
+
data.correctIndex = index;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
data.incorrect = true;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return data;
|
|
134
|
+
}
|
|
135
|
+
exports.correctMark = correctMark;
|