@instructure/quiz-core 20.18.1-rc.1 → 20.18.1-rc.2

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.
@@ -14,8 +14,9 @@ export var handleExtraTime = function handleExtraTime(extraTimeInSeconds, endAt,
14
14
  var remainingTimeInMs = new Date(endAt) - Date.now();
15
15
  var remainingTimeInSeconds = Math.floor(remainingTimeInMs / 1000);
16
16
  var formattedExtraTimeText = formatTime(extraTimeInSeconds);
17
- updateTimeAction(remainingTimeInSeconds);
18
- notifyTimeAdded(formattedExtraTimeText);
17
+ var isUnlimited = endAt === null && extraTimeInSeconds === null;
18
+ updateTimeAction(remainingTimeInSeconds, !isUnlimited);
19
+ notifyTimeAdded(!isUnlimited, !isUnlimited ? formattedExtraTimeText : null);
19
20
  };
20
21
  export var parseJwt = function parseJwt(token) {
21
22
  try {
@@ -43,14 +44,13 @@ export var handleWebSocketMessage = function handleWebSocketMessage(webSocketMes
43
44
  return;
44
45
  }
45
46
 
46
- var extra_time_in_seconds = webSocketMessageData.extra_time_in_seconds;
47
- var end_at = webSocketMessageData.end_at;
47
+ var type = webSocketMessageData.type;
48
48
 
49
- if (!extra_time_in_seconds || !end_at) {
49
+ if (type !== 'accommodation_changed') {
50
50
  return;
51
51
  }
52
52
 
53
- handleExtraTimeFn(extra_time_in_seconds, end_at, boundTakingApiActions.updateTime, boundTakingApiActions.notifyTimeAdded);
53
+ handleExtraTimeFn(webSocketMessageData.extra_time_in_seconds, webSocketMessageData.end_at, boundTakingApiActions.updateTime, boundTakingApiActions.notifyTimeAdded);
54
54
  };
55
55
  export var createQuizTimerWebSocketMiddleware = function createQuizTimerWebSocketMiddleware() {
56
56
  var createWebsocketFn = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : createWebsocket;
@@ -59,13 +59,7 @@ export var createQuizTimerWebSocketMiddleware = function createQuizTimerWebSocke
59
59
  return function (store) {
60
60
  return function (next) {
61
61
  return function (action) {
62
- var addTimeToExistingQuizSessionsEnabled = featureOnFn('add_time_to_existing_quiz_sessions');
63
-
64
- if (!addTimeToExistingQuizSessionsEnabled) {
65
- return next(action);
66
- }
67
-
68
- if (action.type === SET_WS_TOKEN && socket === null) {
62
+ if (action.type === SET_WS_TOKEN && featureOnFn('add_time_to_existing_quiz_sessions') && socket === null) {
69
63
  var token = action.payload.wsToken;
70
64
  socket = initializeWebSocket(token, createWebsocketFn);
71
65
 
@@ -244,19 +244,20 @@ export function submitQuiz(quizSessionId) {
244
244
  }
245
245
  };
246
246
  }
247
- export function notifyTimeAdded(extraTime) {
247
+ export function notifyTimeAdded(isUnlimited, extraTime) {
248
248
  return function (dispatch) {
249
- return dispatch(addInfo(t('Your original time limit has been extended by { extraTime }', {
249
+ var message = isUnlimited ? t('Your original time limit has been extended by { extraTime }', {
250
250
  extraTime: extraTime
251
- })));
251
+ }) : t('Unlimited time accommodation has been added to your quiz');
252
+ return dispatch(addInfo(message));
252
253
  };
253
254
  }
254
- export function updateTime(timeInSeconds) {
255
+ export function updateTime(timeInSeconds, timerRunning) {
255
256
  return function (dispatch) {
256
257
  return dispatch(updateTimerInfo({
257
258
  timeLeftInSeconds: timeInSeconds,
258
- timerRunning: true,
259
- timeRecording: true
259
+ timerRunning: timerRunning,
260
+ timeRecording: false
260
261
  }));
261
262
  };
262
263
  }
@@ -30,8 +30,9 @@ var handleExtraTime = function handleExtraTime(extraTimeInSeconds, endAt, update
30
30
  var remainingTimeInMs = new Date(endAt) - Date.now();
31
31
  var remainingTimeInSeconds = Math.floor(remainingTimeInMs / 1000);
32
32
  var formattedExtraTimeText = (0, _formatTimespan.formatTime)(extraTimeInSeconds);
33
- updateTimeAction(remainingTimeInSeconds);
34
- notifyTimeAdded(formattedExtraTimeText);
33
+ var isUnlimited = endAt === null && extraTimeInSeconds === null;
34
+ updateTimeAction(remainingTimeInSeconds, !isUnlimited);
35
+ notifyTimeAdded(!isUnlimited, !isUnlimited ? formattedExtraTimeText : null);
35
36
  };
36
37
 
37
38
  exports.handleExtraTime = handleExtraTime;
@@ -68,14 +69,13 @@ var handleWebSocketMessage = function handleWebSocketMessage(webSocketMessage, b
68
69
  return;
69
70
  }
70
71
 
71
- var extra_time_in_seconds = webSocketMessageData.extra_time_in_seconds;
72
- var end_at = webSocketMessageData.end_at;
72
+ var type = webSocketMessageData.type;
73
73
 
74
- if (!extra_time_in_seconds || !end_at) {
74
+ if (type !== 'accommodation_changed') {
75
75
  return;
76
76
  }
77
77
 
78
- handleExtraTimeFn(extra_time_in_seconds, end_at, boundTakingApiActions.updateTime, boundTakingApiActions.notifyTimeAdded);
78
+ handleExtraTimeFn(webSocketMessageData.extra_time_in_seconds, webSocketMessageData.end_at, boundTakingApiActions.updateTime, boundTakingApiActions.notifyTimeAdded);
79
79
  };
80
80
 
81
81
  exports.handleWebSocketMessage = handleWebSocketMessage;
@@ -87,13 +87,7 @@ var createQuizTimerWebSocketMiddleware = function createQuizTimerWebSocketMiddle
87
87
  return function (store) {
88
88
  return function (next) {
89
89
  return function (action) {
90
- var addTimeToExistingQuizSessionsEnabled = featureOnFn('add_time_to_existing_quiz_sessions');
91
-
92
- if (!addTimeToExistingQuizSessionsEnabled) {
93
- return next(action);
94
- }
95
-
96
- if (action.type === _quizCommon.SET_WS_TOKEN && socket === null) {
90
+ if (action.type === _quizCommon.SET_WS_TOKEN && featureOnFn('add_time_to_existing_quiz_sessions') && socket === null) {
97
91
  var token = action.payload.wsToken;
98
92
  socket = initializeWebSocket(token, createWebsocketFn);
99
93
 
@@ -301,20 +301,21 @@ function submitQuiz(quizSessionId) {
301
301
  };
302
302
  }
303
303
 
304
- function notifyTimeAdded(extraTime) {
304
+ function notifyTimeAdded(isUnlimited, extraTime) {
305
305
  return function (dispatch) {
306
- return dispatch((0, _alerts.addInfo)((0, _formatMessage.default)('Your original time limit has been extended by { extraTime }', {
306
+ var message = isUnlimited ? (0, _formatMessage.default)('Your original time limit has been extended by { extraTime }', {
307
307
  extraTime: extraTime
308
- })));
308
+ }) : (0, _formatMessage.default)('Unlimited time accommodation has been added to your quiz');
309
+ return dispatch((0, _alerts.addInfo)(message));
309
310
  };
310
311
  }
311
312
 
312
- function updateTime(timeInSeconds) {
313
+ function updateTime(timeInSeconds, timerRunning) {
313
314
  return function (dispatch) {
314
315
  return dispatch((0, _taking.updateTimerInfo)({
315
316
  timeLeftInSeconds: timeInSeconds,
316
- timerRunning: true,
317
- timeRecording: true
317
+ timerRunning: timerRunning,
318
+ timeRecording: false
318
319
  }));
319
320
  };
320
321
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/quiz-core",
3
- "version": "20.18.1-rc.1+70dd69c4d",
3
+ "version": "20.18.1-rc.2+2937efc1f",
4
4
  "license": "MIT",
5
5
  "description": "The Quiz React SDK by Instructure Inc.",
6
6
  "author": "Instructure, Inc. Engineering and Product Design",
@@ -44,11 +44,11 @@
44
44
  "@instructure/emotion": "^8.51.0",
45
45
  "@instructure/grading-utils": "^1.0.0",
46
46
  "@instructure/outcomes-ui": "^3.2.2",
47
- "@instructure/quiz-common": "20.18.1-rc.1+70dd69c4d",
48
- "@instructure/quiz-i18n": "20.18.1-rc.1+70dd69c4d",
49
- "@instructure/quiz-interactions": "20.18.1-rc.1+70dd69c4d",
50
- "@instructure/quiz-number-input": "20.18.1-rc.1+70dd69c4d",
51
- "@instructure/quiz-rce": "20.18.1-rc.1+70dd69c4d",
47
+ "@instructure/quiz-common": "20.18.1-rc.2+2937efc1f",
48
+ "@instructure/quiz-i18n": "20.18.1-rc.2+2937efc1f",
49
+ "@instructure/quiz-interactions": "20.18.1-rc.2+2937efc1f",
50
+ "@instructure/quiz-number-input": "20.18.1-rc.2+2937efc1f",
51
+ "@instructure/quiz-rce": "20.18.1-rc.2+2937efc1f",
52
52
  "@instructure/ui-a11y-content": "^8.51.0",
53
53
  "@instructure/ui-alerts": "^8.51.0",
54
54
  "@instructure/ui-avatar": "^8.51.0",
@@ -111,7 +111,7 @@
111
111
  "file-saver": "~2.0.5",
112
112
  "humps": "^2.0.0",
113
113
  "immutable": "^3.8.1",
114
- "instructure-validations": "20.18.1-rc.1+70dd69c4d",
114
+ "instructure-validations": "20.18.1-rc.2+2937efc1f",
115
115
  "ipaddr.js": "^1.5.4",
116
116
  "isomorphic-fetch": "^2.2.0",
117
117
  "isuuid": "^0.1.0",
@@ -161,7 +161,7 @@
161
161
  "jquery": "^2.2.3",
162
162
  "karma-junit-reporter": "^2.0.1",
163
163
  "most-subject": "^5.3.0",
164
- "quiz-presets": "20.18.1-rc.1+70dd69c4d",
164
+ "quiz-presets": "20.18.1-rc.2+2937efc1f",
165
165
  "react": "^16.8.6",
166
166
  "react-addons-test-utils": "^15.6.2",
167
167
  "react-dom": "^16.8.6",
@@ -177,5 +177,5 @@
177
177
  "publishConfig": {
178
178
  "access": "public"
179
179
  },
180
- "gitHead": "70dd69c4d96b54c29d5adb229c7d6b7dad4f602c"
180
+ "gitHead": "2937efc1fed97381567c711156370de5fb0a7375"
181
181
  }