@coorpacademy/app-review 0.1.16 → 0.1.18
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 +3 -3
- package/es/actions/api/fetch-skills.js +7 -2
- package/es/actions/api/fetch-slide.d.ts +1 -1
- package/es/actions/api/fetch-slide.js +3 -1
- package/es/actions/api/post-answer.d.ts +14 -0
- package/es/actions/api/post-answer.js +25 -0
- package/es/actions/api/post-progression.d.ts +3 -3
- package/es/actions/api/post-progression.js +5 -2
- package/es/actions/api/test/fetch-skills.test.js +7 -4
- package/es/actions/api/test/fetch-slide.test.js +7 -4
- package/es/actions/api/test/post-answer.test.d.ts +1 -0
- package/es/actions/api/test/post-answer.test.js +82 -0
- package/es/actions/api/test/post-progression.test.js +7 -4
- package/es/actions/data/test/token.test.d.ts +1 -0
- package/es/actions/data/test/token.test.js +25 -0
- package/es/actions/index.d.ts +1 -8
- package/es/actions/{api/test → test}/create-test-store.d.ts +2 -2
- package/es/actions/{api/test → test}/create-test-store.js +1 -1
- package/es/actions/ui/answers.d.ts +17 -3
- package/es/actions/ui/answers.js +41 -3
- package/es/actions/ui/slides.d.ts +0 -5
- package/es/actions/ui/slides.js +0 -4
- package/es/actions/ui/test/answers.test.d.ts +1 -0
- package/es/actions/ui/test/answers.test.js +100 -0
- package/es/actions/ui/test/slides.test.d.ts +1 -0
- package/es/actions/ui/test/slides.test.js +26 -0
- package/es/common/index.d.ts +0 -3
- package/es/common/index.js +0 -4
- package/es/index.js +1 -3
- package/es/reducers/data/index.d.ts +1 -1
- package/es/reducers/data/progression.d.ts +3 -3
- package/es/reducers/data/progression.js +2 -5
- package/es/reducers/data/slides.d.ts +2 -3
- package/es/reducers/data/test/progression.test.js +12 -27
- package/es/reducers/index.d.ts +2 -1
- package/es/reducers/ui/answers.d.ts +2 -2
- package/es/reducers/ui/answers.js +4 -8
- package/es/reducers/ui/index.d.ts +4 -1
- package/es/reducers/ui/index.js +3 -1
- package/es/reducers/ui/slide.d.ts +8 -0
- package/es/reducers/ui/slide.js +26 -0
- package/es/reducers/ui/test/answers.test.js +23 -3
- package/es/reducers/ui/test/current-slide-ref.test.js +1 -1
- package/es/reducers/ui/test/navigation.test.js +5 -5
- package/es/reducers/ui/test/slide.test.d.ts +1 -0
- package/es/reducers/ui/test/slide.test.js +12 -0
- package/es/test/util/services.mock.d.ts +3 -1
- package/es/test/util/services.mock.js +89 -72
- package/es/types/common.d.ts +0 -25
- package/es/views/skills/index.d.ts +1 -1
- package/es/views/skills/index.js +0 -3
- package/es/views/skills/test/skills.test.d.ts +1 -0
- package/es/views/skills/test/skills.test.js +94 -0
- package/es/views/slides/index.d.ts +13 -2
- package/es/views/slides/index.js +19 -15
- package/es/views/slides/map-api-slide-to-ui.js +65 -68
- package/es/views/slides/test/fixtures/free-text.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm.d.ts +2 -1
- package/es/views/slides/test/fixtures/slider.d.ts +2 -1
- package/es/views/slides/test/fixtures/template.d.ts +4 -0
- package/{lib/views/slides/test/fixtures/select-template.js → es/views/slides/test/fixtures/template.js} +82 -4
- package/es/views/slides/test/index.test.d.ts +1 -0
- package/es/views/slides/test/index.test.js +473 -0
- package/es/views/slides/test/map-api-slide-to-ui.test.js +4 -10
- package/es/views/slides/test/slide.template.on-change.test.d.ts +1 -0
- package/es/views/slides/test/slide.template.on-change.test.js +79 -0
- package/lib/actions/api/fetch-skills.d.ts +3 -3
- package/lib/actions/api/fetch-skills.js +22 -19
- package/lib/actions/api/fetch-slide.d.ts +1 -1
- package/lib/actions/api/fetch-slide.js +3 -1
- package/lib/actions/api/post-answer.d.ts +14 -0
- package/lib/actions/api/post-answer.js +75 -0
- package/lib/actions/api/post-progression.d.ts +3 -3
- package/lib/actions/api/post-progression.js +6 -3
- package/lib/actions/api/test/fetch-skills.test.js +7 -4
- package/lib/actions/api/test/fetch-slide.test.js +7 -4
- package/lib/actions/api/test/post-answer.test.d.ts +1 -0
- package/lib/actions/api/test/post-answer.test.js +145 -0
- package/lib/actions/api/test/post-progression.test.js +7 -4
- package/lib/actions/data/test/token.test.d.ts +1 -0
- package/lib/actions/data/test/token.test.js +70 -0
- package/lib/actions/index.d.ts +1 -8
- package/lib/actions/{api/test → test}/create-test-store.d.ts +2 -2
- package/lib/actions/{api/test → test}/create-test-store.js +1 -1
- package/lib/actions/ui/answers.d.ts +17 -3
- package/lib/actions/ui/answers.js +50 -3
- package/lib/actions/ui/slides.d.ts +0 -5
- package/lib/actions/ui/slides.js +0 -4
- package/lib/actions/ui/test/answers.test.d.ts +1 -0
- package/lib/actions/ui/test/answers.test.js +190 -0
- package/lib/actions/ui/test/slides.test.d.ts +1 -0
- package/lib/actions/ui/test/slides.test.js +71 -0
- package/lib/common/index.d.ts +0 -3
- package/lib/common/index.js +0 -4
- package/lib/index.js +1 -3
- package/lib/reducers/data/index.d.ts +1 -1
- package/lib/reducers/data/progression.d.ts +3 -3
- package/lib/reducers/data/progression.js +2 -5
- package/lib/reducers/data/slides.d.ts +2 -3
- package/lib/reducers/data/test/progression.test.js +12 -27
- package/lib/reducers/index.d.ts +2 -1
- package/lib/reducers/ui/answers.d.ts +2 -2
- package/lib/reducers/ui/answers.js +4 -8
- package/lib/reducers/ui/index.d.ts +4 -1
- package/lib/reducers/ui/index.js +3 -1
- package/lib/reducers/ui/slide.d.ts +8 -0
- package/lib/reducers/ui/slide.js +27 -0
- package/lib/reducers/ui/test/answers.test.js +23 -3
- package/lib/reducers/ui/test/current-slide-ref.test.js +1 -1
- package/lib/reducers/ui/test/navigation.test.js +5 -5
- package/lib/reducers/ui/test/slide.test.d.ts +1 -0
- package/lib/reducers/ui/test/slide.test.js +12 -0
- package/lib/test/util/services.mock.d.ts +3 -1
- package/lib/test/util/services.mock.js +89 -72
- package/lib/types/common.d.ts +0 -25
- package/lib/views/skills/index.d.ts +1 -1
- package/lib/views/skills/index.js +0 -3
- package/lib/views/skills/test/skills.test.d.ts +1 -0
- package/lib/views/skills/test/skills.test.js +94 -0
- package/lib/views/slides/index.d.ts +13 -2
- package/lib/views/slides/index.js +19 -15
- package/lib/views/slides/map-api-slide-to-ui.js +106 -99
- package/lib/views/slides/test/fixtures/free-text.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm.d.ts +2 -1
- package/lib/views/slides/test/fixtures/slider.d.ts +2 -1
- package/lib/views/slides/test/fixtures/template.d.ts +4 -0
- package/{es/views/slides/test/fixtures/select-template.js → lib/views/slides/test/fixtures/template.js} +82 -4
- package/lib/views/slides/test/index.test.d.ts +1 -0
- package/lib/views/slides/test/index.test.js +473 -0
- package/lib/views/slides/test/map-api-slide-to-ui.test.js +4 -10
- package/lib/views/slides/test/slide.template.on-change.test.d.ts +1 -0
- package/lib/views/slides/test/slide.template.on-change.test.js +82 -0
- package/package.json +6 -5
- package/src/actions/api/fetch-skills.ts +18 -11
- package/src/actions/api/fetch-slide.ts +3 -1
- package/src/actions/api/post-answer.ts +44 -0
- package/src/actions/api/post-progression.ts +7 -4
- package/src/actions/api/test/fetch-skills.test.ts +9 -6
- package/src/actions/api/test/fetch-slide.test.ts +9 -6
- package/src/actions/api/test/post-answer.test.ts +101 -0
- package/src/actions/api/test/post-progression.test.ts +9 -6
- package/src/actions/data/test/token.test.ts +29 -0
- package/src/actions/index.ts +1 -17
- package/src/actions/{api/test → test}/create-test-store.ts +2 -2
- package/src/actions/ui/answers.ts +55 -6
- package/src/actions/ui/slides.ts +1 -8
- package/src/actions/ui/test/answers.test.ts +115 -0
- package/src/actions/ui/test/slides.test.ts +30 -0
- package/src/common/index.ts +0 -7
- package/src/index.tsx +1 -3
- package/src/reducers/data/progression.ts +4 -7
- package/src/reducers/data/slides.ts +2 -3
- package/src/reducers/data/test/progression.test.ts +15 -31
- package/src/reducers/ui/answers.ts +5 -9
- package/src/reducers/ui/index.ts +4 -1
- package/src/reducers/ui/slide.ts +43 -0
- package/src/reducers/ui/test/answers.test.ts +29 -4
- package/src/reducers/ui/test/current-slide-ref.test.ts +1 -1
- package/src/reducers/ui/test/navigation.test.ts +5 -5
- package/src/reducers/ui/test/slide.test.ts +15 -0
- package/src/test/util/services.mock.ts +94 -73
- package/src/types/common.ts +0 -30
- package/src/views/skills/index.ts +1 -5
- package/src/views/skills/test/skills.test.ts +101 -0
- package/src/views/slides/index.ts +38 -23
- package/src/views/slides/map-api-slide-to-ui.ts +146 -113
- package/src/views/slides/test/fixtures/free-text.ts +2 -1
- package/src/views/slides/test/fixtures/qcm-drag.ts +2 -1
- package/src/views/slides/test/fixtures/qcm-graphic.ts +2 -1
- package/src/views/slides/test/fixtures/qcm.ts +2 -1
- package/src/views/slides/test/fixtures/slider.ts +2 -1
- package/src/views/slides/test/fixtures/{select-template.ts → template.ts} +84 -5
- package/src/views/slides/test/index.test.ts +493 -0
- package/src/views/slides/test/map-api-slide-to-ui.test.ts +6 -11
- package/src/views/slides/test/slide.template.on-change.test.ts +92 -0
- package/es/fixtures/qcm-slide.d.ts +0 -2
- package/es/fixtures/qcm-slide.js +0 -33
- package/es/fixtures/temp-fixture.d.ts +0 -3
- package/es/fixtures/temp-fixture.js +0 -84
- package/es/views/slides/test/fixtures/select-template.d.ts +0 -3
- package/es/views/slides/test/fixtures/text-template.d.ts +0 -3
- package/es/views/slides/test/fixtures/text-template.js +0 -58
- package/lib/fixtures/qcm-slide.d.ts +0 -2
- package/lib/fixtures/qcm-slide.js +0 -33
- package/lib/fixtures/temp-fixture.d.ts +0 -3
- package/lib/fixtures/temp-fixture.js +0 -84
- package/lib/views/slides/test/fixtures/select-template.d.ts +0 -3
- package/lib/views/slides/test/fixtures/text-template.d.ts +0 -3
- package/lib/views/slides/test/fixtures/text-template.js +0 -58
- package/src/fixtures/qcm-slide.ts +0 -35
- package/src/fixtures/temp-fixture.ts +0 -94
- package/src/views/slides/test/fixtures/text-template.ts +0 -61
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Dispatch } from 'redux';
|
|
2
|
-
import { UISlide } from '../../types/common';
|
|
3
2
|
import { SlideIndexes } from '../../common';
|
|
4
3
|
import { StoreState } from '../../reducers';
|
|
4
|
+
import { AnswerUI } from '../../types/slides';
|
|
5
5
|
declare const ICON_VALUES: {
|
|
6
6
|
readonly right: "right";
|
|
7
7
|
readonly wrong: "wrong";
|
|
@@ -13,6 +13,17 @@ declare type StepItem = {
|
|
|
13
13
|
icon: IconValue;
|
|
14
14
|
value: string;
|
|
15
15
|
};
|
|
16
|
+
declare type SlideUIAnimations = 'unstack' | 'restack';
|
|
17
|
+
export declare type UISlide = {
|
|
18
|
+
questionText?: string;
|
|
19
|
+
answerUI?: AnswerUI;
|
|
20
|
+
hidden?: boolean;
|
|
21
|
+
position: number;
|
|
22
|
+
animationType?: SlideUIAnimations;
|
|
23
|
+
isCorrect?: boolean;
|
|
24
|
+
endReview?: boolean;
|
|
25
|
+
loading: boolean;
|
|
26
|
+
};
|
|
16
27
|
declare type SlidesStack = {
|
|
17
28
|
[key in SlideIndexes]: UISlide;
|
|
18
29
|
};
|
|
@@ -75,5 +86,5 @@ export declare type SlidesViewProps = {
|
|
|
75
86
|
};
|
|
76
87
|
};
|
|
77
88
|
export declare const initialState: SlidesStack;
|
|
78
|
-
export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch) => SlidesViewProps
|
|
89
|
+
export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch) => SlidesViewProps;
|
|
79
90
|
export {};
|
package/es/views/slides/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import reduce from 'lodash/fp/reduce';
|
|
|
7
7
|
import set from 'lodash/fp/set';
|
|
8
8
|
import slice from 'lodash/fp/slice';
|
|
9
9
|
import toInteger from 'lodash/fp/toInteger';
|
|
10
|
+
import { postAnswer } from '../../actions/api/post-answer';
|
|
10
11
|
import { mapApiSlideToUi } from './map-api-slide-to-ui';
|
|
11
12
|
const ICON_VALUES = {
|
|
12
13
|
right: 'right',
|
|
@@ -16,29 +17,34 @@ const ICON_VALUES = {
|
|
|
16
17
|
export const initialState = {
|
|
17
18
|
'0': {
|
|
18
19
|
hidden: false,
|
|
19
|
-
position: 0
|
|
20
|
+
position: 0,
|
|
21
|
+
loading: true
|
|
20
22
|
},
|
|
21
23
|
'1': {
|
|
22
24
|
hidden: false,
|
|
23
|
-
position: 1
|
|
25
|
+
position: 1,
|
|
26
|
+
loading: true
|
|
24
27
|
},
|
|
25
28
|
'2': {
|
|
26
29
|
hidden: false,
|
|
27
|
-
position: 2
|
|
30
|
+
position: 2,
|
|
31
|
+
loading: true
|
|
28
32
|
},
|
|
29
33
|
'3': {
|
|
30
34
|
hidden: false,
|
|
31
|
-
position: 3
|
|
35
|
+
position: 3,
|
|
36
|
+
loading: true
|
|
32
37
|
},
|
|
33
38
|
'4': {
|
|
34
39
|
hidden: false,
|
|
35
|
-
position: 4
|
|
40
|
+
position: 4,
|
|
41
|
+
loading: true
|
|
36
42
|
}
|
|
37
43
|
};
|
|
38
|
-
const
|
|
44
|
+
const getProgressionSlidesRefs = (progression) => {
|
|
39
45
|
if (progression.state.step.current < 5) {
|
|
40
46
|
const slideRef = progression.state.nextContent.ref;
|
|
41
|
-
return concat(
|
|
47
|
+
return concat(progression.state.slides, [slideRef]);
|
|
42
48
|
}
|
|
43
49
|
return slice(0, 5, progression.state.slides);
|
|
44
50
|
};
|
|
@@ -47,18 +53,20 @@ const buildStackSlides = (state, dispatch) => {
|
|
|
47
53
|
const progression = state.data.progression;
|
|
48
54
|
if (!currentSlideRef || !progression)
|
|
49
55
|
return initialState;
|
|
50
|
-
const slideRefs =
|
|
56
|
+
const slideRefs = getProgressionSlidesRefs(progression);
|
|
51
57
|
// @ts-expect-error typescript does not support capped versions of lodash functions
|
|
52
58
|
const stack = reduce.convert({ cap: false })((acc, uiSlide, index) => {
|
|
53
59
|
const slideRef = slideRefs[toInteger(index)];
|
|
54
60
|
if (!slideRef)
|
|
55
61
|
return set(index, uiSlide, acc);
|
|
56
62
|
const slideFromAPI = get(slideRef, state.data.slides);
|
|
63
|
+
if (!slideFromAPI)
|
|
64
|
+
return set(index, uiSlide, acc);
|
|
57
65
|
const answers = state.ui.answers;
|
|
58
66
|
const { questionText, answerUI } = mapApiSlideToUi(dispatch)(slideFromAPI, answers);
|
|
59
67
|
const parentContentTitle = getOr('', 'parentContentTitle.title', slideFromAPI);
|
|
60
68
|
const parentContentType = getOr('', 'parentContentTitle.type', slideFromAPI);
|
|
61
|
-
const updatedUiSlide = pipe(set(
|
|
69
|
+
const updatedUiSlide = pipe(set('loading', false), set('questionText', questionText), set('answerUI', answerUI), set('parentContentTitle', `From "${parentContentTitle}" ${parentContentType}`) // TODO translate: -From- .... -Course/chapter-
|
|
62
70
|
// TODO: Set position according to currentSlideRef et slideRefs (or maybe a value on the state ui.slidePositions !!)
|
|
63
71
|
)(uiSlide);
|
|
64
72
|
return set(index, updatedUiSlide, acc);
|
|
@@ -118,9 +126,6 @@ const buildStepItems = (state) => {
|
|
|
118
126
|
return steps;
|
|
119
127
|
};
|
|
120
128
|
export const mapStateToSlidesProps = (state, dispatch) => {
|
|
121
|
-
if (!state.data.slides) {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
129
|
return {
|
|
125
130
|
header: {
|
|
126
131
|
mode: '__revision_mode',
|
|
@@ -137,10 +142,9 @@ export const mapStateToSlidesProps = (state, dispatch) => {
|
|
|
137
142
|
slides: buildStackSlides(state, dispatch),
|
|
138
143
|
validateButton: {
|
|
139
144
|
label: '__validate',
|
|
140
|
-
disabled:
|
|
145
|
+
disabled: !get('ui.slide.validateButton', state),
|
|
141
146
|
onClick: () => {
|
|
142
|
-
|
|
143
|
-
console.log('TODO: validate question');
|
|
147
|
+
dispatch(postAnswer);
|
|
144
148
|
}
|
|
145
149
|
},
|
|
146
150
|
correctionPopinProps: undefined,
|
|
@@ -1,75 +1,71 @@
|
|
|
1
|
-
import { concat, divide, get, getOr, head, includes, indexOf, isEmpty, map, rangeStep, size, toInteger } from 'lodash/fp';
|
|
1
|
+
import { concat, constant, divide, get, getOr, head, includes, indexOf, isEmpty, isNil, map, multiply, pipe, rangeStep, round, set, size, times, toInteger, toString as _toString, __ } from 'lodash/fp';
|
|
2
2
|
import { editAnswer } from '../../actions/ui/answers';
|
|
3
|
-
const qcmProps = (question) => {
|
|
4
|
-
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
5
|
-
const answers = [];
|
|
3
|
+
const qcmProps = (dispatch) => (answers, question) => {
|
|
6
4
|
return {
|
|
7
5
|
type: 'qcm',
|
|
8
|
-
answers: map(choice =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
answers: map(choice => {
|
|
7
|
+
const label = choice.label || '';
|
|
8
|
+
return {
|
|
9
|
+
title: label,
|
|
10
|
+
selected: includes(label, answers),
|
|
11
|
+
onClick: () => {
|
|
12
|
+
dispatch(editAnswer([label]));
|
|
13
|
+
},
|
|
14
|
+
ariaLabel: choice.label
|
|
15
|
+
};
|
|
16
|
+
}, question.content.choices)
|
|
18
17
|
};
|
|
19
18
|
};
|
|
20
|
-
const qcmDragProps = (question) => {
|
|
21
|
-
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
22
|
-
const answers = [];
|
|
19
|
+
const qcmDragProps = (dispatch) => (answers, question) => {
|
|
23
20
|
return {
|
|
24
21
|
type: 'qcmDrag',
|
|
25
22
|
answers: map(choice => {
|
|
26
|
-
const
|
|
23
|
+
const label = choice.label || '';
|
|
24
|
+
const indexInAnswer = indexOf(label, answers);
|
|
27
25
|
return {
|
|
28
|
-
title:
|
|
29
|
-
selected: includes(
|
|
26
|
+
title: label,
|
|
27
|
+
selected: includes(label, answers),
|
|
30
28
|
order: indexInAnswer,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
onClick: () => {
|
|
30
|
+
dispatch(editAnswer([label]));
|
|
31
|
+
}
|
|
34
32
|
};
|
|
35
|
-
// TODO: EDIT_CHOICES -> getChoices
|
|
36
33
|
}, question.content.choices)
|
|
37
34
|
};
|
|
38
35
|
};
|
|
39
|
-
const qcmGraphicProps = (question) => {
|
|
40
|
-
// mock the answers
|
|
41
|
-
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
42
|
-
const answers = [];
|
|
36
|
+
const qcmGraphicProps = (dispatch) => (answers, question) => {
|
|
43
37
|
return {
|
|
44
38
|
type: 'qcmGraphic',
|
|
45
|
-
answers: map(choice =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
39
|
+
answers: map(choice => {
|
|
40
|
+
const label = choice.label || '';
|
|
41
|
+
return {
|
|
42
|
+
title: label,
|
|
43
|
+
image: get('media.src.0.url', choice),
|
|
44
|
+
selected: includes(label, answers),
|
|
45
|
+
onClick: () => {
|
|
46
|
+
dispatch(editAnswer([label]));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}, question.content.choices)
|
|
55
50
|
};
|
|
56
51
|
};
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
const updateTemplateAnswer = (text, _answers, index, max) => {
|
|
53
|
+
const answers = isEmpty(_answers) ? times(constant(undefined), max) : _answers;
|
|
54
|
+
return map(a => (isNil(a) ? '' : a), set(index, text, answers));
|
|
55
|
+
};
|
|
56
|
+
const templateTextProps = (dispatch, answers, choice, index, maxLength) => {
|
|
60
57
|
return {
|
|
61
58
|
type: 'text',
|
|
62
59
|
name: getOr('', 'name', choice),
|
|
63
60
|
placeholder: 'Type here',
|
|
64
61
|
value: get(index, answers),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
onChange: (text) => {
|
|
63
|
+
const newAnswers = updateTemplateAnswer(text, answers, index, maxLength);
|
|
64
|
+
dispatch(editAnswer(newAnswers));
|
|
65
|
+
}
|
|
68
66
|
};
|
|
69
67
|
};
|
|
70
|
-
const templateSelectProps = (choice, index) => {
|
|
71
|
-
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
72
|
-
const answers = [];
|
|
68
|
+
const templateSelectProps = (dispatch, answers, choice, index, maxLength) => {
|
|
73
69
|
const answer = get(index, answers);
|
|
74
70
|
const temporaryOption = {
|
|
75
71
|
name: 'Select an answer',
|
|
@@ -89,19 +85,22 @@ const templateSelectProps = (choice, index) => {
|
|
|
89
85
|
return {
|
|
90
86
|
type: 'select',
|
|
91
87
|
name: getOr('', 'name', choice),
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
onChange: (text) => {
|
|
89
|
+
const newAnswers = updateTemplateAnswer(text, answers, index, maxLength);
|
|
90
|
+
dispatch(editAnswer(newAnswers));
|
|
91
|
+
},
|
|
95
92
|
options: isEmpty(answer) ? concat([temporaryOption], selectOptions) : selectOptions
|
|
96
93
|
};
|
|
97
94
|
};
|
|
98
|
-
const templateProps = (question) => {
|
|
99
|
-
// TODO: EDIT_CHOICES -> getChoices
|
|
95
|
+
const templateProps = (dispatch) => (answers, question) => {
|
|
100
96
|
const choices = question.content.choices;
|
|
97
|
+
const maxLength = size(choices);
|
|
101
98
|
return {
|
|
102
99
|
type: 'template',
|
|
103
100
|
template: get('content.template', question),
|
|
104
|
-
answers: choices.map((choice, index) => choice.type === 'text'
|
|
101
|
+
answers: choices.map((choice, index) => choice.type === 'text'
|
|
102
|
+
? templateTextProps(dispatch, answers, choice, index, maxLength)
|
|
103
|
+
: templateSelectProps(dispatch, answers, choice, index, maxLength))
|
|
105
104
|
};
|
|
106
105
|
};
|
|
107
106
|
const basicProps = (dispatch) => (answers, question) => {
|
|
@@ -110,22 +109,19 @@ const basicProps = (dispatch) => (answers, question) => {
|
|
|
110
109
|
placeholder: question.content.placeholder || '',
|
|
111
110
|
value: answers[0] || '',
|
|
112
111
|
onChange: (text) => {
|
|
113
|
-
|
|
114
|
-
console.log(text);
|
|
115
|
-
dispatch(editAnswer(text));
|
|
112
|
+
dispatch(editAnswer([text]));
|
|
116
113
|
}
|
|
117
114
|
};
|
|
118
115
|
};
|
|
119
|
-
const sliderProps = (question) => {
|
|
116
|
+
const sliderProps = (dispatch) => (answers, question) => {
|
|
120
117
|
const values = rangeStep(getOr(1, 'content.step', question), get('content.min', question), get('content.max', question) + 1
|
|
121
118
|
// Lodash doesn't infer the type very well here
|
|
122
119
|
);
|
|
123
|
-
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
124
|
-
const answers = [];
|
|
125
120
|
const stateValue = head(answers) || question.content.min;
|
|
126
121
|
const currentValue = toInteger(stateValue);
|
|
127
122
|
const indexValue = indexOf(currentValue, values);
|
|
128
|
-
const
|
|
123
|
+
const maxValue = size(values) - 1;
|
|
124
|
+
const sliderPosition = divide(indexValue, maxValue);
|
|
129
125
|
const unitLabel = get('content.unitLabel', question);
|
|
130
126
|
return {
|
|
131
127
|
type: 'slider',
|
|
@@ -134,9 +130,10 @@ const sliderProps = (question) => {
|
|
|
134
130
|
maxLabel: `${question.content.max} ${unitLabel}`,
|
|
135
131
|
title: `${currentValue} ${question.content.unitLabel}`,
|
|
136
132
|
value: sliderPosition,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
133
|
+
onChange: (position) => {
|
|
134
|
+
const newValue = pipe(multiply(maxValue), round, get(__, values), _toString)(position);
|
|
135
|
+
dispatch(editAnswer([newValue]));
|
|
136
|
+
}
|
|
140
137
|
};
|
|
141
138
|
};
|
|
142
139
|
export const getQuestionType = (question) => question.type;
|
|
@@ -145,17 +142,17 @@ const getAnswerUIModel = (question, answers, dispatch) => {
|
|
|
145
142
|
const type = getQuestionType(question);
|
|
146
143
|
switch (type) {
|
|
147
144
|
case 'qcm':
|
|
148
|
-
return qcmProps(question);
|
|
145
|
+
return qcmProps(dispatch)(answers, question);
|
|
149
146
|
case 'qcmGraphic':
|
|
150
|
-
return qcmGraphicProps(question);
|
|
147
|
+
return qcmGraphicProps(dispatch)(answers, question);
|
|
151
148
|
case 'qcmDrag':
|
|
152
|
-
return qcmDragProps(question);
|
|
149
|
+
return qcmDragProps(dispatch)(answers, question);
|
|
153
150
|
case 'basic':
|
|
154
151
|
return basicProps(dispatch)(answers, question);
|
|
155
152
|
case 'template':
|
|
156
|
-
return templateProps(question);
|
|
153
|
+
return templateProps(dispatch)(answers, question);
|
|
157
154
|
case 'slider':
|
|
158
|
-
return sliderProps(question);
|
|
155
|
+
return sliderProps(dispatch)(answers, question);
|
|
159
156
|
default:
|
|
160
157
|
throw new Error(`${type} is not an handled question.type`);
|
|
161
158
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UISlide } from '../..';
|
|
2
|
+
import { SlideFromAPI } from '../../../../types/common';
|
|
2
3
|
export declare const qcmGraphicSlide: SlideFromAPI;
|
|
3
4
|
export declare const qcmGraphicUISlide: Partial<UISlide>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import noop from 'lodash/fp/noop';
|
|
2
|
-
export
|
|
2
|
+
export const templateSlide = {
|
|
3
3
|
question: {
|
|
4
4
|
content: {
|
|
5
|
-
template: 'La vue {{sel80495}} présente la liste des
|
|
5
|
+
template: 'La vue {{sel80495}} présente la liste des {{inp58402}} ayant le plus grand nombre d’{{sel80496}} cumulées.',
|
|
6
6
|
choices: [
|
|
7
7
|
{
|
|
8
8
|
items: [
|
|
@@ -30,6 +30,45 @@ export var selectTemplateSlide = {
|
|
|
30
30
|
_id: '5b57464e3b594d002e8829f3',
|
|
31
31
|
name: 'sel80495',
|
|
32
32
|
type: 'select'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
media: {
|
|
36
|
+
src: [],
|
|
37
|
+
posters: [],
|
|
38
|
+
subtitles: []
|
|
39
|
+
},
|
|
40
|
+
items: [],
|
|
41
|
+
_id: '62433c2c58920f02c4950de0',
|
|
42
|
+
type: 'text',
|
|
43
|
+
name: 'inp58402',
|
|
44
|
+
id: '62433c2c58920f02c4950de0'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
items: [
|
|
48
|
+
{
|
|
49
|
+
_id: '5b57464e3b594d002e8829f7',
|
|
50
|
+
value: 'sli_N13-hG3kX.choice_NJgC3aznJm',
|
|
51
|
+
text: 'étoiles'
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
_id: '5b57464e3b594d002e8829f6',
|
|
55
|
+
value: 'sli_N13-hG3kX.choice_EJZ02aMny7',
|
|
56
|
+
text: 'idées'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
_id: '5b57464e3b594d002e8829f5',
|
|
60
|
+
value: 'sli_N13-hG3kX.choice_4keCaf21Q',
|
|
61
|
+
text: 'envies'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
_id: '5b57464e3b594d002e8829f4',
|
|
65
|
+
value: 'sli_N13-hG3kX.choice_NkbJAMn17',
|
|
66
|
+
text: 'images'
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
_id: '5b57464e3b594d002e8829f3',
|
|
70
|
+
name: 'sel80496',
|
|
71
|
+
type: 'select'
|
|
33
72
|
}
|
|
34
73
|
]
|
|
35
74
|
},
|
|
@@ -46,13 +85,13 @@ export var selectTemplateSlide = {
|
|
|
46
85
|
type: 'course'
|
|
47
86
|
}
|
|
48
87
|
};
|
|
49
|
-
export
|
|
88
|
+
export const templateUISlide = {
|
|
50
89
|
questionText: 'Complétez la phrase ci-dessous.',
|
|
51
90
|
answerUI: {
|
|
52
91
|
help: 'Saisissez votre réponse ou sélectionnez la bonne réponse dans le(s) menu(s) déroulant(s).',
|
|
53
92
|
model: {
|
|
54
93
|
type: 'template',
|
|
55
|
-
template: 'La vue {{sel80495}} présente la liste des
|
|
94
|
+
template: 'La vue {{sel80495}} présente la liste des {{inp58402}} ayant le plus grand nombre d’{{sel80496}} cumulées.',
|
|
56
95
|
answers: [
|
|
57
96
|
{
|
|
58
97
|
type: 'select',
|
|
@@ -85,6 +124,45 @@ export var selectTemplateUISlide = {
|
|
|
85
124
|
selected: false
|
|
86
125
|
}
|
|
87
126
|
]
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
type: 'text',
|
|
130
|
+
name: 'inp58402',
|
|
131
|
+
placeholder: 'Type here',
|
|
132
|
+
value: undefined,
|
|
133
|
+
onChange: noop
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
type: 'select',
|
|
137
|
+
name: 'sel80496',
|
|
138
|
+
onChange: noop,
|
|
139
|
+
options: [
|
|
140
|
+
{ name: 'Select an answer', value: '', validOption: false, selected: true },
|
|
141
|
+
{
|
|
142
|
+
name: 'étoiles',
|
|
143
|
+
value: 'étoiles',
|
|
144
|
+
validOption: true,
|
|
145
|
+
selected: false
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'idées',
|
|
149
|
+
value: 'idées',
|
|
150
|
+
validOption: true,
|
|
151
|
+
selected: false
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: 'envies',
|
|
155
|
+
value: 'envies',
|
|
156
|
+
validOption: true,
|
|
157
|
+
selected: false
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: 'images',
|
|
161
|
+
value: 'images',
|
|
162
|
+
validOption: true,
|
|
163
|
+
selected: false
|
|
164
|
+
}
|
|
165
|
+
]
|
|
88
166
|
}
|
|
89
167
|
]
|
|
90
168
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|