@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,2983 @@
1
+ import me from "math-expressions";
2
+ import { cesc, cesc2 } from "../../../../src/utils/url";
3
+
4
+ describe("Paginator Tag Tests", function () {
5
+ beforeEach(() => {
6
+ cy.clearIndexedDB();
7
+ cy.visit("/src/Tools/cypressTest/");
8
+ });
9
+
10
+ it("Multiple sections in paginator", () => {
11
+ let doenetML = `
12
+ <text>a</text>
13
+
14
+ <paginatorControls paginator="pgn" name="pcontrols" />
15
+
16
+ <paginator name="pgn">
17
+ <section>
18
+ <title>Page 1</title>
19
+ <p>What is 1+1? <answer>$two</answer></p>
20
+ <math hide name="two">2</math>
21
+ </section>
22
+ <section>
23
+ <p>What is your name? <textinput name="name" /></p>
24
+ <p>Hello, $name!</p>
25
+ </section>
26
+ <section>
27
+ <title>Page 3</title>
28
+ <math hide name="twox">2x</math>
29
+ <p>What is <m name="mxx">x+x</m>? <answer>$twox</answer></p>
30
+ <p>What is <m name="myy">y+y</m>? <answer>2y</answer></p>
31
+ </section>
32
+ </paginator>
33
+ <p>
34
+ <callAction name="prevPage" disabled="$pageNum = 1" actionName="setPage" target="pgn" number="$pageNum -1" >
35
+ <label>prev</label>
36
+ </callAction>
37
+ Page <copy prop="currentPage" target="pgn" assignNames="pageNum" />
38
+ of <copy prop="numPages" target="pgn" assignNames="numPages" />
39
+ <callAction name="nextPage" disabled="$pageNum = $numPages" actionName="setPage" target="pgn" number="$pageNum +1" >
40
+ <label>next</label>
41
+ </callAction>
42
+
43
+ </p>
44
+ <p>What is 2+2? <answer>4</answer></p>
45
+
46
+ <p>Credit achieved: <copy prop="creditAchieved" target="_document1" assignNames="ca" /></p>
47
+
48
+ `;
49
+
50
+ cy.get("#testRunner_toggleControls").click();
51
+ cy.get("#testRunner_allowLocalState").click();
52
+ cy.wait(100);
53
+ cy.get("#testRunner_toggleControls").click();
54
+
55
+ cy.window().then(async (win) => {
56
+ win.postMessage(
57
+ {
58
+ doenetML,
59
+ },
60
+ "*",
61
+ );
62
+ });
63
+
64
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
65
+
66
+ cy.window().then(async (win) => {
67
+ let stateVariables = await win.returnAllStateVariables1();
68
+
69
+ let mathinput1Name =
70
+ stateVariables["/_answer1"].stateValues.inputChildren[0].componentName;
71
+ let mathinput1Anchor = cesc2("#" + mathinput1Name) + " textarea";
72
+ let mathinput1DisplayAnchor =
73
+ cesc2("#" + mathinput1Name) + " .mq-editable-field";
74
+ let answer1Correct = cesc2("#" + mathinput1Name + "_correct");
75
+ let answer1Incorrect = cesc2("#" + mathinput1Name + "_incorrect");
76
+
77
+ let mathinput4Name =
78
+ stateVariables["/_answer4"].stateValues.inputChildren[0].componentName;
79
+ let mathinput4Anchor = cesc2("#" + mathinput4Name) + " textarea";
80
+ let mathinput4DisplayAnchor =
81
+ cesc2("#" + mathinput4Name) + " .mq-editable-field";
82
+ let answer4Correct = cesc2("#" + mathinput4Name + "_correct");
83
+ let answer4Incorrect = cesc2("#" + mathinput4Name + "_incorrect");
84
+
85
+ cy.get(cesc2("#/ca")).should("have.text", "0");
86
+ cy.get(cesc2("#/_title1")).should("have.text", "Page 1");
87
+ cy.get(cesc2("#/_section2_title")).should("not.exist");
88
+ cy.get(cesc2("#/_title2")).should("not.exist");
89
+
90
+ cy.get(mathinput4Anchor).type("4{enter}", { force: true });
91
+
92
+ cy.get(answer4Correct).should("be.visible");
93
+ cy.get(cesc2("#/ca")).should("have.text", "0.25");
94
+
95
+ cy.get(mathinput4DisplayAnchor)
96
+ .invoke("text")
97
+ .then((text) => {
98
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
99
+ });
100
+
101
+ cy.get(mathinput1Anchor).type("2{enter}", { force: true });
102
+
103
+ cy.get(answer1Correct).should("be.visible");
104
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
105
+ cy.get(mathinput1DisplayAnchor)
106
+ .invoke("text")
107
+ .then((text) => {
108
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
109
+ });
110
+
111
+ cy.log("move to page 2");
112
+ cy.get(cesc2("#/pcontrols_next")).click();
113
+ cy.get(cesc2("#/_title1")).should("not.exist");
114
+ cy.get(cesc2("#/_section2_title")).should("have.text", "Section 2");
115
+ cy.get(cesc2("#/_title2")).should("not.exist");
116
+
117
+ cy.get(answer4Correct).should("be.visible");
118
+ cy.get(mathinput4DisplayAnchor)
119
+ .invoke("text")
120
+ .then((text) => {
121
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
122
+ });
123
+
124
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
125
+
126
+ cy.get(cesc2("#/name_input")).type("Me{enter}");
127
+ cy.get(cesc2("#/_p3")).should("have.text", "Hello, Me!");
128
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
129
+ cy.get(cesc2("#/name_input")).should("have.value", "Me");
130
+
131
+ cy.get(mathinput1Anchor).should("not.exist");
132
+
133
+ cy.get(mathinput4Anchor).type("{end}{backspace}3", { force: true });
134
+ cy.get(answer4Correct).should("not.exist");
135
+ cy.get(mathinput4Anchor).type("{enter}", { force: true });
136
+ cy.get(answer4Incorrect).should("be.visible");
137
+
138
+ cy.get(cesc2("#/ca")).should("have.text", "0.25");
139
+ cy.get(mathinput4DisplayAnchor)
140
+ .invoke("text")
141
+ .then((text) => {
142
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
143
+ });
144
+
145
+ cy.log("back to page 1");
146
+ cy.get(cesc2("#/pcontrols_previous")).click();
147
+ cy.get(cesc2("#/_title1")).should("have.text", "Page 1");
148
+ cy.get(cesc2("#/_section2_title")).should("not.exist");
149
+ cy.get(cesc2("#/_title2")).should("not.exist");
150
+
151
+ cy.get(answer1Correct).should("be.visible");
152
+ cy.get(cesc2("#/ca")).should("have.text", "0.25");
153
+ cy.get(mathinput1DisplayAnchor)
154
+ .invoke("text")
155
+ .then((text) => {
156
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
157
+ });
158
+
159
+ cy.get(cesc2("#/name")).should("not.exist");
160
+
161
+ cy.log("back to second page");
162
+ cy.get(cesc2("#/nextPage_button")).click();
163
+ cy.get(cesc2("#/_title1")).should("not.exist");
164
+ cy.get(cesc2("#/_section2_title")).should("have.text", "Section 2");
165
+ cy.get(cesc2("#/_title2")).should("not.exist");
166
+
167
+ cy.get(cesc2("#/name_input")).should("have.value", "Me");
168
+ cy.get(cesc2("#/_p3")).should("have.text", "Hello, Me!");
169
+
170
+ cy.get(answer4Incorrect).should("be.visible");
171
+ cy.get(cesc2("#/ca")).should("have.text", "0.25");
172
+ cy.get(mathinput4DisplayAnchor)
173
+ .invoke("text")
174
+ .then((text) => {
175
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
176
+ });
177
+
178
+ cy.get(mathinput4Anchor).type("{end}{backspace}4", { force: true });
179
+ cy.get(answer4Incorrect).should("not.exist");
180
+ cy.get(mathinput4Anchor).type("{enter}", { force: true });
181
+
182
+ cy.get(answer4Correct).should("be.visible");
183
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
184
+ cy.get(mathinput4DisplayAnchor)
185
+ .invoke("text")
186
+ .then((text) => {
187
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
188
+ });
189
+
190
+ cy.log("on to third page");
191
+ cy.get(cesc2("#/pcontrols_next")).click();
192
+ cy.get(cesc2("#/_title1")).should("not.exist");
193
+ cy.get(cesc2("#/_section2_title")).should("not.exist");
194
+ cy.get(cesc2("#/_title2")).should("have.text", "Page 3");
195
+
196
+ cy.get(answer4Correct).should("be.visible");
197
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
198
+ cy.get(mathinput4DisplayAnchor)
199
+ .invoke("text")
200
+ .then((text) => {
201
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
202
+ });
203
+
204
+ // cy.get(cesc('#\\/mxx') + ' .mjx-mrow').should('contain.text', 'x+x')
205
+ // cy.get(cesc('#\\/myy') + ' .mjx-mrow').should('contain.text', 'y+y')
206
+
207
+ cy.window().then(async (win) => {
208
+ let stateVariables = await win.returnAllStateVariables1();
209
+
210
+ let mathinput2Name =
211
+ stateVariables["/_answer2"].stateValues.inputChildren[0]
212
+ .componentName;
213
+ let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea";
214
+ let mathinput2DisplayAnchor =
215
+ cesc2("#" + mathinput2Name) + " .mq-editable-field";
216
+ let answer2Correct = cesc2("#" + mathinput2Name + "_correct");
217
+ let answer2Incorrect = cesc2("#" + mathinput2Name + "_incorrect");
218
+
219
+ let mathinput3Name =
220
+ stateVariables["/_answer3"].stateValues.inputChildren[0]
221
+ .componentName;
222
+ let mathinput3Anchor = cesc2("#" + mathinput3Name) + " textarea";
223
+ let mathinput3DisplayAnchor =
224
+ cesc2("#" + mathinput3Name) + " .mq-editable-field";
225
+ let answer3Correct = cesc2("#" + mathinput3Name + "_correct");
226
+ let answer3Incorrect = cesc2("#" + mathinput3Name + "_incorrect");
227
+
228
+ cy.get(mathinput2Anchor).type("2x{enter}", { force: true });
229
+ cy.get(answer2Correct).should("be.visible");
230
+ cy.get(cesc2("#/ca")).should("have.text", "0.75");
231
+ cy.get(mathinput2DisplayAnchor)
232
+ .invoke("text")
233
+ .then((text) => {
234
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2x");
235
+ });
236
+
237
+ cy.get(mathinput3Anchor).type("2y{enter}", { force: true });
238
+ cy.get(answer3Correct).should("be.visible");
239
+ cy.get(cesc2("#/ca")).should("have.text", "1");
240
+ cy.get(mathinput3DisplayAnchor)
241
+ .invoke("text")
242
+ .then((text) => {
243
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2y");
244
+ });
245
+
246
+ cy.get(mathinput2Anchor).type("{end}{backspace}z", { force: true });
247
+ cy.get(answer2Correct).should("not.exist");
248
+ cy.get(mathinput2Anchor).type("{enter}", { force: true });
249
+ cy.get(answer2Incorrect).should("be.visible");
250
+ cy.get(cesc2("#/ca")).should("have.text", "0.75");
251
+ cy.get(mathinput2DisplayAnchor)
252
+ .invoke("text")
253
+ .then((text) => {
254
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2z");
255
+ });
256
+
257
+ cy.log("back to second page");
258
+ cy.get(cesc2("#/prevPage_button")).click();
259
+ cy.get(cesc2("#/_title1")).should("not.exist");
260
+ cy.get(cesc2("#/_section2_title")).should("have.text", "Section 2");
261
+ cy.get(cesc2("#/_title2")).should("not.exist");
262
+
263
+ cy.get(cesc2("#/name_input")).should("have.value", "Me");
264
+ cy.get(cesc2("#/_p3")).should("have.text", "Hello, Me!");
265
+
266
+ cy.get(answer4Correct).should("be.visible");
267
+ cy.get(cesc2("#/ca")).should("have.text", "0.75");
268
+ cy.get(mathinput4DisplayAnchor)
269
+ .invoke("text")
270
+ .then((text) => {
271
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
272
+ });
273
+
274
+ cy.log("back to third page");
275
+ cy.get(cesc2("#/pcontrols_next")).click();
276
+ cy.get(cesc2("#/_title1")).should("not.exist");
277
+ cy.get(cesc2("#/_section2_title")).should("not.exist");
278
+ cy.get(cesc2("#/_title2")).should("have.text", "Page 3");
279
+
280
+ cy.get(answer4Correct).should("be.visible");
281
+ cy.get(cesc2("#/ca")).should("have.text", "0.75");
282
+ cy.get(mathinput4DisplayAnchor)
283
+ .invoke("text")
284
+ .then((text) => {
285
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
286
+ });
287
+
288
+ cy.get(answer2Incorrect).should("be.visible");
289
+ cy.get(mathinput2DisplayAnchor)
290
+ .invoke("text")
291
+ .then((text) => {
292
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2z");
293
+ });
294
+ cy.get(answer3Correct).should("be.visible");
295
+ cy.get(mathinput3DisplayAnchor)
296
+ .invoke("text")
297
+ .then((text) => {
298
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2y");
299
+ });
300
+
301
+ cy.get(cesc2("#/ca")).should("have.text", "0.75");
302
+
303
+ cy.log("back to second page");
304
+ cy.get(cesc2("#/prevPage_button")).click();
305
+ cy.get(cesc2("#/_title1")).should("not.exist");
306
+ cy.get(cesc2("#/_section2_title")).should("have.text", "Section 2");
307
+ cy.get(cesc2("#/_title2")).should("not.exist");
308
+
309
+ cy.get(cesc2("#/name_input")).should("have.value", "Me");
310
+ cy.get(cesc2("#/_p3")).should("have.text", "Hello, Me!");
311
+
312
+ cy.get(answer4Correct).should("be.visible");
313
+ cy.get(cesc2("#/ca")).should("have.text", "0.75");
314
+ cy.get(mathinput4DisplayAnchor)
315
+ .invoke("text")
316
+ .then((text) => {
317
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
318
+ });
319
+ });
320
+ });
321
+
322
+ cy.wait(2000); // make sure 1 second debounce is satisified
323
+ cy.reload();
324
+
325
+ cy.window().then(async (win) => {
326
+ win.postMessage(
327
+ {
328
+ doenetML,
329
+ },
330
+ "*",
331
+ );
332
+ });
333
+
334
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
335
+
336
+ cy.log("on page two");
337
+
338
+ // wait until core is loaded
339
+ cy.waitUntil(() =>
340
+ cy.window().then(async (win) => {
341
+ let stateVariables = await win.returnAllStateVariables1();
342
+ return stateVariables["/_answer4"];
343
+ }),
344
+ );
345
+
346
+ cy.get(cesc2("#/_title1")).should("not.exist");
347
+ cy.get(cesc2("#/_section2_title")).should("have.text", "Section 2");
348
+ cy.get(cesc2("#/_title2")).should("not.exist");
349
+
350
+ cy.window().then(async (win) => {
351
+ let stateVariables = await win.returnAllStateVariables1();
352
+
353
+ let mathinput4Name =
354
+ stateVariables["/_answer4"].stateValues.inputChildren[0].componentName;
355
+ let mathinput4Anchor = cesc2("#" + mathinput4Name) + " textarea";
356
+ let mathinput4DisplayAnchor =
357
+ cesc2("#" + mathinput4Name) + " .mq-editable-field";
358
+ let answer4Correct = cesc2("#" + mathinput4Name + "_correct");
359
+ let answer4Incorrect = cesc2("#" + mathinput4Name + "_incorrect");
360
+
361
+ cy.get(cesc2("#/name_input")).should("have.value", "Me");
362
+ cy.get(cesc2("#/_p3")).should("have.text", "Hello, Me!");
363
+
364
+ cy.get(answer4Correct).should("be.visible");
365
+ cy.get(cesc2("#/ca")).should("have.text", "0.75");
366
+ cy.get(mathinput4DisplayAnchor)
367
+ .invoke("text")
368
+ .then((text) => {
369
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
370
+ });
371
+
372
+ cy.get(cesc2("#/name_input")).clear().type("You{enter}");
373
+ cy.get(cesc2("#/name_input")).should("have.value", "You");
374
+ cy.get(cesc2("#/_p3")).should("have.text", "Hello, You!");
375
+
376
+ cy.get(answer4Correct).should("be.visible");
377
+ cy.get(cesc2("#/ca")).should("have.text", "0.75");
378
+ cy.get(mathinput4DisplayAnchor)
379
+ .invoke("text")
380
+ .then((text) => {
381
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
382
+ });
383
+
384
+ cy.log("to third page");
385
+ cy.get(cesc2("#/pcontrols_next")).click();
386
+ cy.get(cesc2("#/_title1")).should("not.exist");
387
+ cy.get(cesc2("#/_section2_title")).should("not.exist");
388
+ cy.get(cesc2("#/_title2")).should("have.text", "Page 3");
389
+
390
+ cy.get(answer4Correct).should("be.visible");
391
+ cy.get(cesc2("#/ca")).should("have.text", "0.75");
392
+ cy.get(mathinput4DisplayAnchor)
393
+ .invoke("text")
394
+ .then((text) => {
395
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("4");
396
+ });
397
+
398
+ cy.window().then(async (win) => {
399
+ let stateVariables = await win.returnAllStateVariables1();
400
+
401
+ let mathinput2Name =
402
+ stateVariables["/_answer2"].stateValues.inputChildren[0]
403
+ .componentName;
404
+ let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea";
405
+ let mathinput2DisplayAnchor =
406
+ cesc2("#" + mathinput2Name) + " .mq-editable-field";
407
+ let answer2Correct = cesc2("#" + mathinput2Name + "_correct");
408
+ let answer2Incorrect = cesc2("#" + mathinput2Name + "_incorrect");
409
+ let answer2Submit = cesc2("#" + mathinput2Name + "_submit");
410
+
411
+ let mathinput3Name =
412
+ stateVariables["/_answer3"].stateValues.inputChildren[0]
413
+ .componentName;
414
+ let mathinput3Anchor = cesc2("#" + mathinput3Name) + " textarea";
415
+ let mathinput3DisplayAnchor =
416
+ cesc2("#" + mathinput3Name) + " .mq-editable-field";
417
+ let answer3Correct = cesc2("#" + mathinput3Name + "_correct");
418
+ let answer3Incorrect = cesc2("#" + mathinput3Name + "_incorrect");
419
+
420
+ cy.get(answer2Incorrect).should("be.visible");
421
+ cy.get(mathinput2DisplayAnchor)
422
+ .invoke("text")
423
+ .then((text) => {
424
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2z");
425
+ });
426
+ cy.get(answer3Correct).should("be.visible");
427
+ cy.get(mathinput3DisplayAnchor)
428
+ .invoke("text")
429
+ .then((text) => {
430
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2y");
431
+ });
432
+
433
+ cy.get(mathinput3Anchor).type("{end}{backspace}q", { force: true });
434
+ cy.get(answer3Correct).should("not.exist");
435
+ cy.get(mathinput3Anchor).type("{enter}", { force: true });
436
+ cy.get(answer3Incorrect).should("be.visible");
437
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
438
+ cy.get(mathinput3DisplayAnchor)
439
+ .invoke("text")
440
+ .then((text) => {
441
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2q");
442
+ });
443
+
444
+ cy.get(mathinput4Anchor).type("{end}{backspace}3", { force: true });
445
+ cy.get(answer4Correct).should("not.exist");
446
+ cy.get(mathinput4Anchor).type("{enter}", { force: true });
447
+ cy.get(answer4Incorrect).should("be.visible");
448
+ cy.get(cesc2("#/ca")).should("have.text", "0.25");
449
+ cy.get(mathinput4DisplayAnchor)
450
+ .invoke("text")
451
+ .then((text) => {
452
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
453
+ });
454
+
455
+ cy.get(mathinput2Anchor).type("{end}{backspace}x", { force: true });
456
+ cy.get(answer2Incorrect).should("not.exist");
457
+ cy.get(mathinput2Anchor).type("{enter}", { force: true });
458
+ cy.get(answer2Correct).should("be.visible");
459
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
460
+ cy.get(mathinput2DisplayAnchor)
461
+ .invoke("text")
462
+ .then((text) => {
463
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2x");
464
+ });
465
+
466
+ cy.log("back to second page");
467
+ cy.get(cesc2("#/pcontrols_previous")).click();
468
+ cy.get(cesc2("#/_title1")).should("not.exist");
469
+ cy.get(cesc2("#/_section2_title")).should("have.text", "Section 2");
470
+ cy.get(cesc2("#/_title2")).should("not.exist");
471
+
472
+ cy.get(cesc2("#/name_input")).should("have.value", "You");
473
+ cy.get(cesc2("#/_p3")).should("have.text", "Hello, You!");
474
+
475
+ cy.get(answer4Incorrect).should("be.visible");
476
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
477
+ cy.get(mathinput4DisplayAnchor)
478
+ .invoke("text")
479
+ .then((text) => {
480
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
481
+ });
482
+
483
+ cy.log("to first page");
484
+ cy.get(cesc2("#/pcontrols_previous")).click();
485
+ cy.get(cesc2("#/_title1")).should("have.text", "Page 1");
486
+ cy.get(cesc2("#/_section2_title")).should("not.exist");
487
+ cy.get(cesc2("#/_title2")).should("not.exist");
488
+
489
+ cy.get(answer4Incorrect).should("be.visible");
490
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
491
+ cy.get(mathinput4DisplayAnchor)
492
+ .invoke("text")
493
+ .then((text) => {
494
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
495
+ });
496
+
497
+ cy.window().then(async (win) => {
498
+ let stateVariables = await win.returnAllStateVariables1();
499
+
500
+ let mathinput1Name =
501
+ stateVariables["/_answer1"].stateValues.inputChildren[0]
502
+ .componentName;
503
+ let mathinput1Anchor = cesc2("#" + mathinput1Name) + " textarea";
504
+ let mathinput1DisplayAnchor =
505
+ cesc2("#" + mathinput1Name) + " .mq-editable-field";
506
+ let answer1Correct = cesc2("#" + mathinput1Name + "_correct");
507
+ let answer1Incorrect = cesc2("#" + mathinput1Name + "_incorrect");
508
+
509
+ cy.get(answer1Correct).should("be.visible");
510
+ cy.get(mathinput1DisplayAnchor)
511
+ .invoke("text")
512
+ .then((text) => {
513
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
514
+ });
515
+
516
+ cy.get(mathinput1Anchor).type("{end}-", { force: true });
517
+ cy.get(answer1Correct).should("not.exist");
518
+ cy.get(mathinput1Anchor).type("{enter}", { force: true });
519
+ cy.get(answer1Incorrect).should("be.visible");
520
+ cy.get(mathinput1DisplayAnchor)
521
+ .invoke("text")
522
+ .then((text) => {
523
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2−");
524
+ });
525
+ cy.get(cesc2("#/ca")).should("have.text", "0.25");
526
+
527
+ cy.log("back to second page");
528
+ cy.get(cesc2("#/pcontrols_next")).click();
529
+ cy.get(cesc2("#/_title1")).should("not.exist");
530
+ cy.get(cesc2("#/_section2_title")).should("have.text", "Section 2");
531
+ cy.get(cesc2("#/_title2")).should("not.exist");
532
+
533
+ cy.log("back to first page");
534
+ cy.get(cesc2("#/pcontrols_previous")).click();
535
+ cy.get(cesc2("#/_title1")).should("have.text", "Page 1");
536
+ cy.get(cesc2("#/_section2_title")).should("not.exist");
537
+ cy.get(cesc2("#/_title2")).should("not.exist");
538
+
539
+ cy.get(answer1Incorrect).should("be.visible");
540
+ cy.get(mathinput1DisplayAnchor)
541
+ .invoke("text")
542
+ .then((text) => {
543
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2−");
544
+ });
545
+
546
+ cy.log("to third page");
547
+
548
+ cy.get(cesc2("#/pcontrols_next")).click();
549
+ cy.get(cesc2("#/_title1")).should("not.exist");
550
+ cy.get(cesc2("#/_section2_title")).should("have.text", "Section 2");
551
+ cy.get(cesc2("#/_title2")).should("not.exist");
552
+
553
+ cy.get(cesc2("#/pcontrols_next")).click();
554
+ cy.get(cesc2("#/_title1")).should("not.exist");
555
+ cy.get(cesc2("#/_section2_title")).should("not.exist");
556
+ cy.get(cesc2("#/_title2")).should("have.text", "Page 3");
557
+
558
+ cy.get(answer3Incorrect).should("be.visible");
559
+ cy.get(mathinput3DisplayAnchor)
560
+ .invoke("text")
561
+ .then((text) => {
562
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2q");
563
+ });
564
+
565
+ cy.get(answer4Incorrect).should("be.visible");
566
+ cy.get(mathinput4DisplayAnchor)
567
+ .invoke("text")
568
+ .then((text) => {
569
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
570
+ });
571
+
572
+ cy.get(answer2Correct).should("be.visible");
573
+ cy.get(mathinput2DisplayAnchor)
574
+ .invoke("text")
575
+ .then((text) => {
576
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2x");
577
+ });
578
+ cy.get(cesc2("#/ca")).should("have.text", "0.25");
579
+
580
+ cy.get(mathinput2Anchor).type("{end}:", { force: true }).blur();
581
+ cy.get(answer2Submit).should("be.visible");
582
+ cy.get(mathinput2DisplayAnchor)
583
+ .invoke("text")
584
+ .then((text) => {
585
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2x:");
586
+ });
587
+ cy.get(cesc2("#/ca")).should("have.text", "0.25");
588
+
589
+ cy.log("to second page");
590
+ cy.get(cesc2("#/pcontrols_previous")).click();
591
+ cy.get(cesc2("#/_title1")).should("not.exist");
592
+ cy.get(cesc2("#/_section2_title")).should("have.text", "Section 2");
593
+ cy.get(cesc2("#/_title2")).should("not.exist");
594
+
595
+ cy.log("back to third page");
596
+ cy.get(cesc2("#/pcontrols_next")).click();
597
+ cy.get(cesc2("#/_title1")).should("not.exist");
598
+ cy.get(cesc2("#/_section2_title")).should("not.exist");
599
+ cy.get(cesc2("#/_title2")).should("have.text", "Page 3");
600
+
601
+ cy.get(answer2Submit).should("be.visible");
602
+ cy.get(mathinput2DisplayAnchor)
603
+ .invoke("text")
604
+ .then((text) => {
605
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2x:");
606
+ });
607
+ cy.get(answer3Incorrect).should("be.visible");
608
+ cy.get(mathinput3DisplayAnchor)
609
+ .invoke("text")
610
+ .then((text) => {
611
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2q");
612
+ });
613
+ cy.get(answer4Incorrect).should("be.visible");
614
+ cy.get(mathinput4DisplayAnchor)
615
+ .invoke("text")
616
+ .then((text) => {
617
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
618
+ });
619
+ cy.get(cesc2("#/ca")).should("have.text", "0.25");
620
+ });
621
+ });
622
+ });
623
+
624
+ cy.wait(2000); // wait for 1 second debounce
625
+ cy.reload();
626
+
627
+ cy.window().then(async (win) => {
628
+ win.postMessage(
629
+ {
630
+ doenetML,
631
+ },
632
+ "*",
633
+ );
634
+ });
635
+
636
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
637
+
638
+ // wait until core is loaded
639
+ cy.waitUntil(() =>
640
+ cy.window().then(async (win) => {
641
+ let stateVariables = await win.returnAllStateVariables1();
642
+ return stateVariables["/_answer4"];
643
+ }),
644
+ );
645
+
646
+ cy.log("on third page without first and second defined");
647
+ cy.get(cesc2("#/_title1")).should("not.exist");
648
+ cy.get(cesc2("#/_section2_title")).should("not.exist");
649
+ cy.get(cesc2("#/_title2")).should("have.text", "Page 3");
650
+
651
+ cy.window().then(async (win) => {
652
+ let stateVariables = await win.returnAllStateVariables1();
653
+
654
+ let mathinput2Name =
655
+ stateVariables["/_answer2"].stateValues.inputChildren[0].componentName;
656
+ let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea";
657
+ let mathinput2DisplayAnchor =
658
+ cesc2("#" + mathinput2Name) + " .mq-editable-field";
659
+ let answer2Correct = cesc2("#" + mathinput2Name + "_correct");
660
+ let answer2Incorrect = cesc2("#" + mathinput2Name + "_incorrect");
661
+ let answer2Submit = cesc2("#" + mathinput2Name + "_submit");
662
+
663
+ let mathinput3Name =
664
+ stateVariables["/_answer3"].stateValues.inputChildren[0].componentName;
665
+ let mathinput3Anchor = cesc2("#" + mathinput3Name) + " textarea";
666
+ let mathinput3DisplayAnchor =
667
+ cesc2("#" + mathinput3Name) + " .mq-editable-field";
668
+ let answer3Correct = cesc2("#" + mathinput3Name + "_correct");
669
+ let answer3Incorrect = cesc2("#" + mathinput3Name + "_incorrect");
670
+
671
+ let mathinput4Name =
672
+ stateVariables["/_answer4"].stateValues.inputChildren[0].componentName;
673
+ let mathinput4Anchor = cesc2("#" + mathinput4Name) + " textarea";
674
+ let mathinput4DisplayAnchor =
675
+ cesc2("#" + mathinput4Name) + " .mq-editable-field";
676
+ let answer4Correct = cesc2("#" + mathinput4Name + "_correct");
677
+ let answer4Incorrect = cesc2("#" + mathinput4Name + "_incorrect");
678
+
679
+ cy.get(answer2Submit).should("be.visible");
680
+ cy.get(mathinput2DisplayAnchor)
681
+ .invoke("text")
682
+ .then((text) => {
683
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2x:");
684
+ });
685
+ cy.get(answer3Incorrect).should("be.visible");
686
+ cy.get(mathinput3DisplayAnchor)
687
+ .invoke("text")
688
+ .then((text) => {
689
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2q");
690
+ });
691
+ cy.get(answer4Incorrect).should("be.visible");
692
+ cy.get(mathinput4DisplayAnchor)
693
+ .invoke("text")
694
+ .then((text) => {
695
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
696
+ });
697
+ cy.get(cesc2("#/ca")).should("have.text", "0.25");
698
+
699
+ cy.log("to second page");
700
+ cy.get(cesc2("#/pcontrols_previous")).click();
701
+ cy.get(cesc2("#/_title1")).should("not.exist");
702
+ cy.get(cesc2("#/_section2_title")).should("have.text", "Section 2");
703
+ cy.get(cesc2("#/_title2")).should("not.exist");
704
+
705
+ cy.get(cesc2("#/name_input")).should("have.value", "You");
706
+ cy.get(cesc2("#/_p3")).should("have.text", "Hello, You!");
707
+
708
+ cy.get(answer4Incorrect).should("be.visible");
709
+ cy.get(cesc2("#/ca")).should("have.text", "0.25");
710
+ cy.get(mathinput4DisplayAnchor)
711
+ .invoke("text")
712
+ .then((text) => {
713
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
714
+ });
715
+
716
+ cy.log("back to third page");
717
+ cy.get(cesc2("#/pcontrols_next")).click();
718
+ cy.get(answer2Submit).should("be.visible");
719
+ cy.get(mathinput2DisplayAnchor)
720
+ .invoke("text")
721
+ .then((text) => {
722
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2x:");
723
+ });
724
+ cy.get(answer3Incorrect).should("be.visible");
725
+ cy.get(mathinput3DisplayAnchor)
726
+ .invoke("text")
727
+ .then((text) => {
728
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2q");
729
+ });
730
+ cy.get(answer4Incorrect).should("be.visible");
731
+ cy.get(mathinput4DisplayAnchor)
732
+ .invoke("text")
733
+ .then((text) => {
734
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
735
+ });
736
+ cy.get(cesc2("#/ca")).should("have.text", "0.25");
737
+
738
+ cy.log("to first page");
739
+ cy.get(cesc2("#/pcontrols_previous")).click();
740
+ cy.get(cesc2("#/_title1")).should("not.exist");
741
+ cy.get(cesc2("#/_section2_title")).should("have.text", "Section 2");
742
+ cy.get(cesc2("#/_title2")).should("not.exist");
743
+
744
+ cy.get(cesc2("#/pcontrols_previous")).click();
745
+ cy.get(cesc2("#/_title1")).should("have.text", "Page 1");
746
+ cy.get(cesc2("#/_section2_title")).should("not.exist");
747
+ cy.get(cesc2("#/_title2")).should("not.exist");
748
+
749
+ cy.window().then(async (win) => {
750
+ let stateVariables = await win.returnAllStateVariables1();
751
+
752
+ let mathinput1Name =
753
+ stateVariables["/_answer1"].stateValues.inputChildren[0]
754
+ .componentName;
755
+ let mathinput1Anchor = cesc2("#" + mathinput1Name) + " textarea";
756
+ let mathinput1DisplayAnchor =
757
+ cesc2("#" + mathinput1Name) + " .mq-editable-field";
758
+ let answer1Correct = cesc2("#" + mathinput1Name + "_correct");
759
+ let answer1Incorrect = cesc2("#" + mathinput1Name + "_incorrect");
760
+
761
+ cy.get(answer1Incorrect).should("be.visible");
762
+ cy.get(mathinput1DisplayAnchor)
763
+ .invoke("text")
764
+ .then((text) => {
765
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2−");
766
+ });
767
+ cy.get(cesc2("#/ca")).should("have.text", "0.25");
768
+
769
+ cy.get(answer4Incorrect).should("be.visible");
770
+ cy.get(mathinput4DisplayAnchor)
771
+ .invoke("text")
772
+ .then((text) => {
773
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("3");
774
+ });
775
+ });
776
+ });
777
+ });
778
+
779
+ it("With weights", () => {
780
+ let doenetML = `
781
+ <text>a</text>
782
+
783
+ <paginatorControls paginator="pgn" name="pcontrols" />
784
+
785
+ <paginator name="pgn">
786
+ <problem>
787
+ <answer type="text">a</answer>
788
+ </problem>
789
+ <problem weight="2">
790
+ <answer type="text">b</answer>
791
+ </problem>
792
+ <problem weight="3">
793
+ <answer type="text">c</answer>
794
+ </problem>
795
+ </paginator>
796
+
797
+ <p>Credit achieved: <copy prop="creditAchieved" target="_document1" assignNames="ca" /></p>
798
+
799
+ `;
800
+
801
+ cy.get("#testRunner_toggleControls").click();
802
+ cy.get("#testRunner_allowLocalState").click();
803
+ cy.wait(100);
804
+ cy.get("#testRunner_toggleControls").click();
805
+
806
+ cy.window().then(async (win) => {
807
+ win.postMessage(
808
+ {
809
+ doenetML,
810
+ },
811
+ "*",
812
+ );
813
+ });
814
+
815
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
816
+
817
+ cy.window().then(async (win) => {
818
+ let stateVariables = await win.returnAllStateVariables1();
819
+
820
+ let textinput1Name =
821
+ stateVariables["/_answer1"].stateValues.inputChildren[0].componentName;
822
+ let textinput1Anchor = cesc2("#" + textinput1Name) + "_input";
823
+ let textinput1DisplayAnchor =
824
+ cesc2("#" + textinput1Name) + " .mq-editable-field";
825
+ let answer1Submit = cesc2("#" + textinput1Name + "_submit");
826
+ let answer1Correct = cesc2("#" + textinput1Name + "_correct");
827
+ let answer1Incorrect = cesc2("#" + textinput1Name + "_incorrect");
828
+
829
+ cy.get(cesc2("#/_problem1_title")).should("have.text", "Problem 1");
830
+
831
+ cy.get(cesc2("#/ca")).should("have.text", "0");
832
+
833
+ cy.get(textinput1Anchor).type("a{enter}");
834
+
835
+ cy.get(answer1Correct).should("be.visible");
836
+ cy.get(cesc2("#/ca")).should("have.text", "0.167");
837
+
838
+ cy.get(cesc2("#/pcontrols_next")).click();
839
+ cy.get(cesc2("#/_problem2_title")).should("have.text", "Problem 2");
840
+ cy.get(cesc2("#/ca")).should("have.text", "0.167");
841
+
842
+ cy.wait(200);
843
+
844
+ cy.window().then(async (win) => {
845
+ let stateVariables = await win.returnAllStateVariables1();
846
+
847
+ let textinput2Name =
848
+ stateVariables["/_answer2"].stateValues.inputChildren[0]
849
+ .componentName;
850
+ let textinput2Anchor = cesc2("#" + textinput2Name) + "_input";
851
+ let textinput2DisplayAnchor =
852
+ cesc2("#" + textinput2Name) + " .mq-editable-field";
853
+ let answer2Submit = cesc2("#" + textinput2Name + "_submit");
854
+ let answer2Correct = cesc2("#" + textinput2Name + "_correct");
855
+ let answer2Incorrect = cesc2("#" + textinput2Name + "_incorrect");
856
+
857
+ cy.get(answer2Submit).should("be.visible");
858
+
859
+ cy.get(cesc2("#/pcontrols_next")).click();
860
+ cy.get(cesc2("#/_problem3_title")).should("have.text", "Problem 3");
861
+ cy.get(cesc2("#/ca")).should("have.text", "0.167");
862
+
863
+ cy.window().then(async (win) => {
864
+ let stateVariables = await win.returnAllStateVariables1();
865
+
866
+ let textinput3Name =
867
+ stateVariables["/_answer3"].stateValues.inputChildren[0]
868
+ .componentName;
869
+ let textinput3Anchor = cesc2("#" + textinput3Name) + "_input";
870
+ let textinput3DisplayAnchor =
871
+ cesc2("#" + textinput3Name) + " .mq-editable-field";
872
+ let answer3Submit = cesc2("#" + textinput3Name + "_submit");
873
+ let answer3Correct = cesc2("#" + textinput3Name + "_correct");
874
+ let answer3Incorrect = cesc2("#" + textinput3Name + "_incorrect");
875
+
876
+ cy.get(answer3Submit).should("be.visible");
877
+
878
+ cy.get(cesc2("#/pcontrols_previous")).click();
879
+ cy.get(cesc2("#/_problem2_title")).should("have.text", "Problem 2");
880
+ cy.get(cesc2("#/ca")).should("have.text", "0.167");
881
+
882
+ cy.get(textinput2Anchor).type("b{enter}");
883
+
884
+ cy.get(answer2Correct).should("be.visible");
885
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
886
+
887
+ cy.get(cesc2("#/pcontrols_previous")).click();
888
+ cy.get(cesc2("#/_problem1_title")).should("have.text", "Problem 1");
889
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
890
+
891
+ cy.get(answer1Correct).should("be.visible");
892
+
893
+ cy.get(textinput1Anchor).clear();
894
+ cy.get(answer1Correct).should("not.exist");
895
+ cy.get(textinput1Anchor).type("{enter}");
896
+ cy.get(answer1Incorrect).should("be.visible");
897
+ cy.get(cesc2("#/ca")).should("have.text", "0.333");
898
+
899
+ cy.get(cesc2("#/pcontrols_next")).click();
900
+ cy.get(cesc2("#/_problem2_title")).should("have.text", "Problem 2");
901
+ cy.get(cesc2("#/ca")).should("have.text", "0.333");
902
+
903
+ cy.get(answer2Correct).should("be.visible");
904
+
905
+ cy.get(cesc2("#/pcontrols_next")).click();
906
+ cy.get(cesc2("#/_problem3_title")).should("have.text", "Problem 3");
907
+ cy.get(cesc2("#/ca")).should("have.text", "0.333");
908
+
909
+ cy.get(textinput3Anchor).clear().type("c{enter}");
910
+ cy.get(answer3Correct).should("be.visible");
911
+ cy.get(cesc2("#/ca")).should("have.text", "0.833");
912
+
913
+ cy.get(cesc2("#/pcontrols_previous")).click();
914
+ cy.get(cesc2("#/_problem2_title")).should("have.text", "Problem 2");
915
+ cy.get(cesc2("#/ca")).should("have.text", "0.833");
916
+
917
+ cy.get(answer2Correct).should("be.visible");
918
+ });
919
+ });
920
+ });
921
+
922
+ cy.wait(2000); // wait for 1 second debounce
923
+ cy.reload();
924
+
925
+ cy.window().then(async (win) => {
926
+ win.postMessage(
927
+ {
928
+ doenetML,
929
+ },
930
+ "*",
931
+ );
932
+ });
933
+
934
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
935
+
936
+ cy.get(cesc2("#/_problem2_title")).should("have.text", "Problem 2");
937
+ cy.get(cesc2("#/ca")).should("have.text", "0.833");
938
+
939
+ cy.get(cesc2("#/pcontrols_previous")).click();
940
+ cy.get(cesc2("#/_problem1_title")).should("have.text", "Problem 1");
941
+ cy.get(cesc2("#/ca")).should("have.text", "0.833");
942
+
943
+ cy.get(cesc2("#/pcontrols_next")).click();
944
+ cy.get(cesc2("#/_problem2_title")).should("have.text", "Problem 2");
945
+ cy.get(cesc2("#/ca")).should("have.text", "0.833");
946
+
947
+ cy.get(cesc2("#/pcontrols_next")).click();
948
+ cy.get(cesc2("#/_problem3_title")).should("have.text", "Problem 3");
949
+ cy.get(cesc2("#/ca")).should("have.text", "0.833");
950
+ });
951
+
952
+ it.skip("With selects, specify variants", () => {
953
+ let doenetML = `
954
+ <text>a</text>
955
+
956
+ <paginatorControls paginator="pgn" name="pcontrols" />
957
+
958
+ <paginator name="pgn">
959
+ <select assignNames="(problem1)">
960
+ <option>
961
+ <problem newNamespace>
962
+ <title>Problem A</title>
963
+ <p>Enter <m>$n</m>.
964
+ <answer name="ans1">
965
+ <mathinput name="input1"/>
966
+ <award>$n</award>
967
+ </answer>
968
+ </p>
969
+ <p>What is <m>1+$n</m>?
970
+ <answer name="ans2">
971
+ <mathinput name="input2"/>
972
+ <award>1+$n</award>
973
+ </answer>
974
+ </p>
975
+ <selectFromSequence from="1" to="10" assignNames="n" hide />
976
+ </problem>
977
+ </option>
978
+ <option>
979
+ <problem newNamespace>
980
+ <variantControl numVariants="50" />
981
+ <title>Problem B</title>
982
+ <p>Enter <m>$n</m>.
983
+ <answer name="ans1">
984
+ <mathinput name="input1"/>
985
+ <award>$n</award>
986
+ </answer>
987
+ </p>
988
+ <p>What is <m>1-$n</m>?
989
+ <answer name="ans2">
990
+ <mathinput name="input2"/>
991
+ <award>1-$n</award>
992
+ </answer>
993
+ </p>
994
+ <selectFromSequence from="1" to="10" assignNames="n" hide />
995
+ </problem>
996
+ </option>
997
+ </select>
998
+ <select assignNames = "(((problem2) (problem3)))">
999
+ <option>
1000
+ <select numToSelect="2">
1001
+ <option>
1002
+ <problem newNamespace>
1003
+ <title>Problem C</title>
1004
+ <p>What is <m>2+$n</m>?
1005
+ <answer name="ans">
1006
+ <mathinput name="input"/>
1007
+ <award>2+$n</award>
1008
+ </answer>
1009
+ </p>
1010
+ <selectFromSequence from="1" to="10" assignNames="n" hide />
1011
+ </problem>
1012
+ </option>
1013
+ <option>
1014
+ <problem newNamespace>
1015
+ <title>Problem D</title>
1016
+ <variantControl numVariants="50" />
1017
+ <p>What is <m>2-$n</m>?
1018
+ <answer name="ans">
1019
+ <mathinput name="input"/>
1020
+ <award>2-$n</award>
1021
+ </answer>
1022
+ </p>
1023
+ <selectFromSequence from="1" to="10" assignNames="n" hide />
1024
+ </problem>
1025
+ </option>
1026
+ </select>
1027
+ </option>
1028
+ <option>
1029
+ <select numToSelect="2">
1030
+ <option>
1031
+ <problem newNamespace>
1032
+ <title>Problem E</title>
1033
+ <variantcontrol numVariants="3" variantNames="one two three" />
1034
+ <select assignNames="(n)" hide>
1035
+ <option selectForVariants="one"><number>1</number></option>
1036
+ <option selectForVariants="two"><number>2</number></option>
1037
+ <option selectForVariants="three"><number>3</number></option>
1038
+ </select>
1039
+ <p>What is <m>3+$n</m>?
1040
+ <answer name="ans">
1041
+ <mathinput name="input"/>
1042
+ <award>3+$n</award>
1043
+ </answer>
1044
+ </p>
1045
+ </problem>
1046
+ </option>
1047
+ <option>
1048
+ <problem newNamespace>
1049
+ <title>Problem F</title>
1050
+ <variantcontrol numVariants="3" variantNames="four five six" />
1051
+ <select assignNames="(n)" hide>
1052
+ <option selectForVariants="four"><number>4</number></option>
1053
+ <option selectForVariants="five"><number>5</number></option>
1054
+ <option selectForVariants="six"><number>6</number></option>
1055
+ </select>
1056
+ <p>What is <m>3-$n</m>?
1057
+ <answer name="ans">
1058
+ <mathinput name="input"/>
1059
+ <award>3-$n</award>
1060
+ </answer>
1061
+ </p>
1062
+ </problem>
1063
+ </option>
1064
+ </select>
1065
+ </option>
1066
+ </select>
1067
+ <problem name="problem4" newNamespace>
1068
+ <title>Problem G</title>
1069
+ <selectFromSequence from="101" to="999" name="n" hide/>
1070
+ <p>What is <m>2 \\cdot $n</m>?
1071
+ <answer name="ans">
1072
+ <mathinput name="input"/>
1073
+ <award>2$n</award>
1074
+ </answer>
1075
+ </p>
1076
+ </problem>
1077
+ <problem name="problem5" newNamespace>
1078
+ <title>Problem H</title>
1079
+ <variantControl numVariants="7" variantNames="apple banana cherry date elderberry fig grape" />
1080
+ <!-- Note: explicitly don't put fruit in parens to test for previous error -->
1081
+ <select assignNames="fruit" hide>
1082
+ <option selectForVariants="apple"><text>apple</text></option>
1083
+ <option selectForVariants="banana"><text>banana</text></option>
1084
+ <option selectForVariants="cherry"><text>cherry</text></option>
1085
+ <option selectForVariants="date"><text>date</text></option>
1086
+ <option selectForVariants="elderberry"><text>elderberry</text></option>
1087
+ <option selectForVariants="fig"><text>fig</text></option>
1088
+ <option selectForVariants="grape"><text>grape</text></option>
1089
+ </select>
1090
+ <p>Enter $fruit:
1091
+ <answer name="ans" type="text">
1092
+ <textinput name="input"/>
1093
+ <award>$fruit</award>
1094
+ </answer>
1095
+ </p>
1096
+ </problem>
1097
+ </paginator>
1098
+ <p>Credit achieved: <copy prop="creditAchieved" target="_document1" assignNames="ca" /></p>
1099
+ `;
1100
+
1101
+ cy.get("#testRunner_toggleControls").click();
1102
+ cy.get("#testRunner_allowLocalState").click();
1103
+ cy.wait(100);
1104
+ cy.get("#testRunner_toggleControls").click();
1105
+
1106
+ cy.window().then(async (win) => {
1107
+ win.postMessage(
1108
+ {
1109
+ doenetML,
1110
+ requestedVariant: {
1111
+ subvariants: [
1112
+ {
1113
+ indices: [1],
1114
+ subvariants: [
1115
+ {
1116
+ subvariants: [
1117
+ {
1118
+ indices: [7],
1119
+ },
1120
+ ],
1121
+ },
1122
+ ],
1123
+ },
1124
+ {
1125
+ indices: [2],
1126
+ subvariants: [
1127
+ {
1128
+ indices: [2, 1],
1129
+ subvariants: [
1130
+ {
1131
+ index: 1,
1132
+ },
1133
+ {
1134
+ index: 2,
1135
+ },
1136
+ ],
1137
+ },
1138
+ ],
1139
+ },
1140
+ {
1141
+ subvariants: [
1142
+ {
1143
+ indices: [152],
1144
+ },
1145
+ ],
1146
+ },
1147
+ {
1148
+ index: 6,
1149
+ },
1150
+ ],
1151
+ },
1152
+ },
1153
+ "*",
1154
+ );
1155
+ });
1156
+
1157
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1158
+
1159
+ cy.get(cesc2("#/problem1/_title1")).should("have.text", "Problem A");
1160
+ cy.get(cesc2("#/ca")).should("have.text", "0");
1161
+
1162
+ cy.get(cesc2("#/problem1/input1") + " textarea").type("7{enter}", {
1163
+ force: true,
1164
+ });
1165
+ cy.get(cesc2("#/problem1/input1_correct")).should("be.visible");
1166
+ cy.get(cesc2("#/ca")).should("have.text", "0.1");
1167
+
1168
+ cy.get(cesc2("#/pcontrols_next")).click();
1169
+ cy.get(cesc2("#/problem2/_title1")).should("have.text", "Problem F");
1170
+ cy.get(cesc2("#/ca")).should("have.text", "0.1");
1171
+
1172
+ cy.window().then(async (win) => {
1173
+ win.postMessage(
1174
+ {
1175
+ doenetML: `
1176
+ <text>b</text>
1177
+ `,
1178
+ },
1179
+ "*",
1180
+ );
1181
+ });
1182
+ cy.get(cesc("#\\/_text1")).should("have.text", "b"); //wait for page to load
1183
+
1184
+ cy.window().then(async (win) => {
1185
+ win.postMessage(
1186
+ {
1187
+ doenetML,
1188
+ },
1189
+ "*",
1190
+ );
1191
+ });
1192
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1193
+
1194
+ cy.get(cesc2("#/problem2/_title1")).should("have.text", "Problem F");
1195
+ cy.get(cesc2("#/ca")).should("have.text", "0.1");
1196
+
1197
+ cy.get(cesc2("#/problem2/input") + " textarea").type("-1{enter}", {
1198
+ force: true,
1199
+ });
1200
+ cy.get(cesc2("#/problem2/input_correct")).should("be.visible");
1201
+ cy.get(cesc2("#/ca")).should("have.text", "0.3");
1202
+
1203
+ cy.window().then(async (win) => {
1204
+ win.postMessage(
1205
+ {
1206
+ doenetML: `
1207
+ <text>b</text>
1208
+ `,
1209
+ },
1210
+ "*",
1211
+ );
1212
+ });
1213
+ cy.get(cesc("#\\/_text1")).should("have.text", "b"); //wait for page to load
1214
+
1215
+ cy.window().then(async (win) => {
1216
+ win.postMessage(
1217
+ {
1218
+ doenetML,
1219
+ },
1220
+ "*",
1221
+ );
1222
+ });
1223
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1224
+
1225
+ cy.get(cesc2("#/problem2/_title1")).should("have.text", "Problem F");
1226
+ cy.get(cesc2("#/problem2/input_correct")).should("be.visible");
1227
+ cy.get(cesc2("#/ca")).should("have.text", "0.3");
1228
+
1229
+ cy.get(cesc2("#/pcontrols_previous")).click();
1230
+ cy.get(cesc2("#/problem1/_title1")).should("have.text", "Problem A");
1231
+ cy.get(cesc2("#/problem1/input1_correct")).should("be.visible");
1232
+ cy.get(cesc2("#/ca")).should("have.text", "0.3");
1233
+
1234
+ cy.get(cesc2("#/problem1/input1") + " textarea").type(
1235
+ "{end}{backspace}8{enter}",
1236
+ { force: true },
1237
+ );
1238
+ cy.get(cesc2("#/problem1/input1_incorrect")).should("be.visible");
1239
+ cy.get(cesc2("#/ca")).should("have.text", "0.2");
1240
+
1241
+ cy.get(cesc2("#/problem1/input2") + " textarea").type("8{enter}", {
1242
+ force: true,
1243
+ });
1244
+ cy.get(cesc2("#/problem1/input2_correct")).should("be.visible");
1245
+ cy.get(cesc2("#/ca")).should("have.text", "0.3");
1246
+
1247
+ cy.window().then(async (win) => {
1248
+ win.postMessage(
1249
+ {
1250
+ doenetML: `
1251
+ <text>b</text>
1252
+ `,
1253
+ },
1254
+ "*",
1255
+ );
1256
+ });
1257
+ cy.get(cesc("#\\/_text1")).should("have.text", "b"); //wait for page to load
1258
+
1259
+ cy.window().then(async (win) => {
1260
+ win.postMessage(
1261
+ {
1262
+ doenetML,
1263
+ },
1264
+ "*",
1265
+ );
1266
+ });
1267
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1268
+
1269
+ cy.get(cesc2("#/problem1/_title1")).should("have.text", "Problem A");
1270
+ cy.get(cesc2("#/problem1/input1_incorrect")).should("be.visible");
1271
+ cy.get(cesc2("#/problem1/input2_correct")).should("be.visible");
1272
+ cy.get(cesc2("#/ca")).should("have.text", "0.3");
1273
+
1274
+ cy.get(cesc2("#/pcontrols_next")).click();
1275
+ cy.get(cesc2("#/problem2/_title1")).should("have.text", "Problem F");
1276
+ cy.get(cesc2("#/problem2/input_correct")).should("be.visible");
1277
+ cy.get(cesc2("#/ca")).should("have.text", "0.3");
1278
+
1279
+ cy.get(cesc2("#/pcontrols_next")).click();
1280
+ cy.get(cesc2("#/problem3/_title1")).should("have.text", "Problem E");
1281
+ cy.get(cesc2("#/ca")).should("have.text", "0.3");
1282
+
1283
+ cy.get(cesc2("#/problem3/input") + " textarea").type("x^{enter}", {
1284
+ force: true,
1285
+ });
1286
+ cy.get(cesc2("#/problem3/input_incorrect")).should("be.visible");
1287
+ cy.get(cesc2("#/ca")).should("have.text", "0.3");
1288
+
1289
+ cy.window().then(async (win) => {
1290
+ win.postMessage(
1291
+ {
1292
+ doenetML: `
1293
+ <text>b</text>
1294
+ `,
1295
+ },
1296
+ "*",
1297
+ );
1298
+ });
1299
+ cy.get(cesc("#\\/_text1")).should("have.text", "b"); //wait for page to load
1300
+
1301
+ cy.window().then(async (win) => {
1302
+ win.postMessage(
1303
+ {
1304
+ doenetML,
1305
+ },
1306
+ "*",
1307
+ );
1308
+ });
1309
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1310
+
1311
+ cy.get(cesc2("#/problem3/_title1")).should("have.text", "Problem E");
1312
+ cy.get(cesc2("#/problem3/input_incorrect")).should("be.visible");
1313
+ cy.get(cesc2("#/ca")).should("have.text", "0.3");
1314
+
1315
+ cy.get(cesc2("#/pcontrols_previous")).click();
1316
+ cy.get(cesc2("#/problem2/_title1")).should("have.text", "Problem F");
1317
+ cy.get(cesc2("#/problem2/input_correct")).should("be.visible");
1318
+ cy.get(cesc2("#/ca")).should("have.text", "0.3");
1319
+
1320
+ cy.get(cesc2("#/pcontrols_previous")).click();
1321
+ cy.get(cesc2("#/problem1/_title1")).should("have.text", "Problem A");
1322
+ cy.get(cesc2("#/problem1/input1_incorrect")).should("be.visible");
1323
+ cy.get(cesc2("#/problem1/input2_correct")).should("be.visible");
1324
+ cy.get(cesc2("#/ca")).should("have.text", "0.3");
1325
+
1326
+ cy.get(cesc2("#/pcontrols_next")).click();
1327
+ cy.get(cesc2("#/problem2/_title1")).should("have.text", "Problem F");
1328
+ cy.get(cesc2("#/problem2/input_correct")).should("be.visible");
1329
+ cy.get(cesc2("#/ca")).should("have.text", "0.3");
1330
+
1331
+ cy.window().then(async (win) => {
1332
+ win.postMessage(
1333
+ {
1334
+ doenetML: `
1335
+ <text>b</text>
1336
+ `,
1337
+ },
1338
+ "*",
1339
+ );
1340
+ });
1341
+ cy.get(cesc("#\\/_text1")).should("have.text", "b"); //wait for page to load
1342
+
1343
+ cy.window().then(async (win) => {
1344
+ win.postMessage(
1345
+ {
1346
+ doenetML,
1347
+ },
1348
+ "*",
1349
+ );
1350
+ });
1351
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1352
+
1353
+ cy.get(cesc2("#/problem2/_title1")).should("have.text", "Problem F");
1354
+ cy.get(cesc2("#/problem2/input_correct")).should("be.visible");
1355
+ cy.get(cesc2("#/ca")).should("have.text", "0.3");
1356
+
1357
+ cy.get(cesc2("#/pcontrols_next")).click();
1358
+ cy.get(cesc2("#/problem3/_title1")).should("have.text", "Problem E");
1359
+ cy.get(cesc2("#/problem3/input_incorrect")).should("be.visible");
1360
+ cy.get(cesc2("#/ca")).should("have.text", "0.3");
1361
+
1362
+ cy.get(cesc2("#/pcontrols_next")).click();
1363
+ cy.get(cesc2("#/problem4/_title1")).should("have.text", "Problem G");
1364
+ cy.get(cesc2("#/ca")).should("have.text", "0.3");
1365
+
1366
+ cy.get(cesc2("#/problem4/input") + " textarea").type("504{enter}", {
1367
+ force: true,
1368
+ });
1369
+ cy.get(cesc2("#/problem4/input_correct")).should("be.visible");
1370
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
1371
+
1372
+ cy.get(cesc2("#/pcontrols_next")).click();
1373
+ cy.get(cesc2("#/problem5/_title1")).should("have.text", "Problem H");
1374
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
1375
+
1376
+ cy.get(cesc2("#/problem5/input_input")).type("fig{enter}", { force: true });
1377
+ cy.get(cesc2("#/problem5/input_correct")).should("be.visible");
1378
+ cy.get(cesc2("#/ca")).should("have.text", "0.7");
1379
+
1380
+ cy.get(cesc2("#/pcontrols_previous")).click();
1381
+ cy.get(cesc2("#/problem4/_title1")).should("have.text", "Problem G");
1382
+ cy.get(cesc2("#/problem4/input_correct")).should("be.visible");
1383
+ cy.get(cesc2("#/ca")).should("have.text", "0.7");
1384
+
1385
+ cy.window().then(async (win) => {
1386
+ win.postMessage(
1387
+ {
1388
+ doenetML: `
1389
+ <text>b</text>
1390
+ `,
1391
+ },
1392
+ "*",
1393
+ );
1394
+ });
1395
+ cy.get(cesc("#\\/_text1")).should("have.text", "b"); //wait for page to load
1396
+
1397
+ cy.window().then(async (win) => {
1398
+ win.postMessage(
1399
+ {
1400
+ doenetML,
1401
+ },
1402
+ "*",
1403
+ );
1404
+ });
1405
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1406
+
1407
+ cy.get(cesc2("#/problem4/_title1")).should("have.text", "Problem G");
1408
+ cy.get(cesc2("#/problem4/input_correct")).should("be.visible");
1409
+ cy.get(cesc2("#/ca")).should("have.text", "0.7");
1410
+
1411
+ cy.get(cesc2("#/pcontrols_next")).click();
1412
+ cy.get(cesc2("#/problem5/_title1")).should("have.text", "Problem H");
1413
+ cy.get(cesc2("#/ca")).should("have.text", "0.7");
1414
+ });
1415
+
1416
+ it("With external and internal copies", () => {
1417
+ let doenetML = `
1418
+ <text>a</text>
1419
+ <setup>
1420
+ <problem name="problema" newNamespace>
1421
+ <title>A hard problem</title>
1422
+ <p>What is 1+1? <answer><mathinput /><award>2</award></answer></p>
1423
+ </problem>
1424
+ </setup>
1425
+
1426
+ <paginatorControls paginator="pgn" name="pcontrols" />
1427
+
1428
+ <paginator name="pgn">
1429
+ <copy assignNames="problem1" uri="doenet:CID=bafkreifgmyjuw4m6odukznenshkyfupp3egx6ep3jgnlo747d6s5v7nznu" />
1430
+ <copy assignNames="problem2" uri="doenet:CID=bafkreide4mismb45mxved2ibfh5jnj75kty7vjz7w6zo7goyxpwr2e7wti" />
1431
+ <copy assignNames="problem3" target="problema" link="false" />
1432
+
1433
+ </paginator>
1434
+ <p>Credit achieved: <copy prop="creditAchieved" target="_document1" assignNames="ca" /></p>
1435
+ `;
1436
+
1437
+ cy.get("#testRunner_toggleControls").click();
1438
+ cy.get("#testRunner_allowLocalState").click();
1439
+ cy.wait(100);
1440
+ cy.get("#testRunner_toggleControls").click();
1441
+
1442
+ cy.window().then(async (win) => {
1443
+ win.postMessage(
1444
+ {
1445
+ doenetML,
1446
+ requestedVariantIndex: 3,
1447
+ // for now, at least, variant 3 gives mouse....
1448
+ // subvariants: [{}, {
1449
+ // name: "mouse"
1450
+ // }]
1451
+ },
1452
+ "*",
1453
+ );
1454
+ });
1455
+
1456
+ let choices;
1457
+
1458
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1459
+
1460
+ cy.get(cesc2("#/problem1/_title1")).should("have.text", "Animal sounds");
1461
+ cy.get(cesc2("#/ca")).should("have.text", "0");
1462
+ cy.window().then(async (win) => {
1463
+ let stateVariables = await win.returnAllStateVariables1();
1464
+ choices =
1465
+ stateVariables["/problem1/_choiceinput1"].stateValues.choiceTexts;
1466
+ let mouseInd = choices.indexOf("squeak") + 1;
1467
+ cy.get(cesc2(`#/problem1/_choiceinput1_choice${mouseInd}_input`)).click();
1468
+ });
1469
+
1470
+ cy.get(cesc2(`#/problem1/_choiceinput1_submit`)).click();
1471
+ cy.get(cesc2(`#/problem1/_choiceinput1_correct`)).should("be.visible");
1472
+ cy.get(cesc2("#/ca")).should("have.text", "0.333");
1473
+
1474
+ cy.wait(2000); // wait for 1 second debounce
1475
+ cy.reload();
1476
+
1477
+ cy.window().then(async (win) => {
1478
+ win.postMessage(
1479
+ {
1480
+ doenetML,
1481
+ },
1482
+ "*",
1483
+ );
1484
+ });
1485
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1486
+
1487
+ // wait until core is loaded
1488
+ cy.waitUntil(() =>
1489
+ cy.window().then(async (win) => {
1490
+ let stateVariables = await win.returnAllStateVariables1();
1491
+ let foundIt = Boolean(
1492
+ stateVariables["/problem1/_choiceinput1"]?.stateValues?.choiceTexts,
1493
+ );
1494
+ return foundIt;
1495
+ }),
1496
+ );
1497
+
1498
+ cy.get(cesc2("#/problem1/_title1")).should("have.text", "Animal sounds");
1499
+ cy.get(cesc2(`#/problem1/_choiceinput1_correct`)).should("be.visible");
1500
+ cy.get(cesc2("#/ca")).should("have.text", "0.333");
1501
+
1502
+ cy.get(cesc2("#/pcontrols_next")).click();
1503
+ cy.get(cesc2("#/problem2/_title1")).should(
1504
+ "have.text",
1505
+ "Derivative problem",
1506
+ );
1507
+ cy.get(cesc2("#/ca")).should("have.text", "0.333");
1508
+
1509
+ cy.window().then(async (win) => {
1510
+ let stateVariables = await win.returnAllStateVariables1();
1511
+ let mathinput2Name =
1512
+ stateVariables["/problem2/_answer1"].stateValues.inputChildren[0]
1513
+ .componentName;
1514
+
1515
+ let mathinput2Anchor = cesc2(`#${mathinput2Name}`) + " textarea";
1516
+ let mathinput2Correct = cesc2(`#${mathinput2Name}_correct`);
1517
+
1518
+ cy.get(mathinput2Anchor).type("2x{enter}", { force: true });
1519
+ cy.get(mathinput2Correct).should("be.visible");
1520
+ cy.get(cesc2("#/ca")).should("have.text", "0.667");
1521
+
1522
+ cy.get(cesc2("#/pcontrols_previous")).click();
1523
+ cy.get(cesc2("#/problem1/_title1")).should("have.text", "Animal sounds");
1524
+ cy.get(cesc2(`#/problem1/_choiceinput1_correct`)).should("be.visible");
1525
+ cy.get(cesc2("#/ca")).should("have.text", "0.667");
1526
+
1527
+ cy.wait(2000); // wait for 1 second debounce
1528
+ cy.reload();
1529
+
1530
+ cy.window().then(async (win) => {
1531
+ win.postMessage(
1532
+ {
1533
+ doenetML,
1534
+ },
1535
+ "*",
1536
+ );
1537
+ });
1538
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1539
+
1540
+ cy.get(cesc2("#/problem1/_title1")).should("have.text", "Animal sounds");
1541
+ cy.get(cesc2(`#/problem1/_choiceinput1_correct`)).should("be.visible");
1542
+ cy.get(cesc2("#/ca")).should("have.text", "0.667");
1543
+
1544
+ cy.get(cesc2("#/pcontrols_next")).click();
1545
+ cy.get(cesc2("#/problem2/_title1")).should(
1546
+ "have.text",
1547
+ "Derivative problem",
1548
+ );
1549
+ cy.get(mathinput2Correct).should("be.visible");
1550
+ cy.get(cesc2("#/ca")).should("have.text", "0.667");
1551
+
1552
+ cy.get(cesc2("#/pcontrols_next")).click();
1553
+ cy.get(cesc2("#/problem3/_title1")).should("have.text", "A hard problem");
1554
+ cy.get(cesc2("#/ca")).should("have.text", "0.667");
1555
+
1556
+ cy.get(cesc2("#/problem3/_mathinput1") + " textarea").type("2{enter}", {
1557
+ force: true,
1558
+ });
1559
+ cy.get(cesc2("#/problem3/_mathinput1_correct")).should("be.visible");
1560
+ cy.get(cesc2("#/ca")).should("have.text", "1");
1561
+
1562
+ cy.wait(2000); // wait for 1 second debounce
1563
+ cy.reload();
1564
+
1565
+ cy.window().then(async (win) => {
1566
+ win.postMessage(
1567
+ {
1568
+ doenetML,
1569
+ },
1570
+ "*",
1571
+ );
1572
+ });
1573
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1574
+
1575
+ cy.get(cesc2("#/problem3/_title1")).should("have.text", "A hard problem");
1576
+ cy.get(cesc2("#/problem3/_mathinput1_correct")).should("be.visible");
1577
+ cy.get(cesc2("#/ca")).should("have.text", "1");
1578
+
1579
+ cy.get(cesc2("#/pcontrols_previous")).click();
1580
+ cy.get(cesc2("#/problem2/_title1")).should(
1581
+ "have.text",
1582
+ "Derivative problem",
1583
+ );
1584
+ cy.get(mathinput2Correct).should("be.visible");
1585
+ cy.get(cesc2("#/ca")).should("have.text", "1");
1586
+
1587
+ cy.get(cesc2("#/pcontrols_previous")).click();
1588
+ cy.get(cesc2("#/problem1/_title1")).should("have.text", "Animal sounds");
1589
+ cy.get(cesc2(`#/problem1/_choiceinput1_correct`)).should("be.visible");
1590
+ cy.get(cesc2("#/ca")).should("have.text", "1");
1591
+
1592
+ cy.window().then(async (win) => {
1593
+ let stateVariables = await win.returnAllStateVariables1();
1594
+ let choiceTexts =
1595
+ stateVariables["/problem1/_choiceinput1"].stateValues.choiceTexts;
1596
+ expect(choiceTexts).eqls(choices);
1597
+ let dogInd = choices.indexOf("woof") + 1;
1598
+ cy.get(cesc2(`#/problem1/_choiceinput1_choice${dogInd}_input`)).click();
1599
+ });
1600
+
1601
+ cy.get(cesc2(`#/problem1/_choiceinput1_submit`)).click();
1602
+ cy.get(cesc2(`#/problem1/_choiceinput1_incorrect`)).should("be.visible");
1603
+ cy.get(cesc2("#/ca")).should("have.text", "0.667");
1604
+
1605
+ cy.window().then(async (win) => {
1606
+ let stateVariables = await win.returnAllStateVariables1();
1607
+ let choiceTexts =
1608
+ stateVariables["/problem1/_choiceinput1"].stateValues.choiceTexts;
1609
+ expect(choiceTexts).eqls(choices);
1610
+ let mouseInd = choices.indexOf("squeak") + 1;
1611
+ cy.get(
1612
+ cesc2(`#/problem1/_choiceinput1_choice${mouseInd}_input`),
1613
+ ).click();
1614
+ });
1615
+
1616
+ cy.get(cesc2(`#/problem1/_choiceinput1_submit`)).click();
1617
+ cy.get(cesc2(`#/problem1/_choiceinput1_correct`)).should("be.visible");
1618
+ cy.get(cesc2("#/ca")).should("have.text", "1");
1619
+ });
1620
+ });
1621
+
1622
+ it("External and internal copies, with variantcontrols in document and problem", () => {
1623
+ let doenetML = `
1624
+ <text>a</text>
1625
+ <variantControl numVariants="100" />
1626
+ <setup>
1627
+ <problem name="problema" newNamespace>
1628
+ <variantControl numVariants="1" />
1629
+ <title>A hard problem</title>
1630
+ <p>What is 1+1? <answer><mathinput /><award>2</award></answer></p>
1631
+ </problem>
1632
+ </setup>
1633
+
1634
+ <paginatorControls paginator="pgn" name="pcontrols" />
1635
+
1636
+ <paginator name="pgn">
1637
+ <copy assignNames="problem1" uri="doenet:CID=bafkreifgmyjuw4m6odukznenshkyfupp3egx6ep3jgnlo747d6s5v7nznu" />
1638
+ <copy assignNames="problem2" uri="doenet:CID=bafkreide4mismb45mxved2ibfh5jnj75kty7vjz7w6zo7goyxpwr2e7wti" />
1639
+ <copy assignNames="problem3" target="problema" link="false" />
1640
+
1641
+ </paginator>
1642
+ <p>Credit achieved: <copy prop="creditAchieved" target="_document1" assignNames="ca" /></p>
1643
+ `;
1644
+
1645
+ cy.get("#testRunner_toggleControls").click();
1646
+ cy.get("#testRunner_allowLocalState").click();
1647
+ cy.wait(100);
1648
+ cy.get("#testRunner_toggleControls").click();
1649
+
1650
+ cy.window().then(async (win) => {
1651
+ win.postMessage(
1652
+ {
1653
+ doenetML,
1654
+ requestedVariantIndex: 3,
1655
+ },
1656
+ "*",
1657
+ );
1658
+ });
1659
+
1660
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1661
+
1662
+ cy.get(cesc2("#/problem1/_title1")).should("have.text", "Animal sounds");
1663
+ cy.get(cesc2("#/ca")).should("have.text", "0");
1664
+ cy.window().then(async (win) => {
1665
+ let stateVariables = await win.returnAllStateVariables1();
1666
+ let choices = [
1667
+ ...stateVariables["/problem1/_choiceinput1"].stateValues.choiceTexts,
1668
+ ];
1669
+ let mouseInd = choices.indexOf("squeak") + 1;
1670
+ cy.get(cesc2(`#/problem1/_choiceinput1_choice${mouseInd}_input`)).click();
1671
+ });
1672
+
1673
+ cy.get(cesc2(`#/problem1/_choiceinput1_submit`)).click();
1674
+ cy.get(cesc2(`#/problem1/_choiceinput1_correct`)).should("be.visible");
1675
+ cy.get(cesc2("#/ca")).should("have.text", "0.333");
1676
+
1677
+ cy.wait(2000); // wait for 1 second debounce
1678
+ cy.reload();
1679
+
1680
+ cy.window().then(async (win) => {
1681
+ win.postMessage(
1682
+ {
1683
+ doenetML,
1684
+ },
1685
+ "*",
1686
+ );
1687
+ });
1688
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1689
+
1690
+ cy.get(cesc2("#/problem1/_title1")).should("have.text", "Animal sounds");
1691
+ cy.get(cesc2(`#/problem1/_choiceinput1_correct`)).should("be.visible");
1692
+ cy.get(cesc2("#/ca")).should("have.text", "0.333");
1693
+
1694
+ cy.get(cesc2("#/pcontrols_next")).click();
1695
+ cy.get(cesc2("#/problem2/_title1")).should(
1696
+ "have.text",
1697
+ "Derivative problem",
1698
+ );
1699
+ cy.get(cesc2("#/ca")).should("have.text", "0.333");
1700
+
1701
+ cy.window().then(async (win) => {
1702
+ let stateVariables = await win.returnAllStateVariables1();
1703
+ let mathinput2Name =
1704
+ stateVariables["/problem2/_answer1"].stateValues.inputChildren[0]
1705
+ .componentName;
1706
+
1707
+ let mathinput2Anchor = cesc2(`#${mathinput2Name}`) + " textarea";
1708
+ let mathinput2Correct = cesc2(`#${mathinput2Name}_correct`);
1709
+
1710
+ cy.get(mathinput2Anchor).type("2x{enter}", { force: true });
1711
+ cy.get(mathinput2Correct).should("be.visible");
1712
+ cy.get(cesc2("#/ca")).should("have.text", "0.667");
1713
+
1714
+ cy.get(cesc2("#/pcontrols_previous")).click();
1715
+ cy.get(cesc2("#/problem1/_title1")).should("have.text", "Animal sounds");
1716
+ cy.get(cesc2(`#/problem1/_choiceinput1_correct`)).should("be.visible");
1717
+ cy.get(cesc2("#/ca")).should("have.text", "0.667");
1718
+
1719
+ cy.wait(2000); // wait for 1 second debounce
1720
+ cy.reload();
1721
+
1722
+ cy.window().then(async (win) => {
1723
+ win.postMessage(
1724
+ {
1725
+ doenetML,
1726
+ },
1727
+ "*",
1728
+ );
1729
+ });
1730
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1731
+
1732
+ cy.get(cesc2("#/problem1/_title1")).should("have.text", "Animal sounds");
1733
+ cy.get(cesc2(`#/problem1/_choiceinput1_correct`)).should("be.visible");
1734
+ cy.get(cesc2("#/ca")).should("have.text", "0.667");
1735
+
1736
+ cy.get(cesc2("#/pcontrols_next")).click();
1737
+ cy.get(cesc2("#/problem2/_title1")).should(
1738
+ "have.text",
1739
+ "Derivative problem",
1740
+ );
1741
+ cy.get(mathinput2Correct).should("be.visible");
1742
+ cy.get(cesc2("#/ca")).should("have.text", "0.667");
1743
+
1744
+ cy.get(cesc2("#/pcontrols_next")).click();
1745
+ cy.get(cesc2("#/problem3/_title1")).should("have.text", "A hard problem");
1746
+ cy.get(cesc2("#/ca")).should("have.text", "0.667");
1747
+
1748
+ cy.get(cesc2("#/problem3/_mathinput1") + " textarea").type("2{enter}", {
1749
+ force: true,
1750
+ });
1751
+ cy.get(cesc2("#/problem3/_mathinput1_correct")).should("be.visible");
1752
+ cy.get(cesc2("#/ca")).should("have.text", "1");
1753
+
1754
+ cy.wait(2000); // wait for 1 second debounce
1755
+ cy.reload();
1756
+
1757
+ cy.window().then(async (win) => {
1758
+ win.postMessage(
1759
+ {
1760
+ doenetML,
1761
+ },
1762
+ "*",
1763
+ );
1764
+ });
1765
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1766
+
1767
+ cy.get(cesc2("#/problem3/_title1")).should("have.text", "A hard problem");
1768
+ cy.get(cesc2("#/problem3/_mathinput1_correct")).should("be.visible");
1769
+ cy.get(cesc2("#/ca")).should("have.text", "1");
1770
+
1771
+ cy.get(cesc2("#/pcontrols_previous")).click();
1772
+ cy.get(cesc2("#/problem2/_title1")).should(
1773
+ "have.text",
1774
+ "Derivative problem",
1775
+ );
1776
+ cy.get(mathinput2Correct).should("be.visible");
1777
+ cy.get(cesc2("#/ca")).should("have.text", "1");
1778
+
1779
+ cy.get(cesc2("#/pcontrols_previous")).click();
1780
+ cy.get(cesc2("#/problem1/_title1")).should("have.text", "Animal sounds");
1781
+ cy.get(cesc2(`#/problem1/_choiceinput1_correct`)).should("be.visible");
1782
+ cy.get(cesc2("#/ca")).should("have.text", "1");
1783
+ });
1784
+ });
1785
+
1786
+ it("Variantcontrols in document and problem", () => {
1787
+ let doenetML = `
1788
+ <text>a</text>
1789
+ <variantControl numVariants="100" />
1790
+
1791
+ <paginatorControls paginator="pgn" name="pcontrols" />
1792
+
1793
+ <paginator name="pgn">
1794
+ <problem>
1795
+ <title>Type a number</title>
1796
+ <variantControl numVariants="100" />
1797
+ <selectFromSequence assignNames="a" from="1" to="1000" hide />
1798
+ $a: <answer>$a</answer>
1799
+ </problem>
1800
+ <problem>
1801
+ <title>Type a letter</title>
1802
+ <variantControl numVariants="3" />
1803
+ <select assignNames="b" hide >u v w x y z</select>
1804
+ $b: <answer>$b</answer>
1805
+ </problem>
1806
+
1807
+ </paginator>
1808
+ <p>Credit achieved: <copy prop="creditAchieved" target="_document1" assignNames="ca" /></p>
1809
+ `;
1810
+
1811
+ cy.get("#testRunner_toggleControls").click();
1812
+ cy.get("#testRunner_allowLocalState").click();
1813
+ cy.wait(100);
1814
+ cy.get("#testRunner_toggleControls").click();
1815
+
1816
+ cy.window().then(async (win) => {
1817
+ win.postMessage(
1818
+ {
1819
+ doenetML,
1820
+ },
1821
+ "*",
1822
+ );
1823
+ });
1824
+
1825
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1826
+
1827
+ cy.get(cesc2("#/_title1")).should("have.text", "Type a number");
1828
+ cy.get(cesc2("#/ca")).should("have.text", "0");
1829
+ cy.window().then(async (win) => {
1830
+ let stateVariables = await win.returnAllStateVariables1();
1831
+ let a = stateVariables["/a"].stateValues.value;
1832
+
1833
+ let mathinput1Name =
1834
+ stateVariables["/_answer1"].stateValues.inputChildren[0].componentName;
1835
+ let mathinput1Anchor = cesc2(`#${mathinput1Name}`) + " textarea";
1836
+ let mathinput1Correct = cesc2(`#${mathinput1Name}_correct`);
1837
+
1838
+ cy.get(mathinput1Anchor).type(`${a}{enter}`, { force: true });
1839
+ cy.get(mathinput1Correct).should("be.visible");
1840
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
1841
+ });
1842
+
1843
+ cy.get(cesc2("#/pcontrols_next")).click();
1844
+ cy.get(cesc2("#/_title2")).should("have.text", "Type a letter");
1845
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
1846
+
1847
+ cy.wait(100);
1848
+ cy.window().then(async (win) => {
1849
+ let stateVariables = await win.returnAllStateVariables1();
1850
+ let b = stateVariables["/b"].stateValues.value;
1851
+
1852
+ let mathinput2Name =
1853
+ stateVariables["/_answer2"].stateValues.inputChildren[0].componentName;
1854
+ let mathinput2Anchor = cesc2(`#${mathinput2Name}`) + " textarea";
1855
+ let mathinput2Correct = cesc2(`#${mathinput2Name}_correct`);
1856
+
1857
+ cy.get(mathinput2Anchor).type(`${b}{enter}`, { force: true });
1858
+ cy.get(mathinput2Correct).should("be.visible");
1859
+ cy.get(cesc2("#/ca")).should("have.text", "1");
1860
+ });
1861
+
1862
+ cy.wait(2000); // wait for 1 second debounce
1863
+ cy.reload();
1864
+
1865
+ cy.window().then(async (win) => {
1866
+ win.postMessage(
1867
+ {
1868
+ doenetML,
1869
+ },
1870
+ "*",
1871
+ );
1872
+ });
1873
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1874
+
1875
+ // wait until core is loaded
1876
+ cy.waitUntil(() =>
1877
+ cy.window().then(async (win) => {
1878
+ let stateVariables = await win.returnAllStateVariables1();
1879
+ return Boolean(stateVariables["/_answer2"]);
1880
+ }),
1881
+ );
1882
+
1883
+ cy.get(cesc2("#/_title2")).should("have.text", "Type a letter");
1884
+ cy.get(cesc2("#/ca")).should("have.text", "1");
1885
+
1886
+ cy.window().then(async (win) => {
1887
+ let stateVariables = await win.returnAllStateVariables1();
1888
+
1889
+ let mathinput2Name =
1890
+ stateVariables["/_answer2"].stateValues.inputChildren[0].componentName;
1891
+ let mathinput2Correct = cesc2(`#${mathinput2Name}_correct`);
1892
+
1893
+ cy.get(mathinput2Correct).should("be.visible");
1894
+ });
1895
+
1896
+ cy.get(cesc2("#/pcontrols_previous")).click();
1897
+ cy.get(cesc2("#/_title1")).should("have.text", "Type a number");
1898
+ cy.get(cesc2("#/ca")).should("have.text", "1");
1899
+
1900
+ cy.window().then(async (win) => {
1901
+ let stateVariables = await win.returnAllStateVariables1();
1902
+
1903
+ let mathinput1Name =
1904
+ stateVariables["/_answer1"].stateValues.inputChildren[0].componentName;
1905
+ let mathinput1Correct = cesc2(`#${mathinput1Name}_correct`);
1906
+
1907
+ cy.get(mathinput1Correct).should("be.visible");
1908
+ });
1909
+ });
1910
+
1911
+ // removed this feature
1912
+ it.skip("Submit all answers on page change", () => {
1913
+ let doenetML = `
1914
+ <text>a</text>
1915
+ <paginatorControls paginator="pgn" name="pcontrols" />
1916
+
1917
+ <paginator name="pgn" submitAllOnPageChange>
1918
+ <problem>
1919
+ <title>Problem 1</title>
1920
+ <p>1: <answer><mathinput name="mi1"/><award>1</award></answer></p>
1921
+ <p>2: <answer><mathinput name="mi2"/><award>2</award></answer></p>
1922
+ </problem>
1923
+ <problem>
1924
+ <title>Problem 2</title>
1925
+ <p>3: <answer><mathinput name="mi3"/><award>3</award></answer></p>
1926
+ <p>4: <answer><mathinput name="mi4"/><award>4</award></answer></p>
1927
+ <p>5: <answer><mathinput name="mi5"/><award>5</award></answer></p>
1928
+ </problem>
1929
+ <problem>
1930
+ <title>Problem 3</title>
1931
+ <p>6: <answer><mathinput name="mi6"/><award>6</award></answer></p>
1932
+ </problem>
1933
+ </paginator>
1934
+ <p>Credit achieved: <copy prop="creditAchieved" target="_document1" assignNames="ca" /></p>
1935
+ `;
1936
+
1937
+ cy.get("#testRunner_toggleControls").click();
1938
+ cy.get("#testRunner_allowLocalState").click();
1939
+ cy.wait(100);
1940
+ cy.get("#testRunner_toggleControls").click();
1941
+
1942
+ cy.window().then(async (win) => {
1943
+ win.postMessage(
1944
+ {
1945
+ doenetML,
1946
+ },
1947
+ "*",
1948
+ );
1949
+ });
1950
+
1951
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
1952
+
1953
+ cy.get(cesc2("#/_title1")).should("have.text", "Problem 1");
1954
+ cy.get(cesc2("#/ca")).should("have.text", "0");
1955
+
1956
+ cy.get(cesc("#\\/mi1") + " textarea").type("1", { force: true });
1957
+ cy.get(cesc("#\\/mi1_submit")).should("be.visible");
1958
+ cy.get(cesc2("#/ca")).should("have.text", "0");
1959
+
1960
+ cy.get(cesc("#\\/mi2") + " textarea").type("2{enter}", { force: true });
1961
+ cy.get(cesc("#\\/mi2_correct")).should("be.visible");
1962
+ cy.get(cesc2("#/ca")).should("have.text", "0.167");
1963
+
1964
+ cy.get(cesc2("#/pcontrols_next")).click();
1965
+ cy.get(cesc2("#/_title2")).should("have.text", "Problem 2");
1966
+ cy.get(cesc2("#/ca")).should("have.text", "0.333");
1967
+
1968
+ cy.get(cesc("#\\/mi3_submit")).should("be.visible");
1969
+ cy.get(cesc("#\\/mi4_submit")).should("be.visible");
1970
+ cy.get(cesc("#\\/mi5_submit")).should("be.visible");
1971
+
1972
+ cy.get(cesc("#\\/mi3") + " textarea").type("3", { force: true });
1973
+ cy.get(cesc("#\\/mi3_submit")).should("be.visible");
1974
+ cy.get(cesc2("#/ca")).should("have.text", "0.333");
1975
+
1976
+ cy.get(cesc("#\\/mi4") + " textarea").type("x", { force: true });
1977
+ cy.get(cesc("#\\/mi4_submit")).should("be.visible");
1978
+ cy.get(cesc2("#/ca")).should("have.text", "0.333");
1979
+
1980
+ cy.get(cesc2("#/pcontrols_previous")).click();
1981
+ cy.get(cesc2("#/_title1")).should("have.text", "Problem 1");
1982
+ cy.get(cesc2("#/ca")).should("have.text", "0.444");
1983
+
1984
+ cy.get(cesc("#\\/mi1_correct")).should("be.visible");
1985
+ cy.get(cesc("#\\/mi2_correct")).should("be.visible");
1986
+
1987
+ cy.get(cesc("#\\/mi1") + " textarea").type("{end}{backspace}y", {
1988
+ force: true,
1989
+ });
1990
+ cy.get(cesc("#\\/mi1_submit")).should("be.visible");
1991
+ cy.get(cesc2("#/ca")).should("have.text", "0.444");
1992
+
1993
+ cy.get(cesc2("#/pcontrols_next")).click();
1994
+ cy.get(cesc2("#/_title2")).should("have.text", "Problem 2");
1995
+ cy.get(cesc2("#/ca")).should("have.text", "0.278");
1996
+
1997
+ cy.get(cesc("#\\/mi3_correct")).should("be.visible");
1998
+ cy.get(cesc("#\\/mi4_incorrect")).should("be.visible");
1999
+ cy.get(cesc("#\\/mi5_incorrect")).should("be.visible");
2000
+
2001
+ cy.get(cesc("#\\/mi5") + " textarea").type("5", { force: true });
2002
+ cy.get(cesc("#\\/mi5_submit")).should("be.visible");
2003
+ cy.get(cesc2("#/ca")).should("have.text", "0.278");
2004
+
2005
+ cy.get(cesc2("#/pcontrols_next")).click();
2006
+ cy.get(cesc2("#/_title3")).should("have.text", "Problem 3");
2007
+ cy.get(cesc2("#/ca")).should("have.text", "0.389");
2008
+
2009
+ cy.get(cesc("#\\/mi6_submit")).should("be.visible");
2010
+
2011
+ cy.get(cesc("#\\/mi6") + " textarea").type("6", { force: true });
2012
+ cy.get(cesc("#\\/mi6_submit")).should("be.visible");
2013
+ cy.get(cesc2("#/ca")).should("have.text", "0.389");
2014
+
2015
+ cy.get(cesc2("#/pcontrols_previous")).click();
2016
+ cy.get(cesc2("#/_title2")).should("have.text", "Problem 2");
2017
+ cy.get(cesc2("#/ca")).should("have.text", "0.722");
2018
+
2019
+ cy.get(cesc("#\\/mi3_correct")).should("be.visible");
2020
+ cy.get(cesc("#\\/mi4_incorrect")).should("be.visible");
2021
+ cy.get(cesc("#\\/mi5_correct")).should("be.visible");
2022
+
2023
+ cy.get(cesc2("#/pcontrols_next")).click();
2024
+ cy.get(cesc2("#/_title3")).should("have.text", "Problem 3");
2025
+ cy.get(cesc2("#/ca")).should("have.text", "0.722");
2026
+
2027
+ cy.get(cesc("#\\/mi6_correct")).should("be.visible");
2028
+
2029
+ cy.log("answers not submitted when readonly");
2030
+ cy.get(cesc("#\\/mi6") + " textarea").type("{end}{backspace}7", {
2031
+ force: true,
2032
+ });
2033
+ cy.get(cesc("#\\/mi6_submit")).should("be.visible");
2034
+ cy.get(cesc2("#/ca")).should("have.text", "0.722");
2035
+
2036
+ // at least right now, this turns on Read Only
2037
+ cy.get("h3 > button").click();
2038
+ cy.get(":nth-child(5) > label > input").click();
2039
+ cy.get("h3 > button").click();
2040
+
2041
+ cy.get(cesc2("#/pcontrols_previous")).click();
2042
+ cy.get(cesc2("#/ca")).should("have.text", "0.722");
2043
+
2044
+ cy.get(cesc2("#/pcontrols_next")).click();
2045
+ cy.get(cesc("#\\/mi6_submit")).should("be.visible");
2046
+ cy.get(cesc2("#/ca")).should("have.text", "0.722");
2047
+ });
2048
+
2049
+ // Do we restore this feature?
2050
+ it.skip("Paginator controls ignore read only flag", () => {
2051
+ let doenetML = `
2052
+ <text>a</text>
2053
+ <paginatorControls paginator="pgn" name="pcontrols" />
2054
+
2055
+ <paginator name="pgn">
2056
+ <problem>
2057
+ <title>Problem 1</title>
2058
+ <p>1: <answer type="text"><textinput name="ti1"/><award>1</award></answer></p>
2059
+ </problem>
2060
+ <problem>
2061
+ <title>Problem 2</title>
2062
+ <p>2: <answer type="text"><textinput name="ti2"/><award>2</award></answer></p>
2063
+ </problem>
2064
+ </paginator>
2065
+ <p>Credit achieved: <copy prop="creditAchieved" target="_document1" assignNames="ca" /></p>
2066
+ `;
2067
+
2068
+ cy.get("#testRunner_toggleControls").click();
2069
+ cy.get("#testRunner_allowLocalState").click();
2070
+ cy.wait(100);
2071
+ cy.get("#testRunner_toggleControls").click();
2072
+
2073
+ cy.window().then(async (win) => {
2074
+ win.postMessage(
2075
+ {
2076
+ doenetML,
2077
+ },
2078
+ "*",
2079
+ );
2080
+ });
2081
+
2082
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2083
+
2084
+ cy.get(cesc2("#/_title1")).should("have.text", "Problem 1");
2085
+
2086
+ cy.get(cesc("#\\/ti1_input")).type("1{enter}");
2087
+ cy.get(cesc("#\\/ti1_input")).should("have.value", "1");
2088
+
2089
+ cy.get(cesc("#\\/ti1_correct")).should("be.visible");
2090
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
2091
+
2092
+ cy.get(cesc2("#/pcontrols_next")).click();
2093
+ cy.get(cesc2("#/_title2")).should("have.text", "Problem 2");
2094
+
2095
+ cy.get(cesc("#\\/ti2_input")).type("2");
2096
+ cy.get(cesc("#\\/ti2_input")).should("have.value", "2");
2097
+ cy.get(cesc("#\\/ti2_submit")).should("be.visible");
2098
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
2099
+
2100
+ // at least right now, this turns on Read Only
2101
+ cy.get("h3 > button").click();
2102
+ cy.get(":nth-child(5) > label > input").click();
2103
+ cy.get("h3 > button").click();
2104
+
2105
+ cy.get(cesc("#\\/ti2_input")).should("be.disabled");
2106
+ cy.get(cesc("#\\/ti2_input")).should("have.value", "2");
2107
+ cy.get(cesc("#\\/ti2_submit")).should("be.disabled");
2108
+
2109
+ cy.get(cesc2("#/pcontrols_previous")).click();
2110
+ cy.get(cesc2("#/_title1")).should("have.text", "Problem 1");
2111
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
2112
+
2113
+ cy.get(cesc("#\\/ti1_input")).should("be.disabled");
2114
+ cy.get(cesc("#\\/ti1_input")).should("have.value", "1");
2115
+
2116
+ cy.get(cesc2("#/pcontrols_next")).click();
2117
+ cy.get(cesc2("#/_title2")).should("have.text", "Problem 2");
2118
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
2119
+
2120
+ cy.get(cesc("#\\/ti2_input")).should("be.disabled");
2121
+ cy.get(cesc("#\\/ti2_input")).should("have.value", "2");
2122
+ cy.get(cesc("#\\/ti2_submit")).should("be.disabled");
2123
+ });
2124
+
2125
+ it("Variants stay consistent with external copies", () => {
2126
+ let doenetMLWithSelects = `
2127
+ <text>a</text>
2128
+ <paginatorControls paginator="pgn" name="pcontrols" />
2129
+
2130
+ <paginator name="pgn">
2131
+ <select numToSelect="2" assignNames="(problem1) (problem2)">
2132
+ <option>
2133
+ <problem copyfromuri="doenet:cid=bafkreidheiqnahrf33h6etsqwo26s7w3upl44bra6xtssxm5rmc3osjave" />
2134
+ </option>
2135
+ <option>
2136
+ <problem copyfromuri="doenet:CID=bafkreifgmyjuw4m6odukznenshkyfupp3egx6ep3jgnlo747d6s5v7nznu" />
2137
+ </option>
2138
+ </select>
2139
+ </paginator>
2140
+
2141
+ <p>Credit achieved: <copy prop="creditAchieved" target="_document1" assignNames="ca" /></p>
2142
+ `;
2143
+
2144
+ let doenetMLorder1 = `
2145
+ <text>a</text>
2146
+ <paginatorControls paginator="pgn" name="pcontrols" />
2147
+ <paginator name="pgn">
2148
+ <copy uri="doenet:cid=bafkreidheiqnahrf33h6etsqwo26s7w3upl44bra6xtssxm5rmc3osjave" assignNames="problem1" />
2149
+ <copy uri="doenet:CID=bafkreifgmyjuw4m6odukznenshkyfupp3egx6ep3jgnlo747d6s5v7nznu" assignNames="problem2" />
2150
+ </paginator>
2151
+
2152
+ <p>Credit achieved: <copy prop="creditAchieved" target="_document1" assignNames="ca" /></p>
2153
+ `;
2154
+
2155
+ let doenetMLorder2 = `
2156
+ <text>a</text>
2157
+ <paginatorControls paginator="pgn" name="pcontrols" />
2158
+ <paginator name="pgn">
2159
+ <copy uri="doenet:CID=bafkreifgmyjuw4m6odukznenshkyfupp3egx6ep3jgnlo747d6s5v7nznu" assignNames="problem1" />
2160
+ <copy uri="doenet:cid=bafkreidheiqnahrf33h6etsqwo26s7w3upl44bra6xtssxm5rmc3osjave" assignNames="problem2" />
2161
+ </paginator>
2162
+
2163
+ <p>Credit achieved: <copy prop="creditAchieved" target="_document1" assignNames="ca" /></p>
2164
+ `;
2165
+
2166
+ let allDoenetMLs = [
2167
+ doenetMLorder1,
2168
+ doenetMLorder2,
2169
+ doenetMLWithSelects,
2170
+ doenetMLWithSelects,
2171
+ doenetMLWithSelects,
2172
+ doenetMLWithSelects,
2173
+ ];
2174
+
2175
+ cy.get("#testRunner_toggleControls").click();
2176
+ cy.get("#testRunner_allowLocalState").click();
2177
+ cy.wait(1000);
2178
+ cy.get("#testRunner_toggleControls").click();
2179
+
2180
+ cy.window().then(async (win) => {
2181
+ win.postMessage(
2182
+ {
2183
+ doenetML: allDoenetMLs[0],
2184
+ },
2185
+ "*",
2186
+ );
2187
+ });
2188
+
2189
+ for (let attemptNumber = 1; attemptNumber <= 6; attemptNumber++) {
2190
+ if (attemptNumber > 1) {
2191
+ cy.get("#testRunner_toggleControls").click();
2192
+ cy.get("#testRunner_newAttempt").click();
2193
+ cy.get("#testRunner_toggleControls").click();
2194
+
2195
+ cy.wait(1000);
2196
+
2197
+ cy.reload();
2198
+
2199
+ cy.window().then(async (win) => {
2200
+ win.postMessage(
2201
+ {
2202
+ doenetML: allDoenetMLs[attemptNumber - 1],
2203
+ },
2204
+ "*",
2205
+ );
2206
+ });
2207
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2208
+ }
2209
+
2210
+ let problemInfo = [{}, {}];
2211
+ let problemOrder;
2212
+
2213
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2214
+
2215
+ cy.window().then(async (win) => {
2216
+ let stateVariables = await win.returnAllStateVariables1();
2217
+
2218
+ expect(
2219
+ stateVariables["/_document1"].stateValues.generatedVariantInfo.index,
2220
+ ).eq(attemptNumber);
2221
+
2222
+ if (stateVariables["/problem1/a"]) {
2223
+ problemOrder = [1, 2];
2224
+ } else {
2225
+ problemOrder = [2, 1];
2226
+ }
2227
+
2228
+ let creditAchieved = 0;
2229
+
2230
+ for (let ind = 0; ind < 2; ind++) {
2231
+ if (ind === 1) {
2232
+ cy.get(cesc2("#/pcontrols_next")).click();
2233
+ }
2234
+
2235
+ cy.wait(0).then((_) => {
2236
+ cy.get(cesc2("#/ca")).should("have.text", `${creditAchieved}`);
2237
+
2238
+ let thisProbInfo = problemInfo[ind];
2239
+ let thisProbName = `/problem${ind + 1}`;
2240
+
2241
+ if (problemOrder[ind] === 1) {
2242
+ cy.get(cesc2(`#${thisProbName}_title`)).should(
2243
+ "have.text",
2244
+ `Problem ${ind + 1}`,
2245
+ );
2246
+ cy.wait(10);
2247
+
2248
+ cy.window().then(async (win) => {
2249
+ let stateVariables = await win.returnAllStateVariables1();
2250
+
2251
+ thisProbInfo.a =
2252
+ stateVariables[`${thisProbName}/a`].stateValues.value;
2253
+ thisProbInfo.v =
2254
+ stateVariables[`${thisProbName}/v`].stateValues.value;
2255
+ thisProbInfo.o1m = me.fromAst(
2256
+ stateVariables[`${thisProbName}/o1/m`].stateValues.value,
2257
+ );
2258
+ thisProbInfo.o1t =
2259
+ stateVariables[`${thisProbName}/o1/t`].stateValues.value;
2260
+ thisProbInfo.o2m = me.fromAst(
2261
+ stateVariables[`${thisProbName}/o2/m`].stateValues.value,
2262
+ );
2263
+ thisProbInfo.o2t =
2264
+ stateVariables[`${thisProbName}/o2/t`].stateValues.value;
2265
+
2266
+ let mathinput1Name =
2267
+ stateVariables[`${thisProbName}/ans1`].stateValues
2268
+ .inputChildren[0].componentName;
2269
+ let mathinput1Anchor =
2270
+ cesc2("#" + mathinput1Name) + " textarea";
2271
+ let answer1Correct = cesc2("#" + mathinput1Name + "_correct");
2272
+
2273
+ let mathinput2Name =
2274
+ stateVariables[`${thisProbName}/ans2`].stateValues
2275
+ .inputChildren[0].componentName;
2276
+ let mathinput2Anchor =
2277
+ cesc2("#" + mathinput2Name) + " textarea";
2278
+ let answer2Correct = cesc2("#" + mathinput2Name + "_correct");
2279
+
2280
+ let textinput3Name =
2281
+ stateVariables[`${thisProbName}/ans3`].stateValues
2282
+ .inputChildren[0].componentName;
2283
+ let textinput3Anchor = cesc2("#" + textinput3Name) + "_input";
2284
+ let answer3Correct = cesc2("#" + textinput3Name + "_correct");
2285
+
2286
+ let mathinput4Name =
2287
+ stateVariables[`${thisProbName}/ans4`].stateValues
2288
+ .inputChildren[0].componentName;
2289
+ let mathinput4Anchor =
2290
+ cesc2("#" + mathinput4Name) + " textarea";
2291
+ let answer4Correct = cesc2("#" + mathinput4Name + "_correct");
2292
+
2293
+ let textinput5Name =
2294
+ stateVariables[`${thisProbName}/ans5`].stateValues
2295
+ .inputChildren[0].componentName;
2296
+ let textinput5Anchor = cesc2("#" + textinput5Name) + "_input";
2297
+ let answer5Correct = cesc2("#" + textinput5Name + "_correct");
2298
+
2299
+ cy.get(mathinput1Anchor).type(
2300
+ `${thisProbInfo.a}${thisProbInfo.v.toString()}{enter}`,
2301
+ { force: true },
2302
+ );
2303
+ cy.get(answer1Correct).should("be.visible");
2304
+
2305
+ cy.get(mathinput2Anchor).type(
2306
+ `${thisProbInfo.o1m.toString()}{enter}`,
2307
+ { force: true },
2308
+ );
2309
+ cy.get(answer2Correct).should("be.visible");
2310
+
2311
+ cy.get(textinput3Anchor).type(`${thisProbInfo.o1t}{enter}`);
2312
+ cy.get(answer3Correct).should("be.visible");
2313
+
2314
+ cy.get(mathinput4Anchor).type(
2315
+ `${thisProbInfo.o2m.toString()}{enter}`,
2316
+ { force: true },
2317
+ );
2318
+ cy.get(answer4Correct).should("be.visible");
2319
+
2320
+ cy.get(textinput5Anchor).type(`${thisProbInfo.o2t}{enter}`);
2321
+ cy.get(answer5Correct).should("be.visible");
2322
+ });
2323
+ } else {
2324
+ cy.get(cesc2(`#${thisProbName}_title`)).should(
2325
+ "have.text",
2326
+ `Animal sounds`,
2327
+ );
2328
+ cy.wait(10);
2329
+
2330
+ cy.window().then(async (win) => {
2331
+ let stateVariables = await win.returnAllStateVariables1();
2332
+
2333
+ thisProbInfo.animal =
2334
+ stateVariables[`${thisProbName}/animal`].stateValues.value;
2335
+ thisProbInfo.sound =
2336
+ stateVariables[`${thisProbName}/sound`].stateValues.value;
2337
+
2338
+ thisProbInfo.choices = [
2339
+ ...stateVariables[`${thisProbName}/_choiceinput1`].stateValues
2340
+ .choiceTexts,
2341
+ ];
2342
+ thisProbInfo.animalInd =
2343
+ thisProbInfo.choices.indexOf(thisProbInfo.sound) + 1;
2344
+ cy.get(
2345
+ cesc2(
2346
+ `#${thisProbName}/_choiceinput1_choice${thisProbInfo.animalInd}_input`,
2347
+ ),
2348
+ ).click();
2349
+
2350
+ cy.get(cesc2(`#${thisProbName}/_choiceinput1_submit`)).click();
2351
+ cy.get(cesc2(`#${thisProbName}/_choiceinput1_correct`)).should(
2352
+ "be.visible",
2353
+ );
2354
+ });
2355
+ }
2356
+
2357
+ creditAchieved += 0.5;
2358
+ });
2359
+ }
2360
+ });
2361
+
2362
+ cy.wait(2000); // wait for 1 second debounce
2363
+
2364
+ cy.window().then(async (win) => {
2365
+ win.postMessage(
2366
+ {
2367
+ doenetML: `
2368
+ <text>b</text>
2369
+ `,
2370
+ },
2371
+ "*",
2372
+ );
2373
+ });
2374
+ cy.get(cesc("#\\/_text1")).should("have.text", "b"); //wait for page to load
2375
+
2376
+ cy.window().then(async (win) => {
2377
+ win.postMessage(
2378
+ {
2379
+ doenetML: allDoenetMLs[attemptNumber - 1],
2380
+ },
2381
+ "*",
2382
+ );
2383
+ });
2384
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2385
+
2386
+ // wait until core is loaded
2387
+ cy.waitUntil(() =>
2388
+ cy.window().then(async (win) => {
2389
+ let stateVariables = await win.returnAllStateVariables1();
2390
+ let foundIt = Boolean(stateVariables["/_document1"]);
2391
+ return foundIt;
2392
+ }),
2393
+ );
2394
+
2395
+ for (let ind = 1; ind >= 0; ind--) {
2396
+ if (ind === 0) {
2397
+ cy.get(cesc2("#/pcontrols_previous")).click();
2398
+ }
2399
+
2400
+ cy.wait(0).then((_) => {
2401
+ cy.get(cesc2("#/ca")).should("have.text", `1`);
2402
+
2403
+ let thisProbInfo = problemInfo[ind];
2404
+ let thisProbName = `/problem${ind + 1}`;
2405
+
2406
+ if (problemOrder[ind] === 1) {
2407
+ cy.get(cesc2(`#${thisProbName}_title`)).should(
2408
+ "have.text",
2409
+ `Problem ${ind + 1}`,
2410
+ );
2411
+ cy.wait(10);
2412
+
2413
+ cy.window().then(async (win) => {
2414
+ let stateVariables = await win.returnAllStateVariables1();
2415
+
2416
+ expect(
2417
+ stateVariables[
2418
+ `${thisProbName}/a`
2419
+ ].stateValues.value.toString(),
2420
+ ).eq(thisProbInfo.a.toString());
2421
+ expect(
2422
+ stateVariables[
2423
+ `${thisProbName}/v`
2424
+ ].stateValues.value.toString(),
2425
+ ).eq(thisProbInfo.v.toString());
2426
+ expect(
2427
+ me
2428
+ .fromAst(
2429
+ stateVariables[`${thisProbName}/o1/m`].stateValues.value,
2430
+ )
2431
+ .toString(),
2432
+ ).eq(thisProbInfo.o1m.toString());
2433
+ expect(
2434
+ stateVariables[
2435
+ `${thisProbName}/o1/t`
2436
+ ].stateValues.value.toString(),
2437
+ ).eq(thisProbInfo.o1t.toString());
2438
+ expect(
2439
+ me
2440
+ .fromAst(
2441
+ stateVariables[`${thisProbName}/o2/m`].stateValues.value,
2442
+ )
2443
+ .toString(),
2444
+ ).eq(thisProbInfo.o2m.toString());
2445
+ expect(
2446
+ stateVariables[
2447
+ `${thisProbName}/o2/t`
2448
+ ].stateValues.value.toString(),
2449
+ ).eq(thisProbInfo.o2t.toString());
2450
+
2451
+ let mathinput1Name =
2452
+ stateVariables[`${thisProbName}/ans1`].stateValues
2453
+ .inputChildren[0].componentName;
2454
+ let answer1Correct = cesc2("#" + mathinput1Name + "_correct");
2455
+
2456
+ let mathinput2Name =
2457
+ stateVariables[`${thisProbName}/ans2`].stateValues
2458
+ .inputChildren[0].componentName;
2459
+ let answer2Correct = cesc2("#" + mathinput2Name + "_correct");
2460
+
2461
+ let textinput3Name =
2462
+ stateVariables[`${thisProbName}/ans3`].stateValues
2463
+ .inputChildren[0].componentName;
2464
+ let answer3Correct = cesc2("#" + textinput3Name + "_correct");
2465
+
2466
+ let mathinput4Name =
2467
+ stateVariables[`${thisProbName}/ans4`].stateValues
2468
+ .inputChildren[0].componentName;
2469
+ let answer4Correct = cesc2("#" + mathinput4Name + "_correct");
2470
+
2471
+ let textinput5Name =
2472
+ stateVariables[`${thisProbName}/ans5`].stateValues
2473
+ .inputChildren[0].componentName;
2474
+ let answer5Correct = cesc2("#" + textinput5Name + "_correct");
2475
+
2476
+ cy.get(answer1Correct).should("be.visible");
2477
+
2478
+ cy.get(answer2Correct).should("be.visible");
2479
+
2480
+ cy.get(answer3Correct).should("be.visible");
2481
+
2482
+ cy.get(answer4Correct).should("be.visible");
2483
+
2484
+ cy.get(answer5Correct).should("be.visible");
2485
+ });
2486
+ } else {
2487
+ cy.get(cesc2(`#${thisProbName}_title`)).should(
2488
+ "have.text",
2489
+ `Animal sounds`,
2490
+ );
2491
+ cy.get(cesc2(`#${thisProbName}/_choiceinput1_correct`)).should(
2492
+ "be.visible",
2493
+ );
2494
+
2495
+ cy.wait(10);
2496
+
2497
+ cy.window().then(async (win) => {
2498
+ let stateVariables = await win.returnAllStateVariables1();
2499
+
2500
+ expect(
2501
+ stateVariables[`${thisProbName}/animal`].stateValues.value,
2502
+ ).eq(thisProbInfo.animal);
2503
+ expect(
2504
+ stateVariables[`${thisProbName}/sound`].stateValues.value,
2505
+ ).eq(thisProbInfo.sound);
2506
+ expect(
2507
+ stateVariables[`${thisProbName}/_choiceinput1`].stateValues
2508
+ .choiceTexts,
2509
+ ).eqls(thisProbInfo.choices);
2510
+ expect(thisProbInfo.choices.indexOf(thisProbInfo.sound) + 1).eq(
2511
+ thisProbInfo.animalInd,
2512
+ );
2513
+ cy.get(cesc2(`#${thisProbName}/_choiceinput1_correct`)).should(
2514
+ "be.visible",
2515
+ );
2516
+ });
2517
+ }
2518
+ });
2519
+ }
2520
+
2521
+ cy.wait(2000); // wait for 1 second debounce
2522
+
2523
+ cy.window().then(async (win) => {
2524
+ win.postMessage(
2525
+ {
2526
+ doenetML: `
2527
+ <text>b</text>
2528
+ `,
2529
+ },
2530
+ "*",
2531
+ );
2532
+ });
2533
+ cy.get(cesc("#\\/_text1")).should("have.text", "b"); //wait for page to load
2534
+
2535
+ cy.window().then(async (win) => {
2536
+ win.postMessage(
2537
+ {
2538
+ doenetML: allDoenetMLs[attemptNumber - 1],
2539
+ },
2540
+ "*",
2541
+ );
2542
+ });
2543
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2544
+
2545
+ // wait until core is loaded
2546
+ cy.waitUntil(() =>
2547
+ cy.window().then(async (win) => {
2548
+ let stateVariables = await win.returnAllStateVariables1();
2549
+ let foundIt = Boolean(stateVariables["/_document1"]);
2550
+ return foundIt;
2551
+ }),
2552
+ );
2553
+
2554
+ for (let ind = 0; ind < 2; ind++) {
2555
+ if (ind === 1) {
2556
+ cy.get(cesc2("#/pcontrols_next")).click();
2557
+ }
2558
+
2559
+ cy.wait(0).then((_) => {
2560
+ cy.get(cesc2("#/ca")).should("have.text", `1`);
2561
+
2562
+ let thisProbInfo = problemInfo[ind];
2563
+ let thisProbName = `/problem${ind + 1}`;
2564
+
2565
+ if (problemOrder[ind] === 1) {
2566
+ cy.get(cesc2(`#${thisProbName}_title`)).should(
2567
+ "have.text",
2568
+ `Problem ${ind + 1}`,
2569
+ );
2570
+ cy.wait(10);
2571
+
2572
+ cy.window().then(async (win) => {
2573
+ let stateVariables = await win.returnAllStateVariables1();
2574
+
2575
+ expect(
2576
+ stateVariables[
2577
+ `${thisProbName}/a`
2578
+ ].stateValues.value.toString(),
2579
+ ).eq(thisProbInfo.a.toString());
2580
+ expect(
2581
+ stateVariables[
2582
+ `${thisProbName}/v`
2583
+ ].stateValues.value.toString(),
2584
+ ).eq(thisProbInfo.v.toString());
2585
+ expect(
2586
+ me
2587
+ .fromAst(
2588
+ stateVariables[`${thisProbName}/o1/m`].stateValues.value,
2589
+ )
2590
+ .toString(),
2591
+ ).eq(thisProbInfo.o1m.toString());
2592
+ expect(
2593
+ stateVariables[
2594
+ `${thisProbName}/o1/t`
2595
+ ].stateValues.value.toString(),
2596
+ ).eq(thisProbInfo.o1t.toString());
2597
+ expect(
2598
+ me
2599
+ .fromAst(
2600
+ stateVariables[`${thisProbName}/o2/m`].stateValues.value,
2601
+ )
2602
+ .toString(),
2603
+ ).eq(thisProbInfo.o2m.toString());
2604
+ expect(
2605
+ stateVariables[
2606
+ `${thisProbName}/o2/t`
2607
+ ].stateValues.value.toString(),
2608
+ ).eq(thisProbInfo.o2t.toString());
2609
+
2610
+ let mathinput1Name =
2611
+ stateVariables[`${thisProbName}/ans1`].stateValues
2612
+ .inputChildren[0].componentName;
2613
+ let answer1Correct = cesc2("#" + mathinput1Name + "_correct");
2614
+
2615
+ let mathinput2Name =
2616
+ stateVariables[`${thisProbName}/ans2`].stateValues
2617
+ .inputChildren[0].componentName;
2618
+ let answer2Correct = cesc2("#" + mathinput2Name + "_correct");
2619
+
2620
+ let textinput3Name =
2621
+ stateVariables[`${thisProbName}/ans3`].stateValues
2622
+ .inputChildren[0].componentName;
2623
+ let answer3Correct = cesc2("#" + textinput3Name + "_correct");
2624
+
2625
+ let mathinput4Name =
2626
+ stateVariables[`${thisProbName}/ans4`].stateValues
2627
+ .inputChildren[0].componentName;
2628
+ let answer4Correct = cesc2("#" + mathinput4Name + "_correct");
2629
+
2630
+ let textinput5Name =
2631
+ stateVariables[`${thisProbName}/ans5`].stateValues
2632
+ .inputChildren[0].componentName;
2633
+ let answer5Correct = cesc2("#" + textinput5Name + "_correct");
2634
+
2635
+ cy.get(answer1Correct).should("be.visible");
2636
+
2637
+ cy.get(answer2Correct).should("be.visible");
2638
+
2639
+ cy.get(answer3Correct).should("be.visible");
2640
+
2641
+ cy.get(answer4Correct).should("be.visible");
2642
+
2643
+ cy.get(answer5Correct).should("be.visible");
2644
+ });
2645
+ } else {
2646
+ cy.get(cesc2(`#${thisProbName}_title`)).should(
2647
+ "have.text",
2648
+ `Animal sounds`,
2649
+ );
2650
+ cy.get(cesc2(`#${thisProbName}/_choiceinput1_correct`)).should(
2651
+ "be.visible",
2652
+ );
2653
+
2654
+ cy.wait(10);
2655
+
2656
+ cy.window().then(async (win) => {
2657
+ let stateVariables = await win.returnAllStateVariables1();
2658
+
2659
+ expect(
2660
+ stateVariables[`${thisProbName}/animal`].stateValues.value,
2661
+ ).eq(thisProbInfo.animal);
2662
+ expect(
2663
+ stateVariables[`${thisProbName}/sound`].stateValues.value,
2664
+ ).eq(thisProbInfo.sound);
2665
+ expect(
2666
+ stateVariables[`${thisProbName}/_choiceinput1`].stateValues
2667
+ .choiceTexts,
2668
+ ).eqls(thisProbInfo.choices);
2669
+ expect(thisProbInfo.choices.indexOf(thisProbInfo.sound) + 1).eq(
2670
+ thisProbInfo.animalInd,
2671
+ );
2672
+ cy.get(cesc2(`#${thisProbName}/_choiceinput1_correct`)).should(
2673
+ "be.visible",
2674
+ );
2675
+ });
2676
+ }
2677
+ });
2678
+ }
2679
+ }
2680
+ });
2681
+
2682
+ it("Conditional content data is saved", () => {
2683
+ let doenetML = `
2684
+ <text>a</text>
2685
+ <paginatorControls paginator="pgn" name="pcontrols" />
2686
+
2687
+ <paginator name="pgn">
2688
+
2689
+ <problem name="problem1" newNamespace>
2690
+
2691
+ <setup>
2692
+ <selectFromSequence from="1" to="2" assignNames="n" />
2693
+ </setup>
2694
+
2695
+ <conditionalContent>
2696
+ <case condition="$n=1">
2697
+ <p>Answer x: <answer>x</answer></p>
2698
+ </case>
2699
+ <case condition="$n=2">
2700
+ <p>Answer y: <answer>y</answer></p>
2701
+ </case>
2702
+ </conditionalContent>
2703
+
2704
+ <conditionalContent condition="$n=1" >
2705
+ <p>Answer 2x: <answer name="a1">2x</answer></p>
2706
+ </conditionalContent>
2707
+ <conditionalContent condition="$n=2" >
2708
+ <p>Answer 2y: <answer name="a2">2y</answer></p>
2709
+ </conditionalContent>
2710
+ </problem>
2711
+
2712
+ <problem name="problem2" newNamespace>
2713
+
2714
+ <setup>
2715
+ <number name="n">1</number>
2716
+ </setup>
2717
+
2718
+ <conditionalContent>
2719
+ <case condition="$n=1">
2720
+ <p>Answer 1: <answer>1</answer></p>
2721
+ </case>
2722
+ <else>
2723
+ <p>Answer 1b: <answer>1b</answer></p>
2724
+ </else>
2725
+ </conditionalContent>
2726
+
2727
+ <conditionalContent condition="$n=1" >
2728
+ <p>Answer 2: <answer>2</answer></p>
2729
+ </conditionalContent>
2730
+
2731
+ </problem>
2732
+ </paginator>
2733
+
2734
+ <p>Credit achieved: <copy prop="creditAchieved" target="_document1" assignNames="ca" /></p>
2735
+
2736
+ `;
2737
+
2738
+ cy.get("#testRunner_toggleControls").click();
2739
+ cy.get("#testRunner_allowLocalState").click();
2740
+ cy.wait(100);
2741
+ cy.get("#testRunner_toggleControls").click();
2742
+
2743
+ cy.window().then(async (win) => {
2744
+ win.postMessage(
2745
+ {
2746
+ doenetML,
2747
+ },
2748
+ "*",
2749
+ );
2750
+ });
2751
+
2752
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2753
+
2754
+ cy.get(cesc("#\\/problem1_title")).should("have.text", "Problem 1");
2755
+ cy.get(cesc("#\\/ca")).should("have.text", "0");
2756
+
2757
+ cy.window().then(async (win) => {
2758
+ let stateVariables = await win.returnAllStateVariables1();
2759
+ let n = stateVariables["/problem1/n"].stateValues.value;
2760
+
2761
+ let mathinput1Name =
2762
+ stateVariables[`/problem1/_answer${n}`].stateValues.inputChildren[0]
2763
+ .componentName;
2764
+ let mathinput1Anchor = cesc2("#" + mathinput1Name) + " textarea";
2765
+ let mathinput1DisplayAnchor =
2766
+ cesc2("#" + mathinput1Name) + " .mq-editable-field";
2767
+ let answer1Correct = cesc2("#" + mathinput1Name + "_correct");
2768
+ let answer1Submit = cesc2("#" + mathinput1Name + "_submit");
2769
+
2770
+ let mathinput2Name =
2771
+ stateVariables[`/problem1/a${n}`].stateValues.inputChildren[0]
2772
+ .componentName;
2773
+ let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea";
2774
+ let mathinput2DisplayAnchor =
2775
+ cesc2("#" + mathinput2Name) + " .mq-editable-field";
2776
+ let answer2Correct = cesc2("#" + mathinput2Name + "_correct");
2777
+ let answer2Submit = cesc2("#" + mathinput2Name + "_submit");
2778
+
2779
+ let correctAnswer = n === 1 ? "x" : "y";
2780
+
2781
+ cy.get(mathinput1Anchor).type(`${correctAnswer}`, { force: true });
2782
+ cy.get(mathinput1DisplayAnchor)
2783
+ .invoke("text")
2784
+ .then((text) => {
2785
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
2786
+ correctAnswer,
2787
+ );
2788
+ });
2789
+ cy.get(answer1Submit).click();
2790
+
2791
+ cy.get(cesc("#\\/ca")).should("have.text", "0.25");
2792
+
2793
+ cy.get(mathinput2Anchor).type(`2${correctAnswer}`, { force: true });
2794
+ cy.get(mathinput2DisplayAnchor)
2795
+ .invoke("text")
2796
+ .then((text) => {
2797
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
2798
+ `2${correctAnswer}`,
2799
+ );
2800
+ });
2801
+ cy.get(answer2Submit).click();
2802
+
2803
+ cy.get(cesc("#\\/ca")).should("have.text", "0.5");
2804
+
2805
+ cy.get(cesc2("#/pcontrols_next")).click();
2806
+ cy.get(cesc("#\\/problem2_title")).should("have.text", "Problem 2");
2807
+ cy.get(cesc("#\\/ca")).should("have.text", "0.5");
2808
+
2809
+ cy.get(cesc2("#/pcontrols_previous")).click();
2810
+ cy.get(cesc("#\\/problem1_title")).should("have.text", "Problem 1");
2811
+ cy.get(cesc("#\\/ca")).should("have.text", "0.5");
2812
+
2813
+ cy.get(mathinput1DisplayAnchor)
2814
+ .invoke("text")
2815
+ .then((text) => {
2816
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
2817
+ correctAnswer,
2818
+ );
2819
+ });
2820
+ cy.get(answer1Correct).should("be.visible");
2821
+
2822
+ cy.get(mathinput2DisplayAnchor)
2823
+ .invoke("text")
2824
+ .then((text) => {
2825
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
2826
+ `2${correctAnswer}`,
2827
+ );
2828
+ });
2829
+ cy.get(answer2Correct).should("be.visible");
2830
+
2831
+ cy.get(cesc2("#/pcontrols_next")).click();
2832
+ cy.get(cesc("#\\/problem2_title")).should("have.text", "Problem 2");
2833
+ cy.get(cesc("#\\/ca")).should("have.text", "0.5");
2834
+
2835
+ cy.window().then(async (win) => {
2836
+ let stateVariables = await win.returnAllStateVariables1();
2837
+
2838
+ let mathinput3Name =
2839
+ stateVariables[`/problem2/_answer1`].stateValues.inputChildren[0]
2840
+ .componentName;
2841
+ let mathinput3Anchor = cesc2("#" + mathinput3Name) + " textarea";
2842
+ let mathinput3DisplayAnchor =
2843
+ cesc2("#" + mathinput3Name) + " .mq-editable-field";
2844
+ let answer3Correct = cesc2("#" + mathinput3Name + "_correct");
2845
+
2846
+ let mathinput4Name =
2847
+ stateVariables[`/problem2/_answer3`].stateValues.inputChildren[0]
2848
+ .componentName;
2849
+ let mathinput4Anchor = cesc2("#" + mathinput4Name) + " textarea";
2850
+ let mathinput4DisplayAnchor =
2851
+ cesc2("#" + mathinput4Name) + " .mq-editable-field";
2852
+ let answer4Correct = cesc2("#" + mathinput4Name + "_correct");
2853
+
2854
+ cy.get(mathinput3Anchor).type(`1{enter}`, { force: true });
2855
+ cy.get(mathinput3DisplayAnchor)
2856
+ .invoke("text")
2857
+ .then((text) => {
2858
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
2859
+ });
2860
+ cy.get(answer3Correct).should("be.visible");
2861
+
2862
+ cy.get(cesc("#\\/ca")).should("have.text", "0.75");
2863
+
2864
+ cy.get(mathinput4Anchor).type(`2{enter}`, { force: true });
2865
+ cy.get(mathinput4DisplayAnchor)
2866
+ .invoke("text")
2867
+ .then((text) => {
2868
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
2869
+ });
2870
+ cy.get(answer4Correct).should("be.visible");
2871
+
2872
+ cy.get(cesc("#\\/ca")).should("have.text", "1");
2873
+
2874
+ cy.get(cesc2("#/pcontrols_previous")).click();
2875
+ cy.get(cesc("#\\/problem1_title")).should("have.text", "Problem 1");
2876
+ cy.get(cesc("#\\/ca")).should("have.text", "1");
2877
+
2878
+ cy.get(mathinput1DisplayAnchor)
2879
+ .invoke("text")
2880
+ .then((text) => {
2881
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
2882
+ correctAnswer,
2883
+ );
2884
+ });
2885
+ cy.get(answer1Correct).should("be.visible");
2886
+
2887
+ cy.get(mathinput2DisplayAnchor)
2888
+ .invoke("text")
2889
+ .then((text) => {
2890
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
2891
+ `2${correctAnswer}`,
2892
+ );
2893
+ });
2894
+ cy.get(answer2Correct).should("be.visible");
2895
+
2896
+ cy.get(cesc2("#/pcontrols_next")).click();
2897
+ cy.get(cesc("#\\/problem2_title")).should("have.text", "Problem 2");
2898
+ cy.get(cesc("#\\/ca")).should("have.text", "1");
2899
+
2900
+ cy.get(mathinput3DisplayAnchor)
2901
+ .invoke("text")
2902
+ .then((text) => {
2903
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
2904
+ });
2905
+ cy.get(answer3Correct).should("be.visible");
2906
+
2907
+ cy.get(mathinput4DisplayAnchor)
2908
+ .invoke("text")
2909
+ .then((text) => {
2910
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
2911
+ });
2912
+ cy.get(answer4Correct).should("be.visible");
2913
+
2914
+ cy.get(cesc("#\\/ca")).should("have.text", "1");
2915
+
2916
+ cy.wait(2000); // wait for 1 second debounce
2917
+
2918
+ cy.window().then(async (win) => {
2919
+ win.postMessage(
2920
+ {
2921
+ doenetML: "<text>b</text>",
2922
+ },
2923
+ "*",
2924
+ );
2925
+ });
2926
+
2927
+ cy.get(cesc("#\\/_text1")).should("have.text", "b"); //wait for page to load
2928
+
2929
+ cy.window().then(async (win) => {
2930
+ win.postMessage(
2931
+ {
2932
+ doenetML,
2933
+ },
2934
+ "*",
2935
+ );
2936
+ });
2937
+
2938
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2939
+
2940
+ cy.get(cesc("#\\/problem2_title")).should("have.text", "Problem 2");
2941
+ cy.get(cesc("#\\/ca")).should("have.text", "1");
2942
+
2943
+ cy.get(mathinput3DisplayAnchor)
2944
+ .invoke("text")
2945
+ .then((text) => {
2946
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("1");
2947
+ });
2948
+ cy.get(answer3Correct).should("be.visible");
2949
+
2950
+ cy.get(mathinput4DisplayAnchor)
2951
+ .invoke("text")
2952
+ .then((text) => {
2953
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal("2");
2954
+ });
2955
+ cy.get(answer4Correct).should("be.visible");
2956
+
2957
+ cy.get(cesc("#\\/ca")).should("have.text", "1");
2958
+
2959
+ cy.get(cesc2("#/pcontrols_previous")).click();
2960
+ cy.get(cesc("#\\/problem1_title")).should("have.text", "Problem 1");
2961
+ cy.get(cesc("#\\/ca")).should("have.text", "1");
2962
+
2963
+ cy.get(mathinput1DisplayAnchor)
2964
+ .invoke("text")
2965
+ .then((text) => {
2966
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
2967
+ correctAnswer,
2968
+ );
2969
+ });
2970
+ cy.get(answer1Correct).should("be.visible");
2971
+
2972
+ cy.get(mathinput2DisplayAnchor)
2973
+ .invoke("text")
2974
+ .then((text) => {
2975
+ expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal(
2976
+ `2${correctAnswer}`,
2977
+ );
2978
+ });
2979
+ cy.get(answer2Correct).should("be.visible");
2980
+ });
2981
+ });
2982
+ });
2983
+ });