@instructure/quiz-core 17.34.0 → 17.34.1-rc.0

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.
@@ -2,21 +2,23 @@ import { bindActionCreators } from 'redux';
2
2
  import { Map } from 'immutable';
3
3
  import { connect } from "../../../react-redux.js";
4
4
  import { PrintTrigger as PrintTriggerPresenter } from "./presenter.js";
5
- import { PRINT_FONT_SIZE_MODAL } from '@instructure/quiz-common';
5
+ import { PRINT_FONT_SIZE_MODAL, QUIZ_SESSION_GRADE_SCOPE } from '@instructure/quiz-common';
6
6
  import * as printingActions from "../../../actions/printing.js";
7
7
  import * as modalActions from "../../../actions/modal.js";
8
8
  import * as quizEntriesApiActions from "../../../../building/api/quizEntries.js";
9
9
  import { featureOn } from "../../../util/featureCheck.js";
10
+ import { getConfigTokenScope } from "../../../selectors/config.js";
10
11
  export function mapStateToProps(state) {
11
12
  return {
13
+ activeQuizId: state.getIn(['quizzes', 'activeQuizId']),
12
14
  appContainer: state.getIn(['ui', 'appContainer']),
13
15
  asyncSampleItemsEnabled: featureOn('async_sample_items'),
14
16
  bankQuizEntryIds: state.get('quizEntries', Map()).filter(function (quizEntry) {
15
17
  return quizEntry.get('entryType') === 'Bank';
16
18
  }).keySeq().toArray(),
19
+ isGrading: getConfigTokenScope(state) === QUIZ_SESSION_GRADE_SCOPE,
17
20
  printFontSizeModalOpen: state.getIn(['modal', 'isOpen']) === PRINT_FONT_SIZE_MODAL,
18
- persistedPrintFontSize: state.getIn(['printing', 'fontSizePreference']),
19
- activeQuizId: state.getIn(['quizzes', 'activeQuizId'])
21
+ persistedPrintFontSize: state.getIn(['printing', 'fontSizePreference'])
20
22
  };
21
23
  }
22
24
 
@@ -42,7 +42,7 @@ export var PrintTrigger = /*#__PURE__*/function (_Component) {
42
42
 
43
43
  var sampleItemFetchPromises = [];
44
44
 
45
- if (_this.props.asyncSampleItemsEnabled) {
45
+ if (_this.props.asyncSampleItemsEnabled && !_this.props.isGrading) {
46
46
  var _this$props = _this.props,
47
47
  activeQuizId = _this$props.activeQuizId,
48
48
  bankQuizEntryIds = _this$props.bankQuizEntryIds,
@@ -134,6 +134,7 @@ PrintTrigger.propTypes = {
134
134
  bankQuizEntryIds: PropTypes.arrayOf(PropTypes.string),
135
135
  closePrintFontSizeModal: PropTypes.func.isRequired,
136
136
  getSampleItemsForQuizEntry: PropTypes.func.isRequired,
137
+ isGrading: PropTypes.bool,
137
138
  navigateToPreviewPrint: PropTypes.func,
138
139
  openPrintFontSizeModal: PropTypes.func.isRequired,
139
140
  persistedPrintFontSize: PropTypes.string,
@@ -146,6 +147,7 @@ PrintTrigger.defaultProps = {
146
147
  appContainer: null,
147
148
  asyncSampleItemsEnabled: false,
148
149
  bankQuizEntryIds: [],
150
+ isGrading: false,
149
151
  persistedPrintFontSize: 'medium',
150
152
  navigateToPreviewPrint: function navigateToPreviewPrint() {}
151
153
  };
@@ -0,0 +1,14 @@
1
+ import jwt from 'jwt-simple';
2
+
3
+ function decodeToken(token) {
4
+ try {
5
+ return jwt.decode(token, '', true) || {};
6
+ } catch (e) {
7
+ return {};
8
+ }
9
+ }
10
+
11
+ export function getConfigTokenScope(state) {
12
+ var token = state.getIn(['config', 'userToken']);
13
+ return decodeToken(token).scope;
14
+ }
@@ -26,16 +26,19 @@ var quizEntriesApiActions = _interopRequireWildcard(require("../../../../buildin
26
26
 
27
27
  var _featureCheck = require("../../../util/featureCheck.js");
28
28
 
29
+ var _config = require("../../../selectors/config.js");
30
+
29
31
  function mapStateToProps(state) {
30
32
  return {
33
+ activeQuizId: state.getIn(['quizzes', 'activeQuizId']),
31
34
  appContainer: state.getIn(['ui', 'appContainer']),
32
35
  asyncSampleItemsEnabled: (0, _featureCheck.featureOn)('async_sample_items'),
33
36
  bankQuizEntryIds: state.get('quizEntries', (0, _immutable.Map)()).filter(function (quizEntry) {
34
37
  return quizEntry.get('entryType') === 'Bank';
35
38
  }).keySeq().toArray(),
39
+ isGrading: (0, _config.getConfigTokenScope)(state) === _quizCommon.QUIZ_SESSION_GRADE_SCOPE,
36
40
  printFontSizeModalOpen: state.getIn(['modal', 'isOpen']) === _quizCommon.PRINT_FONT_SIZE_MODAL,
37
- persistedPrintFontSize: state.getIn(['printing', 'fontSizePreference']),
38
- activeQuizId: state.getIn(['quizzes', 'activeQuizId'])
41
+ persistedPrintFontSize: state.getIn(['printing', 'fontSizePreference'])
39
42
  };
40
43
  }
41
44
 
@@ -67,7 +67,7 @@ var PrintTrigger = /*#__PURE__*/function (_Component) {
67
67
 
68
68
  var sampleItemFetchPromises = [];
69
69
 
70
- if (_this.props.asyncSampleItemsEnabled) {
70
+ if (_this.props.asyncSampleItemsEnabled && !_this.props.isGrading) {
71
71
  var _this$props = _this.props,
72
72
  activeQuizId = _this$props.activeQuizId,
73
73
  bankQuizEntryIds = _this$props.bankQuizEntryIds,
@@ -160,6 +160,7 @@ PrintTrigger.propTypes = {
160
160
  bankQuizEntryIds: _propTypes.default.arrayOf(_propTypes.default.string),
161
161
  closePrintFontSizeModal: _propTypes.default.func.isRequired,
162
162
  getSampleItemsForQuizEntry: _propTypes.default.func.isRequired,
163
+ isGrading: _propTypes.default.bool,
163
164
  navigateToPreviewPrint: _propTypes.default.func,
164
165
  openPrintFontSizeModal: _propTypes.default.func.isRequired,
165
166
  persistedPrintFontSize: _propTypes.default.string,
@@ -172,6 +173,7 @@ PrintTrigger.defaultProps = {
172
173
  appContainer: null,
173
174
  asyncSampleItemsEnabled: false,
174
175
  bankQuizEntryIds: [],
176
+ isGrading: false,
175
177
  persistedPrintFontSize: 'medium',
176
178
  navigateToPreviewPrint: function navigateToPreviewPrint() {}
177
179
  };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.getConfigTokenScope = getConfigTokenScope;
9
+
10
+ var _jwtSimple = _interopRequireDefault(require("jwt-simple"));
11
+
12
+ function decodeToken(token) {
13
+ try {
14
+ return _jwtSimple.default.decode(token, '', true) || {};
15
+ } catch (e) {
16
+ return {};
17
+ }
18
+ }
19
+
20
+ function getConfigTokenScope(state) {
21
+ var token = state.getIn(['config', 'userToken']);
22
+ return decodeToken(token).scope;
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/quiz-core",
3
- "version": "17.34.0",
3
+ "version": "17.34.1-rc.0+58fac0c00",
4
4
  "license": "MIT",
5
5
  "description": "The Quiz React SDK by Instructure Inc.",
6
6
  "author": "Instructure, Inc. Engineering and Product Design",
@@ -41,11 +41,11 @@
41
41
  ],
42
42
  "dependencies": {
43
43
  "@instructure/outcomes-ui": "^2.1.2",
44
- "@instructure/quiz-common": "^17.34.0",
45
- "@instructure/quiz-i18n": "^17.34.0",
46
- "@instructure/quiz-interactions": "^17.34.0",
47
- "@instructure/quiz-number-input": "^17.34.0",
48
- "@instructure/quiz-rce": "^17.34.0",
44
+ "@instructure/quiz-common": "17.34.1-rc.0+58fac0c00",
45
+ "@instructure/quiz-i18n": "17.34.1-rc.0+58fac0c00",
46
+ "@instructure/quiz-interactions": "17.34.1-rc.0+58fac0c00",
47
+ "@instructure/quiz-number-input": "17.34.1-rc.0+58fac0c00",
48
+ "@instructure/quiz-rce": "17.34.1-rc.0+58fac0c00",
49
49
  "@instructure/ui-a11y-content": "^7.20.0",
50
50
  "@instructure/ui-alerts": "^7.20.0",
51
51
  "@instructure/ui-avatar": "^7.20.0",
@@ -106,7 +106,7 @@
106
106
  "eventemitter3": "^3.1.0",
107
107
  "humps": "^2.0.0",
108
108
  "immutable": "^3.8.1",
109
- "instructure-validations": "^17.34.0",
109
+ "instructure-validations": "17.34.1-rc.0+58fac0c00",
110
110
  "ipaddr.js": "^1.5.4",
111
111
  "isomorphic-fetch": "^2.2.0",
112
112
  "isuuid": "^0.1.0",
@@ -137,7 +137,7 @@
137
137
  "uuid": "^3.2.1"
138
138
  },
139
139
  "devDependencies": {
140
- "@instructure/quiz-scripts": "^17.34.0",
140
+ "@instructure/quiz-scripts": "17.34.1-rc.0+58fac0c00",
141
141
  "@instructure/ui-axe-check": "^7.20.0",
142
142
  "@instructure/ui-babel-preset": "^7.20.0",
143
143
  "@instructure/ui-karma-config": "^7.20.0",
@@ -156,7 +156,7 @@
156
156
  "intl": "^1.2.4",
157
157
  "jquery": "^2.2.3",
158
158
  "most-subject": "^5.3.0",
159
- "quiz-presets": "^17.34.0",
159
+ "quiz-presets": "17.34.1-rc.0+58fac0c00",
160
160
  "react": "^16.8.6",
161
161
  "react-addons-test-utils": "^15.6.2",
162
162
  "react-dom": "^16.8.6",
@@ -172,5 +172,5 @@
172
172
  "publishConfig": {
173
173
  "access": "public"
174
174
  },
175
- "gitHead": "9a66c738f1f741d00c3bf4406208ccff98823481"
175
+ "gitHead": "58fac0c00a5335c08537f02778c0b9dcd4b20265"
176
176
  }