@coorpacademy/app-review 0.1.15 → 0.1.17

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.
Files changed (289) hide show
  1. package/es/actions/api/fetch-skills.d.ts +5 -7
  2. package/es/actions/api/fetch-skills.js +12 -4
  3. package/es/actions/api/fetch-slide.d.ts +14 -7
  4. package/es/actions/api/fetch-slide.js +23 -18
  5. package/es/actions/api/post-answer.d.ts +10 -0
  6. package/es/actions/api/post-answer.js +25 -0
  7. package/es/actions/api/post-progression.d.ts +5 -7
  8. package/es/actions/api/post-progression.js +16 -8
  9. package/es/actions/api/test/fetch-skills.test.js +57 -0
  10. package/es/actions/api/test/fetch-slide.test.js +64 -0
  11. package/es/actions/api/test/post-answer.test.d.ts +1 -0
  12. package/es/actions/api/test/post-answer.test.js +82 -0
  13. package/es/actions/api/test/post-progression.test.d.ts +1 -0
  14. package/es/actions/api/test/post-progression.test.js +105 -0
  15. package/es/actions/data/test/token.test.d.ts +1 -0
  16. package/es/actions/data/test/token.test.js +25 -0
  17. package/es/actions/index.d.ts +1 -8
  18. package/es/actions/test/create-test-store.d.ts +5 -0
  19. package/es/actions/test/create-test-store.js +16 -0
  20. package/es/actions/ui/answers.d.ts +21 -0
  21. package/es/actions/ui/answers.js +43 -0
  22. package/es/actions/ui/slides.d.ts +0 -5
  23. package/es/actions/ui/slides.js +0 -4
  24. package/es/actions/ui/test/answers.test.d.ts +1 -0
  25. package/es/actions/ui/test/answers.test.js +90 -0
  26. package/es/actions/ui/test/slides.test.d.ts +1 -0
  27. package/es/actions/ui/test/slides.test.js +26 -0
  28. package/es/common/index.d.ts +0 -3
  29. package/es/common/index.js +0 -4
  30. package/es/index.js +11 -19
  31. package/es/reducers/data/index.d.ts +2 -2
  32. package/es/reducers/data/progression.d.ts +2 -3
  33. package/es/reducers/data/progression.js +0 -5
  34. package/es/reducers/data/slides.d.ts +3 -4
  35. package/es/reducers/data/slides.js +5 -1
  36. package/es/reducers/data/test/progression.test.d.ts +1 -0
  37. package/es/reducers/data/test/progression.test.js +38 -0
  38. package/es/reducers/data/test/skills.test.d.ts +1 -0
  39. package/es/reducers/data/test/skills.test.js +12 -0
  40. package/es/reducers/data/test/slides.test.d.ts +1 -0
  41. package/es/reducers/data/test/slides.test.js +20 -0
  42. package/es/reducers/data/test/token.test.d.ts +1 -0
  43. package/es/reducers/data/test/token.test.js +11 -0
  44. package/es/reducers/index.d.ts +3 -2
  45. package/es/reducers/ui/answers.d.ts +4 -0
  46. package/es/reducers/ui/answers.js +9 -0
  47. package/es/reducers/ui/index.d.ts +7 -4
  48. package/es/reducers/ui/index.js +4 -2
  49. package/es/reducers/ui/slide.d.ts +8 -0
  50. package/es/reducers/ui/slide.js +26 -0
  51. package/es/reducers/ui/test/answers.test.d.ts +1 -0
  52. package/es/reducers/ui/test/answers.test.js +27 -0
  53. package/es/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
  54. package/es/reducers/ui/test/current-slide-ref.test.js +12 -0
  55. package/es/reducers/ui/test/navigation.test.d.ts +1 -0
  56. package/es/reducers/ui/test/navigation.test.js +15 -0
  57. package/es/reducers/ui/test/slide.test.d.ts +1 -0
  58. package/es/reducers/ui/test/slide.test.js +12 -0
  59. package/es/services/fetch-slide.js +1 -1
  60. package/es/services/index.js +3 -1
  61. package/es/services/post-answer.d.ts +2 -0
  62. package/es/services/post-answer.js +18 -0
  63. package/es/services/test/fetch-slide.test.d.ts +1 -0
  64. package/es/services/test/fetch-slide.test.js +22 -0
  65. package/es/services/test/post-answer.test.d.ts +1 -0
  66. package/es/services/test/post-answer.test.js +57 -0
  67. package/es/services/test/post-progression.test.js +9 -1
  68. package/es/test/util/services.mock.d.ts +2 -1
  69. package/es/test/util/services.mock.js +88 -44
  70. package/es/types/common.d.ts +22 -33
  71. package/es/views/skills/index.d.ts +1 -1
  72. package/es/views/skills/index.js +0 -3
  73. package/es/views/skills/test/skills.test.d.ts +1 -0
  74. package/es/views/skills/test/skills.test.js +94 -0
  75. package/es/views/slides/index.d.ts +89 -2
  76. package/es/views/slides/index.js +80 -10
  77. package/es/views/slides/map-api-slide-to-ui.d.ts +8 -0
  78. package/es/views/slides/map-api-slide-to-ui.js +165 -0
  79. package/es/{helpers → views/slides}/test/fixtures/free-text.d.ts +2 -1
  80. package/es/views/slides/test/fixtures/free-text.js +38 -0
  81. package/es/{helpers → views/slides}/test/fixtures/qcm-drag.d.ts +2 -1
  82. package/es/views/slides/test/fixtures/qcm-drag.js +108 -0
  83. package/es/{helpers → views/slides}/test/fixtures/qcm-graphic.d.ts +2 -1
  84. package/es/views/slides/test/fixtures/qcm-graphic.js +88 -0
  85. package/es/{helpers → views/slides}/test/fixtures/qcm.d.ts +2 -1
  86. package/es/{helpers → views/slides}/test/fixtures/qcm.js +5 -1
  87. package/es/{helpers → views/slides}/test/fixtures/select-template.d.ts +2 -1
  88. package/es/views/slides/test/fixtures/select-template.js +92 -0
  89. package/es/{helpers → views/slides}/test/fixtures/slider.d.ts +2 -1
  90. package/es/views/slides/test/fixtures/slider.js +36 -0
  91. package/es/{helpers → views/slides}/test/fixtures/text-template.d.ts +2 -1
  92. package/es/{helpers → views/slides}/test/fixtures/text-template.js +5 -1
  93. package/es/views/slides/test/index.test.d.ts +1 -0
  94. package/es/views/slides/test/index.test.js +234 -0
  95. package/es/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
  96. package/es/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
  97. package/lib/actions/api/fetch-skills.d.ts +5 -7
  98. package/lib/actions/api/fetch-skills.js +58 -7
  99. package/lib/actions/api/fetch-slide.d.ts +14 -7
  100. package/lib/actions/api/fetch-slide.js +72 -20
  101. package/lib/actions/api/post-answer.d.ts +10 -0
  102. package/lib/actions/api/post-answer.js +75 -0
  103. package/lib/actions/api/post-progression.d.ts +5 -7
  104. package/lib/actions/api/post-progression.js +67 -10
  105. package/lib/actions/api/test/fetch-skills.test.d.ts +1 -0
  106. package/lib/actions/api/test/fetch-skills.test.js +116 -0
  107. package/lib/actions/api/test/fetch-slide.test.d.ts +1 -0
  108. package/lib/actions/api/test/fetch-slide.test.js +123 -0
  109. package/lib/actions/api/test/post-answer.test.d.ts +1 -0
  110. package/lib/actions/api/test/post-answer.test.js +145 -0
  111. package/lib/actions/api/test/post-progression.test.d.ts +1 -0
  112. package/lib/actions/api/test/post-progression.test.js +163 -0
  113. package/lib/actions/data/test/token.test.d.ts +1 -0
  114. package/lib/actions/data/test/token.test.js +70 -0
  115. package/lib/actions/index.d.ts +1 -8
  116. package/lib/actions/test/create-test-store.d.ts +5 -0
  117. package/lib/actions/test/create-test-store.js +18 -0
  118. package/lib/actions/ui/answers.d.ts +21 -0
  119. package/lib/actions/ui/answers.js +54 -0
  120. package/lib/actions/ui/slides.d.ts +0 -5
  121. package/lib/actions/ui/slides.js +0 -4
  122. package/lib/actions/ui/test/answers.test.d.ts +1 -0
  123. package/lib/actions/ui/test/answers.test.js +171 -0
  124. package/lib/actions/ui/test/slides.test.d.ts +1 -0
  125. package/lib/actions/ui/test/slides.test.js +71 -0
  126. package/lib/common/index.d.ts +0 -3
  127. package/lib/common/index.js +0 -4
  128. package/lib/index.js +22 -21
  129. package/lib/reducers/data/index.d.ts +2 -2
  130. package/lib/reducers/data/progression.d.ts +2 -3
  131. package/lib/reducers/data/progression.js +0 -5
  132. package/lib/reducers/data/slides.d.ts +3 -4
  133. package/lib/reducers/data/slides.js +5 -1
  134. package/lib/reducers/data/test/progression.test.d.ts +1 -0
  135. package/lib/reducers/data/test/progression.test.js +38 -0
  136. package/lib/reducers/data/test/skills.test.d.ts +1 -0
  137. package/lib/reducers/data/test/skills.test.js +12 -0
  138. package/lib/reducers/data/test/slides.test.d.ts +1 -0
  139. package/lib/reducers/data/test/slides.test.js +20 -0
  140. package/lib/reducers/data/test/token.test.d.ts +1 -0
  141. package/lib/reducers/data/test/token.test.js +11 -0
  142. package/lib/reducers/index.d.ts +3 -2
  143. package/lib/reducers/ui/answers.d.ts +4 -0
  144. package/lib/reducers/ui/answers.js +10 -0
  145. package/lib/reducers/ui/index.d.ts +7 -4
  146. package/lib/reducers/ui/index.js +4 -2
  147. package/lib/reducers/ui/slide.d.ts +8 -0
  148. package/lib/reducers/ui/slide.js +27 -0
  149. package/lib/reducers/ui/test/answers.test.d.ts +1 -0
  150. package/lib/reducers/ui/test/answers.test.js +27 -0
  151. package/lib/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
  152. package/lib/reducers/ui/test/current-slide-ref.test.js +12 -0
  153. package/lib/reducers/ui/test/navigation.test.d.ts +1 -0
  154. package/lib/reducers/ui/test/navigation.test.js +15 -0
  155. package/lib/reducers/ui/test/slide.test.d.ts +1 -0
  156. package/lib/reducers/ui/test/slide.test.js +12 -0
  157. package/lib/services/fetch-slide.js +1 -1
  158. package/lib/services/index.js +3 -1
  159. package/lib/services/post-answer.d.ts +2 -0
  160. package/lib/services/post-answer.js +62 -0
  161. package/lib/services/test/fetch-slide.test.d.ts +1 -0
  162. package/lib/services/test/fetch-slide.test.js +76 -0
  163. package/lib/services/test/post-answer.test.d.ts +1 -0
  164. package/lib/services/test/post-answer.test.js +111 -0
  165. package/lib/services/test/post-progression.test.js +9 -1
  166. package/lib/test/util/services.mock.d.ts +2 -1
  167. package/lib/test/util/services.mock.js +88 -44
  168. package/lib/types/common.d.ts +22 -33
  169. package/lib/views/skills/index.d.ts +1 -1
  170. package/lib/views/skills/index.js +0 -3
  171. package/lib/views/skills/test/skills.test.d.ts +1 -0
  172. package/lib/views/skills/test/skills.test.js +94 -0
  173. package/lib/views/slides/index.d.ts +89 -2
  174. package/lib/views/slides/index.js +80 -10
  175. package/lib/views/slides/map-api-slide-to-ui.d.ts +8 -0
  176. package/lib/views/slides/map-api-slide-to-ui.js +179 -0
  177. package/lib/{helpers → views/slides}/test/fixtures/free-text.d.ts +2 -1
  178. package/lib/views/slides/test/fixtures/free-text.js +38 -0
  179. package/lib/{helpers → views/slides}/test/fixtures/qcm-drag.d.ts +2 -1
  180. package/lib/views/slides/test/fixtures/qcm-drag.js +108 -0
  181. package/lib/{helpers → views/slides}/test/fixtures/qcm-graphic.d.ts +2 -1
  182. package/lib/views/slides/test/fixtures/qcm-graphic.js +88 -0
  183. package/lib/{helpers → views/slides}/test/fixtures/qcm.d.ts +2 -1
  184. package/lib/{helpers → views/slides}/test/fixtures/qcm.js +5 -1
  185. package/lib/{helpers → views/slides}/test/fixtures/select-template.d.ts +2 -1
  186. package/lib/views/slides/test/fixtures/select-template.js +92 -0
  187. package/lib/{helpers → views/slides}/test/fixtures/slider.d.ts +2 -1
  188. package/lib/views/slides/test/fixtures/slider.js +36 -0
  189. package/lib/{helpers → views/slides}/test/fixtures/text-template.d.ts +2 -1
  190. package/lib/{helpers → views/slides}/test/fixtures/text-template.js +5 -1
  191. package/lib/views/slides/test/index.test.d.ts +1 -0
  192. package/lib/views/slides/test/index.test.js +234 -0
  193. package/lib/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
  194. package/lib/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
  195. package/package.json +6 -5
  196. package/src/actions/api/fetch-skills.ts +19 -12
  197. package/src/actions/api/fetch-slide.ts +35 -29
  198. package/src/actions/api/post-answer.ts +39 -0
  199. package/src/actions/api/post-progression.ts +22 -22
  200. package/src/actions/api/test/fetch-skills.test.ts +73 -0
  201. package/src/actions/api/test/fetch-slide.test.ts +80 -0
  202. package/src/actions/api/test/post-answer.test.ts +101 -0
  203. package/src/actions/api/test/post-progression.test.ts +122 -0
  204. package/src/actions/data/test/token.test.ts +29 -0
  205. package/src/actions/index.ts +1 -17
  206. package/src/actions/test/create-test-store.ts +25 -0
  207. package/src/actions/ui/answers.ts +63 -0
  208. package/src/actions/ui/slides.ts +1 -8
  209. package/src/actions/ui/test/answers.test.ts +103 -0
  210. package/src/actions/ui/test/slides.test.ts +30 -0
  211. package/src/common/index.ts +0 -7
  212. package/src/index.tsx +15 -32
  213. package/src/reducers/data/index.ts +1 -1
  214. package/src/reducers/data/progression.ts +2 -7
  215. package/src/reducers/data/slides.ts +12 -4
  216. package/src/reducers/data/test/progression.test.ts +42 -0
  217. package/src/reducers/data/test/skills.test.ts +14 -0
  218. package/src/reducers/data/test/slides.test.ts +26 -0
  219. package/src/reducers/data/test/token.test.ts +13 -0
  220. package/src/reducers/ui/answers.ts +15 -0
  221. package/src/reducers/ui/index.ts +6 -3
  222. package/src/reducers/ui/slide.ts +43 -0
  223. package/src/reducers/ui/test/answers.test.ts +33 -0
  224. package/src/reducers/ui/test/current-slide-ref.test.ts +14 -0
  225. package/src/reducers/ui/test/navigation.test.ts +19 -0
  226. package/src/reducers/ui/test/slide.test.ts +15 -0
  227. package/src/services/fetch-slide.ts +1 -1
  228. package/src/services/index.ts +3 -1
  229. package/src/services/post-answer.ts +27 -0
  230. package/src/services/test/fetch-slide.test.ts +30 -0
  231. package/src/services/test/post-answer.test.ts +68 -0
  232. package/src/services/test/post-progression.test.ts +9 -1
  233. package/src/test/util/services.mock.ts +93 -45
  234. package/src/types/common.ts +34 -44
  235. package/src/views/skills/index.ts +1 -5
  236. package/src/views/skills/test/skills.test.ts +101 -0
  237. package/src/views/slides/index.ts +186 -12
  238. package/src/views/slides/map-api-slide-to-ui.ts +251 -0
  239. package/src/views/slides/test/fixtures/free-text.ts +44 -0
  240. package/src/views/slides/test/fixtures/qcm-drag.ts +112 -0
  241. package/src/views/slides/test/fixtures/qcm-graphic.ts +95 -0
  242. package/src/{helpers → views/slides}/test/fixtures/qcm.ts +7 -2
  243. package/src/views/slides/test/fixtures/select-template.ts +99 -0
  244. package/src/views/slides/test/fixtures/slider.ts +42 -0
  245. package/src/{helpers → views/slides}/test/fixtures/text-template.ts +7 -2
  246. package/src/views/slides/test/index.test.ts +240 -0
  247. package/src/{helpers → views/slides}/test/map-api-slide-to-ui.test.ts +22 -10
  248. package/es/fixtures/qcm-slide.d.ts +0 -2
  249. package/es/fixtures/qcm-slide.js +0 -33
  250. package/es/fixtures/temp-fixture.d.ts +0 -3
  251. package/es/fixtures/temp-fixture.js +0 -84
  252. package/es/helpers/map-api-slide-to-ui.d.ts +0 -11
  253. package/es/helpers/map-api-slide-to-ui.js +0 -193
  254. package/es/helpers/test/fixtures/free-text.js +0 -30
  255. package/es/helpers/test/fixtures/qcm-drag.js +0 -112
  256. package/es/helpers/test/fixtures/qcm-graphic.js +0 -76
  257. package/es/helpers/test/fixtures/select-template.js +0 -94
  258. package/es/helpers/test/fixtures/slider.js +0 -33
  259. package/es/reducers/ui/slides.d.ts +0 -9
  260. package/es/reducers/ui/slides.js +0 -42
  261. package/es/types/views/slides.d.ts +0 -74
  262. package/es/types/views/slides.js +0 -6
  263. package/lib/fixtures/qcm-slide.d.ts +0 -2
  264. package/lib/fixtures/qcm-slide.js +0 -33
  265. package/lib/fixtures/temp-fixture.d.ts +0 -3
  266. package/lib/fixtures/temp-fixture.js +0 -84
  267. package/lib/helpers/map-api-slide-to-ui.d.ts +0 -11
  268. package/lib/helpers/map-api-slide-to-ui.js +0 -201
  269. package/lib/helpers/test/fixtures/free-text.js +0 -30
  270. package/lib/helpers/test/fixtures/qcm-drag.js +0 -112
  271. package/lib/helpers/test/fixtures/qcm-graphic.js +0 -76
  272. package/lib/helpers/test/fixtures/select-template.js +0 -94
  273. package/lib/helpers/test/fixtures/slider.js +0 -33
  274. package/lib/reducers/ui/slides.d.ts +0 -9
  275. package/lib/reducers/ui/slides.js +0 -43
  276. package/lib/types/views/slides.d.ts +0 -74
  277. package/lib/types/views/slides.js +0 -6
  278. package/src/fixtures/qcm-slide.ts +0 -35
  279. package/src/fixtures/temp-fixture.ts +0 -94
  280. package/src/helpers/map-api-slide-to-ui.ts +0 -279
  281. package/src/helpers/test/fixtures/free-text.ts +0 -33
  282. package/src/helpers/test/fixtures/qcm-drag.ts +0 -115
  283. package/src/helpers/test/fixtures/qcm-graphic.ts +0 -79
  284. package/src/helpers/test/fixtures/select-template.ts +0 -97
  285. package/src/helpers/test/fixtures/slider.ts +0 -36
  286. package/src/reducers/ui/slides.ts +0 -58
  287. package/src/types/views/slides.ts +0 -90
  288. /package/es/{helpers/test/map-api-slide-to-ui.test.d.ts → actions/api/test/fetch-skills.test.d.ts} +0 -0
  289. /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,251 @@
1
+ import {
2
+ concat,
3
+ divide,
4
+ get,
5
+ getOr,
6
+ head,
7
+ includes,
8
+ indexOf,
9
+ isEmpty,
10
+ map,
11
+ multiply,
12
+ pipe,
13
+ rangeStep,
14
+ round,
15
+ size,
16
+ toInteger,
17
+ toString as _toString,
18
+ __
19
+ } from 'lodash/fp';
20
+ import {Dispatch} from 'redux';
21
+ import {
22
+ AnswerUI,
23
+ FreeText,
24
+ Qcm,
25
+ QcmDrag,
26
+ QcmGraphic,
27
+ QuestionRange,
28
+ SelectionTemplate,
29
+ Template,
30
+ TextTemplate
31
+ } from '../../types/slides';
32
+ import {
33
+ BasicQuestion,
34
+ ChoiceFromAPI,
35
+ QcmDragQuestion,
36
+ QcmGraphicQuestion,
37
+ QcmQuestion,
38
+ Question,
39
+ SlideFromAPI,
40
+ SliderQuestion,
41
+ TemplateQuestion
42
+ } from '../../types/common';
43
+ import {editAnswer} from '../../actions/ui/answers';
44
+
45
+ const qcmProps =
46
+ (dispatch: Dispatch) =>
47
+ (answers: string[], question: QcmQuestion): Qcm => {
48
+ return {
49
+ type: 'qcm',
50
+ answers: map(choice => {
51
+ const label = choice.label || '';
52
+ return {
53
+ title: label,
54
+ selected: includes(label, answers),
55
+ onClick: (): void => {
56
+ dispatch(editAnswer(label));
57
+ },
58
+ ariaLabel: choice.label
59
+ };
60
+ }, question.content.choices)
61
+ };
62
+ };
63
+
64
+ const qcmDragProps =
65
+ (dispatch: Dispatch) =>
66
+ (answers: string[], question: QcmDragQuestion): QcmDrag => {
67
+ return {
68
+ type: 'qcmDrag',
69
+ answers: map(choice => {
70
+ const label = choice.label || '';
71
+ const indexInAnswer = indexOf(label, answers);
72
+ return {
73
+ title: label,
74
+ selected: includes(label, answers),
75
+ order: indexInAnswer,
76
+ onClick: (): void => {
77
+ dispatch(editAnswer(label));
78
+ }
79
+ };
80
+ }, question.content.choices)
81
+ };
82
+ };
83
+
84
+ const qcmGraphicProps =
85
+ (dispatch: Dispatch) =>
86
+ (answers: string[], question: QcmGraphicQuestion): QcmGraphic => {
87
+ return {
88
+ type: 'qcmGraphic',
89
+ answers: map(choice => {
90
+ const label = choice.label || '';
91
+ return {
92
+ title: label,
93
+ image: get('media.src.0.url', choice),
94
+ selected: includes(label, answers),
95
+ onClick: (): void => {
96
+ dispatch(editAnswer(label));
97
+ }
98
+ };
99
+ }, question.content.choices)
100
+ };
101
+ };
102
+
103
+ const templateTextProps = (choice: ChoiceFromAPI, index: number): TextTemplate => {
104
+ // TODO: EDIT_CHOICES -> getAnswerValues
105
+ const answers: string[] = [];
106
+ return {
107
+ type: 'text',
108
+ name: getOr('', 'name', choice), // TODO prendre valeur depuis les données de l'api
109
+ placeholder: 'Type here',
110
+ value: get(index, answers),
111
+ // TODO: EDIT_CHOICES
112
+ // eslint-disable-next-line no-console
113
+ onChange: () => console.log('TODO: on choice change')
114
+ };
115
+ };
116
+
117
+ const templateSelectProps = (choice: ChoiceFromAPI, index: number): SelectionTemplate => {
118
+ // TODO: EDIT_CHOICES -> getAnswerValues
119
+ const answers: string[] = [];
120
+ const answer = get(index, answers);
121
+ const temporaryOption = {
122
+ name: 'Select an answer', // TODO translate
123
+ value: '',
124
+ validOption: false,
125
+ selected: true
126
+ };
127
+ const selectOptions = choice.items.map(item => {
128
+ const itemText = getOr('', 'text', item);
129
+ return {
130
+ name: itemText,
131
+ value: itemText,
132
+ validOption: true,
133
+ selected: itemText === answer
134
+ };
135
+ });
136
+
137
+ return {
138
+ type: 'select',
139
+ name: getOr('', 'name', choice),
140
+ // TODO: EDIT_CHOICES
141
+ // eslint-disable-next-line no-console
142
+ onChange: () => console.log('TODO: on choice change'),
143
+ options: isEmpty(answer) ? concat([temporaryOption], selectOptions) : selectOptions
144
+ };
145
+ };
146
+
147
+ const templateProps = (question: TemplateQuestion): Template => {
148
+ // TODO: EDIT_CHOICES -> getChoices
149
+ const choices = question.content.choices;
150
+ return {
151
+ type: 'template',
152
+ template: get('content.template', question),
153
+ answers: choices.map((choice, index) =>
154
+ choice.type === 'text' ? templateTextProps(choice, index) : templateSelectProps(choice, index)
155
+ )
156
+ };
157
+ };
158
+
159
+ const basicProps =
160
+ (dispatch: Dispatch) =>
161
+ (answers: string[], question: BasicQuestion): FreeText => {
162
+ return {
163
+ type: 'freeText',
164
+ placeholder: question.content.placeholder || '',
165
+ value: answers[0] || '',
166
+ onChange: (text: string): void => {
167
+ dispatch(editAnswer(text));
168
+ }
169
+ };
170
+ };
171
+
172
+ const sliderProps =
173
+ (dispatch: Dispatch) =>
174
+ (answers: string[], question: SliderQuestion): QuestionRange => {
175
+ const values: number[] = rangeStep(
176
+ getOr(1, 'content.step', question),
177
+ get('content.min', question),
178
+ get('content.max', question) + 1
179
+ // Lodash doesn't infer the type very well here
180
+ ) as unknown as number[];
181
+
182
+ const stateValue = head(answers) || question.content.min;
183
+ const currentValue = toInteger(stateValue);
184
+
185
+ const indexValue = indexOf(currentValue, values);
186
+ const maxValue = size(values) - 1;
187
+ const sliderPosition = divide(indexValue, maxValue);
188
+
189
+ const unitLabel = get('content.unitLabel', question);
190
+
191
+ return {
192
+ type: 'slider',
193
+ placeholder: question.explanation,
194
+ minLabel: `${question.content.min} ${unitLabel}`,
195
+ maxLabel: `${question.content.max} ${unitLabel}`,
196
+ title: `${currentValue} ${question.content.unitLabel}`,
197
+ value: sliderPosition,
198
+ onChange: (position: number): void => {
199
+ const newValue = pipe(multiply(maxValue), round, get(__, values), _toString)(position);
200
+ dispatch(editAnswer(newValue));
201
+ }
202
+ };
203
+ };
204
+
205
+ export const getQuestionType = (question: Question): Question['type'] => question.type;
206
+
207
+ const getHelp = (slide: SlideFromAPI): string => get('question.explanation', slide);
208
+
209
+ const getAnswerUIModel = (
210
+ question: Question,
211
+ answers: string[],
212
+ dispatch: Dispatch
213
+ ): AnswerUI['model'] => {
214
+ const type = getQuestionType(question);
215
+ switch (type) {
216
+ case 'qcm':
217
+ return qcmProps(dispatch)(answers, question as QcmQuestion);
218
+
219
+ case 'qcmGraphic':
220
+ return qcmGraphicProps(dispatch)(answers, question as QcmGraphicQuestion);
221
+
222
+ case 'qcmDrag':
223
+ return qcmDragProps(dispatch)(answers, question as QcmDragQuestion);
224
+
225
+ case 'basic':
226
+ return basicProps(dispatch)(answers, question as BasicQuestion);
227
+
228
+ case 'template':
229
+ return templateProps(question as TemplateQuestion);
230
+
231
+ case 'slider':
232
+ return sliderProps(dispatch)(answers, question as SliderQuestion);
233
+
234
+ default:
235
+ throw new Error(`${type} is not an handled question.type`);
236
+ }
237
+ };
238
+
239
+ export const mapApiSlideToUi =
240
+ (dispatch: Dispatch) =>
241
+ (slide: SlideFromAPI, answers: string[]): {questionText: string; answerUI: AnswerUI} => {
242
+ if (!slide) {
243
+ throw new Error('no slide was found');
244
+ }
245
+ const questionText = getOr('', 'question.header', slide);
246
+
247
+ return {
248
+ questionText,
249
+ answerUI: {model: getAnswerUIModel(slide.question, answers, dispatch), help: getHelp(slide)}
250
+ };
251
+ };
@@ -0,0 +1,44 @@
1
+ import noop from 'lodash/fp/noop';
2
+ import {UISlide} from '../..';
3
+ import {SlideFromAPI} from '../../../../types/common';
4
+
5
+ export const freeTextSlide: SlideFromAPI = {
6
+ question: {
7
+ content: {
8
+ media: {
9
+ src: [],
10
+ posters: [],
11
+ subtitles: []
12
+ },
13
+ label: '',
14
+ placeholder: 'Type here',
15
+ id: 'sli_VJYjJnJhg.choice_1'
16
+ },
17
+ type: 'basic',
18
+ header:
19
+ 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?',
20
+ explanation: 'Type your answer.'
21
+ },
22
+ klf: 'To negotiate your salary when being hired, you have to establish a benchmark beforehand. In other words, you should assess the salary to which you aspire by enquiring about the remuneration paid in the same industry, the same region and the same position.',
23
+ tips: 'According to Insee, Paris salaries are 20-25% higher compared with those of the provinces in 2015.',
24
+ universalRef: 'sli_VJYjJnJhg',
25
+ id: 'sli_VJYjJnJhg',
26
+ parentContentTitle: {
27
+ title: 'Developing the review app',
28
+ type: 'course'
29
+ }
30
+ };
31
+
32
+ export const freeTextUISlide: Partial<UISlide> = {
33
+ answerUI: {
34
+ help: 'Type your answer.',
35
+ model: {
36
+ type: 'freeText',
37
+ placeholder: 'Type here',
38
+ value: '',
39
+ onChange: noop
40
+ }
41
+ },
42
+ questionText:
43
+ 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
44
+ };
@@ -0,0 +1,112 @@
1
+ import noop from 'lodash/fp/noop';
2
+ import {UISlide} from '../..';
3
+ import {SlideFromAPI} from '../../../../types/common';
4
+
5
+ export const qcmDragSlide: SlideFromAPI = {
6
+ question: {
7
+ content: {
8
+ media: {
9
+ src: [],
10
+ posters: [],
11
+ subtitles: []
12
+ },
13
+ choices: [
14
+ {
15
+ media: {
16
+ src: [],
17
+ posters: [],
18
+ subtitles: []
19
+ },
20
+ items: [],
21
+ _id: '624f01970a234b0333bc7ce8',
22
+ label: 'La démoralisation',
23
+ value: 'sli_4yGBq-mCg.choice_4kRL5uQCg',
24
+ id: '624f01970a234b0333bc7ce8'
25
+ },
26
+ {
27
+ media: {
28
+ src: [],
29
+ posters: [],
30
+ subtitles: []
31
+ },
32
+ items: [],
33
+ _id: '624f01970a234b0333bc7ce9',
34
+ label: 'La stagnation',
35
+ value: 'sli_4yGBq-mCg.choice_E11v9OXAx',
36
+ id: '624f01970a234b0333bc7ce9'
37
+ },
38
+ {
39
+ media: {
40
+ src: [],
41
+ posters: [],
42
+ subtitles: []
43
+ },
44
+ items: [],
45
+ _id: '624f01970a234b0333bc7cea',
46
+ label: 'La frustration',
47
+ value: 'sli_4yGBq-mCg.choice_N1lP9dmRg',
48
+ id: '624f01970a234b0333bc7cea'
49
+ },
50
+ {
51
+ media: {
52
+ src: [],
53
+ posters: [],
54
+ subtitles: []
55
+ },
56
+ items: [],
57
+ _id: '624f01970a234b0333bc7ceb',
58
+ label: "L'implication",
59
+ value: 'sli_4yGBq-mCg.choice_Eybw5dQCx',
60
+ id: '624f01970a234b0333bc7ceb'
61
+ }
62
+ ]
63
+ },
64
+ type: 'qcmDrag',
65
+ header: "Remettez dans l'ordre les quatre étapes du burn out.",
66
+ explanation: 'Sélectionnez les réponses ci-dessous dans le bon ordre.'
67
+ },
68
+ klf: "Le burn out s'installe en quatre étapes : tout d'abord, l'implication (investissement émotionnel et/ou affectif, sacrifice de sa vie privée) ; en second, la stagnation (premières déceptions, signes de fatigue) ; ensuite, la frustration (efforts non reconnus) ; et enfin, la démoralisation (problèmes de concentration, sentiment d'inutilité, désespoir).",
69
+ tips: "Encadré par la loi, l'entretien professionnel a pour but d'aider le collaborateur à verbaliser ses difficultés et à construire son projet professionnel.",
70
+ universalRef: 'sli_4yGBq-mCg',
71
+ id: 'sli_4yGBq-mCg',
72
+ parentContentTitle: {
73
+ title: 'Using redux',
74
+ type: 'chapter'
75
+ }
76
+ };
77
+
78
+ export const qcmDragUISlide: Partial<UISlide> = {
79
+ questionText: "Remettez dans l'ordre les quatre étapes du burn out.",
80
+ answerUI: {
81
+ help: 'Sélectionnez les réponses ci-dessous dans le bon ordre.',
82
+ model: {
83
+ type: 'qcmDrag',
84
+ answers: [
85
+ {
86
+ title: 'La démoralisation',
87
+ selected: false,
88
+ order: -1,
89
+ onClick: noop
90
+ },
91
+ {
92
+ title: 'La stagnation',
93
+ selected: false,
94
+ order: -1,
95
+ onClick: noop
96
+ },
97
+ {
98
+ title: 'La frustration',
99
+ selected: false,
100
+ order: -1,
101
+ onClick: noop
102
+ },
103
+ {
104
+ title: "L'implication",
105
+ selected: false,
106
+ order: -1,
107
+ onClick: noop
108
+ }
109
+ ]
110
+ }
111
+ }
112
+ };
@@ -0,0 +1,95 @@
1
+ import noop from 'lodash/fp/noop';
2
+ import {UISlide} from '../..';
3
+ import {SlideFromAPI} from '../../../../types/common';
4
+
5
+ export const qcmGraphicSlide: SlideFromAPI = {
6
+ question: {
7
+ content: {
8
+ media: {
9
+ src: [],
10
+ posters: [],
11
+ subtitles: []
12
+ },
13
+ choices: [
14
+ {
15
+ media: {
16
+ src: [
17
+ {
18
+ _id: '624efd915948a7013083e986',
19
+ mimeType: 'image/jpeg',
20
+ url: '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/true-1512554153232.jpg',
21
+ id: '624efd915948a7013083e986'
22
+ }
23
+ ],
24
+ posters: [],
25
+ subtitles: [],
26
+ type: 'img'
27
+ },
28
+ items: [],
29
+ _id: '624efd915948a7013083e985',
30
+ label: 'Vrai',
31
+ value: 'sli_VkSQroQnx.choice_NJesyUo7nx',
32
+ id: '624efd915948a7013083e985'
33
+ },
34
+ {
35
+ media: {
36
+ src: [
37
+ {
38
+ _id: '624efd915948a7013083e988',
39
+ mimeType: 'image/jpeg',
40
+ url: '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/false-1512554160848.jpg',
41
+ id: '624efd915948a7013083e988'
42
+ }
43
+ ],
44
+ posters: [],
45
+ subtitles: [],
46
+ type: 'img'
47
+ },
48
+ items: [],
49
+ _id: '624efd915948a7013083e987',
50
+ label: 'Faux',
51
+ value: 'sli_VkSQroQnx.choice_VkgayLjX3e',
52
+ id: '624efd915948a7013083e987'
53
+ }
54
+ ]
55
+ },
56
+ type: 'qcmGraphic',
57
+ header: 'Pour mener une bonne négociation, il ne faut ressentir aucune émotion. Vrai ou faux ?',
58
+ explanation: 'Sélectionnez la bonne réponse.'
59
+ },
60
+ klf: "Il ne faut pas prendre la négociation comme une affaire personnelle, afin de rester centré sur son sujet. Mais cela ne signifie pas être dépourvu de toute émotion, car celles-ci peuvent être de vrais atouts. À condition de réussir à les exprimer sans accuser l'autre d'en être à l'origine.",
61
+ tips: "Pour gérer ses émotions, il faut d'abord les identifier, notamment en analysant ses ressentis physiques et en trouvant l'élément déclencheur.",
62
+ universalRef: 'sli_VkSQroQnx',
63
+ id: 'sli_VkSQroQnx',
64
+ parentContentTitle: {
65
+ title: 'Developing the review app',
66
+ type: 'course'
67
+ }
68
+ };
69
+
70
+ export const qcmGraphicUISlide: Partial<UISlide> = {
71
+ questionText:
72
+ 'Pour mener une bonne négociation, il ne faut ressentir aucune émotion. Vrai ou faux ?',
73
+ answerUI: {
74
+ help: 'Sélectionnez la bonne réponse.',
75
+ model: {
76
+ type: 'qcmGraphic',
77
+ answers: [
78
+ {
79
+ title: 'Vrai',
80
+ image:
81
+ '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/true-1512554153232.jpg',
82
+ selected: false,
83
+ onClick: noop
84
+ },
85
+ {
86
+ title: 'Faux',
87
+ image:
88
+ '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/false-1512554160848.jpg',
89
+ selected: false,
90
+ onClick: noop
91
+ }
92
+ ]
93
+ }
94
+ }
95
+ };
@@ -1,5 +1,6 @@
1
1
  import noop from 'lodash/fp/noop';
2
- import {SlideFromAPI, UISlide} from '../../../types/common';
2
+ import {UISlide} from '../..';
3
+ import {SlideFromAPI} from '../../../../types/common';
3
4
 
4
5
  export const qcmSlide: SlideFromAPI = {
5
6
  question: {
@@ -70,7 +71,11 @@ export const qcmSlide: SlideFromAPI = {
70
71
  tips: 'En 2021, le média en ligne Numerama a créé un NFT vendu aux enchères sur OpenSea. Sur cette plateforme, il est obligatoire de mettre un prix de réserve, autrement dit un prix minimum au-dessous duquel la vente ne sera pas automatiquement acceptée. Sur OpenSea il ne peut être inférieur à 1 ETH. Si le prix de réserve est atteint, pas de problème, les "gas fees" (les frais de gaz) sont couverts par OpenSea. Mais, si ce n’est pas le cas, c’est au vendeur de s’en acquitter. <br/>Le NFT en question est parti à 0,021 ETH, soit 40€ au cours de l\'époque, un prix inférieur au prix de réserve. Numerama a dû acquitter des frais de gaz, et payer 190 €. <br/>Avec les NFT, on ne gagne pas à tous les coups.',
71
72
  universalRef: 'sli_N1XACJobn',
72
73
  hasClue: true,
73
- id: 'sli_N1XACJobn'
74
+ id: 'sli_N1XACJobn',
75
+ parentContentTitle: {
76
+ title: 'Developing the review app',
77
+ type: 'course'
78
+ }
74
79
  };
75
80
 
76
81
  export const qcmUISlide: Partial<UISlide> = {
@@ -0,0 +1,99 @@
1
+ import noop from 'lodash/fp/noop';
2
+ import {UISlide} from '../..';
3
+ import {SlideFromAPI} from '../../../../types/common';
4
+
5
+ export const selectTemplateSlide: SlideFromAPI = {
6
+ question: {
7
+ content: {
8
+ template:
9
+ 'La vue {{sel80495}} présente la liste des utilisateurs ayant le plus grand nombre d’étoiles cumulées.',
10
+ choices: [
11
+ {
12
+ items: [
13
+ {
14
+ _id: '5b57464e3b594d002e8829f7',
15
+ value: 'sli_N13-hG3kX.choice_NJgC3aznJm',
16
+ text: 'Catalogue'
17
+ },
18
+ {
19
+ _id: '5b57464e3b594d002e8829f6',
20
+ value: 'sli_N13-hG3kX.choice_EJZ02aMny7',
21
+ text: 'Leaderboard'
22
+ },
23
+ {
24
+ _id: '5b57464e3b594d002e8829f5',
25
+ value: 'sli_N13-hG3kX.choice_4keCaf21Q',
26
+ text: 'Activité'
27
+ },
28
+ {
29
+ _id: '5b57464e3b594d002e8829f4',
30
+ value: 'sli_N13-hG3kX.choice_NkbJAMn17',
31
+ text: 'Slides'
32
+ }
33
+ ],
34
+ _id: '5b57464e3b594d002e8829f3',
35
+ name: 'sel80495',
36
+ type: 'select'
37
+ }
38
+ ]
39
+ },
40
+ type: 'template',
41
+ header: 'Complétez la phrase ci-dessous.',
42
+ explanation:
43
+ 'Saisissez votre réponse ou sélectionnez la bonne réponse dans le(s) menu(s) déroulant(s).'
44
+ },
45
+ klf: 'L’apprenant peut aussi évaluer sa performance grâce à un classement disponible sur la vue leaderboard. Elle compare sa position par rapport à celle des autres apprenants de la plateforme.',
46
+ tips: "La position d'un apprenant peut être aussi consultée depuis le header ou en-tête de la page. Elle se met à jour à chaque fois qu'un apprenant obtient des étoiles.",
47
+ universalRef: 'sli_N13-hG3kX',
48
+ id: 'sli_N13-hG3kX',
49
+ parentContentTitle: {
50
+ title: 'Developing the review app',
51
+ type: 'course'
52
+ }
53
+ };
54
+
55
+ export const selectTemplateUISlide: Partial<UISlide> = {
56
+ questionText: 'Complétez la phrase ci-dessous.',
57
+ answerUI: {
58
+ help: 'Saisissez votre réponse ou sélectionnez la bonne réponse dans le(s) menu(s) déroulant(s).',
59
+ model: {
60
+ type: 'template',
61
+ template:
62
+ 'La vue {{sel80495}} présente la liste des utilisateurs ayant le plus grand nombre d’étoiles cumulées.',
63
+ answers: [
64
+ {
65
+ type: 'select',
66
+ name: 'sel80495',
67
+ onChange: noop,
68
+ options: [
69
+ {name: 'Select an answer', value: '', validOption: false, selected: true},
70
+ {
71
+ name: 'Catalogue',
72
+ value: 'Catalogue',
73
+ validOption: true,
74
+ selected: false
75
+ },
76
+ {
77
+ name: 'Leaderboard',
78
+ value: 'Leaderboard',
79
+ validOption: true,
80
+ selected: false
81
+ },
82
+ {
83
+ name: 'Activité',
84
+ value: 'Activité',
85
+ validOption: true,
86
+ selected: false
87
+ },
88
+ {
89
+ name: 'Slides',
90
+ value: 'Slides',
91
+ validOption: true,
92
+ selected: false
93
+ }
94
+ ]
95
+ }
96
+ ]
97
+ }
98
+ }
99
+ };
@@ -0,0 +1,42 @@
1
+ import noop from 'lodash/fp/noop';
2
+ import {UISlide} from '../..';
3
+ import {SlideFromAPI} from '../../../../types/common';
4
+
5
+ export const sliderSlide: SlideFromAPI = {
6
+ question: {
7
+ content: {
8
+ min: 1,
9
+ max: 15,
10
+ unitLabel: 'an(s)'
11
+ },
12
+ type: 'slider',
13
+ header:
14
+ 'En combien d’années la communauté de communes du Thouarsais est-elle passée de zéro à un tiers d’énergies renouvelables ?',
15
+ explanation: 'Déplacez le curseur.'
16
+ },
17
+ klf: 'Dans le cadre d’un projet local, la communauté de communes du Thouarsais, dans le Poitou (ouest de la France), a développé un parc diversifié d’énergies renouvelables : éolien, biomasse, solaire… En sept ans seulement, entre 2007 et 2014, la part d’énergies renouvelables est passée de zéro à un tiers !',
18
+ tips: 'En 2014, le Thouarsais a reçu la médaille de bronze du championnat européen des énergies renouvelables.',
19
+ universalRef: 'sli_VkAzsCLKb',
20
+ id: 'sli_VkAzsCLKb',
21
+ parentContentTitle: {
22
+ title: 'Developing the review app',
23
+ type: 'course'
24
+ }
25
+ };
26
+
27
+ export const sliderUISlide: Partial<UISlide> = {
28
+ questionText:
29
+ 'En combien d’années la communauté de communes du Thouarsais est-elle passée de zéro à un tiers d’énergies renouvelables ?',
30
+ answerUI: {
31
+ help: 'Déplacez le curseur.',
32
+ model: {
33
+ type: 'slider',
34
+ placeholder: 'Déplacez le curseur.',
35
+ minLabel: '1 an(s)',
36
+ maxLabel: '15 an(s)',
37
+ title: '1 an(s)',
38
+ value: 0,
39
+ onChange: noop
40
+ }
41
+ }
42
+ };
@@ -1,5 +1,6 @@
1
1
  import noop from 'lodash/fp/noop';
2
- import {SlideFromAPI, UISlide} from '../../../types/common';
2
+ import {UISlide} from '../..';
3
+ import {SlideFromAPI} from '../../../../types/common';
3
4
 
4
5
  export const textTemplateSlide: SlideFromAPI = {
5
6
  question: {
@@ -33,7 +34,11 @@ export const textTemplateSlide: SlideFromAPI = {
33
34
  tips: "L'origine de l'expression <i>role model</i> est attribué au sociologue Robert K. Merton.",
34
35
  universalRef: 'sli_VJKQonm2g',
35
36
  hasClue: true,
36
- id: 'sli_VJKQonm2g'
37
+ id: 'sli_VJKQonm2g',
38
+ parentContentTitle: {
39
+ title: 'Using redux',
40
+ type: 'chapter'
41
+ }
37
42
  };
38
43
 
39
44
  export const textTemplateUISlide: Partial<UISlide> = {