@quesmed/types 1.5.2 → 1.5.5

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.
@@ -64,6 +64,7 @@ export interface IOsceMarksheet {
64
64
  pausedAt: number | Date;
65
65
  timeRemaining: string;
66
66
  totalStationTime: string;
67
+ stage: EOsceStage;
67
68
  marks: IOsceMarksheetMark[];
68
69
  users: IOsceMarksheetUser[];
69
70
  members: IUser[];
@@ -87,9 +88,16 @@ export declare enum EOsceTimerState {
87
88
  PAUSE = 1,
88
89
  COMPLETED = 2
89
90
  }
91
+ export declare enum EOsceStage {
92
+ READING = 0,
93
+ STATION = 1,
94
+ FEEDBACK = 2
95
+ }
90
96
  export interface IOsceMarksheetTimer {
91
97
  osceMarksheetId: number;
92
98
  timeRemaining: string;
93
99
  totalStationTime: string;
100
+ stage: EOsceStage;
94
101
  state: EOsceTimerState;
95
102
  }
103
+ export declare function createTimerPayload(osceMarksheet: Partial<Omit<IOsceMarksheet, 'marks'>>): IOsceMarksheetTimer;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EOsceTimerState = exports.EOsceMarksheetState = exports.EOsceMarksheetAction = exports.EOsceRoles = void 0;
3
+ exports.createTimerPayload = exports.EOsceStage = exports.EOsceTimerState = exports.EOsceMarksheetState = exports.EOsceMarksheetAction = exports.EOsceRoles = void 0;
4
+ const utils_1 = require("../utils");
4
5
  var EOsceRoles;
5
6
  (function (EOsceRoles) {
6
7
  EOsceRoles[EOsceRoles["ALL"] = 0] = "ALL";
@@ -34,3 +35,65 @@ var EOsceTimerState;
34
35
  EOsceTimerState[EOsceTimerState["PAUSE"] = 1] = "PAUSE";
35
36
  EOsceTimerState[EOsceTimerState["COMPLETED"] = 2] = "COMPLETED";
36
37
  })(EOsceTimerState = exports.EOsceTimerState || (exports.EOsceTimerState = {}));
38
+ var EOsceStage;
39
+ (function (EOsceStage) {
40
+ EOsceStage[EOsceStage["READING"] = 0] = "READING";
41
+ EOsceStage[EOsceStage["STATION"] = 1] = "STATION";
42
+ EOsceStage[EOsceStage["FEEDBACK"] = 2] = "FEEDBACK";
43
+ })(EOsceStage = exports.EOsceStage || (exports.EOsceStage = {}));
44
+ function createTimerPayload(osceMarksheet) {
45
+ const payload = {
46
+ osceMarksheetId: osceMarksheet.id,
47
+ timeRemaining: '00:00',
48
+ totalStationTime: '00:00',
49
+ stage: EOsceStage.READING,
50
+ state: EOsceTimerState.PAUSE,
51
+ };
52
+ if (!osceMarksheet.startedAt ||
53
+ !osceMarksheet.endedAt ||
54
+ !osceMarksheet.readingTime ||
55
+ !osceMarksheet.stationTime ||
56
+ !osceMarksheet.feedbackTime) {
57
+ return payload;
58
+ }
59
+ payload.state = EOsceTimerState.START;
60
+ const stationDuration = osceMarksheet.readingTime +
61
+ (osceMarksheet.stationTime + osceMarksheet.feedbackTime) * 60;
62
+ payload.totalStationTime = (0, utils_1.printDuration)(stationDuration);
63
+ let endedAt;
64
+ if (typeof osceMarksheet.endedAt === 'number') {
65
+ endedAt = osceMarksheet.endedAt;
66
+ }
67
+ else {
68
+ endedAt = Math.floor(osceMarksheet.endedAt.getTime() / 1000);
69
+ }
70
+ // calculate duration from pause timestamp or from current time
71
+ let timeRemainingDuration = endedAt - Math.floor(Date.now() / 1000);
72
+ if (osceMarksheet.completed || timeRemainingDuration < 0) {
73
+ payload.state = EOsceTimerState.COMPLETED;
74
+ }
75
+ if (osceMarksheet.pausedAt) {
76
+ let pausedAt;
77
+ if (typeof osceMarksheet.pausedAt === 'number') {
78
+ pausedAt = osceMarksheet.pausedAt;
79
+ }
80
+ else {
81
+ pausedAt = Math.floor(osceMarksheet.pausedAt.getTime() / 1000);
82
+ }
83
+ timeRemainingDuration = endedAt - pausedAt;
84
+ payload.state = EOsceTimerState.PAUSE;
85
+ }
86
+ if (timeRemainingDuration > stationDuration - osceMarksheet.readingTime) {
87
+ payload.stage = EOsceStage.READING;
88
+ }
89
+ else if (timeRemainingDuration >
90
+ stationDuration - osceMarksheet.readingTime - osceMarksheet.stationTime * 60) {
91
+ payload.stage = EOsceStage.STATION;
92
+ }
93
+ else {
94
+ payload.stage = EOsceStage.FEEDBACK;
95
+ }
96
+ payload.timeRemaining = (0, utils_1.printDuration)(timeRemainingDuration);
97
+ return payload;
98
+ }
99
+ exports.createTimerPayload = createTimerPayload;
@@ -1,3 +1,4 @@
1
+ import { printDuration } from '../utils';
1
2
  export var EOsceRoles;
2
3
  (function (EOsceRoles) {
3
4
  EOsceRoles[EOsceRoles["ALL"] = 0] = "ALL";
@@ -31,3 +32,64 @@ export var EOsceTimerState;
31
32
  EOsceTimerState[EOsceTimerState["PAUSE"] = 1] = "PAUSE";
32
33
  EOsceTimerState[EOsceTimerState["COMPLETED"] = 2] = "COMPLETED";
33
34
  })(EOsceTimerState || (EOsceTimerState = {}));
35
+ export var EOsceStage;
36
+ (function (EOsceStage) {
37
+ EOsceStage[EOsceStage["READING"] = 0] = "READING";
38
+ EOsceStage[EOsceStage["STATION"] = 1] = "STATION";
39
+ EOsceStage[EOsceStage["FEEDBACK"] = 2] = "FEEDBACK";
40
+ })(EOsceStage || (EOsceStage = {}));
41
+ export function createTimerPayload(osceMarksheet) {
42
+ const payload = {
43
+ osceMarksheetId: osceMarksheet.id,
44
+ timeRemaining: '00:00',
45
+ totalStationTime: '00:00',
46
+ stage: EOsceStage.READING,
47
+ state: EOsceTimerState.PAUSE,
48
+ };
49
+ if (!osceMarksheet.startedAt ||
50
+ !osceMarksheet.endedAt ||
51
+ !osceMarksheet.readingTime ||
52
+ !osceMarksheet.stationTime ||
53
+ !osceMarksheet.feedbackTime) {
54
+ return payload;
55
+ }
56
+ payload.state = EOsceTimerState.START;
57
+ const stationDuration = osceMarksheet.readingTime +
58
+ (osceMarksheet.stationTime + osceMarksheet.feedbackTime) * 60;
59
+ payload.totalStationTime = printDuration(stationDuration);
60
+ let endedAt;
61
+ if (typeof osceMarksheet.endedAt === 'number') {
62
+ endedAt = osceMarksheet.endedAt;
63
+ }
64
+ else {
65
+ endedAt = Math.floor(osceMarksheet.endedAt.getTime() / 1000);
66
+ }
67
+ // calculate duration from pause timestamp or from current time
68
+ let timeRemainingDuration = endedAt - Math.floor(Date.now() / 1000);
69
+ if (osceMarksheet.completed || timeRemainingDuration < 0) {
70
+ payload.state = EOsceTimerState.COMPLETED;
71
+ }
72
+ if (osceMarksheet.pausedAt) {
73
+ let pausedAt;
74
+ if (typeof osceMarksheet.pausedAt === 'number') {
75
+ pausedAt = osceMarksheet.pausedAt;
76
+ }
77
+ else {
78
+ pausedAt = Math.floor(osceMarksheet.pausedAt.getTime() / 1000);
79
+ }
80
+ timeRemainingDuration = endedAt - pausedAt;
81
+ payload.state = EOsceTimerState.PAUSE;
82
+ }
83
+ if (timeRemainingDuration > stationDuration - osceMarksheet.readingTime) {
84
+ payload.stage = EOsceStage.READING;
85
+ }
86
+ else if (timeRemainingDuration >
87
+ stationDuration - osceMarksheet.readingTime - osceMarksheet.stationTime * 60) {
88
+ payload.stage = EOsceStage.STATION;
89
+ }
90
+ else {
91
+ payload.stage = EOsceStage.FEEDBACK;
92
+ }
93
+ payload.timeRemaining = printDuration(timeRemainingDuration);
94
+ return payload;
95
+ }
@@ -42,7 +42,7 @@ export interface IOsceStation {
42
42
  walkthroughPictures?: IOsceWalkthroughPicture[];
43
43
  }
44
44
  export interface IOsceStationItem extends IOsceStation {
45
- attempted: boolean;
45
+ lastOsceMarksheetId: Id;
46
46
  score: number;
47
47
  }
48
48
  export declare const OSCE_GLOBAL_RATING: {
package/models/User.d.ts CHANGED
@@ -5,6 +5,7 @@ import { IQuestion } from './Question';
5
5
  import { ISubscription } from './Subscription';
6
6
  import { ITopic } from './Topic';
7
7
  import { Id } from './Type';
8
+ export declare type IAccessLevel = 'subscriber' | 'administrator' | 'tutor';
8
9
  export declare type IClassYear = 'Year 1' | 'Year 2' | 'Year 3' | 'Year 4' | 'Year 5' | 'Graduated' | 'PhD' | 'BSc' | 'MSc' | 'Beta Tester';
9
10
  export declare const classYears: IClassYear[];
10
11
  export declare enum EClassYearGroup {
@@ -20,7 +21,7 @@ export interface IPayload {
20
21
  firstName: string;
21
22
  lastName: string;
22
23
  username: string;
23
- accessLevel: string;
24
+ accessLevel: IAccessLevel;
24
25
  tocAccepted: boolean;
25
26
  exp: number;
26
27
  stripeSubscriptionEndDate: number | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "1.5.2",
3
+ "version": "1.5.5",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -50,7 +50,7 @@ exports.OSCE_STATION_FIELDS = (0, client_1.gql) `
50
50
  }
51
51
 
52
52
  # user-specific keys
53
- # attempted
53
+ # lastOsceMarksheetId
54
54
  # score
55
55
  }
56
56
  `;
@@ -90,6 +90,7 @@ exports.OSCE_MARKSHEET_FIELDS = (0, client_1.gql) `
90
90
  pausedAt
91
91
  timeRemaining
92
92
  totalStationTime
93
+ stage
93
94
  marks {
94
95
  ...OsceMarksheetMarkFields
95
96
  }
@@ -47,7 +47,7 @@ export const OSCE_STATION_FIELDS = gql `
47
47
  }
48
48
 
49
49
  # user-specific keys
50
- # attempted
50
+ # lastOsceMarksheetId
51
51
  # score
52
52
  }
53
53
  `;
@@ -87,6 +87,7 @@ export const OSCE_MARKSHEET_FIELDS = gql `
87
87
  pausedAt
88
88
  timeRemaining
89
89
  totalStationTime
90
+ stage
90
91
  marks {
91
92
  ...OsceMarksheetMarkFields
92
93
  }
@@ -67,7 +67,6 @@ export declare const SAVE_OSCE_MARKSHEET: import("@apollo/client").DocumentNode;
67
67
  export interface ISaveOsceMarksheetVar {
68
68
  osceMarksheetId: Id;
69
69
  globalScore?: number;
70
- timeTaken?: number;
71
70
  feedback?: string;
72
71
  }
73
72
  export declare type ISaveOsceMarksheetData = RestrictedData<graphqlNormalize & IOsceMarksheet, 'saveOsceMarksheet'>;
@@ -168,14 +168,12 @@ exports.SAVE_OSCE_MARKSHEET = (0, client_1.gql) `
168
168
  $osceMarksheetId: Int!
169
169
  $feedback: String
170
170
  $globalScore: Int
171
- $timeTaken: Int
172
171
  ) {
173
172
  restricted {
174
173
  saveOsceMarksheet(
175
174
  osceMarksheetId: $osceMarksheetId
176
175
  feedback: $feedback
177
176
  globalScore: $globalScore
178
- timeTaken: $timeTaken
179
177
  ) {
180
178
  ...OsceMarksheetFields
181
179
  }
@@ -195,14 +193,12 @@ exports.END_OSCE_MARKSHEET = (0, client_1.gql) `
195
193
  $osceMarksheetId: Int!
196
194
  $feedback: String
197
195
  $globalScore: Int
198
- $timeTaken: Int
199
196
  ) {
200
197
  restricted {
201
198
  endOsceMarksheet(
202
199
  osceMarksheetId: $osceMarksheetId
203
200
  feedback: $feedback
204
201
  globalScore: $globalScore
205
- timeTaken: $timeTaken
206
202
  ) {
207
203
  ...OsceMarksheetFields
208
204
  }
@@ -164,14 +164,12 @@ export const SAVE_OSCE_MARKSHEET = gql `
164
164
  $osceMarksheetId: Int!
165
165
  $feedback: String
166
166
  $globalScore: Int
167
- $timeTaken: Int
168
167
  ) {
169
168
  restricted {
170
169
  saveOsceMarksheet(
171
170
  osceMarksheetId: $osceMarksheetId
172
171
  feedback: $feedback
173
172
  globalScore: $globalScore
174
- timeTaken: $timeTaken
175
173
  ) {
176
174
  ...OsceMarksheetFields
177
175
  }
@@ -191,14 +189,12 @@ export const END_OSCE_MARKSHEET = gql `
191
189
  $osceMarksheetId: Int!
192
190
  $feedback: String
193
191
  $globalScore: Int
194
- $timeTaken: Int
195
192
  ) {
196
193
  restricted {
197
194
  endOsceMarksheet(
198
195
  osceMarksheetId: $osceMarksheetId
199
196
  feedback: $feedback
200
197
  globalScore: $globalScore
201
- timeTaken: $timeTaken
202
198
  ) {
203
199
  ...OsceMarksheetFields
204
200
  }
@@ -70,7 +70,7 @@ exports.OSCE_STATIONS = (0, client_1.gql) `
70
70
  topicIds: $topicIds
71
71
  ) {
72
72
  ...OsceStationFields
73
- attempted
73
+ lastOsceMarksheetId
74
74
  score
75
75
  }
76
76
  }
@@ -103,7 +103,7 @@ exports.SEARCH_OSCE_STATIONS = (0, client_1.gql) `
103
103
  restricted {
104
104
  searchOsceStations(search: $search) {
105
105
  ...OsceStationFields
106
- attempted
106
+ lastOsceMarksheetId
107
107
  score
108
108
  }
109
109
  }
@@ -67,7 +67,7 @@ export const OSCE_STATIONS = gql `
67
67
  topicIds: $topicIds
68
68
  ) {
69
69
  ...OsceStationFields
70
- attempted
70
+ lastOsceMarksheetId
71
71
  score
72
72
  }
73
73
  }
@@ -100,7 +100,7 @@ export const SEARCH_OSCE_STATIONS = gql `
100
100
  restricted {
101
101
  searchOsceStations(search: $search) {
102
102
  ...OsceStationFields
103
- attempted
103
+ lastOsceMarksheetId
104
104
  score
105
105
  }
106
106
  }
@@ -142,7 +142,7 @@ const osceStationReplicationQuery = `query OsceStationReplication($lastId: Strin
142
142
  }
143
143
 
144
144
  # user-specific keys
145
- # attempted
145
+ # lastOsceMarksheetId
146
146
  # score
147
147
  }
148
148
 
@@ -137,7 +137,7 @@ const osceStationReplicationQuery = `query OsceStationReplication($lastId: Strin
137
137
  }
138
138
 
139
139
  # user-specific keys
140
- # attempted
140
+ # lastOsceMarksheetId
141
141
  # score
142
142
  }
143
143
 
@@ -1,6 +1,5 @@
1
- import { EOsceMarksheetAction, EOsceRoles, IClassYear, Id, IOsceMarksheetTimer, IOsceMarksheetUser, IUser } from '../../models';
1
+ import { EClassYearGroup, EOsceMarksheetAction, EOsceRoles, IAccessLevel, IClassYear, Id, IOsceMarksheetTimer, IOsceMarksheetUser, IUser } from '../../models';
2
2
  import { RootData } from '../types';
3
- import { EClassYearGroup } from './../../models/User';
4
3
  export declare const OSCE_ROLE_CHANGE_KEY = "OSCE_ROLE_CHANGE";
5
4
  export declare const OSCE_MARKSHEET_ACTION_KEY = "OSCE_MARKSHEET_ACTION";
6
5
  export declare const OSCE_MARKSHEET_TIMER_KEY = "OSCE_MARKSHEET_TIMER";
@@ -44,6 +43,7 @@ export interface IOsceMatchmakingAction {
44
43
  userId: Id;
45
44
  classYear: IClassYear;
46
45
  classYearGroup: EClassYearGroup;
46
+ accessLevel: IAccessLevel;
47
47
  lastSyncAt: number;
48
48
  startedAt: number;
49
49
  grouped: boolean;
@@ -101,6 +101,7 @@ exports.OSCE_MARKSHEET_TIMER = (0, client_1.gql) `
101
101
  osceMarksheetId
102
102
  timeRemaining
103
103
  totalStationTime
104
+ stage
104
105
  state
105
106
  }
106
107
  }
@@ -97,6 +97,7 @@ export const OSCE_MARKSHEET_TIMER = gql `
97
97
  osceMarksheetId
98
98
  timeRemaining
99
99
  totalStationTime
100
+ stage
100
101
  state
101
102
  }
102
103
  }
package/utils/index.d.ts CHANGED
@@ -6,3 +6,4 @@ export * from './webSocketLink';
6
6
  export * from './wordsToNumber';
7
7
  import uuid from './uuid4';
8
8
  export declare const Uuid4: typeof uuid;
9
+ export declare function printDuration(duration: number): string;
package/utils/index.js CHANGED
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
14
  };
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.Uuid4 = void 0;
16
+ exports.printDuration = exports.Uuid4 = void 0;
17
17
  __exportStar(require("./commonFunctions"), exports);
18
18
  __exportStar(require("./lightgallery"), exports);
19
19
  __exportStar(require("./offlineLink"), exports);
@@ -22,3 +22,21 @@ __exportStar(require("./webSocketLink"), exports);
22
22
  __exportStar(require("./wordsToNumber"), exports);
23
23
  const uuid4_1 = __importDefault(require("./uuid4"));
24
24
  exports.Uuid4 = uuid4_1.default;
25
+ function printDuration(duration) {
26
+ let timeRemainingMins = Math.floor(duration / 60);
27
+ if (timeRemainingMins < 0) {
28
+ timeRemainingMins = 0;
29
+ }
30
+ const timeRemainingMinsStr = timeRemainingMins >= 10
31
+ ? timeRemainingMins.toString()
32
+ : `0${timeRemainingMins}`;
33
+ let timeRemainingSecs = duration % 60;
34
+ if (timeRemainingSecs < 0) {
35
+ timeRemainingSecs = 0;
36
+ }
37
+ const timeRemainingSecsStr = timeRemainingSecs >= 10
38
+ ? timeRemainingSecs.toString()
39
+ : `0${timeRemainingSecs}`;
40
+ return `${timeRemainingMinsStr}:${timeRemainingSecsStr}`;
41
+ }
42
+ exports.printDuration = printDuration;
package/utils/index.mjs CHANGED
@@ -6,3 +6,20 @@ export * from './webSocketLink';
6
6
  export * from './wordsToNumber';
7
7
  import uuid from './uuid4';
8
8
  export const Uuid4 = uuid;
9
+ export function printDuration(duration) {
10
+ let timeRemainingMins = Math.floor(duration / 60);
11
+ if (timeRemainingMins < 0) {
12
+ timeRemainingMins = 0;
13
+ }
14
+ const timeRemainingMinsStr = timeRemainingMins >= 10
15
+ ? timeRemainingMins.toString()
16
+ : `0${timeRemainingMins}`;
17
+ let timeRemainingSecs = duration % 60;
18
+ if (timeRemainingSecs < 0) {
19
+ timeRemainingSecs = 0;
20
+ }
21
+ const timeRemainingSecsStr = timeRemainingSecs >= 10
22
+ ? timeRemainingSecs.toString()
23
+ : `0${timeRemainingSecs}`;
24
+ return `${timeRemainingMinsStr}:${timeRemainingSecsStr}`;
25
+ }