@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,2768 @@
1
+ import { cesc, cesc2 } from "../../../../src/utils/url";
2
+
3
+ describe("Problem Tag Tests", function () {
4
+ beforeEach(() => {
5
+ cy.clearIndexedDB();
6
+ cy.visit("/src/Tools/cypressTest/");
7
+ });
8
+
9
+ it("problems default to weight 1", () => {
10
+ cy.window().then(async (win) => {
11
+ win.postMessage(
12
+ {
13
+ doenetML: `
14
+ <title>Activity</title>
15
+ <p>Credit achieved for <copy prop="title" target="_document1" />:
16
+ <copy name="docCa" prop="creditAchieved" target="_document1" />, or <copy name="docPca" prop="percentCreditAchieved" target="_document1" />%</p>
17
+
18
+ <p>Enter <m>u</m>: <answer>u</answer></p>
19
+
20
+ <problem name="problem1"><title>Problem 1</title>
21
+ <p>Credit achieved for <copy prop="title" target="problem1" />:
22
+ <copy name="p1Ca" prop="creditAchieved" target="problem1" />, or <copy name="p1Pca" prop="percentCreditAchieved" target="problem1" />%</p>
23
+
24
+ <p>Enter <m>x</m>: <answer>x</answer></p>
25
+ <p>Enter <m>y</m>: <answer weight="2">y</answer></p>
26
+
27
+
28
+ </problem>
29
+ <problem name="problem2"><title>Problem 2</title>
30
+ <p>Credit achieved for <copy prop="title" target="problem2" />:
31
+ <copy name="p2Ca" prop="creditAchieved" target="problem2" />, or <copy name="p2Pca" prop="percentCreditAchieved" target="problem2" />%</p>
32
+
33
+ <p>Enter <m>z</m>: <answer>z</answer></p>
34
+
35
+ <problem name="problem21"><title>Problem 2.1</title>
36
+ <p>Credit achieved for <copy prop="title" target="problem21" />:
37
+ <copy name="p21Ca" prop="creditAchieved" target="problem21" />, or <copy name="p21Pca" prop="percentCreditAchieved" target="problem21" />%</p>
38
+
39
+ <p>Enter <m>v</m>: <answer weight="0.5">v</answer></p>
40
+ <p>Enter <m>w</m>: <answer>w</answer></p>
41
+
42
+ </problem>
43
+ <problem name="problem22"><title>Problem 2.2</title>
44
+ <p>Credit achieved for <copy prop="title" target="problem22" />:
45
+ <copy name="p22Ca" prop="creditAchieved" target="problem22" />, or <copy name="p22Pca" prop="percentCreditAchieved" target="problem22" />%</p>
46
+
47
+ <p>Enter <m>q</m>: <answer>q</answer></p>
48
+
49
+ <problem name="problem221"><title>Problem 2.2.1</title>
50
+ <p>Credit achieved for <copy prop="title" target="problem221" />:
51
+ <copy name="p221Ca" prop="creditAchieved" target="problem221" />, or <copy name="p221Pca" prop="percentCreditAchieved" target="problem221" />%</p>
52
+
53
+ <p>Enter <m>r</m>: <answer>r</answer></p>
54
+
55
+ </problem>
56
+ <problem name="problem222"><title>Problem 2.2.2</title>
57
+ <p>Credit achieved for <copy prop="title" target="problem222" />:
58
+ <copy name="p222Ca" prop="creditAchieved" target="problem222" />, or <copy name="p222Pca" prop="percentCreditAchieved" target="problem222" />%</p>
59
+
60
+ <p>Enter <m>s</m>: <answer weight="3">s</answer></p>
61
+
62
+ </problem>
63
+ </problem>
64
+
65
+ </problem>
66
+ `,
67
+ },
68
+ "*",
69
+ );
70
+ });
71
+
72
+ // to wait for page to load
73
+ cy.get(cesc("#\\/_document1_title")).should("have.text", "Activity");
74
+
75
+ cy.window().then(async (win) => {
76
+ let stateVariables = await win.returnAllStateVariables1();
77
+
78
+ let docCaAnchor = cesc2(
79
+ "#" + stateVariables["/docCa"].replacements[0].componentName,
80
+ );
81
+ let docPcaAnchor = cesc2(
82
+ "#" + stateVariables["/docPca"].replacements[0].componentName,
83
+ );
84
+ let p1CaAnchor = cesc2(
85
+ "#" + stateVariables["/p1Ca"].replacements[0].componentName,
86
+ );
87
+ let p1PcaAnchor = cesc2(
88
+ "#" + stateVariables["/p1Pca"].replacements[0].componentName,
89
+ );
90
+ let p2CaAnchor = cesc2(
91
+ "#" + stateVariables["/p2Ca"].replacements[0].componentName,
92
+ );
93
+ let p2PcaAnchor = cesc2(
94
+ "#" + stateVariables["/p2Pca"].replacements[0].componentName,
95
+ );
96
+ let p21CaAnchor = cesc2(
97
+ "#" + stateVariables["/p21Ca"].replacements[0].componentName,
98
+ );
99
+ let p21PcaAnchor = cesc2(
100
+ "#" + stateVariables["/p21Pca"].replacements[0].componentName,
101
+ );
102
+ let p22CaAnchor = cesc2(
103
+ "#" + stateVariables["/p22Ca"].replacements[0].componentName,
104
+ );
105
+ let p22PcaAnchor = cesc2(
106
+ "#" + stateVariables["/p22Pca"].replacements[0].componentName,
107
+ );
108
+ let p221CaAnchor = cesc2(
109
+ "#" + stateVariables["/p221Ca"].replacements[0].componentName,
110
+ );
111
+ let p221PcaAnchor = cesc2(
112
+ "#" + stateVariables["/p221Pca"].replacements[0].componentName,
113
+ );
114
+ let p222CaAnchor = cesc2(
115
+ "#" + stateVariables["/p222Ca"].replacements[0].componentName,
116
+ );
117
+ let p222PcaAnchor = cesc2(
118
+ "#" + stateVariables["/p222Pca"].replacements[0].componentName,
119
+ );
120
+ let mathinput1Anchor =
121
+ cesc2(
122
+ "#" +
123
+ stateVariables["/_answer1"].stateValues.inputChildren[0]
124
+ .componentName,
125
+ ) + " textarea";
126
+ let mathinput2Anchor =
127
+ cesc2(
128
+ "#" +
129
+ stateVariables["/_answer2"].stateValues.inputChildren[0]
130
+ .componentName,
131
+ ) + " textarea";
132
+ let mathinput3Anchor =
133
+ cesc2(
134
+ "#" +
135
+ stateVariables["/_answer3"].stateValues.inputChildren[0]
136
+ .componentName,
137
+ ) + " textarea";
138
+ let mathinput4Anchor =
139
+ cesc2(
140
+ "#" +
141
+ stateVariables["/_answer4"].stateValues.inputChildren[0]
142
+ .componentName,
143
+ ) + " textarea";
144
+ let mathinput5Anchor =
145
+ cesc2(
146
+ "#" +
147
+ stateVariables["/_answer5"].stateValues.inputChildren[0]
148
+ .componentName,
149
+ ) + " textarea";
150
+ let mathinput6Anchor =
151
+ cesc2(
152
+ "#" +
153
+ stateVariables["/_answer6"].stateValues.inputChildren[0]
154
+ .componentName,
155
+ ) + " textarea";
156
+ let mathinput7Anchor =
157
+ cesc2(
158
+ "#" +
159
+ stateVariables["/_answer7"].stateValues.inputChildren[0]
160
+ .componentName,
161
+ ) + " textarea";
162
+ let mathinput8Anchor =
163
+ cesc2(
164
+ "#" +
165
+ stateVariables["/_answer8"].stateValues.inputChildren[0]
166
+ .componentName,
167
+ ) + " textarea";
168
+ let mathinput9Anchor =
169
+ cesc2(
170
+ "#" +
171
+ stateVariables["/_answer9"].stateValues.inputChildren[0]
172
+ .componentName,
173
+ ) + " textarea";
174
+
175
+ cy.get(docCaAnchor).should("have.text", "0");
176
+ cy.get(docPcaAnchor).should("have.text", "0");
177
+ cy.get(p1CaAnchor).should("have.text", "0");
178
+ cy.get(p1PcaAnchor).should("have.text", "0");
179
+ cy.get(p2CaAnchor).should("have.text", "0");
180
+ cy.get(p2PcaAnchor).should("have.text", "0");
181
+ cy.get(p21CaAnchor).should("have.text", "0");
182
+ cy.get(p21PcaAnchor).should("have.text", "0");
183
+ cy.get(p22CaAnchor).should("have.text", "0");
184
+ cy.get(p22PcaAnchor).should("have.text", "0");
185
+ cy.get(p221CaAnchor).should("have.text", "0");
186
+ cy.get(p221PcaAnchor).should("have.text", "0");
187
+ cy.get(p222CaAnchor).should("have.text", "0");
188
+ cy.get(p222PcaAnchor).should("have.text", "0");
189
+
190
+ cy.window().then(async (win) => {
191
+ let stateVariables = await win.returnAllStateVariables1();
192
+ expect(stateVariables["/_document1"].stateValues.creditAchieved).eq(0);
193
+ expect(
194
+ stateVariables["/_document1"].stateValues.percentCreditAchieved,
195
+ ).eq(0);
196
+ expect(stateVariables["/problem1"].stateValues.creditAchieved).eq(0);
197
+ expect(
198
+ stateVariables["/problem1"].stateValues.percentCreditAchieved,
199
+ ).eq(0);
200
+ expect(stateVariables["/problem2"].stateValues.creditAchieved).eq(0);
201
+ expect(
202
+ stateVariables["/problem2"].stateValues.percentCreditAchieved,
203
+ ).eq(0);
204
+ expect(stateVariables["/problem21"].stateValues.creditAchieved).eq(0);
205
+ expect(
206
+ stateVariables["/problem21"].stateValues.percentCreditAchieved,
207
+ ).eq(0);
208
+ expect(stateVariables["/problem22"].stateValues.creditAchieved).eq(0);
209
+ expect(
210
+ stateVariables["/problem22"].stateValues.percentCreditAchieved,
211
+ ).eq(0);
212
+ expect(stateVariables["/problem221"].stateValues.creditAchieved).eq(0);
213
+ expect(
214
+ stateVariables["/problem221"].stateValues.percentCreditAchieved,
215
+ ).eq(0);
216
+ expect(stateVariables["/problem222"].stateValues.creditAchieved).eq(0);
217
+ expect(
218
+ stateVariables["/problem222"].stateValues.percentCreditAchieved,
219
+ ).eq(0);
220
+ expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(0);
221
+ expect(stateVariables["/_answer2"].stateValues.creditAchieved).eq(0);
222
+ expect(stateVariables["/_answer3"].stateValues.creditAchieved).eq(0);
223
+ expect(stateVariables["/_answer4"].stateValues.creditAchieved).eq(0);
224
+ expect(stateVariables["/_answer5"].stateValues.creditAchieved).eq(0);
225
+ expect(stateVariables["/_answer6"].stateValues.creditAchieved).eq(0);
226
+ expect(stateVariables["/_answer7"].stateValues.creditAchieved).eq(0);
227
+ expect(stateVariables["/_answer8"].stateValues.creditAchieved).eq(0);
228
+ expect(stateVariables["/_answer9"].stateValues.creditAchieved).eq(0);
229
+ });
230
+
231
+ cy.log("enter first correct answer");
232
+ cy.get(mathinput1Anchor).type(`u{enter}`, { force: true });
233
+
234
+ let credit1 = 1 / 3;
235
+ let credit1Round = Math.round(1000 * credit1) / 1000;
236
+ let percentCredit1 = credit1 * 100;
237
+ let percentCredit1Round = Math.round(10 * percentCredit1) / 10;
238
+
239
+ cy.get(docCaAnchor).should("have.text", credit1Round.toString());
240
+ cy.get(docPcaAnchor).should("have.text", percentCredit1Round.toString());
241
+ cy.get(p1CaAnchor).should("have.text", "0");
242
+ cy.get(p1PcaAnchor).should("have.text", "0");
243
+ cy.get(p2CaAnchor).should("have.text", "0");
244
+ cy.get(p2PcaAnchor).should("have.text", "0");
245
+ cy.get(p21CaAnchor).should("have.text", "0");
246
+ cy.get(p21PcaAnchor).should("have.text", "0");
247
+ cy.get(p22CaAnchor).should("have.text", "0");
248
+ cy.get(p22PcaAnchor).should("have.text", "0");
249
+ cy.get(p221CaAnchor).should("have.text", "0");
250
+ cy.get(p221PcaAnchor).should("have.text", "0");
251
+ cy.get(p222CaAnchor).should("have.text", "0");
252
+ cy.get(p222PcaAnchor).should("have.text", "0");
253
+
254
+ cy.window().then(async (win) => {
255
+ let stateVariables = await win.returnAllStateVariables1();
256
+ expect(
257
+ stateVariables["/_document1"].stateValues.creditAchieved,
258
+ ).closeTo(credit1, 1e-12);
259
+ expect(
260
+ stateVariables["/_document1"].stateValues.percentCreditAchieved,
261
+ ).closeTo(percentCredit1, 1e-12);
262
+ expect(stateVariables["/problem1"].stateValues.creditAchieved).eq(0);
263
+ expect(
264
+ stateVariables["/problem1"].stateValues.percentCreditAchieved,
265
+ ).eq(0);
266
+ expect(stateVariables["/problem2"].stateValues.creditAchieved).eq(0);
267
+ expect(
268
+ stateVariables["/problem2"].stateValues.percentCreditAchieved,
269
+ ).eq(0);
270
+ expect(stateVariables["/problem21"].stateValues.creditAchieved).eq(0);
271
+ expect(
272
+ stateVariables["/problem21"].stateValues.percentCreditAchieved,
273
+ ).eq(0);
274
+ expect(stateVariables["/problem22"].stateValues.creditAchieved).eq(0);
275
+ expect(
276
+ stateVariables["/problem22"].stateValues.percentCreditAchieved,
277
+ ).eq(0);
278
+ expect(stateVariables["/problem221"].stateValues.creditAchieved).eq(0);
279
+ expect(
280
+ stateVariables["/problem221"].stateValues.percentCreditAchieved,
281
+ ).eq(0);
282
+ expect(stateVariables["/problem222"].stateValues.creditAchieved).eq(0);
283
+ expect(
284
+ stateVariables["/problem222"].stateValues.percentCreditAchieved,
285
+ ).eq(0);
286
+ expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(1);
287
+ expect(stateVariables["/_answer2"].stateValues.creditAchieved).eq(0);
288
+ expect(stateVariables["/_answer3"].stateValues.creditAchieved).eq(0);
289
+ expect(stateVariables["/_answer4"].stateValues.creditAchieved).eq(0);
290
+ expect(stateVariables["/_answer5"].stateValues.creditAchieved).eq(0);
291
+ expect(stateVariables["/_answer6"].stateValues.creditAchieved).eq(0);
292
+ expect(stateVariables["/_answer7"].stateValues.creditAchieved).eq(0);
293
+ expect(stateVariables["/_answer8"].stateValues.creditAchieved).eq(0);
294
+ expect(stateVariables["/_answer9"].stateValues.creditAchieved).eq(0);
295
+ });
296
+
297
+ cy.log("enter additional correct answers");
298
+ cy.get(mathinput3Anchor).type(`y{enter}`, { force: true });
299
+ cy.get(mathinput5Anchor).type(`v{enter}`, { force: true });
300
+ cy.get(mathinput7Anchor).type(`q{enter}`, { force: true });
301
+
302
+ let problem1credit2 = 2 / 3;
303
+ let problem1credit2Round = Math.round(1000 * problem1credit2) / 1000;
304
+ let problem1percentCredit2 = problem1credit2 * 100;
305
+ let problem1percentCredit2Round =
306
+ Math.round(10 * problem1percentCredit2) / 10;
307
+
308
+ let problem21credit2 = 1 / 3;
309
+ let problem21credit2Round = Math.round(1000 * problem21credit2) / 1000;
310
+ let problem21percentCredit2 = problem21credit2 * 100;
311
+ let problem21percentCredit2Round =
312
+ Math.round(10 * problem21percentCredit2) / 10;
313
+
314
+ let problem22credit2 = 1 / 3;
315
+ let problem22credit2Round = Math.round(1000 * problem22credit2) / 1000;
316
+ let problem22percentCredit2 = problem22credit2 * 100;
317
+ let problem22percentCredit2Round =
318
+ Math.round(10 * problem22percentCredit2) / 10;
319
+
320
+ let problem2credit2 = (problem21credit2 + problem22credit2) / 3;
321
+ let problem2credit2Round = Math.round(1000 * problem2credit2) / 1000;
322
+ let problem2percentCredit2 = problem2credit2 * 100;
323
+ let problem2percentCredit2Round =
324
+ Math.round(10 * problem2percentCredit2) / 10;
325
+
326
+ let credit2 = (1 + problem1credit2 + problem2credit2) / 3;
327
+ let credit2Round = Math.round(1000 * credit2) / 1000;
328
+ let percentCredit2 = credit2 * 100;
329
+ let percentCredit2Round = Math.round(10 * percentCredit2) / 10;
330
+
331
+ cy.get(docCaAnchor).should("have.text", credit2Round.toString());
332
+ cy.get(docPcaAnchor).should("have.text", percentCredit2Round.toString());
333
+ cy.get(p1CaAnchor).should("have.text", problem1credit2Round.toString());
334
+ cy.get(p1PcaAnchor).should(
335
+ "have.text",
336
+ problem1percentCredit2Round.toString(),
337
+ );
338
+ cy.get(p2CaAnchor).should("have.text", problem2credit2Round.toString());
339
+ cy.get(p2PcaAnchor).should(
340
+ "have.text",
341
+ problem2percentCredit2Round.toString(),
342
+ );
343
+ cy.get(p21CaAnchor).should("have.text", problem21credit2Round.toString());
344
+ cy.get(p21PcaAnchor).should(
345
+ "have.text",
346
+ problem21percentCredit2Round.toString(),
347
+ );
348
+ cy.get(p22CaAnchor).should("have.text", problem22credit2Round.toString());
349
+ cy.get(p22PcaAnchor).should(
350
+ "have.text",
351
+ problem22percentCredit2Round.toString(),
352
+ );
353
+ cy.get(p221CaAnchor).should("have.text", "0");
354
+ cy.get(p221PcaAnchor).should("have.text", "0");
355
+ cy.get(p222CaAnchor).should("have.text", "0");
356
+ cy.get(p222PcaAnchor).should("have.text", "0");
357
+
358
+ cy.window().then(async (win) => {
359
+ let stateVariables = await win.returnAllStateVariables1();
360
+ expect(
361
+ stateVariables["/_document1"].stateValues.creditAchieved,
362
+ ).closeTo(credit2, 1e-12);
363
+ expect(
364
+ stateVariables["/_document1"].stateValues.percentCreditAchieved,
365
+ ).closeTo(percentCredit2, 1e-12);
366
+ expect(stateVariables["/problem1"].stateValues.creditAchieved).closeTo(
367
+ problem1credit2,
368
+ 1e-12,
369
+ );
370
+ expect(
371
+ stateVariables["/problem1"].stateValues.percentCreditAchieved,
372
+ ).closeTo(problem1percentCredit2, 1e-12);
373
+ expect(stateVariables["/problem2"].stateValues.creditAchieved).closeTo(
374
+ problem2credit2,
375
+ 1e-12,
376
+ );
377
+ expect(
378
+ stateVariables["/problem2"].stateValues.percentCreditAchieved,
379
+ ).closeTo(problem2percentCredit2, 1e-12);
380
+ expect(stateVariables["/problem21"].stateValues.creditAchieved).closeTo(
381
+ problem21credit2,
382
+ 1e-12,
383
+ );
384
+ expect(
385
+ stateVariables["/problem21"].stateValues.percentCreditAchieved,
386
+ ).closeTo(problem21percentCredit2, 1e-12);
387
+ expect(stateVariables["/problem22"].stateValues.creditAchieved).closeTo(
388
+ problem22credit2,
389
+ 1e-12,
390
+ );
391
+ expect(
392
+ stateVariables["/problem22"].stateValues.percentCreditAchieved,
393
+ ).closeTo(problem22percentCredit2, 1e-12);
394
+ expect(stateVariables["/problem221"].stateValues.creditAchieved).eq(0);
395
+ expect(
396
+ stateVariables["/problem221"].stateValues.percentCreditAchieved,
397
+ ).eq(0);
398
+ expect(stateVariables["/problem222"].stateValues.creditAchieved).eq(0);
399
+ expect(
400
+ stateVariables["/problem222"].stateValues.percentCreditAchieved,
401
+ ).eq(0);
402
+ expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(1);
403
+ expect(stateVariables["/_answer2"].stateValues.creditAchieved).eq(0);
404
+ expect(stateVariables["/_answer3"].stateValues.creditAchieved).eq(1);
405
+ expect(stateVariables["/_answer4"].stateValues.creditAchieved).eq(0);
406
+ expect(stateVariables["/_answer5"].stateValues.creditAchieved).eq(1);
407
+ expect(stateVariables["/_answer6"].stateValues.creditAchieved).eq(0);
408
+ expect(stateVariables["/_answer7"].stateValues.creditAchieved).eq(1);
409
+ expect(stateVariables["/_answer8"].stateValues.creditAchieved).eq(0);
410
+ expect(stateVariables["/_answer9"].stateValues.creditAchieved).eq(0);
411
+ });
412
+
413
+ cy.log("enter most other correct answers");
414
+ cy.get(mathinput2Anchor).type(`x{enter}`, { force: true });
415
+ cy.get(mathinput4Anchor).type(`z{enter}`, { force: true });
416
+ cy.get(mathinput6Anchor).type(`w{enter}`, { force: true });
417
+ cy.get(mathinput8Anchor).type(`r{enter}`, { force: true });
418
+
419
+ let problem1credit3 = 1;
420
+ let problem1credit3Round = Math.round(1000 * problem1credit3) / 1000;
421
+ let problem1percentCredit3 = problem1credit3 * 100;
422
+ let problem1percentCredit3Round =
423
+ Math.round(10 * problem1percentCredit3) / 10;
424
+
425
+ let problem21credit3 = 1;
426
+ let problem21credit3Round = Math.round(1000 * problem21credit3) / 1000;
427
+ let problem21percentCredit3 = problem21credit3 * 100;
428
+ let problem21percentCredit3Round =
429
+ Math.round(10 * problem21percentCredit3) / 10;
430
+
431
+ let problem221credit3 = 1;
432
+ let problem221credit3Round = Math.round(1000 * problem221credit3) / 1000;
433
+ let problem221percentCredit3 = problem221credit3 * 100;
434
+ let problem221percentCredit3Round =
435
+ Math.round(10 * problem221percentCredit3) / 10;
436
+
437
+ let problem22credit3 = (problem221credit3 + 1) / 3;
438
+ let problem22credit3Round = Math.round(1000 * problem22credit3) / 1000;
439
+ let problem22percentCredit3 = problem22credit3 * 100;
440
+ let problem22percentCredit3Round =
441
+ Math.round(10 * problem22percentCredit3) / 10;
442
+
443
+ let problem2credit3 = (problem21credit3 + problem22credit3 + 1) / 3;
444
+ let problem2credit3Round = Math.round(1000 * problem2credit3) / 1000;
445
+ let problem2percentCredit3 = problem2credit3 * 100;
446
+ let problem2percentCredit3Round =
447
+ Math.round(10 * problem2percentCredit3) / 10;
448
+
449
+ let credit3 = (1 + problem1credit3 + problem2credit3) / 3;
450
+ let credit3Round = Math.round(1000 * credit3) / 1000;
451
+ let percentCredit3 = credit3 * 100;
452
+ let percentCredit3Round = Math.round(10 * percentCredit3) / 10;
453
+
454
+ cy.get(docCaAnchor).should("have.text", credit3Round.toString());
455
+ cy.get(docPcaAnchor).should("have.text", percentCredit3Round.toString());
456
+ cy.get(p1CaAnchor).should("have.text", problem1credit3Round.toString());
457
+ cy.get(p1PcaAnchor).should(
458
+ "have.text",
459
+ problem1percentCredit3Round.toString(),
460
+ );
461
+ cy.get(p2CaAnchor).should("have.text", problem2credit3Round.toString());
462
+ cy.get(p2PcaAnchor).should(
463
+ "have.text",
464
+ problem2percentCredit3Round.toString(),
465
+ );
466
+ cy.get(p21CaAnchor).should("have.text", problem21credit3Round.toString());
467
+ cy.get(p21PcaAnchor).should(
468
+ "have.text",
469
+ problem21percentCredit3Round.toString(),
470
+ );
471
+ cy.get(p22CaAnchor).should("have.text", problem22credit3Round.toString());
472
+ cy.get(p22PcaAnchor).should(
473
+ "have.text",
474
+ problem22percentCredit3Round.toString(),
475
+ );
476
+ cy.get(p221CaAnchor).should(
477
+ "have.text",
478
+ problem221credit3Round.toString(),
479
+ );
480
+ cy.get(p221PcaAnchor).should(
481
+ "have.text",
482
+ problem221percentCredit3Round.toString(),
483
+ );
484
+ cy.get(p222CaAnchor).should("have.text", "0");
485
+ cy.get(p222PcaAnchor).should("have.text", "0");
486
+
487
+ cy.window().then(async (win) => {
488
+ let stateVariables = await win.returnAllStateVariables1();
489
+ expect(
490
+ stateVariables["/_document1"].stateValues.creditAchieved,
491
+ ).closeTo(credit3, 1e-12);
492
+ expect(
493
+ stateVariables["/_document1"].stateValues.percentCreditAchieved,
494
+ ).closeTo(percentCredit3, 1e-12);
495
+ expect(stateVariables["/problem1"].stateValues.creditAchieved).closeTo(
496
+ problem1credit3,
497
+ 1e-12,
498
+ );
499
+ expect(
500
+ stateVariables["/problem1"].stateValues.percentCreditAchieved,
501
+ ).closeTo(problem1percentCredit3, 1e-12);
502
+ expect(stateVariables["/problem2"].stateValues.creditAchieved).closeTo(
503
+ problem2credit3,
504
+ 1e-12,
505
+ );
506
+ expect(
507
+ stateVariables["/problem2"].stateValues.percentCreditAchieved,
508
+ ).closeTo(problem2percentCredit3, 1e-12);
509
+ expect(stateVariables["/problem21"].stateValues.creditAchieved).closeTo(
510
+ problem21credit3,
511
+ 1e-12,
512
+ );
513
+ expect(
514
+ stateVariables["/problem21"].stateValues.percentCreditAchieved,
515
+ ).closeTo(problem21percentCredit3, 1e-12);
516
+ expect(stateVariables["/problem22"].stateValues.creditAchieved).closeTo(
517
+ problem22credit3,
518
+ 1e-12,
519
+ );
520
+ expect(
521
+ stateVariables["/problem22"].stateValues.percentCreditAchieved,
522
+ ).closeTo(problem22percentCredit3, 1e-12);
523
+ expect(
524
+ stateVariables["/problem221"].stateValues.creditAchieved,
525
+ ).closeTo(problem221credit3, 1e-12);
526
+ expect(
527
+ stateVariables["/problem221"].stateValues.percentCreditAchieved,
528
+ ).closeTo(problem221percentCredit3, 1e-12);
529
+ expect(stateVariables["/problem222"].stateValues.creditAchieved).eq(0);
530
+ expect(
531
+ stateVariables["/problem222"].stateValues.percentCreditAchieved,
532
+ ).eq(0);
533
+ expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(1);
534
+ expect(stateVariables["/_answer2"].stateValues.creditAchieved).eq(1);
535
+ expect(stateVariables["/_answer3"].stateValues.creditAchieved).eq(1);
536
+ expect(stateVariables["/_answer4"].stateValues.creditAchieved).eq(1);
537
+ expect(stateVariables["/_answer5"].stateValues.creditAchieved).eq(1);
538
+ expect(stateVariables["/_answer6"].stateValues.creditAchieved).eq(1);
539
+ expect(stateVariables["/_answer7"].stateValues.creditAchieved).eq(1);
540
+ expect(stateVariables["/_answer8"].stateValues.creditAchieved).eq(1);
541
+ expect(stateVariables["/_answer9"].stateValues.creditAchieved).eq(0);
542
+ });
543
+
544
+ cy.log("enter last correct answer");
545
+ cy.get(mathinput9Anchor).type(`s{enter}`, { force: true });
546
+
547
+ let problem1credit4 = 1;
548
+ let problem1credit4Round = Math.round(1000 * problem1credit4) / 1000;
549
+ let problem1percentCredit4 = problem1credit4 * 100;
550
+ let problem1percentCredit4Round =
551
+ Math.round(10 * problem1percentCredit4) / 10;
552
+
553
+ let problem221credit4 = 1;
554
+ let problem221credit4Round = Math.round(1000 * problem221credit4) / 1000;
555
+ let problem221percentCredit4 = problem221credit4 * 100;
556
+ let problem221percentCredit4Round =
557
+ Math.round(10 * problem221percentCredit4) / 10;
558
+
559
+ let problem222credit4 = 1;
560
+ let problem222credit4Round = Math.round(1000 * problem222credit4) / 1000;
561
+ let problem222percentCredit4 = problem222credit4 * 100;
562
+ let problem222percentCredit4Round =
563
+ Math.round(10 * problem222percentCredit4) / 10;
564
+
565
+ let problem21credit4 = 1;
566
+ let problem21credit4Round = Math.round(1000 * problem21credit4) / 1000;
567
+ let problem21percentCredit4 = problem21credit4 * 100;
568
+ let problem21percentCredit4Round =
569
+ Math.round(10 * problem21percentCredit4) / 10;
570
+
571
+ let problem22credit4 = 1;
572
+ let problem22credit4Round = Math.round(1000 * problem22credit4) / 1000;
573
+ let problem22percentCredit4 = problem22credit4 * 100;
574
+ let problem22percentCredit4Round =
575
+ Math.round(10 * problem22percentCredit4) / 10;
576
+
577
+ let problem2credit4 = 1;
578
+ let problem2credit4Round = Math.round(1000 * problem2credit4) / 1000;
579
+ let problem2percentCredit4 = problem2credit4 * 100;
580
+ let problem2percentCredit4Round =
581
+ Math.round(10 * problem2percentCredit4) / 10;
582
+
583
+ let credit4 = (1 + problem1credit4 + problem2credit4) / 3;
584
+ let credit4Round = Math.round(1000 * credit4) / 1000;
585
+ let percentCredit4 = credit4 * 100;
586
+ let percentCredit4Round = Math.round(10 * percentCredit4) / 10;
587
+
588
+ cy.get(docCaAnchor).should("have.text", credit4Round.toString());
589
+ cy.get(docPcaAnchor).should("have.text", percentCredit4Round.toString());
590
+ cy.get(p1CaAnchor).should("have.text", problem1credit4Round.toString());
591
+ cy.get(p1PcaAnchor).should(
592
+ "have.text",
593
+ problem1percentCredit4Round.toString(),
594
+ );
595
+ cy.get(p2CaAnchor).should("have.text", problem2credit4Round.toString());
596
+ cy.get(p2PcaAnchor).should(
597
+ "have.text",
598
+ problem2percentCredit4Round.toString(),
599
+ );
600
+ cy.get(p21CaAnchor).should("have.text", problem21credit4Round.toString());
601
+ cy.get(p21PcaAnchor).should(
602
+ "have.text",
603
+ problem21percentCredit4Round.toString(),
604
+ );
605
+ cy.get(p22CaAnchor).should("have.text", problem22credit4Round.toString());
606
+ cy.get(p22PcaAnchor).should(
607
+ "have.text",
608
+ problem22percentCredit4Round.toString(),
609
+ );
610
+ cy.get(p221CaAnchor).should(
611
+ "have.text",
612
+ problem221credit4Round.toString(),
613
+ );
614
+ cy.get(p221PcaAnchor).should(
615
+ "have.text",
616
+ problem221percentCredit4Round.toString(),
617
+ );
618
+ cy.get(p222CaAnchor).should(
619
+ "have.text",
620
+ problem222credit4Round.toString(),
621
+ );
622
+ cy.get(p222PcaAnchor).should(
623
+ "have.text",
624
+ problem222percentCredit4Round.toString(),
625
+ );
626
+
627
+ cy.window().then(async (win) => {
628
+ let stateVariables = await win.returnAllStateVariables1();
629
+ expect(
630
+ stateVariables["/_document1"].stateValues.creditAchieved,
631
+ ).closeTo(credit4, 1e-12);
632
+ expect(
633
+ stateVariables["/_document1"].stateValues.percentCreditAchieved,
634
+ ).closeTo(percentCredit4, 1e-12);
635
+ expect(stateVariables["/problem1"].stateValues.creditAchieved).closeTo(
636
+ problem1credit4,
637
+ 1e-12,
638
+ );
639
+ expect(
640
+ stateVariables["/problem1"].stateValues.percentCreditAchieved,
641
+ ).closeTo(problem1percentCredit4, 1e-12);
642
+ expect(stateVariables["/problem2"].stateValues.creditAchieved).closeTo(
643
+ problem2credit4,
644
+ 1e-12,
645
+ );
646
+ expect(
647
+ stateVariables["/problem2"].stateValues.percentCreditAchieved,
648
+ ).closeTo(problem2percentCredit4, 1e-12);
649
+ expect(stateVariables["/problem21"].stateValues.creditAchieved).closeTo(
650
+ problem21credit4,
651
+ 1e-12,
652
+ );
653
+ expect(
654
+ stateVariables["/problem21"].stateValues.percentCreditAchieved,
655
+ ).closeTo(problem21percentCredit4, 1e-12);
656
+ expect(stateVariables["/problem22"].stateValues.creditAchieved).closeTo(
657
+ problem22credit4,
658
+ 1e-12,
659
+ );
660
+ expect(
661
+ stateVariables["/problem22"].stateValues.percentCreditAchieved,
662
+ ).closeTo(problem22percentCredit4, 1e-12);
663
+ expect(
664
+ stateVariables["/problem221"].stateValues.creditAchieved,
665
+ ).closeTo(problem221credit4, 1e-12);
666
+ expect(
667
+ stateVariables["/problem221"].stateValues.percentCreditAchieved,
668
+ ).closeTo(problem221percentCredit4, 1e-12);
669
+ expect(
670
+ stateVariables["/problem222"].stateValues.creditAchieved,
671
+ ).closeTo(problem222credit4, 1e-12);
672
+ expect(
673
+ stateVariables["/problem222"].stateValues.percentCreditAchieved,
674
+ ).closeTo(problem222percentCredit4, 1e-12);
675
+ expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(1);
676
+ expect(stateVariables["/_answer2"].stateValues.creditAchieved).eq(1);
677
+ expect(stateVariables["/_answer3"].stateValues.creditAchieved).eq(1);
678
+ expect(stateVariables["/_answer4"].stateValues.creditAchieved).eq(1);
679
+ expect(stateVariables["/_answer5"].stateValues.creditAchieved).eq(1);
680
+ expect(stateVariables["/_answer6"].stateValues.creditAchieved).eq(1);
681
+ expect(stateVariables["/_answer7"].stateValues.creditAchieved).eq(1);
682
+ expect(stateVariables["/_answer8"].stateValues.creditAchieved).eq(1);
683
+ expect(stateVariables["/_answer9"].stateValues.creditAchieved).eq(1);
684
+ });
685
+ });
686
+ });
687
+
688
+ it("problems with weights", () => {
689
+ cy.window().then(async (win) => {
690
+ win.postMessage(
691
+ {
692
+ doenetML: `
693
+ <title>Activity</title>
694
+ <p>Credit achieved for <copy prop="title" target="_document1" />:
695
+ <copy name="docCa" prop="creditAchieved" target="_document1" />, or <copy name="docPca" prop="percentCreditAchieved" target="_document1" />%</p>
696
+
697
+ <p>Enter <m>u</m>: <answer>u</answer></p>
698
+
699
+ <problem name="problem1" weight="0.5"><title>Problem 1</title>
700
+ <p>Credit achieved for <copy prop="title" target="problem1" />:
701
+ <copy name="p1Ca" prop="creditAchieved" target="problem1" />, or <copy name="p1Pca" prop="percentCreditAchieved" target="problem1" />%</p>
702
+
703
+ <p>Enter <m>x</m>: <answer>x</answer></p>
704
+ <p>Enter <m>y</m>: <answer weight="2">y</answer></p>
705
+
706
+
707
+ </problem>
708
+ <problem name="problem2" weight="2"><title>Problem 2</title>
709
+ <p>Credit achieved for <copy prop="title" target="problem2" />:
710
+ <copy name="p2Ca" prop="creditAchieved" target="problem2" />, or <copy name="p2Pca" prop="percentCreditAchieved" target="problem2" />%</p>
711
+
712
+ <p>Enter <m>z</m>: <answer>z</answer></p>
713
+
714
+ <problem name="problem21" weight="3"><title>Problem 2.1</title>
715
+ <p>Credit achieved for <copy prop="title" target="problem21" />:
716
+ <copy name="p21Ca" prop="creditAchieved" target="problem21" />, or <copy name="p21Pca" prop="percentCreditAchieved" target="problem21" />%</p>
717
+
718
+
719
+ <p>Enter <m>v</m>: <answer weight="0.5">v</answer></p>
720
+ <p>Enter <m>w</m>: <answer>w</answer></p>
721
+
722
+ </problem>
723
+ <problem name="problem22" weight="4"><title>Problem 2.2</title>
724
+ <p>Credit achieved for <copy prop="title" target="problem22" />:
725
+ <copy name="p22Ca" prop="creditAchieved" target="problem22" />, or <copy name="p22Pca" prop="percentCreditAchieved" target="problem22" />%</p>
726
+
727
+ <p>Enter <m>q</m>: <answer>q</answer></p>
728
+
729
+ <problem name="problem221" weight="5"><title>Problem 2.2.1</title>
730
+ <p>Credit achieved for <copy prop="title" target="problem221" />:
731
+ <copy name="p221Ca" prop="creditAchieved" target="problem221" />, or <copy name="p221Pca" prop="percentCreditAchieved" target="problem221" />%</p>
732
+
733
+ <p>Enter <m>r</m>: <answer>r</answer></p>
734
+
735
+ </problem>
736
+ <problem name="problem222" weight="1"><title>Problem 2.2.2</title>
737
+ <p>Credit achieved for <copy prop="title" target="problem222" />:
738
+ <copy name="p222Ca" prop="creditAchieved" target="problem222" />, or <copy name="p222Pca" prop="percentCreditAchieved" target="problem222" />%</p>
739
+
740
+ <p>Enter <m>s</m>: <answer weight="3">s</answer></p>
741
+
742
+ </problem>
743
+ </problem>
744
+
745
+ </problem>
746
+ `,
747
+ },
748
+ "*",
749
+ );
750
+ });
751
+
752
+ // to wait for page to load
753
+ cy.get(cesc("#\\/_document1_title")).should("have.text", "Activity");
754
+
755
+ cy.window().then(async (win) => {
756
+ let stateVariables = await win.returnAllStateVariables1();
757
+
758
+ let docCaAnchor = cesc2(
759
+ "#" + stateVariables["/docCa"].replacements[0].componentName,
760
+ );
761
+ let docPcaAnchor = cesc2(
762
+ "#" + stateVariables["/docPca"].replacements[0].componentName,
763
+ );
764
+ let p1CaAnchor = cesc2(
765
+ "#" + stateVariables["/p1Ca"].replacements[0].componentName,
766
+ );
767
+ let p1PcaAnchor = cesc2(
768
+ "#" + stateVariables["/p1Pca"].replacements[0].componentName,
769
+ );
770
+ let p2CaAnchor = cesc2(
771
+ "#" + stateVariables["/p2Ca"].replacements[0].componentName,
772
+ );
773
+ let p2PcaAnchor = cesc2(
774
+ "#" + stateVariables["/p2Pca"].replacements[0].componentName,
775
+ );
776
+ let p21CaAnchor = cesc2(
777
+ "#" + stateVariables["/p21Ca"].replacements[0].componentName,
778
+ );
779
+ let p21PcaAnchor = cesc2(
780
+ "#" + stateVariables["/p21Pca"].replacements[0].componentName,
781
+ );
782
+ let p22CaAnchor = cesc2(
783
+ "#" + stateVariables["/p22Ca"].replacements[0].componentName,
784
+ );
785
+ let p22PcaAnchor = cesc2(
786
+ "#" + stateVariables["/p22Pca"].replacements[0].componentName,
787
+ );
788
+ let p221CaAnchor = cesc2(
789
+ "#" + stateVariables["/p221Ca"].replacements[0].componentName,
790
+ );
791
+ let p221PcaAnchor = cesc2(
792
+ "#" + stateVariables["/p221Pca"].replacements[0].componentName,
793
+ );
794
+ let p222CaAnchor = cesc2(
795
+ "#" + stateVariables["/p222Ca"].replacements[0].componentName,
796
+ );
797
+ let p222PcaAnchor = cesc2(
798
+ "#" + stateVariables["/p222Pca"].replacements[0].componentName,
799
+ );
800
+ let mathinput1Anchor =
801
+ cesc2(
802
+ "#" +
803
+ stateVariables["/_answer1"].stateValues.inputChildren[0]
804
+ .componentName,
805
+ ) + " textarea";
806
+ let mathinput2Anchor =
807
+ cesc2(
808
+ "#" +
809
+ stateVariables["/_answer2"].stateValues.inputChildren[0]
810
+ .componentName,
811
+ ) + " textarea";
812
+ let mathinput3Anchor =
813
+ cesc2(
814
+ "#" +
815
+ stateVariables["/_answer3"].stateValues.inputChildren[0]
816
+ .componentName,
817
+ ) + " textarea";
818
+ let mathinput4Anchor =
819
+ cesc2(
820
+ "#" +
821
+ stateVariables["/_answer4"].stateValues.inputChildren[0]
822
+ .componentName,
823
+ ) + " textarea";
824
+ let mathinput5Anchor =
825
+ cesc2(
826
+ "#" +
827
+ stateVariables["/_answer5"].stateValues.inputChildren[0]
828
+ .componentName,
829
+ ) + " textarea";
830
+ let mathinput6Anchor =
831
+ cesc2(
832
+ "#" +
833
+ stateVariables["/_answer6"].stateValues.inputChildren[0]
834
+ .componentName,
835
+ ) + " textarea";
836
+ let mathinput7Anchor =
837
+ cesc2(
838
+ "#" +
839
+ stateVariables["/_answer7"].stateValues.inputChildren[0]
840
+ .componentName,
841
+ ) + " textarea";
842
+ let mathinput8Anchor =
843
+ cesc2(
844
+ "#" +
845
+ stateVariables["/_answer8"].stateValues.inputChildren[0]
846
+ .componentName,
847
+ ) + " textarea";
848
+ let mathinput9Anchor =
849
+ cesc2(
850
+ "#" +
851
+ stateVariables["/_answer9"].stateValues.inputChildren[0]
852
+ .componentName,
853
+ ) + " textarea";
854
+
855
+ cy.get(docCaAnchor).should("have.text", "0");
856
+ cy.get(docPcaAnchor).should("have.text", "0");
857
+ cy.get(p1CaAnchor).should("have.text", "0");
858
+ cy.get(p1PcaAnchor).should("have.text", "0");
859
+ cy.get(p2CaAnchor).should("have.text", "0");
860
+ cy.get(p2PcaAnchor).should("have.text", "0");
861
+ cy.get(p21CaAnchor).should("have.text", "0");
862
+ cy.get(p21PcaAnchor).should("have.text", "0");
863
+ cy.get(p22CaAnchor).should("have.text", "0");
864
+ cy.get(p22PcaAnchor).should("have.text", "0");
865
+ cy.get(p221CaAnchor).should("have.text", "0");
866
+ cy.get(p221PcaAnchor).should("have.text", "0");
867
+ cy.get(p222CaAnchor).should("have.text", "0");
868
+ cy.get(p222PcaAnchor).should("have.text", "0");
869
+
870
+ cy.window().then(async (win) => {
871
+ let stateVariables = await win.returnAllStateVariables1();
872
+ expect(stateVariables["/_document1"].stateValues.creditAchieved).eq(0);
873
+ expect(
874
+ stateVariables["/_document1"].stateValues.percentCreditAchieved,
875
+ ).eq(0);
876
+ expect(stateVariables["/problem1"].stateValues.creditAchieved).eq(0);
877
+ expect(
878
+ stateVariables["/problem1"].stateValues.percentCreditAchieved,
879
+ ).eq(0);
880
+ expect(stateVariables["/problem2"].stateValues.creditAchieved).eq(0);
881
+ expect(
882
+ stateVariables["/problem2"].stateValues.percentCreditAchieved,
883
+ ).eq(0);
884
+ expect(stateVariables["/problem21"].stateValues.creditAchieved).eq(0);
885
+ expect(
886
+ stateVariables["/problem21"].stateValues.percentCreditAchieved,
887
+ ).eq(0);
888
+ expect(stateVariables["/problem22"].stateValues.creditAchieved).eq(0);
889
+ expect(
890
+ stateVariables["/problem22"].stateValues.percentCreditAchieved,
891
+ ).eq(0);
892
+ expect(stateVariables["/problem221"].stateValues.creditAchieved).eq(0);
893
+ expect(
894
+ stateVariables["/problem221"].stateValues.percentCreditAchieved,
895
+ ).eq(0);
896
+ expect(stateVariables["/problem222"].stateValues.creditAchieved).eq(0);
897
+ expect(
898
+ stateVariables["/problem222"].stateValues.percentCreditAchieved,
899
+ ).eq(0);
900
+ expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(0);
901
+ expect(stateVariables["/_answer2"].stateValues.creditAchieved).eq(0);
902
+ expect(stateVariables["/_answer3"].stateValues.creditAchieved).eq(0);
903
+ expect(stateVariables["/_answer4"].stateValues.creditAchieved).eq(0);
904
+ expect(stateVariables["/_answer5"].stateValues.creditAchieved).eq(0);
905
+ expect(stateVariables["/_answer6"].stateValues.creditAchieved).eq(0);
906
+ expect(stateVariables["/_answer7"].stateValues.creditAchieved).eq(0);
907
+ expect(stateVariables["/_answer8"].stateValues.creditAchieved).eq(0);
908
+ expect(stateVariables["/_answer9"].stateValues.creditAchieved).eq(0);
909
+ });
910
+
911
+ cy.log("enter first correct answer");
912
+ cy.get(mathinput1Anchor).type(`u{enter}`, { force: true });
913
+
914
+ let credit1 = 1 / 3.5;
915
+ let credit1Round = Math.round(1000 * credit1) / 1000;
916
+ let percentCredit1 = credit1 * 100;
917
+ let percentCredit1Round = Math.round(10 * percentCredit1) / 10;
918
+
919
+ cy.get(docCaAnchor).should("have.text", credit1Round.toString());
920
+ cy.get(docPcaAnchor).should("have.text", percentCredit1Round.toString());
921
+ cy.get(p1CaAnchor).should("have.text", "0");
922
+ cy.get(p1PcaAnchor).should("have.text", "0");
923
+ cy.get(p2CaAnchor).should("have.text", "0");
924
+ cy.get(p2PcaAnchor).should("have.text", "0");
925
+ cy.get(p21CaAnchor).should("have.text", "0");
926
+ cy.get(p21PcaAnchor).should("have.text", "0");
927
+ cy.get(p22CaAnchor).should("have.text", "0");
928
+ cy.get(p22PcaAnchor).should("have.text", "0");
929
+ cy.get(p221CaAnchor).should("have.text", "0");
930
+ cy.get(p221PcaAnchor).should("have.text", "0");
931
+ cy.get(p222CaAnchor).should("have.text", "0");
932
+ cy.get(p222PcaAnchor).should("have.text", "0");
933
+
934
+ cy.window().then(async (win) => {
935
+ let stateVariables = await win.returnAllStateVariables1();
936
+ expect(
937
+ stateVariables["/_document1"].stateValues.creditAchieved,
938
+ ).closeTo(credit1, 1e-12);
939
+ expect(
940
+ stateVariables["/_document1"].stateValues.percentCreditAchieved,
941
+ ).closeTo(percentCredit1, 1e-12);
942
+ expect(stateVariables["/problem1"].stateValues.creditAchieved).eq(0);
943
+ expect(
944
+ stateVariables["/problem1"].stateValues.percentCreditAchieved,
945
+ ).eq(0);
946
+ expect(stateVariables["/problem2"].stateValues.creditAchieved).eq(0);
947
+ expect(
948
+ stateVariables["/problem2"].stateValues.percentCreditAchieved,
949
+ ).eq(0);
950
+ expect(stateVariables["/problem21"].stateValues.creditAchieved).eq(0);
951
+ expect(
952
+ stateVariables["/problem21"].stateValues.percentCreditAchieved,
953
+ ).eq(0);
954
+ expect(stateVariables["/problem22"].stateValues.creditAchieved).eq(0);
955
+ expect(
956
+ stateVariables["/problem22"].stateValues.percentCreditAchieved,
957
+ ).eq(0);
958
+ expect(stateVariables["/problem221"].stateValues.creditAchieved).eq(0);
959
+ expect(
960
+ stateVariables["/problem221"].stateValues.percentCreditAchieved,
961
+ ).eq(0);
962
+ expect(stateVariables["/problem222"].stateValues.creditAchieved).eq(0);
963
+ expect(
964
+ stateVariables["/problem222"].stateValues.percentCreditAchieved,
965
+ ).eq(0);
966
+ expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(1);
967
+ expect(stateVariables["/_answer2"].stateValues.creditAchieved).eq(0);
968
+ expect(stateVariables["/_answer3"].stateValues.creditAchieved).eq(0);
969
+ expect(stateVariables["/_answer4"].stateValues.creditAchieved).eq(0);
970
+ expect(stateVariables["/_answer5"].stateValues.creditAchieved).eq(0);
971
+ expect(stateVariables["/_answer6"].stateValues.creditAchieved).eq(0);
972
+ expect(stateVariables["/_answer7"].stateValues.creditAchieved).eq(0);
973
+ expect(stateVariables["/_answer8"].stateValues.creditAchieved).eq(0);
974
+ expect(stateVariables["/_answer9"].stateValues.creditAchieved).eq(0);
975
+ });
976
+
977
+ cy.log("enter additional correct answers");
978
+ cy.get(mathinput3Anchor).type(`y{enter}`, { force: true });
979
+ cy.get(mathinput5Anchor).type(`v{enter}`, { force: true });
980
+ cy.get(mathinput7Anchor).type(`q{enter}`, { force: true });
981
+
982
+ let problem1credit2 = 2 / 3;
983
+ let problem1credit2Round = Math.round(1000 * problem1credit2) / 1000;
984
+ let problem1percentCredit2 = problem1credit2 * 100;
985
+ let problem1percentCredit2Round =
986
+ Math.round(10 * problem1percentCredit2) / 10;
987
+
988
+ let problem21credit2 = 1 / 3;
989
+ let problem21credit2Round = Math.round(1000 * problem21credit2) / 1000;
990
+ let problem21percentCredit2 = problem21credit2 * 100;
991
+ let problem21percentCredit2Round =
992
+ Math.round(10 * problem21percentCredit2) / 10;
993
+
994
+ let problem22credit2 = 1 / 7;
995
+ let problem22credit2Round = Math.round(1000 * problem22credit2) / 1000;
996
+ let problem22percentCredit2 = problem22credit2 * 100;
997
+ let problem22percentCredit2Round =
998
+ Math.round(10 * problem22percentCredit2) / 10;
999
+
1000
+ let problem2credit2 = (3 * problem21credit2 + 4 * problem22credit2) / 8;
1001
+ let problem2credit2Round = Math.round(1000 * problem2credit2) / 1000;
1002
+ let problem2percentCredit2 = problem2credit2 * 100;
1003
+ let problem2percentCredit2Round =
1004
+ Math.round(10 * problem2percentCredit2) / 10;
1005
+
1006
+ let credit2 = (1 + 0.5 * problem1credit2 + 2 * problem2credit2) / 3.5;
1007
+ let credit2Round = Math.round(1000 * credit2) / 1000;
1008
+ let percentCredit2 = credit2 * 100;
1009
+ let percentCredit2Round = Math.round(10 * percentCredit2) / 10;
1010
+
1011
+ cy.get(docCaAnchor).should("have.text", credit2Round.toString());
1012
+ cy.get(docPcaAnchor).should("have.text", percentCredit2Round.toString());
1013
+ cy.get(p1CaAnchor).should("have.text", problem1credit2Round.toString());
1014
+ cy.get(p1PcaAnchor).should(
1015
+ "have.text",
1016
+ problem1percentCredit2Round.toString(),
1017
+ );
1018
+ cy.get(p2CaAnchor).should("have.text", problem2credit2Round.toString());
1019
+ cy.get(p2PcaAnchor).should(
1020
+ "have.text",
1021
+ problem2percentCredit2Round.toString(),
1022
+ );
1023
+ cy.get(p21CaAnchor).should("have.text", problem21credit2Round.toString());
1024
+ cy.get(p21PcaAnchor).should(
1025
+ "have.text",
1026
+ problem21percentCredit2Round.toString(),
1027
+ );
1028
+ cy.get(p22CaAnchor).should("have.text", problem22credit2Round.toString());
1029
+ cy.get(p22PcaAnchor).should(
1030
+ "have.text",
1031
+ problem22percentCredit2Round.toString(),
1032
+ );
1033
+ cy.get(p221CaAnchor).should("have.text", "0");
1034
+ cy.get(p221PcaAnchor).should("have.text", "0");
1035
+ cy.get(p222CaAnchor).should("have.text", "0");
1036
+ cy.get(p222PcaAnchor).should("have.text", "0");
1037
+
1038
+ cy.window().then(async (win) => {
1039
+ let stateVariables = await win.returnAllStateVariables1();
1040
+ expect(
1041
+ stateVariables["/_document1"].stateValues.creditAchieved,
1042
+ ).closeTo(credit2, 1e-12);
1043
+ expect(
1044
+ stateVariables["/_document1"].stateValues.percentCreditAchieved,
1045
+ ).closeTo(percentCredit2, 1e-12);
1046
+ expect(stateVariables["/problem1"].stateValues.creditAchieved).closeTo(
1047
+ problem1credit2,
1048
+ 1e-12,
1049
+ );
1050
+ expect(
1051
+ stateVariables["/problem1"].stateValues.percentCreditAchieved,
1052
+ ).closeTo(problem1percentCredit2, 1e-12);
1053
+ expect(stateVariables["/problem2"].stateValues.creditAchieved).closeTo(
1054
+ problem2credit2,
1055
+ 1e-12,
1056
+ );
1057
+ expect(
1058
+ stateVariables["/problem2"].stateValues.percentCreditAchieved,
1059
+ ).closeTo(problem2percentCredit2, 1e-12);
1060
+ expect(stateVariables["/problem21"].stateValues.creditAchieved).closeTo(
1061
+ problem21credit2,
1062
+ 1e-12,
1063
+ );
1064
+ expect(
1065
+ stateVariables["/problem21"].stateValues.percentCreditAchieved,
1066
+ ).closeTo(problem21percentCredit2, 1e-12);
1067
+ expect(stateVariables["/problem22"].stateValues.creditAchieved).closeTo(
1068
+ problem22credit2,
1069
+ 1e-12,
1070
+ );
1071
+ expect(
1072
+ stateVariables["/problem22"].stateValues.percentCreditAchieved,
1073
+ ).closeTo(problem22percentCredit2, 1e-12);
1074
+ expect(stateVariables["/problem221"].stateValues.creditAchieved).eq(0);
1075
+ expect(
1076
+ stateVariables["/problem221"].stateValues.percentCreditAchieved,
1077
+ ).eq(0);
1078
+ expect(stateVariables["/problem222"].stateValues.creditAchieved).eq(0);
1079
+ expect(
1080
+ stateVariables["/problem222"].stateValues.percentCreditAchieved,
1081
+ ).eq(0);
1082
+ expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(1);
1083
+ expect(stateVariables["/_answer2"].stateValues.creditAchieved).eq(0);
1084
+ expect(stateVariables["/_answer3"].stateValues.creditAchieved).eq(1);
1085
+ expect(stateVariables["/_answer4"].stateValues.creditAchieved).eq(0);
1086
+ expect(stateVariables["/_answer5"].stateValues.creditAchieved).eq(1);
1087
+ expect(stateVariables["/_answer6"].stateValues.creditAchieved).eq(0);
1088
+ expect(stateVariables["/_answer7"].stateValues.creditAchieved).eq(1);
1089
+ expect(stateVariables["/_answer8"].stateValues.creditAchieved).eq(0);
1090
+ expect(stateVariables["/_answer9"].stateValues.creditAchieved).eq(0);
1091
+ });
1092
+
1093
+ cy.log("enter most other correct answers");
1094
+ cy.get(mathinput2Anchor).type(`x{enter}`, { force: true });
1095
+ cy.get(mathinput4Anchor).type(`z{enter}`, { force: true });
1096
+ cy.get(mathinput6Anchor).type(`w{enter}`, { force: true });
1097
+ cy.get(mathinput8Anchor).type(`r{enter}`, { force: true });
1098
+
1099
+ let problem1credit3 = 1;
1100
+ let problem1credit3Round = Math.round(1000 * problem1credit3) / 1000;
1101
+ let problem1percentCredit3 = problem1credit3 * 100;
1102
+ let problem1percentCredit3Round =
1103
+ Math.round(10 * problem1percentCredit3) / 10;
1104
+
1105
+ let problem21credit3 = 1;
1106
+ let problem21credit3Round = Math.round(1000 * problem21credit3) / 1000;
1107
+ let problem21percentCredit3 = problem21credit3 * 100;
1108
+ let problem21percentCredit3Round =
1109
+ Math.round(10 * problem21percentCredit3) / 10;
1110
+
1111
+ let problem221credit3 = 1;
1112
+ let problem221credit3Round = Math.round(1000 * problem221credit3) / 1000;
1113
+ let problem221percentCredit3 = problem221credit3 * 100;
1114
+ let problem221percentCredit3Round =
1115
+ Math.round(10 * problem221percentCredit3) / 10;
1116
+
1117
+ let problem22credit3 = 6 / 7;
1118
+ let problem22credit3Round = Math.round(1000 * problem22credit3) / 1000;
1119
+ let problem22percentCredit3 = problem22credit3 * 100;
1120
+ let problem22percentCredit3Round =
1121
+ Math.round(10 * problem22percentCredit3) / 10;
1122
+
1123
+ let problem2credit3 =
1124
+ (1 + 3 * problem21credit3 + 4 * problem22credit3) / 8;
1125
+ let problem2credit3Round = Math.round(1000 * problem2credit3) / 1000;
1126
+ let problem2percentCredit3 = problem2credit3 * 100;
1127
+ let problem2percentCredit3Round =
1128
+ Math.round(10 * problem2percentCredit3) / 10;
1129
+
1130
+ let credit3 = (1 + 0.5 * problem1credit3 + 2 * problem2credit3) / 3.5;
1131
+ let credit3Round = Math.round(1000 * credit3) / 1000;
1132
+ let percentCredit3 = credit3 * 100;
1133
+ let percentCredit3Round = Math.round(10 * percentCredit3) / 10;
1134
+
1135
+ cy.get(docCaAnchor).should("have.text", credit3Round.toString());
1136
+ cy.get(docPcaAnchor).should("have.text", percentCredit3Round.toString());
1137
+ cy.get(p1CaAnchor).should("have.text", problem1credit3Round.toString());
1138
+ cy.get(p1PcaAnchor).should(
1139
+ "have.text",
1140
+ problem1percentCredit3Round.toString(),
1141
+ );
1142
+ cy.get(p2CaAnchor).should("have.text", problem2credit3Round.toString());
1143
+ cy.get(p2PcaAnchor).should(
1144
+ "have.text",
1145
+ problem2percentCredit3Round.toString(),
1146
+ );
1147
+ cy.get(p21CaAnchor).should("have.text", problem21credit3Round.toString());
1148
+ cy.get(p21PcaAnchor).should(
1149
+ "have.text",
1150
+ problem21percentCredit3Round.toString(),
1151
+ );
1152
+ cy.get(p22CaAnchor).should("have.text", problem22credit3Round.toString());
1153
+ cy.get(p22PcaAnchor).should(
1154
+ "have.text",
1155
+ problem22percentCredit3Round.toString(),
1156
+ );
1157
+ cy.get(p221CaAnchor).should(
1158
+ "have.text",
1159
+ problem221credit3Round.toString(),
1160
+ );
1161
+ cy.get(p221PcaAnchor).should(
1162
+ "have.text",
1163
+ problem221percentCredit3Round.toString(),
1164
+ );
1165
+ cy.get(p222CaAnchor).should("have.text", "0");
1166
+ cy.get(p222PcaAnchor).should("have.text", "0");
1167
+
1168
+ cy.window().then(async (win) => {
1169
+ let stateVariables = await win.returnAllStateVariables1();
1170
+ expect(
1171
+ stateVariables["/_document1"].stateValues.creditAchieved,
1172
+ ).closeTo(credit3, 1e-12);
1173
+ expect(
1174
+ stateVariables["/_document1"].stateValues.percentCreditAchieved,
1175
+ ).closeTo(percentCredit3, 1e-12);
1176
+ expect(stateVariables["/problem1"].stateValues.creditAchieved).closeTo(
1177
+ problem1credit3,
1178
+ 1e-12,
1179
+ );
1180
+ expect(
1181
+ stateVariables["/problem1"].stateValues.percentCreditAchieved,
1182
+ ).closeTo(problem1percentCredit3, 1e-12);
1183
+ expect(stateVariables["/problem2"].stateValues.creditAchieved).closeTo(
1184
+ problem2credit3,
1185
+ 1e-12,
1186
+ );
1187
+ expect(
1188
+ stateVariables["/problem2"].stateValues.percentCreditAchieved,
1189
+ ).closeTo(problem2percentCredit3, 1e-12);
1190
+ expect(stateVariables["/problem21"].stateValues.creditAchieved).closeTo(
1191
+ problem21credit3,
1192
+ 1e-12,
1193
+ );
1194
+ expect(
1195
+ stateVariables["/problem21"].stateValues.percentCreditAchieved,
1196
+ ).closeTo(problem21percentCredit3, 1e-12);
1197
+ expect(stateVariables["/problem22"].stateValues.creditAchieved).closeTo(
1198
+ problem22credit3,
1199
+ 1e-12,
1200
+ );
1201
+ expect(
1202
+ stateVariables["/problem22"].stateValues.percentCreditAchieved,
1203
+ ).closeTo(problem22percentCredit3, 1e-12);
1204
+ expect(
1205
+ stateVariables["/problem221"].stateValues.creditAchieved,
1206
+ ).closeTo(problem221credit3, 1e-12);
1207
+ expect(
1208
+ stateVariables["/problem221"].stateValues.percentCreditAchieved,
1209
+ ).closeTo(problem221percentCredit3, 1e-12);
1210
+ expect(stateVariables["/problem222"].stateValues.creditAchieved).eq(0);
1211
+ expect(
1212
+ stateVariables["/problem222"].stateValues.percentCreditAchieved,
1213
+ ).eq(0);
1214
+ expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(1);
1215
+ expect(stateVariables["/_answer2"].stateValues.creditAchieved).eq(1);
1216
+ expect(stateVariables["/_answer3"].stateValues.creditAchieved).eq(1);
1217
+ expect(stateVariables["/_answer4"].stateValues.creditAchieved).eq(1);
1218
+ expect(stateVariables["/_answer5"].stateValues.creditAchieved).eq(1);
1219
+ expect(stateVariables["/_answer6"].stateValues.creditAchieved).eq(1);
1220
+ expect(stateVariables["/_answer7"].stateValues.creditAchieved).eq(1);
1221
+ expect(stateVariables["/_answer8"].stateValues.creditAchieved).eq(1);
1222
+ expect(stateVariables["/_answer9"].stateValues.creditAchieved).eq(0);
1223
+ });
1224
+
1225
+ cy.log("enter last correct answer");
1226
+ cy.get(mathinput9Anchor).type(`s{enter}`, { force: true });
1227
+
1228
+ let problem1credit4 = 1;
1229
+ let problem1credit4Round = Math.round(1000 * problem1credit4) / 1000;
1230
+ let problem1percentCredit4 = problem1credit4 * 100;
1231
+ let problem1percentCredit4Round =
1232
+ Math.round(10 * problem1percentCredit4) / 10;
1233
+
1234
+ let problem21credit4 = 1;
1235
+ let problem21credit4Round = Math.round(1000 * problem21credit4) / 1000;
1236
+ let problem21percentCredit4 = problem21credit4 * 100;
1237
+ let problem21percentCredit4Round =
1238
+ Math.round(10 * problem21percentCredit4) / 10;
1239
+
1240
+ let problem221credit4 = 1;
1241
+ let problem221credit4Round = Math.round(1000 * problem221credit4) / 1000;
1242
+ let problem221percentCredit4 = problem221credit4 * 100;
1243
+ let problem221percentCredit4Round =
1244
+ Math.round(10 * problem221percentCredit4) / 10;
1245
+
1246
+ let problem222credit4 = 1;
1247
+ let problem222credit4Round = Math.round(1000 * problem222credit4) / 1000;
1248
+ let problem222percentCredit4 = problem222credit4 * 100;
1249
+ let problem222percentCredit4Round =
1250
+ Math.round(10 * problem222percentCredit4) / 10;
1251
+
1252
+ let problem22credit4 = 1;
1253
+ let problem22credit4Round = Math.round(1000 * problem22credit4) / 1000;
1254
+ let problem22percentCredit4 = problem22credit4 * 100;
1255
+ let problem22percentCredit4Round =
1256
+ Math.round(10 * problem22percentCredit4) / 10;
1257
+
1258
+ let problem2credit4 = 1;
1259
+ let problem2credit4Round = Math.round(1000 * problem2credit4) / 1000;
1260
+ let problem2percentCredit4 = problem2credit4 * 100;
1261
+ let problem2percentCredit4Round =
1262
+ Math.round(10 * problem2percentCredit4) / 10;
1263
+
1264
+ let credit4 = (1 + problem1credit4 + problem2credit4) / 3;
1265
+ let credit4Round = Math.round(1000 * credit4) / 1000;
1266
+ let percentCredit4 = credit4 * 100;
1267
+ let percentCredit4Round = Math.round(10 * percentCredit4) / 10;
1268
+
1269
+ cy.get(docCaAnchor).should("have.text", credit4Round.toString());
1270
+ cy.get(docPcaAnchor).should("have.text", percentCredit4Round.toString());
1271
+ cy.get(p1CaAnchor).should("have.text", problem1credit4Round.toString());
1272
+ cy.get(p1PcaAnchor).should(
1273
+ "have.text",
1274
+ problem1percentCredit4Round.toString(),
1275
+ );
1276
+ cy.get(p2CaAnchor).should("have.text", problem2credit4Round.toString());
1277
+ cy.get(p2PcaAnchor).should(
1278
+ "have.text",
1279
+ problem2percentCredit4Round.toString(),
1280
+ );
1281
+ cy.get(p21CaAnchor).should("have.text", problem21credit4Round.toString());
1282
+ cy.get(p21PcaAnchor).should(
1283
+ "have.text",
1284
+ problem21percentCredit4Round.toString(),
1285
+ );
1286
+ cy.get(p22CaAnchor).should("have.text", problem22credit4Round.toString());
1287
+ cy.get(p22PcaAnchor).should(
1288
+ "have.text",
1289
+ problem22percentCredit4Round.toString(),
1290
+ );
1291
+ cy.get(p221CaAnchor).should(
1292
+ "have.text",
1293
+ problem221credit4Round.toString(),
1294
+ );
1295
+ cy.get(p221PcaAnchor).should(
1296
+ "have.text",
1297
+ problem221percentCredit4Round.toString(),
1298
+ );
1299
+ cy.get(p222CaAnchor).should(
1300
+ "have.text",
1301
+ problem222credit4Round.toString(),
1302
+ );
1303
+ cy.get(p222PcaAnchor).should(
1304
+ "have.text",
1305
+ problem222percentCredit4Round.toString(),
1306
+ );
1307
+
1308
+ cy.window().then(async (win) => {
1309
+ let stateVariables = await win.returnAllStateVariables1();
1310
+ expect(
1311
+ stateVariables["/_document1"].stateValues.creditAchieved,
1312
+ ).closeTo(credit4, 1e-12);
1313
+ expect(
1314
+ stateVariables["/_document1"].stateValues.percentCreditAchieved,
1315
+ ).closeTo(percentCredit4, 1e-12);
1316
+ expect(stateVariables["/problem1"].stateValues.creditAchieved).closeTo(
1317
+ problem1credit4,
1318
+ 1e-12,
1319
+ );
1320
+ expect(
1321
+ stateVariables["/problem1"].stateValues.percentCreditAchieved,
1322
+ ).closeTo(problem1percentCredit4, 1e-12);
1323
+ expect(stateVariables["/problem2"].stateValues.creditAchieved).closeTo(
1324
+ problem2credit4,
1325
+ 1e-12,
1326
+ );
1327
+ expect(
1328
+ stateVariables["/problem2"].stateValues.percentCreditAchieved,
1329
+ ).closeTo(problem2percentCredit4, 1e-12);
1330
+ expect(stateVariables["/problem21"].stateValues.creditAchieved).closeTo(
1331
+ problem21credit4,
1332
+ 1e-12,
1333
+ );
1334
+ expect(
1335
+ stateVariables["/problem21"].stateValues.percentCreditAchieved,
1336
+ ).closeTo(problem21percentCredit4, 1e-12);
1337
+ expect(stateVariables["/problem22"].stateValues.creditAchieved).closeTo(
1338
+ problem22credit4,
1339
+ 1e-12,
1340
+ );
1341
+ expect(
1342
+ stateVariables["/problem22"].stateValues.percentCreditAchieved,
1343
+ ).closeTo(problem22percentCredit4, 1e-12);
1344
+ expect(
1345
+ stateVariables["/problem221"].stateValues.creditAchieved,
1346
+ ).closeTo(problem221credit4, 1e-12);
1347
+ expect(
1348
+ stateVariables["/problem221"].stateValues.percentCreditAchieved,
1349
+ ).closeTo(problem221percentCredit4, 1e-12);
1350
+ expect(
1351
+ stateVariables["/problem222"].stateValues.creditAchieved,
1352
+ ).closeTo(problem222credit4, 1e-12);
1353
+ expect(
1354
+ stateVariables["/problem222"].stateValues.percentCreditAchieved,
1355
+ ).closeTo(problem222percentCredit4, 1e-12);
1356
+ expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq(1);
1357
+ expect(stateVariables["/_answer2"].stateValues.creditAchieved).eq(1);
1358
+ expect(stateVariables["/_answer3"].stateValues.creditAchieved).eq(1);
1359
+ expect(stateVariables["/_answer4"].stateValues.creditAchieved).eq(1);
1360
+ expect(stateVariables["/_answer5"].stateValues.creditAchieved).eq(1);
1361
+ expect(stateVariables["/_answer6"].stateValues.creditAchieved).eq(1);
1362
+ expect(stateVariables["/_answer7"].stateValues.creditAchieved).eq(1);
1363
+ expect(stateVariables["/_answer8"].stateValues.creditAchieved).eq(1);
1364
+ expect(stateVariables["/_answer9"].stateValues.creditAchieved).eq(1);
1365
+ });
1366
+ });
1367
+ });
1368
+
1369
+ it("section wide checkwork in problem", () => {
1370
+ cy.window().then(async (win) => {
1371
+ win.postMessage(
1372
+ {
1373
+ doenetML: `
1374
+ <text>a</text>
1375
+ <p>Section wide checkwork: <booleaninput name="swcw" /></p>
1376
+ <problem sectionWideCheckwork="$swcw" name="theProblem">
1377
+ <title>Problem 1</title>
1378
+
1379
+ <p>2x: <answer name="twox">2x</answer></p>
1380
+
1381
+ <p>hello: <answer type="text" name="hello">hello</answer></p>
1382
+
1383
+ <p>banana:
1384
+ <answer name="fruit">
1385
+ <choiceinput shuffleOrder name="fruitInput">
1386
+ <choice credit="1">banana</choice>
1387
+ <choice>apple</choice>
1388
+ <choice>orange</choice>
1389
+ </choiceinput>
1390
+ </answer>
1391
+ </p>
1392
+
1393
+ <p>Numbers that add to 3: <mathinput name="n1" /> <mathinput name="n2" />
1394
+ <answer name="sum3">
1395
+ <award sourcesAreResponses="n1 n2">
1396
+ <when>$n1+$n2=3</when>
1397
+ </award>
1398
+ </answer></p>
1399
+
1400
+ </problem>
1401
+ `,
1402
+ },
1403
+ "*",
1404
+ );
1405
+ });
1406
+
1407
+ // to wait for page to load
1408
+ cy.get(cesc("#\\/_text1")).should("have.text", "a");
1409
+
1410
+ cy.get(cesc("#\\/swcw_input")).should("not.be.checked");
1411
+
1412
+ cy.get(cesc("#\\/theProblem_submit")).should("not.exist");
1413
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
1414
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
1415
+ cy.get(cesc("#\\/theProblem_partial")).should("not.exist");
1416
+
1417
+ cy.window().then(async (win) => {
1418
+ let stateVariables = await win.returnAllStateVariables1();
1419
+
1420
+ let twoxInputName =
1421
+ stateVariables["/twox"].stateValues.inputChildren[0].componentName;
1422
+ let twoxInputAnchor = cesc2("#" + twoxInputName) + " textarea";
1423
+ let twoxInputSubmitAnchor = cesc2("#" + twoxInputName + "_submit");
1424
+ let twoxInputCorrectAnchor = cesc2("#" + twoxInputName + "_correct");
1425
+ let twoxInputIncorrectAnchor = cesc2("#" + twoxInputName + "_incorrect");
1426
+
1427
+ cy.get(twoxInputSubmitAnchor).should("be.visible");
1428
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
1429
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
1430
+
1431
+ cy.get(twoxInputAnchor).type("2x{enter}", { force: true });
1432
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
1433
+ cy.get(twoxInputCorrectAnchor).should("be.visible");
1434
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
1435
+
1436
+ let helloInputName =
1437
+ stateVariables["/hello"].stateValues.inputChildren[0].componentName;
1438
+ let helloInputAnchor = cesc2("#" + helloInputName + "_input");
1439
+ let helloInputSubmitAnchor = cesc2("#" + helloInputName + "_submit");
1440
+ let helloInputCorrectAnchor = cesc2("#" + helloInputName + "_correct");
1441
+ let helloInputIncorrectAnchor = cesc2(
1442
+ "#" + helloInputName + "_incorrect",
1443
+ );
1444
+
1445
+ cy.get(helloInputSubmitAnchor).should("be.visible");
1446
+ cy.get(helloInputCorrectAnchor).should("not.exist");
1447
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
1448
+
1449
+ cy.get(helloInputAnchor).type("hello{enter}");
1450
+ cy.get(helloInputSubmitAnchor).should("not.exist");
1451
+ cy.get(helloInputCorrectAnchor).should("be.visible");
1452
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
1453
+
1454
+ cy.get(cesc("#\\/fruitInput_submit")).should("be.visible");
1455
+ cy.get(cesc("#\\/fruitInput_correct")).should("not.exist");
1456
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
1457
+
1458
+ cy.get(cesc("#\\/fruitInput")).contains(`banana`).click({ force: true });
1459
+ cy.get(cesc("#\\/fruitInput_submit")).click();
1460
+
1461
+ cy.get(cesc("#\\/fruitInput_submit")).should("not.exist");
1462
+ cy.get(cesc("#\\/fruitInput_correct")).should("be.visible");
1463
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
1464
+
1465
+ cy.get(cesc("#\\/sum3_submit")).should("be.visible");
1466
+ cy.get(cesc("#\\/sum3_correct")).should("not.exist");
1467
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
1468
+
1469
+ cy.get(cesc("#\\/n1") + " textarea").type("2{enter}", { force: true });
1470
+ cy.get(cesc("#\\/n2") + " textarea").type("1{enter}", { force: true });
1471
+
1472
+ cy.get(cesc("#\\/sum3_submit")).should("be.visible");
1473
+ cy.get(cesc("#\\/sum3_correct")).should("not.exist");
1474
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
1475
+
1476
+ cy.get(cesc("#\\/sum3_submit")).click();
1477
+ cy.get(cesc("#\\/sum3_submit")).should("not.exist");
1478
+ cy.get(cesc("#\\/sum3_correct")).should("be.visible");
1479
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
1480
+
1481
+ cy.log("switch to section wide checkwork");
1482
+
1483
+ cy.get(cesc("#\\/swcw")).click();
1484
+ cy.get(cesc("#\\/swcw_input")).should("be.checked");
1485
+
1486
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
1487
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
1488
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
1489
+
1490
+ cy.get(helloInputSubmitAnchor).should("not.exist");
1491
+ cy.get(helloInputCorrectAnchor).should("not.exist");
1492
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
1493
+
1494
+ cy.get(cesc("#\\/fruitInput_submit")).should("not.exist");
1495
+ cy.get(cesc("#\\/fruitInput_correct")).should("not.exist");
1496
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
1497
+
1498
+ cy.get(cesc("#\\/sum3_submit")).should("not.exist");
1499
+ cy.get(cesc("#\\/sum3_correct")).should("not.exist");
1500
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
1501
+
1502
+ cy.get(cesc("#\\/theProblem_submit")).should("not.exist");
1503
+ cy.get(cesc("#\\/theProblem_correct")).should("be.visible");
1504
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
1505
+ cy.get(cesc("#\\/theProblem_partial")).should("not.exist");
1506
+
1507
+ cy.get(twoxInputAnchor).type("{end}{backspace}y{enter}", { force: true });
1508
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
1509
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
1510
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
1511
+
1512
+ cy.get(cesc("#\\/theProblem_submit")).should("be.visible");
1513
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
1514
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
1515
+ cy.get(cesc("#\\/theProblem_partial")).should("not.exist");
1516
+
1517
+ cy.get(cesc("#\\/theProblem_submit")).click();
1518
+ cy.get(cesc("#\\/theProblem_submit")).should("not.exist");
1519
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
1520
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
1521
+ cy.get(cesc("#\\/theProblem_partial"))
1522
+ .invoke("text")
1523
+ .then((text) => {
1524
+ expect(text.trim().toLowerCase()).equal("75% correct");
1525
+ });
1526
+
1527
+ cy.get(helloInputAnchor).type("2{enter}");
1528
+ cy.get(helloInputSubmitAnchor).should("not.exist");
1529
+ cy.get(helloInputCorrectAnchor).should("not.exist");
1530
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
1531
+
1532
+ cy.get(cesc("#\\/theProblem_submit")).should("be.visible");
1533
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
1534
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
1535
+ cy.get(cesc("#\\/theProblem_partial")).should("not.exist");
1536
+
1537
+ cy.get(cesc("#\\/theProblem_submit")).click();
1538
+ cy.get(cesc("#\\/theProblem_submit")).should("not.exist");
1539
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
1540
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
1541
+ cy.get(cesc("#\\/theProblem_partial"))
1542
+ .invoke("text")
1543
+ .then((text) => {
1544
+ expect(text.trim().toLowerCase()).equal("50% correct");
1545
+ });
1546
+
1547
+ cy.log("turn off section wide checkwork");
1548
+
1549
+ cy.get(cesc("#\\/swcw")).click();
1550
+ cy.get(cesc("#\\/swcw_input")).should("not.be.checked");
1551
+
1552
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
1553
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
1554
+ cy.get(twoxInputIncorrectAnchor).should("be.visible");
1555
+
1556
+ cy.get(helloInputSubmitAnchor).should("not.exist");
1557
+ cy.get(helloInputCorrectAnchor).should("not.exist");
1558
+ cy.get(helloInputIncorrectAnchor).should("be.visible");
1559
+
1560
+ cy.get(cesc("#\\/fruitInput_submit")).should("not.exist");
1561
+ cy.get(cesc("#\\/fruitInput_correct")).should("be.visible");
1562
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
1563
+
1564
+ cy.get(cesc("#\\/sum3_submit")).should("not.exist");
1565
+ cy.get(cesc("#\\/sum3_correct")).should("be.visible");
1566
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
1567
+
1568
+ cy.get(cesc("#\\/theProblem_submit")).should("not.exist");
1569
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
1570
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
1571
+ cy.get(cesc("#\\/theProblem_partial")).should("not.exist");
1572
+ });
1573
+ });
1574
+
1575
+ it("section wide checkwork in section", () => {
1576
+ cy.window().then(async (win) => {
1577
+ win.postMessage(
1578
+ {
1579
+ doenetML: `
1580
+ <text>a</text>
1581
+ <p>Section wide checkwork: <booleaninput name="swcw" /></p>
1582
+ <section aggregateScores sectionWideCheckwork="$swcw" name="theProblem">
1583
+ <title>Problem 1</title>
1584
+
1585
+ <p>2x: <answer name="twox">2x</answer></p>
1586
+
1587
+ <p>hello: <answer type="text" name="hello">hello</answer></p>
1588
+
1589
+ <p>banana:
1590
+ <answer name="fruit">
1591
+ <choiceinput shuffleOrder name="fruitInput">
1592
+ <choice credit="1">banana</choice>
1593
+ <choice>apple</choice>
1594
+ <choice>orange</choice>
1595
+ </choiceinput>
1596
+ </answer>
1597
+ </p>
1598
+
1599
+ <p>Numbers that add to 3: <mathinput name="n1" /> <mathinput name="n2" />
1600
+ <answer name="sum3">
1601
+ <award sourcesAreResponses="n1 n2">
1602
+ <when>$n1+$n2=3</when>
1603
+ </award>
1604
+ </answer></p>
1605
+
1606
+ </section>
1607
+ `,
1608
+ },
1609
+ "*",
1610
+ );
1611
+ });
1612
+
1613
+ // to wait for page to load
1614
+ cy.get(cesc("#\\/_text1")).should("have.text", "a");
1615
+
1616
+ cy.get(cesc("#\\/swcw_input")).should("not.be.checked");
1617
+
1618
+ cy.get(cesc("#\\/theProblem_submit")).should("not.exist");
1619
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
1620
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
1621
+ cy.get(cesc("#\\/theProblem_partial")).should("not.exist");
1622
+
1623
+ cy.window().then(async (win) => {
1624
+ let stateVariables = await win.returnAllStateVariables1();
1625
+
1626
+ let twoxInputName =
1627
+ stateVariables["/twox"].stateValues.inputChildren[0].componentName;
1628
+ let twoxInputAnchor = cesc2("#" + twoxInputName) + " textarea";
1629
+ let twoxInputSubmitAnchor = cesc2("#" + twoxInputName + "_submit");
1630
+ let twoxInputCorrectAnchor = cesc2("#" + twoxInputName + "_correct");
1631
+ let twoxInputIncorrectAnchor = cesc2("#" + twoxInputName + "_incorrect");
1632
+
1633
+ cy.get(twoxInputSubmitAnchor).should("be.visible");
1634
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
1635
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
1636
+
1637
+ cy.get(twoxInputAnchor).type("2x{enter}", { force: true });
1638
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
1639
+ cy.get(twoxInputCorrectAnchor).should("be.visible");
1640
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
1641
+
1642
+ let helloInputName =
1643
+ stateVariables["/hello"].stateValues.inputChildren[0].componentName;
1644
+ let helloInputAnchor = cesc2("#" + helloInputName + "_input");
1645
+ let helloInputSubmitAnchor = cesc2("#" + helloInputName + "_submit");
1646
+ let helloInputCorrectAnchor = cesc2("#" + helloInputName + "_correct");
1647
+ let helloInputIncorrectAnchor = cesc2(
1648
+ "#" + helloInputName + "_incorrect",
1649
+ );
1650
+
1651
+ cy.get(helloInputSubmitAnchor).should("be.visible");
1652
+ cy.get(helloInputCorrectAnchor).should("not.exist");
1653
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
1654
+
1655
+ cy.get(helloInputAnchor).type("hello{enter}");
1656
+ cy.get(helloInputSubmitAnchor).should("not.exist");
1657
+ cy.get(helloInputCorrectAnchor).should("be.visible");
1658
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
1659
+
1660
+ cy.get(cesc("#\\/fruitInput_submit")).should("be.visible");
1661
+ cy.get(cesc("#\\/fruitInput_correct")).should("not.exist");
1662
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
1663
+
1664
+ cy.get(cesc("#\\/fruitInput")).contains(`banana`).click({ force: true });
1665
+ cy.get(cesc("#\\/fruitInput_submit")).click();
1666
+
1667
+ cy.get(cesc("#\\/fruitInput_submit")).should("not.exist");
1668
+ cy.get(cesc("#\\/fruitInput_correct")).should("be.visible");
1669
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
1670
+
1671
+ cy.get(cesc("#\\/sum3_submit")).should("be.visible");
1672
+ cy.get(cesc("#\\/sum3_correct")).should("not.exist");
1673
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
1674
+
1675
+ cy.get(cesc("#\\/n1") + " textarea").type("2{enter}", { force: true });
1676
+ cy.get(cesc("#\\/n2") + " textarea").type("1{enter}", { force: true });
1677
+
1678
+ cy.get(cesc("#\\/sum3_submit")).should("be.visible");
1679
+ cy.get(cesc("#\\/sum3_correct")).should("not.exist");
1680
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
1681
+
1682
+ cy.get(cesc("#\\/sum3_submit")).click();
1683
+ cy.get(cesc("#\\/sum3_submit")).should("not.exist");
1684
+ cy.get(cesc("#\\/sum3_correct")).should("be.visible");
1685
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
1686
+
1687
+ cy.log("switch to section wide checkwork");
1688
+
1689
+ cy.get(cesc("#\\/swcw")).click();
1690
+ cy.get(cesc("#\\/swcw_input")).should("be.checked");
1691
+
1692
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
1693
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
1694
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
1695
+
1696
+ cy.get(helloInputSubmitAnchor).should("not.exist");
1697
+ cy.get(helloInputCorrectAnchor).should("not.exist");
1698
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
1699
+
1700
+ cy.get(cesc("#\\/fruitInput_submit")).should("not.exist");
1701
+ cy.get(cesc("#\\/fruitInput_correct")).should("not.exist");
1702
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
1703
+
1704
+ cy.get(cesc("#\\/sum3_submit")).should("not.exist");
1705
+ cy.get(cesc("#\\/sum3_correct")).should("not.exist");
1706
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
1707
+
1708
+ cy.get(cesc("#\\/theProblem_submit")).should("not.exist");
1709
+ cy.get(cesc("#\\/theProblem_correct")).should("be.visible");
1710
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
1711
+ cy.get(cesc("#\\/theProblem_partial")).should("not.exist");
1712
+
1713
+ cy.get(twoxInputAnchor).type("{end}{backspace}y{enter}", { force: true });
1714
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
1715
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
1716
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
1717
+
1718
+ cy.get(cesc("#\\/theProblem_submit")).should("be.visible");
1719
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
1720
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
1721
+ cy.get(cesc("#\\/theProblem_partial")).should("not.exist");
1722
+
1723
+ cy.get(cesc("#\\/theProblem_submit")).click();
1724
+ cy.get(cesc("#\\/theProblem_submit")).should("not.exist");
1725
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
1726
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
1727
+ cy.get(cesc("#\\/theProblem_partial"))
1728
+ .invoke("text")
1729
+ .then((text) => {
1730
+ expect(text.trim().toLowerCase()).equal("75% correct");
1731
+ });
1732
+
1733
+ cy.get(helloInputAnchor).type("2{enter}");
1734
+ cy.get(helloInputSubmitAnchor).should("not.exist");
1735
+ cy.get(helloInputCorrectAnchor).should("not.exist");
1736
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
1737
+
1738
+ cy.get(cesc("#\\/theProblem_submit")).should("be.visible");
1739
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
1740
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
1741
+ cy.get(cesc("#\\/theProblem_partial")).should("not.exist");
1742
+
1743
+ cy.get(cesc("#\\/theProblem_submit")).click();
1744
+ cy.get(cesc("#\\/theProblem_submit")).should("not.exist");
1745
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
1746
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
1747
+ cy.get(cesc("#\\/theProblem_partial"))
1748
+ .invoke("text")
1749
+ .then((text) => {
1750
+ expect(text.trim().toLowerCase()).equal("50% correct");
1751
+ });
1752
+
1753
+ cy.log("turn off section wide checkwork");
1754
+
1755
+ cy.get(cesc("#\\/swcw")).click();
1756
+ cy.get(cesc("#\\/swcw_input")).should("not.be.checked");
1757
+
1758
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
1759
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
1760
+ cy.get(twoxInputIncorrectAnchor).should("be.visible");
1761
+
1762
+ cy.get(helloInputSubmitAnchor).should("not.exist");
1763
+ cy.get(helloInputCorrectAnchor).should("not.exist");
1764
+ cy.get(helloInputIncorrectAnchor).should("be.visible");
1765
+
1766
+ cy.get(cesc("#\\/fruitInput_submit")).should("not.exist");
1767
+ cy.get(cesc("#\\/fruitInput_correct")).should("be.visible");
1768
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
1769
+
1770
+ cy.get(cesc("#\\/sum3_submit")).should("not.exist");
1771
+ cy.get(cesc("#\\/sum3_correct")).should("be.visible");
1772
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
1773
+
1774
+ cy.get(cesc("#\\/theProblem_submit")).should("not.exist");
1775
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
1776
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
1777
+ cy.get(cesc("#\\/theProblem_partial")).should("not.exist");
1778
+ });
1779
+ });
1780
+
1781
+ it("document wide checkwork", () => {
1782
+ cy.window().then(async (win) => {
1783
+ win.postMessage(
1784
+ {
1785
+ doenetML: `
1786
+ <text>a</text>
1787
+ <document documentWideCheckwork="$dwcw" name="theDocument">
1788
+ <title>The problem</title>
1789
+
1790
+ <p>Document wide checkwork: <booleaninput name="dwcw" /></p>
1791
+
1792
+ <p>2x: <answer name="twox">2x</answer></p>
1793
+
1794
+ <p>hello: <answer type="text" name="hello">hello</answer></p>
1795
+
1796
+ <p>banana:
1797
+ <answer name="fruit">
1798
+ <choiceinput shuffleOrder name="fruitInput">
1799
+ <choice credit="1">banana</choice>
1800
+ <choice>apple</choice>
1801
+ <choice>orange</choice>
1802
+ </choiceinput>
1803
+ </answer>
1804
+ </p>
1805
+
1806
+ <p>Numbers that add to 3: <mathinput name="n1" /> <mathinput name="n2" />
1807
+ <answer name="sum3">
1808
+ <award sourcesAreResponses="n1 n2">
1809
+ <when>$n1+$n2=3</when>
1810
+ </award>
1811
+ </answer></p>
1812
+ </document>
1813
+ `,
1814
+ },
1815
+ "*",
1816
+ );
1817
+ });
1818
+
1819
+ // to wait for page to load
1820
+ cy.get(cesc("#\\/_text1")).should("have.text", "a");
1821
+
1822
+ cy.get(cesc("#\\/dwcw_input")).should("not.be.checked");
1823
+
1824
+ cy.get(cesc("#\\/theDocument_submit")).should("not.exist");
1825
+ cy.get(cesc("#\\/theDocument_correct")).should("not.exist");
1826
+ cy.get(cesc("#\\/theDocument_incorrect")).should("not.exist");
1827
+ cy.get(cesc("#\\/theDocument_partial")).should("not.exist");
1828
+
1829
+ cy.window().then(async (win) => {
1830
+ let stateVariables = await win.returnAllStateVariables1();
1831
+
1832
+ let twoxInputName =
1833
+ stateVariables["/twox"].stateValues.inputChildren[0].componentName;
1834
+ let twoxInputAnchor = cesc2("#" + twoxInputName) + " textarea";
1835
+ let twoxInputSubmitAnchor = cesc2("#" + twoxInputName + "_submit");
1836
+ let twoxInputCorrectAnchor = cesc2("#" + twoxInputName + "_correct");
1837
+ let twoxInputIncorrectAnchor = cesc2("#" + twoxInputName + "_incorrect");
1838
+
1839
+ cy.get(twoxInputSubmitAnchor).should("be.visible");
1840
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
1841
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
1842
+
1843
+ cy.get(twoxInputAnchor).type("2x{enter}", { force: true });
1844
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
1845
+ cy.get(twoxInputCorrectAnchor).should("be.visible");
1846
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
1847
+
1848
+ let helloInputName =
1849
+ stateVariables["/hello"].stateValues.inputChildren[0].componentName;
1850
+ let helloInputAnchor = cesc2("#" + helloInputName + "_input");
1851
+ let helloInputSubmitAnchor = cesc2("#" + helloInputName + "_submit");
1852
+ let helloInputCorrectAnchor = cesc2("#" + helloInputName + "_correct");
1853
+ let helloInputIncorrectAnchor = cesc2(
1854
+ "#" + helloInputName + "_incorrect",
1855
+ );
1856
+
1857
+ cy.get(helloInputSubmitAnchor).should("be.visible");
1858
+ cy.get(helloInputCorrectAnchor).should("not.exist");
1859
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
1860
+
1861
+ cy.get(helloInputAnchor).type("hello{enter}");
1862
+ cy.get(helloInputSubmitAnchor).should("not.exist");
1863
+ cy.get(helloInputCorrectAnchor).should("be.visible");
1864
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
1865
+
1866
+ cy.get(cesc("#\\/fruitInput_submit")).should("be.visible");
1867
+ cy.get(cesc("#\\/fruitInput_correct")).should("not.exist");
1868
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
1869
+
1870
+ cy.get(cesc("#\\/fruitInput")).contains(`banana`).click({ force: true });
1871
+ cy.get(cesc("#\\/fruitInput_submit")).click();
1872
+
1873
+ cy.get(cesc("#\\/fruitInput_submit")).should("not.exist");
1874
+ cy.get(cesc("#\\/fruitInput_correct")).should("be.visible");
1875
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
1876
+
1877
+ cy.get(cesc("#\\/sum3_submit")).should("be.visible");
1878
+ cy.get(cesc("#\\/sum3_correct")).should("not.exist");
1879
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
1880
+
1881
+ cy.get(cesc("#\\/n1") + " textarea").type("2{enter}", { force: true });
1882
+ cy.get(cesc("#\\/n2") + " textarea").type("1{enter}", { force: true });
1883
+
1884
+ cy.get(cesc("#\\/sum3_submit")).should("be.visible");
1885
+ cy.get(cesc("#\\/sum3_correct")).should("not.exist");
1886
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
1887
+
1888
+ cy.get(cesc("#\\/sum3_submit")).click();
1889
+ cy.get(cesc("#\\/sum3_submit")).should("not.exist");
1890
+ cy.get(cesc("#\\/sum3_correct")).should("be.visible");
1891
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
1892
+
1893
+ cy.log("switch to document wide checkwork");
1894
+
1895
+ cy.get(cesc("#\\/dwcw")).click();
1896
+ cy.get(cesc("#\\/dwcw_input")).should("be.checked");
1897
+
1898
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
1899
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
1900
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
1901
+
1902
+ cy.get(helloInputSubmitAnchor).should("not.exist");
1903
+ cy.get(helloInputCorrectAnchor).should("not.exist");
1904
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
1905
+
1906
+ cy.get(cesc("#\\/fruitInput_submit")).should("not.exist");
1907
+ cy.get(cesc("#\\/fruitInput_correct")).should("not.exist");
1908
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
1909
+
1910
+ cy.get(cesc("#\\/sum3_submit")).should("not.exist");
1911
+ cy.get(cesc("#\\/sum3_correct")).should("not.exist");
1912
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
1913
+
1914
+ cy.get(cesc("#\\/theDocument_submit")).should("not.exist");
1915
+ cy.get(cesc("#\\/theDocument_correct")).should("be.visible");
1916
+ cy.get(cesc("#\\/theDocument_incorrect")).should("not.exist");
1917
+ cy.get(cesc("#\\/theDocument_partial")).should("not.exist");
1918
+
1919
+ cy.get(twoxInputAnchor).type("{end}{backspace}y{enter}", { force: true });
1920
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
1921
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
1922
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
1923
+
1924
+ cy.get(cesc("#\\/theDocument_submit")).should("be.visible");
1925
+ cy.get(cesc("#\\/theDocument_correct")).should("not.exist");
1926
+ cy.get(cesc("#\\/theDocument_incorrect")).should("not.exist");
1927
+ cy.get(cesc("#\\/theDocument_partial")).should("not.exist");
1928
+
1929
+ cy.get(cesc("#\\/theDocument_submit")).click();
1930
+ cy.get(cesc("#\\/theDocument_submit")).should("not.exist");
1931
+ cy.get(cesc("#\\/theDocument_correct")).should("not.exist");
1932
+ cy.get(cesc("#\\/theDocument_incorrect")).should("not.exist");
1933
+ cy.get(cesc("#\\/theDocument_partial"))
1934
+ .invoke("text")
1935
+ .then((text) => {
1936
+ expect(text.trim().toLowerCase()).equal("75% correct");
1937
+ });
1938
+
1939
+ cy.get(helloInputAnchor).type("2{enter}");
1940
+ cy.get(helloInputSubmitAnchor).should("not.exist");
1941
+ cy.get(helloInputCorrectAnchor).should("not.exist");
1942
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
1943
+
1944
+ cy.get(cesc("#\\/theDocument_submit")).should("be.visible");
1945
+ cy.get(cesc("#\\/theDocument_correct")).should("not.exist");
1946
+ cy.get(cesc("#\\/theDocument_incorrect")).should("not.exist");
1947
+ cy.get(cesc("#\\/theDocument_partial")).should("not.exist");
1948
+
1949
+ cy.get(cesc("#\\/theDocument_submit")).click();
1950
+ cy.get(cesc("#\\/theDocument_submit")).should("not.exist");
1951
+ cy.get(cesc("#\\/theDocument_correct")).should("not.exist");
1952
+ cy.get(cesc("#\\/theDocument_incorrect")).should("not.exist");
1953
+ cy.get(cesc("#\\/theDocument_partial"))
1954
+ .invoke("text")
1955
+ .then((text) => {
1956
+ expect(text.trim().toLowerCase()).equal("50% correct");
1957
+ });
1958
+
1959
+ cy.log("turn off document wide checkwork");
1960
+
1961
+ cy.get(cesc("#\\/dwcw")).click();
1962
+ cy.get(cesc("#\\/dwcw_input")).should("not.be.checked");
1963
+
1964
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
1965
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
1966
+ cy.get(twoxInputIncorrectAnchor).should("be.visible");
1967
+
1968
+ cy.get(helloInputSubmitAnchor).should("not.exist");
1969
+ cy.get(helloInputCorrectAnchor).should("not.exist");
1970
+ cy.get(helloInputIncorrectAnchor).should("be.visible");
1971
+
1972
+ cy.get(cesc("#\\/fruitInput_submit")).should("not.exist");
1973
+ cy.get(cesc("#\\/fruitInput_correct")).should("be.visible");
1974
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
1975
+
1976
+ cy.get(cesc("#\\/sum3_submit")).should("not.exist");
1977
+ cy.get(cesc("#\\/sum3_correct")).should("be.visible");
1978
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
1979
+
1980
+ cy.get(cesc("#\\/theDocument_submit")).should("not.exist");
1981
+ cy.get(cesc("#\\/theDocument_correct")).should("not.exist");
1982
+ cy.get(cesc("#\\/theDocument_incorrect")).should("not.exist");
1983
+ cy.get(cesc("#\\/theDocument_partial")).should("not.exist");
1984
+ });
1985
+ });
1986
+
1987
+ it("outer section wide checkwork supercedes inner section", () => {
1988
+ cy.window().then(async (win) => {
1989
+ win.postMessage(
1990
+ {
1991
+ doenetML: `
1992
+ <text>a</text>
1993
+ <p>Section wide checkwork: <booleaninput name="swcw" /></p>
1994
+ <section aggregateScores sectionWideCheckwork="$swcw" name="theProblem">
1995
+ <title>Problem 1</title>
1996
+
1997
+ <p>2x: <answer name="twox">2x</answer></p>
1998
+
1999
+ <p>hello: <answer type="text" name="hello">hello</answer></p>
2000
+
2001
+ <subsection aggregateScores sectionWideCheckwork name="subProblem">
2002
+ <title>Sub problem a</title>
2003
+ <p>banana:
2004
+ <answer name="fruit">
2005
+ <choiceinput shuffleOrder name="fruitInput">
2006
+ <choice credit="1">banana</choice>
2007
+ <choice>apple</choice>
2008
+ <choice>orange</choice>
2009
+ </choiceinput>
2010
+ </answer>
2011
+ </p>
2012
+
2013
+ <p>Numbers that add to 3: <mathinput name="n1" /> <mathinput name="n2" />
2014
+ <answer name="sum3">
2015
+ <award sourcesAreResponses="n1 n2">
2016
+ <when>$n1+$n2=3</when>
2017
+ </award>
2018
+ </answer></p>
2019
+ </subsection>
2020
+
2021
+ </section>
2022
+ `,
2023
+ },
2024
+ "*",
2025
+ );
2026
+ });
2027
+
2028
+ // to wait for page to load
2029
+ cy.get(cesc("#\\/_text1")).should("have.text", "a");
2030
+
2031
+ cy.get(cesc("#\\/swcw_input")).should("not.be.checked");
2032
+
2033
+ cy.get(cesc("#\\/theProblem_submit")).should("not.exist");
2034
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
2035
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
2036
+ cy.get(cesc("#\\/theProblem_partial")).should("not.exist");
2037
+
2038
+ cy.window().then(async (win) => {
2039
+ let stateVariables = await win.returnAllStateVariables1();
2040
+
2041
+ let twoxInputName =
2042
+ stateVariables["/twox"].stateValues.inputChildren[0].componentName;
2043
+ let twoxInputAnchor = cesc2("#" + twoxInputName) + " textarea";
2044
+ let twoxInputSubmitAnchor = cesc2("#" + twoxInputName + "_submit");
2045
+ let twoxInputCorrectAnchor = cesc2("#" + twoxInputName + "_correct");
2046
+ let twoxInputIncorrectAnchor = cesc2("#" + twoxInputName + "_incorrect");
2047
+
2048
+ cy.get(twoxInputSubmitAnchor).should("be.visible");
2049
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
2050
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
2051
+
2052
+ cy.get(twoxInputAnchor).type("2x{enter}", { force: true });
2053
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
2054
+ cy.get(twoxInputCorrectAnchor).should("be.visible");
2055
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
2056
+
2057
+ let helloInputName =
2058
+ stateVariables["/hello"].stateValues.inputChildren[0].componentName;
2059
+ let helloInputAnchor = cesc2("#" + helloInputName + "_input");
2060
+ let helloInputSubmitAnchor = cesc2("#" + helloInputName + "_submit");
2061
+ let helloInputCorrectAnchor = cesc2("#" + helloInputName + "_correct");
2062
+ let helloInputIncorrectAnchor = cesc2(
2063
+ "#" + helloInputName + "_incorrect",
2064
+ );
2065
+
2066
+ cy.get(helloInputSubmitAnchor).should("be.visible");
2067
+ cy.get(helloInputCorrectAnchor).should("not.exist");
2068
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
2069
+
2070
+ cy.get(helloInputAnchor).type("hello{enter}");
2071
+ cy.get(helloInputSubmitAnchor).should("not.exist");
2072
+ cy.get(helloInputCorrectAnchor).should("be.visible");
2073
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
2074
+
2075
+ cy.get(cesc("#\\/fruitInput_submit")).should("not.exist");
2076
+ cy.get(cesc("#\\/fruitInput_correct")).should("not.exist");
2077
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
2078
+ cy.get(cesc("#\\/sum3_submit")).should("not.exist");
2079
+ cy.get(cesc("#\\/sum3_correct")).should("not.exist");
2080
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
2081
+
2082
+ cy.get(cesc("#\\/subProblem_submit")).should("be.visible");
2083
+ cy.get(cesc("#\\/subProblem_correct")).should("not.exist");
2084
+ cy.get(cesc("#\\/subProblem_incorrect")).should("not.exist");
2085
+ cy.get(cesc("#\\/subProblem_partial")).should("not.exist");
2086
+
2087
+ cy.get(cesc("#\\/fruitInput")).contains(`banana`).click({ force: true });
2088
+ cy.get(cesc("#\\/subProblem_submit")).click();
2089
+
2090
+ cy.get(cesc("#\\/subProblem_submit")).should("not.exist");
2091
+ cy.get(cesc("#\\/subProblem_correct")).should("not.exist");
2092
+ cy.get(cesc("#\\/subProblem_incorrect")).should("not.exist");
2093
+ cy.get(cesc("#\\/subProblem_partial"))
2094
+ .invoke("text")
2095
+ .then((text) => {
2096
+ expect(text.trim().toLowerCase()).equal("50% correct");
2097
+ });
2098
+
2099
+ cy.get(cesc("#\\/n1") + " textarea").type("2{enter}", { force: true });
2100
+ cy.get(cesc("#\\/n2") + " textarea").type("1{enter}", { force: true });
2101
+
2102
+ cy.get(cesc("#\\/subProblem_submit")).should("be.visible");
2103
+ cy.get(cesc("#\\/subProblem_correct")).should("not.exist");
2104
+ cy.get(cesc("#\\/subProblem_incorrect")).should("not.exist");
2105
+ cy.get(cesc("#\\/subProblem_partial")).should("not.exist");
2106
+
2107
+ cy.get(cesc("#\\/subProblem_submit")).click();
2108
+
2109
+ cy.get(cesc("#\\/subProblem_submit")).should("not.exist");
2110
+ cy.get(cesc("#\\/subProblem_correct")).should("be.visible");
2111
+ cy.get(cesc("#\\/subProblem_incorrect")).should("not.exist");
2112
+ cy.get(cesc("#\\/subProblem_partial")).should("not.exist");
2113
+
2114
+ cy.log("switch to section wide checkwork");
2115
+
2116
+ cy.get(cesc("#\\/swcw")).click();
2117
+ cy.get(cesc("#\\/swcw_input")).should("be.checked");
2118
+
2119
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
2120
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
2121
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
2122
+
2123
+ cy.get(helloInputSubmitAnchor).should("not.exist");
2124
+ cy.get(helloInputCorrectAnchor).should("not.exist");
2125
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
2126
+
2127
+ cy.get(cesc("#\\/fruitInput_submit")).should("not.exist");
2128
+ cy.get(cesc("#\\/fruitInput_correct")).should("not.exist");
2129
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
2130
+
2131
+ cy.get(cesc("#\\/sum3_submit")).should("not.exist");
2132
+ cy.get(cesc("#\\/sum3_correct")).should("not.exist");
2133
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
2134
+
2135
+ cy.get(cesc("#\\/subProblem_submit")).should("not.exist");
2136
+ cy.get(cesc("#\\/subProblem_correct")).should("not.exist");
2137
+ cy.get(cesc("#\\/subProblem_incorrect")).should("not.exist");
2138
+ cy.get(cesc("#\\/subProblem_partial")).should("not.exist");
2139
+
2140
+ cy.get(cesc("#\\/theProblem_submit")).should("not.exist");
2141
+ cy.get(cesc("#\\/theProblem_correct")).should("be.visible");
2142
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
2143
+ cy.get(cesc("#\\/theProblem_partial")).should("not.exist");
2144
+
2145
+ cy.get(twoxInputAnchor).type("{end}{backspace}y{enter}", { force: true });
2146
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
2147
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
2148
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
2149
+
2150
+ cy.get(cesc("#\\/theProblem_submit")).should("be.visible");
2151
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
2152
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
2153
+ cy.get(cesc("#\\/theProblem_partial")).should("not.exist");
2154
+
2155
+ cy.get(cesc("#\\/theProblem_submit")).click();
2156
+ cy.get(cesc("#\\/theProblem_submit")).should("not.exist");
2157
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
2158
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
2159
+ cy.get(cesc("#\\/theProblem_partial"))
2160
+ .invoke("text")
2161
+ .then((text) => {
2162
+ expect(text.trim().toLowerCase()).equal("67% correct");
2163
+ });
2164
+
2165
+ cy.get(helloInputAnchor).type("2{enter}");
2166
+ cy.get(helloInputSubmitAnchor).should("not.exist");
2167
+ cy.get(helloInputCorrectAnchor).should("not.exist");
2168
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
2169
+
2170
+ cy.get(cesc("#\\/theProblem_submit")).should("be.visible");
2171
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
2172
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
2173
+ cy.get(cesc("#\\/theProblem_partial")).should("not.exist");
2174
+
2175
+ cy.get(cesc("#\\/theProblem_submit")).click();
2176
+ cy.get(cesc("#\\/theProblem_submit")).should("not.exist");
2177
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
2178
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
2179
+ cy.get(cesc("#\\/theProblem_partial"))
2180
+ .invoke("text")
2181
+ .then((text) => {
2182
+ expect(text.trim().toLowerCase()).equal("33% correct");
2183
+ });
2184
+
2185
+ cy.log("turn off section wide checkwork");
2186
+
2187
+ cy.get(cesc("#\\/swcw")).click();
2188
+ cy.get(cesc("#\\/swcw_input")).should("not.be.checked");
2189
+
2190
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
2191
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
2192
+ cy.get(twoxInputIncorrectAnchor).should("be.visible");
2193
+
2194
+ cy.get(helloInputSubmitAnchor).should("not.exist");
2195
+ cy.get(helloInputCorrectAnchor).should("not.exist");
2196
+ cy.get(helloInputIncorrectAnchor).should("be.visible");
2197
+
2198
+ cy.get(cesc("#\\/fruitInput_submit")).should("not.exist");
2199
+ cy.get(cesc("#\\/fruitInput_correct")).should("not.exist");
2200
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
2201
+
2202
+ cy.get(cesc("#\\/sum3_submit")).should("not.exist");
2203
+ cy.get(cesc("#\\/sum3_correct")).should("not.exist");
2204
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
2205
+
2206
+ cy.get(cesc("#\\/subProblem_submit")).should("not.exist");
2207
+ cy.get(cesc("#\\/subProblem_correct")).should("be.visible");
2208
+ cy.get(cesc("#\\/subProblem_incorrect")).should("not.exist");
2209
+ cy.get(cesc("#\\/subProblem_partial")).should("not.exist");
2210
+
2211
+ cy.get(cesc("#\\/theProblem_submit")).should("not.exist");
2212
+ cy.get(cesc("#\\/theProblem_correct")).should("not.exist");
2213
+ cy.get(cesc("#\\/theProblem_incorrect")).should("not.exist");
2214
+ cy.get(cesc("#\\/theProblem_partial")).should("not.exist");
2215
+ });
2216
+ });
2217
+
2218
+ it("document wide checkwork supercedes section", () => {
2219
+ cy.window().then(async (win) => {
2220
+ win.postMessage(
2221
+ {
2222
+ doenetML: `
2223
+ <text>a</text>
2224
+ <document documentWideCheckwork="$dwcw" name="theDocument">
2225
+ <title>The problem</title>
2226
+
2227
+ <p>Document wide checkwork: <booleaninput name="dwcw" /></p>
2228
+ <p>2x: <answer name="twox">2x</answer></p>
2229
+
2230
+ <p>hello: <answer type="text" name="hello">hello</answer></p>
2231
+
2232
+ <section aggregateScores sectionWideCheckwork name="subProblem">
2233
+ <title>Sub problem a</title>
2234
+ <p>banana:
2235
+ <answer name="fruit">
2236
+ <choiceinput shuffleOrder name="fruitInput">
2237
+ <choice credit="1">banana</choice>
2238
+ <choice>apple</choice>
2239
+ <choice>orange</choice>
2240
+ </choiceinput>
2241
+ </answer>
2242
+ </p>
2243
+
2244
+ <p>Numbers that add to 3: <mathinput name="n1" /> <mathinput name="n2" />
2245
+ <answer name="sum3">
2246
+ <award sourcesAreResponses="n1 n2">
2247
+ <when>$n1+$n2=3</when>
2248
+ </award>
2249
+ </answer></p>
2250
+ </section>
2251
+
2252
+ </document>
2253
+ `,
2254
+ },
2255
+ "*",
2256
+ );
2257
+ });
2258
+
2259
+ // to wait for page to load
2260
+ cy.get(cesc("#\\/_text1")).should("have.text", "a");
2261
+
2262
+ cy.get(cesc("#\\/dwcw_input")).should("not.be.checked");
2263
+
2264
+ cy.get(cesc("#\\/theDocument_submit")).should("not.exist");
2265
+ cy.get(cesc("#\\/theDocument_correct")).should("not.exist");
2266
+ cy.get(cesc("#\\/theDocument_incorrect")).should("not.exist");
2267
+ cy.get(cesc("#\\/theDocument_partial")).should("not.exist");
2268
+
2269
+ cy.window().then(async (win) => {
2270
+ let stateVariables = await win.returnAllStateVariables1();
2271
+
2272
+ let twoxInputName =
2273
+ stateVariables["/twox"].stateValues.inputChildren[0].componentName;
2274
+ let twoxInputAnchor = cesc2("#" + twoxInputName) + " textarea";
2275
+ let twoxInputSubmitAnchor = cesc2("#" + twoxInputName + "_submit");
2276
+ let twoxInputCorrectAnchor = cesc2("#" + twoxInputName + "_correct");
2277
+ let twoxInputIncorrectAnchor = cesc2("#" + twoxInputName + "_incorrect");
2278
+
2279
+ cy.get(twoxInputSubmitAnchor).should("be.visible");
2280
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
2281
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
2282
+
2283
+ cy.get(twoxInputAnchor).type("2x{enter}", { force: true });
2284
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
2285
+ cy.get(twoxInputCorrectAnchor).should("be.visible");
2286
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
2287
+
2288
+ let helloInputName =
2289
+ stateVariables["/hello"].stateValues.inputChildren[0].componentName;
2290
+ let helloInputAnchor = cesc2("#" + helloInputName + "_input");
2291
+ let helloInputSubmitAnchor = cesc2("#" + helloInputName + "_submit");
2292
+ let helloInputCorrectAnchor = cesc2("#" + helloInputName + "_correct");
2293
+ let helloInputIncorrectAnchor = cesc2(
2294
+ "#" + helloInputName + "_incorrect",
2295
+ );
2296
+
2297
+ cy.get(helloInputSubmitAnchor).should("be.visible");
2298
+ cy.get(helloInputCorrectAnchor).should("not.exist");
2299
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
2300
+
2301
+ cy.get(helloInputAnchor).type("hello{enter}");
2302
+ cy.get(helloInputSubmitAnchor).should("not.exist");
2303
+ cy.get(helloInputCorrectAnchor).should("be.visible");
2304
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
2305
+
2306
+ cy.get(cesc("#\\/fruitInput_submit")).should("not.exist");
2307
+ cy.get(cesc("#\\/fruitInput_correct")).should("not.exist");
2308
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
2309
+ cy.get(cesc("#\\/sum3_submit")).should("not.exist");
2310
+ cy.get(cesc("#\\/sum3_correct")).should("not.exist");
2311
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
2312
+
2313
+ cy.get(cesc("#\\/subProblem_submit")).should("be.visible");
2314
+ cy.get(cesc("#\\/subProblem_correct")).should("not.exist");
2315
+ cy.get(cesc("#\\/subProblem_incorrect")).should("not.exist");
2316
+ cy.get(cesc("#\\/subProblem_partial")).should("not.exist");
2317
+
2318
+ cy.get(cesc("#\\/fruitInput")).contains(`banana`).click({ force: true });
2319
+ cy.get(cesc("#\\/subProblem_submit")).click();
2320
+
2321
+ cy.get(cesc("#\\/subProblem_submit")).should("not.exist");
2322
+ cy.get(cesc("#\\/subProblem_correct")).should("not.exist");
2323
+ cy.get(cesc("#\\/subProblem_incorrect")).should("not.exist");
2324
+ cy.get(cesc("#\\/subProblem_partial"))
2325
+ .invoke("text")
2326
+ .then((text) => {
2327
+ expect(text.trim().toLowerCase()).equal("50% correct");
2328
+ });
2329
+
2330
+ cy.get(cesc("#\\/n1") + " textarea").type("2{enter}", { force: true });
2331
+ cy.get(cesc("#\\/n2") + " textarea").type("1{enter}", { force: true });
2332
+
2333
+ cy.get(cesc("#\\/subProblem_submit")).should("be.visible");
2334
+ cy.get(cesc("#\\/subProblem_correct")).should("not.exist");
2335
+ cy.get(cesc("#\\/subProblem_incorrect")).should("not.exist");
2336
+ cy.get(cesc("#\\/subProblem_partial")).should("not.exist");
2337
+
2338
+ cy.get(cesc("#\\/subProblem_submit")).click();
2339
+
2340
+ cy.get(cesc("#\\/subProblem_submit")).should("not.exist");
2341
+ cy.get(cesc("#\\/subProblem_correct")).should("be.visible");
2342
+ cy.get(cesc("#\\/subProblem_incorrect")).should("not.exist");
2343
+ cy.get(cesc("#\\/subProblem_partial")).should("not.exist");
2344
+
2345
+ cy.log("switch to document wide checkwork");
2346
+
2347
+ cy.get(cesc("#\\/dwcw")).click();
2348
+ cy.get(cesc("#\\/dwcw_input")).should("be.checked");
2349
+
2350
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
2351
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
2352
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
2353
+
2354
+ cy.get(helloInputSubmitAnchor).should("not.exist");
2355
+ cy.get(helloInputCorrectAnchor).should("not.exist");
2356
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
2357
+
2358
+ cy.get(cesc("#\\/fruitInput_submit")).should("not.exist");
2359
+ cy.get(cesc("#\\/fruitInput_correct")).should("not.exist");
2360
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
2361
+
2362
+ cy.get(cesc("#\\/sum3_submit")).should("not.exist");
2363
+ cy.get(cesc("#\\/sum3_correct")).should("not.exist");
2364
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
2365
+
2366
+ cy.get(cesc("#\\/subProblem_submit")).should("not.exist");
2367
+ cy.get(cesc("#\\/subProblem_correct")).should("not.exist");
2368
+ cy.get(cesc("#\\/subProblem_incorrect")).should("not.exist");
2369
+ cy.get(cesc("#\\/subProblem_partial")).should("not.exist");
2370
+
2371
+ cy.get(cesc("#\\/theDocument_submit")).should("not.exist");
2372
+ cy.get(cesc("#\\/theDocument_correct")).should("be.visible");
2373
+ cy.get(cesc("#\\/theDocument_incorrect")).should("not.exist");
2374
+ cy.get(cesc("#\\/theDocument_partial")).should("not.exist");
2375
+
2376
+ cy.get(twoxInputAnchor).type("{end}{backspace}y{enter}", { force: true });
2377
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
2378
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
2379
+ cy.get(twoxInputIncorrectAnchor).should("not.exist");
2380
+
2381
+ cy.get(cesc("#\\/theDocument_submit")).should("be.visible");
2382
+ cy.get(cesc("#\\/theDocument_correct")).should("not.exist");
2383
+ cy.get(cesc("#\\/theDocument_incorrect")).should("not.exist");
2384
+ cy.get(cesc("#\\/theDocument_partial")).should("not.exist");
2385
+
2386
+ cy.get(cesc("#\\/theDocument_submit")).click();
2387
+ cy.get(cesc("#\\/theDocument_submit")).should("not.exist");
2388
+ cy.get(cesc("#\\/theDocument_correct")).should("not.exist");
2389
+ cy.get(cesc("#\\/theDocument_incorrect")).should("not.exist");
2390
+ cy.get(cesc("#\\/theDocument_partial"))
2391
+ .invoke("text")
2392
+ .then((text) => {
2393
+ expect(text.trim().toLowerCase()).equal("67% correct");
2394
+ });
2395
+
2396
+ cy.get(helloInputAnchor).type("2{enter}");
2397
+ cy.get(helloInputSubmitAnchor).should("not.exist");
2398
+ cy.get(helloInputCorrectAnchor).should("not.exist");
2399
+ cy.get(helloInputIncorrectAnchor).should("not.exist");
2400
+
2401
+ cy.get(cesc("#\\/theDocument_submit")).should("be.visible");
2402
+ cy.get(cesc("#\\/theDocument_correct")).should("not.exist");
2403
+ cy.get(cesc("#\\/theDocument_incorrect")).should("not.exist");
2404
+ cy.get(cesc("#\\/theDocument_partial")).should("not.exist");
2405
+
2406
+ cy.get(cesc("#\\/theDocument_submit")).click();
2407
+ cy.get(cesc("#\\/theDocument_submit")).should("not.exist");
2408
+ cy.get(cesc("#\\/theDocument_correct")).should("not.exist");
2409
+ cy.get(cesc("#\\/theDocument_incorrect")).should("not.exist");
2410
+ cy.get(cesc("#\\/theDocument_partial"))
2411
+ .invoke("text")
2412
+ .then((text) => {
2413
+ expect(text.trim().toLowerCase()).equal("33% correct");
2414
+ });
2415
+
2416
+ cy.log("turn off document wide checkwork");
2417
+
2418
+ cy.get(cesc("#\\/dwcw")).click();
2419
+ cy.get(cesc("#\\/dwcw_input")).should("not.be.checked");
2420
+
2421
+ cy.get(twoxInputSubmitAnchor).should("not.exist");
2422
+ cy.get(twoxInputCorrectAnchor).should("not.exist");
2423
+ cy.get(twoxInputIncorrectAnchor).should("be.visible");
2424
+
2425
+ cy.get(helloInputSubmitAnchor).should("not.exist");
2426
+ cy.get(helloInputCorrectAnchor).should("not.exist");
2427
+ cy.get(helloInputIncorrectAnchor).should("be.visible");
2428
+
2429
+ cy.get(cesc("#\\/fruitInput_submit")).should("not.exist");
2430
+ cy.get(cesc("#\\/fruitInput_correct")).should("not.exist");
2431
+ cy.get(cesc("#\\/fruitInput_incorrect")).should("not.exist");
2432
+
2433
+ cy.get(cesc("#\\/sum3_submit")).should("not.exist");
2434
+ cy.get(cesc("#\\/sum3_correct")).should("not.exist");
2435
+ cy.get(cesc("#\\/sum3_incorrect")).should("not.exist");
2436
+
2437
+ cy.get(cesc("#\\/subProblem_submit")).should("not.exist");
2438
+ cy.get(cesc("#\\/subProblem_correct")).should("be.visible");
2439
+ cy.get(cesc("#\\/subProblem_incorrect")).should("not.exist");
2440
+ cy.get(cesc("#\\/subProblem_partial")).should("not.exist");
2441
+
2442
+ cy.get(cesc("#\\/theDocument_submit")).should("not.exist");
2443
+ cy.get(cesc("#\\/theDocument_correct")).should("not.exist");
2444
+ cy.get(cesc("#\\/theDocument_incorrect")).should("not.exist");
2445
+ cy.get(cesc("#\\/theDocument_partial")).should("not.exist");
2446
+ });
2447
+ });
2448
+
2449
+ it("section wide checkwork, submit label", () => {
2450
+ cy.window().then(async (win) => {
2451
+ win.postMessage(
2452
+ {
2453
+ doenetML: `
2454
+ <text>a</text>
2455
+ <problem sectionWideCheckwork name="prob1">
2456
+ <answer name="ans1">x</answer>
2457
+ </problem>
2458
+ <problem sectionWideCheckwork name="prob2" submitLabel="Hit it!">
2459
+ <answer name="ans2">x</answer>
2460
+ </problem>
2461
+ <problem sectionWideCheckwork name="prob3" submitLabelNoCorrectness="Guess">
2462
+ <answer name="ans3">x</answer>
2463
+ </problem>
2464
+ <problem sectionWideCheckwork name="prob4" submitLabel="Hit it!" submitLabelNoCorrectness="Guess">
2465
+ <answer name="ans4">x</answer>
2466
+ </problem>
2467
+ `,
2468
+ },
2469
+ "*",
2470
+ );
2471
+ });
2472
+
2473
+ // to wait for page to load
2474
+ cy.get(cesc("#\\/_text1")).should("have.text", "a");
2475
+
2476
+ cy.window().then(async (win) => {
2477
+ let stateVariables = await win.returnAllStateVariables1();
2478
+
2479
+ let mathinput1Name =
2480
+ stateVariables["/ans1"].stateValues.inputChildren[0].componentName;
2481
+ let mathinput1Anchor = cesc2("#" + mathinput1Name) + " textarea";
2482
+
2483
+ let mathinput2Name =
2484
+ stateVariables["/ans2"].stateValues.inputChildren[0].componentName;
2485
+ let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea";
2486
+
2487
+ let mathinput3Name =
2488
+ stateVariables["/ans3"].stateValues.inputChildren[0].componentName;
2489
+ let mathinput3Anchor = cesc2("#" + mathinput3Name) + " textarea";
2490
+
2491
+ let mathinput4Name =
2492
+ stateVariables["/ans4"].stateValues.inputChildren[0].componentName;
2493
+ let mathinput4Anchor = cesc2("#" + mathinput4Name) + " textarea";
2494
+
2495
+ cy.get(cesc("#\\/prob1_submit"))
2496
+ .invoke("text")
2497
+ .then((text) => {
2498
+ expect(text.trim()).equal("Check Work");
2499
+ });
2500
+ cy.get(cesc("#\\/prob2_submit"))
2501
+ .invoke("text")
2502
+ .then((text) => {
2503
+ expect(text.trim()).equal("Hit it!");
2504
+ });
2505
+ cy.get(cesc("#\\/prob3_submit"))
2506
+ .invoke("text")
2507
+ .then((text) => {
2508
+ expect(text.trim()).equal("Check Work");
2509
+ });
2510
+ cy.get(cesc("#\\/prob4_submit"))
2511
+ .invoke("text")
2512
+ .then((text) => {
2513
+ expect(text.trim()).equal("Hit it!");
2514
+ });
2515
+
2516
+ cy.get(mathinput1Anchor).type("x{enter}", { force: true });
2517
+ cy.get(mathinput2Anchor).type("x{enter}", { force: true });
2518
+ cy.get(mathinput3Anchor).type("x{enter}", { force: true });
2519
+ cy.get(mathinput4Anchor).type("x{enter}", { force: true });
2520
+
2521
+ cy.get(cesc("#\\/prob1_submit")).click();
2522
+ cy.get(cesc("#\\/prob2_submit")).click();
2523
+ cy.get(cesc("#\\/prob3_submit")).click();
2524
+ cy.get(cesc("#\\/prob4_submit")).click();
2525
+
2526
+ cy.get(cesc("#\\/prob1_correct")).should("contain.text", "Correct");
2527
+ cy.get(cesc("#\\/prob2_correct")).should("contain.text", "Correct");
2528
+ cy.get(cesc("#\\/prob3_correct")).should("contain.text", "Correct");
2529
+ cy.get(cesc("#\\/prob4_correct")).should("contain.text", "Correct");
2530
+
2531
+ cy.get("#testRunner_toggleControls").click();
2532
+ cy.get("#testRunner_showCorrectness").click();
2533
+ cy.wait(100);
2534
+ cy.get("#testRunner_toggleControls").click();
2535
+
2536
+ cy.get(cesc("#\\/prob1_submit")).should(
2537
+ "contain.text",
2538
+ "Submit Response",
2539
+ );
2540
+ cy.get(cesc("#\\/prob2_submit")).should(
2541
+ "contain.text",
2542
+ "Submit Response",
2543
+ );
2544
+ cy.get(cesc("#\\/prob3_submit")).should("contain.text", "Guess");
2545
+ cy.get(cesc("#\\/prob4_submit")).should("contain.text", "Guess");
2546
+
2547
+ cy.get(cesc("#\\/prob1_submit"))
2548
+ .invoke("text")
2549
+ .then((text) => {
2550
+ expect(text.trim()).equal("Submit Response");
2551
+ });
2552
+ cy.get(cesc("#\\/prob2_submit"))
2553
+ .invoke("text")
2554
+ .then((text) => {
2555
+ expect(text.trim()).equal("Submit Response");
2556
+ });
2557
+ cy.get(cesc("#\\/prob3_submit"))
2558
+ .invoke("text")
2559
+ .then((text) => {
2560
+ expect(text.trim()).equal("Guess");
2561
+ });
2562
+ cy.get(cesc("#\\/prob4_submit"))
2563
+ .invoke("text")
2564
+ .then((text) => {
2565
+ expect(text.trim()).equal("Guess");
2566
+ });
2567
+
2568
+ cy.get(mathinput1Anchor).type("x{enter}", { force: true });
2569
+ cy.get(mathinput2Anchor).type("x{enter}", { force: true });
2570
+ cy.get(mathinput3Anchor).type("x{enter}", { force: true });
2571
+ cy.get(mathinput4Anchor).type("x{enter}", { force: true });
2572
+
2573
+ cy.get(cesc("#\\/prob1_submit")).click();
2574
+ cy.get(cesc("#\\/prob2_submit")).click();
2575
+ cy.get(cesc("#\\/prob3_submit")).click();
2576
+ cy.get(cesc("#\\/prob4_submit")).click();
2577
+
2578
+ cy.get(cesc("#\\/prob1_saved")).should("contain.text", "Response Saved");
2579
+ cy.get(cesc("#\\/prob2_saved")).should("contain.text", "Response Saved");
2580
+ cy.get(cesc("#\\/prob3_saved")).should("contain.text", "Response Saved");
2581
+ cy.get(cesc("#\\/prob4_saved")).should("contain.text", "Response Saved");
2582
+ });
2583
+ });
2584
+
2585
+ it("document wide checkwork, submit label", () => {
2586
+ cy.window().then(async (win) => {
2587
+ win.postMessage(
2588
+ {
2589
+ doenetML: `
2590
+ <document documentWideCheckwork name="doc" submitLabel="Hit it!" submitLabelNoCorrectness="Guess">
2591
+ <text>a</text>
2592
+ <answer name="ans1">x</answer>
2593
+ </document>
2594
+ `,
2595
+ },
2596
+ "*",
2597
+ );
2598
+ });
2599
+
2600
+ // to wait for page to load
2601
+ cy.get(cesc("#\\/_text1")).should("have.text", "a");
2602
+
2603
+ cy.window().then(async (win) => {
2604
+ let stateVariables = await win.returnAllStateVariables1();
2605
+
2606
+ let mathinput1Name =
2607
+ stateVariables["/ans1"].stateValues.inputChildren[0].componentName;
2608
+ let mathinput1Anchor = cesc2("#" + mathinput1Name) + " textarea";
2609
+
2610
+ cy.get(cesc("#\\/doc_submit"))
2611
+ .invoke("text")
2612
+ .then((text) => {
2613
+ expect(text.trim()).equal("Hit it!");
2614
+ });
2615
+
2616
+ cy.get(mathinput1Anchor).type("x{enter}", { force: true });
2617
+
2618
+ cy.get(cesc("#\\/doc_submit")).click();
2619
+
2620
+ cy.get(cesc("#\\/doc_correct")).should("contain.text", "Correct");
2621
+
2622
+ cy.get("#testRunner_toggleControls").click();
2623
+ cy.get("#testRunner_showCorrectness").click();
2624
+ cy.wait(100);
2625
+ cy.get("#testRunner_toggleControls").click();
2626
+
2627
+ cy.get(cesc("#\\/doc_submit")).should("contain.text", "Guess");
2628
+
2629
+ cy.get(cesc("#\\/doc_submit"))
2630
+ .invoke("text")
2631
+ .then((text) => {
2632
+ expect(text.trim()).equal("Guess");
2633
+ });
2634
+
2635
+ cy.get(mathinput1Anchor).type("x{enter}", { force: true });
2636
+
2637
+ cy.get(cesc("#\\/doc_submit")).click();
2638
+
2639
+ cy.get(cesc("#\\/doc_saved")).should("contain.text", "Response Saved");
2640
+ });
2641
+ });
2642
+
2643
+ it("maintain state while reloading problem", () => {
2644
+ let doenetML = `
2645
+ <text>a</text>
2646
+ <problem name="problem1" newNamespace>
2647
+ <variantControl numVariants="2" variantNames="apple banana" />
2648
+ <select assignNames="fruit" hide>
2649
+ <option selectForVariants="apple" newNamespace>
2650
+ <text name="name">apple</text>
2651
+ <text name="color">red</text>
2652
+ </option>
2653
+ <option selectForVariants="banana" newNamespace>
2654
+ <text name="name">banana</text>
2655
+ <text name="color">yellow</text>
2656
+ </option>
2657
+ </select>
2658
+ <p>Enter <copy target="fruit/name" assignNames="fruitName" />:
2659
+ <answer type="text">
2660
+ <textinput name="input1" />
2661
+ <award>$(fruit/name)</award>
2662
+ </answer>
2663
+ </p>
2664
+ <p>Enter $(fruit/color):
2665
+ <answer type="text">
2666
+ <textinput name="input2" />
2667
+ <award>$(fruit/color)</award>
2668
+ </answer>
2669
+ </p>
2670
+ </problem>
2671
+
2672
+ <p>Credit achieved: <copy prop="creditAchieved" target="_document1" assignNames="ca" /></p>
2673
+ `;
2674
+
2675
+ cy.get("#testRunner_toggleControls").click();
2676
+ cy.get("#testRunner_allowLocalState").click();
2677
+ cy.wait(100);
2678
+ cy.get("#testRunner_toggleControls").click();
2679
+
2680
+ cy.window().then(async (win) => {
2681
+ win.postMessage(
2682
+ {
2683
+ doenetML,
2684
+ requestedVariantIndex: 1,
2685
+ },
2686
+ "*",
2687
+ );
2688
+ });
2689
+
2690
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2691
+
2692
+ cy.get(cesc2("#/ca")).should("have.text", "0");
2693
+
2694
+ cy.get(cesc2("#/problem1/input1_input")).type("banana{enter}");
2695
+ cy.get(cesc2("#/problem1/input1_incorrect")).should("be.visible");
2696
+ cy.get(cesc2("#/ca")).should("have.text", "0");
2697
+
2698
+ cy.get(cesc2("#/problem1/input2_submit")).should("be.visible");
2699
+
2700
+ cy.wait(2000); // wait to make sure debounce save happened
2701
+
2702
+ cy.reload();
2703
+
2704
+ cy.window().then(async (win) => {
2705
+ win.postMessage(
2706
+ {
2707
+ doenetML,
2708
+ },
2709
+ "*",
2710
+ );
2711
+ });
2712
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2713
+
2714
+ cy.get(cesc2("#/problem1/input1_incorrect")).should("be.visible");
2715
+ cy.get(cesc2("#/problem1/input2_submit")).should("be.visible");
2716
+ cy.get(cesc2("#/ca")).should("have.text", "0");
2717
+
2718
+ cy.get(cesc2("#/problem1/input1_input")).clear().type("apple");
2719
+ cy.get(cesc2("#/problem1/input1_submit")).click();
2720
+ cy.get(cesc2("#/problem1/input1_correct")).should("be.visible");
2721
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
2722
+
2723
+ cy.get(cesc2("#/problem1/input2_input")).clear().type("yellow{enter}");
2724
+ cy.get(cesc2("#/problem1/input2_incorrect")).should("be.visible");
2725
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
2726
+
2727
+ cy.wait(2000); // wait to make sure debounce save happened
2728
+
2729
+ cy.reload();
2730
+
2731
+ cy.window().then(async (win) => {
2732
+ win.postMessage(
2733
+ {
2734
+ doenetML,
2735
+ },
2736
+ "*",
2737
+ );
2738
+ });
2739
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2740
+
2741
+ cy.get(cesc2("#/problem1/input1_correct")).should("be.visible");
2742
+ cy.get(cesc2("#/problem1/input2_incorrect")).should("be.visible");
2743
+ cy.get(cesc2("#/ca")).should("have.text", "0.5");
2744
+
2745
+ cy.get(cesc2("#/problem1/input2_input")).clear().type("red");
2746
+ cy.get(cesc2("#/problem1/input2_submit")).click();
2747
+ cy.get(cesc2("#/problem1/input2_correct")).should("be.visible");
2748
+ cy.get(cesc2("#/ca")).should("have.text", "1");
2749
+
2750
+ cy.wait(2000); // wait to make sure debounce save happened
2751
+
2752
+ cy.reload();
2753
+
2754
+ cy.window().then(async (win) => {
2755
+ win.postMessage(
2756
+ {
2757
+ doenetML,
2758
+ },
2759
+ "*",
2760
+ );
2761
+ });
2762
+ cy.get(cesc("#\\/_text1")).should("have.text", "a"); //wait for page to load
2763
+
2764
+ cy.get(cesc2("#/problem1/input1_correct")).should("be.visible");
2765
+ cy.get(cesc2("#/problem1/input2_correct")).should("be.visible");
2766
+ cy.get(cesc2("#/ca")).should("have.text", "1");
2767
+ });
2768
+ });