@instructure/quiz-core 21.0.1-rc.6 → 21.0.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.
- package/es/building/components/layout/header/BuildingButtons/theme.js +1 -1
- package/es/common/actions/taking.js +3 -2
- package/es/common/components/layout/navbar/theme.js +1 -1
- package/es/common/components/shared/Card/CardWrapper/theme.js +1 -1
- package/es/common/reducers/taking.js +5 -1
- package/es/common/selectors/taking.js +3 -0
- package/es/common/util/getClientIpAddress.js +35 -0
- package/es/common/util/serializeEvent.js +4 -2
- package/es/index.js +1 -2
- package/es/moderating/components/events/Event.js +27 -10
- package/es/moderating/components/events/ResponseEvent.js +24 -7
- package/es/moderating/components/events/SessionStartEvent.js +16 -15
- package/es/moderating/components/events/SessionSubmitEvent.js +42 -0
- package/es/moderating/components/resources/EventDetails.js +43 -0
- package/es/moderating/components/resources/SessionBreachAlert.js +10 -0
- package/es/moderating/components/resources/util/checkIsBreach.js +28 -0
- package/es/moderating/components/resources/util/extractSessionData.js +20 -0
- package/es/reporting/components/resources/common/propTypes.js +14 -0
- package/es/taking/api/taking.js +26 -3
- package/lib/building/components/layout/header/BuildingButtons/theme.js +1 -1
- package/lib/common/actions/taking.js +3 -2
- package/lib/common/components/layout/navbar/theme.js +1 -1
- package/lib/common/components/shared/Card/CardWrapper/theme.js +1 -1
- package/lib/common/reducers/taking.js +5 -1
- package/lib/common/selectors/taking.js +5 -1
- package/lib/common/util/getClientIpAddress.js +43 -0
- package/lib/common/util/serializeEvent.js +3 -1
- package/lib/index.js +8 -0
- package/lib/moderating/components/events/Event.js +26 -9
- package/lib/moderating/components/events/ResponseEvent.js +25 -7
- package/lib/moderating/components/events/SessionStartEvent.js +16 -15
- package/lib/moderating/components/events/SessionSubmitEvent.js +52 -0
- package/lib/moderating/components/resources/EventDetails.js +51 -0
- package/lib/moderating/components/resources/SessionBreachAlert.js +18 -0
- package/lib/moderating/components/resources/util/checkIsBreach.js +36 -0
- package/lib/moderating/components/resources/util/extractSessionData.js +28 -0
- package/lib/reporting/components/resources/common/propTypes.js +18 -2
- package/lib/taking/api/taking.js +26 -3
- package/package.json +9 -9
|
@@ -5,7 +5,7 @@ var generateComponentTheme = function generateComponentTheme(_ref) {
|
|
|
5
5
|
return {
|
|
6
6
|
quizSavingColor: colors.lightGray,
|
|
7
7
|
quizSavingMargin: spacing.large,
|
|
8
|
-
buttonsHolderMargin: spacing.
|
|
8
|
+
buttonsHolderMargin: spacing.mediumSmall,
|
|
9
9
|
menuIconMargin: spacing.xSmall,
|
|
10
10
|
menuIconFontSize: typography.fontSizeLarge
|
|
11
11
|
};
|
|
@@ -104,12 +104,13 @@ export var loadResumeData = function loadResumeData(resumeData) {
|
|
|
104
104
|
payload: resumeData
|
|
105
105
|
};
|
|
106
106
|
};
|
|
107
|
-
export var sessionStartOrResumeEvent = function sessionStartOrResumeEvent(userAgent) {
|
|
107
|
+
export var sessionStartOrResumeEvent = function sessionStartOrResumeEvent(userAgent, ipAddress) {
|
|
108
108
|
return {
|
|
109
109
|
type: SESSION_STARTED_OR_RESUMED_EVENT,
|
|
110
110
|
payload: {
|
|
111
111
|
userAgent: userAgent,
|
|
112
|
-
browserSessionId: uuid()
|
|
112
|
+
browserSessionId: uuid(),
|
|
113
|
+
ipAddress: ipAddress
|
|
113
114
|
}
|
|
114
115
|
};
|
|
115
116
|
};
|
|
@@ -3,7 +3,7 @@ var generateComponentTheme = function generateComponentTheme(_ref) {
|
|
|
3
3
|
breakpoints = _ref.breakpoints,
|
|
4
4
|
transitions = _ref.transitions;
|
|
5
5
|
return {
|
|
6
|
-
wrapperPadding: spacing.
|
|
6
|
+
wrapperPadding: spacing.mediumSmall,
|
|
7
7
|
wrapperTransitionDuration: transitions.duration,
|
|
8
8
|
phoneBreakPoint: "max-width: ".concat(breakpoints.medium),
|
|
9
9
|
phoneWrapperPadding: spacing.medium
|
|
@@ -67,7 +67,11 @@ var loadResponses = function loadResponses(state, payload) {
|
|
|
67
67
|
return payload.reduce(modifyResponse, state);
|
|
68
68
|
};
|
|
69
69
|
var markSessionStartedIdentifier = function markSessionStartedIdentifier(state, payload) {
|
|
70
|
-
|
|
70
|
+
var needsUpdate = state.get('browserSessionId') !== payload.browserSessionId || state.get('ipAddress') !== payload.ipAddress;
|
|
71
|
+
return needsUpdate ? state.merge({
|
|
72
|
+
browserSessionId: payload.browserSessionId,
|
|
73
|
+
ipAddress: payload.ipAddress
|
|
74
|
+
}) : state;
|
|
71
75
|
};
|
|
72
76
|
var updateQuizSubmitFlag = function updateQuizSubmitFlag(state, payload) {
|
|
73
77
|
return state.set('submitFlag', payload.value);
|
|
@@ -7,6 +7,9 @@ export var getCurrentSessionItemPosition = function getCurrentSessionItemPositio
|
|
|
7
7
|
export var getBrowserSessionId = function getBrowserSessionId(state) {
|
|
8
8
|
return state.getIn([path, 'browserSessionId']);
|
|
9
9
|
};
|
|
10
|
+
export var getIpAddress = function getIpAddress(state) {
|
|
11
|
+
return state.getIn([path, 'ipAddress']);
|
|
12
|
+
};
|
|
10
13
|
export var getTimerData = function getTimerData(state) {
|
|
11
14
|
return state.getIn([path, 'timerData'], Map());
|
|
12
15
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import Fetcher from "./Fetcher.js";
|
|
4
|
+
export var getClientIpAddress = /*#__PURE__*/function () {
|
|
5
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(quizSessionId) {
|
|
6
|
+
var url, fetcher, _yield$fetcher$get, ip;
|
|
7
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
8
|
+
while (1) {
|
|
9
|
+
switch (_context.prev = _context.next) {
|
|
10
|
+
case 0:
|
|
11
|
+
_context.prev = 0;
|
|
12
|
+
url = "/api/quiz_sessions/".concat(quizSessionId, "/get_ip_address");
|
|
13
|
+
fetcher = new Fetcher();
|
|
14
|
+
_context.next = 5;
|
|
15
|
+
return fetcher.get(url);
|
|
16
|
+
case 5:
|
|
17
|
+
_yield$fetcher$get = _context.sent;
|
|
18
|
+
ip = _yield$fetcher$get.ip;
|
|
19
|
+
return _context.abrupt("return", ip);
|
|
20
|
+
case 10:
|
|
21
|
+
_context.prev = 10;
|
|
22
|
+
_context.t0 = _context["catch"](0);
|
|
23
|
+
console.error(_context.t0);
|
|
24
|
+
return _context.abrupt("return", null);
|
|
25
|
+
case 14:
|
|
26
|
+
case "end":
|
|
27
|
+
return _context.stop();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}, _callee, null, [[0, 10]]);
|
|
31
|
+
}));
|
|
32
|
+
return function getClientIpAddress(_x) {
|
|
33
|
+
return _ref.apply(this, arguments);
|
|
34
|
+
};
|
|
35
|
+
}();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QUIZ_SUBMISSION_EVENT, RESPONSE, SESSION_STARTED_OR_RESUMED_EVENT, RCE_EVENT, PAGE_BLURRED_EVENT, PAGE_FOCUSED_EVENT } from '@instructure/quiz-common';
|
|
2
|
-
import { getBrowserSessionId } from "../selectors/taking.js";
|
|
2
|
+
import { getBrowserSessionId, getIpAddress } from "../selectors/taking.js";
|
|
3
3
|
import { getActiveQuizSession } from "../selectors/quizSessions.js";
|
|
4
4
|
var whitelist = [QUIZ_SUBMISSION_EVENT, RESPONSE, SESSION_STARTED_OR_RESUMED_EVENT, RCE_EVENT, PAGE_BLURRED_EVENT, PAGE_FOCUSED_EVENT];
|
|
5
5
|
export function serializeEvent(action, store) {
|
|
@@ -10,8 +10,10 @@ export function serializeEvent(action, store) {
|
|
|
10
10
|
var state = store.getState();
|
|
11
11
|
var quizSession = getActiveQuizSession(state);
|
|
12
12
|
var defaultEventData = {
|
|
13
|
+
userAgent: navigator.userAgent,
|
|
13
14
|
browserSessionId: getBrowserSessionId(state),
|
|
14
|
-
clientTimestamp: new Date()
|
|
15
|
+
clientTimestamp: new Date(),
|
|
16
|
+
ipAddress: getIpAddress(state)
|
|
15
17
|
};
|
|
16
18
|
var authoritativeData = {
|
|
17
19
|
accountUuid: quizSession.accountUuid,
|
package/es/index.js
CHANGED
|
@@ -107,8 +107,7 @@ export { sessionStore } from "./common/util/sessionStore.js";
|
|
|
107
107
|
export { printWithCss, ensureImagesLoaded } from "./common/util/printUtils.js";
|
|
108
108
|
export { ensureRCEContentIsLoaded } from "./common/util/rceChecker.js";
|
|
109
109
|
export { applyComponentStyleOverride, withStyleOverrides, getThemeByKey, setThemeByKey, getActiveTheme, setActiveTheme } from '@instructure/quiz-common';
|
|
110
|
-
|
|
111
|
-
// APIs
|
|
110
|
+
export { getClientIpAddress } from "./common/util/getClientIpAddress.js"; // APIs
|
|
112
111
|
export { createQuizEntryRegrade } from "./grading/api/quizEntryRegrades.js";
|
|
113
112
|
export { getQuizEntry } from "./building/api/quizEntries.js";
|
|
114
113
|
export { getItem } from "./building/api/items.js";
|
|
@@ -6,14 +6,17 @@ var _Event;
|
|
|
6
6
|
import React, { Component } from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
9
|
-
import { RESPONSE, SESSION_STARTED_OR_RESUMED_EVENT, RCE_EVENT, PAGE_BLURRED_EVENT, PAGE_FOCUSED_EVENT } from '@instructure/quiz-common';
|
|
9
|
+
import { RESPONSE, SESSION_STARTED_OR_RESUMED_EVENT, RCE_EVENT, PAGE_BLURRED_EVENT, PAGE_FOCUSED_EVENT, QUIZ_SUBMISSION_EVENT } from '@instructure/quiz-common';
|
|
10
10
|
import { Table } from '@instructure/ui-table';
|
|
11
11
|
import ElapsedTime from "../resources/ElapsedTime.js";
|
|
12
12
|
import ResponseEvent from "./ResponseEvent.js";
|
|
13
13
|
import SessionStartEvent from "./SessionStartEvent.js";
|
|
14
|
+
import { SessionSubmitEvent } from "./SessionSubmitEvent.js";
|
|
14
15
|
import RCEEvent from "./RCEEvent.js";
|
|
15
16
|
import PageBlurredEvent from "./PageBlurredEvent.js";
|
|
16
17
|
import PageFocusedEvent from "./PageFocusedEvent.js";
|
|
18
|
+
import { extractSessionData } from "../resources/util/extractSessionData.js";
|
|
19
|
+
import { checkIsBreach } from "../resources/util/checkIsBreach.js";
|
|
17
20
|
var _ref = /*#__PURE__*/React.createElement(PageBlurredEvent, null);
|
|
18
21
|
var _ref2 = /*#__PURE__*/React.createElement(PageFocusedEvent, null);
|
|
19
22
|
export var Event = /*#__PURE__*/function (_Component) {
|
|
@@ -25,26 +28,34 @@ export var Event = /*#__PURE__*/function (_Component) {
|
|
|
25
28
|
}
|
|
26
29
|
_createClass(Event, [{
|
|
27
30
|
key: "renderResponseEvent",
|
|
28
|
-
value: function renderResponseEvent(event) {
|
|
31
|
+
value: function renderResponseEvent(event, validationErrors, currentEventData) {
|
|
29
32
|
var item = event.getItem();
|
|
30
33
|
if (!item) {
|
|
31
34
|
return null;
|
|
32
35
|
} else {
|
|
33
36
|
return /*#__PURE__*/React.createElement(ResponseEvent, {
|
|
34
37
|
event: event,
|
|
35
|
-
item: item
|
|
38
|
+
item: item,
|
|
39
|
+
validationErrors: validationErrors,
|
|
40
|
+
currentEventData: currentEventData
|
|
36
41
|
});
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
44
|
}, {
|
|
40
45
|
key: "renderPayload",
|
|
41
|
-
value: function renderPayload(event) {
|
|
46
|
+
value: function renderPayload(event, validationErrors, currentEventData) {
|
|
42
47
|
switch (event.eventType) {
|
|
43
48
|
case RESPONSE:
|
|
44
|
-
return this.renderResponseEvent(event);
|
|
49
|
+
return this.renderResponseEvent(event, validationErrors, currentEventData);
|
|
45
50
|
case SESSION_STARTED_OR_RESUMED_EVENT:
|
|
46
51
|
return /*#__PURE__*/React.createElement(SessionStartEvent, {
|
|
47
|
-
|
|
52
|
+
validationErrors: validationErrors,
|
|
53
|
+
currentEventData: currentEventData
|
|
54
|
+
});
|
|
55
|
+
case QUIZ_SUBMISSION_EVENT:
|
|
56
|
+
return /*#__PURE__*/React.createElement(SessionSubmitEvent, {
|
|
57
|
+
validationErrors: validationErrors,
|
|
58
|
+
currentEventData: currentEventData
|
|
48
59
|
});
|
|
49
60
|
case RCE_EVENT:
|
|
50
61
|
return /*#__PURE__*/React.createElement(RCEEvent, {
|
|
@@ -64,8 +75,12 @@ export var Event = /*#__PURE__*/function (_Component) {
|
|
|
64
75
|
value: function render() {
|
|
65
76
|
var _this$props = this.props,
|
|
66
77
|
event = _this$props.event,
|
|
67
|
-
startTime = _this$props.startTime
|
|
68
|
-
|
|
78
|
+
startTime = _this$props.startTime,
|
|
79
|
+
firstEvent = _this$props.firstEvent;
|
|
80
|
+
var currentEventData = extractSessionData(event);
|
|
81
|
+
var firstEventData = extractSessionData(firstEvent);
|
|
82
|
+
var validationErrors = checkIsBreach(firstEventData, currentEventData);
|
|
83
|
+
var payloadNode = this.renderPayload(event, validationErrors, currentEventData);
|
|
69
84
|
if (!payloadNode) return null;
|
|
70
85
|
return /*#__PURE__*/React.createElement(Table.Row, null, /*#__PURE__*/React.createElement(Table.Cell, null, /*#__PURE__*/React.createElement(ElapsedTime, {
|
|
71
86
|
eventTime: event.createdDate(),
|
|
@@ -82,10 +97,12 @@ Event.displayName = 'Row';
|
|
|
82
97
|
Event.componentId = "Quizzes".concat(_Event.displayName);
|
|
83
98
|
Event.propTypes = {
|
|
84
99
|
event: ImmutablePropTypes.record,
|
|
85
|
-
startTime: PropTypes.instanceOf(Date)
|
|
100
|
+
startTime: PropTypes.instanceOf(Date),
|
|
101
|
+
firstEvent: ImmutablePropTypes.record
|
|
86
102
|
};
|
|
87
103
|
Event.defaultProps = {
|
|
88
104
|
event: void 0,
|
|
89
|
-
startTime: void 0
|
|
105
|
+
startTime: void 0,
|
|
106
|
+
firstEvent: void 0
|
|
90
107
|
};
|
|
91
108
|
export default Event;
|
|
@@ -4,7 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
var _dec, _class, _ResponseEvent;
|
|
6
6
|
/** @jsx jsx */
|
|
7
|
-
import { Component } from 'react';
|
|
7
|
+
import React, { Component } from 'react';
|
|
8
8
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
10
|
import { IconImageSolid } from '@instructure/ui-icons';
|
|
@@ -14,9 +14,11 @@ import { ToggleDetails } from '@instructure/ui-toggle-details';
|
|
|
14
14
|
import { jsx } from '@instructure/emotion';
|
|
15
15
|
import t from '@instructure/quiz-i18n/es/format-message';
|
|
16
16
|
import { extractTextFromHtml } from '@instructure/quiz-interactions';
|
|
17
|
+
import { EventDetails } from "../resources/EventDetails.js";
|
|
17
18
|
import generateStyle from "./styles.js";
|
|
18
19
|
import generateComponentTheme from "./theme.js";
|
|
19
20
|
import { withStyleOverrides } from '@instructure/quiz-common';
|
|
21
|
+
import { sessionValidationErrorsPropType, eventDataPropType } from "../../../reporting/components/resources/common/propTypes.js";
|
|
20
22
|
var imgRegex = /<img.*?src=['"](.+)['"]/g;
|
|
21
23
|
export var ResponseEvent = (_dec = withStyleOverrides(generateStyle, generateComponentTheme), _dec(_class = (_ResponseEvent = /*#__PURE__*/function (_Component) {
|
|
22
24
|
_inherits(ResponseEvent, _Component);
|
|
@@ -44,13 +46,16 @@ export var ResponseEvent = (_dec = withStyleOverrides(generateStyle, generateCom
|
|
|
44
46
|
}, {
|
|
45
47
|
key: "renderTextSummary",
|
|
46
48
|
value: function renderTextSummary() {
|
|
49
|
+
var isBreach = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
47
50
|
var strippedItemBody = extractTextFromHtml(this.itemBody);
|
|
48
51
|
return jsx("span", null, this.hasMedia() && jsx(IconImageSolid, {
|
|
49
52
|
css: this.props.styles.answerMediaIcon
|
|
50
|
-
}),
|
|
53
|
+
}), jsx(Text, {
|
|
54
|
+
color: isBreach ? 'danger' : 'primary'
|
|
55
|
+
}, t('Answered question {position}: {question}', {
|
|
51
56
|
position: this.props.event.getIn(['eventData', 'position']),
|
|
52
57
|
question: strippedItemBody
|
|
53
|
-
}));
|
|
58
|
+
})));
|
|
54
59
|
}
|
|
55
60
|
}, {
|
|
56
61
|
key: "renderMedia",
|
|
@@ -78,16 +83,26 @@ export var ResponseEvent = (_dec = withStyleOverrides(generateStyle, generateCom
|
|
|
78
83
|
}, {
|
|
79
84
|
key: "render",
|
|
80
85
|
value: function render() {
|
|
86
|
+
var _this$props = this.props,
|
|
87
|
+
validationErrors = _this$props.validationErrors,
|
|
88
|
+
currentEventData = _this$props.currentEventData;
|
|
81
89
|
var responseText = this.getReadableResponseText();
|
|
82
90
|
if (responseText) {
|
|
83
91
|
// If this returns falsey, then we know to just display the stem
|
|
84
92
|
return jsx(ToggleDetails, {
|
|
85
|
-
summary: this.renderTextSummary()
|
|
86
|
-
}, this.renderMedia(),
|
|
93
|
+
summary: this.renderTextSummary(validationErrors.isBreach)
|
|
94
|
+
}, this.renderMedia(), jsx(EventDetails, {
|
|
95
|
+
currentEventData: currentEventData,
|
|
96
|
+
validationErrors: validationErrors,
|
|
97
|
+
answerValue: responseText
|
|
98
|
+
}));
|
|
87
99
|
} else {
|
|
88
100
|
return jsx(Text, {
|
|
89
101
|
size: "small"
|
|
90
|
-
}, this.renderTextSummary(),
|
|
102
|
+
}, this.renderTextSummary(validationErrors.isBreach), jsx(EventDetails, {
|
|
103
|
+
currentEventData: currentEventData,
|
|
104
|
+
validationErrors: validationErrors
|
|
105
|
+
}), this.renderMedia());
|
|
91
106
|
}
|
|
92
107
|
}
|
|
93
108
|
}, {
|
|
@@ -101,6 +116,8 @@ export var ResponseEvent = (_dec = withStyleOverrides(generateStyle, generateCom
|
|
|
101
116
|
}(Component), _ResponseEvent.displayName = 'ResponseEvent', _ResponseEvent.componentId = "Quizzes".concat(_ResponseEvent.displayName), _ResponseEvent.propTypes = {
|
|
102
117
|
event: ImmutablePropTypes.record.isRequired,
|
|
103
118
|
item: ImmutablePropTypes.record.isRequired,
|
|
104
|
-
styles: PropTypes.object
|
|
119
|
+
styles: PropTypes.object,
|
|
120
|
+
validationErrors: sessionValidationErrorsPropType,
|
|
121
|
+
currentEventData: eventDataPropType
|
|
105
122
|
}, _ResponseEvent)) || _class);
|
|
106
123
|
export default ResponseEvent;
|
|
@@ -3,11 +3,11 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React, { Component } from 'react';
|
|
6
|
-
import
|
|
7
|
-
import platform from 'platform';
|
|
6
|
+
import { EventDetails } from "../resources/EventDetails.js";
|
|
8
7
|
import { ToggleDetails } from '@instructure/ui-toggle-details';
|
|
9
|
-
import { Table } from '@instructure/ui-table';
|
|
10
8
|
import t from '@instructure/quiz-i18n/es/format-message';
|
|
9
|
+
import { Text } from '@instructure/ui-text';
|
|
10
|
+
import { sessionValidationErrorsPropType, eventDataPropType } from "../../../reporting/components/resources/common/propTypes.js";
|
|
11
11
|
export var SessionStartEvent = /*#__PURE__*/function (_Component) {
|
|
12
12
|
_inherits(SessionStartEvent, _Component);
|
|
13
13
|
var _super = _createSuper(SessionStartEvent);
|
|
@@ -18,24 +18,25 @@ export var SessionStartEvent = /*#__PURE__*/function (_Component) {
|
|
|
18
18
|
_createClass(SessionStartEvent, [{
|
|
19
19
|
key: "render",
|
|
20
20
|
value: function render() {
|
|
21
|
-
var
|
|
22
|
-
|
|
21
|
+
var _this$props = this.props,
|
|
22
|
+
validationErrors = _this$props.validationErrors,
|
|
23
|
+
currentEventData = _this$props.currentEventData;
|
|
24
|
+
var summary = /*#__PURE__*/React.createElement(Text, {
|
|
25
|
+
color: validationErrors.isBreach ? 'danger' : 'primary'
|
|
26
|
+
}, t('Session started'));
|
|
23
27
|
return /*#__PURE__*/React.createElement(ToggleDetails, {
|
|
24
|
-
summary:
|
|
25
|
-
}, /*#__PURE__*/React.createElement(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}, t('attribute')), /*#__PURE__*/React.createElement(Table.ColHeader, {
|
|
30
|
-
id: "system-details-value"
|
|
31
|
-
}, t('value')))), /*#__PURE__*/React.createElement(Table.Body, null, /*#__PURE__*/React.createElement(Table.Row, null, /*#__PURE__*/React.createElement(Table.Cell, null, t('Browser')), /*#__PURE__*/React.createElement(Table.Cell, null, // eslint-disable-next-line react/jsx-no-literals
|
|
32
|
-
"".concat(userPlatform.name, " ").concat(userPlatform.version))), /*#__PURE__*/React.createElement(Table.Row, null, /*#__PURE__*/React.createElement(Table.Cell, null, t('Operating System')), /*#__PURE__*/React.createElement(Table.Cell, null, userPlatform.os.toString())))));
|
|
28
|
+
summary: summary
|
|
29
|
+
}, /*#__PURE__*/React.createElement(EventDetails, {
|
|
30
|
+
currentEventData: currentEventData,
|
|
31
|
+
validationErrors: validationErrors
|
|
32
|
+
}));
|
|
33
33
|
}
|
|
34
34
|
}]);
|
|
35
35
|
SessionStartEvent.displayName = "SessionStartEvent";
|
|
36
36
|
return SessionStartEvent;
|
|
37
37
|
}(Component);
|
|
38
38
|
SessionStartEvent.propTypes = {
|
|
39
|
-
|
|
39
|
+
validationErrors: sessionValidationErrorsPropType,
|
|
40
|
+
currentEventData: eventDataPropType
|
|
40
41
|
};
|
|
41
42
|
export default SessionStartEvent;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React, { Component } from 'react';
|
|
6
|
+
import t from '@instructure/quiz-i18n/es/format-message';
|
|
7
|
+
import { EventDetails } from "../resources/EventDetails.js";
|
|
8
|
+
import { ToggleDetails } from '@instructure/ui-toggle-details';
|
|
9
|
+
import { Text } from '@instructure/ui-text';
|
|
10
|
+
import { sessionValidationErrorsPropType, eventDataPropType } from "../../../reporting/components/resources/common/propTypes.js";
|
|
11
|
+
export var SessionSubmitEvent = /*#__PURE__*/function (_Component) {
|
|
12
|
+
_inherits(SessionSubmitEvent, _Component);
|
|
13
|
+
var _super = _createSuper(SessionSubmitEvent);
|
|
14
|
+
function SessionSubmitEvent() {
|
|
15
|
+
_classCallCheck(this, SessionSubmitEvent);
|
|
16
|
+
return _super.apply(this, arguments);
|
|
17
|
+
}
|
|
18
|
+
_createClass(SessionSubmitEvent, [{
|
|
19
|
+
key: "render",
|
|
20
|
+
value: function render() {
|
|
21
|
+
var _this$props = this.props,
|
|
22
|
+
validationErrors = _this$props.validationErrors,
|
|
23
|
+
currentEventData = _this$props.currentEventData;
|
|
24
|
+
var summary = /*#__PURE__*/React.createElement(Text, {
|
|
25
|
+
color: validationErrors.isBreach ? 'danger' : 'primary'
|
|
26
|
+
}, t('Session submitted'));
|
|
27
|
+
return /*#__PURE__*/React.createElement(ToggleDetails, {
|
|
28
|
+
summary: summary
|
|
29
|
+
}, /*#__PURE__*/React.createElement(EventDetails, {
|
|
30
|
+
currentEventData: currentEventData,
|
|
31
|
+
validationErrors: validationErrors
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
}]);
|
|
35
|
+
SessionSubmitEvent.displayName = "SessionSubmitEvent";
|
|
36
|
+
return SessionSubmitEvent;
|
|
37
|
+
}(Component);
|
|
38
|
+
SessionSubmitEvent.propTypes = {
|
|
39
|
+
validationErrors: sessionValidationErrorsPropType,
|
|
40
|
+
currentEventData: eventDataPropType
|
|
41
|
+
};
|
|
42
|
+
export default SessionSubmitEvent;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Table } from '@instructure/ui-table';
|
|
2
|
+
import { Text } from '@instructure/ui-text';
|
|
3
|
+
import { IconButton } from '@instructure/ui-buttons';
|
|
4
|
+
import t from '@instructure/quiz-i18n/es/format-message';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { SessionBreachAlert } from "./SessionBreachAlert.js";
|
|
7
|
+
import { IconInfoLine } from '@instructure/ui-icons';
|
|
8
|
+
import { Tooltip } from '@instructure/ui-tooltip';
|
|
9
|
+
var _ref2 = /*#__PURE__*/React.createElement(SessionBreachAlert, null);
|
|
10
|
+
export var EventDetails = function EventDetails(_ref) {
|
|
11
|
+
var currentEventData = _ref.currentEventData,
|
|
12
|
+
validationErrors = _ref.validationErrors,
|
|
13
|
+
_ref$answerValue = _ref.answerValue,
|
|
14
|
+
answerValue = _ref$answerValue === void 0 ? null : _ref$answerValue;
|
|
15
|
+
var eventTimeString = "".concat(t('Event time'), ": ").concat(currentEventData.eventDate);
|
|
16
|
+
var renderTooltip = function renderTooltip(message) {
|
|
17
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
18
|
+
renderTip: message,
|
|
19
|
+
placement: "end",
|
|
20
|
+
on: ['click', 'hover', 'focus']
|
|
21
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
22
|
+
screenReaderLabel: message,
|
|
23
|
+
renderIcon: IconInfoLine,
|
|
24
|
+
withBackground: false,
|
|
25
|
+
withBorder: false
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, validationErrors.isBreach && _ref2, /*#__PURE__*/React.createElement("h4", null, eventTimeString), /*#__PURE__*/React.createElement(Table, {
|
|
29
|
+
caption: t('System details')
|
|
30
|
+
}, /*#__PURE__*/React.createElement(Table.Head, null, /*#__PURE__*/React.createElement(Table.Row, null, /*#__PURE__*/React.createElement(Table.ColHeader, {
|
|
31
|
+
id: "system-details-attribute"
|
|
32
|
+
}, t('Attribute')), /*#__PURE__*/React.createElement(Table.ColHeader, {
|
|
33
|
+
id: "system-details-value"
|
|
34
|
+
}, t('Value')))), /*#__PURE__*/React.createElement(Table.Body, null, /*#__PURE__*/React.createElement(Table.Row, null, /*#__PURE__*/React.createElement(Table.Cell, null, t('Client IP address')), /*#__PURE__*/React.createElement(Table.Cell, null, /*#__PURE__*/React.createElement(Text, {
|
|
35
|
+
color: validationErrors.ipAddress ? 'danger' : 'primary'
|
|
36
|
+
}, currentEventData.ipAddress), validationErrors.ipAddress && renderTooltip(validationErrors.ipAddress))), /*#__PURE__*/React.createElement(Table.Row, null, /*#__PURE__*/React.createElement(Table.Cell, null, t('Browser session ID')), /*#__PURE__*/React.createElement(Table.Cell, null, /*#__PURE__*/React.createElement(Text, {
|
|
37
|
+
color: validationErrors.browserSessionID ? 'danger' : 'primary'
|
|
38
|
+
}, currentEventData.browserSessionID), validationErrors.browserSessionID && renderTooltip(validationErrors.browserSessionID))), /*#__PURE__*/React.createElement(Table.Row, null, /*#__PURE__*/React.createElement(Table.Cell, null, t('Browser')), /*#__PURE__*/React.createElement(Table.Cell, null, /*#__PURE__*/React.createElement(Text, {
|
|
39
|
+
color: validationErrors.browserString ? 'danger' : 'primary'
|
|
40
|
+
}, currentEventData.browserString), validationErrors.browserString && renderTooltip(validationErrors.browserString))), /*#__PURE__*/React.createElement(Table.Row, null, /*#__PURE__*/React.createElement(Table.Cell, null, t('Operating System')), /*#__PURE__*/React.createElement(Table.Cell, null, /*#__PURE__*/React.createElement(Text, {
|
|
41
|
+
color: validationErrors.userPlatform ? 'danger' : 'primary'
|
|
42
|
+
}, currentEventData.userPlatform), validationErrors.userPlatform && renderTooltip(validationErrors.userPlatform))), answerValue && /*#__PURE__*/React.createElement(Table.Row, null, /*#__PURE__*/React.createElement(Table.Cell, null, t('Answer value')), /*#__PURE__*/React.createElement(Table.Cell, null, answerValue)))));
|
|
43
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Alert } from '@instructure/ui-alerts';
|
|
3
|
+
import t from '@instructure/quiz-i18n/es/format-message';
|
|
4
|
+
var _ref = /*#__PURE__*/React.createElement("br", null);
|
|
5
|
+
export var SessionBreachAlert = function SessionBreachAlert() {
|
|
6
|
+
return /*#__PURE__*/React.createElement(Alert, {
|
|
7
|
+
variant: "warning",
|
|
8
|
+
margin: "small"
|
|
9
|
+
}, t('Potential breach: This Quiz appears to have been accessed from multiple devices or browsers.'), _ref, t('Review the activity log and take appropriate action.'));
|
|
10
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import t from '@instructure/quiz-i18n/es/format-message';
|
|
2
|
+
export var checkIsBreach = function checkIsBreach(firstEventData, currentEventData) {
|
|
3
|
+
var result = {
|
|
4
|
+
isBreach: false
|
|
5
|
+
};
|
|
6
|
+
var checks = [{
|
|
7
|
+
key: 'ipAddress',
|
|
8
|
+
message: t('Client IP address is different from initial address')
|
|
9
|
+
}, {
|
|
10
|
+
key: 'browserSessionID',
|
|
11
|
+
message: t('Browser session ID is different from initial id')
|
|
12
|
+
}, {
|
|
13
|
+
key: 'browserString',
|
|
14
|
+
message: t('Browser is different from initial browser')
|
|
15
|
+
}, {
|
|
16
|
+
key: 'userPlatform',
|
|
17
|
+
message: t('Operating system is different from initial system')
|
|
18
|
+
}];
|
|
19
|
+
checks.forEach(function (_ref) {
|
|
20
|
+
var key = _ref.key,
|
|
21
|
+
message = _ref.message;
|
|
22
|
+
if (currentEventData[key] !== firstEventData[key]) {
|
|
23
|
+
result.isBreach = true;
|
|
24
|
+
result[key] = message;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import platform from 'platform';
|
|
2
|
+
import { formatDateTimeSeconds } from '@instructure/quiz-i18n';
|
|
3
|
+
export var extractSessionData = function extractSessionData(sourceData) {
|
|
4
|
+
if (!sourceData) return {
|
|
5
|
+
ipAddress: '',
|
|
6
|
+
browserSessionID: '',
|
|
7
|
+
eventDate: '',
|
|
8
|
+
browserString: '',
|
|
9
|
+
userPlatform: ''
|
|
10
|
+
};
|
|
11
|
+
var clientTimestamp = sourceData.getIn(['eventData', 'clientTimestamp']);
|
|
12
|
+
var userPlatform = platform.parse(sourceData.getIn(['eventData', 'userAgent']));
|
|
13
|
+
return {
|
|
14
|
+
ipAddress: sourceData.getIn(['eventData', 'ipAddress']),
|
|
15
|
+
browserSessionID: sourceData.getIn(['eventData', 'browserSessionId']),
|
|
16
|
+
eventDate: clientTimestamp ? formatDateTimeSeconds(clientTimestamp) : '',
|
|
17
|
+
browserString: "".concat(userPlatform.name, " ").concat(userPlatform.version),
|
|
18
|
+
userPlatform: userPlatform.os.toString()
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -163,4 +163,18 @@ export var afsFlags = PropTypes.shape({
|
|
|
163
163
|
numericEnabled: PropTypes.bool.isRequired,
|
|
164
164
|
essayEnabled: PropTypes.bool.isRequired,
|
|
165
165
|
fileUploadEnabled: PropTypes.bool.isRequired
|
|
166
|
+
});
|
|
167
|
+
export var sessionValidationErrorsPropType = PropTypes.shape({
|
|
168
|
+
isBreach: PropTypes.bool,
|
|
169
|
+
ipAddress: PropTypes.string,
|
|
170
|
+
browserSessionID: PropTypes.string,
|
|
171
|
+
browserString: PropTypes.string,
|
|
172
|
+
userPlatform: PropTypes.string
|
|
173
|
+
});
|
|
174
|
+
export var eventDataPropType = PropTypes.shape({
|
|
175
|
+
ipAddress: PropTypes.string,
|
|
176
|
+
browserSessionID: PropTypes.string,
|
|
177
|
+
eventDate: PropTypes.string,
|
|
178
|
+
browserString: PropTypes.string,
|
|
179
|
+
userPlatform: PropTypes.string
|
|
166
180
|
});
|
package/es/taking/api/taking.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
1
3
|
// =============================================
|
|
2
4
|
// =============================================
|
|
3
5
|
|
|
@@ -25,6 +27,7 @@ import { getSessionItems, handleQuizSessionFetch } from "../../common/actions/qu
|
|
|
25
27
|
import { handleSessionItemsResponse, handleResumeDataResponse, handleQuizSessionResponse } from "../../common/api/callHandlers.js";
|
|
26
28
|
import * as modalActions from "../../common/actions/modal.js";
|
|
27
29
|
import { backtrackingNextQuestion, sessionStartOrResumeEvent, setCurrentSessionItemPosition, submitQuizSessionEvent, updateQuizSubmitFlag, updateQuizSessionStatusOnPageLoad, updateTimerInfo } from "../../common/actions/taking.js";
|
|
30
|
+
import { getClientIpAddress } from "../../common/util/getClientIpAddress.js";
|
|
28
31
|
var getQuizSessionConfig = function getQuizSessionConfig(quizSession) {
|
|
29
32
|
// these should be handled by existing functions
|
|
30
33
|
var oneQuestionAtATime = quizSession.isOneQuestionAtATime();
|
|
@@ -144,9 +147,29 @@ export function newQuizTakingSession(quizSessionId) {
|
|
|
144
147
|
};
|
|
145
148
|
}
|
|
146
149
|
export function onQuizSessionReadyForTaking(quizSession) {
|
|
147
|
-
return function (
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
return /*#__PURE__*/function () {
|
|
151
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch) {
|
|
152
|
+
var ipAddress;
|
|
153
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
154
|
+
while (1) {
|
|
155
|
+
switch (_context.prev = _context.next) {
|
|
156
|
+
case 0:
|
|
157
|
+
_context.next = 2;
|
|
158
|
+
return getClientIpAddress(quizSession.id);
|
|
159
|
+
case 2:
|
|
160
|
+
ipAddress = _context.sent;
|
|
161
|
+
dispatch([makeSessionItemCall(quizSession), getResumeData(quizSession.id), sessionStartOrResumeEvent(navigator.userAgent, ipAddress), updateQuizSessionStatusOnPageLoad(quizSession.status)]);
|
|
162
|
+
case 4:
|
|
163
|
+
case "end":
|
|
164
|
+
return _context.stop();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}, _callee);
|
|
168
|
+
}));
|
|
169
|
+
return function (_x) {
|
|
170
|
+
return _ref.apply(this, arguments);
|
|
171
|
+
};
|
|
172
|
+
}();
|
|
150
173
|
}
|
|
151
174
|
|
|
152
175
|
// ====================================
|
|
@@ -11,7 +11,7 @@ var generateComponentTheme = function generateComponentTheme(_ref) {
|
|
|
11
11
|
return {
|
|
12
12
|
quizSavingColor: colors.lightGray,
|
|
13
13
|
quizSavingMargin: spacing.large,
|
|
14
|
-
buttonsHolderMargin: spacing.
|
|
14
|
+
buttonsHolderMargin: spacing.mediumSmall,
|
|
15
15
|
menuIconMargin: spacing.xSmall,
|
|
16
16
|
menuIconFontSize: typography.fontSizeLarge
|
|
17
17
|
};
|
|
@@ -122,12 +122,13 @@ var loadResumeData = function loadResumeData(resumeData) {
|
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
124
|
exports.loadResumeData = loadResumeData;
|
|
125
|
-
var sessionStartOrResumeEvent = function sessionStartOrResumeEvent(userAgent) {
|
|
125
|
+
var sessionStartOrResumeEvent = function sessionStartOrResumeEvent(userAgent, ipAddress) {
|
|
126
126
|
return {
|
|
127
127
|
type: _quizCommon.SESSION_STARTED_OR_RESUMED_EVENT,
|
|
128
128
|
payload: {
|
|
129
129
|
userAgent: userAgent,
|
|
130
|
-
browserSessionId: (0, _uuid.v4)()
|
|
130
|
+
browserSessionId: (0, _uuid.v4)(),
|
|
131
|
+
ipAddress: ipAddress
|
|
131
132
|
}
|
|
132
133
|
};
|
|
133
134
|
};
|
|
@@ -8,7 +8,7 @@ var generateComponentTheme = function generateComponentTheme(_ref) {
|
|
|
8
8
|
var breakpoints = _ref.breakpoints,
|
|
9
9
|
colors = _ref.colors;
|
|
10
10
|
return {
|
|
11
|
-
backgroundColor: colors.
|
|
11
|
+
backgroundColor: colors.white,
|
|
12
12
|
phoneBreakPoint: breakpoints.medium
|
|
13
13
|
};
|
|
14
14
|
};
|
|
@@ -9,7 +9,7 @@ var generateComponentTheme = function generateComponentTheme(_ref) {
|
|
|
9
9
|
breakpoints = _ref.breakpoints,
|
|
10
10
|
transitions = _ref.transitions;
|
|
11
11
|
return {
|
|
12
|
-
wrapperPadding: spacing.
|
|
12
|
+
wrapperPadding: spacing.mediumSmall,
|
|
13
13
|
wrapperTransitionDuration: transitions.duration,
|
|
14
14
|
phoneBreakPoint: "max-width: ".concat(breakpoints.medium),
|
|
15
15
|
phoneWrapperPadding: spacing.medium
|
|
@@ -73,7 +73,11 @@ var loadResponses = function loadResponses(state, payload) {
|
|
|
73
73
|
return payload.reduce(modifyResponse, state);
|
|
74
74
|
};
|
|
75
75
|
var markSessionStartedIdentifier = function markSessionStartedIdentifier(state, payload) {
|
|
76
|
-
|
|
76
|
+
var needsUpdate = state.get('browserSessionId') !== payload.browserSessionId || state.get('ipAddress') !== payload.ipAddress;
|
|
77
|
+
return needsUpdate ? state.merge({
|
|
78
|
+
browserSessionId: payload.browserSessionId,
|
|
79
|
+
ipAddress: payload.ipAddress
|
|
80
|
+
}) : state;
|
|
77
81
|
};
|
|
78
82
|
var updateQuizSubmitFlag = function updateQuizSubmitFlag(state, payload) {
|
|
79
83
|
return state.set('submitFlag', payload.value);
|