@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
@@ -1,5 +1,79 @@
1
+ import concat from 'lodash/fp/concat';
2
+ import get from 'lodash/fp/get';
3
+ import getOr from 'lodash/fp/getOr';
1
4
  import isEmpty from 'lodash/fp/isEmpty';
2
- const buildStepItemps = (state) => {
5
+ import pipe from 'lodash/fp/pipe';
6
+ import reduce from 'lodash/fp/reduce';
7
+ import set from 'lodash/fp/set';
8
+ import slice from 'lodash/fp/slice';
9
+ import toInteger from 'lodash/fp/toInteger';
10
+ import { postAnswer } from '../../actions/api/post-answer';
11
+ import { mapApiSlideToUi } from './map-api-slide-to-ui';
12
+ const ICON_VALUES = {
13
+ right: 'right',
14
+ wrong: 'wrong',
15
+ 'no-answer': 'no-answer'
16
+ };
17
+ export const initialState = {
18
+ '0': {
19
+ hidden: false,
20
+ position: 0,
21
+ loading: true
22
+ },
23
+ '1': {
24
+ hidden: false,
25
+ position: 1,
26
+ loading: true
27
+ },
28
+ '2': {
29
+ hidden: false,
30
+ position: 2,
31
+ loading: true
32
+ },
33
+ '3': {
34
+ hidden: false,
35
+ position: 3,
36
+ loading: true
37
+ },
38
+ '4': {
39
+ hidden: false,
40
+ position: 4,
41
+ loading: true
42
+ }
43
+ };
44
+ const getProgressionSlidesRefs = (progression) => {
45
+ if (progression.state.step.current < 5) {
46
+ const slideRef = progression.state.nextContent.ref;
47
+ return concat([slideRef], progression.state.slides);
48
+ }
49
+ return slice(0, 5, progression.state.slides);
50
+ };
51
+ const buildStackSlides = (state, dispatch) => {
52
+ const currentSlideRef = state.ui.currentSlideRef;
53
+ const progression = state.data.progression;
54
+ if (!currentSlideRef || !progression)
55
+ return initialState;
56
+ const slideRefs = getProgressionSlidesRefs(progression);
57
+ // @ts-expect-error typescript does not support capped versions of lodash functions
58
+ const stack = reduce.convert({ cap: false })((acc, uiSlide, index) => {
59
+ const slideRef = slideRefs[toInteger(index)];
60
+ if (!slideRef)
61
+ return set(index, uiSlide, acc);
62
+ const slideFromAPI = get(slideRef, state.data.slides);
63
+ if (!slideFromAPI)
64
+ return set(index, uiSlide, acc);
65
+ const answers = state.ui.answers;
66
+ const { questionText, answerUI } = mapApiSlideToUi(dispatch)(slideFromAPI, answers);
67
+ const parentContentTitle = getOr('', 'parentContentTitle.title', slideFromAPI);
68
+ const parentContentType = getOr('', 'parentContentTitle.type', slideFromAPI);
69
+ const updatedUiSlide = pipe(set('loading', false), set('questionText', questionText), set('answerUI', answerUI), set('parentContentTitle', `From "${parentContentTitle}" ${parentContentType}`) // TODO translate: -From- .... -Course/chapter-
70
+ // TODO: Set position according to currentSlideRef et slideRefs (or maybe a value on the state ui.slidePositions !!)
71
+ )(uiSlide);
72
+ return set(index, updatedUiSlide, acc);
73
+ }, initialState, initialState);
74
+ return stack;
75
+ };
76
+ const buildStepItems = (state) => {
3
77
  const { progression } = state.data;
4
78
  const { currentSlideRef } = state.ui;
5
79
  if (!progression)
@@ -51,10 +125,7 @@ const buildStepItemps = (state) => {
51
125
  });
52
126
  return steps;
53
127
  };
54
- export const mapStateToSlidesProps = (state) => {
55
- if (!state.data.slides) {
56
- return null;
57
- }
128
+ export const mapStateToSlidesProps = (state, dispatch) => {
58
129
  return {
59
130
  header: {
60
131
  mode: '__revision_mode',
@@ -65,16 +136,15 @@ export const mapStateToSlidesProps = (state) => {
65
136
  },
66
137
  'aria-label': 'aria-header-wrapper',
67
138
  closeButtonAriaLabel: 'aria-close-button',
68
- steps: buildStepItemps(state)
139
+ steps: buildStepItems(state)
69
140
  },
70
141
  stack: {
71
- slides: state.ui.slides,
142
+ slides: buildStackSlides(state, dispatch),
72
143
  validateButton: {
73
144
  label: '__validate',
74
- disabled: true,
145
+ disabled: !get('ui.slide.validateButton', state),
75
146
  onClick: () => {
76
- // eslint-disable-next-line no-console
77
- console.log('TODO: validate question');
147
+ dispatch(postAnswer);
78
148
  }
79
149
  },
80
150
  correctionPopinProps: undefined,
@@ -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
+ };
@@ -0,0 +1,165 @@
1
+ import { concat, divide, get, getOr, head, includes, indexOf, isEmpty, map, multiply, pipe, rangeStep, round, size, toInteger, toString as _toString, __ } from 'lodash/fp';
2
+ import { editAnswer } from '../../actions/ui/answers';
3
+ const qcmProps = (dispatch) => (answers, question) => {
4
+ return {
5
+ type: 'qcm',
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)
17
+ };
18
+ };
19
+ const qcmDragProps = (dispatch) => (answers, question) => {
20
+ return {
21
+ type: 'qcmDrag',
22
+ answers: map(choice => {
23
+ const label = choice.label || '';
24
+ const indexInAnswer = indexOf(label, answers);
25
+ return {
26
+ title: label,
27
+ selected: includes(label, answers),
28
+ order: indexInAnswer,
29
+ onClick: () => {
30
+ dispatch(editAnswer(label));
31
+ }
32
+ };
33
+ }, question.content.choices)
34
+ };
35
+ };
36
+ const qcmGraphicProps = (dispatch) => (answers, question) => {
37
+ return {
38
+ type: 'qcmGraphic',
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)
50
+ };
51
+ };
52
+ const templateTextProps = (choice, index) => {
53
+ // TODO: EDIT_CHOICES -> getAnswerValues
54
+ const answers = [];
55
+ return {
56
+ type: 'text',
57
+ name: getOr('', 'name', choice),
58
+ placeholder: 'Type here',
59
+ value: get(index, answers),
60
+ // TODO: EDIT_CHOICES
61
+ // eslint-disable-next-line no-console
62
+ onChange: () => console.log('TODO: on choice change')
63
+ };
64
+ };
65
+ const templateSelectProps = (choice, index) => {
66
+ // TODO: EDIT_CHOICES -> getAnswerValues
67
+ const answers = [];
68
+ const answer = get(index, answers);
69
+ const temporaryOption = {
70
+ name: 'Select an answer',
71
+ value: '',
72
+ validOption: false,
73
+ selected: true
74
+ };
75
+ const selectOptions = choice.items.map(item => {
76
+ const itemText = getOr('', 'text', item);
77
+ return {
78
+ name: itemText,
79
+ value: itemText,
80
+ validOption: true,
81
+ selected: itemText === answer
82
+ };
83
+ });
84
+ return {
85
+ type: 'select',
86
+ name: getOr('', 'name', choice),
87
+ // TODO: EDIT_CHOICES
88
+ // eslint-disable-next-line no-console
89
+ onChange: () => console.log('TODO: on choice change'),
90
+ options: isEmpty(answer) ? concat([temporaryOption], selectOptions) : selectOptions
91
+ };
92
+ };
93
+ const templateProps = (question) => {
94
+ // TODO: EDIT_CHOICES -> getChoices
95
+ const choices = question.content.choices;
96
+ return {
97
+ type: 'template',
98
+ template: get('content.template', question),
99
+ answers: choices.map((choice, index) => choice.type === 'text' ? templateTextProps(choice, index) : templateSelectProps(choice, index))
100
+ };
101
+ };
102
+ const basicProps = (dispatch) => (answers, question) => {
103
+ return {
104
+ type: 'freeText',
105
+ placeholder: question.content.placeholder || '',
106
+ value: answers[0] || '',
107
+ onChange: (text) => {
108
+ dispatch(editAnswer(text));
109
+ }
110
+ };
111
+ };
112
+ const sliderProps = (dispatch) => (answers, question) => {
113
+ const values = rangeStep(getOr(1, 'content.step', question), get('content.min', question), get('content.max', question) + 1
114
+ // Lodash doesn't infer the type very well here
115
+ );
116
+ const stateValue = head(answers) || question.content.min;
117
+ const currentValue = toInteger(stateValue);
118
+ const indexValue = indexOf(currentValue, values);
119
+ const maxValue = size(values) - 1;
120
+ const sliderPosition = divide(indexValue, maxValue);
121
+ const unitLabel = get('content.unitLabel', question);
122
+ return {
123
+ type: 'slider',
124
+ placeholder: question.explanation,
125
+ minLabel: `${question.content.min} ${unitLabel}`,
126
+ maxLabel: `${question.content.max} ${unitLabel}`,
127
+ title: `${currentValue} ${question.content.unitLabel}`,
128
+ value: sliderPosition,
129
+ onChange: (position) => {
130
+ const newValue = pipe(multiply(maxValue), round, get(__, values), _toString)(position);
131
+ dispatch(editAnswer(newValue));
132
+ }
133
+ };
134
+ };
135
+ export const getQuestionType = (question) => question.type;
136
+ const getHelp = (slide) => get('question.explanation', slide);
137
+ const getAnswerUIModel = (question, answers, dispatch) => {
138
+ const type = getQuestionType(question);
139
+ switch (type) {
140
+ case 'qcm':
141
+ return qcmProps(dispatch)(answers, question);
142
+ case 'qcmGraphic':
143
+ return qcmGraphicProps(dispatch)(answers, question);
144
+ case 'qcmDrag':
145
+ return qcmDragProps(dispatch)(answers, question);
146
+ case 'basic':
147
+ return basicProps(dispatch)(answers, question);
148
+ case 'template':
149
+ return templateProps(question);
150
+ case 'slider':
151
+ return sliderProps(dispatch)(answers, question);
152
+ default:
153
+ throw new Error(`${type} is not an handled question.type`);
154
+ }
155
+ };
156
+ export const mapApiSlideToUi = (dispatch) => (slide, answers) => {
157
+ if (!slide) {
158
+ throw new Error('no slide was found');
159
+ }
160
+ const questionText = getOr('', 'question.header', slide);
161
+ return {
162
+ questionText,
163
+ answerUI: { model: getAnswerUIModel(slide.question, answers, dispatch), help: getHelp(slide) }
164
+ };
165
+ };
@@ -1,3 +1,4 @@
1
- import { SlideFromAPI, UISlide } from '../../../types/common';
1
+ import { UISlide } from '../..';
2
+ import { SlideFromAPI } from '../../../../types/common';
2
3
  export declare const freeTextSlide: SlideFromAPI;
3
4
  export declare const freeTextUISlide: Partial<UISlide>;
@@ -0,0 +1,38 @@
1
+ import noop from 'lodash/fp/noop';
2
+ export const freeTextSlide = {
3
+ question: {
4
+ content: {
5
+ media: {
6
+ src: [],
7
+ posters: [],
8
+ subtitles: []
9
+ },
10
+ label: '',
11
+ placeholder: 'Type here',
12
+ id: 'sli_VJYjJnJhg.choice_1'
13
+ },
14
+ type: 'basic',
15
+ header: 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?',
16
+ explanation: 'Type your answer.'
17
+ },
18
+ 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.',
19
+ tips: 'According to Insee, Paris salaries are 20-25% higher compared with those of the provinces in 2015.',
20
+ universalRef: 'sli_VJYjJnJhg',
21
+ id: 'sli_VJYjJnJhg',
22
+ parentContentTitle: {
23
+ title: 'Developing the review app',
24
+ type: 'course'
25
+ }
26
+ };
27
+ export const freeTextUISlide = {
28
+ answerUI: {
29
+ help: 'Type your answer.',
30
+ model: {
31
+ type: 'freeText',
32
+ placeholder: 'Type here',
33
+ value: '',
34
+ onChange: noop
35
+ }
36
+ },
37
+ questionText: 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
38
+ };
@@ -1,3 +1,4 @@
1
- import { SlideFromAPI, UISlide } from '../../../types/common';
1
+ import { UISlide } from '../..';
2
+ import { SlideFromAPI } from '../../../../types/common';
2
3
  export declare const qcmDragSlide: SlideFromAPI;
3
4
  export declare const qcmDragUISlide: Partial<UISlide>;
@@ -0,0 +1,108 @@
1
+ import noop from 'lodash/fp/noop';
2
+ export const qcmDragSlide = {
3
+ question: {
4
+ content: {
5
+ media: {
6
+ src: [],
7
+ posters: [],
8
+ subtitles: []
9
+ },
10
+ choices: [
11
+ {
12
+ media: {
13
+ src: [],
14
+ posters: [],
15
+ subtitles: []
16
+ },
17
+ items: [],
18
+ _id: '624f01970a234b0333bc7ce8',
19
+ label: 'La démoralisation',
20
+ value: 'sli_4yGBq-mCg.choice_4kRL5uQCg',
21
+ id: '624f01970a234b0333bc7ce8'
22
+ },
23
+ {
24
+ media: {
25
+ src: [],
26
+ posters: [],
27
+ subtitles: []
28
+ },
29
+ items: [],
30
+ _id: '624f01970a234b0333bc7ce9',
31
+ label: 'La stagnation',
32
+ value: 'sli_4yGBq-mCg.choice_E11v9OXAx',
33
+ id: '624f01970a234b0333bc7ce9'
34
+ },
35
+ {
36
+ media: {
37
+ src: [],
38
+ posters: [],
39
+ subtitles: []
40
+ },
41
+ items: [],
42
+ _id: '624f01970a234b0333bc7cea',
43
+ label: 'La frustration',
44
+ value: 'sli_4yGBq-mCg.choice_N1lP9dmRg',
45
+ id: '624f01970a234b0333bc7cea'
46
+ },
47
+ {
48
+ media: {
49
+ src: [],
50
+ posters: [],
51
+ subtitles: []
52
+ },
53
+ items: [],
54
+ _id: '624f01970a234b0333bc7ceb',
55
+ label: "L'implication",
56
+ value: 'sli_4yGBq-mCg.choice_Eybw5dQCx',
57
+ id: '624f01970a234b0333bc7ceb'
58
+ }
59
+ ]
60
+ },
61
+ type: 'qcmDrag',
62
+ header: "Remettez dans l'ordre les quatre étapes du burn out.",
63
+ explanation: 'Sélectionnez les réponses ci-dessous dans le bon ordre.'
64
+ },
65
+ 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).",
66
+ tips: "Encadré par la loi, l'entretien professionnel a pour but d'aider le collaborateur à verbaliser ses difficultés et à construire son projet professionnel.",
67
+ universalRef: 'sli_4yGBq-mCg',
68
+ id: 'sli_4yGBq-mCg',
69
+ parentContentTitle: {
70
+ title: 'Using redux',
71
+ type: 'chapter'
72
+ }
73
+ };
74
+ export const qcmDragUISlide = {
75
+ questionText: "Remettez dans l'ordre les quatre étapes du burn out.",
76
+ answerUI: {
77
+ help: 'Sélectionnez les réponses ci-dessous dans le bon ordre.',
78
+ model: {
79
+ type: 'qcmDrag',
80
+ answers: [
81
+ {
82
+ title: 'La démoralisation',
83
+ selected: false,
84
+ order: -1,
85
+ onClick: noop
86
+ },
87
+ {
88
+ title: 'La stagnation',
89
+ selected: false,
90
+ order: -1,
91
+ onClick: noop
92
+ },
93
+ {
94
+ title: 'La frustration',
95
+ selected: false,
96
+ order: -1,
97
+ onClick: noop
98
+ },
99
+ {
100
+ title: "L'implication",
101
+ selected: false,
102
+ order: -1,
103
+ onClick: noop
104
+ }
105
+ ]
106
+ }
107
+ }
108
+ };
@@ -1,3 +1,4 @@
1
- import { SlideFromAPI, UISlide } from '../../../types/common';
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>;
@@ -0,0 +1,88 @@
1
+ import noop from 'lodash/fp/noop';
2
+ export const qcmGraphicSlide = {
3
+ question: {
4
+ content: {
5
+ media: {
6
+ src: [],
7
+ posters: [],
8
+ subtitles: []
9
+ },
10
+ choices: [
11
+ {
12
+ media: {
13
+ src: [
14
+ {
15
+ _id: '624efd915948a7013083e986',
16
+ mimeType: 'image/jpeg',
17
+ url: '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/true-1512554153232.jpg',
18
+ id: '624efd915948a7013083e986'
19
+ }
20
+ ],
21
+ posters: [],
22
+ subtitles: [],
23
+ type: 'img'
24
+ },
25
+ items: [],
26
+ _id: '624efd915948a7013083e985',
27
+ label: 'Vrai',
28
+ value: 'sli_VkSQroQnx.choice_NJesyUo7nx',
29
+ id: '624efd915948a7013083e985'
30
+ },
31
+ {
32
+ media: {
33
+ src: [
34
+ {
35
+ _id: '624efd915948a7013083e988',
36
+ mimeType: 'image/jpeg',
37
+ url: '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/false-1512554160848.jpg',
38
+ id: '624efd915948a7013083e988'
39
+ }
40
+ ],
41
+ posters: [],
42
+ subtitles: [],
43
+ type: 'img'
44
+ },
45
+ items: [],
46
+ _id: '624efd915948a7013083e987',
47
+ label: 'Faux',
48
+ value: 'sli_VkSQroQnx.choice_VkgayLjX3e',
49
+ id: '624efd915948a7013083e987'
50
+ }
51
+ ]
52
+ },
53
+ type: 'qcmGraphic',
54
+ header: 'Pour mener une bonne négociation, il ne faut ressentir aucune émotion. Vrai ou faux ?',
55
+ explanation: 'Sélectionnez la bonne réponse.'
56
+ },
57
+ 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.",
58
+ 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.",
59
+ universalRef: 'sli_VkSQroQnx',
60
+ id: 'sli_VkSQroQnx',
61
+ parentContentTitle: {
62
+ title: 'Developing the review app',
63
+ type: 'course'
64
+ }
65
+ };
66
+ export const qcmGraphicUISlide = {
67
+ questionText: 'Pour mener une bonne négociation, il ne faut ressentir aucune émotion. Vrai ou faux ?',
68
+ answerUI: {
69
+ help: 'Sélectionnez la bonne réponse.',
70
+ model: {
71
+ type: 'qcmGraphic',
72
+ answers: [
73
+ {
74
+ title: 'Vrai',
75
+ image: '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/true-1512554153232.jpg',
76
+ selected: false,
77
+ onClick: noop
78
+ },
79
+ {
80
+ title: 'Faux',
81
+ image: '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/false-1512554160848.jpg',
82
+ selected: false,
83
+ onClick: noop
84
+ }
85
+ ]
86
+ }
87
+ }
88
+ };
@@ -1,3 +1,4 @@
1
- import { SlideFromAPI, UISlide } from '../../../types/common';
1
+ import { UISlide } from '../..';
2
+ import { SlideFromAPI } from '../../../../types/common';
2
3
  export declare const qcmSlide: SlideFromAPI;
3
4
  export declare const qcmUISlide: Partial<UISlide>;
@@ -66,7 +66,11 @@ export const qcmSlide = {
66
66
  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.',
67
67
  universalRef: 'sli_N1XACJobn',
68
68
  hasClue: true,
69
- id: 'sli_N1XACJobn'
69
+ id: 'sli_N1XACJobn',
70
+ parentContentTitle: {
71
+ title: 'Developing the review app',
72
+ type: 'course'
73
+ }
70
74
  };
71
75
  export const qcmUISlide = {
72
76
  questionText: "Après la vente d'un NFT, son créateur peut-il toucher de l'argent ?",
@@ -1,3 +1,4 @@
1
- import { SlideFromAPI, UISlide } from '../../../types/common';
1
+ import { UISlide } from '../..';
2
+ import { SlideFromAPI } from '../../../../types/common';
2
3
  export declare const selectTemplateSlide: SlideFromAPI;
3
4
  export declare const selectTemplateUISlide: Partial<UISlide>;
@@ -0,0 +1,92 @@
1
+ import noop from 'lodash/fp/noop';
2
+ export const selectTemplateSlide = {
3
+ question: {
4
+ content: {
5
+ template: 'La vue {{sel80495}} présente la liste des utilisateurs ayant le plus grand nombre d’étoiles cumulées.',
6
+ choices: [
7
+ {
8
+ items: [
9
+ {
10
+ _id: '5b57464e3b594d002e8829f7',
11
+ value: 'sli_N13-hG3kX.choice_NJgC3aznJm',
12
+ text: 'Catalogue'
13
+ },
14
+ {
15
+ _id: '5b57464e3b594d002e8829f6',
16
+ value: 'sli_N13-hG3kX.choice_EJZ02aMny7',
17
+ text: 'Leaderboard'
18
+ },
19
+ {
20
+ _id: '5b57464e3b594d002e8829f5',
21
+ value: 'sli_N13-hG3kX.choice_4keCaf21Q',
22
+ text: 'Activité'
23
+ },
24
+ {
25
+ _id: '5b57464e3b594d002e8829f4',
26
+ value: 'sli_N13-hG3kX.choice_NkbJAMn17',
27
+ text: 'Slides'
28
+ }
29
+ ],
30
+ _id: '5b57464e3b594d002e8829f3',
31
+ name: 'sel80495',
32
+ type: 'select'
33
+ }
34
+ ]
35
+ },
36
+ type: 'template',
37
+ header: 'Complétez la phrase ci-dessous.',
38
+ explanation: 'Saisissez votre réponse ou sélectionnez la bonne réponse dans le(s) menu(s) déroulant(s).'
39
+ },
40
+ 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.',
41
+ 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.",
42
+ universalRef: 'sli_N13-hG3kX',
43
+ id: 'sli_N13-hG3kX',
44
+ parentContentTitle: {
45
+ title: 'Developing the review app',
46
+ type: 'course'
47
+ }
48
+ };
49
+ export const selectTemplateUISlide = {
50
+ questionText: 'Complétez la phrase ci-dessous.',
51
+ answerUI: {
52
+ help: 'Saisissez votre réponse ou sélectionnez la bonne réponse dans le(s) menu(s) déroulant(s).',
53
+ model: {
54
+ type: 'template',
55
+ template: 'La vue {{sel80495}} présente la liste des utilisateurs ayant le plus grand nombre d’étoiles cumulées.',
56
+ answers: [
57
+ {
58
+ type: 'select',
59
+ name: 'sel80495',
60
+ onChange: noop,
61
+ options: [
62
+ { name: 'Select an answer', value: '', validOption: false, selected: true },
63
+ {
64
+ name: 'Catalogue',
65
+ value: 'Catalogue',
66
+ validOption: true,
67
+ selected: false
68
+ },
69
+ {
70
+ name: 'Leaderboard',
71
+ value: 'Leaderboard',
72
+ validOption: true,
73
+ selected: false
74
+ },
75
+ {
76
+ name: 'Activité',
77
+ value: 'Activité',
78
+ validOption: true,
79
+ selected: false
80
+ },
81
+ {
82
+ name: 'Slides',
83
+ value: 'Slides',
84
+ validOption: true,
85
+ selected: false
86
+ }
87
+ ]
88
+ }
89
+ ]
90
+ }
91
+ }
92
+ };
@@ -1,3 +1,4 @@
1
- import { SlideFromAPI, UISlide } from '../../../types/common';
1
+ import { UISlide } from '../..';
2
+ import { SlideFromAPI } from '../../../../types/common';
2
3
  export declare const sliderSlide: SlideFromAPI;
3
4
  export declare const sliderUISlide: Partial<UISlide>;