@coorpacademy/app-review 0.1.17 → 0.1.19
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/post-answer.d.ts +5 -1
- package/es/actions/ui/answers.d.ts +1 -1
- package/es/actions/ui/answers.js +6 -4
- package/es/actions/ui/test/answers.test.js +15 -5
- package/es/reducers/data/index.d.ts +1 -1
- package/es/reducers/data/progression.d.ts +2 -1
- package/es/reducers/data/progression.js +2 -0
- package/es/reducers/data/test/progression.test.js +11 -26
- package/es/reducers/index.d.ts +1 -1
- package/es/reducers/ui/index.d.ts +1 -1
- package/es/reducers/ui/test/answers.test.js +4 -0
- package/es/test/util/services.mock.d.ts +1 -0
- package/es/test/util/services.mock.js +4 -1
- package/es/views/slides/index.js +1 -1
- package/es/views/slides/map-api-slide-to-ui.js +26 -22
- package/es/views/slides/test/fixtures/template.d.ts +4 -0
- package/es/views/slides/test/fixtures/{select-template.js → template.js} +82 -4
- package/es/views/slides/test/index.test.js +239 -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/post-answer.d.ts +5 -1
- package/lib/actions/ui/answers.d.ts +1 -1
- package/lib/actions/ui/answers.js +6 -4
- package/lib/actions/ui/test/answers.test.js +24 -5
- package/lib/reducers/data/index.d.ts +1 -1
- package/lib/reducers/data/progression.d.ts +2 -1
- package/lib/reducers/data/progression.js +2 -0
- package/lib/reducers/data/test/progression.test.js +11 -26
- package/lib/reducers/index.d.ts +1 -1
- package/lib/reducers/ui/index.d.ts +1 -1
- package/lib/reducers/ui/test/answers.test.js +4 -0
- package/lib/test/util/services.mock.d.ts +1 -0
- package/lib/test/util/services.mock.js +4 -1
- package/lib/views/slides/index.js +1 -1
- package/lib/views/slides/map-api-slide-to-ui.js +34 -28
- package/lib/views/slides/test/fixtures/template.d.ts +4 -0
- package/lib/views/slides/test/fixtures/{select-template.js → template.js} +82 -4
- package/lib/views/slides/test/index.test.js +239 -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 +3 -3
- package/src/actions/api/post-answer.ts +6 -1
- package/src/actions/ui/answers.ts +8 -6
- package/src/actions/ui/test/answers.test.ts +17 -5
- package/src/reducers/data/progression.ts +3 -1
- package/src/reducers/data/test/progression.test.ts +12 -28
- package/src/reducers/ui/test/answers.test.ts +5 -0
- package/src/test/util/services.mock.ts +4 -1
- package/src/views/slides/index.ts +1 -1
- package/src/views/slides/map-api-slide-to-ui.ts +63 -30
- package/src/views/slides/test/fixtures/{select-template.ts → template.ts} +82 -4
- package/src/views/slides/test/index.test.ts +253 -0
- package/src/views/slides/test/map-api-slide-to-ui.test.ts +4 -10
- package/src/views/slides/test/slide.template.on-change.test.ts +92 -0
- package/es/views/slides/test/fixtures/select-template.d.ts +0 -4
- package/es/views/slides/test/fixtures/text-template.d.ts +0 -4
- package/es/views/slides/test/fixtures/text-template.js +0 -58
- package/lib/views/slides/test/fixtures/select-template.d.ts +0 -4
- package/lib/views/slides/test/fixtures/text-template.d.ts +0 -4
- package/lib/views/slides/test/fixtures/text-template.js +0 -58
- package/src/views/slides/test/fixtures/text-template.ts +0 -62
|
@@ -29,25 +29,27 @@ export type EditAnswerAction = {
|
|
|
29
29
|
payload: string[];
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
const buildAnswer = (userAnswers: string[], questionType: string, newValue: string): string[] => {
|
|
32
|
+
const buildAnswer = (userAnswers: string[], questionType: string, newValue: string[]): string[] => {
|
|
33
33
|
switch (questionType) {
|
|
34
34
|
case 'qcm':
|
|
35
35
|
case 'qcmGraphic':
|
|
36
36
|
case 'qcmDrag': {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const firstValue = newValue[0];
|
|
38
|
+
return includes(firstValue, userAnswers)
|
|
39
|
+
? pull(firstValue, userAnswers)
|
|
40
|
+
: flatten([...userAnswers, firstValue]);
|
|
40
41
|
}
|
|
41
42
|
case 'basic':
|
|
42
43
|
case 'slider':
|
|
43
|
-
|
|
44
|
+
case 'template':
|
|
45
|
+
return newValue;
|
|
44
46
|
default:
|
|
45
47
|
return [];
|
|
46
48
|
}
|
|
47
49
|
};
|
|
48
50
|
|
|
49
51
|
export const editAnswer =
|
|
50
|
-
(answer: string) =>
|
|
52
|
+
(answer: string[]) =>
|
|
51
53
|
(dispatch: Dispatch, getState: () => StoreState): EditAnswerAction => {
|
|
52
54
|
const state = getState();
|
|
53
55
|
const currentSlideRef = get(['ui', 'currentSlideRef'])(state);
|
|
@@ -9,6 +9,8 @@ import {qcmDragSlide} from '../../../views/slides/test/fixtures/qcm-drag';
|
|
|
9
9
|
import {qcmSlide} from '../../../views/slides/test/fixtures/qcm';
|
|
10
10
|
import {qcmGraphicSlide} from '../../../views/slides/test/fixtures/qcm-graphic';
|
|
11
11
|
import {sliderSlide} from '../../../views/slides/test/fixtures/slider';
|
|
12
|
+
import {templateSlide} from '../../../views/slides/test/fixtures/template';
|
|
13
|
+
|
|
12
14
|
import {StoreState} from '../../../reducers';
|
|
13
15
|
import {editAnswer, ANSWER_EDIT} from '../answers';
|
|
14
16
|
|
|
@@ -64,7 +66,7 @@ test('should dispatch EDIT_BASIC action when editAnswer is called', async t => {
|
|
|
64
66
|
const state = buildInitialState(initialState, freeTextSlide);
|
|
65
67
|
const expectedActions = [{type: ANSWER_EDIT.basic, payload: ['My Answer']}];
|
|
66
68
|
const {dispatch} = createTestStore(t, state, services, expectedActions);
|
|
67
|
-
await dispatch(editAnswer('My Answer'));
|
|
69
|
+
await dispatch(editAnswer(['My Answer']));
|
|
68
70
|
});
|
|
69
71
|
|
|
70
72
|
test('should dispatch EDIT_QCM action when editAnswer is called', async t => {
|
|
@@ -72,7 +74,7 @@ test('should dispatch EDIT_QCM action when editAnswer is called', async t => {
|
|
|
72
74
|
state = set(['ui', 'answers'], ['My First Answer', 'My Second Answer'], state);
|
|
73
75
|
const expectedActions = [{type: ANSWER_EDIT.qcm, payload: ['My First Answer']}];
|
|
74
76
|
const {dispatch} = createTestStore(t, state, services, expectedActions);
|
|
75
|
-
await dispatch(editAnswer('My Second Answer'));
|
|
77
|
+
await dispatch(editAnswer(['My Second Answer']));
|
|
76
78
|
});
|
|
77
79
|
|
|
78
80
|
test('should dispatch EDIT_QCM_GRAPHIC action when editAnswer is called', async t => {
|
|
@@ -82,7 +84,7 @@ test('should dispatch EDIT_QCM_GRAPHIC action when editAnswer is called', async
|
|
|
82
84
|
{type: ANSWER_EDIT.qcmGraphic, payload: ['My First Answer', 'My Third Answer']}
|
|
83
85
|
];
|
|
84
86
|
const {dispatch} = createTestStore(t, state, services, expectedActions);
|
|
85
|
-
await dispatch(editAnswer('My Second Answer'));
|
|
87
|
+
await dispatch(editAnswer(['My Second Answer']));
|
|
86
88
|
});
|
|
87
89
|
|
|
88
90
|
test('should dispatch EDIT_QCM_DRAG action when editAnswer is called', async t => {
|
|
@@ -92,12 +94,22 @@ test('should dispatch EDIT_QCM_DRAG action when editAnswer is called', async t =
|
|
|
92
94
|
{type: ANSWER_EDIT.qcmDrag, payload: ['My First Answer', 'My Second Answer', 'My Third Answer']}
|
|
93
95
|
];
|
|
94
96
|
const {dispatch} = createTestStore(t, state, services, expectedActions);
|
|
95
|
-
await dispatch(editAnswer('My Third Answer'));
|
|
97
|
+
await dispatch(editAnswer(['My Third Answer']));
|
|
96
98
|
});
|
|
97
99
|
|
|
98
100
|
test('should dispatch EDIT_SLIDER action when editAnswer is called', async t => {
|
|
99
101
|
const state = buildInitialState(initialState, sliderSlide);
|
|
100
102
|
const expectedActions = [{type: ANSWER_EDIT.slider, payload: ['5']}];
|
|
101
103
|
const {dispatch} = createTestStore(t, state, services, expectedActions);
|
|
102
|
-
await dispatch(editAnswer('5'));
|
|
104
|
+
await dispatch(editAnswer(['5']));
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('should dispatch EDIT_TEMPLATE action when editAnswer is called', async t => {
|
|
108
|
+
let state = buildInitialState(initialState, templateSlide);
|
|
109
|
+
state = set(['ui', 'answers'], ['Catalogue', '', 'étoiles'], state);
|
|
110
|
+
const expectedActions = [
|
|
111
|
+
{type: ANSWER_EDIT.template, payload: ['Catalogue', 'My Answer', 'étoiles']}
|
|
112
|
+
];
|
|
113
|
+
const {dispatch} = createTestStore(t, state, services, expectedActions);
|
|
114
|
+
await dispatch(editAnswer(['Catalogue', 'My Answer', 'étoiles']));
|
|
103
115
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {PostAnswerSuccessAction, POST_ANSWER_SUCCESS} from '../../actions/api/post-answer';
|
|
1
2
|
import {POST_PROGRESSION_SUCCESS, ReceivedProgression} from '../../actions/api/post-progression';
|
|
2
3
|
import {ProgressionFromAPI} from '../../types/common';
|
|
3
4
|
|
|
@@ -6,9 +7,10 @@ export type ProgressionState = ProgressionFromAPI | null;
|
|
|
6
7
|
const reducer = (
|
|
7
8
|
// eslint-disable-next-line default-param-last
|
|
8
9
|
state: ProgressionState = null,
|
|
9
|
-
action: ReceivedProgression
|
|
10
|
+
action: ReceivedProgression | PostAnswerSuccessAction
|
|
10
11
|
): ProgressionState => {
|
|
11
12
|
switch (action.type) {
|
|
13
|
+
case POST_ANSWER_SUCCESS:
|
|
12
14
|
case POST_PROGRESSION_SUCCESS: {
|
|
13
15
|
const progression = action.payload;
|
|
14
16
|
return progression;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import reducer from '../progression';
|
|
3
3
|
import {POST_PROGRESSION_SUCCESS, ReceivedProgression} from '../../../actions/api/post-progression';
|
|
4
|
-
import {
|
|
4
|
+
import {POST_ANSWER_SUCCESS} from '../../../actions/api/post-answer';
|
|
5
|
+
import {postAnswerResponse, postProgressionResponse} from '../../../test/util/services.mock';
|
|
5
6
|
|
|
6
7
|
test('should have initial value', t => {
|
|
7
8
|
const state = reducer(undefined, {} as ReceivedProgression);
|
|
@@ -9,34 +10,17 @@ test('should have initial value', t => {
|
|
|
9
10
|
});
|
|
10
11
|
|
|
11
12
|
test('should set the value of POST_PROGRESSION_SUCCESS action', t => {
|
|
12
|
-
const progression: ProgressionFromAPI = {
|
|
13
|
-
_id: '62b1d1087aa12f00253f40ee',
|
|
14
|
-
content: {
|
|
15
|
-
ref: '_skill-ref',
|
|
16
|
-
type: 'skill'
|
|
17
|
-
},
|
|
18
|
-
engine: {
|
|
19
|
-
ref: 'review'
|
|
20
|
-
},
|
|
21
|
-
state: {
|
|
22
|
-
allAnswers: [],
|
|
23
|
-
isCorrect: true,
|
|
24
|
-
nextContent: {
|
|
25
|
-
ref: 'sli_N1XACJobn',
|
|
26
|
-
type: 'slide'
|
|
27
|
-
},
|
|
28
|
-
pendingSlides: [],
|
|
29
|
-
slides: [],
|
|
30
|
-
step: {
|
|
31
|
-
current: 1
|
|
32
|
-
},
|
|
33
|
-
stars: 0
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
13
|
const state = reducer(null, {
|
|
38
14
|
type: POST_PROGRESSION_SUCCESS,
|
|
39
|
-
payload:
|
|
15
|
+
payload: postProgressionResponse
|
|
16
|
+
});
|
|
17
|
+
t.deepEqual(state, postProgressionResponse);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('should set the value of POST_ANSWER_SUCCESS action', t => {
|
|
21
|
+
const state = reducer(null, {
|
|
22
|
+
type: POST_ANSWER_SUCCESS,
|
|
23
|
+
payload: postAnswerResponse
|
|
40
24
|
});
|
|
41
|
-
t.deepEqual(state,
|
|
25
|
+
t.deepEqual(state, postAnswerResponse);
|
|
42
26
|
});
|
|
@@ -31,3 +31,8 @@ test('should set the value of EDIT_SLIDER action', t => {
|
|
|
31
31
|
const state = reducer([], {type: ANSWER_EDIT.slider, payload: ['5']});
|
|
32
32
|
t.deepEqual(state, ['5']);
|
|
33
33
|
});
|
|
34
|
+
|
|
35
|
+
test('should set the value of EDIT_TEMPLATE action', t => {
|
|
36
|
+
const state = reducer([], {type: ANSWER_EDIT.template, payload: ['value1', 'value2']});
|
|
37
|
+
t.deepEqual(state, ['value1', 'value2']);
|
|
38
|
+
});
|
|
@@ -2,6 +2,7 @@ import {qcmSlide} from '../../views/slides/test/fixtures/qcm';
|
|
|
2
2
|
import {qcmGraphicSlide} from '../../views/slides/test/fixtures/qcm-graphic';
|
|
3
3
|
import {freeTextSlide} from '../../views/slides/test/fixtures/free-text';
|
|
4
4
|
import {sliderSlide} from '../../views/slides/test/fixtures/slider';
|
|
5
|
+
import {templateSlide} from '../../views/slides/test/fixtures/template';
|
|
5
6
|
import {ProgressionFromAPI, Services, SlideFromAPI} from '../../types/common';
|
|
6
7
|
|
|
7
8
|
const getSlideFixture = (ref: string): SlideFromAPI => {
|
|
@@ -12,6 +13,8 @@ const getSlideFixture = (ref: string): SlideFromAPI => {
|
|
|
12
13
|
return qcmGraphicSlide;
|
|
13
14
|
case freeTextSlide.universalRef:
|
|
14
15
|
return freeTextSlide;
|
|
16
|
+
case templateSlide.universalRef:
|
|
17
|
+
return templateSlide;
|
|
15
18
|
default:
|
|
16
19
|
return sliderSlide;
|
|
17
20
|
}
|
|
@@ -32,7 +35,7 @@ const fetchSkillsResponse = [
|
|
|
32
35
|
}
|
|
33
36
|
];
|
|
34
37
|
|
|
35
|
-
const postProgressionResponse: ProgressionFromAPI = {
|
|
38
|
+
export const postProgressionResponse: ProgressionFromAPI = {
|
|
36
39
|
_id: '62b1d1087aa12f00253f40ee',
|
|
37
40
|
content: {
|
|
38
41
|
ref: '_skill-ref',
|
|
@@ -138,7 +138,7 @@ export const initialState: SlidesStack = {
|
|
|
138
138
|
const getProgressionSlidesRefs = (progression: ProgressionFromAPI): string[] => {
|
|
139
139
|
if (progression.state.step.current < 5) {
|
|
140
140
|
const slideRef = progression.state.nextContent.ref;
|
|
141
|
-
return concat(
|
|
141
|
+
return concat(progression.state.slides, [slideRef]);
|
|
142
142
|
}
|
|
143
143
|
return slice(0, 5, progression.state.slides);
|
|
144
144
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
concat,
|
|
3
|
+
constant,
|
|
3
4
|
divide,
|
|
4
5
|
get,
|
|
5
6
|
getOr,
|
|
@@ -7,12 +8,15 @@ import {
|
|
|
7
8
|
includes,
|
|
8
9
|
indexOf,
|
|
9
10
|
isEmpty,
|
|
11
|
+
isNil,
|
|
10
12
|
map,
|
|
11
13
|
multiply,
|
|
12
14
|
pipe,
|
|
13
15
|
rangeStep,
|
|
14
16
|
round,
|
|
17
|
+
set,
|
|
15
18
|
size,
|
|
19
|
+
times,
|
|
16
20
|
toInteger,
|
|
17
21
|
toString as _toString,
|
|
18
22
|
__
|
|
@@ -53,7 +57,7 @@ const qcmProps =
|
|
|
53
57
|
title: label,
|
|
54
58
|
selected: includes(label, answers),
|
|
55
59
|
onClick: (): void => {
|
|
56
|
-
dispatch(editAnswer(label));
|
|
60
|
+
dispatch(editAnswer([label]));
|
|
57
61
|
},
|
|
58
62
|
ariaLabel: choice.label
|
|
59
63
|
};
|
|
@@ -74,7 +78,7 @@ const qcmDragProps =
|
|
|
74
78
|
selected: includes(label, answers),
|
|
75
79
|
order: indexInAnswer,
|
|
76
80
|
onClick: (): void => {
|
|
77
|
-
dispatch(editAnswer(label));
|
|
81
|
+
dispatch(editAnswer([label]));
|
|
78
82
|
}
|
|
79
83
|
};
|
|
80
84
|
}, question.content.choices)
|
|
@@ -93,30 +97,49 @@ const qcmGraphicProps =
|
|
|
93
97
|
image: get('media.src.0.url', choice),
|
|
94
98
|
selected: includes(label, answers),
|
|
95
99
|
onClick: (): void => {
|
|
96
|
-
dispatch(editAnswer(label));
|
|
100
|
+
dispatch(editAnswer([label]));
|
|
97
101
|
}
|
|
98
102
|
};
|
|
99
103
|
}, question.content.choices)
|
|
100
104
|
};
|
|
101
105
|
};
|
|
102
106
|
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
const updateTemplateAnswer = (
|
|
108
|
+
text: string,
|
|
109
|
+
_answers: string[],
|
|
110
|
+
index: number,
|
|
111
|
+
max: number
|
|
112
|
+
): string[] => {
|
|
113
|
+
const answers = isEmpty(_answers) ? times(constant(undefined), max) : _answers;
|
|
114
|
+
return map(a => (isNil(a) ? '' : a), set(index, text, answers)) as string[];
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const templateTextProps = (
|
|
118
|
+
dispatch: Dispatch,
|
|
119
|
+
answers: string[],
|
|
120
|
+
choice: ChoiceFromAPI,
|
|
121
|
+
index: number,
|
|
122
|
+
maxLength: number
|
|
123
|
+
): TextTemplate => {
|
|
106
124
|
return {
|
|
107
125
|
type: 'text',
|
|
108
|
-
name: getOr('', 'name', choice),
|
|
126
|
+
name: getOr('', 'name', choice),
|
|
109
127
|
placeholder: 'Type here',
|
|
110
128
|
value: get(index, answers),
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
129
|
+
onChange: (text: string): void => {
|
|
130
|
+
const newAnswers = updateTemplateAnswer(text, answers, index, maxLength);
|
|
131
|
+
dispatch(editAnswer(newAnswers));
|
|
132
|
+
}
|
|
114
133
|
};
|
|
115
134
|
};
|
|
116
135
|
|
|
117
|
-
const templateSelectProps = (
|
|
118
|
-
|
|
119
|
-
|
|
136
|
+
const templateSelectProps = (
|
|
137
|
+
dispatch: Dispatch,
|
|
138
|
+
answers: string[],
|
|
139
|
+
choice: ChoiceFromAPI,
|
|
140
|
+
index: number,
|
|
141
|
+
maxLength: number
|
|
142
|
+
): SelectionTemplate => {
|
|
120
143
|
const answer = get(index, answers);
|
|
121
144
|
const temporaryOption = {
|
|
122
145
|
name: 'Select an answer', // TODO translate
|
|
@@ -137,24 +160,29 @@ const templateSelectProps = (choice: ChoiceFromAPI, index: number): SelectionTem
|
|
|
137
160
|
return {
|
|
138
161
|
type: 'select',
|
|
139
162
|
name: getOr('', 'name', choice),
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
163
|
+
onChange: (text: string): void => {
|
|
164
|
+
const newAnswers = updateTemplateAnswer(text, answers, index, maxLength);
|
|
165
|
+
dispatch(editAnswer(newAnswers));
|
|
166
|
+
},
|
|
143
167
|
options: isEmpty(answer) ? concat([temporaryOption], selectOptions) : selectOptions
|
|
144
168
|
};
|
|
145
169
|
};
|
|
146
170
|
|
|
147
|
-
const templateProps =
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
171
|
+
const templateProps =
|
|
172
|
+
(dispatch: Dispatch) =>
|
|
173
|
+
(answers: string[], question: TemplateQuestion): Template => {
|
|
174
|
+
const choices = question.content.choices;
|
|
175
|
+
const maxLength = size(choices);
|
|
176
|
+
return {
|
|
177
|
+
type: 'template',
|
|
178
|
+
template: get('content.template', question),
|
|
179
|
+
answers: choices.map((choice, index) =>
|
|
180
|
+
choice.type === 'text'
|
|
181
|
+
? templateTextProps(dispatch, answers, choice, index, maxLength)
|
|
182
|
+
: templateSelectProps(dispatch, answers, choice, index, maxLength)
|
|
183
|
+
)
|
|
184
|
+
};
|
|
156
185
|
};
|
|
157
|
-
};
|
|
158
186
|
|
|
159
187
|
const basicProps =
|
|
160
188
|
(dispatch: Dispatch) =>
|
|
@@ -164,7 +192,7 @@ const basicProps =
|
|
|
164
192
|
placeholder: question.content.placeholder || '',
|
|
165
193
|
value: answers[0] || '',
|
|
166
194
|
onChange: (text: string): void => {
|
|
167
|
-
dispatch(editAnswer(text));
|
|
195
|
+
dispatch(editAnswer([text]));
|
|
168
196
|
}
|
|
169
197
|
};
|
|
170
198
|
};
|
|
@@ -196,8 +224,13 @@ const sliderProps =
|
|
|
196
224
|
title: `${currentValue} ${question.content.unitLabel}`,
|
|
197
225
|
value: sliderPosition,
|
|
198
226
|
onChange: (position: number): void => {
|
|
199
|
-
const newValue = pipe(
|
|
200
|
-
|
|
227
|
+
const newValue: string = pipe(
|
|
228
|
+
multiply(maxValue),
|
|
229
|
+
round,
|
|
230
|
+
get(__, values),
|
|
231
|
+
_toString
|
|
232
|
+
)(position);
|
|
233
|
+
dispatch(editAnswer([newValue]));
|
|
201
234
|
}
|
|
202
235
|
};
|
|
203
236
|
};
|
|
@@ -226,7 +259,7 @@ const getAnswerUIModel = (
|
|
|
226
259
|
return basicProps(dispatch)(answers, question as BasicQuestion);
|
|
227
260
|
|
|
228
261
|
case 'template':
|
|
229
|
-
return templateProps(question as TemplateQuestion);
|
|
262
|
+
return templateProps(dispatch)(answers, question as TemplateQuestion);
|
|
230
263
|
|
|
231
264
|
case 'slider':
|
|
232
265
|
return sliderProps(dispatch)(answers, question as SliderQuestion);
|
|
@@ -2,11 +2,11 @@ import noop from 'lodash/fp/noop';
|
|
|
2
2
|
import {UISlide} from '../..';
|
|
3
3
|
import {SlideFromAPI} from '../../../../types/common';
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const templateSlide: SlideFromAPI = {
|
|
6
6
|
question: {
|
|
7
7
|
content: {
|
|
8
8
|
template:
|
|
9
|
-
'La vue {{sel80495}} présente la liste des
|
|
9
|
+
'La vue {{sel80495}} présente la liste des {{inp58402}} ayant le plus grand nombre d’{{sel80496}} cumulées.',
|
|
10
10
|
choices: [
|
|
11
11
|
{
|
|
12
12
|
items: [
|
|
@@ -34,6 +34,45 @@ export const selectTemplateSlide: SlideFromAPI = {
|
|
|
34
34
|
_id: '5b57464e3b594d002e8829f3',
|
|
35
35
|
name: 'sel80495',
|
|
36
36
|
type: 'select'
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
media: {
|
|
40
|
+
src: [],
|
|
41
|
+
posters: [],
|
|
42
|
+
subtitles: []
|
|
43
|
+
},
|
|
44
|
+
items: [],
|
|
45
|
+
_id: '62433c2c58920f02c4950de0',
|
|
46
|
+
type: 'text',
|
|
47
|
+
name: 'inp58402',
|
|
48
|
+
id: '62433c2c58920f02c4950de0'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
items: [
|
|
52
|
+
{
|
|
53
|
+
_id: '5b57464e3b594d002e8829f7',
|
|
54
|
+
value: 'sli_N13-hG3kX.choice_NJgC3aznJm',
|
|
55
|
+
text: 'étoiles'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
_id: '5b57464e3b594d002e8829f6',
|
|
59
|
+
value: 'sli_N13-hG3kX.choice_EJZ02aMny7',
|
|
60
|
+
text: 'idées'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
_id: '5b57464e3b594d002e8829f5',
|
|
64
|
+
value: 'sli_N13-hG3kX.choice_4keCaf21Q',
|
|
65
|
+
text: 'envies'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
_id: '5b57464e3b594d002e8829f4',
|
|
69
|
+
value: 'sli_N13-hG3kX.choice_NkbJAMn17',
|
|
70
|
+
text: 'images'
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
_id: '5b57464e3b594d002e8829f3',
|
|
74
|
+
name: 'sel80496',
|
|
75
|
+
type: 'select'
|
|
37
76
|
}
|
|
38
77
|
]
|
|
39
78
|
},
|
|
@@ -52,14 +91,14 @@ export const selectTemplateSlide: SlideFromAPI = {
|
|
|
52
91
|
}
|
|
53
92
|
};
|
|
54
93
|
|
|
55
|
-
export const
|
|
94
|
+
export const templateUISlide: Partial<UISlide> = {
|
|
56
95
|
questionText: 'Complétez la phrase ci-dessous.',
|
|
57
96
|
answerUI: {
|
|
58
97
|
help: 'Saisissez votre réponse ou sélectionnez la bonne réponse dans le(s) menu(s) déroulant(s).',
|
|
59
98
|
model: {
|
|
60
99
|
type: 'template',
|
|
61
100
|
template:
|
|
62
|
-
'La vue {{sel80495}} présente la liste des
|
|
101
|
+
'La vue {{sel80495}} présente la liste des {{inp58402}} ayant le plus grand nombre d’{{sel80496}} cumulées.',
|
|
63
102
|
answers: [
|
|
64
103
|
{
|
|
65
104
|
type: 'select',
|
|
@@ -92,6 +131,45 @@ export const selectTemplateUISlide: Partial<UISlide> = {
|
|
|
92
131
|
selected: false
|
|
93
132
|
}
|
|
94
133
|
]
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
type: 'text',
|
|
137
|
+
name: 'inp58402',
|
|
138
|
+
placeholder: 'Type here',
|
|
139
|
+
value: undefined,
|
|
140
|
+
onChange: noop
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
type: 'select',
|
|
144
|
+
name: 'sel80496',
|
|
145
|
+
onChange: noop,
|
|
146
|
+
options: [
|
|
147
|
+
{name: 'Select an answer', value: '', validOption: false, selected: true},
|
|
148
|
+
{
|
|
149
|
+
name: 'étoiles',
|
|
150
|
+
value: 'étoiles',
|
|
151
|
+
validOption: true,
|
|
152
|
+
selected: false
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: 'idées',
|
|
156
|
+
value: 'idées',
|
|
157
|
+
validOption: true,
|
|
158
|
+
selected: false
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: 'envies',
|
|
162
|
+
value: 'envies',
|
|
163
|
+
validOption: true,
|
|
164
|
+
selected: false
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: 'images',
|
|
168
|
+
value: 'images',
|
|
169
|
+
validOption: true,
|
|
170
|
+
selected: false
|
|
171
|
+
}
|
|
172
|
+
]
|
|
95
173
|
}
|
|
96
174
|
]
|
|
97
175
|
}
|