@quesmed/types 1.0.12 → 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.
@@ -13,6 +13,7 @@ export declare enum EQuestionLike {
13
13
  DISLIKE = 1,
14
14
  REMOVE = 2
15
15
  }
16
+ export declare type IMarksheetMarkJSONB = string | [string] | [string[], string[]] | [IPrescribeAnswer] | null;
16
17
  export interface IMarksheetMark {
17
18
  id: Id;
18
19
  index: number;
@@ -22,7 +23,7 @@ export interface IMarksheetMark {
22
23
  flagged: boolean;
23
24
  questionId: Id;
24
25
  question: IQuestion;
25
- mark: string | string[] | [string[], string[]] | IPrescribeAnswer | null;
26
+ mark: IMarksheetMarkJSONB;
26
27
  like: number;
27
28
  dislike: number;
28
29
  isLikeByMe: string;
@@ -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: any;
19
+ answer: IQuestionAnswer;
19
20
  totalVotes: number;
20
21
  choices: IQuestionChoice[];
21
22
  pictures: IQuestionPicture[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "main": "index.js",
6
6
  "types": "dist/index.d.ts",
@@ -70,9 +70,11 @@ function correctMark(mark) {
70
70
  if (!mark || !mark.mark) {
71
71
  return data;
72
72
  }
73
+ const flatAnswer = mark.question.answer[0];
74
+ const flatAttempt = mark.mark[0];
73
75
  if (models_1.EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
74
- const answer = mark.question.answer[0];
75
- const attempt = mark.mark[0];
76
+ const answer = flatAnswer;
77
+ const attempt = flatAttempt;
76
78
  if (answer === attempt) {
77
79
  data.correct = true;
78
80
  }
@@ -81,8 +83,8 @@ function correctMark(mark) {
81
83
  }
82
84
  }
83
85
  else if (models_1.EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
84
- const answer = mark.question.answer.toLowerCase().replace(/\s/g, '');
85
- const attempt = mark.mark.toLowerCase().replace(/\s/g, '');
86
+ const answer = flatAnswer.toLowerCase().replace(/\s/g, '');
87
+ const attempt = flatAttempt.toLowerCase().replace(/\s/g, '');
86
88
  if (answer === attempt) {
87
89
  data.correct = true;
88
90
  }
@@ -105,7 +107,7 @@ function correctMark(mark) {
105
107
  }
106
108
  else if (models_1.EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
107
109
  const answers = mark.question.answer.map(formatPrescribeAnswer);
108
- const attempt = formatPrescribeAnswer(mark.mark);
110
+ const attempt = formatPrescribeAnswer(flatAttempt);
109
111
  let foundCorrect = false;
110
112
  let index = 0;
111
113
  for (const answer of answers) {