@instructure/quiz-core 17.19.2 → 17.20.0

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 (534) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/es/common/components/resources/item/ItemEdit/index.js +1 -0
  3. package/es/common/components/resources/item/ItemEdit/presenter.js +2 -0
  4. package/es/common/util/interactionTypePropsHelper.js +1 -0
  5. package/lib/banks/api/bankEntries.js +203 -0
  6. package/lib/banks/api/banks.js +315 -0
  7. package/lib/banks/api/tagAssociations.js +128 -0
  8. package/lib/banks/components/AddBankEntryModal/index.js +47 -0
  9. package/lib/banks/components/AddBankEntryModal/presenter.js +156 -0
  10. package/lib/banks/components/AddToBankModal/index.js +53 -0
  11. package/lib/banks/components/AddToBankModal/presenter.js +238 -0
  12. package/lib/banks/components/Bank/index.js +60 -0
  13. package/lib/banks/components/Bank/presenter.js +390 -0
  14. package/lib/banks/components/Bank/theme.js +21 -0
  15. package/lib/banks/components/BankEntriesList/index.js +30 -0
  16. package/lib/banks/components/BankEntriesList/presenter.js +93 -0
  17. package/lib/banks/components/BankEntriesList/theme.js +13 -0
  18. package/lib/banks/components/BankEntry/index.js +97 -0
  19. package/lib/banks/components/BankEntry/presenter.js +763 -0
  20. package/lib/banks/components/BankEntry/theme.js +31 -0
  21. package/lib/banks/components/BankEntryRow/BankEntryRow.examples.js +55 -0
  22. package/lib/banks/components/BankEntryRow/index.js +68 -0
  23. package/lib/banks/components/BankEntryRow/presenter.js +453 -0
  24. package/lib/banks/components/BankEntryRow/theme.js +30 -0
  25. package/lib/banks/components/BankSearch/BankSearch.stories.js +75 -0
  26. package/lib/banks/components/BankSearch/index.js +49 -0
  27. package/lib/banks/components/BankSearch/presenter.js +243 -0
  28. package/lib/banks/components/BankSearch/theme.js +16 -0
  29. package/lib/banks/components/Banks/index.js +58 -0
  30. package/lib/banks/components/Banks/noResults.svg +56 -0
  31. package/lib/banks/components/Banks/presenter.js +480 -0
  32. package/lib/banks/components/Banks/theme.js +20 -0
  33. package/lib/banks/components/BanksList/index.js +38 -0
  34. package/lib/banks/components/BanksList/presenter.js +390 -0
  35. package/lib/banks/components/BanksList/theme.js +28 -0
  36. package/lib/banks/components/CopyMoveBankEntryModal/index.js +56 -0
  37. package/lib/banks/components/CopyMoveBankEntryModal/presenter.js +264 -0
  38. package/lib/banks/components/CreateBankModal/index.js +64 -0
  39. package/lib/banks/components/CreateBankModal/presenter.js +190 -0
  40. package/lib/banks/components/CreateBankModal/theme.js +16 -0
  41. package/lib/banks/components/EditBankModal/index.js +56 -0
  42. package/lib/banks/components/EditBankModal/presenter.js +183 -0
  43. package/lib/banks/components/EditBankModal/theme.js +15 -0
  44. package/lib/banks/components/HeaderMenu/index.js +34 -0
  45. package/lib/banks/components/HeaderMenu/presenter.js +100 -0
  46. package/lib/banks/components/HeaderMenu/theme.js +15 -0
  47. package/lib/banks/components/NavWrapper/NavWrapper.examples.js +27 -0
  48. package/lib/banks/components/NavWrapper/index.js +24 -0
  49. package/lib/banks/components/NavWrapper/presenter.js +189 -0
  50. package/lib/banks/components/NavWrapper/theme.js +24 -0
  51. package/lib/banks/components/SharingModal/ContextualButton/index.js +80 -0
  52. package/lib/banks/components/SharingModal/ShareList/ShareList.examples.js +30 -0
  53. package/lib/banks/components/SharingModal/ShareList/index.js +253 -0
  54. package/lib/banks/components/SharingModal/ShareList/theme.js +10 -0
  55. package/lib/banks/components/SharingModal/asyncSearch.js +399 -0
  56. package/lib/banks/components/SharingModal/index.js +45 -0
  57. package/lib/banks/components/SharingModal/presenter.js +530 -0
  58. package/lib/banks/components/SharingModal/theme.js +17 -0
  59. package/lib/building/api/items.js +255 -0
  60. package/lib/building/api/qtiImports.js +135 -0
  61. package/lib/building/api/quizEntries.js +380 -0
  62. package/lib/building/api/quizzes.js +285 -0
  63. package/lib/building/api/stimuli.js +92 -0
  64. package/lib/building/components/QTIImportModal/index.js +54 -0
  65. package/lib/building/components/layout/Sidebar/Sidebar.examples.js +134 -0
  66. package/lib/building/components/layout/Sidebar/SidebarItem/index.js +86 -0
  67. package/lib/building/components/layout/Sidebar/SidebarItem/presenter.js +159 -0
  68. package/lib/building/components/layout/Sidebar/Stimulus/index.js +87 -0
  69. package/lib/building/components/layout/Sidebar/Stimulus/presenter.js +167 -0
  70. package/lib/building/components/layout/Sidebar/index.js +80 -0
  71. package/lib/building/components/layout/Sidebar/presenter.js +267 -0
  72. package/lib/building/components/layout/Sidebar/theme.js +13 -0
  73. package/lib/building/components/layout/header/BuildingButtons/index.js +56 -0
  74. package/lib/building/components/layout/header/BuildingButtons/presenter.js +195 -0
  75. package/lib/building/components/layout/header/BuildingButtons/theme.js +19 -0
  76. package/lib/building/components/layout/header/SDKBuildingButtons/index.js +27 -0
  77. package/lib/building/components/resources/ActionButtons/index.js +40 -0
  78. package/lib/building/components/resources/ActionButtons/presenter.js +194 -0
  79. package/lib/building/components/resources/ActionButtons/theme.js +16 -0
  80. package/lib/building/components/resources/AddToBankOptions/index.js +119 -0
  81. package/lib/building/components/resources/AddToBankOptions/theme.js +15 -0
  82. package/lib/building/components/resources/BanksTray/index.js +34 -0
  83. package/lib/building/components/resources/BanksTray/presenter.js +233 -0
  84. package/lib/building/components/resources/DeleteStimulusModal/index.js +54 -0
  85. package/lib/building/components/resources/DeleteStimulusModal/presenter.js +316 -0
  86. package/lib/building/components/resources/DeleteStimulusModal/theme.js +17 -0
  87. package/lib/building/components/resources/ItemFeedbackModal/index.js +52 -0
  88. package/lib/building/components/resources/ItemFeedbackModal/presenter.js +183 -0
  89. package/lib/building/components/resources/ItemFeedbackModal/theme.js +13 -0
  90. package/lib/building/components/resources/MoveImmutableModal/index.js +54 -0
  91. package/lib/building/components/resources/MoveImmutableModal/presenter.js +140 -0
  92. package/lib/building/components/resources/quiz/editButton/EditButton.js +89 -0
  93. package/lib/building/components/resources/quiz/instructions/Edit/index.js +22 -0
  94. package/lib/building/components/resources/quiz/instructions/Edit/presenter.js +142 -0
  95. package/lib/building/components/resources/quiz/instructions/Edit/theme.js +14 -0
  96. package/lib/building/components/resources/quiz/instructions/Instructions/Instructions.examples.js +34 -0
  97. package/lib/building/components/resources/quiz/instructions/Instructions/index.js +39 -0
  98. package/lib/building/components/resources/quiz/instructions/Instructions/presenter.js +223 -0
  99. package/lib/building/components/resources/quiz/instructions/Instructions/theme.js +20 -0
  100. package/lib/building/components/resources/quiz/instructions/Show/index.js +97 -0
  101. package/lib/building/components/resources/quiz/instructions/Show/theme.js +16 -0
  102. package/lib/building/components/resources/quiz/title/Edit/index.js +214 -0
  103. package/lib/building/components/resources/quiz/title/Edit/theme.js +24 -0
  104. package/lib/building/components/resources/quiz/title/Show/index.js +97 -0
  105. package/lib/building/components/resources/quiz/title/Show/theme.js +16 -0
  106. package/lib/building/components/resources/quiz/title/Title/Title.examples.js +51 -0
  107. package/lib/building/components/resources/quiz/title/Title/index.js +42 -0
  108. package/lib/building/components/resources/quiz/title/Title/presenter.js +217 -0
  109. package/lib/building/components/resources/quiz/title/Title/theme.js +20 -0
  110. package/lib/building/components/resources/quizEntry/QuizEntry/index.js +98 -0
  111. package/lib/building/components/resources/quizEntry/QuizEntry/presenter.js +435 -0
  112. package/lib/building/components/resources/quizEntry/QuizEntry/theme.js +19 -0
  113. package/lib/building/components/resources/quizEntry/QuizEntryBank/QuizEntryBankEdit/index.js +41 -0
  114. package/lib/building/components/resources/quizEntry/QuizEntryBank/QuizEntryBankEdit/presenter.js +291 -0
  115. package/lib/building/components/resources/quizEntry/QuizEntryBank/QuizEntryBankEdit/theme.js +28 -0
  116. package/lib/building/components/resources/quizEntry/QuizEntryBank/QuizEntryBankShow/index.js +139 -0
  117. package/lib/building/components/resources/quizEntry/QuizEntryBank/QuizEntryBankShow/theme.js +20 -0
  118. package/lib/building/components/resources/quizEntry/QuizEntryEdit/Footer/index.js +39 -0
  119. package/lib/building/components/resources/quizEntry/QuizEntryEdit/Footer/presenter.js +299 -0
  120. package/lib/building/components/resources/quizEntry/QuizEntryEdit/Footer/theme.js +17 -0
  121. package/lib/building/components/resources/quizEntry/QuizEntryEdit/Header/index.js +366 -0
  122. package/lib/building/components/resources/quizEntry/QuizEntryEdit/Header/theme.js +21 -0
  123. package/lib/building/components/resources/quizEntry/QuizEntryEdit/index.js +98 -0
  124. package/lib/building/components/resources/quizEntry/QuizEntryEdit/presenter.js +545 -0
  125. package/lib/building/components/resources/quizEntry/QuizEntryEdit/theme.js +17 -0
  126. package/lib/building/components/resources/quizEntry/QuizEntryShow/index.js +51 -0
  127. package/lib/building/components/resources/quizEntry/QuizEntryShow/presenter.js +385 -0
  128. package/lib/building/components/resources/quizEntry/QuizEntryShow/theme.js +33 -0
  129. package/lib/common/actions/addInteractionTypes.js +15 -0
  130. package/lib/common/actions/alerts.js +72 -0
  131. package/lib/common/actions/bankEntries.js +26 -0
  132. package/lib/common/actions/bankSearch.js +51 -0
  133. package/lib/common/actions/banks.js +71 -0
  134. package/lib/common/actions/config.js +23 -0
  135. package/lib/common/actions/dragAndDrop.js +15 -0
  136. package/lib/common/actions/editing.js +33 -0
  137. package/lib/common/actions/errorsShowing.js +35 -0
  138. package/lib/common/actions/features.js +23 -0
  139. package/lib/common/actions/items.js +15 -0
  140. package/lib/common/actions/modal.js +86 -0
  141. package/lib/common/actions/moderation.js +22 -0
  142. package/lib/common/actions/modifications.js +560 -0
  143. package/lib/common/actions/outcomes.js +31 -0
  144. package/lib/common/actions/postMessage.js +15 -0
  145. package/lib/common/actions/printing.js +23 -0
  146. package/lib/common/actions/qtiImports.js +22 -0
  147. package/lib/common/actions/quizEntries.js +56 -0
  148. package/lib/common/actions/quizSessionEvents.js +17 -0
  149. package/lib/common/actions/quizSessionResults.js +17 -0
  150. package/lib/common/actions/quizSessions.js +129 -0
  151. package/lib/common/actions/quizzes.js +74 -0
  152. package/lib/common/actions/regrading.js +31 -0
  153. package/lib/common/actions/reporting.js +47 -0
  154. package/lib/common/actions/scrolling.js +24 -0
  155. package/lib/common/actions/sessionItemResults.js +17 -0
  156. package/lib/common/actions/sessionItems.js +17 -0
  157. package/lib/common/actions/sharedBanks.js +38 -0
  158. package/lib/common/actions/sidebar.js +25 -0
  159. package/lib/common/actions/stimuli.js +15 -0
  160. package/lib/common/actions/tagAssociations.js +113 -0
  161. package/lib/common/actions/taking.js +160 -0
  162. package/lib/common/actions/ui.js +83 -0
  163. package/lib/common/actions/upload.js +57 -0
  164. package/lib/common/api/callHandlers.js +217 -0
  165. package/lib/common/api/camelizeHelpers.js +40 -0
  166. package/lib/common/api/features.js +27 -0
  167. package/lib/common/api/fileUpload.js +48 -0
  168. package/lib/common/api/getPersistenceActions.js +140 -0
  169. package/lib/common/api/helpers.js +197 -0
  170. package/lib/common/api/interactionTypes.js +24 -0
  171. package/lib/common/api/quizSessions.js +236 -0
  172. package/lib/common/api/quizzes.js +55 -0
  173. package/lib/common/api/schema.js +109 -0
  174. package/lib/common/components/ConfirmationModal/index.js +37 -0
  175. package/lib/common/components/ConfirmationModal/presenter.js +156 -0
  176. package/lib/common/components/ImportModal/ImportFileSelector/index.js +167 -0
  177. package/lib/common/components/ImportModal/ImportFileSelector/theme.js +23 -0
  178. package/lib/common/components/ImportModal/index.js +78 -0
  179. package/lib/common/components/ImportModal/presenter.js +442 -0
  180. package/lib/common/components/ImportModal/theme.js +13 -0
  181. package/lib/common/components/LearnosityCalculator/index.js +196 -0
  182. package/lib/common/components/Pin/Pin.examples.js +20 -0
  183. package/lib/common/components/Pin/index.js +13 -0
  184. package/lib/common/components/Pin/presenter.js +88 -0
  185. package/lib/common/components/PreviewFrame/examples.config.js +24 -0
  186. package/lib/common/components/PreviewFrame/index.js +71 -0
  187. package/lib/common/components/PrintFontSizeModal/index.js +13 -0
  188. package/lib/common/components/PrintFontSizeModal/presenter.js +204 -0
  189. package/lib/common/components/PrintFontSizeModal/theme.js +17 -0
  190. package/lib/common/components/RichContentInput/RceImageImportModal/index.js +28 -0
  191. package/lib/common/components/RichContentInput/RceImageImportModal/presenter.js +115 -0
  192. package/lib/common/components/RichContentInput/index.js +33 -0
  193. package/lib/common/components/RichContentInput/presenter.js +102 -0
  194. package/lib/common/components/SDKApp/index.js +206 -0
  195. package/lib/common/components/SDKApp/theme.js +10 -0
  196. package/lib/common/components/SDKHeaderCalculator.js +29 -0
  197. package/lib/common/components/SDKMenuButton.js +27 -0
  198. package/lib/common/components/SDKTimer.js +29 -0
  199. package/lib/common/components/alerts/index.js +33 -0
  200. package/lib/common/components/alerts/presenter.js +115 -0
  201. package/lib/common/components/alerts/theme.js +18 -0
  202. package/lib/common/components/layout/Page/index.js +102 -0
  203. package/lib/common/components/layout/Page/theme.js +17 -0
  204. package/lib/common/components/layout/header/Calculator/index.js +36 -0
  205. package/lib/common/components/layout/header/Calculator/presenter.js +84 -0
  206. package/lib/common/components/layout/header/HeaderMenuButton/index.js +39 -0
  207. package/lib/common/components/layout/header/HeaderMenuButton/presenter.js +86 -0
  208. package/lib/common/components/layout/header/HeaderMenuButton/theme.js +18 -0
  209. package/lib/common/components/layout/header/Timer/index.js +48 -0
  210. package/lib/common/components/layout/header/Timer/presenter.js +201 -0
  211. package/lib/common/components/layout/header/Timer/theme.js +25 -0
  212. package/lib/common/components/layout/sidebar/PositionSummary/index.js +81 -0
  213. package/lib/common/components/layout/sidebar/PositionSummary/theme.js +22 -0
  214. package/lib/common/components/layout/sidebar/Sidebar/Pin.js +78 -0
  215. package/lib/common/components/layout/sidebar/Sidebar/Sidebar.examples.js +46 -0
  216. package/lib/common/components/layout/sidebar/Sidebar/index.js +338 -0
  217. package/lib/common/components/layout/sidebar/Sidebar/theme.js +50 -0
  218. package/lib/common/components/layout/sidebar/SidebarItem/index.js +46 -0
  219. package/lib/common/components/layout/sidebar/SidebarItem/presenter.js +235 -0
  220. package/lib/common/components/layout/sidebar/SidebarItem/theme.js +33 -0
  221. package/lib/common/components/layout/sidebar/Stimulus/Collection/index.js +20 -0
  222. package/lib/common/components/layout/sidebar/Stimulus/Collection/presenter.js +195 -0
  223. package/lib/common/components/layout/sidebar/Stimulus/Collection/theme.js +17 -0
  224. package/lib/common/components/layout/sidebar/Stimulus/Summary/index.js +20 -0
  225. package/lib/common/components/layout/sidebar/Stimulus/Summary/presenter.js +182 -0
  226. package/lib/common/components/layout/sidebar/Stimulus/Summary/theme.js +20 -0
  227. package/lib/common/components/layout/sidebar/Stimulus/Title/index.js +89 -0
  228. package/lib/common/components/layout/sidebar/Stimulus/Title/theme.js +10 -0
  229. package/lib/common/components/layout/sidebar/Stimulus/index.js +42 -0
  230. package/lib/common/components/layout/sidebar/Stimulus/presenter.js +202 -0
  231. package/lib/common/components/layout/sidebar/Stimulus/theme.js +26 -0
  232. package/lib/common/components/resources/BankSelection/BankSelection.examples.js +26 -0
  233. package/lib/common/components/resources/BankSelection/index.js +39 -0
  234. package/lib/common/components/resources/BankSelection/presenter.js +253 -0
  235. package/lib/common/components/resources/WarningWrapper/index.js +167 -0
  236. package/lib/common/components/resources/WarningWrapper/theme.js +20 -0
  237. package/lib/common/components/resources/entry/EntrySave/index.js +40 -0
  238. package/lib/common/components/resources/entry/EntrySave/presenter.js +221 -0
  239. package/lib/common/components/resources/item/ItemEdit/index.js +92 -0
  240. package/lib/common/components/resources/item/ItemEdit/presenter.js +233 -0
  241. package/lib/common/components/resources/item/ItemOverride/index.js +55 -0
  242. package/lib/common/components/resources/item/ItemOverride/presenter.js +108 -0
  243. package/lib/common/components/resources/item/ItemShow/index.js +71 -0
  244. package/lib/common/components/resources/positionBox/PositionBox.js +78 -0
  245. package/lib/common/components/resources/positionBox/theme.js +21 -0
  246. package/lib/common/components/resources/quiz/AddContent/Body/index.js +42 -0
  247. package/lib/common/components/resources/quiz/AddContent/Body/presenter.js +207 -0
  248. package/lib/common/components/resources/quiz/AddContent/Body/theme.js +20 -0
  249. package/lib/common/components/resources/quiz/AddContent/Button/index.js +129 -0
  250. package/lib/common/components/resources/quiz/AddContent/Button/theme.js +30 -0
  251. package/lib/common/components/resources/quiz/AddContent/Modal/index.js +44 -0
  252. package/lib/common/components/resources/quiz/AddContent/Modal/presenter.js +103 -0
  253. package/lib/common/components/resources/quiz/AddContent/Popover/index.js +54 -0
  254. package/lib/common/components/resources/quiz/AddContent/Popover/presenter.js +185 -0
  255. package/lib/common/components/resources/quiz/AddContent/Popover/theme.js +15 -0
  256. package/lib/common/components/resources/quiz/info/QuizInfo.js +52 -0
  257. package/lib/common/components/resources/quiz/instructions/Instructions.js +76 -0
  258. package/lib/common/components/resources/quiz/instructions/theme.js +15 -0
  259. package/lib/common/components/resources/quiz/title/Title.js +78 -0
  260. package/lib/common/components/resources/quiz/title/theme.js +16 -0
  261. package/lib/common/components/resources/quizSessionResult/Header/index.js +119 -0
  262. package/lib/common/components/resources/quizSessionResult/Header/theme.js +17 -0
  263. package/lib/common/components/resources/quizSessionResult/Info/Info.examples.js +46 -0
  264. package/lib/common/components/resources/quizSessionResult/Info/index.js +321 -0
  265. package/lib/common/components/resources/quizSessionResult/Info/theme.js +20 -0
  266. package/lib/common/components/resources/sessionItemResult/ResultStimulus/index.js +129 -0
  267. package/lib/common/components/resources/sessionItemResult/ResultStimulus/theme.js +39 -0
  268. package/lib/common/components/resources/sessionItemResult/SessionItemResult/index.js +30 -0
  269. package/lib/common/components/resources/sessionItemResult/SessionItemResult/presenter.js +392 -0
  270. package/lib/common/components/resources/sessionItemResult/SessionItemResult/theme.js +37 -0
  271. package/lib/common/components/resources/sessionItemResult/SessionItemResultsList/index.js +123 -0
  272. package/lib/common/components/resources/sessionItemResult/SessionItemResultsList/theme.js +21 -0
  273. package/lib/common/components/resources/stimulus/Stimulus/index.js +45 -0
  274. package/lib/common/components/resources/stimulus/Stimulus/presenter.js +255 -0
  275. package/lib/common/components/resources/stimulus/Stimulus/theme.js +22 -0
  276. package/lib/common/components/resources/stimulus/StimulusEdit/index.js +81 -0
  277. package/lib/common/components/resources/stimulus/StimulusEdit/presenter.js +558 -0
  278. package/lib/common/components/resources/stimulus/StimulusEdit/theme.js +24 -0
  279. package/lib/common/components/resources/stimulus/StimulusEditInfo/index.js +39 -0
  280. package/lib/common/components/resources/stimulus/StimulusEditInfo/presenter.js +247 -0
  281. package/lib/common/components/resources/stimulus/StimulusEditInfo/theme.js +18 -0
  282. package/lib/common/components/resources/stimulus/StimulusShow/index.js +142 -0
  283. package/lib/common/components/resources/stimulus/StimulusShow/theme.js +22 -0
  284. package/lib/common/components/resources/stimulus/StimulusShowInfo/StimulusShowInfo.examples.js +22 -0
  285. package/lib/common/components/resources/stimulus/StimulusShowInfo/index.js +87 -0
  286. package/lib/common/components/shared/Card/CardContent/index.js +73 -0
  287. package/lib/common/components/shared/Card/CardContent/theme.js +24 -0
  288. package/lib/common/components/shared/Card/CardWrapper/index.js +72 -0
  289. package/lib/common/components/shared/Card/CardWrapper/theme.js +21 -0
  290. package/lib/common/components/shared/Card/index.js +46 -0
  291. package/lib/common/components/shared/ExpandButton/index.js +90 -0
  292. package/lib/common/components/shared/ExpandButton/theme.js +12 -0
  293. package/lib/common/components/shared/FormattedDuration/FormattedDuration.examples.js +27 -0
  294. package/lib/common/components/shared/FormattedDuration/index.js +126 -0
  295. package/lib/common/components/shared/IfFeature/index.js +24 -0
  296. package/lib/common/components/shared/IfFeature/presenter.js +56 -0
  297. package/lib/common/components/shared/InteractionTypes/index.js +20 -0
  298. package/lib/common/components/shared/InteractionTypes/presenter.js +197 -0
  299. package/lib/common/components/shared/InteractionTypes/theme.js +18 -0
  300. package/lib/common/components/shared/PaginatedCollection/index.js +36 -0
  301. package/lib/common/components/shared/PaginatedCollection/presenter.js +228 -0
  302. package/lib/common/components/shared/PaginatedCollection/theme.js +17 -0
  303. package/lib/common/components/shared/Paginator/index.js +90 -0
  304. package/lib/common/components/shared/Paginator/theme.js +13 -0
  305. package/lib/common/components/shared/PrintTrigger/index.js +43 -0
  306. package/lib/common/components/shared/PrintTrigger/presenter.js +151 -0
  307. package/lib/common/components/shared/TagDisplay/index.js +105 -0
  308. package/lib/common/components/shared/TagDisplay/theme.js +10 -0
  309. package/lib/common/components/shared/TagSelect/index.js +13 -0
  310. package/lib/common/components/shared/TagSelect/presenter.js +306 -0
  311. package/lib/common/components/shared/TagSuggestSelect/index.js +36 -0
  312. package/lib/common/components/shared/TagSuggestSelect/presenter.js +135 -0
  313. package/lib/common/components/shared/TagWrapper/index.js +13 -0
  314. package/lib/common/components/shared/TagWrapper/presenter.js +89 -0
  315. package/lib/common/components/shared/TimeUnitsInput/TimeUnitsInput.examples.js +25 -0
  316. package/lib/common/components/shared/TimeUnitsInput/index.js +366 -0
  317. package/lib/common/components/shared/drag_and_drop/DragAndDropZone/index.js +126 -0
  318. package/lib/common/components/shared/drag_and_drop/DragAndDropZone/theme.js +25 -0
  319. package/lib/common/components/shared/drag_and_drop/DragHandle/index.js +51 -0
  320. package/lib/common/components/shared/drag_and_drop/DragHandle/presenter.js +324 -0
  321. package/lib/common/components/shared/drag_and_drop/dragAndDropUtils.js +403 -0
  322. package/lib/common/components/shared/errors/Errors.js +81 -0
  323. package/lib/common/components/shared/errors/theme.js +16 -0
  324. package/lib/common/components/shared/file_selector/FileSelector.js +90 -0
  325. package/lib/common/components/shared/file_selector/theme.js +18 -0
  326. package/lib/common/components/shared/functionality/componentWithOutsideClick.js +94 -0
  327. package/lib/common/components/shared/functionality/disableDraggingOverride.js +22 -0
  328. package/lib/common/components/shared/functionality/makeEditable.js +152 -0
  329. package/lib/common/components/shared/functionality/makeScrollable.js +174 -0
  330. package/lib/common/components/shared/overlay/Overlay.js +95 -0
  331. package/lib/common/components/shared/overlay/theme.js +17 -0
  332. package/lib/common/components/shared/return_button/ReturnButton.js +66 -0
  333. package/lib/common/components/shared/spinner/Spinner.js +92 -0
  334. package/lib/common/components/shared/spinner/theme.js +13 -0
  335. package/lib/common/kinesis/QuizEventsLogger.js +155 -0
  336. package/lib/common/kinesis/StreamQueue.js +141 -0
  337. package/lib/common/kinesis/client.js +66 -0
  338. package/lib/common/kinesis/config.js +54 -0
  339. package/lib/common/kinesis/eventTypes.js +48 -0
  340. package/lib/common/middleware/alertTimerMiddleware.js +32 -0
  341. package/lib/common/middleware/crossDomainMessagingMiddleware.js +25 -0
  342. package/lib/common/middleware/eventLoggerMiddleware.js +42 -0
  343. package/lib/common/middleware/persistedStorageMiddleware.js +66 -0
  344. package/lib/common/react-redux.js +21 -0
  345. package/lib/common/records/Alert.js +37 -0
  346. package/lib/common/records/Bank.js +129 -0
  347. package/lib/common/records/BankEntry.js +96 -0
  348. package/lib/common/records/Item.js +151 -0
  349. package/lib/common/records/ItemAnalysis.js +177 -0
  350. package/lib/common/records/QtiImport.js +63 -0
  351. package/lib/common/records/Quiz.js +205 -0
  352. package/lib/common/records/QuizAnalysis.js +121 -0
  353. package/lib/common/records/QuizEntry.js +543 -0
  354. package/lib/common/records/QuizSession.js +219 -0
  355. package/lib/common/records/QuizSessionEvent.js +65 -0
  356. package/lib/common/records/QuizSessionResult.js +90 -0
  357. package/lib/common/records/Response.js +65 -0
  358. package/lib/common/records/SessionItem.js +150 -0
  359. package/lib/common/records/SessionItemResult.js +91 -0
  360. package/lib/common/records/Stimulus.js +101 -0
  361. package/lib/common/records/baseRecord.js +116 -0
  362. package/lib/common/records/index.js +135 -0
  363. package/lib/common/records/reduxRecord.js +46 -0
  364. package/lib/common/reducers/alerts.js +28 -0
  365. package/lib/common/reducers/bankEntries.js +38 -0
  366. package/lib/common/reducers/bankSearch.js +50 -0
  367. package/lib/common/reducers/banks.js +71 -0
  368. package/lib/common/reducers/calls.js +28 -0
  369. package/lib/common/reducers/config.js +32 -0
  370. package/lib/common/reducers/dragAndDrop.js +25 -0
  371. package/lib/common/reducers/editing.js +25 -0
  372. package/lib/common/reducers/errorsShowing.js +31 -0
  373. package/lib/common/reducers/features.js +28 -0
  374. package/lib/common/reducers/interactionTypes.js +33 -0
  375. package/lib/common/reducers/items.js +36 -0
  376. package/lib/common/reducers/modal.js +45 -0
  377. package/lib/common/reducers/moderation.js +34 -0
  378. package/lib/common/reducers/modifications.js +225 -0
  379. package/lib/common/reducers/outcomes.js +37 -0
  380. package/lib/common/reducers/printing.js +26 -0
  381. package/lib/common/reducers/qtiImports.js +39 -0
  382. package/lib/common/reducers/quizEntries.js +182 -0
  383. package/lib/common/reducers/quizSessionEvents.js +36 -0
  384. package/lib/common/reducers/quizSessionResults.js +34 -0
  385. package/lib/common/reducers/quizSessions.js +68 -0
  386. package/lib/common/reducers/quizzes.js +77 -0
  387. package/lib/common/reducers/regrading.js +39 -0
  388. package/lib/common/reducers/reporting.js +72 -0
  389. package/lib/common/reducers/scrolling.js +28 -0
  390. package/lib/common/reducers/sessionItemResults.js +34 -0
  391. package/lib/common/reducers/sessionItems.js +36 -0
  392. package/lib/common/reducers/sharedBanks.js +45 -0
  393. package/lib/common/reducers/sidebar.js +30 -0
  394. package/lib/common/reducers/stimuli.js +36 -0
  395. package/lib/common/reducers/tagAssociations.js +140 -0
  396. package/lib/common/reducers/taking.js +143 -0
  397. package/lib/common/reducers/ui.js +51 -0
  398. package/lib/common/reducers/upload.js +41 -0
  399. package/lib/common/selectors/calculator.js +39 -0
  400. package/lib/common/selectors/calls.js +14 -0
  401. package/lib/common/selectors/interactionTypes.js +45 -0
  402. package/lib/common/selectors/items.js +28 -0
  403. package/lib/common/selectors/qtiImports.js +35 -0
  404. package/lib/common/selectors/quizSessionResults.js +25 -0
  405. package/lib/common/selectors/quizSessions.js +54 -0
  406. package/lib/common/selectors/quizzes.js +146 -0
  407. package/lib/common/selectors/reporting.js +26 -0
  408. package/lib/common/selectors/sessionItemResults.js +41 -0
  409. package/lib/common/selectors/sessionItems.js +53 -0
  410. package/lib/common/selectors/taking.js +64 -0
  411. package/lib/common/selectors/ui.js +12 -0
  412. package/lib/common/util/CustomPropTypes.js +88 -0
  413. package/lib/common/util/ElementsForSelectors.js +22 -0
  414. package/lib/common/util/ExhaustivePaginatedFetcher.js +127 -0
  415. package/lib/common/util/Fetcher.js +455 -0
  416. package/lib/common/util/MultiWeakMap.js +88 -0
  417. package/lib/common/util/PaginatedFetcher.js +110 -0
  418. package/lib/common/util/ThunkQueue.js +163 -0
  419. package/lib/common/util/TimeRecordingService.js +85 -0
  420. package/lib/common/util/TimerService.js +210 -0
  421. package/lib/common/util/cachePreviousArgs.js +32 -0
  422. package/lib/common/util/callHelpers.js +48 -0
  423. package/lib/common/util/componentForItem.js +40 -0
  424. package/lib/common/util/crossDomainMessaging.js +14 -0
  425. package/lib/common/util/debounceLatestPromise.js +38 -0
  426. package/lib/common/util/featureCheck.js +58 -0
  427. package/lib/common/util/fetchHelpers.js +14 -0
  428. package/lib/common/util/formatTimespan.js +68 -0
  429. package/lib/common/util/generateDisplayPositions.js +34 -0
  430. package/lib/common/util/httpHeaders.js +28 -0
  431. package/lib/common/util/immutableHelpers.js +36 -0
  432. package/lib/common/util/instUIMessages.js +17 -0
  433. package/lib/common/util/interactionTypeMetadata.js +60 -0
  434. package/lib/common/util/interactionTypePropsHelper.js +100 -0
  435. package/lib/common/util/interactionTypeRecordForItem.js +36 -0
  436. package/lib/common/util/jsonify.js +39 -0
  437. package/lib/common/util/keyboardClickable.js +17 -0
  438. package/lib/common/util/maxContent.js +22 -0
  439. package/lib/common/util/modalHelpers.js +13 -0
  440. package/lib/common/util/noop.js +12 -0
  441. package/lib/common/util/persistedState.js +61 -0
  442. package/lib/common/util/printUtils.js +50 -0
  443. package/lib/common/util/renderAlerts.js +34 -0
  444. package/lib/common/util/serializeEvent.js +43 -0
  445. package/lib/common/util/sessionStore.js +81 -0
  446. package/lib/common/util/valMap.js +20 -0
  447. package/lib/common/util/warningHelpers.js +160 -0
  448. package/lib/common/util/windowChecks.js +27 -0
  449. package/lib/common/util/withCachedArguments.js +41 -0
  450. package/lib/common/util/withDynamoPagination.js +136 -0
  451. package/lib/common/util/withStateCache.js +63 -0
  452. package/lib/config.js +46 -0
  453. package/lib/configureStore.js +175 -0
  454. package/lib/grading/api/quizEntryRegrades.js +50 -0
  455. package/lib/grading/api/updateResults.js +50 -0
  456. package/lib/index.js +1534 -0
  457. package/lib/moderating/api/quizSessionEvents.js +28 -0
  458. package/lib/moderating/api/quizSessions.js +66 -0
  459. package/lib/moderating/components/events/Event.js +111 -0
  460. package/lib/moderating/components/events/ResponseEvent.js +143 -0
  461. package/lib/moderating/components/events/SessionStartEvent.js +70 -0
  462. package/lib/moderating/components/events/theme.js +18 -0
  463. package/lib/moderating/components/resources/AccommodationsModal/AccommodationsModal.examples.js +23 -0
  464. package/lib/moderating/components/resources/AccommodationsModal/ExtraAttemptSettings/ExtraAttemptsInput/index.js +140 -0
  465. package/lib/moderating/components/resources/AccommodationsModal/ExtraAttemptSettings/ExtraAttemptsInput/{}.examples.js +28 -0
  466. package/lib/moderating/components/resources/AccommodationsModal/ExtraAttemptSettings/index.js +133 -0
  467. package/lib/moderating/components/resources/AccommodationsModal/ExtraTimeMultiplier/index.js +172 -0
  468. package/lib/moderating/components/resources/AccommodationsModal/ExtraTimeSettings/ExtraTimeSettings.examples.js +56 -0
  469. package/lib/moderating/components/resources/AccommodationsModal/ExtraTimeSettings/index.js +173 -0
  470. package/lib/moderating/components/resources/AccommodationsModal/index.js +164 -0
  471. package/lib/moderating/components/resources/ElapsedTime.js +81 -0
  472. package/lib/moderating/components/resources/ModerateTable/index.js +62 -0
  473. package/lib/moderating/components/resources/ModerateTable/presenter.js +442 -0
  474. package/lib/moderating/components/resources/ModerateTable/theme.js +15 -0
  475. package/lib/moderating/components/resources/ModerateTableRow/ModerateTableRow.examples.js +86 -0
  476. package/lib/moderating/components/resources/ModerateTableRow/index.js +31 -0
  477. package/lib/moderating/components/resources/ModerateTableRow/presenter.js +416 -0
  478. package/lib/moderating/components/resources/ModerateTableRow/story.js +27 -0
  479. package/lib/moderating/components/resources/ModerateTableRow/theme.js +14 -0
  480. package/lib/moderating/components/resources/OutstandingQuizzesModal/OutstandingQuizzesModal.examples.js +86 -0
  481. package/lib/moderating/components/resources/OutstandingQuizzesModal/index.js +35 -0
  482. package/lib/moderating/components/resources/OutstandingQuizzesModal/presenter.js +203 -0
  483. package/lib/moderating/components/sidebar/ModerateTray/ModerateTray.examples.js +20 -0
  484. package/lib/moderating/components/sidebar/ModerateTray/index.js +28 -0
  485. package/lib/moderating/components/sidebar/ModerateTray/presenter.js +189 -0
  486. package/lib/moderating/components/sidebar/ResetQuiz/index.js +52 -0
  487. package/lib/moderating/components/sidebar/ResetQuiz/presenter.js +125 -0
  488. package/lib/package.json +1 -0
  489. package/lib/reduxStore.js +49 -0
  490. package/lib/reporting/api/itemAnalyses.js +27 -0
  491. package/lib/reporting/api/quizAnalyses.js +30 -0
  492. package/lib/reporting/components/Caption/index.js +76 -0
  493. package/lib/reporting/components/Caption/theme.js +16 -0
  494. package/lib/reporting/components/MetricsListItem/index.js +88 -0
  495. package/lib/reporting/components/MetricsListItem/theme.js +10 -0
  496. package/lib/reporting/components/charts/CentileDistribution/CentileDistribution.examples.js +32 -0
  497. package/lib/reporting/components/charts/CentileDistribution/index.js +13 -0
  498. package/lib/reporting/components/charts/CentileDistribution/presenter.js +191 -0
  499. package/lib/reporting/components/charts/CentileDistribution/theme.js +16 -0
  500. package/lib/reporting/components/charts/Distribution/CentileDistribution.js +14 -0
  501. package/lib/reporting/components/charts/Distribution/Distribution.js +14 -0
  502. package/lib/reporting/components/charts/Distribution/QuintileDistribution.js +14 -0
  503. package/lib/reporting/components/charts/Distribution/index.js +13 -0
  504. package/lib/reporting/components/charts/Distribution/presenter.js +386 -0
  505. package/lib/reporting/components/charts/Distribution/theme.js +19 -0
  506. package/lib/reporting/components/charts/Legend/index.js +94 -0
  507. package/lib/reporting/components/charts/Legend/theme.js +24 -0
  508. package/lib/reporting/components/charts/QuintileDistribution/QuintileDistribution.examples.js +16 -0
  509. package/lib/reporting/components/charts/QuintileDistribution/index.js +13 -0
  510. package/lib/reporting/components/charts/QuintileDistribution/presenter.js +175 -0
  511. package/lib/reporting/components/charts/QuintileDistribution/theme.js +16 -0
  512. package/lib/reporting/components/itemAnalysis/AnswerFrequencySummary/AnswerFrequencySummary.examples.js +45 -0
  513. package/lib/reporting/components/itemAnalysis/AnswerFrequencySummary/index.js +189 -0
  514. package/lib/reporting/components/itemAnalysis/AnswerFrequencySummary/theme.js +33 -0
  515. package/lib/reporting/components/itemAnalysis/ItemAnalysisRow/ItemAnalysisRow.examples.js +60 -0
  516. package/lib/reporting/components/itemAnalysis/ItemAnalysisRow/index.js +28 -0
  517. package/lib/reporting/components/itemAnalysis/ItemAnalysisRow/presenter.js +337 -0
  518. package/lib/reporting/components/itemAnalysis/ItemAnalysisRow/theme.js +32 -0
  519. package/lib/reporting/components/quizAnalysis/QuizAnalysisOverview.js +188 -0
  520. package/lib/reporting/components/quizAnalysis/theme.js +20 -0
  521. package/lib/reporting/components/resources/OutcomeAnalysis/index.js +30 -0
  522. package/lib/reporting/components/resources/OutcomeAnalysis/presenter.js +129 -0
  523. package/lib/reporting/components/resources/QuizAndItemAnalysis/QuizAndItemAnalysis.examples.js +190 -0
  524. package/lib/reporting/components/resources/QuizAndItemAnalysis/index.js +45 -0
  525. package/lib/reporting/components/resources/QuizAndItemAnalysis/presenter.js +340 -0
  526. package/lib/reporting/components/resources/QuizAndItemAnalysis/theme.js +20 -0
  527. package/lib/reporting/components/resources/ReportCard/index.js +89 -0
  528. package/lib/reporting/components/resources/ReportCard/theme.js +20 -0
  529. package/lib/reporting/components/resources/ReportList/index.js +84 -0
  530. package/lib/reporting/components/resources/ReportList/theme.js +17 -0
  531. package/lib/taking/api/taking.js +371 -0
  532. package/lib/taking/learnosity/index.js +195 -0
  533. package/lib/taking/learnosity/loader.js +87 -0
  534. package/package.json +11 -11
@@ -0,0 +1,380 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.getQuizEntry = getQuizEntry;
9
+ exports.getQuizEntries = getQuizEntries;
10
+ exports.createQuizEntry = createQuizEntry;
11
+ exports.updateQuizEntry = updateQuizEntry;
12
+ exports.cloneQuizEntry = cloneQuizEntry;
13
+ exports.moveQuizEntry = moveQuizEntry;
14
+ exports.moveImmutableQuizEntry = moveImmutableQuizEntry;
15
+ exports.removeQuizEntry = removeQuizEntry;
16
+ exports.removeStimulusQuizEntry = removeStimulusQuizEntry;
17
+ exports.createItemAndQuizEntry = exports.createStimulusAndQuizEntry = void 0;
18
+
19
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
20
+
21
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
22
+
23
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
24
+
25
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
26
+
27
+ var _pick = _interopRequireDefault(require("lodash/pick"));
28
+
29
+ var _pickBy = _interopRequireDefault(require("lodash/pickBy"));
30
+
31
+ var _humps = require("humps");
32
+
33
+ var _Fetcher = _interopRequireDefault(require("../../common/util/Fetcher.js"));
34
+
35
+ var _ExhaustivePaginatedFetcher = _interopRequireDefault(require("../../common/util/ExhaustivePaginatedFetcher.js"));
36
+
37
+ var _scrolling = require("../../common/actions/scrolling.js");
38
+
39
+ var _ThunkQueue = _interopRequireDefault(require("../../common/util/ThunkQueue.js"));
40
+
41
+ var _noop = _interopRequireDefault(require("../../common/util/noop.js"));
42
+
43
+ var _quizCommon = require("@instructure/quiz-common");
44
+
45
+ var _items = require("./items.js");
46
+
47
+ var _stimuli = require("./stimuli.js");
48
+
49
+ var _alerts = require("../../common/actions/alerts.js");
50
+
51
+ var _quizEntries = require("../../common/actions/quizEntries.js");
52
+
53
+ var _ui = require("../../common/actions/ui.js");
54
+
55
+ var _quizzes = require("../../common/actions/quizzes.js");
56
+
57
+ var _callHandlers = require("../../common/api/callHandlers.js");
58
+
59
+ var _quizzes2 = require("../../common/api/quizzes.js");
60
+
61
+ var _QuizEntry = _interopRequireDefault(require("../../common/records/QuizEntry.js"));
62
+
63
+ var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/es/format-message"));
64
+
65
+ // Actions that involve an API call should happen in order, to prevent race
66
+ // conditions (a user moving a question into a stimulus then immediately
67
+ // deleting the stimulus, for example). We use this queue to make sure requests
68
+ // wait for previous requests to finish, without preventing UI updates.
69
+ var queue = new _ThunkQueue.default(function (error, dispatch, getState) {
70
+ // If an action fails, re-fetch all quiz entries from the backend
71
+ var activeQuizId = getState().getIn(['quizzes', 'activeQuizId']);
72
+ dispatch(getQuizEntries(activeQuizId));
73
+ throw error;
74
+ }); // =====================
75
+ // =====================
76
+ // GET INDEX
77
+ // =====================
78
+ // =====================
79
+
80
+ var handleQuizEntriesGet = function handleQuizEntriesGet(dispatch, quizId, quizEntries) {
81
+ dispatch([(0, _callHandlers.handleQuizEntriesResponse)(quizEntries, quizId), (0, _quizzes.associateQuizEntries)(quizId, quizEntries)]);
82
+ return quizEntries;
83
+ };
84
+
85
+ function getQuizEntry(quizId, quizEntryId) {
86
+ var url = "/api/quizzes/".concat(quizId, "/quiz_entries/").concat(quizEntryId);
87
+ return function (dispatch, getState) {
88
+ var fetcher = new _Fetcher.default();
89
+ return fetcher.get(url).then(function (data) {
90
+ return handleQuizEntriesGet(dispatch, quizId, [data]);
91
+ });
92
+ };
93
+ }
94
+
95
+ function getQuizEntries(quizId) {
96
+ var cb = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : _noop.default;
97
+ var url = "/api/quizzes/".concat(quizId, "/quiz_entries");
98
+ return function (dispatch, getState) {
99
+ var fetcher = new _ExhaustivePaginatedFetcher.default();
100
+ return fetcher.get(url).then(function (data) {
101
+ return handleQuizEntriesGet(dispatch, quizId, data);
102
+ }).then(cb);
103
+ };
104
+ } // =====================
105
+ // =====================
106
+ // CREATE
107
+ // =====================
108
+ // =====================
109
+
110
+
111
+ function createEntryAndQuizEntry(quizId, entry, quizEntry, entryCreationCb, quizEntryCreationCb) {
112
+ return function (dispatch, getState) {
113
+ var entryProperties = quizEntry.getProperties();
114
+ return dispatch(entryCreationCb(entry, quizId, 'quiz')).then(function (entryData) {
115
+ return dispatch(quizEntryCreationCb(quizId, entryData.id, quizEntry.get('entryType'), entryProperties));
116
+ });
117
+ };
118
+ }
119
+
120
+ var createStimulusAndQuizEntry = queue.wrapActionCreator(function (quizId, stimulus, quizEntry) {
121
+ var stimulusCreationCb = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : _stimuli.createStimulus;
122
+ var quizEntryCreationCb = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : createQuizEntry;
123
+ return createEntryAndQuizEntry(quizId, stimulus, quizEntry, stimulusCreationCb, quizEntryCreationCb);
124
+ });
125
+ exports.createStimulusAndQuizEntry = createStimulusAndQuizEntry;
126
+ var createItemAndQuizEntry = queue.wrapActionCreator(function (quizId, item, quizEntry) {
127
+ var itemCreationCb = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : _items.createItem;
128
+ var quizEntryCreationCb = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : createQuizEntry;
129
+ return createEntryAndQuizEntry(quizId, item, quizEntry, itemCreationCb, quizEntryCreationCb);
130
+ });
131
+ exports.createItemAndQuizEntry = createItemAndQuizEntry;
132
+
133
+ function createQuizEntry(quizId, entryId, entryType, entryProperties) {
134
+ var requireFocus = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : true;
135
+ var url = "/api/quizzes/".concat(quizId, "/quiz_entries");
136
+ var quizEntryParams = (0, _objectSpread2.default)({
137
+ quizId: quizId,
138
+ entryType: entryType,
139
+ entryId: entryId
140
+ }, entryProperties);
141
+ var body = JSON.stringify({
142
+ quiz_entry: quizEntryParams
143
+ });
144
+ return function (dispatch, getState) {
145
+ var fetcher = new _Fetcher.default({
146
+ callType: _quizCommon.CREATE_QUIZ_ENTRY_CALL,
147
+ onError: function onError() {
148
+ return (0, _alerts.addError)((0, _formatMessage.default)('Failed to create quiz entry.'));
149
+ }
150
+ }); // TODO: this re-fetches all quiz entries after the new quiz entry is
151
+ // created. This causes the new question to disappear and reappear after a
152
+ // noticeable delay. Should we add the quiz entry optimistically, for
153
+ // better UX?
154
+
155
+ return fetcher.post(url, {
156
+ body: body
157
+ }).then(function (response) {
158
+ var scrollCallback = function scrollCallback() {
159
+ return dispatch((0, _scrolling.scrollToItem)(response.id, requireFocus));
160
+ };
161
+
162
+ return dispatch(getQuizEntries(quizId, scrollCallback));
163
+ });
164
+ };
165
+ } // =====================
166
+ // =====================
167
+ // UPDATE, CLONE & MOVE
168
+ // =====================
169
+ // =====================
170
+ // UPDATE HELPER
171
+
172
+
173
+ function updateBody(updatedProperties) {
174
+ var properties = updatedProperties.properties;
175
+
176
+ if (properties && properties.selection === 'all') {
177
+ properties.sampleNum = null;
178
+ }
179
+
180
+ var validProperties = Object.keys(updatedProperties).map(_humps.decamelize).concat(['properties']);
181
+ var entryProperties = (0, _pick.default)({
182
+ points_possible: parseFloat(updatedProperties.pointsPossible),
183
+ position: updatedProperties.position,
184
+ stimulus_quiz_entry_id: updatedProperties.stimulusQuizEntryId,
185
+ entry_id: updatedProperties.entryId,
186
+ entry_type: updatedProperties.entryType,
187
+ properties: properties
188
+ }, validProperties);
189
+
190
+ var isDefined = function isDefined(val) {
191
+ return val !== null && val !== void 0;
192
+ };
193
+
194
+ var entryPropsToUpdate = (0, _pickBy.default)(entryProperties, isDefined);
195
+ return JSON.stringify({
196
+ quiz_entry: entryPropsToUpdate
197
+ });
198
+ } // Update the given quiz entry. If handleResponse is true, the redux store will
199
+ // be updated with response data when it comes back. You may want to set
200
+ // handleResponse to false for some optimistic update flows.
201
+
202
+
203
+ function updateQuizEntry(quizId, quizEntryId, updatedProperties) {
204
+ var _ref = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {},
205
+ _ref$handleResponse = _ref.handleResponse,
206
+ handleResponse = _ref$handleResponse === void 0 ? true : _ref$handleResponse;
207
+
208
+ var url = "/api/quizzes/".concat(quizId, "/quiz_entries/").concat(quizEntryId);
209
+ var fetcher = new _Fetcher.default({
210
+ callType: _quizCommon.UPDATE_QUIZ_ENTRY_CALL,
211
+ onError: function onError() {
212
+ return (0, _alerts.addError)((0, _formatMessage.default)('Failed to update quiz entry.'));
213
+ }
214
+ });
215
+ var body = updateBody(updatedProperties);
216
+ return /*#__PURE__*/function () {
217
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(dispatch, getState) {
218
+ var response;
219
+ return _regenerator.default.wrap(function _callee$(_context) {
220
+ while (1) {
221
+ switch (_context.prev = _context.next) {
222
+ case 0:
223
+ _context.next = 2;
224
+ return fetcher.patch(url, {
225
+ body: body
226
+ });
227
+
228
+ case 2:
229
+ response = _context.sent;
230
+
231
+ if (handleResponse) {
232
+ dispatch((0, _callHandlers.handleQuizEntryResponse)(response));
233
+ }
234
+
235
+ case 4:
236
+ case "end":
237
+ return _context.stop();
238
+ }
239
+ }
240
+ }, _callee);
241
+ }));
242
+
243
+ return function (_x, _x2) {
244
+ return _ref2.apply(this, arguments);
245
+ };
246
+ }();
247
+ }
248
+
249
+ function cloneQuizEntry(quizId, quizEntryId, updatedProperties) {
250
+ var url = "/api/quizzes/".concat(quizId, "/quiz_entries/").concat(quizEntryId, "/clone");
251
+ var fetcher = new _Fetcher.default({
252
+ callType: _quizCommon.CLONE_QUIZ_ENTRY_CALL,
253
+ onError: function onError() {
254
+ return (0, _alerts.addError)((0, _formatMessage.default)('Failed to clone quiz entry.'));
255
+ }
256
+ });
257
+ var body = updateBody(updatedProperties);
258
+ return function (dispatch, getState) {
259
+ return fetcher.post(url, {
260
+ body: body
261
+ }).then(function (qeData) {
262
+ dispatch((0, _callHandlers.handleQuizEntryResponse)(qeData));
263
+ return qeData;
264
+ }).then(function () {
265
+ return dispatch((0, _quizzes2.getExistingQuizAndItems)(quizId));
266
+ });
267
+ };
268
+ }
269
+
270
+ function moveQuizEntry(quizId, position, stimulusQuizEntryId, quizEntryId, moveTempItem) {
271
+ var updateAction = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : updateQuizEntry;
272
+ return function (dispatch, getState) {
273
+ // Optimistically move the quiz entry in the redux store without waiting
274
+ // for a response.
275
+ return dispatch([(0, _quizEntries.moveQuizEntry)(quizEntryId, position, stimulusQuizEntryId), (0, _ui.set)(_quizCommon.MOVED_QUIZ_ENTRY, quizEntryId)]).then(function () {
276
+ moveTempItem && moveTempItem(); // this functionality was temporarily disabled in 9c03aa9
277
+
278
+ var queuedUpdate = queue.wrapThunk(updateAction(quizId, quizEntryId, {
279
+ position: position,
280
+ stimulusQuizEntryId: stimulusQuizEntryId
281
+ }, {
282
+ handleResponse: false
283
+ }));
284
+ return dispatch(queuedUpdate);
285
+ });
286
+ };
287
+ }
288
+
289
+ function moveImmutableQuizEntry(quizId, position, stimulusQuizEntryId, quizEntryId) {
290
+ var createItemAction = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : _items.createItem;
291
+ var updateAction = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : updateQuizEntry;
292
+ return function (dispatch, getState) {
293
+ return dispatch(moveQuizEntry(quizId, position, stimulusQuizEntryId, quizEntryId, void 0, // We pass a noop action creator here to only move the quiz entry in our
294
+ // local state, not on the backend. We need to wait to move the entry on
295
+ // the backend until after the new item has been created, otherwise the
296
+ // backend will complain about trying to update an immutable item.
297
+ function () {
298
+ return {
299
+ type: _quizCommon.DO_NOTHING
300
+ };
301
+ })).then(function () {
302
+ return dispatch(createItemAndMoveQuizEntry(quizId, position, stimulusQuizEntryId, quizEntryId, createItemAction, updateAction));
303
+ });
304
+ };
305
+ }
306
+
307
+ var createItemAndMoveQuizEntry = queue.wrapActionCreator(function (quizId, position, stimulusQuizEntryId, quizEntryId) {
308
+ var createItemAction = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : _items.createItem;
309
+ var updateAction = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : updateQuizEntry;
310
+ return function (dispatch, getState) {
311
+ var quizEntry = _QuizEntry.default.create(getState().getIn(['quizEntries', quizEntryId]));
312
+
313
+ var workingItem = quizEntry.getEntry().getWorkingInstance();
314
+ return dispatch(createItemAction(workingItem, quizId, 'quiz', workingItem.id)).then(function (_ref3) {
315
+ var id = _ref3.id;
316
+ return dispatch(updateAction(quizId, quizEntryId, {
317
+ entryId: id,
318
+ position: position,
319
+ stimulusQuizEntryId: stimulusQuizEntryId
320
+ }, {
321
+ handleResponse: false
322
+ }));
323
+ });
324
+ };
325
+ }); // =====================
326
+ // =====================
327
+ // DESTROY
328
+ // =====================
329
+ // =====================
330
+
331
+ function quizEntryDeleted(dispatch, quizEntry) {
332
+ setTimeout(function () {
333
+ dispatch((0, _ui.set)(_quizCommon.DELETED_QUIZ_ENTRY, {
334
+ position: quizEntry.position,
335
+ inStimulus: quizEntry.isInStimulus
336
+ }));
337
+ }, 100);
338
+ }
339
+
340
+ var deleteQuizEntry = queue.wrapActionCreator(function (url, params) {
341
+ return function (dispatch, getState) {
342
+ var fetcher = new _Fetcher.default({
343
+ callType: _quizCommon.DELETE_QUIZ_ENTRY_CALL,
344
+ onError: function onError() {
345
+ return (0, _alerts.addError)((0, _formatMessage.default)('Failed to remove quiz entry.'));
346
+ }
347
+ });
348
+ return fetcher.delete(url, params);
349
+ };
350
+ });
351
+
352
+ function removeQuizEntry(quizId, quizEntry) {
353
+ var url = "/api/quizzes/".concat(quizId, "/quiz_entries/").concat(quizEntry.id);
354
+ return function (dispatch, getState) {
355
+ return dispatch([(0, _quizEntries.deleteQuizEntry)(quizEntry.id), (0, _quizzes.disassociateQuizEntry)(quizId, quizEntry.id)]).then(function () {
356
+ quizEntryDeleted(dispatch, quizEntry);
357
+ return dispatch(deleteQuizEntry(url));
358
+ });
359
+ };
360
+ }
361
+
362
+ function removeStimulusQuizEntry(quizId, stimulusEntry, childEntries) {
363
+ var url = "/api/quizzes/".concat(quizId, "/quiz_entries/").concat(stimulusEntry.id, "/stimuli");
364
+ var childEntryIds = childEntries.map(function (e) {
365
+ return e.id;
366
+ });
367
+ return function (dispatch, getState) {
368
+ var body = JSON.stringify({
369
+ child_ids: childEntryIds
370
+ });
371
+ return dispatch([(0, _quizEntries.deleteStimulusEntry)(stimulusEntry.id, childEntryIds), (0, _quizzes.disassociateQuizEntry)(quizId, stimulusEntry.id)].concat((0, _toConsumableArray2.default)(childEntryIds.map(function (id) {
372
+ return (0, _quizzes.disassociateQuizEntry)(quizId, id);
373
+ })))).then(function () {
374
+ quizEntryDeleted(dispatch, stimulusEntry);
375
+ return dispatch(deleteQuizEntry(url, {
376
+ body: body
377
+ }));
378
+ });
379
+ };
380
+ }
@@ -0,0 +1,285 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.quizBuildingSession = quizBuildingSession;
9
+ exports.saveQuizChange = saveQuizChange;
10
+ exports.startNewQuiz = startNewQuiz;
11
+ exports.getExistingQuizAndItemsForBuilding = getExistingQuizAndItemsForBuilding;
12
+ exports.interactionFileUpload = interactionFileUpload;
13
+ exports.setQuizShuffleQuestions = setQuizShuffleQuestions;
14
+ exports.setQuizShuffleAnswers = setQuizShuffleAnswers;
15
+ exports.setRequireStudentAccessCode = setRequireStudentAccessCode;
16
+ exports.setStudentAccessCodeUi = setStudentAccessCodeUi;
17
+ exports.setStudentAccessCodeApi = setStudentAccessCodeApi;
18
+ exports.setOneAtATimeType = setOneAtATimeType;
19
+ exports.setBacktracking = setBacktracking;
20
+ exports.setQuizHasTimeLimit = setQuizHasTimeLimit;
21
+ exports.setSessionTimeLimitInSecondsUi = setSessionTimeLimitInSecondsUi;
22
+ exports.setSessionTimeLimitInSecondsApi = setSessionTimeLimitInSecondsApi;
23
+ exports.setFilterIpAddress = setFilterIpAddress;
24
+ exports.setIpFiltersUi = setIpFiltersUi;
25
+ exports.setIpFiltersApi = setIpFiltersApi;
26
+ exports.setCalculatorType = setCalculatorType;
27
+
28
+ var _immutable = require("immutable");
29
+
30
+ var _quizCommon = require("@instructure/quiz-common");
31
+
32
+ var _Fetcher = _interopRequireDefault(require("../../common/util/Fetcher.js"));
33
+
34
+ var _qtiImports = require("./qtiImports.js");
35
+
36
+ var _modifications = require("../../common/actions/modifications.js");
37
+
38
+ var _callHandlers = require("../../common/api/callHandlers.js");
39
+
40
+ var _fileUpload = require("../../common/api/fileUpload.js");
41
+
42
+ var _interactionTypes = require("../../common/api/interactionTypes.js");
43
+
44
+ var _quizzes = require("../../common/api/quizzes.js");
45
+
46
+ var config = require('../../config');
47
+
48
+ var quizApiEndpoint = '/api/quizzes'; // ==== CALLBACKS ====
49
+
50
+ var handleQuizFetch = function handleQuizFetch(dispatch, quiz) {
51
+ (0, _quizzes.quizFetchHandler)(dispatch, quiz); // if feature is on, fetch qti import data
52
+
53
+ dispatch((0, _qtiImports.getQTIInfo)(quiz.id));
54
+ }; // ==================
55
+ // ==========================================
56
+ // called by the router when a quiz is needed
57
+ // knows how to create a new quiz, fetch
58
+ // an existing quiz, or set activeId depending
59
+ // on the current state & params
60
+ // ==========================================
61
+
62
+
63
+ function quizBuildingSession(routerParams) {
64
+ return function (dispatch, getState) {
65
+ var contextId = routerParams.contextId;
66
+ var quizId = routerParams.activeQuizId;
67
+ var createNew = routerParams.createNew;
68
+ var needsQuiz = quizId === _quizCommon.NEW_QUIZ_ID || !quizId; // create a new quiz if none exists
69
+
70
+ if (createNew && needsQuiz) {
71
+ return dispatch(startNewQuiz(contextId));
72
+ } // do nothing if already on quiz and questions are loaded
73
+
74
+
75
+ var currentQuizId = getState().getIn(['quizzes', 'activeQuizId']);
76
+ var quizEntries = getState().get('quizEntries', (0, _immutable.Map)());
77
+
78
+ if (currentQuizId === quizId && quizEntries.size > 0) {
79
+ return {
80
+ type: _quizCommon.DO_NOTHING
81
+ };
82
+ }
83
+
84
+ dispatch(getExistingQuizAndItemsForBuilding(quizId));
85
+ };
86
+ } // ====================================
87
+ // save quiz changed, and on success
88
+ // add these changes to the quiz store
89
+ // ====================================
90
+
91
+
92
+ function saveQuizChange(workingQuiz, quiz) {
93
+ if (workingQuiz.equals(quiz)) {
94
+ // cannot just return null since
95
+ // dispatch expects an action
96
+ return {
97
+ type: _quizCommon.DO_NOTHING
98
+ };
99
+ }
100
+
101
+ var url = "".concat(quizApiEndpoint, "/").concat(workingQuiz.get('id'));
102
+ var quizData = JSON.stringify(workingQuiz.validData().toJS());
103
+ return function (dispatch, getState) {
104
+ var params = {
105
+ body: quizData
106
+ };
107
+ var fetcher = new _Fetcher.default({
108
+ callType: _quizCommon.QUIZ_SAVE_CALL
109
+ });
110
+ return fetcher.patch(url, params).then(function (quizData) {
111
+ dispatch((0, _callHandlers.handleQuizResponse)(quizData));
112
+ });
113
+ };
114
+ } // =================================
115
+ // create a new quiz, add its data,
116
+ // and add it as the active quiz
117
+ // =================================
118
+
119
+
120
+ function startNewQuiz(contextId) {
121
+ return function (dispatch, getState) {
122
+ var newQuizData = JSON.stringify({
123
+ title: 'Add Title...',
124
+ context_id: contextId || config.defaultContextId
125
+ });
126
+ var params = {
127
+ body: newQuizData
128
+ };
129
+ var fetcher = new _Fetcher.default();
130
+ return fetcher.post(quizApiEndpoint, params).then(function (quizData) {
131
+ handleQuizFetch(dispatch, quizData);
132
+ }).then(function () {
133
+ dispatch((0, _interactionTypes.interactionTypeFetch)());
134
+ });
135
+ };
136
+ } // ====================================
137
+ // fetch the data for an existing quiz
138
+ // and add it as the active quiz
139
+ // ====================================
140
+
141
+
142
+ function getExistingQuizAndItemsForBuilding(quizId) {
143
+ var fetchTags = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
144
+ // TODO: handleQuizFetch is not handled in getExistingQuizAndItems,
145
+ // so determine impact of getQTIInfo not being dispatched
146
+ return (0, _quizzes.getExistingQuizAndItems)(quizId, fetchTags, handleQuizFetch);
147
+ } // =========================================
148
+ // media upload endpoint funcs
149
+ // =========================================
150
+
151
+
152
+ function getPathToGetUrl(parentType, parentId) {
153
+ switch (parentType) {
154
+ case _quizCommon.PARENT_TYPE_BANK:
155
+ return "/api/banks/".concat(parentId, "/items/media_upload_url");
156
+
157
+ case _quizCommon.PARENT_TYPE_QUIZ:
158
+ return "/api/quizzes/".concat(parentId, "/items/media_upload_url");
159
+
160
+ case _quizCommon.PARENT_TYPE_QUIZ_SESSION:
161
+ return "/api/quiz_sessions/".concat(parentId, "/media_upload_url");
162
+ }
163
+ }
164
+
165
+ function interactionFileUpload(parentType, parentId, file, onSuccess, onError, uploadPath) {
166
+ var withUrlCallback = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : _fileUpload.sendFileToS3;
167
+ return function (dispatch, getState) {
168
+ var pathToGetUrl = uploadPath || getPathToGetUrl(parentType, parentId);
169
+ return (0, _fileUpload.getUploadUrl)(pathToGetUrl).then(withUrlCallback(file, onSuccess, onError));
170
+ };
171
+ } // ====================================
172
+ // update the data for an existing quiz
173
+ // ====================================
174
+
175
+
176
+ function setQuizProperty(quizId, properties, action) {
177
+ var url = "/api/quizzes/".concat(quizId);
178
+ var body = JSON.stringify({
179
+ id: quizId,
180
+ quiz: properties
181
+ });
182
+ return function (dispatch, getState) {
183
+ var params = {
184
+ body: body
185
+ };
186
+ var fetcher = new _Fetcher.default({
187
+ callType: _quizCommon.QUIZ_SAVE_CALL
188
+ });
189
+
190
+ if (action !== null) {
191
+ dispatch(action);
192
+ }
193
+
194
+ return fetcher.patch(url, params).then(function (response) {
195
+ dispatch((0, _callHandlers.handleQuizResponse)(response));
196
+ });
197
+ };
198
+ }
199
+
200
+ function setQuizShuffleQuestions(quizId, value) {
201
+ return setQuizProperty(quizId, {
202
+ shuffle_questions: Boolean(value)
203
+ }, (0, _modifications.changeQuizShuffleQuestions)(quizId, value));
204
+ }
205
+
206
+ function setQuizShuffleAnswers(quizId, value) {
207
+ return setQuizProperty(quizId, {
208
+ shuffle_answers: Boolean(value)
209
+ }, (0, _modifications.changeQuizShuffleAnswers)(quizId, value));
210
+ }
211
+
212
+ function setRequireStudentAccessCode(quizId, value) {
213
+ return setQuizProperty(quizId, {
214
+ require_student_access_code: Boolean(value)
215
+ }, (0, _modifications.changeQuizRequireStudentAccessCode)(quizId, value));
216
+ }
217
+
218
+ function setStudentAccessCodeUi(quizId, value) {
219
+ return function (dispatch, getState) {
220
+ dispatch((0, _modifications.changeQuizStudentAccessCode)(quizId, value));
221
+ };
222
+ }
223
+
224
+ function setStudentAccessCodeApi(quizId, value) {
225
+ return setQuizProperty(quizId, {
226
+ student_access_code: value
227
+ }, null);
228
+ }
229
+
230
+ function setOneAtATimeType(quizId, checked) {
231
+ var oneAtATimeType = checked ? 'question' : null;
232
+ return setQuizProperty(quizId, {
233
+ one_at_a_time_type: oneAtATimeType
234
+ }, (0, _modifications.changeQuizOneAtATimeType)(quizId, oneAtATimeType));
235
+ }
236
+
237
+ function setBacktracking(quizId, value) {
238
+ return setQuizProperty(quizId, {
239
+ allow_backtracking: Boolean(value)
240
+ }, (0, _modifications.changeQuizAllowBacktracking)(quizId, value));
241
+ }
242
+
243
+ function setQuizHasTimeLimit(quizId, value) {
244
+ return setQuizProperty(quizId, {
245
+ has_time_limit: Boolean(value)
246
+ }, (0, _modifications.changeQuizHasTimeLimit)(quizId, value));
247
+ }
248
+
249
+ function setSessionTimeLimitInSecondsUi(quizId, value) {
250
+ return function (dispatch, getState) {
251
+ dispatch((0, _modifications.changeSessionTimeLimitInSeconds)(quizId, value));
252
+ };
253
+ }
254
+
255
+ function setSessionTimeLimitInSecondsApi(quizId, value) {
256
+ return setQuizProperty(quizId, {
257
+ session_time_limit_in_seconds: value
258
+ }, null);
259
+ }
260
+
261
+ function setFilterIpAddress(quizId, value) {
262
+ return setQuizProperty(quizId, {
263
+ filter_ip_address: Boolean(value)
264
+ }, (0, _modifications.changeQuizFilterIpAddress)(quizId, value));
265
+ }
266
+
267
+ function setIpFiltersUi(quizId, value) {
268
+ return function (dispatch, getState) {
269
+ dispatch((0, _modifications.changeQuizIpFilters)(quizId, value));
270
+ };
271
+ }
272
+
273
+ function setIpFiltersApi(quizId, value) {
274
+ return setQuizProperty(quizId, {
275
+ filters: {
276
+ ips: value
277
+ }
278
+ }, null);
279
+ }
280
+
281
+ function setCalculatorType(quizId, value) {
282
+ return setQuizProperty(quizId, {
283
+ calculator_type: value
284
+ }, (0, _modifications.changeQuizCalculatorType)(quizId, value));
285
+ }