@doenet/doenetml 0.6.0-alpha1

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 (549) hide show
  1. package/.prettierrc +3 -0
  2. package/LICENSE +661 -0
  3. package/README.md +146 -0
  4. package/cypress/e2e/ActivityViewer/activityVariants.cy.js +1770 -0
  5. package/cypress/e2e/ActivityViewer/compiledActivity.cy.js +83 -0
  6. package/cypress/e2e/ActivityViewer/relationshipsAmongPages.cy.js +697 -0
  7. package/cypress/e2e/answerValidation/errorinnumbers.cy.js +2125 -0
  8. package/cypress/e2e/answerValidation/factoring.cy.js +1945 -0
  9. package/cypress/e2e/answerValidation/factoringOldAlgorithm.cy.js +892 -0
  10. package/cypress/e2e/answerValidation/functionanswers.cy.js +314 -0
  11. package/cypress/e2e/answerValidation/matchingpatterns.cy.js +287 -0
  12. package/cypress/e2e/answerValidation/matchpartial.cy.js +6711 -0
  13. package/cypress/e2e/answerValidation/pointlocation.cy.js +3989 -0
  14. package/cypress/e2e/answerValidation/symbolicequality.cy.js +1893 -0
  15. package/cypress/e2e/answerValidation/videoProgress.cy.js +210 -0
  16. package/cypress/e2e/assignNames/basiccopy.cy.js +2376 -0
  17. package/cypress/e2e/assignNames/collections.cy.js +9247 -0
  18. package/cypress/e2e/assignNames/selects.cy.js +105 -0
  19. package/cypress/e2e/assignNames/sequences.cy.js +1964 -0
  20. package/cypress/e2e/baseComponent/basecomponentproperties.cy.js +999 -0
  21. package/cypress/e2e/baseComponent/doenetMLtext.cy.js +427 -0
  22. package/cypress/e2e/chemistry/atom.cy.js +201 -0
  23. package/cypress/e2e/chemistry/ion.cy.js +608 -0
  24. package/cypress/e2e/chemistry/ioniccompound.cy.js +133 -0
  25. package/cypress/e2e/dynamicalsystem/cobwebpolyline.cy.js +2653 -0
  26. package/cypress/e2e/dynamicalsystem/equilibriumcurve.cy.js +311 -0
  27. package/cypress/e2e/dynamicalsystem/equilibriumline.cy.js +279 -0
  28. package/cypress/e2e/dynamicalsystem/equilibriumpoint.cy.js +283 -0
  29. package/cypress/e2e/dynamicalsystem/odesystem.cy.js +1834 -0
  30. package/cypress/e2e/equality/mathexpressions.cy.js +948 -0
  31. package/cypress/e2e/graphing/graphreferences.cy.js +978 -0
  32. package/cypress/e2e/graphing/graphreferences2.cy.js +615 -0
  33. package/cypress/e2e/linearAlgebra/eigenDecomposition.cy.js +401 -0
  34. package/cypress/e2e/tagSpecific/angle.cy.js +3898 -0
  35. package/cypress/e2e/tagSpecific/animatefromsequence.cy.js +2306 -0
  36. package/cypress/e2e/tagSpecific/answer.cy.js +31647 -0
  37. package/cypress/e2e/tagSpecific/bestfitline.cy.js +612 -0
  38. package/cypress/e2e/tagSpecific/blockquote.cy.js +30 -0
  39. package/cypress/e2e/tagSpecific/boolean.cy.js +742 -0
  40. package/cypress/e2e/tagSpecific/booleaninput.cy.js +1283 -0
  41. package/cypress/e2e/tagSpecific/booleanlist.cy.js +588 -0
  42. package/cypress/e2e/tagSpecific/booleanoperators.cy.js +596 -0
  43. package/cypress/e2e/tagSpecific/booleanoperatorsonmath.cy.js +498 -0
  44. package/cypress/e2e/tagSpecific/callaction.cy.js +2835 -0
  45. package/cypress/e2e/tagSpecific/choiceinput.cy.js +3205 -0
  46. package/cypress/e2e/tagSpecific/circle.cy.js +22036 -0
  47. package/cypress/e2e/tagSpecific/codeeditor.cy.js +1995 -0
  48. package/cypress/e2e/tagSpecific/collect.cy.js +5035 -0
  49. package/cypress/e2e/tagSpecific/componentsize.cy.js +502 -0
  50. package/cypress/e2e/tagSpecific/conditionalcontent.cy.js +3495 -0
  51. package/cypress/e2e/tagSpecific/contentBrowser.cy.js +335 -0
  52. package/cypress/e2e/tagSpecific/contentpicker.cy.js +261 -0
  53. package/cypress/e2e/tagSpecific/copy.cy.js +12627 -0
  54. package/cypress/e2e/tagSpecific/copy2.cy.js +5698 -0
  55. package/cypress/e2e/tagSpecific/curve.bezier.cy.js +12440 -0
  56. package/cypress/e2e/tagSpecific/curve.cy.js +1716 -0
  57. package/cypress/e2e/tagSpecific/curve.function.cy.js +1471 -0
  58. package/cypress/e2e/tagSpecific/curve.parametrized.cy.js +920 -0
  59. package/cypress/e2e/tagSpecific/document.cy.js +234 -0
  60. package/cypress/e2e/tagSpecific/endpoint.cy.js +197 -0
  61. package/cypress/e2e/tagSpecific/evaluate.cy.js +8895 -0
  62. package/cypress/e2e/tagSpecific/extract.cy.js +2282 -0
  63. package/cypress/e2e/tagSpecific/feedback.cy.js +2941 -0
  64. package/cypress/e2e/tagSpecific/function.cy.js +9450 -0
  65. package/cypress/e2e/tagSpecific/functioniterates.cy.js +1178 -0
  66. package/cypress/e2e/tagSpecific/functionoperators.cy.js +4047 -0
  67. package/cypress/e2e/tagSpecific/graph.cy.js +2491 -0
  68. package/cypress/e2e/tagSpecific/group.cy.js +683 -0
  69. package/cypress/e2e/tagSpecific/hint.cy.js +204 -0
  70. package/cypress/e2e/tagSpecific/image.cy.js +770 -0
  71. package/cypress/e2e/tagSpecific/integer.cy.js +206 -0
  72. package/cypress/e2e/tagSpecific/label.cy.js +800 -0
  73. package/cypress/e2e/tagSpecific/legend.cy.js +1001 -0
  74. package/cypress/e2e/tagSpecific/line.cy.js +12167 -0
  75. package/cypress/e2e/tagSpecific/linesegment.cy.js +4749 -0
  76. package/cypress/e2e/tagSpecific/lorem.cy.js +289 -0
  77. package/cypress/e2e/tagSpecific/map.cy.js +4476 -0
  78. package/cypress/e2e/tagSpecific/matchespattern.cy.js +693 -0
  79. package/cypress/e2e/tagSpecific/math.cy.js +10990 -0
  80. package/cypress/e2e/tagSpecific/mathdisplay.cy.js +2689 -0
  81. package/cypress/e2e/tagSpecific/mathinput.cy.js +15628 -0
  82. package/cypress/e2e/tagSpecific/mathinputgraph.cy.js +566 -0
  83. package/cypress/e2e/tagSpecific/mathlist.cy.js +4073 -0
  84. package/cypress/e2e/tagSpecific/mathoperators.cy.js +13851 -0
  85. package/cypress/e2e/tagSpecific/matrix.cy.js +8825 -0
  86. package/cypress/e2e/tagSpecific/matrixinput.cy.js +16277 -0
  87. package/cypress/e2e/tagSpecific/module.cy.js +1771 -0
  88. package/cypress/e2e/tagSpecific/number.cy.js +2221 -0
  89. package/cypress/e2e/tagSpecific/numberlist.cy.js +1285 -0
  90. package/cypress/e2e/tagSpecific/p.cy.js +72 -0
  91. package/cypress/e2e/tagSpecific/paginator.cy.js +2983 -0
  92. package/cypress/e2e/tagSpecific/parabola.cy.js +14331 -0
  93. package/cypress/e2e/tagSpecific/paragraphmarkup.cy.js +104 -0
  94. package/cypress/e2e/tagSpecific/periodicset.cy.js +1439 -0
  95. package/cypress/e2e/tagSpecific/piecewisefunction.cy.js +1055 -0
  96. package/cypress/e2e/tagSpecific/pluralize.cy.js +274 -0
  97. package/cypress/e2e/tagSpecific/point.cy.js +8895 -0
  98. package/cypress/e2e/tagSpecific/point2.cy.js +10259 -0
  99. package/cypress/e2e/tagSpecific/polygon.cy.js +5039 -0
  100. package/cypress/e2e/tagSpecific/polyline.cy.js +4704 -0
  101. package/cypress/e2e/tagSpecific/problem.cy.js +2768 -0
  102. package/cypress/e2e/tagSpecific/ray.cy.js +10770 -0
  103. package/cypress/e2e/tagSpecific/rectangle.cy.js +2143 -0
  104. package/cypress/e2e/tagSpecific/ref.cy.js +420 -0
  105. package/cypress/e2e/tagSpecific/regularPolygon.cy.js +1006 -0
  106. package/cypress/e2e/tagSpecific/regularPolygon2.cy.js +100 -0
  107. package/cypress/e2e/tagSpecific/regularPolygon3.cy.js +777 -0
  108. package/cypress/e2e/tagSpecific/samplerandomnumbers.cy.js +3619 -0
  109. package/cypress/e2e/tagSpecific/sectioning.cy.js +3530 -0
  110. package/cypress/e2e/tagSpecific/select.cy.js +5376 -0
  111. package/cypress/e2e/tagSpecific/selectfromsequence.cy.js +3846 -0
  112. package/cypress/e2e/tagSpecific/selectrandomnumbers.cy.js +2914 -0
  113. package/cypress/e2e/tagSpecific/sequence.cy.js +2093 -0
  114. package/cypress/e2e/tagSpecific/shuffle.cy.js +490 -0
  115. package/cypress/e2e/tagSpecific/sidebyside.cy.js +8057 -0
  116. package/cypress/e2e/tagSpecific/singlecharactercomponents.cy.js +72 -0
  117. package/cypress/e2e/tagSpecific/slider.cy.js +914 -0
  118. package/cypress/e2e/tagSpecific/solution.cy.js +109 -0
  119. package/cypress/e2e/tagSpecific/solveequations.cy.js +1026 -0
  120. package/cypress/e2e/tagSpecific/sort.cy.js +1685 -0
  121. package/cypress/e2e/tagSpecific/spreadsheet.cy.js +5971 -0
  122. package/cypress/e2e/tagSpecific/subsetofreals.cy.js +2725 -0
  123. package/cypress/e2e/tagSpecific/substitute.cy.js +2646 -0
  124. package/cypress/e2e/tagSpecific/tabular.cy.js +36 -0
  125. package/cypress/e2e/tagSpecific/text.cy.js +975 -0
  126. package/cypress/e2e/tagSpecific/textinput.cy.js +2177 -0
  127. package/cypress/e2e/tagSpecific/textlist.cy.js +369 -0
  128. package/cypress/e2e/tagSpecific/triangle.cy.js +1936 -0
  129. package/cypress/e2e/tagSpecific/triggerset.cy.js +2023 -0
  130. package/cypress/e2e/tagSpecific/updatevalue.cy.js +3288 -0
  131. package/cypress/e2e/tagSpecific/vector.cy.js +20183 -0
  132. package/cypress/e2e/tagSpecific/video.cy.js +612 -0
  133. package/cypress/e2e/tagSpecific/when.cy.js +202 -0
  134. package/cypress/e2e/variants/specifysinglevariant.cy.js +6726 -0
  135. package/cypress/e2e/variants/uniquevariants.cy.js +4846 -0
  136. package/cypress/fixtures/example.json +5 -0
  137. package/cypress/support/commands.js +32 -0
  138. package/cypress/support/e2e.js +31 -0
  139. package/cypress.config.js +18 -0
  140. package/docs/codeSnippet.jsx +11 -0
  141. package/docs/index.html +133 -0
  142. package/docs/index.jsx +138 -0
  143. package/docs/prism.css +3 -0
  144. package/index.html +14 -0
  145. package/index.js +21 -0
  146. package/media/answer_example.png +0 -0
  147. package/media/graph_example.png +0 -0
  148. package/media/graph_markup_example.png +0 -0
  149. package/package.json +83 -0
  150. package/public/favicon.ico +0 -0
  151. package/public/fonts/files/open-sans-v18-latin-700.woff +0 -0
  152. package/public/fonts/files/open-sans-v18-latin-700.woff2 +0 -0
  153. package/public/fonts/files/open-sans-v18-latin-700italic.woff +0 -0
  154. package/public/fonts/files/open-sans-v18-latin-700italic.woff2 +0 -0
  155. package/public/fonts/files/open-sans-v18-latin-italic.woff +0 -0
  156. package/public/fonts/files/open-sans-v18-latin-italic.woff2 +0 -0
  157. package/public/fonts/files/open-sans-v18-latin-light-italic.woff +0 -0
  158. package/public/fonts/files/open-sans-v18-latin-light-italic.woff2 +0 -0
  159. package/public/fonts/files/open-sans-v18-latin-light.woff +0 -0
  160. package/public/fonts/files/open-sans-v18-latin-light.woff2 +0 -0
  161. package/public/fonts/files/open-sans-v18-latin-regular.woff +0 -0
  162. package/public/fonts/files/open-sans-v18-latin-regular.woff2 +0 -0
  163. package/src/Core/ComponentTypes.js +426 -0
  164. package/src/Core/Core.js +11852 -0
  165. package/src/Core/CoreWorker.js +127 -0
  166. package/src/Core/Dependencies.js +8226 -0
  167. package/src/Core/Numerics.js +473 -0
  168. package/src/Core/ParameterStack.js +36 -0
  169. package/src/Core/ReadOnlyProxyHandler.js +41 -0
  170. package/src/Core/StateProxyHandler.js +88 -0
  171. package/src/Core/components/Aliases.js +67 -0
  172. package/src/Core/components/Angle.js +758 -0
  173. package/src/Core/components/AnimateFromSequence.js +922 -0
  174. package/src/Core/components/Answer.js +2087 -0
  175. package/src/Core/components/AsList.js +83 -0
  176. package/src/Core/components/AttractTo.js +245 -0
  177. package/src/Core/components/AttractToAngles.js +262 -0
  178. package/src/Core/components/AttractToConstraint.js +104 -0
  179. package/src/Core/components/AttractToGrid.js +315 -0
  180. package/src/Core/components/Award.js +906 -0
  181. package/src/Core/components/BestFitLine.js +318 -0
  182. package/src/Core/components/BezierControls.js +719 -0
  183. package/src/Core/components/BlockQuote.js +35 -0
  184. package/src/Core/components/Boolean.js +500 -0
  185. package/src/Core/components/BooleanInput.js +330 -0
  186. package/src/Core/components/BooleanList.js +396 -0
  187. package/src/Core/components/BooleanOperators.js +35 -0
  188. package/src/Core/components/BooleanOperatorsOfMath.js +148 -0
  189. package/src/Core/components/CallAction.js +261 -0
  190. package/src/Core/components/Caption.js +73 -0
  191. package/src/Core/components/Case.js +56 -0
  192. package/src/Core/components/Cell.js +439 -0
  193. package/src/Core/components/CellBlock.js +64 -0
  194. package/src/Core/components/Chart.js +795 -0
  195. package/src/Core/components/Choice.js +266 -0
  196. package/src/Core/components/ChoiceInput.js +1407 -0
  197. package/src/Core/components/Circle.js +2884 -0
  198. package/src/Core/components/CodeEditor.js +647 -0
  199. package/src/Core/components/CodeViewer.js +294 -0
  200. package/src/Core/components/CollaborateGroupSetup.js +46 -0
  201. package/src/Core/components/CollaborateGroups.js +119 -0
  202. package/src/Core/components/Collect.js +850 -0
  203. package/src/Core/components/Column.js +608 -0
  204. package/src/Core/components/ConditionalContent.js +468 -0
  205. package/src/Core/components/ConsiderAsResponses.js +49 -0
  206. package/src/Core/components/ConstrainTo.js +161 -0
  207. package/src/Core/components/ConstrainToAngles.js +244 -0
  208. package/src/Core/components/ConstrainToGraph.js +142 -0
  209. package/src/Core/components/ConstrainToGrid.js +175 -0
  210. package/src/Core/components/ConstraintUnion.js +119 -0
  211. package/src/Core/components/Constraints.js +497 -0
  212. package/src/Core/components/ContentBrowser.js +441 -0
  213. package/src/Core/components/ContentPicker.js +263 -0
  214. package/src/Core/components/ControlVectors.js +25 -0
  215. package/src/Core/components/Coords.js +63 -0
  216. package/src/Core/components/Copy.js +3412 -0
  217. package/src/Core/components/Curve.js +4130 -0
  218. package/src/Core/components/CustomAttribute.js +175 -0
  219. package/src/Core/components/DataFrame.js +357 -0
  220. package/src/Core/components/DiscreteSimulationResultList.js +342 -0
  221. package/src/Core/components/DiscreteSimulationResultPolyline.js +581 -0
  222. package/src/Core/components/Divisions.js +55 -0
  223. package/src/Core/components/Document.js +888 -0
  224. package/src/Core/components/Embed.js +65 -0
  225. package/src/Core/components/Endpoint.js +62 -0
  226. package/src/Core/components/Evaluate.js +321 -0
  227. package/src/Core/components/Extract.js +656 -0
  228. package/src/Core/components/Extrema.js +556 -0
  229. package/src/Core/components/Feedback.js +200 -0
  230. package/src/Core/components/FeedbackDefinitions.js +97 -0
  231. package/src/Core/components/Figure.js +148 -0
  232. package/src/Core/components/Footnote.js +73 -0
  233. package/src/Core/components/Function.js +5344 -0
  234. package/src/Core/components/FunctionIterates.js +306 -0
  235. package/src/Core/components/FunctionOperators.js +702 -0
  236. package/src/Core/components/Graph.js +1679 -0
  237. package/src/Core/components/Group.js +7 -0
  238. package/src/Core/components/HasSameFactoring.js +407 -0
  239. package/src/Core/components/Hint.js +241 -0
  240. package/src/Core/components/Image.js +524 -0
  241. package/src/Core/components/Indexing.js +79 -0
  242. package/src/Core/components/IntComma.js +64 -0
  243. package/src/Core/components/Integer.js +81 -0
  244. package/src/Core/components/Intersection.js +328 -0
  245. package/src/Core/components/Interval.js +29 -0
  246. package/src/Core/components/Label.js +492 -0
  247. package/src/Core/components/Latex.js +104 -0
  248. package/src/Core/components/Legend.js +329 -0
  249. package/src/Core/components/Line.js +2040 -0
  250. package/src/Core/components/LineSegment.js +882 -0
  251. package/src/Core/components/Lists.js +180 -0
  252. package/src/Core/components/Lorem.js +249 -0
  253. package/src/Core/components/MMeMen.js +377 -0
  254. package/src/Core/components/Map.js +873 -0
  255. package/src/Core/components/Markers.js +101 -0
  256. package/src/Core/components/MatchesPattern.js +339 -0
  257. package/src/Core/components/Math.js +2552 -0
  258. package/src/Core/components/MathInput.js +948 -0
  259. package/src/Core/components/MathList.js +828 -0
  260. package/src/Core/components/MathOperators.js +1286 -0
  261. package/src/Core/components/Matrix.js +497 -0
  262. package/src/Core/components/MatrixInput.js +3157 -0
  263. package/src/Core/components/MdMdnMrow.js +394 -0
  264. package/src/Core/components/Module.js +16 -0
  265. package/src/Core/components/Number.js +1031 -0
  266. package/src/Core/components/NumberList.js +550 -0
  267. package/src/Core/components/Option.js +24 -0
  268. package/src/Core/components/P.js +71 -0
  269. package/src/Core/components/Paginator.js +338 -0
  270. package/src/Core/components/Panel.js +126 -0
  271. package/src/Core/components/Parabola.js +1561 -0
  272. package/src/Core/components/ParagraphMarkup.js +59 -0
  273. package/src/Core/components/Pegboard.js +43 -0
  274. package/src/Core/components/PeriodicSet.js +291 -0
  275. package/src/Core/components/PiecewiseFunction.js +832 -0
  276. package/src/Core/components/Pluralize.js +198 -0
  277. package/src/Core/components/Point.js +1295 -0
  278. package/src/Core/components/Polygon.js +408 -0
  279. package/src/Core/components/Polyline.js +841 -0
  280. package/src/Core/components/RandomizedTextList.js +225 -0
  281. package/src/Core/components/Ray.js +1737 -0
  282. package/src/Core/components/Rectangle.js +1535 -0
  283. package/src/Core/components/Ref.js +350 -0
  284. package/src/Core/components/RegionBetweenCurveXAxis.js +124 -0
  285. package/src/Core/components/RegionHalfPlane.js +107 -0
  286. package/src/Core/components/RegularPolygon.js +2118 -0
  287. package/src/Core/components/RenderDoenetML.js +181 -0
  288. package/src/Core/components/Row.js +780 -0
  289. package/src/Core/components/SampleRandomNumbers.js +653 -0
  290. package/src/Core/components/Sectioning.js +303 -0
  291. package/src/Core/components/Select.js +947 -0
  292. package/src/Core/components/SelectFromSequence.js +1242 -0
  293. package/src/Core/components/SelectRandomNumbers.js +225 -0
  294. package/src/Core/components/Sequence.js +444 -0
  295. package/src/Core/components/Setup.js +53 -0
  296. package/src/Core/components/Shuffle.js +470 -0
  297. package/src/Core/components/SideBySide.js +2130 -0
  298. package/src/Core/components/SingleCharacterComponents.js +41 -0
  299. package/src/Core/components/Slider.js +819 -0
  300. package/src/Core/components/SolutionContainer.js +67 -0
  301. package/src/Core/components/Solutions.js +334 -0
  302. package/src/Core/components/SolveEquations.js +568 -0
  303. package/src/Core/components/Sort.js +398 -0
  304. package/src/Core/components/Sources.js +108 -0
  305. package/src/Core/components/Split.js +205 -0
  306. package/src/Core/components/Spreadsheet.js +1507 -0
  307. package/src/Core/components/StyleDefinitions.js +111 -0
  308. package/src/Core/components/SubsetOfReals.js +348 -0
  309. package/src/Core/components/SubsetOfRealsInput.js +1474 -0
  310. package/src/Core/components/Substitute.js +496 -0
  311. package/src/Core/components/SummaryStatistics.js +652 -0
  312. package/src/Core/components/Table.js +145 -0
  313. package/src/Core/components/Tabular.js +384 -0
  314. package/src/Core/components/Template.js +360 -0
  315. package/src/Core/components/Text.js +341 -0
  316. package/src/Core/components/TextInput.js +566 -0
  317. package/src/Core/components/TextList.js +442 -0
  318. package/src/Core/components/TextListFromString.js +137 -0
  319. package/src/Core/components/TextOperatorsOfMath.js +21 -0
  320. package/src/Core/components/Triangle.js +280 -0
  321. package/src/Core/components/TriggerSet.js +189 -0
  322. package/src/Core/components/TupleList.js +43 -0
  323. package/src/Core/components/UpdateValue.js +435 -0
  324. package/src/Core/components/VariantControl.js +36 -0
  325. package/src/Core/components/Vector.js +2478 -0
  326. package/src/Core/components/Verbatim.js +125 -0
  327. package/src/Core/components/Video.js +673 -0
  328. package/src/Core/components/When.js +198 -0
  329. package/src/Core/components/abstract/AngleListComponent.js +140 -0
  330. package/src/Core/components/abstract/BaseComponent.js +1496 -0
  331. package/src/Core/components/abstract/BlockComponent.js +5 -0
  332. package/src/Core/components/abstract/BooleanBaseOperator.js +88 -0
  333. package/src/Core/components/abstract/BooleanBaseOperatorOfMath.js +100 -0
  334. package/src/Core/components/abstract/BooleanBaseOperatorOneInput.js +44 -0
  335. package/src/Core/components/abstract/ComponentSize.js +789 -0
  336. package/src/Core/components/abstract/ComponentWithSelectableType.js +537 -0
  337. package/src/Core/components/abstract/CompositeComponent.js +142 -0
  338. package/src/Core/components/abstract/ConstraintComponent.js +19 -0
  339. package/src/Core/components/abstract/FunctionBaseOperator.js +680 -0
  340. package/src/Core/components/abstract/GraphicalComponent.js +56 -0
  341. package/src/Core/components/abstract/InlineComponent.js +5 -0
  342. package/src/Core/components/abstract/InlineRenderInlineChildren.js +63 -0
  343. package/src/Core/components/abstract/Input.js +192 -0
  344. package/src/Core/components/abstract/IntervalListComponent.js +218 -0
  345. package/src/Core/components/abstract/LineListComponent.js +114 -0
  346. package/src/Core/components/abstract/MathBaseOperator.js +631 -0
  347. package/src/Core/components/abstract/MathBaseOperatorOneInput.js +112 -0
  348. package/src/Core/components/abstract/PointListComponent.js +238 -0
  349. package/src/Core/components/abstract/SectioningComponent.js +1262 -0
  350. package/src/Core/components/abstract/SingleCharacterInline.js +23 -0
  351. package/src/Core/components/abstract/TextBaseOperatorOfMath.js +47 -0
  352. package/src/Core/components/abstract/TextOrInline.js +66 -0
  353. package/src/Core/components/abstract/VariableName.js +31 -0
  354. package/src/Core/components/abstract/VariableNameList.js +83 -0
  355. package/src/Core/components/abstract/VectorListComponent.js +235 -0
  356. package/src/Core/components/chemistry/Atom.js +910 -0
  357. package/src/Core/components/chemistry/ElectronConfiguration.js +36 -0
  358. package/src/Core/components/chemistry/Ion.js +684 -0
  359. package/src/Core/components/chemistry/IonicCompound.js +189 -0
  360. package/src/Core/components/chemistry/OrbitalDiagram.js +175 -0
  361. package/src/Core/components/chemistry/OrbitalDiagramInput.js +753 -0
  362. package/src/Core/components/chemistry/index.js +6 -0
  363. package/src/Core/components/commonsugar/breakstrings.js +627 -0
  364. package/src/Core/components/commonsugar/lists.js +177 -0
  365. package/src/Core/components/dynamicalSystems/CobwebPolyline.js +913 -0
  366. package/src/Core/components/dynamicalSystems/EquilibriumCurve.js +95 -0
  367. package/src/Core/components/dynamicalSystems/EquilibriumLine.js +93 -0
  368. package/src/Core/components/dynamicalSystems/EquilibriumPoint.js +93 -0
  369. package/src/Core/components/dynamicalSystems/ODESystem.js +943 -0
  370. package/src/Core/components/dynamicalSystems/index.js +5 -0
  371. package/src/Core/components/linearAlgebra/EigenDecomposition.js +294 -0
  372. package/src/Core/utils/array.js +30 -0
  373. package/src/Core/utils/booleanLogic.js +965 -0
  374. package/src/Core/utils/checkEquality.js +818 -0
  375. package/src/Core/utils/cid.js +29 -0
  376. package/src/Core/utils/componentInfoObjects.js +100 -0
  377. package/src/Core/utils/constraints.js +23 -0
  378. package/src/Core/utils/copy.js +572 -0
  379. package/src/Core/utils/deepFunctions.js +173 -0
  380. package/src/Core/utils/descendants.js +252 -0
  381. package/src/Core/utils/enumeration.js +234 -0
  382. package/src/Core/utils/feedback.js +84 -0
  383. package/src/Core/utils/function.js +1343 -0
  384. package/src/Core/utils/graphical.js +196 -0
  385. package/src/Core/utils/label.js +396 -0
  386. package/src/Core/utils/math.js +1056 -0
  387. package/src/Core/utils/naming.js +45 -0
  388. package/src/Core/utils/periodicSetEquality.js +403 -0
  389. package/src/Core/utils/randomNumbers.js +70 -0
  390. package/src/Core/utils/retrieveMedia.js +98 -0
  391. package/src/Core/utils/retrieveTextFile.js +140 -0
  392. package/src/Core/utils/returnAllPossibleVariants.js +73 -0
  393. package/src/Core/utils/rounding.js +316 -0
  394. package/src/Core/utils/sequence.js +754 -0
  395. package/src/Core/utils/serializedStateProcessing.js +4049 -0
  396. package/src/Core/utils/size.js +22 -0
  397. package/src/Core/utils/stateVariables.js +138 -0
  398. package/src/Core/utils/style.js +535 -0
  399. package/src/Core/utils/subset-of-reals.js +796 -0
  400. package/src/Core/utils/table.js +41 -0
  401. package/src/Core/utils/text.js +16 -0
  402. package/src/Core/utils/triggering.js +167 -0
  403. package/src/Core/utils/variants.js +477 -0
  404. package/src/DoenetML.css +308 -0
  405. package/src/DoenetML.jsx +201 -0
  406. package/src/Parser/doenet.grammar +90 -0
  407. package/src/Parser/doenet.js +33 -0
  408. package/src/Parser/doenet.terms.js +20 -0
  409. package/src/Parser/parser.js +266 -0
  410. package/src/Parser/tokens.js +129 -0
  411. package/src/Tools/CodeMirror.jsx +440 -0
  412. package/src/Tools/DarkmodeController.jsx +21 -0
  413. package/src/Tools/Footers/MathInputSelector.jsx +34 -0
  414. package/src/Tools/Footers/VirtualKeyboard.jsx +751 -0
  415. package/src/Tools/cypressTest/CypressTest.jsx +341 -0
  416. package/src/Tools/cypressTest/index.html +102 -0
  417. package/src/Tools/cypressTest/index.jsx +40 -0
  418. package/src/Viewer/ActivityViewer.jsx +1461 -0
  419. package/src/Viewer/PageViewer.jsx +1329 -0
  420. package/src/Viewer/renderers/alert.jsx +17 -0
  421. package/src/Viewer/renderers/angle.jsx +209 -0
  422. package/src/Viewer/renderers/answer.jsx +206 -0
  423. package/src/Viewer/renderers/asList.jsx +25 -0
  424. package/src/Viewer/renderers/blockQuote.jsx +41 -0
  425. package/src/Viewer/renderers/boolean.jsx +17 -0
  426. package/src/Viewer/renderers/booleanInput.css +105 -0
  427. package/src/Viewer/renderers/booleanInput.jsx +636 -0
  428. package/src/Viewer/renderers/button.jsx +369 -0
  429. package/src/Viewer/renderers/c.jsx +17 -0
  430. package/src/Viewer/renderers/callAction.jsx +18 -0
  431. package/src/Viewer/renderers/cell.jsx +59 -0
  432. package/src/Viewer/renderers/chart.jsx +83 -0
  433. package/src/Viewer/renderers/choiceInput.css +223 -0
  434. package/src/Viewer/renderers/choiceInput.jsx +535 -0
  435. package/src/Viewer/renderers/circle.jsx +990 -0
  436. package/src/Viewer/renderers/cobwebPolyline.jsx +442 -0
  437. package/src/Viewer/renderers/codeEditor.jsx +248 -0
  438. package/src/Viewer/renderers/codeViewer.jsx +105 -0
  439. package/src/Viewer/renderers/containerBlock.jsx +41 -0
  440. package/src/Viewer/renderers/containerInline.jsx +17 -0
  441. package/src/Viewer/renderers/contentBrowser.jsx +159 -0
  442. package/src/Viewer/renderers/contentPicker.jsx +160 -0
  443. package/src/Viewer/renderers/curve.jsx +1072 -0
  444. package/src/Viewer/renderers/ellipsis.jsx +17 -0
  445. package/src/Viewer/renderers/em.jsx +17 -0
  446. package/src/Viewer/renderers/embed.jsx +110 -0
  447. package/src/Viewer/renderers/feedback.jsx +74 -0
  448. package/src/Viewer/renderers/figure.jsx +131 -0
  449. package/src/Viewer/renderers/footnote.jsx +52 -0
  450. package/src/Viewer/renderers/graph.jsx +925 -0
  451. package/src/Viewer/renderers/hint.jsx +142 -0
  452. package/src/Viewer/renderers/image.jsx +581 -0
  453. package/src/Viewer/renderers/jsxgraph-distrib/jsxgraphcore.mjs +2 -0
  454. package/src/Viewer/renderers/jsxgraph-distrib/jsxgraphcore.mjs.map +1 -0
  455. package/src/Viewer/renderers/label.jsx +470 -0
  456. package/src/Viewer/renderers/legend.jsx +306 -0
  457. package/src/Viewer/renderers/line.jsx +511 -0
  458. package/src/Viewer/renderers/lineSegment.jsx +754 -0
  459. package/src/Viewer/renderers/list.jsx +111 -0
  460. package/src/Viewer/renderers/lq.jsx +12 -0
  461. package/src/Viewer/renderers/lsq.jsx +12 -0
  462. package/src/Viewer/renderers/math.jsx +582 -0
  463. package/src/Viewer/renderers/mathInput.css +10 -0
  464. package/src/Viewer/renderers/mathInput.jsx +425 -0
  465. package/src/Viewer/renderers/mathInputog.jsx +534 -0
  466. package/src/Viewer/renderers/mathList.jsx +39 -0
  467. package/src/Viewer/renderers/matrixInput.jsx +317 -0
  468. package/src/Viewer/renderers/mdash.jsx +12 -0
  469. package/src/Viewer/renderers/nbsp.jsx +12 -0
  470. package/src/Viewer/renderers/ndash.jsx +12 -0
  471. package/src/Viewer/renderers/number.jsx +454 -0
  472. package/src/Viewer/renderers/numberList.jsx +35 -0
  473. package/src/Viewer/renderers/orbitalDiagram.jsx +247 -0
  474. package/src/Viewer/renderers/orbitalDiagramInput.jsx +450 -0
  475. package/src/Viewer/renderers/p.jsx +38 -0
  476. package/src/Viewer/renderers/paginatorControls.jsx +41 -0
  477. package/src/Viewer/renderers/pegboard.jsx +239 -0
  478. package/src/Viewer/renderers/point.jsx +649 -0
  479. package/src/Viewer/renderers/polygon.jsx +612 -0
  480. package/src/Viewer/renderers/polyline.jsx +608 -0
  481. package/src/Viewer/renderers/pre.jsx +34 -0
  482. package/src/Viewer/renderers/q.jsx +17 -0
  483. package/src/Viewer/renderers/ray.jsx +410 -0
  484. package/src/Viewer/renderers/ref.jsx +149 -0
  485. package/src/Viewer/renderers/regionBetweenCurveXAxis.jsx +182 -0
  486. package/src/Viewer/renderers/renderDoenetML.jsx +56 -0
  487. package/src/Viewer/renderers/row.jsx +31 -0
  488. package/src/Viewer/renderers/rq.jsx +12 -0
  489. package/src/Viewer/renderers/rsq.jsx +12 -0
  490. package/src/Viewer/renderers/section.jsx +427 -0
  491. package/src/Viewer/renderers/sideBySide.jsx +80 -0
  492. package/src/Viewer/renderers/slider.jsx +800 -0
  493. package/src/Viewer/renderers/solution.jsx +134 -0
  494. package/src/Viewer/renderers/spreadsheet.jsx +83 -0
  495. package/src/Viewer/renderers/sq.jsx +17 -0
  496. package/src/Viewer/renderers/styles/global.css +14 -0
  497. package/src/Viewer/renderers/subsetOfRealsInput.jsx +392 -0
  498. package/src/Viewer/renderers/summaryStatistics.jsx +83 -0
  499. package/src/Viewer/renderers/table.jsx +78 -0
  500. package/src/Viewer/renderers/tabular.jsx +58 -0
  501. package/src/Viewer/renderers/tag.jsx +26 -0
  502. package/src/Viewer/renderers/text.jsx +439 -0
  503. package/src/Viewer/renderers/textInput.jsx +774 -0
  504. package/src/Viewer/renderers/textList.jsx +30 -0
  505. package/src/Viewer/renderers/triggerSet.jsx +52 -0
  506. package/src/Viewer/renderers/updateValue.jsx +30 -0
  507. package/src/Viewer/renderers/utils/css.js +13 -0
  508. package/src/Viewer/renderers/utils/graph.js +159 -0
  509. package/src/Viewer/renderers/utils/offGraphIndicators.js +91 -0
  510. package/src/Viewer/renderers/vector.jsx +678 -0
  511. package/src/Viewer/renderers/video.jsx +494 -0
  512. package/src/Viewer/useDoenetRenderer.jsx +128 -0
  513. package/src/main.jsx +16 -0
  514. package/src/media/fonts/files/open-sans-v18-latin-700.woff +0 -0
  515. package/src/media/fonts/files/open-sans-v18-latin-700.woff2 +0 -0
  516. package/src/media/fonts/files/open-sans-v18-latin-700italic.woff +0 -0
  517. package/src/media/fonts/files/open-sans-v18-latin-700italic.woff2 +0 -0
  518. package/src/media/fonts/files/open-sans-v18-latin-italic.woff +0 -0
  519. package/src/media/fonts/files/open-sans-v18-latin-italic.woff2 +0 -0
  520. package/src/media/fonts/files/open-sans-v18-latin-light-italic.woff +0 -0
  521. package/src/media/fonts/files/open-sans-v18-latin-light-italic.woff2 +0 -0
  522. package/src/media/fonts/files/open-sans-v18-latin-light.woff +0 -0
  523. package/src/media/fonts/files/open-sans-v18-latin-light.woff2 +0 -0
  524. package/src/media/fonts/files/open-sans-v18-latin-regular.woff +0 -0
  525. package/src/media/fonts/files/open-sans-v18-latin-regular.woff2 +0 -0
  526. package/src/test/testCode.doenet +26 -0
  527. package/src/test/testViewer.jsx +158 -0
  528. package/src/uiComponents/ActionButton.jsx +157 -0
  529. package/src/uiComponents/ActionButtonGroup.jsx +93 -0
  530. package/src/uiComponents/Button.jsx +160 -0
  531. package/src/uiComponents/ButtonGroup.jsx +56 -0
  532. package/src/uiComponents/ToggleButton.jsx +194 -0
  533. package/src/uiComponents/ToggleButtonGroup.jsx +77 -0
  534. package/src/utils/activityUtils.js +713 -0
  535. package/src/utils/array.js +17 -0
  536. package/src/utils/cid.js +34 -0
  537. package/src/utils/componentInfoObjects.js +89 -0
  538. package/src/utils/deepFunctions.js +165 -0
  539. package/src/utils/enumeration.js +226 -0
  540. package/src/utils/math.js +624 -0
  541. package/src/utils/naming.js +44 -0
  542. package/src/utils/retrieveTextFile.js +156 -0
  543. package/src/utils/returnAllPossibleVariants.js +81 -0
  544. package/src/utils/sequence.js +715 -0
  545. package/src/utils/serialize.js +29 -0
  546. package/src/utils/serializedStateProcessing.js +2587 -0
  547. package/src/utils/subset-of-reals.js +783 -0
  548. package/src/utils/url.js +19 -0
  549. package/vite.config.js +14 -0
@@ -0,0 +1,2914 @@
1
+ import me from "math-expressions";
2
+ import { cesc } from "../../../../src/utils/url";
3
+
4
+ describe("SelectRandomNumbers Tag Tests", function () {
5
+ beforeEach(() => {
6
+ cy.clearIndexedDB();
7
+ cy.visit("/src/Tools/cypressTest/");
8
+ });
9
+
10
+ it("no parameters, select single uniform random number from 0 to 1", () => {
11
+ cy.window().then(async (win) => {
12
+ win.postMessage(
13
+ {
14
+ doenetML: `
15
+ <text>a</text>
16
+ <p><aslist>
17
+ <map>
18
+ <template><selectrandomnumbers/></template>
19
+ <sources><sequence length="100" /></sources>
20
+ </map>
21
+ </aslist></p>
22
+
23
+ <p><aslist>
24
+ <copy target="_map1" />
25
+ </aslist></p>
26
+
27
+ <copy target="_p1" assignNames = "p" />
28
+ `,
29
+ },
30
+ "*",
31
+ );
32
+ });
33
+
34
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
35
+
36
+ cy.window().then(async (win) => {
37
+ let stateVariables = await win.returnAllStateVariables1();
38
+
39
+ let samples = stateVariables["/_map1"].replacements.map(
40
+ (x) =>
41
+ stateVariables[
42
+ stateVariables[
43
+ stateVariables[x.componentName].replacements[0].componentName
44
+ ].replacements[0].componentName
45
+ ].stateValues.value,
46
+ );
47
+
48
+ expect(samples.length).eq(100);
49
+
50
+ for (let sample of samples) {
51
+ expect(sample).gt(0);
52
+ expect(sample).lte(1);
53
+ }
54
+
55
+ let meanX = me.math.mean(samples);
56
+ let varX = me.math.variance(samples, "uncorrected");
57
+
58
+ expect(meanX).closeTo(0.5, 0.05);
59
+ expect(varX).closeTo(1 / 12, 0.02);
60
+
61
+ let firstSelect =
62
+ stateVariables[
63
+ stateVariables[stateVariables["/_map1"].replacements[0].componentName]
64
+ .replacements[0].componentName
65
+ ];
66
+ expect(firstSelect.stateValues.mean).closeTo(0.5, 1e-10);
67
+ expect(firstSelect.stateValues.variance).closeTo(1 / 12, 1e-10);
68
+ expect(firstSelect.stateValues.standardDeviation).closeTo(
69
+ Math.sqrt(1 / 12),
70
+ 1e-10,
71
+ );
72
+
73
+ let copiedSamples = stateVariables["/_copy1"].replacements.map(
74
+ (x) =>
75
+ stateVariables[
76
+ stateVariables[
77
+ stateVariables[x.componentName].replacements[0].componentName
78
+ ].replacements[0].componentName
79
+ ].stateValues.value,
80
+ );
81
+ expect(copiedSamples).eqls(samples);
82
+
83
+ let copiedCopiedSamples = stateVariables[
84
+ stateVariables["/p"].activeChildren[0].componentName
85
+ ].activeChildren.map(
86
+ (x) => stateVariables[x.componentName].stateValues.value,
87
+ );
88
+ expect(copiedCopiedSamples).eqls(samples);
89
+ });
90
+ });
91
+
92
+ it("select five uniform random numbers from 0 to 8, only to specified", () => {
93
+ cy.window().then(async (win) => {
94
+ win.postMessage(
95
+ {
96
+ doenetML: `
97
+ <text>a</text>
98
+ <p><aslist>
99
+ <map>
100
+ <template><selectrandomnumbers type="uniform" numToSelect="5" to="8" /></template>
101
+ <sources><sequence length="20" /></sources>
102
+ </map>
103
+ </aslist></p>
104
+
105
+ <p><aslist>
106
+ <copy target="_map1" />
107
+ </aslist></p>
108
+
109
+ <copy target="_p1" assignNames = "p" />
110
+ `,
111
+ },
112
+ "*",
113
+ );
114
+ });
115
+
116
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
117
+
118
+ cy.window().then(async (win) => {
119
+ let stateVariables = await win.returnAllStateVariables1();
120
+
121
+ let samples = stateVariables["/_map1"].replacements.reduce(
122
+ (a, c) => [
123
+ ...a,
124
+ ...stateVariables[
125
+ stateVariables[c.componentName].replacements[0].componentName
126
+ ].replacements.map(
127
+ (y) => stateVariables[y.componentName].stateValues.value,
128
+ ),
129
+ ],
130
+ [],
131
+ );
132
+ expect(samples.length).eq(100);
133
+
134
+ for (let sample of samples) {
135
+ expect(sample).gt(0);
136
+ expect(sample).lte(8);
137
+ }
138
+
139
+ let meanX = me.math.mean(samples);
140
+ let varX = me.math.variance(samples, "uncorrected");
141
+
142
+ expect(meanX).closeTo(4, 0.5);
143
+ expect(varX).closeTo(8 ** 2 / 12, 1);
144
+
145
+ let firstSelect =
146
+ stateVariables[
147
+ stateVariables[stateVariables["/_map1"].replacements[0].componentName]
148
+ .replacements[0].componentName
149
+ ];
150
+ expect(firstSelect.stateValues.mean).closeTo(4, 1e-10);
151
+ expect(firstSelect.stateValues.variance).closeTo(8 ** 2 / 12, 1e-10);
152
+ expect(firstSelect.stateValues.standardDeviation).closeTo(
153
+ Math.sqrt(8 ** 2 / 12),
154
+ 1e-10,
155
+ );
156
+
157
+ let copiedSamples = stateVariables["/_copy1"].replacements.reduce(
158
+ (a, c) => [
159
+ ...a,
160
+ ...stateVariables[
161
+ stateVariables[c.componentName].replacements[0].componentName
162
+ ].replacements.map(
163
+ (y) => stateVariables[y.componentName].stateValues.value,
164
+ ),
165
+ ],
166
+ [],
167
+ );
168
+ expect(copiedSamples).eqls(samples);
169
+
170
+ let copiedCopiedSamples = stateVariables[
171
+ stateVariables["/p"].activeChildren[0].componentName
172
+ ].activeChildren.map(
173
+ (x) => stateVariables[x.componentName].stateValues.value,
174
+ );
175
+ expect(copiedCopiedSamples).eqls(samples);
176
+ });
177
+ });
178
+
179
+ it("select five uniform random numbers from -5 to -4, only from specified", () => {
180
+ cy.window().then(async (win) => {
181
+ win.postMessage(
182
+ {
183
+ doenetML: `
184
+ <text>a</text>
185
+ <p><aslist>
186
+ <map>
187
+ <template><selectrandomnumbers type="uniform" numToSelect="5" from="-5" /></template>
188
+ <sources><sequence length="20" /></sources>
189
+ </map>
190
+ </aslist></p>
191
+
192
+ <p><aslist>
193
+ <copy target="_map1" />
194
+ </aslist></p>
195
+
196
+ <copy target="_p1" assignNames = "p" />
197
+ `,
198
+ },
199
+ "*",
200
+ );
201
+ });
202
+
203
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
204
+
205
+ cy.window().then(async (win) => {
206
+ let stateVariables = await win.returnAllStateVariables1();
207
+
208
+ let samples = stateVariables["/_map1"].replacements.reduce(
209
+ (a, c) => [
210
+ ...a,
211
+ ...stateVariables[
212
+ stateVariables[c.componentName].replacements[0].componentName
213
+ ].replacements.map(
214
+ (y) => stateVariables[y.componentName].stateValues.value,
215
+ ),
216
+ ],
217
+ [],
218
+ );
219
+ expect(samples.length).eq(100);
220
+
221
+ for (let sample of samples) {
222
+ expect(sample).gt(-5);
223
+ expect(sample).lte(-4);
224
+ }
225
+
226
+ let meanX = me.math.mean(samples);
227
+ let varX = me.math.variance(samples, "uncorrected");
228
+
229
+ expect(meanX).closeTo(-4.5, 0.05);
230
+ expect(varX).closeTo(1 / 12, 0.02);
231
+
232
+ let firstSelect =
233
+ stateVariables[
234
+ stateVariables[stateVariables["/_map1"].replacements[0].componentName]
235
+ .replacements[0].componentName
236
+ ];
237
+ expect(firstSelect.stateValues.mean).closeTo(-4.5, 1e-10);
238
+ expect(firstSelect.stateValues.variance).closeTo(1 / 12, 1e-10);
239
+ expect(firstSelect.stateValues.standardDeviation).closeTo(
240
+ Math.sqrt(1 / 12),
241
+ 1e-10,
242
+ );
243
+
244
+ let copiedSamples = stateVariables["/_copy1"].replacements.reduce(
245
+ (a, c) => [
246
+ ...a,
247
+ ...stateVariables[
248
+ stateVariables[c.componentName].replacements[0].componentName
249
+ ].replacements.map(
250
+ (y) => stateVariables[y.componentName].stateValues.value,
251
+ ),
252
+ ],
253
+ [],
254
+ );
255
+ expect(copiedSamples).eqls(samples);
256
+
257
+ let copiedCopiedSamples = stateVariables[
258
+ stateVariables["/p"].activeChildren[0].componentName
259
+ ].activeChildren.map(
260
+ (x) => stateVariables[x.componentName].stateValues.value,
261
+ );
262
+ expect(copiedCopiedSamples).eqls(samples);
263
+ });
264
+ });
265
+
266
+ it("select ten uniform random numbers from -4 to -2", () => {
267
+ cy.window().then(async (win) => {
268
+ win.postMessage(
269
+ {
270
+ doenetML: `
271
+ <text>a</text>
272
+ <p><aslist>
273
+ <map>
274
+ <template><selectrandomnumbers numToSelect="10" from="-4" to="-2" /></template>
275
+ <sources><sequence length="10" /></sources>
276
+ </map>
277
+ </aslist></p>
278
+
279
+ <p><aslist>
280
+ <copy target="_map1" />
281
+ </aslist></p>
282
+
283
+ <copy target="_p1" assignNames = "p" />
284
+ `,
285
+ },
286
+ "*",
287
+ );
288
+ });
289
+
290
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
291
+
292
+ cy.window().then(async (win) => {
293
+ let stateVariables = await win.returnAllStateVariables1();
294
+
295
+ let samples = stateVariables["/_map1"].replacements.reduce(
296
+ (a, c) => [
297
+ ...a,
298
+ ...stateVariables[
299
+ stateVariables[c.componentName].replacements[0].componentName
300
+ ].replacements.map(
301
+ (y) => stateVariables[y.componentName].stateValues.value,
302
+ ),
303
+ ],
304
+ [],
305
+ );
306
+ expect(samples.length).eq(100);
307
+
308
+ for (let sample of samples) {
309
+ expect(sample).gt(-4);
310
+ expect(sample).lte(-2);
311
+ }
312
+
313
+ let meanX = me.math.mean(samples);
314
+ let varX = me.math.variance(samples, "uncorrected");
315
+
316
+ expect(meanX).closeTo(-3, 0.5);
317
+ expect(varX).closeTo(2 ** 2 / 12, 0.5);
318
+
319
+ let firstSelect =
320
+ stateVariables[
321
+ stateVariables[stateVariables["/_map1"].replacements[0].componentName]
322
+ .replacements[0].componentName
323
+ ];
324
+ expect(firstSelect.stateValues.mean).closeTo(-3, 1e-10);
325
+ expect(firstSelect.stateValues.variance).closeTo(2 ** 2 / 12, 1e-10);
326
+ expect(firstSelect.stateValues.standardDeviation).closeTo(
327
+ Math.sqrt(2 ** 2 / 12),
328
+ 1e-10,
329
+ );
330
+
331
+ let copiedSamples = stateVariables["/_copy1"].replacements.reduce(
332
+ (a, c) => [
333
+ ...a,
334
+ ...stateVariables[
335
+ stateVariables[c.componentName].replacements[0].componentName
336
+ ].replacements.map(
337
+ (y) => stateVariables[y.componentName].stateValues.value,
338
+ ),
339
+ ],
340
+ [],
341
+ );
342
+ expect(copiedSamples).eqls(samples);
343
+
344
+ let copiedCopiedSamples = stateVariables[
345
+ stateVariables["/p"].activeChildren[0].componentName
346
+ ].activeChildren.map(
347
+ (x) => stateVariables[x.componentName].stateValues.value,
348
+ );
349
+ expect(copiedCopiedSamples).eqls(samples);
350
+ });
351
+ });
352
+
353
+ it("select ten uniform random numbers from -2 to -4", () => {
354
+ cy.window().then(async (win) => {
355
+ win.postMessage(
356
+ {
357
+ doenetML: `
358
+ <text>a</text>
359
+ <p><aslist>
360
+ <map>
361
+ <template><selectrandomnumbers numToSelect="10" from="-2" to="-4" /></template>
362
+ <sources><sequence length="10" /></sources>
363
+ </map>
364
+ </aslist></p>
365
+
366
+ <p><aslist>
367
+ <copy target="_map1" />
368
+ </aslist></p>
369
+
370
+ <copy target="_p1" assignNames = "p" />
371
+ `,
372
+ },
373
+ "*",
374
+ );
375
+ });
376
+
377
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
378
+
379
+ cy.window().then(async (win) => {
380
+ let stateVariables = await win.returnAllStateVariables1();
381
+
382
+ let samples = stateVariables["/_map1"].replacements.reduce(
383
+ (a, c) => [
384
+ ...a,
385
+ ...stateVariables[
386
+ stateVariables[c.componentName].replacements[0].componentName
387
+ ].replacements.map(
388
+ (y) => stateVariables[y.componentName].stateValues.value,
389
+ ),
390
+ ],
391
+ [],
392
+ );
393
+ expect(samples.length).eq(100);
394
+
395
+ for (let sample of samples) {
396
+ expect(sample).gt(-4);
397
+ expect(sample).lte(-2);
398
+ }
399
+
400
+ let meanX = me.math.mean(samples);
401
+ let varX = me.math.variance(samples, "uncorrected");
402
+
403
+ expect(meanX).closeTo(-3, 0.5);
404
+ expect(varX).closeTo(2 ** 2 / 12, 0.5);
405
+
406
+ let firstSelect =
407
+ stateVariables[
408
+ stateVariables[stateVariables["/_map1"].replacements[0].componentName]
409
+ .replacements[0].componentName
410
+ ];
411
+ expect(firstSelect.stateValues.mean).closeTo(-3, 1e-10);
412
+ expect(firstSelect.stateValues.variance).closeTo(2 ** 2 / 12, 1e-10);
413
+ expect(firstSelect.stateValues.standardDeviation).closeTo(
414
+ Math.sqrt(2 ** 2 / 12),
415
+ 1e-10,
416
+ );
417
+
418
+ let copiedSamples = stateVariables["/_copy1"].replacements.reduce(
419
+ (a, c) => [
420
+ ...a,
421
+ ...stateVariables[
422
+ stateVariables[c.componentName].replacements[0].componentName
423
+ ].replacements.map(
424
+ (y) => stateVariables[y.componentName].stateValues.value,
425
+ ),
426
+ ],
427
+ [],
428
+ );
429
+ expect(copiedSamples).eqls(samples);
430
+
431
+ let copiedCopiedSamples = stateVariables[
432
+ stateVariables["/p"].activeChildren[0].componentName
433
+ ].activeChildren.map(
434
+ (x) => stateVariables[x.componentName].stateValues.value,
435
+ );
436
+ expect(copiedCopiedSamples).eqls(samples);
437
+ });
438
+ });
439
+
440
+ it("select twenty continuous standard normals, no parameters", () => {
441
+ cy.window().then(async (win) => {
442
+ win.postMessage(
443
+ {
444
+ doenetML: `
445
+ <text>a</text>
446
+ <p><aslist>
447
+ <map>
448
+ <template><selectrandomnumbers type="gaussian" numToSelect="20" /></template>
449
+ <sources><sequence length="5" /></sources>
450
+ </map>
451
+ </aslist></p>
452
+
453
+ <p><aslist>
454
+ <copy target="_map1" />
455
+ </aslist></p>
456
+
457
+ <copy target="_p1" assignNames = "p" />
458
+ `,
459
+ },
460
+ "*",
461
+ );
462
+ });
463
+
464
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
465
+
466
+ cy.window().then(async (win) => {
467
+ let stateVariables = await win.returnAllStateVariables1();
468
+
469
+ let samples = stateVariables["/_map1"].replacements.reduce(
470
+ (a, c) => [
471
+ ...a,
472
+ ...stateVariables[
473
+ stateVariables[c.componentName].replacements[0].componentName
474
+ ].replacements.map(
475
+ (y) => stateVariables[y.componentName].stateValues.value,
476
+ ),
477
+ ],
478
+ [],
479
+ );
480
+ expect(samples.length).eq(100);
481
+
482
+ let meanX = me.math.mean(samples);
483
+ let varX = me.math.variance(samples, "uncorrected");
484
+
485
+ expect(meanX).closeTo(0, 0.2);
486
+ expect(varX).closeTo(1, 0.2);
487
+
488
+ let firstSelect =
489
+ stateVariables[
490
+ stateVariables[stateVariables["/_map1"].replacements[0].componentName]
491
+ .replacements[0].componentName
492
+ ];
493
+ expect(firstSelect.stateValues.mean).closeTo(0, 1e-10);
494
+ expect(firstSelect.stateValues.variance).closeTo(1, 1e-10);
495
+ expect(firstSelect.stateValues.standardDeviation).closeTo(
496
+ Math.sqrt(1),
497
+ 1e-10,
498
+ );
499
+
500
+ let copiedSamples = stateVariables["/_copy1"].replacements.reduce(
501
+ (a, c) => [
502
+ ...a,
503
+ ...stateVariables[
504
+ stateVariables[c.componentName].replacements[0].componentName
505
+ ].replacements.map(
506
+ (y) => stateVariables[y.componentName].stateValues.value,
507
+ ),
508
+ ],
509
+ [],
510
+ );
511
+ expect(copiedSamples).eqls(samples);
512
+
513
+ let copiedCopiedSamples = stateVariables[
514
+ stateVariables["/p"].activeChildren[0].componentName
515
+ ].activeChildren.map(
516
+ (x) => stateVariables[x.componentName].stateValues.value,
517
+ );
518
+ expect(copiedCopiedSamples).eqls(samples);
519
+ });
520
+ });
521
+
522
+ it("select five continuous standard normals, unspecified mean 0, standard deviation 10", () => {
523
+ cy.window().then(async (win) => {
524
+ win.postMessage(
525
+ {
526
+ doenetML: `
527
+ <text>a</text>
528
+ <p><aslist>
529
+ <map>
530
+ <template><selectrandomnumbers type="gaussian" numToSelect="5" standardDeviation="10" /></template>
531
+ <sources><sequence length="20" /></sources>
532
+ </map>
533
+ </aslist></p>
534
+
535
+ <p><aslist>
536
+ <copy target="_map1" />
537
+ </aslist></p>
538
+
539
+ <copy target="_p1" assignNames = "p" />
540
+ `,
541
+ },
542
+ "*",
543
+ );
544
+ });
545
+
546
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
547
+
548
+ cy.window().then(async (win) => {
549
+ let stateVariables = await win.returnAllStateVariables1();
550
+
551
+ let samples = stateVariables["/_map1"].replacements.reduce(
552
+ (a, c) => [
553
+ ...a,
554
+ ...stateVariables[
555
+ stateVariables[c.componentName].replacements[0].componentName
556
+ ].replacements.map(
557
+ (y) => stateVariables[y.componentName].stateValues.value,
558
+ ),
559
+ ],
560
+ [],
561
+ );
562
+ expect(samples.length).eq(100);
563
+
564
+ let meanX = me.math.mean(samples);
565
+ let varX = me.math.variance(samples, "uncorrected");
566
+
567
+ expect(meanX).closeTo(0, 2);
568
+ expect(varX).closeTo(100, 10);
569
+
570
+ let firstSelect =
571
+ stateVariables[
572
+ stateVariables[stateVariables["/_map1"].replacements[0].componentName]
573
+ .replacements[0].componentName
574
+ ];
575
+ expect(firstSelect.stateValues.mean).closeTo(0, 1e-10);
576
+ expect(firstSelect.stateValues.variance).closeTo(100, 1e-10);
577
+ expect(firstSelect.stateValues.standardDeviation).closeTo(
578
+ Math.sqrt(100),
579
+ 1e-10,
580
+ );
581
+
582
+ let copiedSamples = stateVariables["/_copy1"].replacements.reduce(
583
+ (a, c) => [
584
+ ...a,
585
+ ...stateVariables[
586
+ stateVariables[c.componentName].replacements[0].componentName
587
+ ].replacements.map(
588
+ (y) => stateVariables[y.componentName].stateValues.value,
589
+ ),
590
+ ],
591
+ [],
592
+ );
593
+ expect(copiedSamples).eqls(samples);
594
+
595
+ let copiedCopiedSamples = stateVariables[
596
+ stateVariables["/p"].activeChildren[0].componentName
597
+ ].activeChildren.map(
598
+ (x) => stateVariables[x.componentName].stateValues.value,
599
+ );
600
+ expect(copiedCopiedSamples).eqls(samples);
601
+ });
602
+ });
603
+
604
+ it("select single continuous standard normal, mean -50, unspecified standard deviation 1", () => {
605
+ cy.window().then(async (win) => {
606
+ win.postMessage(
607
+ {
608
+ doenetML: `
609
+ <text>a</text>
610
+ <p><aslist>
611
+ <map>
612
+ <template><selectrandomnumbers type="gaussian" mean="-50" /></template>
613
+ <sources><sequence length="100" /></sources>
614
+ </map>
615
+ </aslist></p>
616
+
617
+ <p><aslist>
618
+ <copy target="_map1" />
619
+ </aslist></p>
620
+
621
+ <copy target="_p1" assignNames = "p" />
622
+ `,
623
+ },
624
+ "*",
625
+ );
626
+ });
627
+
628
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
629
+
630
+ cy.window().then(async (win) => {
631
+ let stateVariables = await win.returnAllStateVariables1();
632
+
633
+ let samples = stateVariables["/_map1"].replacements.reduce(
634
+ (a, c) => [
635
+ ...a,
636
+ ...stateVariables[
637
+ stateVariables[c.componentName].replacements[0].componentName
638
+ ].replacements.map(
639
+ (y) => stateVariables[y.componentName].stateValues.value,
640
+ ),
641
+ ],
642
+ [],
643
+ );
644
+ expect(samples.length).eq(100);
645
+
646
+ let meanX = me.math.mean(samples);
647
+ let varX = me.math.variance(samples, "uncorrected");
648
+
649
+ expect(meanX).closeTo(-50, 0.5);
650
+ expect(varX).closeTo(1, 0.1);
651
+
652
+ let firstSelect =
653
+ stateVariables[
654
+ stateVariables[stateVariables["/_map1"].replacements[0].componentName]
655
+ .replacements[0].componentName
656
+ ];
657
+ expect(firstSelect.stateValues.mean).closeTo(-50, 1e-10);
658
+ expect(firstSelect.stateValues.variance).closeTo(1, 1e-10);
659
+ expect(firstSelect.stateValues.standardDeviation).closeTo(
660
+ Math.sqrt(1),
661
+ 1e-10,
662
+ );
663
+
664
+ let copiedSamples = stateVariables["/_copy1"].replacements.reduce(
665
+ (a, c) => [
666
+ ...a,
667
+ ...stateVariables[
668
+ stateVariables[c.componentName].replacements[0].componentName
669
+ ].replacements.map(
670
+ (y) => stateVariables[y.componentName].stateValues.value,
671
+ ),
672
+ ],
673
+ [],
674
+ );
675
+ expect(copiedSamples).eqls(samples);
676
+
677
+ let copiedCopiedSamples = stateVariables[
678
+ stateVariables["/p"].activeChildren[0].componentName
679
+ ].activeChildren.map(
680
+ (x) => stateVariables[x.componentName].stateValues.value,
681
+ );
682
+ expect(copiedCopiedSamples).eqls(samples);
683
+ });
684
+ });
685
+
686
+ it("select twenty continuous standard normals, mean 100, standard deviation 10", () => {
687
+ cy.window().then(async (win) => {
688
+ win.postMessage(
689
+ {
690
+ doenetML: `
691
+ <text>a</text>
692
+ <p><aslist>
693
+ <map>
694
+ <template><selectrandomnumbers type="gaussian" numToSelect="20" mean="100" standardDeviation="10" /></template>
695
+ <sources><sequence length="5" /></sources>
696
+ </map>
697
+ </aslist></p>
698
+
699
+ <p><aslist>
700
+ <copy target="_map1" />
701
+ </aslist></p>
702
+
703
+ <copy target="_p1" assignNames = "p" />
704
+ `,
705
+ },
706
+ "*",
707
+ );
708
+ });
709
+
710
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
711
+
712
+ cy.window().then(async (win) => {
713
+ let stateVariables = await win.returnAllStateVariables1();
714
+
715
+ let samples = stateVariables["/_map1"].replacements.reduce(
716
+ (a, c) => [
717
+ ...a,
718
+ ...stateVariables[
719
+ stateVariables[c.componentName].replacements[0].componentName
720
+ ].replacements.map(
721
+ (y) => stateVariables[y.componentName].stateValues.value,
722
+ ),
723
+ ],
724
+ [],
725
+ );
726
+ expect(samples.length).eq(100);
727
+
728
+ let meanX = me.math.mean(samples);
729
+ let varX = me.math.variance(samples, "uncorrected");
730
+
731
+ expect(meanX).closeTo(100, 2);
732
+ expect(varX).closeTo(100, 20);
733
+
734
+ let firstSelect =
735
+ stateVariables[
736
+ stateVariables[stateVariables["/_map1"].replacements[0].componentName]
737
+ .replacements[0].componentName
738
+ ];
739
+ expect(firstSelect.stateValues.mean).closeTo(100, 1e-10);
740
+ expect(firstSelect.stateValues.variance).closeTo(100, 1e-10);
741
+ expect(firstSelect.stateValues.standardDeviation).closeTo(
742
+ Math.sqrt(100),
743
+ 1e-10,
744
+ );
745
+
746
+ let copiedSamples = stateVariables["/_copy1"].replacements.reduce(
747
+ (a, c) => [
748
+ ...a,
749
+ ...stateVariables[
750
+ stateVariables[c.componentName].replacements[0].componentName
751
+ ].replacements.map(
752
+ (y) => stateVariables[y.componentName].stateValues.value,
753
+ ),
754
+ ],
755
+ [],
756
+ );
757
+ expect(copiedSamples).eqls(samples);
758
+
759
+ let copiedCopiedSamples = stateVariables[
760
+ stateVariables["/p"].activeChildren[0].componentName
761
+ ].activeChildren.map(
762
+ (x) => stateVariables[x.componentName].stateValues.value,
763
+ );
764
+ expect(copiedCopiedSamples).eqls(samples);
765
+ });
766
+ });
767
+
768
+ it("select twenty continuous standard normals, mean -3, variance 0.01", () => {
769
+ cy.window().then(async (win) => {
770
+ win.postMessage(
771
+ {
772
+ doenetML: `
773
+ <text>a</text>
774
+ <p><aslist>
775
+ <map>
776
+ <template><selectrandomnumbers type="gaussian" numToSelect="20" mean="-3" variance="0.01" /></template>
777
+ <sources><sequence length="5" /></sources>
778
+ </map>
779
+ </aslist></p>
780
+
781
+ <p><aslist>
782
+ <copy target="_map1" />
783
+ </aslist></p>
784
+
785
+ <copy target="_p1" assignNames = "p" />
786
+ `,
787
+ },
788
+ "*",
789
+ );
790
+ });
791
+
792
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
793
+
794
+ cy.window().then(async (win) => {
795
+ let stateVariables = await win.returnAllStateVariables1();
796
+
797
+ let samples = stateVariables["/_map1"].replacements.reduce(
798
+ (a, c) => [
799
+ ...a,
800
+ ...stateVariables[
801
+ stateVariables[c.componentName].replacements[0].componentName
802
+ ].replacements.map(
803
+ (y) => stateVariables[y.componentName].stateValues.value,
804
+ ),
805
+ ],
806
+ [],
807
+ );
808
+ expect(samples.length).eq(100);
809
+
810
+ let meanX = me.math.mean(samples);
811
+ let varX = me.math.variance(samples, "uncorrected");
812
+
813
+ expect(meanX).closeTo(-3, 0.1);
814
+ expect(varX).closeTo(0.01, 0.002);
815
+
816
+ let firstSelect =
817
+ stateVariables[
818
+ stateVariables[stateVariables["/_map1"].replacements[0].componentName]
819
+ .replacements[0].componentName
820
+ ];
821
+ expect(firstSelect.stateValues.mean).closeTo(-3, 1e-10);
822
+ expect(firstSelect.stateValues.variance).closeTo(0.01, 1e-10);
823
+ expect(firstSelect.stateValues.standardDeviation).closeTo(
824
+ Math.sqrt(0.01),
825
+ 1e-10,
826
+ );
827
+
828
+ let copiedSamples = stateVariables["/_copy1"].replacements.reduce(
829
+ (a, c) => [
830
+ ...a,
831
+ ...stateVariables[
832
+ stateVariables[c.componentName].replacements[0].componentName
833
+ ].replacements.map(
834
+ (y) => stateVariables[y.componentName].stateValues.value,
835
+ ),
836
+ ],
837
+ [],
838
+ );
839
+ expect(copiedSamples).eqls(samples);
840
+
841
+ let copiedCopiedSamples = stateVariables[
842
+ stateVariables["/p"].activeChildren[0].componentName
843
+ ].activeChildren.map(
844
+ (x) => stateVariables[x.componentName].stateValues.value,
845
+ );
846
+ expect(copiedCopiedSamples).eqls(samples);
847
+ });
848
+ });
849
+
850
+ it("select single discrete uniform, no parameters, integer from 0 to 1", () => {
851
+ cy.window().then(async (win) => {
852
+ win.postMessage(
853
+ {
854
+ doenetML: `
855
+ <text>a</text>
856
+ <p><aslist>
857
+ <map>
858
+ <template><selectrandomnumbers type="discreteUniform" /></template>
859
+ <sources><sequence length="100" /></sources>
860
+ </map>
861
+ </aslist></p>
862
+
863
+ <p><aslist>
864
+ <copy target="_map1" />
865
+ </aslist></p>
866
+
867
+ <copy target="_p1" assignNames = "p" />
868
+ `,
869
+ },
870
+ "*",
871
+ );
872
+ });
873
+
874
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
875
+
876
+ cy.window().then(async (win) => {
877
+ let stateVariables = await win.returnAllStateVariables1();
878
+
879
+ let samples = stateVariables["/_map1"].replacements.reduce(
880
+ (a, c) => [
881
+ ...a,
882
+ ...stateVariables[
883
+ stateVariables[c.componentName].replacements[0].componentName
884
+ ].replacements.map(
885
+ (y) => stateVariables[y.componentName].stateValues.value,
886
+ ),
887
+ ],
888
+ [],
889
+ );
890
+ expect(samples.length).eq(100);
891
+
892
+ for (let sample of samples) {
893
+ expect([0, 1].includes(sample)).eq(true);
894
+ }
895
+
896
+ let meanX = me.math.mean(samples);
897
+ let varX = me.math.variance(samples, "uncorrected");
898
+
899
+ expect(meanX).closeTo(0.5, 0.05);
900
+ expect(varX).closeTo((2 ** 2 - 1) / 12, 0.05);
901
+
902
+ let firstSelect =
903
+ stateVariables[
904
+ stateVariables[stateVariables["/_map1"].replacements[0].componentName]
905
+ .replacements[0].componentName
906
+ ];
907
+ expect(firstSelect.stateValues.mean).closeTo(0.5, 1e-10);
908
+ expect(firstSelect.stateValues.variance).closeTo(
909
+ (2 ** 2 - 1) / 12,
910
+ 1e-10,
911
+ );
912
+ expect(firstSelect.stateValues.standardDeviation).closeTo(
913
+ Math.sqrt((2 ** 2 - 1) / 12),
914
+ 1e-10,
915
+ );
916
+
917
+ let copiedSamples = stateVariables["/_copy1"].replacements.reduce(
918
+ (a, c) => [
919
+ ...a,
920
+ ...stateVariables[
921
+ stateVariables[c.componentName].replacements[0].componentName
922
+ ].replacements.map(
923
+ (y) => stateVariables[y.componentName].stateValues.value,
924
+ ),
925
+ ],
926
+ [],
927
+ );
928
+ expect(copiedSamples).eqls(samples);
929
+
930
+ let copiedCopiedSamples = stateVariables[
931
+ stateVariables["/p"].activeChildren[0].componentName
932
+ ].activeChildren.map(
933
+ (x) => stateVariables[x.componentName].stateValues.value,
934
+ );
935
+ expect(copiedCopiedSamples).eqls(samples);
936
+ });
937
+ });
938
+
939
+ it("select single discrete uniform, from 0.5 to 5.5, only to specified", () => {
940
+ cy.window().then(async (win) => {
941
+ win.postMessage(
942
+ {
943
+ doenetML: `
944
+ <text>a</text>
945
+ <p><aslist>
946
+ <map>
947
+ <template><selectrandomnumbers type="discreteUniform" to="5.5" /></template>
948
+ <sources><sequence length="100" /></sources>
949
+ </map>
950
+ </aslist></p>
951
+
952
+ <p><aslist>
953
+ <copy target="_map1" />
954
+ </aslist></p>
955
+
956
+ <copy target="_p1" assignNames = "p" />
957
+ `,
958
+ },
959
+ "*",
960
+ );
961
+ });
962
+
963
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
964
+
965
+ cy.window().then(async (win) => {
966
+ let stateVariables = await win.returnAllStateVariables1();
967
+
968
+ let samples = stateVariables["/_map1"].replacements.reduce(
969
+ (a, c) => [
970
+ ...a,
971
+ ...stateVariables[
972
+ stateVariables[c.componentName].replacements[0].componentName
973
+ ].replacements.map(
974
+ (y) => stateVariables[y.componentName].stateValues.value,
975
+ ),
976
+ ],
977
+ [],
978
+ );
979
+ expect(samples.length).eq(100);
980
+
981
+ for (let sample of samples) {
982
+ expect([0.5, 1.5, 2.5, 3.5, 4.5, 5.5].includes(sample)).eq(true);
983
+ }
984
+
985
+ let meanX = me.math.mean(samples);
986
+ let varX = me.math.variance(samples, "uncorrected");
987
+
988
+ expect(meanX).closeTo(3, 0.2);
989
+ expect(varX).closeTo((6 ** 2 - 1) / 12, 0.5);
990
+
991
+ let firstSelect =
992
+ stateVariables[
993
+ stateVariables[stateVariables["/_map1"].replacements[0].componentName]
994
+ .replacements[0].componentName
995
+ ];
996
+ expect(firstSelect.stateValues.mean).closeTo(3, 1e-10);
997
+ expect(firstSelect.stateValues.variance).closeTo(
998
+ (6 ** 2 - 1) / 12,
999
+ 1e-10,
1000
+ );
1001
+ expect(firstSelect.stateValues.standardDeviation).closeTo(
1002
+ Math.sqrt((6 ** 2 - 1) / 12),
1003
+ 1e-10,
1004
+ );
1005
+
1006
+ let copiedSamples = stateVariables["/_copy1"].replacements.reduce(
1007
+ (a, c) => [
1008
+ ...a,
1009
+ ...stateVariables[
1010
+ stateVariables[c.componentName].replacements[0].componentName
1011
+ ].replacements.map(
1012
+ (y) => stateVariables[y.componentName].stateValues.value,
1013
+ ),
1014
+ ],
1015
+ [],
1016
+ );
1017
+ expect(copiedSamples).eqls(samples);
1018
+
1019
+ let copiedCopiedSamples = stateVariables[
1020
+ stateVariables["/p"].activeChildren[0].componentName
1021
+ ].activeChildren.map(
1022
+ (x) => stateVariables[x.componentName].stateValues.value,
1023
+ );
1024
+ expect(copiedCopiedSamples).eqls(samples);
1025
+ });
1026
+ });
1027
+
1028
+ it("select single discrete uniform, from 8.5 to 9.5, only from specified", () => {
1029
+ cy.window().then(async (win) => {
1030
+ win.postMessage(
1031
+ {
1032
+ doenetML: `
1033
+ <text>a</text>
1034
+ <p><aslist>
1035
+ <map>
1036
+ <template><selectrandomnumbers type="discreteUniform" from="8.5" /></template>
1037
+ <sources><sequence length="100" /></sources>
1038
+ </map>
1039
+ </aslist></p>
1040
+
1041
+ <p><aslist>
1042
+ <copy target="_map1" />
1043
+ </aslist></p>
1044
+
1045
+ <copy target="_p1" assignNames = "p" />
1046
+ `,
1047
+ },
1048
+ "*",
1049
+ );
1050
+ });
1051
+
1052
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1053
+
1054
+ cy.window().then(async (win) => {
1055
+ let stateVariables = await win.returnAllStateVariables1();
1056
+
1057
+ let samples = stateVariables["/_map1"].replacements.reduce(
1058
+ (a, c) => [
1059
+ ...a,
1060
+ ...stateVariables[
1061
+ stateVariables[c.componentName].replacements[0].componentName
1062
+ ].replacements.map(
1063
+ (y) => stateVariables[y.componentName].stateValues.value,
1064
+ ),
1065
+ ],
1066
+ [],
1067
+ );
1068
+ expect(samples.length).eq(100);
1069
+
1070
+ for (let sample of samples) {
1071
+ expect([8.5, 9.5].includes(sample)).eq(true);
1072
+ }
1073
+
1074
+ let meanX = me.math.mean(samples);
1075
+ let varX = me.math.variance(samples, "uncorrected");
1076
+
1077
+ expect(meanX).closeTo(9, 0.05);
1078
+ expect(varX).closeTo((2 ** 2 - 1) / 12, 0.05);
1079
+
1080
+ let firstSelect =
1081
+ stateVariables[
1082
+ stateVariables[stateVariables["/_map1"].replacements[0].componentName]
1083
+ .replacements[0].componentName
1084
+ ];
1085
+ expect(firstSelect.stateValues.mean).closeTo(9, 1e-10);
1086
+ expect(firstSelect.stateValues.variance).closeTo(
1087
+ (2 ** 2 - 1) / 12,
1088
+ 1e-10,
1089
+ );
1090
+ expect(firstSelect.stateValues.standardDeviation).closeTo(
1091
+ Math.sqrt((2 ** 2 - 1) / 12),
1092
+ 1e-10,
1093
+ );
1094
+
1095
+ let copiedSamples = stateVariables["/_copy1"].replacements.reduce(
1096
+ (a, c) => [
1097
+ ...a,
1098
+ ...stateVariables[
1099
+ stateVariables[c.componentName].replacements[0].componentName
1100
+ ].replacements.map(
1101
+ (y) => stateVariables[y.componentName].stateValues.value,
1102
+ ),
1103
+ ],
1104
+ [],
1105
+ );
1106
+ expect(copiedSamples).eqls(samples);
1107
+
1108
+ let copiedCopiedSamples = stateVariables[
1109
+ stateVariables["/p"].activeChildren[0].componentName
1110
+ ].activeChildren.map(
1111
+ (x) => stateVariables[x.componentName].stateValues.value,
1112
+ );
1113
+ expect(copiedCopiedSamples).eqls(samples);
1114
+ });
1115
+ });
1116
+
1117
+ it("select five integers from -3 to 5", () => {
1118
+ cy.window().then(async (win) => {
1119
+ win.postMessage(
1120
+ {
1121
+ doenetML: `
1122
+ <text>a</text>
1123
+ <p><aslist>
1124
+ <map>
1125
+ <template><selectrandomnumbers type="discreteUniform" from="-3" to="5" numToSelect="5" /></template>
1126
+ <sources><sequence length="20" /></sources>
1127
+ </map>
1128
+ </aslist></p>
1129
+
1130
+ <p><aslist>
1131
+ <copy target="_map1" />
1132
+ </aslist></p>
1133
+
1134
+ <copy target="_p1" assignNames = "p" />
1135
+ `,
1136
+ },
1137
+ "*",
1138
+ );
1139
+ });
1140
+
1141
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1142
+
1143
+ cy.window().then(async (win) => {
1144
+ let stateVariables = await win.returnAllStateVariables1();
1145
+
1146
+ let samples = stateVariables["/_map1"].replacements.reduce(
1147
+ (a, c) => [
1148
+ ...a,
1149
+ ...stateVariables[
1150
+ stateVariables[c.componentName].replacements[0].componentName
1151
+ ].replacements.map(
1152
+ (y) => stateVariables[y.componentName].stateValues.value,
1153
+ ),
1154
+ ],
1155
+ [],
1156
+ );
1157
+ expect(samples.length).eq(100);
1158
+
1159
+ for (let sample of samples) {
1160
+ expect([-3, -2, -1, 0, 1, 2, 3, 4, 5].includes(sample)).eq(true);
1161
+ }
1162
+
1163
+ let meanX = me.math.mean(samples);
1164
+ let varX = me.math.variance(samples, "uncorrected");
1165
+
1166
+ expect(meanX).closeTo(1, 0.3);
1167
+ expect(varX).closeTo((9 ** 2 - 1) / 12, 1);
1168
+
1169
+ let firstSelect =
1170
+ stateVariables[
1171
+ stateVariables[stateVariables["/_map1"].replacements[0].componentName]
1172
+ .replacements[0].componentName
1173
+ ];
1174
+ expect(firstSelect.stateValues.mean).closeTo(1, 1e-10);
1175
+ expect(firstSelect.stateValues.variance).closeTo(
1176
+ (9 ** 2 - 1) / 12,
1177
+ 1e-10,
1178
+ );
1179
+ expect(firstSelect.stateValues.standardDeviation).closeTo(
1180
+ Math.sqrt((9 ** 2 - 1) / 12),
1181
+ 1e-10,
1182
+ );
1183
+
1184
+ let copiedSamples = stateVariables["/_copy1"].replacements.reduce(
1185
+ (a, c) => [
1186
+ ...a,
1187
+ ...stateVariables[
1188
+ stateVariables[c.componentName].replacements[0].componentName
1189
+ ].replacements.map(
1190
+ (y) => stateVariables[y.componentName].stateValues.value,
1191
+ ),
1192
+ ],
1193
+ [],
1194
+ );
1195
+ expect(copiedSamples).eqls(samples);
1196
+
1197
+ let copiedCopiedSamples = stateVariables[
1198
+ stateVariables["/p"].activeChildren[0].componentName
1199
+ ].activeChildren.map(
1200
+ (x) => stateVariables[x.componentName].stateValues.value,
1201
+ );
1202
+ expect(copiedCopiedSamples).eqls(samples);
1203
+ });
1204
+ });
1205
+
1206
+ it("select five integers from 5 to -3 gives nothing", () => {
1207
+ cy.window().then(async (win) => {
1208
+ win.postMessage(
1209
+ {
1210
+ doenetML: `
1211
+ <text>a</text>
1212
+ <p><aslist>
1213
+ <map>
1214
+ <template><selectrandomnumbers type="discreteUniform" from="5" to="-3" numToSelect="5" /></template>
1215
+ <sources><sequence length="20" /></sources>
1216
+ </map>
1217
+ </aslist></p>
1218
+
1219
+ <p><aslist>
1220
+ <copy target="_map1" />
1221
+ </aslist></p>
1222
+
1223
+ <copy target="_p1" assignNames = "p" />
1224
+ `,
1225
+ },
1226
+ "*",
1227
+ );
1228
+ });
1229
+
1230
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1231
+
1232
+ cy.window().then(async (win) => {
1233
+ let stateVariables = await win.returnAllStateVariables1();
1234
+
1235
+ let samples = stateVariables["/_map1"].replacements.reduce(
1236
+ (a, c) => [
1237
+ ...a,
1238
+ ...stateVariables[
1239
+ stateVariables[c.componentName].replacements[0].componentName
1240
+ ].replacements.map(
1241
+ (y) => stateVariables[y.componentName].stateValues.value,
1242
+ ),
1243
+ ],
1244
+ [],
1245
+ );
1246
+ expect(samples.length).eq(0);
1247
+
1248
+ let copiedSamples = stateVariables["/_copy1"].replacements.reduce(
1249
+ (a, c) => [
1250
+ ...a,
1251
+ ...stateVariables[
1252
+ stateVariables[c.componentName].replacements[0].componentName
1253
+ ].replacements.map(
1254
+ (y) => stateVariables[y.componentName].stateValues.value,
1255
+ ),
1256
+ ],
1257
+ [],
1258
+ );
1259
+ expect(copiedSamples).eqls(samples);
1260
+
1261
+ let copiedCopiedSamples = stateVariables[
1262
+ stateVariables["/p"].activeChildren[0].componentName
1263
+ ].activeChildren.map(
1264
+ (x) => stateVariables[x.componentName].stateValues.value,
1265
+ );
1266
+ expect(copiedCopiedSamples).eqls(samples);
1267
+ });
1268
+ });
1269
+
1270
+ it("select 10 odd integers from -3 to 5", () => {
1271
+ cy.window().then(async (win) => {
1272
+ win.postMessage(
1273
+ {
1274
+ doenetML: `
1275
+ <text>a</text>
1276
+ <p><aslist>
1277
+ <map>
1278
+ <template><selectrandomnumbers type="discreteUniform" from="-3" to="5" numToSelect="10" step="2" /></template>
1279
+ <sources><sequence length="10" /></sources>
1280
+ </map>
1281
+ </aslist></p>
1282
+
1283
+ <p><aslist>
1284
+ <copy target="_map1" />
1285
+ </aslist></p>
1286
+
1287
+ <copy target="_p1" assignNames = "p" />
1288
+ `,
1289
+ },
1290
+ "*",
1291
+ );
1292
+ });
1293
+
1294
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1295
+
1296
+ cy.window().then(async (win) => {
1297
+ let stateVariables = await win.returnAllStateVariables1();
1298
+
1299
+ let samples = stateVariables["/_map1"].replacements.reduce(
1300
+ (a, c) => [
1301
+ ...a,
1302
+ ...stateVariables[
1303
+ stateVariables[c.componentName].replacements[0].componentName
1304
+ ].replacements.map(
1305
+ (y) => stateVariables[y.componentName].stateValues.value,
1306
+ ),
1307
+ ],
1308
+ [],
1309
+ );
1310
+ expect(samples.length).eq(100);
1311
+
1312
+ for (let sample of samples) {
1313
+ expect([-3, -1, 1, 3, 5].includes(sample)).eq(true);
1314
+ }
1315
+
1316
+ let meanX = me.math.mean(samples);
1317
+ let varX = me.math.variance(samples, "uncorrected");
1318
+
1319
+ expect(meanX).closeTo(1, 0.4);
1320
+ expect(varX).closeTo(((5 ** 2 - 1) * 2 ** 2) / 12, 1);
1321
+
1322
+ let firstSelect =
1323
+ stateVariables[
1324
+ stateVariables[stateVariables["/_map1"].replacements[0].componentName]
1325
+ .replacements[0].componentName
1326
+ ];
1327
+ expect(firstSelect.stateValues.mean).closeTo(1, 1e-10);
1328
+ expect(firstSelect.stateValues.variance).closeTo(
1329
+ ((5 ** 2 - 1) * 2 ** 2) / 12,
1330
+ 1e-10,
1331
+ );
1332
+ expect(firstSelect.stateValues.standardDeviation).closeTo(
1333
+ Math.sqrt(((5 ** 2 - 1) * 2 ** 2) / 12),
1334
+ 1e-10,
1335
+ );
1336
+
1337
+ let copiedSamples = stateVariables["/_copy1"].replacements.reduce(
1338
+ (a, c) => [
1339
+ ...a,
1340
+ ...stateVariables[
1341
+ stateVariables[c.componentName].replacements[0].componentName
1342
+ ].replacements.map(
1343
+ (y) => stateVariables[y.componentName].stateValues.value,
1344
+ ),
1345
+ ],
1346
+ [],
1347
+ );
1348
+ expect(copiedSamples).eqls(samples);
1349
+
1350
+ let copiedCopiedSamples = stateVariables[
1351
+ stateVariables["/p"].activeChildren[0].componentName
1352
+ ].activeChildren.map(
1353
+ (x) => stateVariables[x.componentName].stateValues.value,
1354
+ );
1355
+ expect(copiedCopiedSamples).eqls(samples);
1356
+ });
1357
+ });
1358
+
1359
+ it("selected number doesn't change dynamically", () => {
1360
+ cy.window().then(async (win) => {
1361
+ win.postMessage(
1362
+ {
1363
+ doenetML: `
1364
+ <text>a</text>
1365
+ <mathinput prefill="20" name="numToSelect"/>
1366
+ <mathinput prefill="10" name="maxnum"/>
1367
+ <p><aslist>
1368
+ <selectRandomNumbers name="sample1" to="$maxnum" numToSelect="$numToSelect" />
1369
+ </aslist></p>
1370
+
1371
+ <mathinput prefill="10" name="numToSelect2"/>
1372
+ <mathinput prefill="4" name="maxnum2"/>
1373
+ <p><aslist>
1374
+ <selectRandomNumbers type="discreteUniform" name="sample2" to="$maxnum2" numToSelect="$numToSelect2" />
1375
+ </aslist></p>
1376
+ <p><copy prop="value" target="maxnum2" assignNames="maxnum2a" /></p>
1377
+ `,
1378
+ },
1379
+ "*",
1380
+ );
1381
+ });
1382
+
1383
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1384
+
1385
+ let sample1numbers, sample2numbers;
1386
+
1387
+ cy.window().then(async (win) => {
1388
+ let stateVariables = await win.returnAllStateVariables1();
1389
+ let sample1replacements = stateVariables["/sample1"].replacements;
1390
+ let sample2replacements = stateVariables["/sample2"].replacements;
1391
+ expect(sample1replacements.length).eq(20);
1392
+ expect(sample2replacements.length).eq(10);
1393
+ sample1numbers = sample1replacements.map(
1394
+ (x) => stateVariables[x.componentName].stateValues.value,
1395
+ );
1396
+ sample2numbers = sample2replacements.map(
1397
+ (x) => stateVariables[x.componentName].stateValues.value,
1398
+ );
1399
+
1400
+ for (let num of sample1numbers) {
1401
+ expect(num).gte(0);
1402
+ expect(num).lt(10);
1403
+ }
1404
+ for (let num of sample2numbers) {
1405
+ expect([0, 1, 2, 3, 4].includes(num)).eq(true);
1406
+ }
1407
+ });
1408
+
1409
+ cy.log("Nothing changes when change mathinputs");
1410
+ cy.get(cesc("#\\/numToSelect") + " textarea").type(
1411
+ `{end}{backspace}{backspace}7{enter}`,
1412
+ { force: true },
1413
+ );
1414
+ cy.get(cesc("#\\/maxnum") + " textarea").type(
1415
+ `{end}{backspace}{backspace}11{enter}`,
1416
+ { force: true },
1417
+ );
1418
+ cy.get(cesc("#\\/numToSelect2") + " textarea").type(
1419
+ `{end}{backspace}{backspace}15{enter}`,
1420
+ { force: true },
1421
+ );
1422
+ cy.get(cesc("#\\/maxnum2") + " textarea").type(
1423
+ `{end}{backspace}{backspace}18{enter}`,
1424
+ { force: true },
1425
+ );
1426
+ cy.get(cesc("#\\/maxnum2a")).should("contain.text", "18");
1427
+
1428
+ cy.window().then(async (win) => {
1429
+ let stateVariables = await win.returnAllStateVariables1();
1430
+ let sample1replacements = stateVariables["/sample1"].replacements;
1431
+ let sample2replacements = stateVariables["/sample2"].replacements;
1432
+
1433
+ expect(
1434
+ sample1replacements.map(
1435
+ (x) => stateVariables[x.componentName].stateValues.value,
1436
+ ),
1437
+ ).eqls(sample1numbers);
1438
+ expect(
1439
+ sample2replacements.map(
1440
+ (x) => stateVariables[x.componentName].stateValues.value,
1441
+ ),
1442
+ ).eqls(sample2numbers);
1443
+ });
1444
+ });
1445
+
1446
+ it("random number doesn't resample in dynamic map", () => {
1447
+ cy.window().then(async (win) => {
1448
+ win.postMessage(
1449
+ {
1450
+ doenetML: `
1451
+ <text>a</text>
1452
+ How many numbers do you want? <mathinput />
1453
+ <p name="p1"><aslist>
1454
+ <map assignnames="a b c d e f">
1455
+ <template newNamespace>
1456
+ <selectRandomNumbers assignnames="n" />
1457
+ </template>
1458
+ <sources>
1459
+ <sequence length="$_mathinput1" />
1460
+ </sources>
1461
+ </map>
1462
+ </aslist></p>
1463
+
1464
+ <p name="p2"><aslist><copy target="_map1" /></aslist></p>
1465
+ <p name="p3"><copy target="_aslist1" /></p>
1466
+
1467
+ <copy name="p4" target="p1" />
1468
+ <copy name="p5" target="p2" />
1469
+ <copy name="p6" target="p3" />
1470
+
1471
+ <copy name="p7" target="p4" />
1472
+ <copy name="p8" target="p5" />
1473
+ <copy name="p9" target="p6" />
1474
+ <p><copy prop="value" target="_mathinput1" assignNames="m1" /></p>
1475
+ `,
1476
+ },
1477
+ "*",
1478
+ );
1479
+ });
1480
+
1481
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1482
+
1483
+ let samplednumbers = [];
1484
+
1485
+ cy.log("initially nothing");
1486
+ cy.window().then(async (win) => {
1487
+ let stateVariables = await win.returnAllStateVariables1();
1488
+ expect(
1489
+ stateVariables[stateVariables["/p1"].activeChildren[0].componentName]
1490
+ .activeChildren.length,
1491
+ ).eq(0);
1492
+ expect(
1493
+ stateVariables[stateVariables["/p2"].activeChildren[0].componentName]
1494
+ .activeChildren.length,
1495
+ ).eq(0);
1496
+ expect(
1497
+ stateVariables[stateVariables["/p3"].activeChildren[0].componentName]
1498
+ .activeChildren.length,
1499
+ ).eq(0);
1500
+ expect(
1501
+ stateVariables[
1502
+ stateVariables[stateVariables["/p4"].replacements[0].componentName]
1503
+ .activeChildren[0].componentName
1504
+ ].activeChildren.length,
1505
+ ).eq(0);
1506
+ expect(
1507
+ stateVariables[
1508
+ stateVariables[stateVariables["/p5"].replacements[0].componentName]
1509
+ .activeChildren[0].componentName
1510
+ ].activeChildren.length,
1511
+ ).eq(0);
1512
+ expect(
1513
+ stateVariables[
1514
+ stateVariables[stateVariables["/p6"].replacements[0].componentName]
1515
+ .activeChildren[0].componentName
1516
+ ].activeChildren.length,
1517
+ ).eq(0);
1518
+ expect(
1519
+ stateVariables[
1520
+ stateVariables[stateVariables["/p7"].replacements[0].componentName]
1521
+ .activeChildren[0].componentName
1522
+ ].activeChildren.length,
1523
+ ).eq(0);
1524
+ expect(
1525
+ stateVariables[
1526
+ stateVariables[stateVariables["/p8"].replacements[0].componentName]
1527
+ .activeChildren[0].componentName
1528
+ ].activeChildren.length,
1529
+ ).eq(0);
1530
+ expect(
1531
+ stateVariables[
1532
+ stateVariables[stateVariables["/p9"].replacements[0].componentName]
1533
+ .activeChildren[0].componentName
1534
+ ].activeChildren.length,
1535
+ ).eq(0);
1536
+ });
1537
+
1538
+ cy.log("sample one variable");
1539
+ cy.get(cesc("#\\/_mathinput1") + " textarea").type(
1540
+ `{end}{backspace}1{enter}`,
1541
+ { force: true },
1542
+ );
1543
+ cy.get(cesc("#\\/m1")).should("contain.text", "1");
1544
+ cy.window().then(async (win) => {
1545
+ let stateVariables = await win.returnAllStateVariables1();
1546
+ let n1 = stateVariables["/a/n"].stateValues.value;
1547
+ samplednumbers.push(n1);
1548
+ expect(
1549
+ stateVariables[stateVariables["/p1"].activeChildren[0].componentName]
1550
+ .activeChildren.length,
1551
+ ).eq(1);
1552
+ expect(
1553
+ stateVariables[stateVariables["/p2"].activeChildren[0].componentName]
1554
+ .activeChildren.length,
1555
+ ).eq(1);
1556
+ expect(
1557
+ stateVariables[stateVariables["/p3"].activeChildren[0].componentName]
1558
+ .activeChildren.length,
1559
+ ).eq(1);
1560
+ expect(
1561
+ stateVariables[
1562
+ stateVariables[stateVariables["/p4"].replacements[0].componentName]
1563
+ .activeChildren[0].componentName
1564
+ ].activeChildren.length,
1565
+ ).eq(1);
1566
+ expect(
1567
+ stateVariables[
1568
+ stateVariables[stateVariables["/p5"].replacements[0].componentName]
1569
+ .activeChildren[0].componentName
1570
+ ].activeChildren.length,
1571
+ ).eq(1);
1572
+ expect(
1573
+ stateVariables[
1574
+ stateVariables[stateVariables["/p6"].replacements[0].componentName]
1575
+ .activeChildren[0].componentName
1576
+ ].activeChildren.length,
1577
+ ).eq(1);
1578
+ expect(
1579
+ stateVariables[
1580
+ stateVariables[stateVariables["/p7"].replacements[0].componentName]
1581
+ .activeChildren[0].componentName
1582
+ ].activeChildren.length,
1583
+ ).eq(1);
1584
+ expect(
1585
+ stateVariables[
1586
+ stateVariables[stateVariables["/p8"].replacements[0].componentName]
1587
+ .activeChildren[0].componentName
1588
+ ].activeChildren.length,
1589
+ ).eq(1);
1590
+ expect(
1591
+ stateVariables[
1592
+ stateVariables[stateVariables["/p9"].replacements[0].componentName]
1593
+ .activeChildren[0].componentName
1594
+ ].activeChildren.length,
1595
+ ).eq(1);
1596
+ for (let ind = 0; ind < 1; ind++) {
1597
+ expect(
1598
+ stateVariables[
1599
+ stateVariables[
1600
+ stateVariables["/p1"].activeChildren[0].componentName
1601
+ ].activeChildren[ind].componentName
1602
+ ].stateValues.value,
1603
+ ).eq(samplednumbers[ind]);
1604
+ expect(
1605
+ stateVariables[
1606
+ stateVariables[
1607
+ stateVariables["/p2"].activeChildren[0].componentName
1608
+ ].activeChildren[ind].componentName
1609
+ ].stateValues.value,
1610
+ ).eq(samplednumbers[ind]);
1611
+ expect(
1612
+ stateVariables[
1613
+ stateVariables[
1614
+ stateVariables["/p3"].activeChildren[0].componentName
1615
+ ].activeChildren[ind].componentName
1616
+ ].stateValues.value,
1617
+ ).eq(samplednumbers[ind]);
1618
+ expect(
1619
+ stateVariables[
1620
+ stateVariables[
1621
+ stateVariables[
1622
+ stateVariables["/p4"].replacements[0].componentName
1623
+ ].activeChildren[0].componentName
1624
+ ].activeChildren[ind].componentName
1625
+ ].stateValues.value,
1626
+ ).eq(samplednumbers[ind]);
1627
+ expect(
1628
+ stateVariables[
1629
+ stateVariables[
1630
+ stateVariables[
1631
+ stateVariables["/p5"].replacements[0].componentName
1632
+ ].activeChildren[0].componentName
1633
+ ].activeChildren[ind].componentName
1634
+ ].stateValues.value,
1635
+ ).eq(samplednumbers[ind]);
1636
+ expect(
1637
+ stateVariables[
1638
+ stateVariables[
1639
+ stateVariables[
1640
+ stateVariables["/p6"].replacements[0].componentName
1641
+ ].activeChildren[0].componentName
1642
+ ].activeChildren[ind].componentName
1643
+ ].stateValues.value,
1644
+ ).eq(samplednumbers[ind]);
1645
+ expect(
1646
+ stateVariables[
1647
+ stateVariables[
1648
+ stateVariables[
1649
+ stateVariables["/p7"].replacements[0].componentName
1650
+ ].activeChildren[0].componentName
1651
+ ].activeChildren[ind].componentName
1652
+ ].stateValues.value,
1653
+ ).eq(samplednumbers[ind]);
1654
+ expect(
1655
+ stateVariables[
1656
+ stateVariables[
1657
+ stateVariables[
1658
+ stateVariables["/p8"].replacements[0].componentName
1659
+ ].activeChildren[0].componentName
1660
+ ].activeChildren[ind].componentName
1661
+ ].stateValues.value,
1662
+ ).eq(samplednumbers[ind]);
1663
+ expect(
1664
+ stateVariables[
1665
+ stateVariables[
1666
+ stateVariables[
1667
+ stateVariables["/p9"].replacements[0].componentName
1668
+ ].activeChildren[0].componentName
1669
+ ].activeChildren[ind].componentName
1670
+ ].stateValues.value,
1671
+ ).eq(samplednumbers[ind]);
1672
+ }
1673
+ });
1674
+
1675
+ cy.log("go back to nothing");
1676
+ cy.get(cesc("#\\/_mathinput1") + " textarea").type(
1677
+ `{end}{backspace}0{enter}`,
1678
+ { force: true },
1679
+ );
1680
+ cy.get(cesc("#\\/m1")).should("contain.text", "0");
1681
+ cy.window().then(async (win) => {
1682
+ let stateVariables = await win.returnAllStateVariables1();
1683
+ expect(
1684
+ stateVariables[stateVariables["/p1"].activeChildren[0].componentName]
1685
+ .activeChildren.length,
1686
+ ).eq(0);
1687
+ expect(
1688
+ stateVariables[stateVariables["/p2"].activeChildren[0].componentName]
1689
+ .activeChildren.length,
1690
+ ).eq(0);
1691
+ expect(
1692
+ stateVariables[stateVariables["/p3"].activeChildren[0].componentName]
1693
+ .activeChildren.length,
1694
+ ).eq(0);
1695
+ expect(
1696
+ stateVariables[
1697
+ stateVariables[stateVariables["/p4"].replacements[0].componentName]
1698
+ .activeChildren[0].componentName
1699
+ ].activeChildren.length,
1700
+ ).eq(0);
1701
+ expect(
1702
+ stateVariables[
1703
+ stateVariables[stateVariables["/p5"].replacements[0].componentName]
1704
+ .activeChildren[0].componentName
1705
+ ].activeChildren.length,
1706
+ ).eq(0);
1707
+ expect(
1708
+ stateVariables[
1709
+ stateVariables[stateVariables["/p6"].replacements[0].componentName]
1710
+ .activeChildren[0].componentName
1711
+ ].activeChildren.length,
1712
+ ).eq(0);
1713
+ expect(
1714
+ stateVariables[
1715
+ stateVariables[stateVariables["/p7"].replacements[0].componentName]
1716
+ .activeChildren[0].componentName
1717
+ ].activeChildren.length,
1718
+ ).eq(0);
1719
+ expect(
1720
+ stateVariables[
1721
+ stateVariables[stateVariables["/p8"].replacements[0].componentName]
1722
+ .activeChildren[0].componentName
1723
+ ].activeChildren.length,
1724
+ ).eq(0);
1725
+ expect(
1726
+ stateVariables[
1727
+ stateVariables[stateVariables["/p9"].replacements[0].componentName]
1728
+ .activeChildren[0].componentName
1729
+ ].activeChildren.length,
1730
+ ).eq(0);
1731
+ });
1732
+
1733
+ cy.log("get same number back");
1734
+ cy.get(cesc("#\\/_mathinput1") + " textarea").type(
1735
+ `{end}{backspace}1{enter}`,
1736
+ { force: true },
1737
+ );
1738
+ cy.get(cesc("#\\/m1")).should("contain.text", "1");
1739
+ cy.window().then(async (win) => {
1740
+ let stateVariables = await win.returnAllStateVariables1();
1741
+ let n1 = stateVariables["/a/n"].stateValues.value;
1742
+ expect(n1).eq(samplednumbers[0]);
1743
+ expect(
1744
+ stateVariables[stateVariables["/p1"].activeChildren[0].componentName]
1745
+ .activeChildren.length,
1746
+ ).eq(1);
1747
+ expect(
1748
+ stateVariables[stateVariables["/p2"].activeChildren[0].componentName]
1749
+ .activeChildren.length,
1750
+ ).eq(1);
1751
+ expect(
1752
+ stateVariables[stateVariables["/p3"].activeChildren[0].componentName]
1753
+ .activeChildren.length,
1754
+ ).eq(1);
1755
+ expect(
1756
+ stateVariables[
1757
+ stateVariables[stateVariables["/p4"].replacements[0].componentName]
1758
+ .activeChildren[0].componentName
1759
+ ].activeChildren.length,
1760
+ ).eq(1);
1761
+ expect(
1762
+ stateVariables[
1763
+ stateVariables[stateVariables["/p5"].replacements[0].componentName]
1764
+ .activeChildren[0].componentName
1765
+ ].activeChildren.length,
1766
+ ).eq(1);
1767
+ expect(
1768
+ stateVariables[
1769
+ stateVariables[stateVariables["/p6"].replacements[0].componentName]
1770
+ .activeChildren[0].componentName
1771
+ ].activeChildren.length,
1772
+ ).eq(1);
1773
+ expect(
1774
+ stateVariables[
1775
+ stateVariables[stateVariables["/p7"].replacements[0].componentName]
1776
+ .activeChildren[0].componentName
1777
+ ].activeChildren.length,
1778
+ ).eq(1);
1779
+ expect(
1780
+ stateVariables[
1781
+ stateVariables[stateVariables["/p8"].replacements[0].componentName]
1782
+ .activeChildren[0].componentName
1783
+ ].activeChildren.length,
1784
+ ).eq(1);
1785
+ expect(
1786
+ stateVariables[
1787
+ stateVariables[stateVariables["/p9"].replacements[0].componentName]
1788
+ .activeChildren[0].componentName
1789
+ ].activeChildren.length,
1790
+ ).eq(1);
1791
+
1792
+ for (let ind = 0; ind < 1; ind++) {
1793
+ expect(
1794
+ stateVariables[
1795
+ stateVariables[
1796
+ stateVariables["/p1"].activeChildren[0].componentName
1797
+ ].activeChildren[ind].componentName
1798
+ ].stateValues.value,
1799
+ ).eq(samplednumbers[ind]);
1800
+ expect(
1801
+ stateVariables[
1802
+ stateVariables[
1803
+ stateVariables["/p2"].activeChildren[0].componentName
1804
+ ].activeChildren[ind].componentName
1805
+ ].stateValues.value,
1806
+ ).eq(samplednumbers[ind]);
1807
+ expect(
1808
+ stateVariables[
1809
+ stateVariables[
1810
+ stateVariables["/p3"].activeChildren[0].componentName
1811
+ ].activeChildren[ind].componentName
1812
+ ].stateValues.value,
1813
+ ).eq(samplednumbers[ind]);
1814
+ expect(
1815
+ stateVariables[
1816
+ stateVariables[
1817
+ stateVariables[
1818
+ stateVariables["/p4"].replacements[0].componentName
1819
+ ].activeChildren[0].componentName
1820
+ ].activeChildren[ind].componentName
1821
+ ].stateValues.value,
1822
+ ).eq(samplednumbers[ind]);
1823
+ expect(
1824
+ stateVariables[
1825
+ stateVariables[
1826
+ stateVariables[
1827
+ stateVariables["/p5"].replacements[0].componentName
1828
+ ].activeChildren[0].componentName
1829
+ ].activeChildren[ind].componentName
1830
+ ].stateValues.value,
1831
+ ).eq(samplednumbers[ind]);
1832
+ expect(
1833
+ stateVariables[
1834
+ stateVariables[
1835
+ stateVariables[
1836
+ stateVariables["/p6"].replacements[0].componentName
1837
+ ].activeChildren[0].componentName
1838
+ ].activeChildren[ind].componentName
1839
+ ].stateValues.value,
1840
+ ).eq(samplednumbers[ind]);
1841
+ expect(
1842
+ stateVariables[
1843
+ stateVariables[
1844
+ stateVariables[
1845
+ stateVariables["/p7"].replacements[0].componentName
1846
+ ].activeChildren[0].componentName
1847
+ ].activeChildren[ind].componentName
1848
+ ].stateValues.value,
1849
+ ).eq(samplednumbers[ind]);
1850
+ expect(
1851
+ stateVariables[
1852
+ stateVariables[
1853
+ stateVariables[
1854
+ stateVariables["/p8"].replacements[0].componentName
1855
+ ].activeChildren[0].componentName
1856
+ ].activeChildren[ind].componentName
1857
+ ].stateValues.value,
1858
+ ).eq(samplednumbers[ind]);
1859
+ expect(
1860
+ stateVariables[
1861
+ stateVariables[
1862
+ stateVariables[
1863
+ stateVariables["/p9"].replacements[0].componentName
1864
+ ].activeChildren[0].componentName
1865
+ ].activeChildren[ind].componentName
1866
+ ].stateValues.value,
1867
+ ).eq(samplednumbers[ind]);
1868
+ }
1869
+ });
1870
+
1871
+ cy.log("get two more samples");
1872
+ cy.get(cesc("#\\/_mathinput1") + " textarea").type(
1873
+ `{end}{backspace}3{enter}`,
1874
+ { force: true },
1875
+ );
1876
+ cy.get(cesc("#\\/m1")).should("contain.text", "3");
1877
+ cy.window().then(async (win) => {
1878
+ let stateVariables = await win.returnAllStateVariables1();
1879
+ let n1 = stateVariables["/a/n"].stateValues.value;
1880
+ let n2 = stateVariables["/b/n"].stateValues.value;
1881
+ let n3 = stateVariables["/c/n"].stateValues.value;
1882
+ expect(n1).eq(samplednumbers[0]);
1883
+ samplednumbers.push(n2);
1884
+ samplednumbers.push(n3);
1885
+ expect(
1886
+ stateVariables[stateVariables["/p1"].activeChildren[0].componentName]
1887
+ .activeChildren.length,
1888
+ ).eq(3);
1889
+ expect(
1890
+ stateVariables[stateVariables["/p2"].activeChildren[0].componentName]
1891
+ .activeChildren.length,
1892
+ ).eq(3);
1893
+ expect(
1894
+ stateVariables[stateVariables["/p3"].activeChildren[0].componentName]
1895
+ .activeChildren.length,
1896
+ ).eq(3);
1897
+ expect(
1898
+ stateVariables[
1899
+ stateVariables[stateVariables["/p4"].replacements[0].componentName]
1900
+ .activeChildren[0].componentName
1901
+ ].activeChildren.length,
1902
+ ).eq(3);
1903
+ expect(
1904
+ stateVariables[
1905
+ stateVariables[stateVariables["/p5"].replacements[0].componentName]
1906
+ .activeChildren[0].componentName
1907
+ ].activeChildren.length,
1908
+ ).eq(3);
1909
+ expect(
1910
+ stateVariables[
1911
+ stateVariables[stateVariables["/p6"].replacements[0].componentName]
1912
+ .activeChildren[0].componentName
1913
+ ].activeChildren.length,
1914
+ ).eq(3);
1915
+ expect(
1916
+ stateVariables[
1917
+ stateVariables[stateVariables["/p7"].replacements[0].componentName]
1918
+ .activeChildren[0].componentName
1919
+ ].activeChildren.length,
1920
+ ).eq(3);
1921
+ expect(
1922
+ stateVariables[
1923
+ stateVariables[stateVariables["/p8"].replacements[0].componentName]
1924
+ .activeChildren[0].componentName
1925
+ ].activeChildren.length,
1926
+ ).eq(3);
1927
+ expect(
1928
+ stateVariables[
1929
+ stateVariables[stateVariables["/p9"].replacements[0].componentName]
1930
+ .activeChildren[0].componentName
1931
+ ].activeChildren.length,
1932
+ ).eq(3);
1933
+ for (let ind = 0; ind < 3; ind++) {
1934
+ expect(
1935
+ stateVariables[
1936
+ stateVariables[
1937
+ stateVariables["/p1"].activeChildren[0].componentName
1938
+ ].activeChildren[ind].componentName
1939
+ ].stateValues.value,
1940
+ ).eq(samplednumbers[ind]);
1941
+ expect(
1942
+ stateVariables[
1943
+ stateVariables[
1944
+ stateVariables["/p2"].activeChildren[0].componentName
1945
+ ].activeChildren[ind].componentName
1946
+ ].stateValues.value,
1947
+ ).eq(samplednumbers[ind]);
1948
+ expect(
1949
+ stateVariables[
1950
+ stateVariables[
1951
+ stateVariables["/p3"].activeChildren[0].componentName
1952
+ ].activeChildren[ind].componentName
1953
+ ].stateValues.value,
1954
+ ).eq(samplednumbers[ind]);
1955
+ expect(
1956
+ stateVariables[
1957
+ stateVariables[
1958
+ stateVariables[
1959
+ stateVariables["/p4"].replacements[0].componentName
1960
+ ].activeChildren[0].componentName
1961
+ ].activeChildren[ind].componentName
1962
+ ].stateValues.value,
1963
+ ).eq(samplednumbers[ind]);
1964
+ expect(
1965
+ stateVariables[
1966
+ stateVariables[
1967
+ stateVariables[
1968
+ stateVariables["/p5"].replacements[0].componentName
1969
+ ].activeChildren[0].componentName
1970
+ ].activeChildren[ind].componentName
1971
+ ].stateValues.value,
1972
+ ).eq(samplednumbers[ind]);
1973
+ expect(
1974
+ stateVariables[
1975
+ stateVariables[
1976
+ stateVariables[
1977
+ stateVariables["/p6"].replacements[0].componentName
1978
+ ].activeChildren[0].componentName
1979
+ ].activeChildren[ind].componentName
1980
+ ].stateValues.value,
1981
+ ).eq(samplednumbers[ind]);
1982
+ expect(
1983
+ stateVariables[
1984
+ stateVariables[
1985
+ stateVariables[
1986
+ stateVariables["/p7"].replacements[0].componentName
1987
+ ].activeChildren[0].componentName
1988
+ ].activeChildren[ind].componentName
1989
+ ].stateValues.value,
1990
+ ).eq(samplednumbers[ind]);
1991
+ expect(
1992
+ stateVariables[
1993
+ stateVariables[
1994
+ stateVariables[
1995
+ stateVariables["/p8"].replacements[0].componentName
1996
+ ].activeChildren[0].componentName
1997
+ ].activeChildren[ind].componentName
1998
+ ].stateValues.value,
1999
+ ).eq(samplednumbers[ind]);
2000
+ expect(
2001
+ stateVariables[
2002
+ stateVariables[
2003
+ stateVariables[
2004
+ stateVariables["/p9"].replacements[0].componentName
2005
+ ].activeChildren[0].componentName
2006
+ ].activeChildren[ind].componentName
2007
+ ].stateValues.value,
2008
+ ).eq(samplednumbers[ind]);
2009
+ }
2010
+ });
2011
+
2012
+ cy.log("go back to nothing");
2013
+ cy.get(cesc("#\\/_mathinput1") + " textarea").type(
2014
+ `{end}{backspace}0{enter}`,
2015
+ { force: true },
2016
+ );
2017
+ cy.get(cesc("#\\/m1")).should("contain.text", "0");
2018
+ cy.window().then(async (win) => {
2019
+ let stateVariables = await win.returnAllStateVariables1();
2020
+ expect(
2021
+ stateVariables[stateVariables["/p1"].activeChildren[0].componentName]
2022
+ .activeChildren.length,
2023
+ ).eq(0);
2024
+ expect(
2025
+ stateVariables[stateVariables["/p2"].activeChildren[0].componentName]
2026
+ .activeChildren.length,
2027
+ ).eq(0);
2028
+ expect(
2029
+ stateVariables[stateVariables["/p3"].activeChildren[0].componentName]
2030
+ .activeChildren.length,
2031
+ ).eq(0);
2032
+ expect(
2033
+ stateVariables[
2034
+ stateVariables[stateVariables["/p4"].replacements[0].componentName]
2035
+ .activeChildren[0].componentName
2036
+ ].activeChildren.length,
2037
+ ).eq(0);
2038
+ expect(
2039
+ stateVariables[
2040
+ stateVariables[stateVariables["/p5"].replacements[0].componentName]
2041
+ .activeChildren[0].componentName
2042
+ ].activeChildren.length,
2043
+ ).eq(0);
2044
+ expect(
2045
+ stateVariables[
2046
+ stateVariables[stateVariables["/p6"].replacements[0].componentName]
2047
+ .activeChildren[0].componentName
2048
+ ].activeChildren.length,
2049
+ ).eq(0);
2050
+ expect(
2051
+ stateVariables[
2052
+ stateVariables[stateVariables["/p7"].replacements[0].componentName]
2053
+ .activeChildren[0].componentName
2054
+ ].activeChildren.length,
2055
+ ).eq(0);
2056
+ expect(
2057
+ stateVariables[
2058
+ stateVariables[stateVariables["/p8"].replacements[0].componentName]
2059
+ .activeChildren[0].componentName
2060
+ ].activeChildren.length,
2061
+ ).eq(0);
2062
+ expect(
2063
+ stateVariables[
2064
+ stateVariables[stateVariables["/p9"].replacements[0].componentName]
2065
+ .activeChildren[0].componentName
2066
+ ].activeChildren.length,
2067
+ ).eq(0);
2068
+ });
2069
+
2070
+ cy.log("get first two numbers back");
2071
+ cy.get(cesc("#\\/_mathinput1") + " textarea").type(
2072
+ `{end}{backspace}2{enter}`,
2073
+ { force: true },
2074
+ );
2075
+ cy.get(cesc("#\\/m1")).should("contain.text", "2");
2076
+ cy.window().then(async (win) => {
2077
+ let stateVariables = await win.returnAllStateVariables1();
2078
+ let n1 = stateVariables["/a/n"].stateValues.value;
2079
+ let n2 = stateVariables["/b/n"].stateValues.value;
2080
+ expect(n1).eq(samplednumbers[0]);
2081
+ expect(n2).eq(samplednumbers[1]);
2082
+ expect(
2083
+ stateVariables[stateVariables["/p1"].activeChildren[0].componentName]
2084
+ .activeChildren.length,
2085
+ ).eq(2);
2086
+ expect(
2087
+ stateVariables[stateVariables["/p2"].activeChildren[0].componentName]
2088
+ .activeChildren.length,
2089
+ ).eq(2);
2090
+ expect(
2091
+ stateVariables[stateVariables["/p3"].activeChildren[0].componentName]
2092
+ .activeChildren.length,
2093
+ ).eq(2);
2094
+ expect(
2095
+ stateVariables[
2096
+ stateVariables[stateVariables["/p4"].replacements[0].componentName]
2097
+ .activeChildren[0].componentName
2098
+ ].activeChildren.length,
2099
+ ).eq(2);
2100
+ expect(
2101
+ stateVariables[
2102
+ stateVariables[stateVariables["/p5"].replacements[0].componentName]
2103
+ .activeChildren[0].componentName
2104
+ ].activeChildren.length,
2105
+ ).eq(2);
2106
+ expect(
2107
+ stateVariables[
2108
+ stateVariables[stateVariables["/p6"].replacements[0].componentName]
2109
+ .activeChildren[0].componentName
2110
+ ].activeChildren.length,
2111
+ ).eq(2);
2112
+ expect(
2113
+ stateVariables[
2114
+ stateVariables[stateVariables["/p7"].replacements[0].componentName]
2115
+ .activeChildren[0].componentName
2116
+ ].activeChildren.length,
2117
+ ).eq(2);
2118
+ expect(
2119
+ stateVariables[
2120
+ stateVariables[stateVariables["/p8"].replacements[0].componentName]
2121
+ .activeChildren[0].componentName
2122
+ ].activeChildren.length,
2123
+ ).eq(2);
2124
+ expect(
2125
+ stateVariables[
2126
+ stateVariables[stateVariables["/p9"].replacements[0].componentName]
2127
+ .activeChildren[0].componentName
2128
+ ].activeChildren.length,
2129
+ ).eq(2);
2130
+
2131
+ for (let ind = 0; ind < 2; ind++) {
2132
+ expect(
2133
+ stateVariables[
2134
+ stateVariables[
2135
+ stateVariables["/p1"].activeChildren[0].componentName
2136
+ ].activeChildren[ind].componentName
2137
+ ].stateValues.value,
2138
+ ).eq(samplednumbers[ind]);
2139
+ expect(
2140
+ stateVariables[
2141
+ stateVariables[
2142
+ stateVariables["/p2"].activeChildren[0].componentName
2143
+ ].activeChildren[ind].componentName
2144
+ ].stateValues.value,
2145
+ ).eq(samplednumbers[ind]);
2146
+ expect(
2147
+ stateVariables[
2148
+ stateVariables[
2149
+ stateVariables["/p3"].activeChildren[0].componentName
2150
+ ].activeChildren[ind].componentName
2151
+ ].stateValues.value,
2152
+ ).eq(samplednumbers[ind]);
2153
+ expect(
2154
+ stateVariables[
2155
+ stateVariables[
2156
+ stateVariables[
2157
+ stateVariables["/p4"].replacements[0].componentName
2158
+ ].activeChildren[0].componentName
2159
+ ].activeChildren[ind].componentName
2160
+ ].stateValues.value,
2161
+ ).eq(samplednumbers[ind]);
2162
+ expect(
2163
+ stateVariables[
2164
+ stateVariables[
2165
+ stateVariables[
2166
+ stateVariables["/p5"].replacements[0].componentName
2167
+ ].activeChildren[0].componentName
2168
+ ].activeChildren[ind].componentName
2169
+ ].stateValues.value,
2170
+ ).eq(samplednumbers[ind]);
2171
+ expect(
2172
+ stateVariables[
2173
+ stateVariables[
2174
+ stateVariables[
2175
+ stateVariables["/p6"].replacements[0].componentName
2176
+ ].activeChildren[0].componentName
2177
+ ].activeChildren[ind].componentName
2178
+ ].stateValues.value,
2179
+ ).eq(samplednumbers[ind]);
2180
+ expect(
2181
+ stateVariables[
2182
+ stateVariables[
2183
+ stateVariables[
2184
+ stateVariables["/p7"].replacements[0].componentName
2185
+ ].activeChildren[0].componentName
2186
+ ].activeChildren[ind].componentName
2187
+ ].stateValues.value,
2188
+ ).eq(samplednumbers[ind]);
2189
+ expect(
2190
+ stateVariables[
2191
+ stateVariables[
2192
+ stateVariables[
2193
+ stateVariables["/p8"].replacements[0].componentName
2194
+ ].activeChildren[0].componentName
2195
+ ].activeChildren[ind].componentName
2196
+ ].stateValues.value,
2197
+ ).eq(samplednumbers[ind]);
2198
+ expect(
2199
+ stateVariables[
2200
+ stateVariables[
2201
+ stateVariables[
2202
+ stateVariables["/p9"].replacements[0].componentName
2203
+ ].activeChildren[0].componentName
2204
+ ].activeChildren[ind].componentName
2205
+ ].stateValues.value,
2206
+ ).eq(samplednumbers[ind]);
2207
+ }
2208
+ });
2209
+
2210
+ cy.log("get six total samples");
2211
+ cy.get(cesc("#\\/_mathinput1") + " textarea").type(
2212
+ `{end}{backspace}6{enter}`,
2213
+ { force: true },
2214
+ );
2215
+ cy.get(cesc("#\\/m1")).should("contain.text", "6");
2216
+ cy.window().then(async (win) => {
2217
+ let stateVariables = await win.returnAllStateVariables1();
2218
+ let n1 = stateVariables["/a/n"].stateValues.value;
2219
+ let n2 = stateVariables["/b/n"].stateValues.value;
2220
+ let n3 = stateVariables["/c/n"].stateValues.value;
2221
+ let n4 = stateVariables["/d/n"].stateValues.value;
2222
+ let n5 = stateVariables["/e/n"].stateValues.value;
2223
+ let n6 = stateVariables["/f/n"].stateValues.value;
2224
+ expect(n1).eq(samplednumbers[0]);
2225
+ expect(n2).eq(samplednumbers[1]);
2226
+ expect(n3).eq(samplednumbers[2]);
2227
+ samplednumbers.push(n4);
2228
+ samplednumbers.push(n5);
2229
+ samplednumbers.push(n6);
2230
+ expect(
2231
+ stateVariables[stateVariables["/p1"].activeChildren[0].componentName]
2232
+ .activeChildren.length,
2233
+ ).eq(6);
2234
+ expect(
2235
+ stateVariables[stateVariables["/p2"].activeChildren[0].componentName]
2236
+ .activeChildren.length,
2237
+ ).eq(6);
2238
+ expect(
2239
+ stateVariables[stateVariables["/p3"].activeChildren[0].componentName]
2240
+ .activeChildren.length,
2241
+ ).eq(6);
2242
+ expect(
2243
+ stateVariables[
2244
+ stateVariables[stateVariables["/p4"].replacements[0].componentName]
2245
+ .activeChildren[0].componentName
2246
+ ].activeChildren.length,
2247
+ ).eq(6);
2248
+ expect(
2249
+ stateVariables[
2250
+ stateVariables[stateVariables["/p5"].replacements[0].componentName]
2251
+ .activeChildren[0].componentName
2252
+ ].activeChildren.length,
2253
+ ).eq(6);
2254
+ expect(
2255
+ stateVariables[
2256
+ stateVariables[stateVariables["/p6"].replacements[0].componentName]
2257
+ .activeChildren[0].componentName
2258
+ ].activeChildren.length,
2259
+ ).eq(6);
2260
+ expect(
2261
+ stateVariables[
2262
+ stateVariables[stateVariables["/p7"].replacements[0].componentName]
2263
+ .activeChildren[0].componentName
2264
+ ].activeChildren.length,
2265
+ ).eq(6);
2266
+ expect(
2267
+ stateVariables[
2268
+ stateVariables[stateVariables["/p8"].replacements[0].componentName]
2269
+ .activeChildren[0].componentName
2270
+ ].activeChildren.length,
2271
+ ).eq(6);
2272
+ expect(
2273
+ stateVariables[
2274
+ stateVariables[stateVariables["/p9"].replacements[0].componentName]
2275
+ .activeChildren[0].componentName
2276
+ ].activeChildren.length,
2277
+ ).eq(6);
2278
+ for (let ind = 0; ind < 6; ind++) {
2279
+ expect(
2280
+ stateVariables[
2281
+ stateVariables[
2282
+ stateVariables["/p1"].activeChildren[0].componentName
2283
+ ].activeChildren[ind].componentName
2284
+ ].stateValues.value,
2285
+ ).eq(samplednumbers[ind]);
2286
+ expect(
2287
+ stateVariables[
2288
+ stateVariables[
2289
+ stateVariables["/p2"].activeChildren[0].componentName
2290
+ ].activeChildren[ind].componentName
2291
+ ].stateValues.value,
2292
+ ).eq(samplednumbers[ind]);
2293
+ expect(
2294
+ stateVariables[
2295
+ stateVariables[
2296
+ stateVariables["/p3"].activeChildren[0].componentName
2297
+ ].activeChildren[ind].componentName
2298
+ ].stateValues.value,
2299
+ ).eq(samplednumbers[ind]);
2300
+ expect(
2301
+ stateVariables[
2302
+ stateVariables[
2303
+ stateVariables[
2304
+ stateVariables["/p4"].replacements[0].componentName
2305
+ ].activeChildren[0].componentName
2306
+ ].activeChildren[ind].componentName
2307
+ ].stateValues.value,
2308
+ ).eq(samplednumbers[ind]);
2309
+ expect(
2310
+ stateVariables[
2311
+ stateVariables[
2312
+ stateVariables[
2313
+ stateVariables["/p5"].replacements[0].componentName
2314
+ ].activeChildren[0].componentName
2315
+ ].activeChildren[ind].componentName
2316
+ ].stateValues.value,
2317
+ ).eq(samplednumbers[ind]);
2318
+ expect(
2319
+ stateVariables[
2320
+ stateVariables[
2321
+ stateVariables[
2322
+ stateVariables["/p6"].replacements[0].componentName
2323
+ ].activeChildren[0].componentName
2324
+ ].activeChildren[ind].componentName
2325
+ ].stateValues.value,
2326
+ ).eq(samplednumbers[ind]);
2327
+ expect(
2328
+ stateVariables[
2329
+ stateVariables[
2330
+ stateVariables[
2331
+ stateVariables["/p7"].replacements[0].componentName
2332
+ ].activeChildren[0].componentName
2333
+ ].activeChildren[ind].componentName
2334
+ ].stateValues.value,
2335
+ ).eq(samplednumbers[ind]);
2336
+ expect(
2337
+ stateVariables[
2338
+ stateVariables[
2339
+ stateVariables[
2340
+ stateVariables["/p8"].replacements[0].componentName
2341
+ ].activeChildren[0].componentName
2342
+ ].activeChildren[ind].componentName
2343
+ ].stateValues.value,
2344
+ ).eq(samplednumbers[ind]);
2345
+ expect(
2346
+ stateVariables[
2347
+ stateVariables[
2348
+ stateVariables[
2349
+ stateVariables["/p9"].replacements[0].componentName
2350
+ ].activeChildren[0].componentName
2351
+ ].activeChildren[ind].componentName
2352
+ ].stateValues.value,
2353
+ ).eq(samplednumbers[ind]);
2354
+ }
2355
+ });
2356
+
2357
+ cy.log("go back to nothing");
2358
+ cy.get(cesc("#\\/_mathinput1") + " textarea").type(
2359
+ `{end}{backspace}0{enter}`,
2360
+ { force: true },
2361
+ );
2362
+ cy.get(cesc("#\\/m1")).should("contain.text", "0");
2363
+ cy.window().then(async (win) => {
2364
+ let stateVariables = await win.returnAllStateVariables1();
2365
+ expect(
2366
+ stateVariables[stateVariables["/p1"].activeChildren[0].componentName]
2367
+ .activeChildren.length,
2368
+ ).eq(0);
2369
+ expect(
2370
+ stateVariables[stateVariables["/p2"].activeChildren[0].componentName]
2371
+ .activeChildren.length,
2372
+ ).eq(0);
2373
+ expect(
2374
+ stateVariables[stateVariables["/p3"].activeChildren[0].componentName]
2375
+ .activeChildren.length,
2376
+ ).eq(0);
2377
+ expect(
2378
+ stateVariables[
2379
+ stateVariables[stateVariables["/p4"].replacements[0].componentName]
2380
+ .activeChildren[0].componentName
2381
+ ].activeChildren.length,
2382
+ ).eq(0);
2383
+ expect(
2384
+ stateVariables[
2385
+ stateVariables[stateVariables["/p5"].replacements[0].componentName]
2386
+ .activeChildren[0].componentName
2387
+ ].activeChildren.length,
2388
+ ).eq(0);
2389
+ expect(
2390
+ stateVariables[
2391
+ stateVariables[stateVariables["/p6"].replacements[0].componentName]
2392
+ .activeChildren[0].componentName
2393
+ ].activeChildren.length,
2394
+ ).eq(0);
2395
+ expect(
2396
+ stateVariables[
2397
+ stateVariables[stateVariables["/p7"].replacements[0].componentName]
2398
+ .activeChildren[0].componentName
2399
+ ].activeChildren.length,
2400
+ ).eq(0);
2401
+ expect(
2402
+ stateVariables[
2403
+ stateVariables[stateVariables["/p8"].replacements[0].componentName]
2404
+ .activeChildren[0].componentName
2405
+ ].activeChildren.length,
2406
+ ).eq(0);
2407
+ expect(
2408
+ stateVariables[
2409
+ stateVariables[stateVariables["/p9"].replacements[0].componentName]
2410
+ .activeChildren[0].componentName
2411
+ ].activeChildren.length,
2412
+ ).eq(0);
2413
+ });
2414
+
2415
+ cy.log("get all six back");
2416
+ cy.get(cesc("#\\/_mathinput1") + " textarea").type(
2417
+ `{end}{backspace}6{enter}`,
2418
+ { force: true },
2419
+ );
2420
+ cy.get(cesc("#\\/m1")).should("contain.text", "6");
2421
+ cy.window().then(async (win) => {
2422
+ let stateVariables = await win.returnAllStateVariables1();
2423
+ let n1 = stateVariables["/a/n"].stateValues.value;
2424
+ let n2 = stateVariables["/b/n"].stateValues.value;
2425
+ let n3 = stateVariables["/c/n"].stateValues.value;
2426
+ let n4 = stateVariables["/d/n"].stateValues.value;
2427
+ let n5 = stateVariables["/e/n"].stateValues.value;
2428
+ let n6 = stateVariables["/f/n"].stateValues.value;
2429
+ expect(n1).eq(samplednumbers[0]);
2430
+ expect(n2).eq(samplednumbers[1]);
2431
+ expect(n3).eq(samplednumbers[2]);
2432
+ expect(n4).eq(samplednumbers[3]);
2433
+ expect(n5).eq(samplednumbers[4]);
2434
+ expect(n6).eq(samplednumbers[5]);
2435
+ expect(
2436
+ stateVariables[stateVariables["/p1"].activeChildren[0].componentName]
2437
+ .activeChildren.length,
2438
+ ).eq(6);
2439
+ expect(
2440
+ stateVariables[stateVariables["/p2"].activeChildren[0].componentName]
2441
+ .activeChildren.length,
2442
+ ).eq(6);
2443
+ expect(
2444
+ stateVariables[stateVariables["/p3"].activeChildren[0].componentName]
2445
+ .activeChildren.length,
2446
+ ).eq(6);
2447
+ expect(
2448
+ stateVariables[
2449
+ stateVariables[stateVariables["/p4"].replacements[0].componentName]
2450
+ .activeChildren[0].componentName
2451
+ ].activeChildren.length,
2452
+ ).eq(6);
2453
+ expect(
2454
+ stateVariables[
2455
+ stateVariables[stateVariables["/p5"].replacements[0].componentName]
2456
+ .activeChildren[0].componentName
2457
+ ].activeChildren.length,
2458
+ ).eq(6);
2459
+ expect(
2460
+ stateVariables[
2461
+ stateVariables[stateVariables["/p6"].replacements[0].componentName]
2462
+ .activeChildren[0].componentName
2463
+ ].activeChildren.length,
2464
+ ).eq(6);
2465
+ expect(
2466
+ stateVariables[
2467
+ stateVariables[stateVariables["/p7"].replacements[0].componentName]
2468
+ .activeChildren[0].componentName
2469
+ ].activeChildren.length,
2470
+ ).eq(6);
2471
+ expect(
2472
+ stateVariables[
2473
+ stateVariables[stateVariables["/p8"].replacements[0].componentName]
2474
+ .activeChildren[0].componentName
2475
+ ].activeChildren.length,
2476
+ ).eq(6);
2477
+ expect(
2478
+ stateVariables[
2479
+ stateVariables[stateVariables["/p9"].replacements[0].componentName]
2480
+ .activeChildren[0].componentName
2481
+ ].activeChildren.length,
2482
+ ).eq(6);
2483
+ for (let ind = 0; ind < 6; ind++) {
2484
+ expect(
2485
+ stateVariables[
2486
+ stateVariables[
2487
+ stateVariables["/p1"].activeChildren[0].componentName
2488
+ ].activeChildren[ind].componentName
2489
+ ].stateValues.value,
2490
+ ).eq(samplednumbers[ind]);
2491
+ expect(
2492
+ stateVariables[
2493
+ stateVariables[
2494
+ stateVariables["/p2"].activeChildren[0].componentName
2495
+ ].activeChildren[ind].componentName
2496
+ ].stateValues.value,
2497
+ ).eq(samplednumbers[ind]);
2498
+ expect(
2499
+ stateVariables[
2500
+ stateVariables[
2501
+ stateVariables["/p3"].activeChildren[0].componentName
2502
+ ].activeChildren[ind].componentName
2503
+ ].stateValues.value,
2504
+ ).eq(samplednumbers[ind]);
2505
+ expect(
2506
+ stateVariables[
2507
+ stateVariables[
2508
+ stateVariables[
2509
+ stateVariables["/p4"].replacements[0].componentName
2510
+ ].activeChildren[0].componentName
2511
+ ].activeChildren[ind].componentName
2512
+ ].stateValues.value,
2513
+ ).eq(samplednumbers[ind]);
2514
+ expect(
2515
+ stateVariables[
2516
+ stateVariables[
2517
+ stateVariables[
2518
+ stateVariables["/p5"].replacements[0].componentName
2519
+ ].activeChildren[0].componentName
2520
+ ].activeChildren[ind].componentName
2521
+ ].stateValues.value,
2522
+ ).eq(samplednumbers[ind]);
2523
+ expect(
2524
+ stateVariables[
2525
+ stateVariables[
2526
+ stateVariables[
2527
+ stateVariables["/p6"].replacements[0].componentName
2528
+ ].activeChildren[0].componentName
2529
+ ].activeChildren[ind].componentName
2530
+ ].stateValues.value,
2531
+ ).eq(samplednumbers[ind]);
2532
+ expect(
2533
+ stateVariables[
2534
+ stateVariables[
2535
+ stateVariables[
2536
+ stateVariables["/p7"].replacements[0].componentName
2537
+ ].activeChildren[0].componentName
2538
+ ].activeChildren[ind].componentName
2539
+ ].stateValues.value,
2540
+ ).eq(samplednumbers[ind]);
2541
+ expect(
2542
+ stateVariables[
2543
+ stateVariables[
2544
+ stateVariables[
2545
+ stateVariables["/p8"].replacements[0].componentName
2546
+ ].activeChildren[0].componentName
2547
+ ].activeChildren[ind].componentName
2548
+ ].stateValues.value,
2549
+ ).eq(samplednumbers[ind]);
2550
+ expect(
2551
+ stateVariables[
2552
+ stateVariables[
2553
+ stateVariables[
2554
+ stateVariables["/p9"].replacements[0].componentName
2555
+ ].activeChildren[0].componentName
2556
+ ].activeChildren[ind].componentName
2557
+ ].stateValues.value,
2558
+ ).eq(samplednumbers[ind]);
2559
+ }
2560
+ });
2561
+ });
2562
+
2563
+ it("select single discrete uniform number, assign name", () => {
2564
+ cy.window().then(async (win) => {
2565
+ win.postMessage(
2566
+ {
2567
+ doenetML: `
2568
+ <text>a</text>
2569
+ <p><selectRandomNumbers type="discreteUniform" from="3" step="7" to="16" assignnames="u"/></p>
2570
+ <p><selectRandomNumbers type="discreteUniform" from="3" step="7" to="16" assignnames="v"/></p>
2571
+ <p><selectRandomNumbers type="discreteUniform" from="3" step="7" to="16" assignnames="w"/></p>
2572
+ <p><copy assignNames="u2" target="u" /></p>
2573
+ <p><copy assignNames="v2" target="v" /></p>
2574
+ <p><copy assignNames="w2" target="w" /></p>
2575
+ `,
2576
+ },
2577
+ "*",
2578
+ );
2579
+ });
2580
+
2581
+ let options = [3, 10];
2582
+
2583
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2584
+
2585
+ cy.window().then(async (win) => {
2586
+ let stateVariables = await win.returnAllStateVariables1();
2587
+
2588
+ let u = stateVariables["/u"];
2589
+ let u2 = stateVariables["/u2"];
2590
+
2591
+ expect(options.includes(u.stateValues.value)).eq(true);
2592
+ expect(u.stateValues.value).eq(u2.stateValues.value);
2593
+
2594
+ let v = stateVariables["/v"];
2595
+ let v2 = stateVariables["/v2"];
2596
+ expect(options.includes(v.stateValues.value)).eq(true);
2597
+ expect(v.stateValues.value).eq(v2.stateValues.value);
2598
+
2599
+ let w = stateVariables["/w"];
2600
+ let w2 = stateVariables["/w2"];
2601
+ expect(options.includes(w.stateValues.value)).eq(true);
2602
+ expect(w.stateValues.value).eq(w2.stateValues.value);
2603
+ });
2604
+ });
2605
+
2606
+ it("select multiple uniform random numbers, assign names", () => {
2607
+ cy.window().then(async (win) => {
2608
+ win.postMessage(
2609
+ {
2610
+ doenetML: `
2611
+ <text>a</text>
2612
+ <p><aslist>
2613
+ <selectRandomNumbers name="s" from="3" to="13" assignnames="u v w" numToSelect="6" displayDigits="10" />
2614
+ </aslist></p>
2615
+ <p><copy assignNames="u2" target="u" /></p>
2616
+ <p><copy assignNames="v2" target="v" /></p>
2617
+ <p><copy assignNames="w2" target="w" /></p>
2618
+ `,
2619
+ },
2620
+ "*",
2621
+ );
2622
+ });
2623
+
2624
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2625
+
2626
+ let results = [];
2627
+
2628
+ for (let ind = 0; ind < 6; ind++) {
2629
+ cy.get(cesc("#\\/_p1") + " > :nth-child(" + (2 * ind + 4) + ")")
2630
+ .invoke("text")
2631
+ .then((text) => {
2632
+ let num = Number(text);
2633
+ results[ind] = num;
2634
+ expect(num).gte(3);
2635
+ expect(num).lt(13);
2636
+ });
2637
+ }
2638
+
2639
+ cy.log("check by name").then(() => {
2640
+ cy.get(cesc("#\\/u")).should("have.text", results[0]);
2641
+ cy.get(cesc("#\\/u2")).should("have.text", results[0]);
2642
+ cy.get(cesc("#\\/v")).should("have.text", results[1]);
2643
+ cy.get(cesc("#\\/v2")).should("have.text", results[1]);
2644
+ cy.get(cesc("#\\/w")).should("have.text", results[2]);
2645
+ cy.get(cesc("#\\/w2")).should("have.text", results[2]);
2646
+ });
2647
+ cy.window().then(async (win) => {
2648
+ let stateVariables = await win.returnAllStateVariables1();
2649
+
2650
+ let u = stateVariables["/u"];
2651
+ let u2 = stateVariables["/u2"];
2652
+ expect(u.stateValues.value).closeTo(results[0], 1e-8);
2653
+ expect(u2.stateValues.value).closeTo(results[0], 1e-8);
2654
+
2655
+ let v = stateVariables["/v"];
2656
+ let v2 = stateVariables["/v2"];
2657
+ expect(v.stateValues.value).closeTo(results[1], 1e-8);
2658
+ expect(v2.stateValues.value).closeTo(results[1], 1e-8);
2659
+
2660
+ let w = stateVariables["/w"];
2661
+ let w2 = stateVariables["/w2"];
2662
+ expect(w.stateValues.value).closeTo(results[2], 1e-8);
2663
+ expect(w2.stateValues.value).closeTo(results[2], 1e-8);
2664
+
2665
+ let s = stateVariables["/s"];
2666
+ expect(s.replacements.length).eq(6);
2667
+ for (let ind = 0; ind < 6; ind++) {
2668
+ let r = stateVariables[s.replacements[ind].componentName];
2669
+ expect(r.stateValues.value).closeTo(results[ind], 1e-8);
2670
+ }
2671
+ });
2672
+ });
2673
+
2674
+ it("select multiple uniform random numbers, assign names, newNamespace", () => {
2675
+ cy.window().then(async (win) => {
2676
+ win.postMessage(
2677
+ {
2678
+ doenetML: `
2679
+ <text>a</text>
2680
+ <p><aslist>
2681
+ <selectRandomNumbers name="s" newnamespace from="3" to="13" assignnames="u v w" numToSelect="6" displayDigits="10" />
2682
+ </aslist></p>
2683
+ <p><copy assignNames="u2" target="s/u" /></p>
2684
+ <p><copy assignNames="v2" target="s/v" /></p>
2685
+ <p><copy assignNames="w2" target="s/w" /></p>
2686
+ `,
2687
+ },
2688
+ "*",
2689
+ );
2690
+ });
2691
+
2692
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2693
+
2694
+ let results = [];
2695
+
2696
+ for (let ind = 0; ind < 6; ind++) {
2697
+ cy.get(cesc("#\\/_p1") + " > :nth-child(" + (2 * ind + 4) + ")")
2698
+ .invoke("text")
2699
+ .then((text) => {
2700
+ let num = Number(text);
2701
+ results[ind] = num;
2702
+ expect(num).gte(3);
2703
+ expect(num).lt(13);
2704
+ });
2705
+ }
2706
+
2707
+ cy.log("check by name").then(() => {
2708
+ cy.get(cesc("#\\/s\\/u")).should("have.text", results[0]);
2709
+ cy.get(cesc("#\\/u2")).should("have.text", results[0]);
2710
+ cy.get(cesc("#\\/s\\/v")).should("have.text", results[1]);
2711
+ cy.get(cesc("#\\/v2")).should("have.text", results[1]);
2712
+ cy.get(cesc("#\\/s\\/w")).should("have.text", results[2]);
2713
+ cy.get(cesc("#\\/w2")).should("have.text", results[2]);
2714
+ });
2715
+ cy.window().then(async (win) => {
2716
+ let stateVariables = await win.returnAllStateVariables1();
2717
+
2718
+ let u = stateVariables["/s/u"];
2719
+ let u2 = stateVariables["/u2"];
2720
+ expect(u.stateValues.value).closeTo(results[0], 1e-8);
2721
+ expect(u2.stateValues.value).closeTo(results[0], 1e-8);
2722
+
2723
+ let v = stateVariables["/s/v"];
2724
+ let v2 = stateVariables["/v2"];
2725
+ expect(v.stateValues.value).closeTo(results[1], 1e-8);
2726
+ expect(v2.stateValues.value).closeTo(results[1], 1e-8);
2727
+
2728
+ let w = stateVariables["/s/w"];
2729
+ let w2 = stateVariables["/w2"];
2730
+ expect(w.stateValues.value).closeTo(results[2], 1e-8);
2731
+ expect(w2.stateValues.value).closeTo(results[2], 1e-8);
2732
+
2733
+ let s = stateVariables["/s"];
2734
+ expect(s.replacements.length).eq(6);
2735
+ for (let ind = 0; ind < 6; ind++) {
2736
+ let r = stateVariables[s.replacements[ind].componentName];
2737
+ expect(r.stateValues.value).closeTo(results[ind], 1e-8);
2738
+ }
2739
+ });
2740
+ });
2741
+
2742
+ it("numToSelect from selectfromsequence", () => {
2743
+ cy.window().then(async (win) => {
2744
+ win.postMessage(
2745
+ {
2746
+ doenetML: `
2747
+ <text>a</text>
2748
+
2749
+ <p>n1 = <selectFromSequence from="1" to="5" assignNames="n1" /></p>
2750
+ <p>nums = <aslist><selectRandomNumbers name="nums1" from="1" to="10" numToSelect="$n1" assignNames="a1 b1 c1 d1 e1" displayDigits="10" /></aslist></p>
2751
+ <p name="p1">a1=$a1, b1=$b1, c1=$c1, d1=$d1, e1=$e1</p>
2752
+
2753
+ <p>n2 = <selectFromSequence from="1" to="5" assignNames="n2" /></p>
2754
+ <p>nums = <aslist><selectRandomNumbers name="nums2" from="1" to="10" numToSelect="$n2" assignNames="a2 b2 c2 d2 e2" displayDigits="10" /></aslist></p>
2755
+ <p name="p2">a2=$a2, b2=$b2, c2=$c2, d2=$d2, e2=$e2</p>
2756
+
2757
+ <p>n3 = <selectFromSequence from="1" to="5" assignNames="n3" /></p>
2758
+ <p>nums = <aslist><selectRandomNumbers name="nums3" from="1" to="10" numToSelect="$n3" assignNames="a3 b3 c3 d3 e3" displayDigits="10" /></aslist></p>
2759
+ <p name="p3">a3=$a3, b3=$b3, c3=$c3, d3=$d3, e3=$e3</p>
2760
+
2761
+ <p>n4 = <selectFromSequence from="1" to="5" assignNames="n4" /></p>
2762
+ <p>nums = <aslist><selectRandomNumbers name="nums4" from="1" to="10" numToSelect="$n4" assignNames="a4 b4 c4 d4 e4" displayDigits="10" /></aslist></p>
2763
+ <p name="p4">a4=$a4, b4=$b4, c4=$c4, d4=$d4, e4=$e4</p>
2764
+
2765
+ <p>n5 = <selectFromSequence from="1" to="5" assignNames="n5" /></p>
2766
+ <p>nums = <aslist><selectRandomNumbers name="nums5" from="1" to="10" numToSelect="$n5" assignNames="a5 b5 c5 d5 e5" displayDigits="10" /></aslist></p>
2767
+ <p name="p5">a5=$a5, b5=$b5, c5=$c5, d5=$d5, e5=$e5</p>
2768
+ `,
2769
+ },
2770
+ "*",
2771
+ );
2772
+ });
2773
+
2774
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load
2775
+
2776
+ cy.window().then(async (win) => {
2777
+ let stateVariables = await win.returnAllStateVariables1();
2778
+ let n1 = stateVariables["/n1"].stateValues.value;
2779
+ let n2 = stateVariables["/n2"].stateValues.value;
2780
+ let n3 = stateVariables["/n3"].stateValues.value;
2781
+ let n4 = stateVariables["/n4"].stateValues.value;
2782
+ let n5 = stateVariables["/n5"].stateValues.value;
2783
+
2784
+ let nums1 = stateVariables["/nums1"].replacements.map(
2785
+ (x) => stateVariables[x.componentName].stateValues.value,
2786
+ );
2787
+ let nums2 = stateVariables["/nums2"].replacements.map(
2788
+ (x) => stateVariables[x.componentName].stateValues.value,
2789
+ );
2790
+ let nums3 = stateVariables["/nums3"].replacements.map(
2791
+ (x) => stateVariables[x.componentName].stateValues.value,
2792
+ );
2793
+ let nums4 = stateVariables["/nums4"].replacements.map(
2794
+ (x) => stateVariables[x.componentName].stateValues.value,
2795
+ );
2796
+ let nums5 = stateVariables["/nums5"].replacements.map(
2797
+ (x) => stateVariables[x.componentName].stateValues.value,
2798
+ );
2799
+
2800
+ expect(nums1.length).eq(n1);
2801
+ expect(nums2.length).eq(n2);
2802
+ expect(nums3.length).eq(n3);
2803
+ expect(nums4.length).eq(n4);
2804
+ expect(nums5.length).eq(n5);
2805
+
2806
+ nums1.length = 5;
2807
+ nums2.length = 5;
2808
+ nums3.length = 5;
2809
+ nums4.length = 5;
2810
+ nums5.length = 5;
2811
+
2812
+ nums1.fill("", n1);
2813
+ nums2.fill("", n2);
2814
+ nums3.fill("", n3);
2815
+ nums4.fill("", n4);
2816
+ nums5.fill("", n5);
2817
+
2818
+ let l = ["a", "b", "c", "d", "e"];
2819
+
2820
+ cy.get(cesc("#\\/p1")).should(
2821
+ "have.text",
2822
+ nums1
2823
+ .map((v, i) => `${l[i]}1=${v ? Math.round(v * 1e9) / 1e9 : ""}`)
2824
+ .join(", "),
2825
+ );
2826
+ cy.get(cesc("#\\/p2")).should(
2827
+ "have.text",
2828
+ nums2
2829
+ .map((v, i) => `${l[i]}2=${v ? Math.round(v * 1e9) / 1e9 : ""}`)
2830
+ .join(", "),
2831
+ );
2832
+ cy.get(cesc("#\\/p3")).should(
2833
+ "have.text",
2834
+ nums3
2835
+ .map((v, i) => `${l[i]}3=${v ? Math.round(v * 1e9) / 1e9 : ""}`)
2836
+ .join(", "),
2837
+ );
2838
+ cy.get(cesc("#\\/p4")).should(
2839
+ "have.text",
2840
+ nums4
2841
+ .map((v, i) => `${l[i]}4=${v ? Math.round(v * 1e9) / 1e9 : ""}`)
2842
+ .join(", "),
2843
+ );
2844
+ cy.get(cesc("#\\/p5")).should(
2845
+ "have.text",
2846
+ nums5
2847
+ .map((v, i) => `${l[i]}5=${v ? Math.round(v * 1e9) / 1e9 : ""}`)
2848
+ .join(", "),
2849
+ );
2850
+ });
2851
+ });
2852
+
2853
+ it("rounding", () => {
2854
+ cy.window().then(async (win) => {
2855
+ win.postMessage(
2856
+ {
2857
+ doenetML: `
2858
+ <text>a</text>
2859
+ <p><aslist><selectRandomNumbers assignNames="n1" from="10" to="20" displayDigits="10" /></aslist></p>
2860
+ <p><aslist><selectRandomNumbers assignNames="n2" from="10" to="20" displayDigits="3" ignoreDisplayDecimals /></aslist></p>
2861
+ <p><aslist><selectRandomNumbers assignNames="n3" from="10" to="20" displayDecimals="3" ignoreDisplayDigits /></aslist></p>
2862
+ <p><aslist><selectRandomNumbers assignNames="n4" type="discreteUniform" from="10" to="20" displayDigits="3" ignoreDisplayDecimals padZeros /></aslist></p>
2863
+
2864
+ <p><number name="n1a">$n1</number></p>
2865
+ <p><number name="n2a">$n2</number></p>
2866
+ <p><number name="n3a">$n3</number></p>
2867
+ <p><number name="n4a">$n4</number></p>
2868
+
2869
+ `,
2870
+ },
2871
+ "*",
2872
+ );
2873
+ });
2874
+
2875
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2876
+
2877
+ cy.window().then(async (win) => {
2878
+ let stateVariables = await win.returnAllStateVariables1();
2879
+
2880
+ let n1 = stateVariables["/n1"].stateValues.value;
2881
+ let n2 = stateVariables["/n2"].stateValues.value;
2882
+ let n3 = stateVariables["/n3"].stateValues.value;
2883
+ let n4 = stateVariables["/n4"].stateValues.value;
2884
+
2885
+ cy.get(cesc("#\\/n1")).should(
2886
+ "have.text",
2887
+ String(Math.round(n1 * 10 ** 8) / 10 ** 8),
2888
+ );
2889
+ cy.get(cesc("#\\/n2")).should(
2890
+ "have.text",
2891
+ String(Math.round(n2 * 10 ** 1) / 10 ** 1),
2892
+ );
2893
+ cy.get(cesc("#\\/n3")).should(
2894
+ "have.text",
2895
+ String(Math.round(n3 * 10 ** 3) / 10 ** 3),
2896
+ );
2897
+ cy.get(cesc("#\\/n4")).should("have.text", String(n4) + ".0");
2898
+
2899
+ cy.get(cesc("#\\/n1a")).should(
2900
+ "have.text",
2901
+ String(Math.round(n1 * 10 ** 8) / 10 ** 8),
2902
+ );
2903
+ cy.get(cesc("#\\/n2a")).should(
2904
+ "have.text",
2905
+ String(Math.round(n2 * 10 ** 1) / 10 ** 1),
2906
+ );
2907
+ cy.get(cesc("#\\/n3a")).should(
2908
+ "have.text",
2909
+ String(Math.round(n3 * 10 ** 3) / 10 ** 3),
2910
+ );
2911
+ cy.get(cesc("#\\/n4a")).should("have.text", String(n4) + ".0");
2912
+ });
2913
+ });
2914
+ });