@instructure/quiz-core 20.16.1-rc.6 → 20.16.1-rc.8

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.
@@ -1,19 +1,21 @@
1
1
  import { v4 as uuid } from 'uuid';
2
- import { ADD_ALERT, REMOVE_ALERT, DEFAULT_ALERT_TIME } from '@instructure/quiz-common';
2
+ import { ADD_ALERT, REMOVE_ALERT, DEFAULT_ALERT_TIME, ASSERTIVE } from '@instructure/quiz-common';
3
3
  export function addAlert(_ref) {
4
4
  var message = _ref.message,
5
5
  variant = _ref.variant,
6
6
  _ref$removeIn = _ref.removeIn,
7
7
  removeIn = _ref$removeIn === void 0 ? DEFAULT_ALERT_TIME : _ref$removeIn,
8
8
  _ref$guid = _ref.guid,
9
- guid = _ref$guid === void 0 ? uuid() : _ref$guid;
9
+ guid = _ref$guid === void 0 ? uuid() : _ref$guid,
10
+ politeness = _ref.politeness;
10
11
  return {
11
12
  type: ADD_ALERT,
12
13
  payload: {
13
14
  message: message,
14
15
  removeIn: removeIn,
15
16
  uuid: guid,
16
- variant: variant
17
+ variant: variant,
18
+ politeness: politeness
17
19
  }
18
20
  };
19
21
  }
@@ -45,10 +47,12 @@ export function addInfo(message) {
45
47
  });
46
48
  }
47
49
  export function screenreaderNotification(message) {
50
+ var politeness = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ASSERTIVE;
48
51
  return addAlert({
49
52
  message: message,
50
53
  variant: 'screenreader',
51
- removeIn: 2000
54
+ removeIn: 2000,
55
+ politeness: politeness
52
56
  });
53
57
  }
54
58
  export function removeAlert(uuid) {
@@ -4,12 +4,14 @@ import { removeAlert } from "../../actions/alerts.js";
4
4
  import Alert from "../../records/Alert.js";
5
5
  import Alerts from "./presenter.js";
6
6
 
7
- var mapStateToProps = function mapStateToProps(state) {
7
+ var mapStateToProps = function mapStateToProps(state, props) {
8
8
  var alerts = state.get('alerts', Map());
9
9
  return {
10
10
  alerts: alerts.map(function (data) {
11
11
  return new Alert(data);
12
- }).valueSeq().toList()
12
+ }).valueSeq().toList().filter(function (alert) {
13
+ return props.politeness === alert.politeness;
14
+ })
13
15
  };
14
16
  };
15
17
 
@@ -11,6 +11,7 @@ import PropTypes from 'prop-types';
11
11
  import partial from 'lodash/partial';
12
12
  import { ScreenReaderContent } from '@instructure/ui-a11y-content';
13
13
  import { IconClockLine, IconClockSolid, IconArrowOpenStartLine } from '@instructure/ui-icons';
14
+ import * as platform from 'platform';
14
15
  import { Button } from '@instructure/ui-buttons';
15
16
  import { TopNavBar } from '@instructure/ui-top-nav-bar';
16
17
  import { View } from '@instructure/ui-view';
@@ -111,7 +112,10 @@ export var Timer = (_dec = withStyle(generateStyle, generateComponentTheme), _de
111
112
  }, {
112
113
  key: "renderHelpScreenreaderText",
113
114
  value: function renderHelpScreenreaderText() {
114
- return jsx(ScreenReaderContent, null, t('During the quiz, press Alt+Shift+T to have the remaining time read'));
115
+ var shortcutKey = platform.os.toString().startsWith('OS X') ? 'Option+Shift+T' : 'Alt+Shift+T';
116
+ return jsx(ScreenReaderContent, null, t('During the quiz, press {shortcutKey} to have the remaining time read', {
117
+ shortcutKey: shortcutKey
118
+ }));
115
119
  }
116
120
  }, {
117
121
  key: "renderMinimizedTimer",
@@ -17,6 +17,7 @@ export var Alert = /*#__PURE__*/function (_Record) {
17
17
  }(Record({
18
18
  message: null,
19
19
  uuid: null,
20
- variant: 'info'
20
+ variant: 'info',
21
+ politeness: 'assertive'
21
22
  }));
22
23
  export default Alert;
@@ -1,17 +1,29 @@
1
1
  import React from 'react';
2
2
  import ReactDOM from 'react-dom';
3
- import { liveRegion } from '@instructure/quiz-common';
3
+ import { liveRegion, politeLiveRegion, POLITE, ASSERTIVE } from '@instructure/quiz-common';
4
4
  import { Provider } from "../react-redux.js";
5
5
  import Alerts from "../components/alerts/index.js"; // alert has to be in the html on render in
6
6
  // order for screenreaders to pick up on role="alert",
7
7
  // so we're rendering a sub-app into it so that so that
8
8
  // we dont accidentally remove it with react
9
9
 
10
- var _ref = /*#__PURE__*/React.createElement(Alerts, null);
10
+ var _ref = /*#__PURE__*/React.createElement(Alerts, {
11
+ politeness: ASSERTIVE
12
+ });
13
+
14
+ var _ref2 = /*#__PURE__*/React.createElement(Alerts, {
15
+ politeness: POLITE
16
+ });
11
17
 
12
18
  export function renderAlerts(store) {
13
19
  ReactDOM.render( /*#__PURE__*/React.createElement(Provider, {
14
20
  store: store
15
21
  }, _ref), liveRegion());
22
+
23
+ if (politeLiveRegion()) {
24
+ ReactDOM.render( /*#__PURE__*/React.createElement(Provider, {
25
+ store: store
26
+ }, _ref2), politeLiveRegion());
27
+ }
16
28
  }
17
29
  export default renderAlerts;
@@ -15,7 +15,7 @@ import { screenreaderNotification } from "../../common/actions/alerts.js";
15
15
  import Item from "../../common/records/Item.js";
16
16
  import { featureOn } from "../../common/util/featureCheck.js";
17
17
  import { fetchLogger } from "../../common/kinesis/QuizEventsLogger.js";
18
- import { STUDENT_ACCESS_CODE_STATUS } from '@instructure/quiz-common';
18
+ import { POLITE, STUDENT_ACCESS_CODE_STATUS } from '@instructure/quiz-common';
19
19
  import * as uiActions from "../../common/actions/ui.js";
20
20
  import { fetchQuizSession, fetchResumeData, fetchTime, recordTime, singleResponseSubmit, submitQuizSession, submitStudentAccessCode as submitStudentAccessCodeApi, takeQuizSession } from "../../common/api/quizSessions.js";
21
21
  import { getSessionItems, handleQuizSessionFetch } from "../../common/actions/quizSessions.js";
@@ -58,7 +58,7 @@ export var submitStudentAccessCode = function submitStudentAccessCode(quizSessio
58
58
  dispatch(uiActions.set(STUDENT_ACCESS_CODE_STATUS, sessionData.accepted_student_access_code));
59
59
 
60
60
  if (sessionData.accepted_student_access_code) {
61
- dispatch(screenreaderNotification(t('Access code successful. You may now begin this assessment')));
61
+ dispatch(screenreaderNotification(t('Access code successful. You may now begin this assessment'), POLITE));
62
62
  } else {
63
63
  dispatch(screenreaderNotification(t('Invalid access code')));
64
64
  }
@@ -21,14 +21,16 @@ function addAlert(_ref) {
21
21
  _ref$removeIn = _ref.removeIn,
22
22
  removeIn = _ref$removeIn === void 0 ? _quizCommon.DEFAULT_ALERT_TIME : _ref$removeIn,
23
23
  _ref$guid = _ref.guid,
24
- guid = _ref$guid === void 0 ? (0, _uuid.v4)() : _ref$guid;
24
+ guid = _ref$guid === void 0 ? (0, _uuid.v4)() : _ref$guid,
25
+ politeness = _ref.politeness;
25
26
  return {
26
27
  type: _quizCommon.ADD_ALERT,
27
28
  payload: {
28
29
  message: message,
29
30
  removeIn: removeIn,
30
31
  uuid: guid,
31
- variant: variant
32
+ variant: variant,
33
+ politeness: politeness
32
34
  }
33
35
  };
34
36
  }
@@ -65,10 +67,12 @@ function addInfo(message) {
65
67
  }
66
68
 
67
69
  function screenreaderNotification(message) {
70
+ var politeness = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : _quizCommon.ASSERTIVE;
68
71
  return addAlert({
69
72
  message: message,
70
73
  variant: 'screenreader',
71
- removeIn: 2000
74
+ removeIn: 2000,
75
+ politeness: politeness
72
76
  });
73
77
  }
74
78
 
@@ -17,12 +17,14 @@ var _Alert = _interopRequireDefault(require("../../records/Alert.js"));
17
17
 
18
18
  var _presenter = _interopRequireDefault(require("./presenter.js"));
19
19
 
20
- var mapStateToProps = function mapStateToProps(state) {
20
+ var mapStateToProps = function mapStateToProps(state, props) {
21
21
  var alerts = state.get('alerts', (0, _immutable.Map)());
22
22
  return {
23
23
  alerts: alerts.map(function (data) {
24
24
  return new _Alert.default(data);
25
- }).valueSeq().toList()
25
+ }).valueSeq().toList().filter(function (alert) {
26
+ return props.politeness === alert.politeness;
27
+ })
26
28
  };
27
29
  };
28
30
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
@@ -25,6 +27,8 @@ var _uiA11yContent = require("@instructure/ui-a11y-content");
25
27
 
26
28
  var _uiIcons = require("@instructure/ui-icons");
27
29
 
30
+ var platform = _interopRequireWildcard(require("platform"));
31
+
28
32
  var _uiButtons = require("@instructure/ui-buttons");
29
33
 
30
34
  var _uiTopNavBar = require("@instructure/ui-top-nav-bar");
@@ -135,7 +139,10 @@ var Timer = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
135
139
  }, {
136
140
  key: "renderHelpScreenreaderText",
137
141
  value: function renderHelpScreenreaderText() {
138
- return (0, _emotion.jsx)(_uiA11yContent.ScreenReaderContent, null, (0, _formatMessage.default)('During the quiz, press Alt+Shift+T to have the remaining time read'));
142
+ var shortcutKey = platform.os.toString().startsWith('OS X') ? 'Option+Shift+T' : 'Alt+Shift+T';
143
+ return (0, _emotion.jsx)(_uiA11yContent.ScreenReaderContent, null, (0, _formatMessage.default)('During the quiz, press {shortcutKey} to have the remaining time read', {
144
+ shortcutKey: shortcutKey
145
+ }));
139
146
  }
140
147
  }, {
141
148
  key: "renderMinimizedTimer",
@@ -29,7 +29,8 @@ var Alert = /*#__PURE__*/function (_Record) {
29
29
  }((0, _immutable.Record)({
30
30
  message: null,
31
31
  uuid: null,
32
- variant: 'info'
32
+ variant: 'info',
33
+ politeness: 'assertive'
33
34
  }));
34
35
 
35
36
  exports.Alert = Alert;
@@ -18,7 +18,13 @@ var _reactRedux = require("../react-redux.js");
18
18
 
19
19
  var _index = _interopRequireDefault(require("../components/alerts/index.js"));
20
20
 
21
- var _ref = /*#__PURE__*/_react.default.createElement(_index.default, null);
21
+ var _ref = /*#__PURE__*/_react.default.createElement(_index.default, {
22
+ politeness: _quizCommon.ASSERTIVE
23
+ });
24
+
25
+ var _ref2 = /*#__PURE__*/_react.default.createElement(_index.default, {
26
+ politeness: _quizCommon.POLITE
27
+ });
22
28
 
23
29
  // alert has to be in the html on render in
24
30
  // order for screenreaders to pick up on role="alert",
@@ -28,6 +34,12 @@ function renderAlerts(store) {
28
34
  _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_reactRedux.Provider, {
29
35
  store: store
30
36
  }, _ref), (0, _quizCommon.liveRegion)());
37
+
38
+ if ((0, _quizCommon.politeLiveRegion)()) {
39
+ _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_reactRedux.Provider, {
40
+ store: store
41
+ }, _ref2), (0, _quizCommon.politeLiveRegion)());
42
+ }
31
43
  }
32
44
 
33
45
  var _default = renderAlerts;
@@ -100,7 +100,7 @@ var submitStudentAccessCode = function submitStudentAccessCode(quizSessionId, ac
100
100
  dispatch(uiActions.set(_quizCommon.STUDENT_ACCESS_CODE_STATUS, sessionData.accepted_student_access_code));
101
101
 
102
102
  if (sessionData.accepted_student_access_code) {
103
- dispatch((0, _alerts.screenreaderNotification)((0, _formatMessage.default)('Access code successful. You may now begin this assessment')));
103
+ dispatch((0, _alerts.screenreaderNotification)((0, _formatMessage.default)('Access code successful. You may now begin this assessment'), _quizCommon.POLITE));
104
104
  } else {
105
105
  dispatch((0, _alerts.screenreaderNotification)((0, _formatMessage.default)('Invalid access code')));
106
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/quiz-core",
3
- "version": "20.16.1-rc.6+34f8d91a7",
3
+ "version": "20.16.1-rc.8+80dd509d0",
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.16.1-rc.6+34f8d91a7",
48
- "@instructure/quiz-i18n": "20.16.1-rc.6+34f8d91a7",
49
- "@instructure/quiz-interactions": "20.16.1-rc.6+34f8d91a7",
50
- "@instructure/quiz-number-input": "20.16.1-rc.6+34f8d91a7",
51
- "@instructure/quiz-rce": "20.16.1-rc.6+34f8d91a7",
47
+ "@instructure/quiz-common": "20.16.1-rc.8+80dd509d0",
48
+ "@instructure/quiz-i18n": "20.16.1-rc.8+80dd509d0",
49
+ "@instructure/quiz-interactions": "20.16.1-rc.8+80dd509d0",
50
+ "@instructure/quiz-number-input": "20.16.1-rc.8+80dd509d0",
51
+ "@instructure/quiz-rce": "20.16.1-rc.8+80dd509d0",
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.16.1-rc.6+34f8d91a7",
114
+ "instructure-validations": "20.16.1-rc.8+80dd509d0",
115
115
  "ipaddr.js": "^1.5.4",
116
116
  "isomorphic-fetch": "^2.2.0",
117
117
  "isuuid": "^0.1.0",
@@ -163,7 +163,7 @@
163
163
  "jquery": "^2.2.3",
164
164
  "karma-junit-reporter": "^2.0.1",
165
165
  "most-subject": "^5.3.0",
166
- "quiz-presets": "20.16.1-rc.6+34f8d91a7",
166
+ "quiz-presets": "20.16.1-rc.8+80dd509d0",
167
167
  "react": "^16.8.6",
168
168
  "react-addons-test-utils": "^15.6.2",
169
169
  "react-dom": "^16.8.6",
@@ -179,5 +179,5 @@
179
179
  "publishConfig": {
180
180
  "access": "public"
181
181
  },
182
- "gitHead": "34f8d91a721ddb30f72cf27aac15ee36b03a6c7a"
182
+ "gitHead": "80dd509d088767c8d222f534bbf703a95c183760"
183
183
  }