@quesmed/types 2.6.272 → 2.6.274

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.
@@ -42,6 +42,10 @@ export interface IChangeOsceRoleVar {
42
42
  }
43
43
  export type IChangeOsceRoleData = RestrictedData<graphqlNormalize & IOsceMarksheet, 'changeOsceRole'>;
44
44
  export declare const MARK_OSCE_MARKSHEET_MARK: import("@apollo/client").DocumentNode;
45
+ export declare const getStationScore: (marks: IOsceMarksheetMark[]) => {
46
+ total: number;
47
+ userScore: number;
48
+ };
45
49
  export interface IMarkOsceMarksheetMarkVar {
46
50
  osceMarksheetMarkId: Id;
47
51
  mark: number | EPaceMarkType;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.END_VOICE_SESSION = exports.CREATE_VOICE_SESSION = exports.optimisticSetOsceMarksheetFeedback = exports.updateCacheOnSetOsceMarksheetFeedback = exports.SET_OSCE_MARKSHEET_FEEDBACK = exports.updateCacheOnAutoMarkOsceMarksheet = exports.AUTO_MARK_OSCE_MARKSHEET = exports.STREAM_OSCE_CHAT_MESSAGE = exports.LEAVE_OSCE_MARKSHEET = exports.optimisticEndOsceMarksheet = exports.updateCacheOnEndOsceMarksheet = exports.END_OSCE_MARKSHEET = exports.MODIFY_OSCE_MARKSHEET = exports.updateCacheOnSaveOsceMarksheet = exports.SAVE_OSCE_MARKSHEET = exports.PRESTART_OSCE_MARKSHEET = exports.START_OSCE_TIMER = exports.START_OSCE_MARKSHEET = exports.SELECT_OSCE_STATION = exports.updateCacheOnMarkOsceMarksheetMark = exports.optimisticMarkOsceMarksheetMark = exports.MARK_OSCE_MARKSHEET_MARK = exports.CHANGE_OSCE_ROLE = exports.BUILD_OSCE_MARKSHEET = exports.CREATE_OR_JOIN_OSCE_MARKSHEET = exports.CANCEL_OSCE_MATCHMAKING = exports.CHECK_OSCE_MATCHMAKING = exports.ACCEPT_OSCE_MATCHMAKING = exports.START_OSCE_MATCHMAKING = void 0;
3
+ exports.END_VOICE_SESSION = exports.CREATE_VOICE_SESSION = exports.optimisticSetOsceMarksheetFeedback = exports.updateCacheOnSetOsceMarksheetFeedback = exports.SET_OSCE_MARKSHEET_FEEDBACK = exports.updateCacheOnAutoMarkOsceMarksheet = exports.AUTO_MARK_OSCE_MARKSHEET = exports.STREAM_OSCE_CHAT_MESSAGE = exports.LEAVE_OSCE_MARKSHEET = exports.optimisticEndOsceMarksheet = exports.updateCacheOnEndOsceMarksheet = exports.END_OSCE_MARKSHEET = exports.MODIFY_OSCE_MARKSHEET = exports.updateCacheOnSaveOsceMarksheet = exports.SAVE_OSCE_MARKSHEET = exports.PRESTART_OSCE_MARKSHEET = exports.START_OSCE_TIMER = exports.START_OSCE_MARKSHEET = exports.SELECT_OSCE_STATION = exports.updateCacheOnMarkOsceMarksheetMark = exports.optimisticMarkOsceMarksheetMark = exports.getStationScore = exports.MARK_OSCE_MARKSHEET_MARK = exports.CHANGE_OSCE_ROLE = exports.BUILD_OSCE_MARKSHEET = exports.CREATE_OR_JOIN_OSCE_MARKSHEET = exports.CANCEL_OSCE_MATCHMAKING = exports.CHECK_OSCE_MATCHMAKING = exports.ACCEPT_OSCE_MATCHMAKING = exports.START_OSCE_MATCHMAKING = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const models_1 = require("../../../models");
6
6
  const fragments_1 = require("../../fragments");
@@ -101,6 +101,44 @@ exports.MARK_OSCE_MARKSHEET_MARK = (0, client_1.gql) `
101
101
  }
102
102
  }
103
103
  `;
104
+ const getStationScore = (marks) => {
105
+ const MarkMap = {
106
+ [models_1.EPaceMarkType.SATISFACTORY]: 2,
107
+ [models_1.EPaceMarkType.BORDERLINE]: 1,
108
+ [models_1.EPaceMarkType.UN_SATISFACTORY]: 0,
109
+ };
110
+ if (!marks?.length) {
111
+ return {
112
+ total: 0,
113
+ userScore: 0,
114
+ };
115
+ }
116
+ const { total, userScore } = marks.reduce((acc, mark) => {
117
+ const choices = mark.osceStationMark?.choices;
118
+ const multiplier = mark.secondaryMark ? 2 : 1;
119
+ // Maximum possible score
120
+ acc.total += multiplier ? 4 : choices?.length ? 2 : 1;
121
+ if (choices) {
122
+ // paces product
123
+ acc.userScore += MarkMap[mark.mark] ?? 0;
124
+ if (mark.secondaryMark) {
125
+ acc.userScore += MarkMap[mark.secondaryMark] ?? 0;
126
+ }
127
+ }
128
+ else {
129
+ acc.userScore += mark.mark ? 1 : 0;
130
+ }
131
+ return acc;
132
+ }, {
133
+ total: 0,
134
+ userScore: 0,
135
+ });
136
+ return {
137
+ total,
138
+ userScore,
139
+ };
140
+ };
141
+ exports.getStationScore = getStationScore;
104
142
  const optimisticMarkOsceMarksheetMark = (variables, productType) => {
105
143
  const data = {};
106
144
  if (productType === models_1.EProductType.PACES) {
@@ -169,6 +207,13 @@ const updateCacheOnMarkOsceMarksheetMark = (cache, result, options) => {
169
207
  mark
170
208
  score
171
209
  secondaryMark
210
+ selectedChoice
211
+ osceStationMark {
212
+ id
213
+ choices {
214
+ score
215
+ }
216
+ }
172
217
  }
173
218
  }
174
219
  `,
@@ -176,10 +221,7 @@ const updateCacheOnMarkOsceMarksheetMark = (cache, result, options) => {
176
221
  if (!marksheet?.marks?.length) {
177
222
  return;
178
223
  }
179
- const hasSecondaryMarks = marksheet.marks.some((m) => m.secondaryMark);
180
- const total = hasSecondaryMarks ? 2 * marksheet.marks.length : marksheet.marks.length;
181
- // const scored = marksheet.marks.filter(({ mark }) => Boolean(mark)).length;
182
- const userScore = marksheet.marks.reduce((sum, m) => sum + Number(m.score), 0);
224
+ const { total, userScore } = (0, exports.getStationScore)(marksheet.marks);
183
225
  cache.modify({
184
226
  id: cache.identify({ id: marksheetId, __typename: 'OsceMarksheet' }),
185
227
  fields: {
@@ -42,6 +42,10 @@ export interface IChangeOsceRoleVar {
42
42
  }
43
43
  export type IChangeOsceRoleData = RestrictedData<graphqlNormalize & IOsceMarksheet, 'changeOsceRole'>;
44
44
  export declare const MARK_OSCE_MARKSHEET_MARK: import("@apollo/client").DocumentNode;
45
+ export declare const getStationScore: (marks: IOsceMarksheetMark[]) => {
46
+ total: number;
47
+ userScore: number;
48
+ };
45
49
  export interface IMarkOsceMarksheetMarkVar {
46
50
  osceMarksheetMarkId: Id;
47
51
  mark: number | EPaceMarkType;
@@ -1,5 +1,5 @@
1
1
  import { gql } from '@apollo/client';
2
- import { EProductType, } from '../../../models';
2
+ import { EPaceMarkType, EProductType, } from '../../../models';
3
3
  import { COMPLETED_OSCE_STATION_FRAGMENT, OSCE_MARKSHEET_FIELDS, OSCE_MATCHMAKING_ACTION_FIELDS, OSCE_STATION_FIELDS, } from '../../fragments';
4
4
  export const START_OSCE_MATCHMAKING = gql `
5
5
  mutation StartOsceMatchmaking($sessionId: String!) {
@@ -98,6 +98,43 @@ export const MARK_OSCE_MARKSHEET_MARK = gql `
98
98
  }
99
99
  }
100
100
  `;
101
+ export const getStationScore = (marks) => {
102
+ const MarkMap = {
103
+ [EPaceMarkType.SATISFACTORY]: 2,
104
+ [EPaceMarkType.BORDERLINE]: 1,
105
+ [EPaceMarkType.UN_SATISFACTORY]: 0,
106
+ };
107
+ if (!marks?.length) {
108
+ return {
109
+ total: 0,
110
+ userScore: 0,
111
+ };
112
+ }
113
+ const { total, userScore } = marks.reduce((acc, mark) => {
114
+ const choices = mark.osceStationMark?.choices;
115
+ const multiplier = mark.secondaryMark ? 2 : 1;
116
+ // Maximum possible score
117
+ acc.total += multiplier ? 4 : choices?.length ? 2 : 1;
118
+ if (choices) {
119
+ // paces product
120
+ acc.userScore += MarkMap[mark.mark] ?? 0;
121
+ if (mark.secondaryMark) {
122
+ acc.userScore += MarkMap[mark.secondaryMark] ?? 0;
123
+ }
124
+ }
125
+ else {
126
+ acc.userScore += mark.mark ? 1 : 0;
127
+ }
128
+ return acc;
129
+ }, {
130
+ total: 0,
131
+ userScore: 0,
132
+ });
133
+ return {
134
+ total,
135
+ userScore,
136
+ };
137
+ };
101
138
  export const optimisticMarkOsceMarksheetMark = (variables, productType) => {
102
139
  const data = {};
103
140
  if (productType === EProductType.PACES) {
@@ -165,6 +202,13 @@ export const updateCacheOnMarkOsceMarksheetMark = (cache, result, options) => {
165
202
  mark
166
203
  score
167
204
  secondaryMark
205
+ selectedChoice
206
+ osceStationMark {
207
+ id
208
+ choices {
209
+ score
210
+ }
211
+ }
168
212
  }
169
213
  }
170
214
  `,
@@ -172,10 +216,7 @@ export const updateCacheOnMarkOsceMarksheetMark = (cache, result, options) => {
172
216
  if (!marksheet?.marks?.length) {
173
217
  return;
174
218
  }
175
- const hasSecondaryMarks = marksheet.marks.some((m) => m.secondaryMark);
176
- const total = hasSecondaryMarks ? 2 * marksheet.marks.length : marksheet.marks.length;
177
- // const scored = marksheet.marks.filter(({ mark }) => Boolean(mark)).length;
178
- const userScore = marksheet.marks.reduce((sum, m) => sum + Number(m.score), 0);
219
+ const { total, userScore } = getStationScore(marksheet.marks);
179
220
  cache.modify({
180
221
  id: cache.identify({ id: marksheetId, __typename: 'OsceMarksheet' }),
181
222
  fields: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "2.6.272",
3
+ "version": "2.6.274",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",