@coorpacademy/app-review 0.2.7 → 0.2.9-alpha.5
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/actions/api/fetch-rank.d.ts +32 -0
- package/es/actions/api/fetch-rank.js +30 -0
- package/es/actions/api/test/fetch-correction.test.js +2 -1
- package/es/actions/api/test/fetch-rank.test.d.ts +1 -0
- package/es/actions/api/test/fetch-rank.test.js +100 -0
- package/es/actions/api/test/fetch-skills.test.js +2 -1
- package/es/actions/api/test/fetch-slide.test.js +2 -1
- package/es/actions/api/test/post-answer.test.js +2 -1
- package/es/actions/api/test/post-progression.test.js +2 -1
- package/es/actions/data/test/token.test.js +2 -1
- package/es/actions/ui/test/answers.test.js +2 -1
- package/es/actions/ui/test/slides.test.js +2 -1
- package/es/reducers/data/corrections.d.ts +1 -1
- package/es/reducers/data/index.d.ts +4 -1
- package/es/reducers/data/index.js +2 -1
- package/es/reducers/data/rank.d.ts +7 -0
- package/es/reducers/data/rank.js +36 -0
- package/es/reducers/data/test/rank.test.d.ts +1 -0
- package/es/reducers/data/test/rank.test.js +59 -0
- package/es/reducers/index.d.ts +4 -3
- package/es/reducers/ui/slide.d.ts +1 -0
- package/es/reducers/ui/slide.js +1 -1
- package/es/services/index.js +2 -0
- package/es/test/util/services.mock.d.ts +1 -0
- package/es/test/util/services.mock.js +21 -1
- package/es/types/common.d.ts +1 -0
- package/es/views/skills/test/skills.test.js +4 -2
- package/es/views/slides/index.d.ts +21 -19
- package/es/views/slides/index.js +29 -3
- package/es/views/slides/test/fixtures/qcm-graphic.js +190 -28
- package/es/views/slides/test/index.test.js +200 -19
- package/es/views/slides/test/slide.free-text.on-change.test.js +4 -1
- package/es/views/slides/test/slide.qcm-drag.on-click.test.js +4 -1
- package/es/views/slides/test/slide.qcm-graphic.on-click.test.js +6 -3
- package/es/views/slides/test/slide.qcm.on-click.test.js +4 -1
- package/es/views/slides/test/slide.slider.on-change.test.js +4 -1
- package/es/views/slides/test/slide.template.on-change.test.js +6 -1
- package/lib/actions/api/fetch-rank.d.ts +32 -0
- package/lib/actions/api/fetch-rank.js +32 -0
- package/lib/actions/api/test/fetch-correction.test.js +2 -1
- package/lib/actions/api/test/fetch-rank.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-rank.test.js +171 -0
- package/lib/actions/api/test/fetch-skills.test.js +2 -1
- package/lib/actions/api/test/fetch-slide.test.js +2 -1
- package/lib/actions/api/test/post-answer.test.js +2 -1
- package/lib/actions/api/test/post-progression.test.js +2 -1
- package/lib/actions/data/test/token.test.js +2 -1
- package/lib/actions/ui/test/answers.test.js +2 -1
- package/lib/actions/ui/test/slides.test.js +2 -1
- package/lib/reducers/data/corrections.d.ts +1 -1
- package/lib/reducers/data/index.d.ts +4 -1
- package/lib/reducers/data/index.js +2 -1
- package/lib/reducers/data/rank.d.ts +7 -0
- package/lib/reducers/data/rank.js +37 -0
- package/lib/reducers/data/test/rank.test.d.ts +1 -0
- package/lib/reducers/data/test/rank.test.js +59 -0
- package/lib/reducers/index.d.ts +4 -3
- package/lib/reducers/ui/slide.d.ts +1 -0
- package/lib/reducers/ui/slide.js +1 -1
- package/lib/services/index.js +2 -0
- package/lib/test/util/services.mock.d.ts +1 -0
- package/lib/test/util/services.mock.js +12 -1
- package/lib/types/common.d.ts +1 -0
- package/lib/views/skills/test/skills.test.js +4 -2
- package/lib/views/slides/index.d.ts +21 -19
- package/lib/views/slides/index.js +29 -3
- package/lib/views/slides/test/fixtures/qcm-graphic.js +190 -28
- package/lib/views/slides/test/index.test.js +211 -22
- package/lib/views/slides/test/slide.free-text.on-change.test.js +4 -1
- package/lib/views/slides/test/slide.qcm-drag.on-click.test.js +4 -1
- package/lib/views/slides/test/slide.qcm-graphic.on-click.test.js +6 -3
- package/lib/views/slides/test/slide.qcm.on-click.test.js +4 -1
- package/lib/views/slides/test/slide.slider.on-change.test.js +4 -1
- package/lib/views/slides/test/slide.template.on-change.test.js +6 -1
- package/package.json +4 -4
- package/src/actions/api/fetch-rank.ts +84 -0
- package/src/actions/api/test/fetch-correction.test.ts +2 -1
- package/src/actions/api/test/fetch-rank.test.ts +130 -0
- package/src/actions/api/test/fetch-skills.test.ts +2 -1
- package/src/actions/api/test/fetch-slide.test.ts +2 -1
- package/src/actions/api/test/post-answer.test.ts +2 -1
- package/src/actions/api/test/post-progression.test.ts +2 -1
- package/src/actions/data/test/token.test.ts +2 -1
- package/src/actions/ui/test/answers.test.ts +2 -1
- package/src/actions/ui/test/slides.test.ts +2 -1
- package/src/reducers/data/corrections.ts +1 -1
- package/src/reducers/data/index.ts +3 -1
- package/src/reducers/data/rank.ts +60 -0
- package/src/reducers/data/test/rank.test.ts +78 -0
- package/src/reducers/index.ts +2 -2
- package/src/reducers/ui/slide.ts +2 -1
- package/src/services/index.ts +2 -0
- package/src/test/util/services.mock.ts +23 -1
- package/src/types/common.ts +1 -0
- package/src/views/skills/test/skills.test.ts +4 -2
- package/src/views/slides/index.ts +65 -22
- package/src/views/slides/test/fixtures/qcm-graphic.ts +196 -29
- package/src/views/slides/test/index.test.ts +210 -21
- package/src/views/slides/test/slide.free-text.on-change.test.ts +4 -1
- package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +4 -1
- package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +6 -4
- package/src/views/slides/test/slide.qcm.on-click.test.ts +4 -1
- package/src/views/slides/test/slide.slider.on-change.test.ts +4 -1
- package/src/views/slides/test/slide.template.on-change.test.ts +6 -1
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import test from 'ava';
|
|
49
|
+
import { fetchStartRank, fetchEndRank, RANK_FETCH_START_REQUEST, RANK_FETCH_START_SUCCESS, RANK_FETCH_START_FAILURE, RANK_FETCH_END_REQUEST, RANK_FETCH_END_SUCCESS, RANK_FETCH_END_FAILURE } from '../fetch-rank';
|
|
50
|
+
import { services as mockedServices } from '../../../test/util/services.mock';
|
|
51
|
+
import { createTestStore } from '../../test/create-test-store';
|
|
52
|
+
var initialState = {
|
|
53
|
+
data: {
|
|
54
|
+
progression: null,
|
|
55
|
+
slides: {},
|
|
56
|
+
skills: [],
|
|
57
|
+
token: '1234',
|
|
58
|
+
corrections: {},
|
|
59
|
+
rank: {}
|
|
60
|
+
},
|
|
61
|
+
ui: {
|
|
62
|
+
currentSlideRef: '',
|
|
63
|
+
navigation: [],
|
|
64
|
+
answers: [],
|
|
65
|
+
slide: {
|
|
66
|
+
validateButton: false
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
test('should dispatch FETCH_START_SUCCESS action when fetchStartRank returns the start rank', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
71
|
+
var services, expectedActions, dispatch;
|
|
72
|
+
return __generator(this, function (_a) {
|
|
73
|
+
switch (_a.label) {
|
|
74
|
+
case 0:
|
|
75
|
+
t.plan(3);
|
|
76
|
+
services = __assign(__assign({}, mockedServices), { fetchRank: function (token) {
|
|
77
|
+
t.is(token, '1234');
|
|
78
|
+
return Promise.resolve({ rank: 93 });
|
|
79
|
+
} });
|
|
80
|
+
expectedActions = [
|
|
81
|
+
{ type: RANK_FETCH_START_REQUEST },
|
|
82
|
+
{
|
|
83
|
+
type: RANK_FETCH_START_SUCCESS,
|
|
84
|
+
payload: { rank: 93 }
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
88
|
+
return [4 /*yield*/, dispatch(fetchStartRank)];
|
|
89
|
+
case 1:
|
|
90
|
+
_a.sent();
|
|
91
|
+
return [2 /*return*/];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}); });
|
|
95
|
+
test('should dispatch FETCH_START_FAILURE action when fetchStartRank fails', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
96
|
+
var services, expectedActions, dispatch;
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
switch (_a.label) {
|
|
99
|
+
case 0:
|
|
100
|
+
t.plan(3);
|
|
101
|
+
services = __assign(__assign({}, mockedServices), { fetchRank: function (token) {
|
|
102
|
+
t.is(token, '1234');
|
|
103
|
+
return Promise.reject(new Error('unexpected'));
|
|
104
|
+
} });
|
|
105
|
+
expectedActions = [
|
|
106
|
+
{ type: RANK_FETCH_START_REQUEST },
|
|
107
|
+
{
|
|
108
|
+
type: RANK_FETCH_START_FAILURE,
|
|
109
|
+
payload: new Error('unexpected'),
|
|
110
|
+
error: true
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
114
|
+
return [4 /*yield*/, dispatch(fetchStartRank)];
|
|
115
|
+
case 1:
|
|
116
|
+
_a.sent();
|
|
117
|
+
return [2 /*return*/];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}); });
|
|
121
|
+
test('should dispatch FETCH_END_SUCCESS action when fetchEndRank returns the end rank', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
122
|
+
var services, expectedActions, dispatch;
|
|
123
|
+
return __generator(this, function (_a) {
|
|
124
|
+
switch (_a.label) {
|
|
125
|
+
case 0:
|
|
126
|
+
t.plan(3);
|
|
127
|
+
services = __assign(__assign({}, mockedServices), { fetchRank: function (token) {
|
|
128
|
+
t.is(token, '1234');
|
|
129
|
+
return Promise.resolve({ rank: 93 });
|
|
130
|
+
} });
|
|
131
|
+
expectedActions = [
|
|
132
|
+
{ type: RANK_FETCH_END_REQUEST },
|
|
133
|
+
{
|
|
134
|
+
type: RANK_FETCH_END_SUCCESS,
|
|
135
|
+
payload: { rank: 93 }
|
|
136
|
+
}
|
|
137
|
+
];
|
|
138
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
139
|
+
return [4 /*yield*/, dispatch(fetchEndRank)];
|
|
140
|
+
case 1:
|
|
141
|
+
_a.sent();
|
|
142
|
+
return [2 /*return*/];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}); });
|
|
146
|
+
test('should dispatch FETCH_END_FAILURE action when fetchEndRank fails', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
147
|
+
var services, expectedActions, dispatch;
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
switch (_a.label) {
|
|
150
|
+
case 0:
|
|
151
|
+
t.plan(3);
|
|
152
|
+
services = __assign(__assign({}, mockedServices), { fetchRank: function (token) {
|
|
153
|
+
t.is(token, '1234');
|
|
154
|
+
return Promise.reject(new Error('unexpected'));
|
|
155
|
+
} });
|
|
156
|
+
expectedActions = [
|
|
157
|
+
{ type: RANK_FETCH_END_REQUEST },
|
|
158
|
+
{
|
|
159
|
+
type: RANK_FETCH_END_FAILURE,
|
|
160
|
+
payload: new Error('unexpected'),
|
|
161
|
+
error: true
|
|
162
|
+
}
|
|
163
|
+
];
|
|
164
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
165
|
+
return [4 /*yield*/, dispatch(fetchEndRank)];
|
|
166
|
+
case 1:
|
|
167
|
+
_a.sent();
|
|
168
|
+
return [2 /*return*/];
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}); });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CorrectionFromAPI } from '../../types/common';
|
|
1
|
+
import type { CorrectionFromAPI } from '../../types/common';
|
|
2
2
|
import { ReceivedCorrection, FetchCorrection } from '../../actions/api/fetch-correction';
|
|
3
3
|
export declare type CorrectionsState = Record<string, CorrectionFromAPI>;
|
|
4
4
|
export declare type CorrectionsAction = ReceivedCorrection | FetchCorrection;
|
|
@@ -3,12 +3,14 @@ import { ProgressionState } from './progression';
|
|
|
3
3
|
import { SkillsState } from './skills';
|
|
4
4
|
import { SlidesState } from './slides';
|
|
5
5
|
import { TokenState } from './token';
|
|
6
|
+
import { RankState } from './rank';
|
|
6
7
|
export declare type DataState = {
|
|
7
8
|
corrections: CorrectionsState;
|
|
8
9
|
progression: ProgressionState;
|
|
9
10
|
skills: SkillsState;
|
|
10
11
|
slides: SlidesState;
|
|
11
12
|
token: TokenState;
|
|
13
|
+
rank: RankState;
|
|
12
14
|
};
|
|
13
15
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
14
16
|
corrections: CorrectionsState;
|
|
@@ -16,5 +18,6 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
16
18
|
skills: SkillsState;
|
|
17
19
|
slides: SlidesState;
|
|
18
20
|
token: string;
|
|
19
|
-
|
|
21
|
+
rank: RankState;
|
|
22
|
+
}>, import("./corrections").CorrectionsAction | import("../../actions/api/post-answer").PostAnswerSuccessAction | import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken | import("../../actions/api/fetch-rank").RankAction>;
|
|
20
23
|
export default _default;
|
|
@@ -4,4 +4,5 @@ import progression from './progression';
|
|
|
4
4
|
import skills from './skills';
|
|
5
5
|
import slides from './slides';
|
|
6
6
|
import token from './token';
|
|
7
|
-
|
|
7
|
+
import rank from './rank';
|
|
8
|
+
export default combineReducers({ corrections: corrections, progression: progression, skills: skills, slides: slides, token: token, rank: rank });
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { get, isNull, isUndefined, pipe, set, unset, update } from 'lodash/fp';
|
|
2
|
+
import { RANK_FETCH_START_REQUEST, RANK_FETCH_START_SUCCESS, RANK_FETCH_START_FAILURE, RANK_FETCH_END_REQUEST, RANK_FETCH_END_SUCCESS, RANK_FETCH_END_FAILURE } from '../../actions/api/fetch-rank';
|
|
3
|
+
var initialState = {};
|
|
4
|
+
var reducer = function (
|
|
5
|
+
// eslint-disable-next-line default-param-last
|
|
6
|
+
state, action) {
|
|
7
|
+
if (state === void 0) { state = initialState; }
|
|
8
|
+
switch (action.type) {
|
|
9
|
+
case RANK_FETCH_START_REQUEST: {
|
|
10
|
+
return update('start', function (startRank) { return (isUndefined(startRank) ? null : startRank); }, state);
|
|
11
|
+
}
|
|
12
|
+
case RANK_FETCH_START_SUCCESS: {
|
|
13
|
+
var payload = action.payload;
|
|
14
|
+
return set('start', payload.rank, state);
|
|
15
|
+
}
|
|
16
|
+
case RANK_FETCH_START_FAILURE: {
|
|
17
|
+
if (pipe(get('start'), isNull)(state))
|
|
18
|
+
return unset('start', state);
|
|
19
|
+
return state;
|
|
20
|
+
}
|
|
21
|
+
case RANK_FETCH_END_REQUEST: {
|
|
22
|
+
return update('end', function (endRank) { return (isUndefined(endRank) ? null : endRank); }, state);
|
|
23
|
+
}
|
|
24
|
+
case RANK_FETCH_END_SUCCESS: {
|
|
25
|
+
var payload = action.payload;
|
|
26
|
+
return set('end', payload.rank, state);
|
|
27
|
+
}
|
|
28
|
+
case RANK_FETCH_END_FAILURE: {
|
|
29
|
+
if (pipe(get('end'), isNull)(state))
|
|
30
|
+
return unset('end', state);
|
|
31
|
+
return state;
|
|
32
|
+
}
|
|
33
|
+
default:
|
|
34
|
+
return state;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export default reducer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../rank';
|
|
3
|
+
import { RANK_FETCH_START_REQUEST, RANK_FETCH_START_SUCCESS, RANK_FETCH_START_FAILURE, RANK_FETCH_END_REQUEST, RANK_FETCH_END_SUCCESS, RANK_FETCH_END_FAILURE } from '../../../actions/api/fetch-rank';
|
|
4
|
+
test('should have initial value', function (t) {
|
|
5
|
+
var state = reducer(undefined, {});
|
|
6
|
+
t.deepEqual(state, {});
|
|
7
|
+
});
|
|
8
|
+
test("should set the start value to null if the value doesn't exist of FETCH_START_REQUEST action", function (t) {
|
|
9
|
+
var state = reducer({}, { type: RANK_FETCH_START_REQUEST });
|
|
10
|
+
t.deepEqual(state, {
|
|
11
|
+
start: null
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
test('should do nothing if a start value already exists of FETCH_START_REQUEST action', function (t) {
|
|
15
|
+
var state = reducer({ start: 93 }, { type: RANK_FETCH_START_REQUEST });
|
|
16
|
+
t.deepEqual(state, {
|
|
17
|
+
start: 93
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
test('should set the start value of FETCH_START_SUCCESS action', function (t) {
|
|
21
|
+
var state = reducer({}, { type: RANK_FETCH_START_SUCCESS, payload: { rank: 93 } });
|
|
22
|
+
t.deepEqual(state, {
|
|
23
|
+
start: 93
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
test('should unset the start value if the value is null of FETCH_START_FAILURE action', function (t) {
|
|
27
|
+
var state = reducer({ start: null }, { type: RANK_FETCH_START_FAILURE });
|
|
28
|
+
t.deepEqual(state, {});
|
|
29
|
+
});
|
|
30
|
+
test('should do nothing if the start value already exists of FETCH_START_FAILURE action', function (t) {
|
|
31
|
+
var state = reducer({ start: 93 }, { type: RANK_FETCH_START_FAILURE });
|
|
32
|
+
t.deepEqual(state, { start: 93 });
|
|
33
|
+
});
|
|
34
|
+
test("should set the end value to null if the value doesn't exist of FETCH_END_REQUEST action", function (t) {
|
|
35
|
+
var state = reducer({}, { type: RANK_FETCH_END_REQUEST });
|
|
36
|
+
t.deepEqual(state, {
|
|
37
|
+
end: null
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
test('should do nothing if an end value already exists of FETCH_END_REQUEST action', function (t) {
|
|
41
|
+
var state = reducer({ end: 94 }, { type: RANK_FETCH_END_REQUEST });
|
|
42
|
+
t.deepEqual(state, {
|
|
43
|
+
end: 94
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
test('should set the end value of FETCH_END_SUCCESS action', function (t) {
|
|
47
|
+
var state = reducer({}, { type: RANK_FETCH_END_SUCCESS, payload: { rank: 94 } });
|
|
48
|
+
t.deepEqual(state, {
|
|
49
|
+
end: 94
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
test('should unset the end value if the value is null of FETCH_END_FAILURE action', function (t) {
|
|
53
|
+
var state = reducer({ end: null }, { type: RANK_FETCH_END_FAILURE });
|
|
54
|
+
t.deepEqual(state, {});
|
|
55
|
+
});
|
|
56
|
+
test('should do nothing if the end value already exists of FETCH_END_FAILURE action', function (t) {
|
|
57
|
+
var state = reducer({ end: 94 }, { type: RANK_FETCH_END_FAILURE });
|
|
58
|
+
t.deepEqual(state, { end: 94 });
|
|
59
|
+
});
|
package/lib/reducers/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DataState } from './data';
|
|
2
|
-
import { UIState } from './ui';
|
|
1
|
+
import { type DataState } from './data';
|
|
2
|
+
import { type UIState } from './ui';
|
|
3
3
|
export declare type StoreState = {
|
|
4
4
|
ui: UIState;
|
|
5
5
|
data: DataState;
|
|
@@ -11,6 +11,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
11
11
|
skills: import("./data/skills").SkillsState;
|
|
12
12
|
slides: import("./data/slides").SlidesState;
|
|
13
13
|
token: string;
|
|
14
|
+
rank: import("./data/rank").RankState;
|
|
14
15
|
}>;
|
|
15
16
|
ui: import("redux").CombinedState<{
|
|
16
17
|
currentSlideRef: string;
|
|
@@ -18,5 +19,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
18
19
|
answers: import("./ui/answers").AnswerState;
|
|
19
20
|
slide: import("./ui/slide").UISlideState;
|
|
20
21
|
}>;
|
|
21
|
-
}>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/post-progression").ReceivedProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction>;
|
|
22
|
+
}>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/post-progression").ReceivedProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/api/fetch-rank").RankAction | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction>;
|
|
22
23
|
export default _default;
|
|
@@ -4,6 +4,7 @@ import { ReceivedCorrection } from '../../actions/api/fetch-correction';
|
|
|
4
4
|
export declare type UISlideState = {
|
|
5
5
|
validateButton: boolean;
|
|
6
6
|
animateCorrectionPopin?: boolean;
|
|
7
|
+
showCorrectionPopin?: boolean;
|
|
7
8
|
};
|
|
8
9
|
export declare const initialState: UISlideState;
|
|
9
10
|
declare const reducer: (state: UISlideState | undefined, action: PostAnswerRequestAction | EditAnswerAction | ReceivedCorrection) => UISlideState;
|
package/lib/reducers/ui/slide.js
CHANGED
|
@@ -23,7 +23,7 @@ state, action) {
|
|
|
23
23
|
return initialState;
|
|
24
24
|
}
|
|
25
25
|
case CORRECTION_FETCH_SUCCESS: {
|
|
26
|
-
return set(['animateCorrectionPopin'], true, state);
|
|
26
|
+
return pipe(set(['animateCorrectionPopin'], true), set(['showCorrectionPopin'], true))(state);
|
|
27
27
|
}
|
|
28
28
|
default:
|
|
29
29
|
return state;
|
package/lib/services/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { fetchCorrection } from './fetch-correction';
|
|
2
|
+
import { fetchRank } from './fetch-rank';
|
|
2
3
|
import { fetchSkills } from './fetch-skills';
|
|
3
4
|
import { fetchSlide } from './fetch-slide';
|
|
4
5
|
import { postAnswer } from './post-answer';
|
|
5
6
|
import { postProgression } from './post-progression';
|
|
6
7
|
export var getServices = function () { return ({
|
|
7
8
|
fetchCorrection: fetchCorrection,
|
|
9
|
+
fetchRank: fetchRank,
|
|
8
10
|
fetchSkills: fetchSkills,
|
|
9
11
|
fetchSlide: fetchSlide,
|
|
10
12
|
postAnswer: postAnswer,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CorrectionFromAPI, ProgressionFromAPI, Services } from '../../types/common';
|
|
2
2
|
export declare const postProgressionResponse: ProgressionFromAPI;
|
|
3
3
|
export declare const postAnswerResponses: Record<string, ProgressionFromAPI>;
|
|
4
|
+
export declare const incorrectFreeTextPostAnswerResponse: ProgressionFromAPI;
|
|
4
5
|
export declare const progressionSlideWithPendingSlide: ProgressionFromAPI;
|
|
5
6
|
export declare const getChoicesCorrection: (ref: string, wrongChoice?: boolean) => CorrectionFromAPI;
|
|
6
7
|
export declare const services: Services;
|
|
@@ -54,6 +54,9 @@ var fetchSkillsResponse = [
|
|
|
54
54
|
custom: true
|
|
55
55
|
}
|
|
56
56
|
];
|
|
57
|
+
var fetchRankResponse = {
|
|
58
|
+
rank: 93
|
|
59
|
+
};
|
|
57
60
|
export var postProgressionResponse = {
|
|
58
61
|
_id: '62b1d1087aa12f00253f40ee',
|
|
59
62
|
content: content,
|
|
@@ -281,6 +284,13 @@ export var postAnswerResponses = (_a = {},
|
|
|
281
284
|
}
|
|
282
285
|
},
|
|
283
286
|
_a);
|
|
287
|
+
export var incorrectFreeTextPostAnswerResponse = __assign(__assign({}, postAnswerResponses[freeTextSlide.universalRef]), { state: __assign(__assign({}, postAnswerResponses[freeTextSlide.universalRef].state), { isCorrect: false, allAnswers: [
|
|
288
|
+
{
|
|
289
|
+
slideRef: freeTextSlide.universalRef,
|
|
290
|
+
isCorrect: false,
|
|
291
|
+
answer: ['NOPE']
|
|
292
|
+
}
|
|
293
|
+
], pendingSlides: [freeTextSlide.universalRef], stars: 0 }) });
|
|
284
294
|
export var progressionSlideWithPendingSlide = {
|
|
285
295
|
_id: '62b1d1087aa12f00253f40ee',
|
|
286
296
|
content: content,
|
|
@@ -415,5 +425,6 @@ export var services = {
|
|
|
415
425
|
var currentSlide = progression.state.nextContent.ref;
|
|
416
426
|
return Promise.resolve(get(currentSlide, postAnswerResponses));
|
|
417
427
|
},
|
|
418
|
-
fetchCorrection: function (ref) { return Promise.resolve(getChoicesCorrection(ref)); }
|
|
428
|
+
fetchCorrection: function (ref) { return Promise.resolve(getChoicesCorrection(ref)); },
|
|
429
|
+
fetchRank: function () { return Promise.resolve(fetchRankResponse); }
|
|
419
430
|
};
|
package/lib/types/common.d.ts
CHANGED
|
@@ -133,6 +133,7 @@ export declare type Services = {
|
|
|
133
133
|
postProgression(skillRef: string, token: string): Promise<ProgressionFromAPI>;
|
|
134
134
|
postAnswer(progression: ProgressionFromAPI, token: string, answer: string[]): Promise<ProgressionFromAPI>;
|
|
135
135
|
fetchCorrection(slideRef: string, token: string, progressionId: string, answer: string[]): Promise<CorrectionFromAPI | void>;
|
|
136
|
+
fetchRank(token: string): Promise<Rank>;
|
|
136
137
|
};
|
|
137
138
|
export declare type Options = {
|
|
138
139
|
services: Services;
|
|
@@ -9,7 +9,8 @@ test('should create initial props when there are no skills on the state', functi
|
|
|
9
9
|
skills: [],
|
|
10
10
|
slides: {},
|
|
11
11
|
token: '1234',
|
|
12
|
-
corrections: {}
|
|
12
|
+
corrections: {},
|
|
13
|
+
rank: {}
|
|
13
14
|
},
|
|
14
15
|
ui: {
|
|
15
16
|
currentSlideRef: '',
|
|
@@ -51,7 +52,8 @@ test('should create initial props when skills on the state', function (t) {
|
|
|
51
52
|
],
|
|
52
53
|
slides: {},
|
|
53
54
|
token: '1234',
|
|
54
|
-
corrections: {}
|
|
55
|
+
corrections: {},
|
|
56
|
+
rank: {}
|
|
55
57
|
},
|
|
56
58
|
ui: {
|
|
57
59
|
currentSlideRef: '',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Dispatch } from 'redux';
|
|
2
|
-
import { SlideIndexes } from '../../common';
|
|
3
|
-
import { StoreState } from '../../reducers';
|
|
4
|
-
import { AnswerUI } from '../../types/slides';
|
|
1
|
+
import type { Dispatch } from 'redux';
|
|
2
|
+
import type { SlideIndexes } from '../../common';
|
|
3
|
+
import type { StoreState } from '../../reducers';
|
|
4
|
+
import type { AnswerUI } from '../../types/slides';
|
|
5
5
|
declare const ICON_VALUES: {
|
|
6
6
|
readonly right: "right";
|
|
7
7
|
readonly wrong: "wrong";
|
|
@@ -27,22 +27,24 @@ export declare type UISlide = {
|
|
|
27
27
|
declare type SlidesStack = {
|
|
28
28
|
[key in SlideIndexes]: UISlide;
|
|
29
29
|
};
|
|
30
|
+
declare type CorrectionPopinInformation = {
|
|
31
|
+
label: string;
|
|
32
|
+
message: string;
|
|
33
|
+
};
|
|
34
|
+
declare type CorrectionPopinKlf = {
|
|
35
|
+
label: string;
|
|
36
|
+
tooltip: string;
|
|
37
|
+
};
|
|
38
|
+
declare type CorrectionPopinNext = {
|
|
39
|
+
label: string;
|
|
40
|
+
ariaLabel: string;
|
|
41
|
+
};
|
|
30
42
|
export declare type CorrectionPopinProps = {
|
|
31
|
-
klf
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
information: {
|
|
37
|
-
label: string;
|
|
38
|
-
message: string;
|
|
39
|
-
};
|
|
40
|
-
next: {
|
|
41
|
-
label: string;
|
|
42
|
-
ariaLabel: string;
|
|
43
|
-
};
|
|
44
|
-
successLabel: string;
|
|
45
|
-
failureLabel: string;
|
|
43
|
+
klf?: CorrectionPopinKlf;
|
|
44
|
+
information: CorrectionPopinInformation;
|
|
45
|
+
next: CorrectionPopinNext;
|
|
46
|
+
resultLabel: string;
|
|
47
|
+
type: 'right' | 'wrong';
|
|
46
48
|
};
|
|
47
49
|
export declare type SlidesViewProps = {
|
|
48
50
|
header: {
|
|
@@ -19,6 +19,7 @@ import reduce from 'lodash/fp/reduce';
|
|
|
19
19
|
import set from 'lodash/fp/set';
|
|
20
20
|
import slice from 'lodash/fp/slice';
|
|
21
21
|
import toInteger from 'lodash/fp/toInteger';
|
|
22
|
+
import join from 'lodash/fp/join';
|
|
22
23
|
import { postAnswer } from '../../actions/api/post-answer';
|
|
23
24
|
import { mapApiSlideToUi } from './map-api-slide-to-ui';
|
|
24
25
|
var ICON_VALUES = {
|
|
@@ -78,7 +79,10 @@ var buildStackSlides = function (state, dispatch) {
|
|
|
78
79
|
var _a = mapApiSlideToUi(dispatch)(slideFromAPI, answers), questionText = _a.questionText, answerUI = _a.answerUI;
|
|
79
80
|
var parentContentTitle = getOr('', 'parentContentTitle.title', slideFromAPI);
|
|
80
81
|
var parentContentType = getOr('', 'parentContentTitle.type', slideFromAPI);
|
|
81
|
-
var
|
|
82
|
+
var isCurrentSlideRef = currentSlideRef === slideRef;
|
|
83
|
+
var animateCorrectionPopin = isCurrentSlideRef && getOr(false, ['ui', 'slide', 'animateCorrectionPopin'], state);
|
|
84
|
+
var showCorrectionPopin = isCurrentSlideRef && getOr(false, ['ui', 'slide', 'showCorrectionPopin'], state);
|
|
85
|
+
var updatedUiSlide = pipe(set('showCorrectionPopin', showCorrectionPopin), set('animateCorrectionPopin', animateCorrectionPopin), set('loading', false), set('questionText', questionText), set('answerUI', answerUI), set('parentContentTitle', "From \"".concat(parentContentTitle, "\" ").concat(parentContentType)) // TODO translate: -From- .... -Course/chapter-
|
|
82
86
|
// TODO: Set position according to currentSlideRef et slideRefs (or maybe a value on the state ui.slidePositions !!)
|
|
83
87
|
)(uiSlide);
|
|
84
88
|
return set(index, updatedUiSlide, acc);
|
|
@@ -145,7 +149,29 @@ export var buildStepItems = function (state) {
|
|
|
145
149
|
});
|
|
146
150
|
return steps;
|
|
147
151
|
};
|
|
152
|
+
var getCorrectionPopinProps = function (isCorrect, correctAnswer, klf) { return ({
|
|
153
|
+
klf: isCorrect
|
|
154
|
+
? undefined
|
|
155
|
+
: {
|
|
156
|
+
label: '_klf',
|
|
157
|
+
tooltip: klf
|
|
158
|
+
},
|
|
159
|
+
resultLabel: isCorrect ? '_right' : '_wrong',
|
|
160
|
+
information: {
|
|
161
|
+
label: isCorrect ? '_klf' : '_correctAnswer',
|
|
162
|
+
message: isCorrect ? klf : join(',', correctAnswer)
|
|
163
|
+
},
|
|
164
|
+
next: {
|
|
165
|
+
ariaLabel: '_correctionNextAriaLabel',
|
|
166
|
+
label: '_correctionNextLabel'
|
|
167
|
+
},
|
|
168
|
+
type: isCorrect ? 'right' : 'wrong'
|
|
169
|
+
}); };
|
|
148
170
|
export var mapStateToSlidesProps = function (state, dispatch) {
|
|
171
|
+
var currentSlideRef = get(['ui', 'currentSlideRef'], state);
|
|
172
|
+
var correction = get(['data', 'corrections', currentSlideRef], state);
|
|
173
|
+
var isCorrect = get(['data', 'progression', 'state', 'isCorrect'], state);
|
|
174
|
+
var klf = getOr('', ['data', 'slides', currentSlideRef, 'klf'], state);
|
|
149
175
|
return {
|
|
150
176
|
header: {
|
|
151
177
|
mode: '__revision_mode',
|
|
@@ -163,11 +189,11 @@ export var mapStateToSlidesProps = function (state, dispatch) {
|
|
|
163
189
|
validateButton: {
|
|
164
190
|
label: '__validate',
|
|
165
191
|
disabled: !get('ui.slide.validateButton', state),
|
|
166
|
-
onClick: function () {
|
|
192
|
+
onClick: /* istanbul ignore next */ function () {
|
|
167
193
|
dispatch(postAnswer);
|
|
168
194
|
}
|
|
169
195
|
},
|
|
170
|
-
correctionPopinProps:
|
|
196
|
+
correctionPopinProps: correction && getCorrectionPopinProps(isCorrect, correction.correctAnswer, klf),
|
|
171
197
|
endReview: false
|
|
172
198
|
},
|
|
173
199
|
congratsProps: undefined
|