@coorpacademy/app-review 0.1.15 → 0.1.16
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-skills.d.ts +4 -6
- package/es/actions/api/fetch-skills.js +7 -4
- package/es/actions/api/fetch-slide.d.ts +14 -7
- package/es/actions/api/fetch-slide.js +22 -19
- package/es/actions/api/post-progression.d.ts +4 -6
- package/es/actions/api/post-progression.js +13 -8
- package/es/actions/api/test/create-test-store.d.ts +5 -0
- package/es/actions/api/test/create-test-store.js +16 -0
- package/es/actions/api/test/fetch-skills.test.js +54 -0
- package/es/actions/api/test/fetch-slide.test.js +61 -0
- package/es/actions/api/test/post-progression.test.d.ts +1 -0
- package/es/actions/api/test/post-progression.test.js +102 -0
- package/es/actions/ui/answers.d.ts +7 -0
- package/es/actions/ui/answers.js +7 -0
- package/es/fixtures/temp-fixture.d.ts +1 -1
- package/es/index.js +10 -16
- package/es/reducers/data/index.d.ts +1 -1
- package/es/reducers/data/slides.d.ts +2 -2
- package/es/reducers/data/slides.js +5 -1
- package/es/reducers/data/test/progression.test.d.ts +1 -0
- package/es/reducers/data/test/progression.test.js +38 -0
- package/es/reducers/data/test/skills.test.d.ts +1 -0
- package/es/reducers/data/test/skills.test.js +12 -0
- package/es/reducers/data/test/slides.test.d.ts +1 -0
- package/es/reducers/data/test/slides.test.js +20 -0
- package/es/reducers/data/test/token.test.d.ts +1 -0
- package/es/reducers/data/test/token.test.js +11 -0
- package/es/reducers/index.d.ts +2 -2
- package/es/reducers/ui/answers.d.ts +4 -0
- package/es/reducers/ui/answers.js +13 -0
- package/es/reducers/ui/index.d.ts +4 -4
- package/es/reducers/ui/index.js +2 -2
- package/es/reducers/ui/test/answers.test.d.ts +1 -0
- package/es/reducers/ui/test/answers.test.js +11 -0
- package/es/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
- package/es/reducers/ui/test/current-slide-ref.test.js +12 -0
- package/es/reducers/ui/test/navigation.test.d.ts +1 -0
- package/es/reducers/ui/test/navigation.test.js +15 -0
- package/es/services/fetch-slide.js +1 -1
- package/es/services/index.js +3 -1
- package/es/services/post-answer.d.ts +2 -0
- package/es/services/post-answer.js +18 -0
- package/es/services/test/fetch-slide.test.d.ts +1 -0
- package/es/services/test/fetch-slide.test.js +22 -0
- package/es/services/test/post-answer.test.d.ts +1 -0
- package/es/services/test/post-answer.test.js +57 -0
- package/es/services/test/post-progression.test.js +9 -1
- package/es/test/util/services.mock.js +37 -7
- package/es/types/common.d.ts +22 -8
- package/es/views/slides/index.d.ts +78 -2
- package/es/views/slides/index.js +70 -4
- package/es/views/slides/map-api-slide-to-ui.d.ts +8 -0
- package/es/views/slides/map-api-slide-to-ui.js +172 -0
- package/{lib/helpers → es/views/slides}/test/fixtures/free-text.d.ts +1 -1
- package/es/views/slides/test/fixtures/free-text.js +38 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm-drag.d.ts +1 -1
- package/es/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm-graphic.d.ts +1 -1
- package/es/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm.d.ts +1 -1
- package/es/{helpers → views/slides}/test/fixtures/qcm.js +5 -1
- package/es/{helpers → views/slides}/test/fixtures/select-template.d.ts +1 -1
- package/es/views/slides/test/fixtures/select-template.js +92 -0
- package/es/{helpers → views/slides}/test/fixtures/slider.d.ts +1 -1
- package/es/views/slides/test/fixtures/slider.js +36 -0
- package/es/{helpers → views/slides}/test/fixtures/text-template.d.ts +1 -1
- package/es/{helpers → views/slides}/test/fixtures/text-template.js +5 -1
- package/es/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/es/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
- package/lib/actions/api/fetch-skills.d.ts +4 -6
- package/lib/actions/api/fetch-skills.js +55 -7
- package/lib/actions/api/fetch-slide.d.ts +14 -7
- package/lib/actions/api/fetch-slide.js +70 -20
- package/lib/actions/api/post-progression.d.ts +4 -6
- package/lib/actions/api/post-progression.js +63 -9
- package/lib/actions/api/test/create-test-store.d.ts +5 -0
- package/lib/actions/api/test/create-test-store.js +18 -0
- package/lib/actions/api/test/fetch-skills.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-skills.test.js +113 -0
- package/lib/actions/api/test/fetch-slide.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-slide.test.js +120 -0
- package/lib/actions/api/test/post-progression.test.d.ts +1 -0
- package/lib/actions/api/test/post-progression.test.js +160 -0
- package/lib/actions/ui/answers.d.ts +7 -0
- package/lib/actions/ui/answers.js +9 -0
- package/lib/fixtures/temp-fixture.d.ts +1 -1
- package/lib/index.js +21 -18
- package/lib/reducers/data/index.d.ts +1 -1
- package/lib/reducers/data/slides.d.ts +2 -2
- package/lib/reducers/data/slides.js +5 -1
- package/lib/reducers/data/test/progression.test.d.ts +1 -0
- package/lib/reducers/data/test/progression.test.js +38 -0
- package/lib/reducers/data/test/skills.test.d.ts +1 -0
- package/lib/reducers/data/test/skills.test.js +12 -0
- package/lib/reducers/data/test/slides.test.d.ts +1 -0
- package/lib/reducers/data/test/slides.test.js +20 -0
- package/lib/reducers/data/test/token.test.d.ts +1 -0
- package/lib/reducers/data/test/token.test.js +11 -0
- package/lib/reducers/index.d.ts +2 -2
- package/lib/reducers/ui/answers.d.ts +4 -0
- package/lib/reducers/ui/answers.js +14 -0
- package/lib/reducers/ui/index.d.ts +4 -4
- package/lib/reducers/ui/index.js +2 -2
- package/lib/reducers/ui/test/answers.test.d.ts +1 -0
- package/lib/reducers/ui/test/answers.test.js +11 -0
- package/lib/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
- package/lib/reducers/ui/test/current-slide-ref.test.js +12 -0
- package/lib/reducers/ui/test/navigation.test.d.ts +1 -0
- package/lib/reducers/ui/test/navigation.test.js +15 -0
- package/lib/services/fetch-slide.js +1 -1
- package/lib/services/index.js +3 -1
- package/lib/services/post-answer.d.ts +2 -0
- package/lib/services/post-answer.js +62 -0
- package/lib/services/test/fetch-slide.test.d.ts +1 -0
- package/lib/services/test/fetch-slide.test.js +76 -0
- package/lib/services/test/post-answer.test.d.ts +1 -0
- package/lib/services/test/post-answer.test.js +111 -0
- package/lib/services/test/post-progression.test.js +9 -1
- package/lib/test/util/services.mock.js +37 -7
- package/lib/types/common.d.ts +22 -8
- package/lib/views/slides/index.d.ts +78 -2
- package/lib/views/slides/index.js +70 -4
- package/lib/views/slides/map-api-slide-to-ui.d.ts +8 -0
- package/lib/views/slides/map-api-slide-to-ui.js +178 -0
- package/{es/helpers → lib/views/slides}/test/fixtures/free-text.d.ts +1 -1
- package/lib/views/slides/test/fixtures/free-text.js +38 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm-drag.d.ts +1 -1
- package/lib/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm-graphic.d.ts +1 -1
- package/lib/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm.d.ts +1 -1
- package/lib/{helpers → views/slides}/test/fixtures/qcm.js +5 -1
- package/lib/{helpers → views/slides}/test/fixtures/select-template.d.ts +1 -1
- package/lib/views/slides/test/fixtures/select-template.js +92 -0
- package/lib/{helpers → views/slides}/test/fixtures/slider.d.ts +1 -1
- package/lib/views/slides/test/fixtures/slider.js +36 -0
- package/lib/{helpers → views/slides}/test/fixtures/text-template.d.ts +1 -1
- package/lib/{helpers → views/slides}/test/fixtures/text-template.js +5 -1
- package/lib/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/lib/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
- package/package.json +3 -3
- package/src/actions/api/fetch-skills.ts +12 -12
- package/src/actions/api/fetch-slide.ts +33 -29
- package/src/actions/api/post-progression.ts +18 -21
- package/src/actions/api/test/create-test-store.ts +25 -0
- package/src/actions/api/test/fetch-skills.test.ts +70 -0
- package/src/actions/api/test/fetch-slide.test.ts +77 -0
- package/src/actions/api/test/post-progression.test.ts +119 -0
- package/src/actions/ui/answers.ts +16 -0
- package/src/fixtures/temp-fixture.ts +1 -1
- package/src/index.tsx +14 -29
- package/src/reducers/data/index.ts +1 -1
- package/src/reducers/data/slides.ts +11 -2
- package/src/reducers/data/test/progression.test.ts +42 -0
- package/src/reducers/data/test/skills.test.ts +14 -0
- package/src/reducers/data/test/slides.test.ts +26 -0
- package/src/reducers/data/test/token.test.ts +13 -0
- package/src/reducers/ui/answers.ts +19 -0
- package/src/reducers/ui/index.ts +3 -3
- package/src/reducers/ui/test/answers.test.ts +13 -0
- package/src/reducers/ui/test/current-slide-ref.test.ts +14 -0
- package/src/reducers/ui/test/navigation.test.ts +19 -0
- package/src/services/fetch-slide.ts +1 -1
- package/src/services/index.ts +3 -1
- package/src/services/post-answer.ts +27 -0
- package/src/services/test/fetch-slide.test.ts +30 -0
- package/src/services/test/post-answer.test.ts +68 -0
- package/src/services/test/post-progression.test.ts +9 -1
- package/src/test/util/services.mock.ts +37 -7
- package/src/types/common.ts +34 -14
- package/src/views/slides/index.ts +164 -5
- package/src/views/slides/map-api-slide-to-ui.ts +251 -0
- package/src/views/slides/test/fixtures/free-text.ts +43 -0
- package/src/views/slides/test/fixtures/qcm-drag.ts +111 -0
- package/src/views/slides/test/fixtures/qcm-graphic.ts +94 -0
- package/src/{helpers → views/slides}/test/fixtures/qcm.ts +6 -2
- package/src/views/slides/test/fixtures/select-template.ts +98 -0
- package/src/views/slides/test/fixtures/slider.ts +41 -0
- package/src/{helpers → views/slides}/test/fixtures/text-template.ts +6 -2
- package/src/{helpers → views/slides}/test/map-api-slide-to-ui.test.ts +21 -10
- package/es/helpers/map-api-slide-to-ui.d.ts +0 -11
- package/es/helpers/map-api-slide-to-ui.js +0 -193
- package/es/helpers/test/fixtures/free-text.js +0 -30
- package/es/helpers/test/fixtures/qcm-drag.js +0 -112
- package/es/helpers/test/fixtures/qcm-graphic.js +0 -76
- package/es/helpers/test/fixtures/select-template.js +0 -94
- package/es/helpers/test/fixtures/slider.js +0 -33
- package/es/reducers/ui/slides.d.ts +0 -9
- package/es/reducers/ui/slides.js +0 -42
- package/es/types/views/slides.d.ts +0 -74
- package/es/types/views/slides.js +0 -6
- package/lib/helpers/map-api-slide-to-ui.d.ts +0 -11
- package/lib/helpers/map-api-slide-to-ui.js +0 -201
- package/lib/helpers/test/fixtures/free-text.js +0 -30
- package/lib/helpers/test/fixtures/qcm-drag.js +0 -112
- package/lib/helpers/test/fixtures/qcm-graphic.js +0 -76
- package/lib/helpers/test/fixtures/select-template.js +0 -94
- package/lib/helpers/test/fixtures/slider.js +0 -33
- package/lib/reducers/ui/slides.d.ts +0 -9
- package/lib/reducers/ui/slides.js +0 -43
- package/lib/types/views/slides.d.ts +0 -74
- package/lib/types/views/slides.js +0 -6
- package/src/helpers/map-api-slide-to-ui.ts +0 -279
- package/src/helpers/test/fixtures/free-text.ts +0 -33
- package/src/helpers/test/fixtures/qcm-drag.ts +0 -115
- package/src/helpers/test/fixtures/qcm-graphic.ts +0 -79
- package/src/helpers/test/fixtures/select-template.ts +0 -97
- package/src/helpers/test/fixtures/slider.ts +0 -36
- package/src/reducers/ui/slides.ts +0 -58
- package/src/types/views/slides.ts +0 -90
- /package/es/{helpers/test/map-api-slide-to-ui.test.d.ts → actions/api/test/fetch-skills.test.d.ts} +0 -0
- /package/{lib/helpers/test/map-api-slide-to-ui.test.d.ts → es/actions/api/test/fetch-slide.test.d.ts} +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import test from 'ava';
|
|
38
|
+
import nock from 'nock';
|
|
39
|
+
import { qcmDragSlide } from '../../views/slides/test/fixtures/qcm-drag';
|
|
40
|
+
import { fetchSlide } from '../fetch-slide';
|
|
41
|
+
test.before(function () {
|
|
42
|
+
nock('http://localhost:3000')
|
|
43
|
+
.get('/api/v2/slide/sli_123546/parentContentTitle')
|
|
44
|
+
.reply(200, qcmDragSlide);
|
|
45
|
+
});
|
|
46
|
+
test.after(function () {
|
|
47
|
+
nock.cleanAll();
|
|
48
|
+
});
|
|
49
|
+
test('should fetch a slide with the parentTitleContent info successfully', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
50
|
+
var token, slide;
|
|
51
|
+
return __generator(this, function (_a) {
|
|
52
|
+
switch (_a.label) {
|
|
53
|
+
case 0:
|
|
54
|
+
token = process.env.API_TEST_TOKEN || '';
|
|
55
|
+
return [4 /*yield*/, fetchSlide('sli_123546', token)];
|
|
56
|
+
case 1:
|
|
57
|
+
slide = _a.sent();
|
|
58
|
+
t.deepEqual(qcmDragSlide, slide);
|
|
59
|
+
return [2 /*return*/];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}); });
|
|
63
|
+
test('should reject if a bad token is passed', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
64
|
+
var badToken, error;
|
|
65
|
+
return __generator(this, function (_a) {
|
|
66
|
+
switch (_a.label) {
|
|
67
|
+
case 0:
|
|
68
|
+
badToken = 'token is not a jwt';
|
|
69
|
+
return [4 /*yield*/, t.throwsAsync(function () { return fetchSlide('sli_123546', badToken); })];
|
|
70
|
+
case 1:
|
|
71
|
+
error = _a.sent();
|
|
72
|
+
t.is(error === null || error === void 0 ? void 0 : error.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
|
|
73
|
+
return [2 /*return*/];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}); });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import test from 'ava';
|
|
38
|
+
import nock from 'nock';
|
|
39
|
+
import { postAnswer } from '../post-answer';
|
|
40
|
+
var progressionId = '123456789123';
|
|
41
|
+
var skillRef = '_skill-ref';
|
|
42
|
+
var answer = ['Lister vos tâches pour vous libérer l’esprit', 'Vous isoler dans un lieu calme'];
|
|
43
|
+
var result = {
|
|
44
|
+
content: {
|
|
45
|
+
type: 'skill',
|
|
46
|
+
ref: skillRef
|
|
47
|
+
},
|
|
48
|
+
engine: {
|
|
49
|
+
ref: 'review'
|
|
50
|
+
},
|
|
51
|
+
_id: '123456123456',
|
|
52
|
+
state: {
|
|
53
|
+
allAnswers: [
|
|
54
|
+
{
|
|
55
|
+
slideRef: 'sli_NkvrWPFF2',
|
|
56
|
+
isCorrect: true,
|
|
57
|
+
answer: answer
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
isCorrect: true,
|
|
61
|
+
nextContent: {
|
|
62
|
+
type: 'slide',
|
|
63
|
+
ref: 'sli_NJ3m5KtWh'
|
|
64
|
+
},
|
|
65
|
+
pendingSlides: [],
|
|
66
|
+
slides: ['sli_NkvrWPFF2'],
|
|
67
|
+
content: {
|
|
68
|
+
ref: 'sli_NkvrWPFF2',
|
|
69
|
+
type: 'slide'
|
|
70
|
+
},
|
|
71
|
+
step: {
|
|
72
|
+
current: 2
|
|
73
|
+
},
|
|
74
|
+
stars: 4
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
test.before(function () {
|
|
78
|
+
var moocApi = nock('http://localhost:3000');
|
|
79
|
+
moocApi.post("/api/v2/progressions/".concat(progressionId, "/answers")).reply(200, result);
|
|
80
|
+
});
|
|
81
|
+
test.after(function () {
|
|
82
|
+
nock.cleanAll();
|
|
83
|
+
});
|
|
84
|
+
test('should post the answers successfully', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
85
|
+
var token, progression;
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
switch (_a.label) {
|
|
88
|
+
case 0:
|
|
89
|
+
token = process.env.API_TEST_TOKEN || '';
|
|
90
|
+
return [4 /*yield*/, postAnswer(skillRef, token, progressionId, answer)];
|
|
91
|
+
case 1:
|
|
92
|
+
progression = _a.sent();
|
|
93
|
+
t.deepEqual(result, progression);
|
|
94
|
+
return [2 /*return*/];
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}); });
|
|
98
|
+
test('should reject bad token', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
99
|
+
var badToken, error;
|
|
100
|
+
return __generator(this, function (_a) {
|
|
101
|
+
switch (_a.label) {
|
|
102
|
+
case 0:
|
|
103
|
+
badToken = 'token is not a jwt';
|
|
104
|
+
return [4 /*yield*/, t.throwsAsync(function () { return postAnswer(skillRef, badToken, progressionId, answer); })];
|
|
105
|
+
case 1:
|
|
106
|
+
error = _a.sent();
|
|
107
|
+
t.is(error === null || error === void 0 ? void 0 : error.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
|
|
108
|
+
return [2 /*return*/];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}); });
|
|
@@ -40,6 +40,13 @@ import { postProgression } from '../post-progression';
|
|
|
40
40
|
var skillRef = '_skill-ref';
|
|
41
41
|
var result = {
|
|
42
42
|
_id: '123456123456',
|
|
43
|
+
content: {
|
|
44
|
+
ref: '_skill-ref',
|
|
45
|
+
type: 'skill'
|
|
46
|
+
},
|
|
47
|
+
engine: {
|
|
48
|
+
ref: 'review'
|
|
49
|
+
},
|
|
43
50
|
state: {
|
|
44
51
|
allAnswers: [],
|
|
45
52
|
isCorrect: true,
|
|
@@ -51,7 +58,8 @@ var result = {
|
|
|
51
58
|
slides: [],
|
|
52
59
|
step: {
|
|
53
60
|
current: 1
|
|
54
|
-
}
|
|
61
|
+
},
|
|
62
|
+
stars: 0
|
|
55
63
|
}
|
|
56
64
|
};
|
|
57
65
|
test.before(function () {
|
|
@@ -9,7 +9,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import {
|
|
12
|
+
import { freeTextSlide } from '../../views/slides/test/fixtures/free-text';
|
|
13
13
|
export var services = {
|
|
14
14
|
fetchSkills: function () {
|
|
15
15
|
return Promise.resolve([
|
|
@@ -18,20 +18,17 @@ export var services = {
|
|
|
18
18
|
slidesToReview: 2,
|
|
19
19
|
name: 'skill-test',
|
|
20
20
|
custom: false
|
|
21
|
-
// TODO parentContentTitle
|
|
22
21
|
},
|
|
23
22
|
{
|
|
24
23
|
skillRef: '_skill-ref-2',
|
|
25
24
|
slidesToReview: 2,
|
|
26
25
|
name: 'skill-test-2',
|
|
27
|
-
custom: true
|
|
28
|
-
parentContentTitle: 'parentContentTitle 2'
|
|
29
|
-
// TODO parentContentTitle
|
|
26
|
+
custom: true
|
|
30
27
|
}
|
|
31
28
|
]);
|
|
32
29
|
},
|
|
33
30
|
fetchSlide: function (ref) {
|
|
34
|
-
return Promise.resolve(__assign(__assign({},
|
|
31
|
+
return Promise.resolve(__assign(__assign({}, freeTextSlide), { universalRef: ref, id: ref }));
|
|
35
32
|
},
|
|
36
33
|
postProgression: function () {
|
|
37
34
|
return Promise.resolve({
|
|
@@ -54,7 +51,40 @@ export var services = {
|
|
|
54
51
|
slides: [],
|
|
55
52
|
step: {
|
|
56
53
|
current: 1
|
|
57
|
-
}
|
|
54
|
+
},
|
|
55
|
+
stars: 0
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
postAnswer: function () {
|
|
60
|
+
return Promise.resolve({
|
|
61
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
62
|
+
content: {
|
|
63
|
+
ref: '_skill-ref',
|
|
64
|
+
type: 'skill'
|
|
65
|
+
},
|
|
66
|
+
engine: {
|
|
67
|
+
ref: 'review'
|
|
68
|
+
},
|
|
69
|
+
state: {
|
|
70
|
+
allAnswers: [
|
|
71
|
+
{
|
|
72
|
+
slideRef: 'sli_N1XACJobn',
|
|
73
|
+
isCorrect: true,
|
|
74
|
+
answer: ['Le créateur peut fixer un pourcentage pour chaque transaction future']
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
isCorrect: true,
|
|
78
|
+
nextContent: {
|
|
79
|
+
ref: 'sli_VkSQroQnx',
|
|
80
|
+
type: 'slide'
|
|
81
|
+
},
|
|
82
|
+
pendingSlides: [],
|
|
83
|
+
slides: ['sli_N1XACJobn'],
|
|
84
|
+
step: {
|
|
85
|
+
current: 2
|
|
86
|
+
},
|
|
87
|
+
stars: 4
|
|
58
88
|
}
|
|
59
89
|
});
|
|
60
90
|
}
|
package/lib/types/common.d.ts
CHANGED
|
@@ -23,21 +23,21 @@ declare type BaseContent = {
|
|
|
23
23
|
media?: unknown;
|
|
24
24
|
choices: ChoiceFromAPI[];
|
|
25
25
|
};
|
|
26
|
-
declare type
|
|
26
|
+
declare type BaseQuestion = {
|
|
27
27
|
header?: string;
|
|
28
28
|
content: BaseContent;
|
|
29
29
|
explanation?: string;
|
|
30
30
|
};
|
|
31
|
-
export declare type QcmQuestion =
|
|
31
|
+
export declare type QcmQuestion = BaseQuestion & {
|
|
32
32
|
type: 'qcm';
|
|
33
33
|
};
|
|
34
|
-
export declare type QcmGraphicQuestion =
|
|
34
|
+
export declare type QcmGraphicQuestion = BaseQuestion & {
|
|
35
35
|
type: 'qcmGraphic';
|
|
36
36
|
};
|
|
37
|
-
export declare type QcmDragQuestion =
|
|
37
|
+
export declare type QcmDragQuestion = BaseQuestion & {
|
|
38
38
|
type: 'qcmDrag';
|
|
39
39
|
};
|
|
40
|
-
export declare type BasicQuestion = Omit<
|
|
40
|
+
export declare type BasicQuestion = Omit<BaseQuestion, 'content'> & {
|
|
41
41
|
type: 'basic';
|
|
42
42
|
content: {
|
|
43
43
|
media?: unknown;
|
|
@@ -46,7 +46,7 @@ export declare type BasicQuestion = Omit<Question, 'content'> & {
|
|
|
46
46
|
id: string;
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
|
-
export declare type SliderQuestion = Omit<
|
|
49
|
+
export declare type SliderQuestion = Omit<BaseQuestion, 'content'> & {
|
|
50
50
|
content: {
|
|
51
51
|
media?: unknown;
|
|
52
52
|
unitLabel: string;
|
|
@@ -56,20 +56,25 @@ export declare type SliderQuestion = Omit<Question, 'content'> & {
|
|
|
56
56
|
};
|
|
57
57
|
type: 'slider';
|
|
58
58
|
};
|
|
59
|
-
export declare type TemplateQuestion = Omit<
|
|
59
|
+
export declare type TemplateQuestion = Omit<BaseQuestion, 'content'> & {
|
|
60
60
|
content: BaseContent & {
|
|
61
61
|
template: string;
|
|
62
62
|
};
|
|
63
63
|
type: 'template';
|
|
64
64
|
};
|
|
65
|
+
export declare type Question = QcmQuestion | QcmGraphicQuestion | QcmDragQuestion | BasicQuestion | SliderQuestion | TemplateQuestion;
|
|
65
66
|
export declare type SlideFromAPI = {
|
|
66
|
-
question:
|
|
67
|
+
question: Question;
|
|
67
68
|
klf: string;
|
|
68
69
|
universalRef: string;
|
|
69
70
|
tips?: string;
|
|
70
71
|
clue?: string;
|
|
71
72
|
hasClue?: boolean;
|
|
72
73
|
id: string;
|
|
74
|
+
parentContentTitle: {
|
|
75
|
+
title: string;
|
|
76
|
+
type: 'chapter' | 'course';
|
|
77
|
+
};
|
|
73
78
|
};
|
|
74
79
|
declare type ProgressionAnswerItem = {
|
|
75
80
|
isCorrect: boolean;
|
|
@@ -92,9 +97,17 @@ export declare type ProgressionState = {
|
|
|
92
97
|
step: {
|
|
93
98
|
current: number;
|
|
94
99
|
};
|
|
100
|
+
stars: number;
|
|
95
101
|
};
|
|
96
102
|
export declare type ProgressionFromAPI = {
|
|
97
103
|
_id: string;
|
|
104
|
+
content: {
|
|
105
|
+
type: 'skill';
|
|
106
|
+
ref: string;
|
|
107
|
+
};
|
|
108
|
+
engine: {
|
|
109
|
+
ref: 'review';
|
|
110
|
+
};
|
|
98
111
|
state: ProgressionState;
|
|
99
112
|
};
|
|
100
113
|
export declare type Skill = {
|
|
@@ -107,6 +120,7 @@ export declare type Services = {
|
|
|
107
120
|
fetchSkills(token: string): Promise<Skill[]>;
|
|
108
121
|
fetchSlide(slideRef: string, token: string): Promise<SlideFromAPI | void>;
|
|
109
122
|
postProgression(skillRef: string, token: string): Promise<ProgressionFromAPI>;
|
|
123
|
+
postAnswer(skillRef: string, token: string, progressionId: string, answer: string[]): Promise<ProgressionFromAPI>;
|
|
110
124
|
};
|
|
111
125
|
export declare type Options = {
|
|
112
126
|
services: Services;
|
|
@@ -1,3 +1,79 @@
|
|
|
1
|
+
import { Dispatch } from 'redux';
|
|
2
|
+
import { UISlide } from '../../types/common';
|
|
3
|
+
import { SlideIndexes } from '../../common';
|
|
1
4
|
import { StoreState } from '../../reducers';
|
|
2
|
-
|
|
3
|
-
|
|
5
|
+
declare const ICON_VALUES: {
|
|
6
|
+
readonly right: "right";
|
|
7
|
+
readonly wrong: "wrong";
|
|
8
|
+
readonly 'no-answer': "no-answer";
|
|
9
|
+
};
|
|
10
|
+
declare type IconValue = keyof typeof ICON_VALUES;
|
|
11
|
+
declare type StepItem = {
|
|
12
|
+
current: boolean;
|
|
13
|
+
icon: IconValue;
|
|
14
|
+
value: string;
|
|
15
|
+
};
|
|
16
|
+
declare type SlidesStack = {
|
|
17
|
+
[key in SlideIndexes]: UISlide;
|
|
18
|
+
};
|
|
19
|
+
export declare type CorrectionPopinProps = {
|
|
20
|
+
klf: {
|
|
21
|
+
label: string;
|
|
22
|
+
onClick: Function;
|
|
23
|
+
tooltip: string;
|
|
24
|
+
};
|
|
25
|
+
information: {
|
|
26
|
+
label: string;
|
|
27
|
+
message: string;
|
|
28
|
+
};
|
|
29
|
+
next: {
|
|
30
|
+
label: string;
|
|
31
|
+
ariaLabel: string;
|
|
32
|
+
};
|
|
33
|
+
successLabel: string;
|
|
34
|
+
failureLabel: string;
|
|
35
|
+
};
|
|
36
|
+
export declare type SlidesViewProps = {
|
|
37
|
+
header: {
|
|
38
|
+
mode: string;
|
|
39
|
+
skillName: string;
|
|
40
|
+
onQuitClick: Function;
|
|
41
|
+
'aria-label'?: string;
|
|
42
|
+
closeButtonAriaLabel: string;
|
|
43
|
+
steps: StepItem[];
|
|
44
|
+
};
|
|
45
|
+
stack: {
|
|
46
|
+
slides: SlidesStack;
|
|
47
|
+
validateButton: {
|
|
48
|
+
label: string;
|
|
49
|
+
disabled: boolean;
|
|
50
|
+
onClick: Function;
|
|
51
|
+
};
|
|
52
|
+
correctionPopinProps?: CorrectionPopinProps;
|
|
53
|
+
endReview: boolean;
|
|
54
|
+
};
|
|
55
|
+
reviewBackgroundAriaLabel?: string;
|
|
56
|
+
congratsProps?: {
|
|
57
|
+
'aria-label'?: string;
|
|
58
|
+
'data-name'?: string;
|
|
59
|
+
animationLottie: unknown;
|
|
60
|
+
title: string;
|
|
61
|
+
cardCongratsStar: unknown;
|
|
62
|
+
cardCongratsRank: unknown;
|
|
63
|
+
buttonRevising: {
|
|
64
|
+
'aria-label'?: string;
|
|
65
|
+
label: string;
|
|
66
|
+
onClick: Function;
|
|
67
|
+
type: string;
|
|
68
|
+
};
|
|
69
|
+
buttonRevisingSkill: {
|
|
70
|
+
'aria-label'?: string;
|
|
71
|
+
label: string;
|
|
72
|
+
onClick: Function;
|
|
73
|
+
type: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export declare const initialState: SlidesStack;
|
|
78
|
+
export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch) => SlidesViewProps | null;
|
|
79
|
+
export {};
|
|
@@ -9,8 +9,74 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
import concat from 'lodash/fp/concat';
|
|
13
|
+
import get from 'lodash/fp/get';
|
|
14
|
+
import getOr from 'lodash/fp/getOr';
|
|
12
15
|
import isEmpty from 'lodash/fp/isEmpty';
|
|
13
|
-
|
|
16
|
+
import pipe from 'lodash/fp/pipe';
|
|
17
|
+
import reduce from 'lodash/fp/reduce';
|
|
18
|
+
import set from 'lodash/fp/set';
|
|
19
|
+
import slice from 'lodash/fp/slice';
|
|
20
|
+
import toInteger from 'lodash/fp/toInteger';
|
|
21
|
+
import { mapApiSlideToUi } from './map-api-slide-to-ui';
|
|
22
|
+
var ICON_VALUES = {
|
|
23
|
+
right: 'right',
|
|
24
|
+
wrong: 'wrong',
|
|
25
|
+
'no-answer': 'no-answer'
|
|
26
|
+
};
|
|
27
|
+
export var initialState = {
|
|
28
|
+
'0': {
|
|
29
|
+
hidden: false,
|
|
30
|
+
position: 0
|
|
31
|
+
},
|
|
32
|
+
'1': {
|
|
33
|
+
hidden: false,
|
|
34
|
+
position: 1
|
|
35
|
+
},
|
|
36
|
+
'2': {
|
|
37
|
+
hidden: false,
|
|
38
|
+
position: 2
|
|
39
|
+
},
|
|
40
|
+
'3': {
|
|
41
|
+
hidden: false,
|
|
42
|
+
position: 3
|
|
43
|
+
},
|
|
44
|
+
'4': {
|
|
45
|
+
hidden: false,
|
|
46
|
+
position: 4
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var getProgressionSlidesRef = function (progression) {
|
|
50
|
+
if (progression.state.step.current < 5) {
|
|
51
|
+
var slideRef = progression.state.nextContent.ref;
|
|
52
|
+
return concat([slideRef], progression.state.slides);
|
|
53
|
+
}
|
|
54
|
+
return slice(0, 5, progression.state.slides);
|
|
55
|
+
};
|
|
56
|
+
var buildStackSlides = function (state, dispatch) {
|
|
57
|
+
var currentSlideRef = state.ui.currentSlideRef;
|
|
58
|
+
var progression = state.data.progression;
|
|
59
|
+
if (!currentSlideRef || !progression)
|
|
60
|
+
return initialState;
|
|
61
|
+
var slideRefs = getProgressionSlidesRef(progression);
|
|
62
|
+
// @ts-expect-error typescript does not support capped versions of lodash functions
|
|
63
|
+
var stack = reduce.convert({ cap: false })(function (acc, uiSlide, index) {
|
|
64
|
+
var slideRef = slideRefs[toInteger(index)];
|
|
65
|
+
if (!slideRef)
|
|
66
|
+
return set(index, uiSlide, acc);
|
|
67
|
+
var slideFromAPI = get(slideRef, state.data.slides);
|
|
68
|
+
var answers = state.ui.answers;
|
|
69
|
+
var _a = mapApiSlideToUi(dispatch)(slideFromAPI, answers), questionText = _a.questionText, answerUI = _a.answerUI;
|
|
70
|
+
var parentContentTitle = getOr('', 'parentContentTitle.title', slideFromAPI);
|
|
71
|
+
var parentContentType = getOr('', 'parentContentTitle.type', slideFromAPI);
|
|
72
|
+
var updatedUiSlide = pipe(set(['questionText'], questionText), set(['answerUI'], answerUI), set(['parentContentTitle'], "From \"".concat(parentContentTitle, "\" ").concat(parentContentType)) // TODO translate: -From- .... -Course/chapter-
|
|
73
|
+
// TODO: Set position according to currentSlideRef et slideRefs (or maybe a value on the state ui.slidePositions !!)
|
|
74
|
+
)(uiSlide);
|
|
75
|
+
return set(index, updatedUiSlide, acc);
|
|
76
|
+
}, initialState, initialState);
|
|
77
|
+
return stack;
|
|
78
|
+
};
|
|
79
|
+
var buildStepItems = function (state) {
|
|
14
80
|
var progression = state.data.progression;
|
|
15
81
|
var currentSlideRef = state.ui.currentSlideRef;
|
|
16
82
|
if (!progression)
|
|
@@ -55,7 +121,7 @@ var buildStepItemps = function (state) {
|
|
|
55
121
|
});
|
|
56
122
|
return steps;
|
|
57
123
|
};
|
|
58
|
-
export var mapStateToSlidesProps = function (state) {
|
|
124
|
+
export var mapStateToSlidesProps = function (state, dispatch) {
|
|
59
125
|
if (!state.data.slides) {
|
|
60
126
|
return null;
|
|
61
127
|
}
|
|
@@ -69,10 +135,10 @@ export var mapStateToSlidesProps = function (state) {
|
|
|
69
135
|
},
|
|
70
136
|
'aria-label': 'aria-header-wrapper',
|
|
71
137
|
closeButtonAriaLabel: 'aria-close-button',
|
|
72
|
-
steps:
|
|
138
|
+
steps: buildStepItems(state)
|
|
73
139
|
},
|
|
74
140
|
stack: {
|
|
75
|
-
slides: state
|
|
141
|
+
slides: buildStackSlides(state, dispatch),
|
|
76
142
|
validateButton: {
|
|
77
143
|
label: '__validate',
|
|
78
144
|
disabled: true,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Dispatch } from 'redux';
|
|
2
|
+
import { AnswerUI } from '../../types/slides';
|
|
3
|
+
import { Question, SlideFromAPI } from '../../types/common';
|
|
4
|
+
export declare const getQuestionType: (question: Question) => Question['type'];
|
|
5
|
+
export declare const mapApiSlideToUi: (dispatch: Dispatch) => (slide: SlideFromAPI, answers: string[]) => {
|
|
6
|
+
questionText: string;
|
|
7
|
+
answerUI: AnswerUI;
|
|
8
|
+
};
|