@gamelearn/arcade-components 0.7.1 → 0.10.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.
- package/dist/components/decision-component/components/DecisionComponent.js +4 -2
- package/dist/components/decision-component/components/Feedback.js +6 -4
- package/dist/components/decision-component/mocks/mockForStory.js +140 -1
- package/dist/components/image-click-wrapper-component/components/ImageClickWrapperComponent.js +1 -2
- package/dist/components/index.js +16 -0
- package/dist/components/{image-click-wrapper-component/components → konva-components}/Area/index.js +0 -20
- package/dist/components/{hacker-puzzle-component/components/KonvaMapper/index.js → konva-components/KonvaMapper.js} +3 -27
- package/dist/components/lectures-component/components/LecturesComponent.js +1 -0
- package/dist/components/rewards-component/components/RewardItem.js +88 -0
- package/dist/components/{decision-component/components/Rewards.js → rewards-component/components/RewardsComponent.js} +98 -111
- package/dist/components/rewards-component/index.js +13 -0
- package/dist/components/rewards-component/mocks/mockForStory.js +264 -0
- package/dist/components/survey-component/components/ApplicableBox.js +73 -0
- package/dist/components/survey-component/components/OpinionBox.js +72 -0
- package/dist/components/survey-component/components/SurveyComponent.js +144 -0
- package/dist/components/survey-component/components/TextBox.js +41 -0
- package/dist/components/survey-component/index.js +13 -0
- package/dist/components/survey-component/mocks/mockForStory.js +20 -0
- package/dist/components/test-component/components/Container.js +162 -0
- package/dist/components/test-component/components/Feedback.js +51 -0
- package/dist/components/test-component/components/Questions.js +71 -0
- package/dist/components/test-component/components/Results.js +164 -0
- package/dist/components/test-component/components/TestComponent.js +278 -0
- package/dist/components/test-component/index.js +13 -0
- package/dist/components/test-component/mocks/mockForStory.js +162 -0
- package/dist/components/writer-puzzle-component/components/FeedbackComponent.js +4 -3
- package/dist/components/writer-puzzle-component/mocks/mockForStory.js +21 -0
- package/package.json +1 -1
- package/dist/components/hacker-puzzle-component/components/Area/index.js +0 -150
- package/dist/components/image-click-wrapper-component/components/KonvaMapper/index.js +0 -230
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _rewardsComponent = _interopRequireDefault(require("../../rewards-component"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
17
|
+
|
|
18
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
|
|
20
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
21
|
+
|
|
22
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
23
|
+
|
|
24
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
25
|
+
|
|
26
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
27
|
+
|
|
28
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
29
|
+
|
|
30
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
31
|
+
|
|
32
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
33
|
+
|
|
34
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
35
|
+
|
|
36
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
37
|
+
|
|
38
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
39
|
+
|
|
40
|
+
var ResultsComponent = function ResultsComponent(_ref) {
|
|
41
|
+
var result = _ref.result,
|
|
42
|
+
showingResult = _ref.showingResult,
|
|
43
|
+
time = _ref.time,
|
|
44
|
+
mandatory = _ref.mandatory,
|
|
45
|
+
correctAnswers = _ref.correctAnswers,
|
|
46
|
+
isFirst = _ref.isFirst,
|
|
47
|
+
reviewTest = _ref.reviewTest,
|
|
48
|
+
finishTest = _ref.finishTest,
|
|
49
|
+
restartTest = _ref.restartTest,
|
|
50
|
+
timeOver = _ref.timeOver,
|
|
51
|
+
timeOverText = _ref.timeOverText,
|
|
52
|
+
emitEvent = _ref.emitEvent;
|
|
53
|
+
|
|
54
|
+
var _useState = (0, _react.useState)(0),
|
|
55
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
56
|
+
points = _useState2[0],
|
|
57
|
+
setPoints = _useState2[1];
|
|
58
|
+
|
|
59
|
+
var _useState3 = (0, _react.useState)(),
|
|
60
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
61
|
+
interval = _useState4[0],
|
|
62
|
+
saveInterval = _useState4[1];
|
|
63
|
+
|
|
64
|
+
var correctAnswersChecked = correctAnswers.filter(function (a) {
|
|
65
|
+
return result[a.question] && result[a.question].id === a.answer;
|
|
66
|
+
}).length;
|
|
67
|
+
var totalCorrectAnswers = correctAnswers.length;
|
|
68
|
+
var showFinishButton = mandatory ? correctAnswersChecked === totalCorrectAnswers : true;
|
|
69
|
+
var showRetryButton = mandatory ? correctAnswersChecked < totalCorrectAnswers : false;
|
|
70
|
+
var rewards = Object.keys(showingResult).reduce(function (acc, resultId) {
|
|
71
|
+
return [].concat(_toConsumableArray(acc), _toConsumableArray(showingResult[resultId].rewards));
|
|
72
|
+
}, []);
|
|
73
|
+
var onlyGrade = rewards.filter(function (reward) {
|
|
74
|
+
return reward.type === 'grade';
|
|
75
|
+
}).length === rewards.length;
|
|
76
|
+
var haveRewards = !onlyGrade && rewards.length > 0;
|
|
77
|
+
var bar = Math.trunc(points / totalCorrectAnswers * 100);
|
|
78
|
+
|
|
79
|
+
var translate = function translate(id, values) {
|
|
80
|
+
return emitEvent({
|
|
81
|
+
type: 'translate',
|
|
82
|
+
payload: id,
|
|
83
|
+
values: values
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
(0, _react.useEffect)(function () {
|
|
88
|
+
if (points < correctAnswersChecked) {
|
|
89
|
+
var timeout = setInterval(function () {
|
|
90
|
+
setPoints(function (t) {
|
|
91
|
+
return t + 1;
|
|
92
|
+
});
|
|
93
|
+
}, 100);
|
|
94
|
+
saveInterval(timeout);
|
|
95
|
+
return function () {
|
|
96
|
+
clearInterval(timeout);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return undefined;
|
|
101
|
+
}, [correctAnswersChecked, points]);
|
|
102
|
+
(0, _react.useEffect)(function () {
|
|
103
|
+
if (points >= correctAnswersChecked) {
|
|
104
|
+
clearInterval(interval);
|
|
105
|
+
}
|
|
106
|
+
}, [correctAnswersChecked, interval, points]);
|
|
107
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
108
|
+
className: "test--results"
|
|
109
|
+
}, isFirst && correctAnswersChecked === totalCorrectAnswers ? /*#__PURE__*/_react.default.createElement("div", {
|
|
110
|
+
className: "fireworks"
|
|
111
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
112
|
+
className: "before"
|
|
113
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
114
|
+
className: "after"
|
|
115
|
+
})) : null, /*#__PURE__*/_react.default.createElement("div", {
|
|
116
|
+
className: "test--results__title"
|
|
117
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, translate(timeOver ? timeOverText : 'tests.finished'))), time ? /*#__PURE__*/_react.default.createElement("div", {
|
|
118
|
+
className: "test--results__time",
|
|
119
|
+
id: "results-time"
|
|
120
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, translate('tests.time', time))) : null, /*#__PURE__*/_react.default.createElement("div", {
|
|
121
|
+
className: "chart center chart".concat(bar)
|
|
122
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
123
|
+
className: "chart-slice"
|
|
124
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
125
|
+
className: "chart-bar"
|
|
126
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
127
|
+
className: "chart-fill"
|
|
128
|
+
})), /*#__PURE__*/_react.default.createElement("span", {
|
|
129
|
+
className: "chart-value"
|
|
130
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
131
|
+
className: "test--results__chart"
|
|
132
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, points), /*#__PURE__*/_react.default.createElement("span", null, "/", totalCorrectAnswers)), /*#__PURE__*/_react.default.createElement("div", {
|
|
133
|
+
className: "test--results__chart--label"
|
|
134
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, translate('tests.success'))))), haveRewards ? /*#__PURE__*/_react.default.createElement(_rewardsComponent.default, {
|
|
135
|
+
rewards: rewards,
|
|
136
|
+
emitEvent: emitEvent
|
|
137
|
+
}) : null, /*#__PURE__*/_react.default.createElement("div", {
|
|
138
|
+
className: "test--buttons"
|
|
139
|
+
}, !timeOver ? /*#__PURE__*/_react.default.createElement("button", {
|
|
140
|
+
className: "gat--btn gat--btn__secondary",
|
|
141
|
+
id: "review-button",
|
|
142
|
+
onClick: function onClick() {
|
|
143
|
+
return reviewTest();
|
|
144
|
+
},
|
|
145
|
+
type: "button"
|
|
146
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, translate('tests.review'))) : null, showRetryButton ? /*#__PURE__*/_react.default.createElement("button", {
|
|
147
|
+
className: "gat--btn gat--btn__primary",
|
|
148
|
+
id: "restart-button",
|
|
149
|
+
onClick: function onClick() {
|
|
150
|
+
return restartTest();
|
|
151
|
+
},
|
|
152
|
+
type: "button"
|
|
153
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, translate('tests.restart'))) : null, showFinishButton ? /*#__PURE__*/_react.default.createElement("button", {
|
|
154
|
+
className: "gat--btn gat--btn__primary",
|
|
155
|
+
id: "finish-button",
|
|
156
|
+
onClick: function onClick() {
|
|
157
|
+
return finishTest();
|
|
158
|
+
},
|
|
159
|
+
type: "button"
|
|
160
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, translate('tests.continue'))) : null));
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
var _default = ResultsComponent;
|
|
164
|
+
exports.default = _default;
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _Container = _interopRequireDefault(require("./Container"));
|
|
13
|
+
|
|
14
|
+
var _Results = _interopRequireDefault(require("./Results"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
23
|
+
|
|
24
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
25
|
+
|
|
26
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
27
|
+
|
|
28
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
29
|
+
|
|
30
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
31
|
+
|
|
32
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
33
|
+
|
|
34
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
35
|
+
|
|
36
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
37
|
+
|
|
38
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
39
|
+
|
|
40
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
41
|
+
|
|
42
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
43
|
+
|
|
44
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
45
|
+
|
|
46
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
47
|
+
|
|
48
|
+
var TestComponent = function TestComponent(_ref) {
|
|
49
|
+
var test = _ref.test,
|
|
50
|
+
_ref$countdown = _ref.countdown,
|
|
51
|
+
countdown = _ref$countdown === void 0 ? {} : _ref$countdown,
|
|
52
|
+
emitEvent = _ref.emitEvent,
|
|
53
|
+
soundActions = _ref.soundActions,
|
|
54
|
+
audio = _ref.audio,
|
|
55
|
+
required = _ref.required;
|
|
56
|
+
var questions = test.questions;
|
|
57
|
+
var indicators = emitEvent({
|
|
58
|
+
type: 'loadIndicators'
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
var _useState = (0, _react.useState)({}),
|
|
62
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
63
|
+
result = _useState2[0],
|
|
64
|
+
setResult = _useState2[1];
|
|
65
|
+
|
|
66
|
+
var _useState3 = (0, _react.useState)(),
|
|
67
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
68
|
+
interval = _useState4[0],
|
|
69
|
+
saveInterval = _useState4[1];
|
|
70
|
+
|
|
71
|
+
var _useState5 = (0, _react.useState)(0),
|
|
72
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
73
|
+
tries = _useState6[0],
|
|
74
|
+
setTries = _useState6[1];
|
|
75
|
+
|
|
76
|
+
var _useState7 = (0, _react.useState)([]),
|
|
77
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
78
|
+
correctAnswers = _useState8[0],
|
|
79
|
+
setCorrectAnswers = _useState8[1];
|
|
80
|
+
|
|
81
|
+
var _useState9 = (0, _react.useState)(countdown.time),
|
|
82
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
83
|
+
time = _useState10[0],
|
|
84
|
+
setTime = _useState10[1];
|
|
85
|
+
|
|
86
|
+
var _useState11 = (0, _react.useState)(false),
|
|
87
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
88
|
+
answeredPage = _useState12[0],
|
|
89
|
+
answerPage = _useState12[1];
|
|
90
|
+
|
|
91
|
+
var _useState13 = (0, _react.useState)('test'),
|
|
92
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
93
|
+
view = _useState14[0],
|
|
94
|
+
changeView = _useState14[1];
|
|
95
|
+
|
|
96
|
+
var _useState15 = (0, _react.useState)(true),
|
|
97
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
98
|
+
isFirst = _useState16[0],
|
|
99
|
+
changeFirst = _useState16[1];
|
|
100
|
+
|
|
101
|
+
var _useState17 = (0, _react.useState)({
|
|
102
|
+
negatives: {},
|
|
103
|
+
positives: {}
|
|
104
|
+
}),
|
|
105
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
106
|
+
resultHolder = _useState18[0],
|
|
107
|
+
setResultHolder = _useState18[1];
|
|
108
|
+
|
|
109
|
+
var _useState19 = (0, _react.useState)({}),
|
|
110
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
111
|
+
showingResult = _useState20[0],
|
|
112
|
+
setShowingResult = _useState20[1];
|
|
113
|
+
|
|
114
|
+
var _useState21 = (0, _react.useState)({}),
|
|
115
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
116
|
+
historicAnswers = _useState22[0],
|
|
117
|
+
setHistoric = _useState22[1];
|
|
118
|
+
|
|
119
|
+
var _useState23 = (0, _react.useState)(false),
|
|
120
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
121
|
+
timeOver = _useState24[0],
|
|
122
|
+
setTimeOver = _useState24[1];
|
|
123
|
+
|
|
124
|
+
var isRequired = required || test.required || false;
|
|
125
|
+
|
|
126
|
+
var _soundActions = _slicedToArray(soundActions, 2),
|
|
127
|
+
playSound = _soundActions[0],
|
|
128
|
+
stop = _soundActions[1];
|
|
129
|
+
|
|
130
|
+
var updateForm = function updateForm(optionSelected, question, index) {
|
|
131
|
+
var actualQuestion = _objectSpread(_objectSpread({}, optionSelected), {}, {
|
|
132
|
+
index: index
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
if (tries > 0) {
|
|
136
|
+
actualQuestion.rewards = actualQuestion.rewards.filter(function (reward) {
|
|
137
|
+
return !historicAnswers[optionSelected.id] || reward.points < 0;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
var actualResult = _objectSpread(_objectSpread({}, result), {}, _defineProperty({}, question, actualQuestion));
|
|
142
|
+
|
|
143
|
+
setResult(actualResult);
|
|
144
|
+
setShowingResult(actualResult);
|
|
145
|
+
setHistoric(_objectSpread(_objectSpread({}, historicAnswers), {}, _defineProperty({}, optionSelected.id, _objectSpread({}, optionSelected))));
|
|
146
|
+
answerPage(true);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
(0, _react.useEffect)(function () {
|
|
150
|
+
if (audio.url) {
|
|
151
|
+
playSound(audio.url);
|
|
152
|
+
}
|
|
153
|
+
}, [playSound, audio]);
|
|
154
|
+
(0, _react.useEffect)(function () {
|
|
155
|
+
var answers = questions.map(function (q) {
|
|
156
|
+
var answer = q.answers.find(function (a) {
|
|
157
|
+
return a.isCorrect;
|
|
158
|
+
});
|
|
159
|
+
return {
|
|
160
|
+
question: q.id,
|
|
161
|
+
answer: answer.id
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
setCorrectAnswers(answers);
|
|
165
|
+
}, [questions]);
|
|
166
|
+
(0, _react.useEffect)(function () {
|
|
167
|
+
if (time === 0) {
|
|
168
|
+
clearInterval(interval);
|
|
169
|
+
answerPage(false);
|
|
170
|
+
setTimeOver(true);
|
|
171
|
+
changeView('results');
|
|
172
|
+
stop();
|
|
173
|
+
}
|
|
174
|
+
}, [interval, stop, time]);
|
|
175
|
+
|
|
176
|
+
var showResults = function showResults() {
|
|
177
|
+
clearInterval(interval);
|
|
178
|
+
answerPage(false);
|
|
179
|
+
changeView('results');
|
|
180
|
+
|
|
181
|
+
var parsedShowingResult = _objectSpread({}, showingResult);
|
|
182
|
+
|
|
183
|
+
Object.keys(resultHolder.positives).forEach(function (questionID) {
|
|
184
|
+
if (parsedShowingResult[questionID] && parsedShowingResult[questionID].id === resultHolder.positives[questionID].id) {
|
|
185
|
+
delete parsedShowingResult[questionID];
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
setShowingResult(parsedShowingResult);
|
|
189
|
+
stop();
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
var finishTest = function finishTest() {
|
|
193
|
+
var actualResult = {
|
|
194
|
+
correctAnswers: correctAnswers.length,
|
|
195
|
+
result: result,
|
|
196
|
+
status: 'resolved'
|
|
197
|
+
};
|
|
198
|
+
Object.keys(actualResult.result).forEach(function (questionID) {
|
|
199
|
+
if (resultHolder.negatives[questionID]) {
|
|
200
|
+
actualResult.result[questionID].rewards = [].concat(_toConsumableArray(actualResult.result[questionID].rewards), _toConsumableArray(resultHolder.negatives[questionID].rewards));
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
emitEvent({
|
|
204
|
+
type: 'saveTest',
|
|
205
|
+
payload: actualResult
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
var restartTest = function restartTest() {
|
|
210
|
+
var holder = _objectSpread({}, resultHolder);
|
|
211
|
+
|
|
212
|
+
Object.keys(result).forEach(function (questionID) {
|
|
213
|
+
var isCorrect = result[questionID].isCorrect ? 'positives' : 'negatives';
|
|
214
|
+
|
|
215
|
+
if (holder[isCorrect][questionID]) {
|
|
216
|
+
holder[isCorrect][questionID].rewards = [].concat(_toConsumableArray(holder[isCorrect][questionID].rewards), _toConsumableArray(result[questionID].rewards));
|
|
217
|
+
} else {
|
|
218
|
+
holder[isCorrect][questionID] = result[questionID];
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
setShowingResult({});
|
|
222
|
+
setHistoric({});
|
|
223
|
+
setResultHolder(holder);
|
|
224
|
+
changeView('test');
|
|
225
|
+
setResult({});
|
|
226
|
+
setTime(countdown.time);
|
|
227
|
+
setTimeOver(false);
|
|
228
|
+
stop();
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
var translate = function translate(id, values) {
|
|
232
|
+
return emitEvent({
|
|
233
|
+
type: 'translate',
|
|
234
|
+
payload: id,
|
|
235
|
+
values: values
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
240
|
+
className: "test--container"
|
|
241
|
+
}, view !== 'results' ? /*#__PURE__*/_react.default.createElement(_Container.default, {
|
|
242
|
+
type: test.type,
|
|
243
|
+
result: result,
|
|
244
|
+
time: time,
|
|
245
|
+
setTries: setTries,
|
|
246
|
+
tries: tries,
|
|
247
|
+
answerPage: answerPage,
|
|
248
|
+
setTime: setTime,
|
|
249
|
+
saveInterval: saveInterval,
|
|
250
|
+
disabled: view !== 'test',
|
|
251
|
+
answered: answeredPage || view !== 'test',
|
|
252
|
+
questions: questions,
|
|
253
|
+
updateForm: updateForm,
|
|
254
|
+
showResults: showResults,
|
|
255
|
+
translate: translate
|
|
256
|
+
}) : /*#__PURE__*/_react.default.createElement(_Results.default, {
|
|
257
|
+
reviewTest: function reviewTest() {
|
|
258
|
+
changeFirst(false);
|
|
259
|
+
changeView('review');
|
|
260
|
+
},
|
|
261
|
+
isFirst: isFirst,
|
|
262
|
+
finishTest: finishTest,
|
|
263
|
+
time: time,
|
|
264
|
+
mandatory: isRequired,
|
|
265
|
+
type: test.type,
|
|
266
|
+
restartTest: restartTest,
|
|
267
|
+
result: result,
|
|
268
|
+
showingResult: showingResult,
|
|
269
|
+
correctAnswers: correctAnswers,
|
|
270
|
+
indicators: indicators,
|
|
271
|
+
timeOver: timeOver,
|
|
272
|
+
timeOverText: countdown.text,
|
|
273
|
+
emitEvent: emitEvent
|
|
274
|
+
}));
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
var _default = TestComponent;
|
|
278
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _TestComponent = _interopRequireDefault(require("./components/TestComponent"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
var _default = _TestComponent.default;
|
|
13
|
+
exports.default = _default;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mockProps = void 0;
|
|
7
|
+
|
|
8
|
+
var emitEvent = function emitEvent(_ref) {
|
|
9
|
+
var type = _ref.type,
|
|
10
|
+
payload = _ref.payload;
|
|
11
|
+
console.log('Emit event called');
|
|
12
|
+
|
|
13
|
+
if (type === 'translate') {
|
|
14
|
+
return payload;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (type === 'loadIndicators') {
|
|
18
|
+
return {
|
|
19
|
+
score: [{
|
|
20
|
+
color: '#4e469e',
|
|
21
|
+
description: 'description_0_dY5ms0vf',
|
|
22
|
+
description_labelId: 'description_0_dY5ms0vf',
|
|
23
|
+
icon: 'font-indicator-bolsa',
|
|
24
|
+
id: 'ki4qrkam',
|
|
25
|
+
name: 'Indicator1',
|
|
26
|
+
name_labelId: 'name_0_dY5ms9T1',
|
|
27
|
+
points: 295,
|
|
28
|
+
type: 'score'
|
|
29
|
+
}, {
|
|
30
|
+
color: '#4e469e',
|
|
31
|
+
description: 'description_0_dY5ms0vf',
|
|
32
|
+
description_labelId: 'description_0_dY5ms0vf',
|
|
33
|
+
icon: 'font-indicator-bolsa',
|
|
34
|
+
id: 'ki4qrop',
|
|
35
|
+
name: 'Indicator1',
|
|
36
|
+
name_labelId: 'name_0_dY5ms9T1',
|
|
37
|
+
points: 300,
|
|
38
|
+
type: 'score'
|
|
39
|
+
}, {
|
|
40
|
+
color: '#4e469e',
|
|
41
|
+
description: 'description_0_dY5ms0vf',
|
|
42
|
+
description_labelId: 'description_0_dY5ms0vf',
|
|
43
|
+
icon: 'font-indicator-bolsa',
|
|
44
|
+
id: 'ki4qiuyi',
|
|
45
|
+
name: 'Indicator1',
|
|
46
|
+
name_labelId: 'name_0_dY5ms9T1',
|
|
47
|
+
points: 300,
|
|
48
|
+
type: 'score'
|
|
49
|
+
}],
|
|
50
|
+
skill: [{
|
|
51
|
+
color: '#559cac',
|
|
52
|
+
description: 'description_0_dY5msi7o',
|
|
53
|
+
description_labelId: 'description_0_dY5msi7o',
|
|
54
|
+
icon: 'font-indicator-microfono-2',
|
|
55
|
+
id: 'ki4qrkas',
|
|
56
|
+
name: 'competency2',
|
|
57
|
+
name_labelId: 'name_0_dY5mslgV',
|
|
58
|
+
points: 295,
|
|
59
|
+
type: 'skill'
|
|
60
|
+
}, {
|
|
61
|
+
color: '#559cac',
|
|
62
|
+
description: 'description_0_dY5msi7o',
|
|
63
|
+
description_labelId: 'description_0_dY5msi7o',
|
|
64
|
+
icon: 'font-indicator-microfono-2',
|
|
65
|
+
id: 'ki4qropi',
|
|
66
|
+
name: 'competency2',
|
|
67
|
+
name_labelId: 'name_0_dY5mslgV',
|
|
68
|
+
points: 295,
|
|
69
|
+
type: 'skill'
|
|
70
|
+
}],
|
|
71
|
+
grade: undefined
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
var soundActions = [function () {}, function () {}];
|
|
77
|
+
var mockProps = {
|
|
78
|
+
emitEvent: emitEvent,
|
|
79
|
+
soundActions: soundActions,
|
|
80
|
+
audio: {
|
|
81
|
+
url: 'https://min.int.gamelearn.io/cooked.gl-lms-storage/clients/58dccfba26561500117caf53/documents/Cat-sound.mp3'
|
|
82
|
+
},
|
|
83
|
+
test: {
|
|
84
|
+
required: true,
|
|
85
|
+
questions: [{
|
|
86
|
+
id: 'q1',
|
|
87
|
+
text: 'q1',
|
|
88
|
+
answers: [{
|
|
89
|
+
id: 'q1a1',
|
|
90
|
+
text: 'q1text',
|
|
91
|
+
rewards: [{
|
|
92
|
+
id: 'id010001',
|
|
93
|
+
name: 'love',
|
|
94
|
+
points: -25,
|
|
95
|
+
type: 'score'
|
|
96
|
+
}],
|
|
97
|
+
isCorrect: false,
|
|
98
|
+
feedback: 'A while back I needed to count the amount of letters that a piece of text in an email template had (to avoid passing any character limits). Unfortunately, I could not think of a quick way to do so on my macbook and I therefore turned to the Internet. There were a couple of tools out there, but none of them met my standards and since I am a web designer I thought: why not do it myself and help others along the way? Character Count Online is a free online character and word counting tool. All resu'
|
|
99
|
+
}, {
|
|
100
|
+
id: 'q1a2',
|
|
101
|
+
text: 'q1text2',
|
|
102
|
+
rewards: [{
|
|
103
|
+
id: 'id010001',
|
|
104
|
+
name: 'love',
|
|
105
|
+
points: -25,
|
|
106
|
+
type: 'score'
|
|
107
|
+
}],
|
|
108
|
+
feedback: '222 A while back I needed to count the amount of letters that a piece of text in an email template had (to avoid passing any character limits). Unfortunately, I could not think of a quick way to do so on my macbook and I therefore turned to the Internet. There were a couple of tools out there, but none of them met my standards and since I am a web designer I thought: why not do it myself and help others along the way? Character Count Online is a free online character and word counting tool. All resu',
|
|
109
|
+
isCorrect: false
|
|
110
|
+
}, {
|
|
111
|
+
id: 'q1a3',
|
|
112
|
+
text: 'q1text3',
|
|
113
|
+
rewards: [{
|
|
114
|
+
id: 'id010001',
|
|
115
|
+
name: 'love',
|
|
116
|
+
points: 50,
|
|
117
|
+
type: 'score'
|
|
118
|
+
}],
|
|
119
|
+
feedback: 'okkk A while back I needed to count the amount of letters that a piece of text in an email template had (to avoid passing any character limits). Unfortunately, I could not think of a quick way to do so on my macbook and I therefore turned to the Internet. There were a couple of tools out there, but none of them met my standards and since I am a web designer I thought: why not do it myself and help others along the way? Character Count Online is a free online character and word counting tool. All resu',
|
|
120
|
+
isCorrect: true
|
|
121
|
+
}]
|
|
122
|
+
}, {
|
|
123
|
+
id: 'q2',
|
|
124
|
+
text: 'q2',
|
|
125
|
+
answers: [{
|
|
126
|
+
id: 'q2a1',
|
|
127
|
+
text: 'q2text',
|
|
128
|
+
rewards: [{
|
|
129
|
+
id: 'id010001',
|
|
130
|
+
name: 'love',
|
|
131
|
+
points: -25,
|
|
132
|
+
type: 'score'
|
|
133
|
+
}],
|
|
134
|
+
isCorrect: false,
|
|
135
|
+
feedback: 'A while back I needed to count the amount of letters that a piece of text in an email template had (to avoid passing any character limits). Unfortunately, I could not think of a quick way to do so on my macbook and I therefore turned to the Internet. There were a couple of tools out there, but none of them met my standards and since I am a web designer I thought: why not do it myself and help others along the way? Character Count Online is a free online character and word counting tool. All resu'
|
|
136
|
+
}, {
|
|
137
|
+
id: 'q2a2',
|
|
138
|
+
text: 'love',
|
|
139
|
+
rewards: [{
|
|
140
|
+
id: 'id010001',
|
|
141
|
+
name: 'love',
|
|
142
|
+
points: -25,
|
|
143
|
+
type: 'score'
|
|
144
|
+
}],
|
|
145
|
+
feedback: '222',
|
|
146
|
+
isCorrect: false
|
|
147
|
+
}, {
|
|
148
|
+
id: 'q2a3',
|
|
149
|
+
text: 'love',
|
|
150
|
+
rewards: [{
|
|
151
|
+
id: 'id010001',
|
|
152
|
+
name: 'love',
|
|
153
|
+
points: 50,
|
|
154
|
+
type: 'score'
|
|
155
|
+
}],
|
|
156
|
+
feedback: 'okkk',
|
|
157
|
+
isCorrect: true
|
|
158
|
+
}]
|
|
159
|
+
}]
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
exports.mockProps = mockProps;
|
|
@@ -9,7 +9,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _RewardsComponent = _interopRequireDefault(require("../../rewards-component/components/RewardsComponent"));
|
|
13
13
|
|
|
14
14
|
var _FeedbackElement = _interopRequireDefault(require("./FeedbackElement"));
|
|
15
15
|
|
|
@@ -66,9 +66,10 @@ var FeedbackComponent = function FeedbackComponent(_ref) {
|
|
|
66
66
|
className: "writer-feedback__points ".concat(!decisionsList ? 'center' : '')
|
|
67
67
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
68
68
|
className: "writer-feedback__title"
|
|
69
|
-
}, translate('puzzles.feedback')), rewardsStack.length !== 0 && /*#__PURE__*/_react.default.createElement(
|
|
69
|
+
}, translate('puzzles.feedback')), rewardsStack.length !== 0 && /*#__PURE__*/_react.default.createElement(_RewardsComponent.default, {
|
|
70
70
|
rewards: rewardsStack,
|
|
71
|
-
nodeId: nodeId
|
|
71
|
+
nodeId: nodeId,
|
|
72
|
+
emitEvent: emitEvent
|
|
72
73
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
73
74
|
className: "writer-feedback__decisions"
|
|
74
75
|
}, decisionsList.map(function (decision) {
|
|
@@ -12,6 +12,27 @@ var emitEvent = function emitEvent(_ref) {
|
|
|
12
12
|
if (type === 'translate') {
|
|
13
13
|
return payload;
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
if (type === 'loadIndicators') {
|
|
17
|
+
return {
|
|
18
|
+
score: [{
|
|
19
|
+
type: 'score',
|
|
20
|
+
points: 187300,
|
|
21
|
+
origName: 'Title 1',
|
|
22
|
+
name: '1a3b2d40',
|
|
23
|
+
description: '88878788',
|
|
24
|
+
id: 'k2koxnkq',
|
|
25
|
+
icon: 'font-indicator-chincheta',
|
|
26
|
+
records: [{
|
|
27
|
+
id: 'k2koxnkq',
|
|
28
|
+
name: '1a3b2d40',
|
|
29
|
+
icon: 'font-indicator-chincheta'
|
|
30
|
+
}]
|
|
31
|
+
}],
|
|
32
|
+
skill: [],
|
|
33
|
+
grade: {}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
15
36
|
};
|
|
16
37
|
|
|
17
38
|
var messages = {
|