diff --git a/packages/doenetml-worker/src/test/answerValidation/errorInNumbers.test.ts b/packages/doenetml-worker/src/test/answerValidation/errorInNumbers.test.ts new file mode 100644 index 000000000..e4c6f5c9c --- /dev/null +++ b/packages/doenetml-worker/src/test/answerValidation/errorInNumbers.test.ts @@ -0,0 +1,497 @@ +import { describe, expect, it, vi } from "vitest"; +import { createTestCore, returnAllStateVariables } from "../utils/test-core"; +import { submitAnswer, updateMathInputValue } from "../utils/actions"; +import Core from "../../Core"; + +const Mock = vi.fn(); +vi.stubGlobal("postMessage", Mock); +vi.mock("hyperformula"); + +async function run_single_response_tests({ + doenetML, + responseCredits, +}: { + doenetML: string; + responseCredits: Record; +}) { + const core = await createTestCore({ doenetML }); + const stateVariables = await returnAllStateVariables(core); + const mathInputName = + stateVariables["/ans"].stateValues.inputChildren[0].componentName; + + for (let response in responseCredits) { + await submit_check({ + response, + creditAchieved: responseCredits[response], + core, + mathInputName, + }); + } + + async function submit_check({ + core, + response, + creditAchieved, + mathInputName, + }: { + core: Core; + response: string; + creditAchieved: number; + mathInputName: string; + }) { + await updateMathInputValue({ + latex: response, + name: mathInputName, + core, + }); + await submitAnswer({ name: "/ans", core }); + const stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/ans"].stateValues.creditAchieved).eq( + creditAchieved, + `For response ${response}`, + ); + } +} + +async function run_two_response_tests({ + doenetML, + responseCredits, +}: { + doenetML: string; + responseCredits: Record; +}) { + const core = await createTestCore({ doenetML }); + + for (let response in responseCredits) { + await submit_check({ + response, + creditAchieved: responseCredits[response], + core, + }); + } + + async function submit_check({ + core, + response, + creditAchieved, + }: { + core: Core; + response: string; + creditAchieved: number; + }) { + let [response1, response2] = response.split(","); + await updateMathInputValue({ + latex: response1, + name: "/mi1", + core, + }); + await updateMathInputValue({ + latex: response2, + name: "/mi2", + core, + }); + await submitAnswer({ name: "/ans", core }); + const stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/ans"].stateValues.creditAchieved).eq( + creditAchieved, + `For response ${response}`, + ); + } +} + +describe("Allow error in numbers validation tests", async () => { + it("expression with single number", async () => { + const doenetML = ` + + + log(32x+c) + + + + + `; + + let responseCredits = { + "\\log(32x+c)": 1, + "\\log(32.04x+c)": 0, + "\\log(32.01x+c)": 0.6, + "\\log(32.001x+c)": 0.8, + "\\log(32.0001x+c)": 1, + "\\log(31.9999x+c)": 1, + "\\log(31.999x+c)": 0.8, + "\\log(31.99x+c)": 0.6, + "\\log(31.9x+c)": 0, + }; + + await run_single_response_tests({ doenetML, responseCredits }); + }); + + it("expression with single number, absolute error", async () => { + let doenetML = ` + + + log(32x+c) + + + + + `; + + let responseCredits = { + "\\log(32x+c)": 1, + "\\log(32.002x+c)": 0, + "\\log(32.0005x+c)": 0.6, + "\\log(32.00005x+c)": 0.8, + "\\log(32.000005x+c)": 1, + "\\log(31.999995x+c)": 1, + "\\log(31.99995x+c)": 0.8, + "\\log(31.9995x+c)": 0.6, + "\\log(31.995x+c)": 0, + }; + + await run_single_response_tests({ doenetML, responseCredits }); + }); + + it("don't ignore exponents", async () => { + let doenetML1 = ` + + + 10x^2-4 + + `; + + let doenetML2 = ` + + + 10x^2-4 + + + `; + + let responseCredits1 = { + "10x^2-4": 1, + "10.002x^{2.0004}-4.0008": 0, // too large an error + "10.002x^{2.0002}-4.0008": 0, // too large an error if don't allow exponent error + "10.001x^{2.00005}-4.0004": 1, // shrink to allowable error in both cases + }; + + let responseCredits2 = { + "10x^2-4": 1, + "10.002x^{2.0004}-4.0008": 0, // too large an error + "10.002x^{2.0002}-4.0008": 1, // too large an error if don't allow exponent error + "10.001x^{2.00005}-4.0004": 1, // shrink to allowable error in both cases + }; + + await run_single_response_tests({ + doenetML: doenetML1, + responseCredits: responseCredits1, + }); + await run_single_response_tests({ + doenetML: doenetML2, + responseCredits: responseCredits2, + }); + }); + + it("symbolic, expression with single number", async () => { + const doenetML = ` + + + log(32x+c) + + + + + `; + + let responseCredits = { + "\\log(32x+c)": 1, + "\\log(32.04x+c)": 0, + "\\log(32.01x+c)": 0.6, + "\\log(32.001x+c)": 0.8, + "\\log(32.0001x+c)": 1, + "\\log(31.9999x+c)": 1, + "\\log(31.999x+c)": 0.8, + "\\log(31.99x+c)": 0.6, + "\\log(31.9x+c)": 0, + }; + + await run_single_response_tests({ doenetML, responseCredits }); + }); + + it("symbolic, expression with single number, absolute error", async () => { + let doenetML = ` + + + log(32x+c) + + + + + `; + + let responseCredits = { + "\\log(32x+c)": 1, + "\\log(32.002x+c)": 0, + "\\log(32.0005x+c)": 0.6, + "\\log(32.00005x+c)": 0.8, + "\\log(32.000005x+c)": 1, + "\\log(31.999995x+c)": 1, + "\\log(31.99995x+c)": 0.8, + "\\log(31.9995x+c)": 0.6, + "\\log(31.995x+c)": 0, + }; + + await run_single_response_tests({ doenetML, responseCredits }); + }); + + // Note: removed numeric version of the "complicated expression" tests + // as they randomly failed depending on samples used for numerical equality + it("symbolic, complicated expression with three numbers", async () => { + let doenetML = ` + + + 10000 exp(7x^2/(0.00003-sqrt(y))) + + + + + `; + + let responseCredits = { + "10000 \\exp(7x^2/(0.00003-\\sqrt{y}))": 1, // exact answer + "9999 \\exp(7x^2/(0.00003-\\sqrt{y}))": 0, // too large an error in first number + "10000 \\exp(7.0001x^2/(0.00003-\\sqrt{y}))": 0, // too large an error in second number + "10000 \\exp(7x^2/(0.0000300005-\\sqrt{y}))": 0, // too large an error in third number + "9999.91 \\exp(7.00005x^2/(0.0000300002-\\sqrt{y}))": 0.6, // partial credit error in each + "9999.991 \\exp(7.000005x^2/(0.00003000002-\\sqrt{y}))": 0.8, // higher partial credit error in each + "9999.9991 \\exp(7.0000005x^2/(0.000030000002-\\sqrt{y}))": 1, // acceptable error for full credit + }; + + await run_single_response_tests({ doenetML, responseCredits }); + }); + + it("symbolic, complicated expression with three numbers, absolute error", async () => { + let doenetML = ` + + + 10000 exp(7x^2/(0.00003-sqrt(y))) + + + + + `; + + let responseCredits = { + "10000 \\exp(7x^2/(0.00003-\\sqrt{y}))": 1, // exact answer + "9999.9999 \\exp(7x^2/(0.00003-\\sqrt{y}))": 0, // too large an error in first number + "10000 \\exp(7.00002x^2/(0.00003-\\sqrt{y}))": 0, // too large an error in second number + "10000 \\exp(7x^2/(0.00005-\\sqrt{y}))": 0, // too large an error in third number + "9999.999991 \\exp(7.000005x^2/(0.000032-\\sqrt{y}))": 0.6, // partial credit error in each + "9999.9999991 \\exp(7.0000005x^2/(0.0000302-\\sqrt{y}))": 0.8, // higher partial credit error in each + "9999.99999991 \\exp(7.00000005x^2/(0.00003002-\\sqrt{y}))": 1, // acceptable error for full credit + }; + + await run_single_response_tests({ doenetML, responseCredits }); + }); + + it("symbolic, don't ignore exponents", async () => { + let doenetML1 = ` + + + 10x^2-4 + + `; + + let doenetML2 = ` + + + 10x^2-4 + + + `; + + let responseCredits1 = { + "10x^2-4": 1, // exact answer + "10x^{2.0004}-4": 0, // too large an error in exponent + "10x^{2.0001}-4": 0, // small error in exponent + "10.0002x^2-4.00008": 1, // error in numbers not in exponents + }; + + let responseCredits2 = { + "10x^2-4": 1, // exact answer + "10x^{2.0004}-4": 0, // too large an error in exponent + "10x^{2.0001}-4": 1, // small error in exponent + "10.0002x^2-4.00008": 1, // error in numbers not in exponents + }; + + await run_single_response_tests({ + doenetML: doenetML1, + responseCredits: responseCredits1, + }); + await run_single_response_tests({ + doenetML: doenetML2, + responseCredits: responseCredits2, + }); + }); + + it("symbolic, no simplification", async () => { + let doenetML = ` + + 2.15234262pi+e*25.602348230 + + `; + + let responseCredits = { + "2.15234262\\pi+e 25.602348230": 1, // exact answer + "\\pi 2.15234262+e*25.602348230": 0, // Reordering not allowed + "e 25.602348230 + 2.15234262\\pi": 0, + ".35618172248981": 0, // Numeric evaluation not allowed + "2.16\\pi+e 25.602348230": 0, // Round too much + "2.15234262\\pi+2.73 25.602348230": 0, + "2.152 3.142+2.718 25.6": 1, // acceptable rounding + }; + + await run_single_response_tests({ doenetML, responseCredits }); + }); + + it("symbolic, evaluate numbers, preserve order", async () => { + let doenetML = ` + + sin(2pi+1x+4x+pi+6) + + `; + + let responseCredits = { + "\\sin(2\\pi+1x+4x+\\pi+6)": 1, // exact answer + "\\sin(2\\pi+\\pi+1x+4x+6)": 0, // Reordering not allowed + "\\sin(2\\pi+5x+\\pi+6)": 0, // Combining terms not allowed + "\\sin(6.28318+x+4x+9.14159)": 1, // Numeric evaluation OK + "\\sin(6.28318+x+4x+9.13)": 0, // Round too much + "\\sin(6.27+x+4x+9.14159)": 0, // Round too much + }; + + await run_single_response_tests({ doenetML, responseCredits }); + }); + + it("symbolic, evaluate numbers", async () => { + let doenetML = ` + + sin(2pi+1x+4x+pi+6) + + `; + + let responseCredits = { + "\\sin(2\\pi+1x+4x+\\pi+6)": 1, // exact answer + "\\sin(2\\pi+\\pi+1x+x*4+6)": 1, // Reordering allowed + "\\sin(2\\pi+5x+\\pi+6)": 0, // Combining terms not allowed + "\\sin(6.28318+x+4x+9.14159)": 1, // Numeric evaluation OK + "\\sin(x+15.42478+4x)": 1, + "\\sin(x+15.4+4x)": 0, // Round too much + }; + + await run_single_response_tests({ doenetML, responseCredits }); + }); + + it("symbolic, full simplification", async () => { + let doenetML = ` + + sin(2pi+1x+4x+pi+6) + + `; + + let responseCredits = { + "\\sin(2\\pi+1x+4x+\\pi+6)": 1, // exact answer + "\\sin(2\\pi+\\pi+1x+x*4+6)": 1, // Reordering allowed + "\\sin(2\\pi+5x+\\pi+6)": 1, // Combining terms allowed + "\\sin(6.28318+x+4x+9.14159)": 1, // Numeric evaluation OK + "\\sin(x+15.42478+4x)": 1, + "\\sin(x+15.4+4x)": 0, // Round too much + }; + + await run_single_response_tests({ doenetML, responseCredits }); + }); + + it("expression with vector, matchPartial", async () => { + let doenetML = ` + + (log(32x+c), 42) + + `; + + let responseCredits = { + "(\\log(32x+c), 42)": 1, // exact answer + "(\\log(32.04x+c), 42)": 0.5, // too large an error in first component + "(\\log(32.04x+c), 42.3)": 0, // too large an error in both components + "(\\log(32.01x+c), 42.3)": 0.5, // shrink error in first component + "(\\log(32.01x+c), 42.03)": 1, // shrink error in second component + "(42, \\log(32x+c))": 0.5, // order matters, so just one component matches + }; + + await run_single_response_tests({ doenetML, responseCredits }); + }); + + it("expression with vector, matchPartial, unordered", async () => { + let doenetML = ` + + (log(32x+c), 42) + + `; + + let responseCredits = { + "(42, \\log(32x+c))": 1, // exact answer + "(42, \\log(32.04x+c))": 0.5, // too large an error in first component + "(42.3, \\log(32.04x+c))": 0, // too large an error in both components + "(42.3, \\log(32.01x+c))": 0.5, // shrink error in first component + "(42.03, \\log(32.01x+c))": 1, // shrink error in second component + "(\\log(32x+c), 42)": 1, // order doesn't matter + }; + + await run_single_response_tests({ doenetML, responseCredits }); + }); + + it("expression with math lists, matchPartial", async () => { + let doenetML = ` + + + + + $mi1 $mi2 = log(32x+c) 42 + + + `; + + let responseCredits = { + "\\log(32x+c),42": 1, // exact answer + "\\log(32.04x+c),42": 0.5, // too large an error in first component + "\\log(32.04x+c),42.3": 0, // too large an error in both components + "\\log(32.01x+c),42.3": 0.5, // shrink error in first component + "\\log(32.01x+c),42.03": 1, // shrink error in second component + "42,\\log(32x+c),": 0.5, // order matters, so just one component matches + }; + + await run_two_response_tests({ doenetML, responseCredits }); + }); + + it("expression with math lists, matchPartial, unordered", async () => { + let doenetML = ` + + + + + $mi1 $mi2 = log(32x+c) 42 + + + `; + + let responseCredits = { + "42,\\log(32x+c)": 1, // exact answer + "42,\\log(32.04x+c)": 0.5, // too large an error in first component + "42.3,\\log(32.04x+c)": 0, // too large an error in both components + "42.3,\\log(32.01x+c)": 0.5, // shrink error in first component + "42.03,\\log(32.01x+c)": 1, // shrink error in second component + "\\log(32x+c),42": 1, // order doesn't matter + }; + + await run_two_response_tests({ doenetML, responseCredits }); + }); +}); diff --git a/packages/doenetml-worker/src/test/answerValidation/factoring.test.ts b/packages/doenetml-worker/src/test/answerValidation/factoring.test.ts new file mode 100644 index 000000000..40a082ce6 --- /dev/null +++ b/packages/doenetml-worker/src/test/answerValidation/factoring.test.ts @@ -0,0 +1,355 @@ +import { describe, expect, it, vi } from "vitest"; +import { createTestCore, returnAllStateVariables } from "../utils/test-core"; +import { submitAnswer, updateMathInputValue } from "../utils/actions"; +import Core from "../../Core"; + +const Mock = vi.fn(); +vi.stubGlobal("postMessage", Mock); +vi.mock("hyperformula"); + +function createDoenetML( + factoredString: string, + partialFactoredString?: string, +) { + function createAward({ + partial = false, + mode = "D", + }: { partial?: boolean; mode?: "D" | "RD" | "MM" | "SD" } = {}) { + let modeString = ""; + if (mode === "RD") { + modeString = "restrictDivision "; + } else if (mode === "MM") { + modeString = "monomialFactorMustMatch"; + } else if (mode === "SD") { + modeString = "allowOnlySignDifferences"; + } + + return ` + + + $resp${partial ? "$partialFactor" : "$poly"} + + + `; + } + + return ` + + ${factoredString} + $poly + ${ + partialFactoredString + ? `${partialFactoredString}` + : "" + } + + +

Question: Factor the polynomial $polyExpandSimplify.

+ +

Answer

+ +

Default setting: + ${createAward()} + ${partialFactoredString ? createAward({ partial: true }) : ""} +

+

Restrict division: + ${createAward({ mode: "RD" })} + ${partialFactoredString ? createAward({ mode: "RD", partial: true }) : ""} +

+

Monomial factor must match: + ${createAward({ mode: "MM" })} + ${partialFactoredString ? createAward({ mode: "MM", partial: true }) : ""} +

+

Allow only sign differences in factors: + ${createAward({ mode: "SD" })} + ${partialFactoredString ? createAward({ mode: "SD", partial: true }) : ""} +

+

Normal equality: + $resp=$poly +

+ `; +} + +const answers = ["D", "RD", "MM", "SD", "E"]; + +async function run_tests({ + factoredString, + partialFactoredString, + responseCredits, +}: { + factoredString: string; + partialFactoredString?: string; + responseCredits: Record< + string, + { + D: number; + RD: number; + MM: number; + SD: number; + E: number; + } + >; +}) { + const core = await createTestCore({ + doenetML: createDoenetML(factoredString, partialFactoredString), + }); + + for (let response in responseCredits) { + await submit_check({ + response, + creditAchieved: responseCredits[response], + core, + }); + } + + async function submit_check({ + core, + response, + creditAchieved, + }: { + core: Core; + response: string; + creditAchieved: { + D: number; + RD: number; + MM: number; + SD: number; + E: number; + }; + }) { + await updateMathInputValue({ + latex: response, + name: "/resp", + core, + }); + for (let ans of answers) { + await submitAnswer({ name: `/check${ans}`, core }); + } + const stateVariables = await returnAllStateVariables(core); + for (let ans of answers) { + expect( + stateVariables[`/check${ans}`].stateValues.creditAchieved, + ).eq(creditAchieved[ans], `${ans} credit for response ${response}`); + } + } +} + +describe("factor polynomial tests", async () => { + it("factor x^2-1", async () => { + let factoredString = "(x-1)(x+1)"; + + let responseCredits = { + "x^2-1": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "(2x^2-2)/2": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "(x-1)(x+1)": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "(1-x)(x+1)": { D: 0, RD: 0, MM: 0, SD: 0, E: 0 }, + "-(1-x)(x+1)": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "(1-x)(-1-x)": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "-(1-x)(-1-x)": { D: 0, RD: 0, MM: 0, SD: 0, E: 0 }, + "-(x-1)(-1-x)": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "(x^2-1)x/x": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "(x^2-1)5/5": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "((x-1)(x+1))": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "(2x-2)(x+1)/2": { D: 1, RD: 0, MM: 0, SD: 0, E: 1 }, + "(2x-2)(x+1)(1/2)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "1/2(2x-2)(x+1)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "0.5(2x-2)(x+1)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "0.25(2x-2)(2x+2)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "\\sqrt{x^2-1}^2": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "\\sqrt{2x^2-2}\\sqrt{(x^2-1)/2}": { + D: 0, + RD: 0, + MM: 0, + SD: 0, + E: 1, + }, + "\\sqrt{4x^2-4}\\sqrt{x^2-1}/2": { + D: 0, + RD: 0, + MM: 0, + SD: 0, + E: 1, + }, + "(x^2-1)(\\cos^2 x+\\sin^2 x)": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "(x-1)(x+1)(\\cos^2 x+\\sin^2 x)/(\\cos^2 x+\\sin^2 x)": { + D: 0, + RD: 0, + MM: 0, + SD: 0, + E: 1, + }, + "(x/3-1/3)(3x+3)": { D: 1, RD: 1, MM: 1, SD: 0, E: 1 }, + }; + + await run_tests({ + factoredString, + responseCredits, + }); + }); + + it("factor 4x^2-4", async () => { + let factoredString = "4(x-1)(x+1)"; + + let responseCredits = { + "4x^2-4": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "4(1-x)(x+1)": { D: 0, RD: 0, MM: 0, SD: 0, E: 0 }, + "4(1-x)(-1-x)": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "-4(1-x)(1+x)": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "(1-x)(1+x)(-4)": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "4(2x-2)(1/2+x/2)": { D: 1, RD: 1, MM: 1, SD: 0, E: 1 }, + "2(1-x)(1+x)(-2)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "(2x-2)(x+1)2": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "2(x-1)(2x+2)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "(3x-3)(8x+8)/6": { D: 1, RD: 0, MM: 0, SD: 0, E: 1 }, + "(3x-3)(8x+8)(1/6)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "(6x-6)(8x+8)(1/6)": { D: 0, RD: 0, MM: 0, SD: 0, E: 0 }, + "0.5(6x-6)(4x+4)(1/3)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + }; + + await run_tests({ + factoredString, + responseCredits, + }); + }); + + it("factor (6z-4)(5z+10)", async () => { + let factoredString = "(6z-4)(5z+10)"; + + let responseCredits = { + "30z^2+40z-40": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "(6z-4)(5z+10)": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "-(4-6z)(5z+10)": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "(30z-20)(z+2)": { D: 1, RD: 1, MM: 1, SD: 0, E: 1 }, + "-(2-3z)(10z+20)": { D: 1, RD: 1, MM: 1, SD: 0, E: 1 }, + "5(6z-4)(z+2)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "5(4-6z)(z+2)": { D: 0, RD: 0, MM: 0, SD: 0, E: 0 }, + "5(2-3z)(z+2)(-2)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "15(2-3z)(z+2)(-2)(1/3)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "15(2-3z)(z+2)(-2)/3": { D: 1, RD: 0, MM: 0, SD: 0, E: 1 }, + "15(2-3z)3(z+2)(-2)/9": { D: 1, RD: 0, MM: 0, SD: 0, E: 1 }, + "15(2-3z)3(z+2)(-2)(1/9)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + }; + + await run_tests({ + factoredString, + responseCredits, + }); + }); + + it("factor (6z-4)(z+2)5", async () => { + let factoredString = "(6z-4)(z+2)5"; + + let responseCredits = { + "30z^2+40z-40": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "(6z-4)(5z+10)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "5(6z-4)(z+2)": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "5(3z-2)(2z+4)": { D: 1, RD: 1, MM: 1, SD: 0, E: 1 }, + "5(4-6z)(z+2)": { D: 0, RD: 0, MM: 0, SD: 0, E: 0 }, + "5(2-3z)(z+2)(-2)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "15(2-3z)(z+2)(-2)(1/3)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "15(2-3z)(z+2)(-2)/3": { D: 1, RD: 0, MM: 0, SD: 0, E: 1 }, + "15(2-3z)3(z+2)(-2)/9": { D: 1, RD: 0, MM: 0, SD: 0, E: 1 }, + "15(2-3z)3(z+2)(-2)(1/9)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + }; + + await run_tests({ + factoredString, + responseCredits, + }); + }); + + it("factor (2x+4)^2", async () => { + let factoredString = "(2x+4)^2"; + + let responseCredits = { + "4x^2+16x+16": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "4(x^2+4x+4)": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "4(x+2)(x+2)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "4(x+2)^2": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "(2x+4)^2": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "(2(x+2))^2": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "(x+4+x)^2": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "(4x+8)(x+2)": { D: 1, RD: 1, MM: 1, SD: 0, E: 1 }, + "4\\sqrt{x^2+4x+4}^2": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "\\sqrt{4x^2+16x+16}^2": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + }; + + await run_tests({ + factoredString, + responseCredits, + }); + }); + + it("factor 2^2(x+2)^2", async () => { + let factoredString = "2^2(x+2)^2"; + + let responseCredits = { + "4x^2+16x+16": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "4(x^2+4x+4)": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "4(x+2)(x+2)": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "4(x+2)^2": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "(2x+4)^2": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "(2(x+2))^2": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "(x+4+x)^2": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "(4x+8)(x+2)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "4\\sqrt{x^2+4x+4}^2": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "\\sqrt{4x^2+16x+16}^2": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "4(2x+4)(x/2+1)": { D: 1, RD: 1, MM: 1, SD: 0, E: 1 }, + }; + + await run_tests({ + factoredString, + responseCredits, + }); + }); + + it("factor (x-1/2)(x+1)", async () => { + let factoredString = "(x-1/2)(x+1)"; + + let responseCredits = { + "x^2+x/2-1/2": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "(x+1)(x-1/2)": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "(x+1)(2x-1)/2": { D: 1, RD: 0, MM: 0, SD: 0, E: 1 }, + "(x+1)(2x-1)(1/2)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "-(x+1)(1-2x)(1/2)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "(x+1)(1-2x)(1/2)": { D: 0, RD: 0, MM: 0, SD: 0, E: 0 }, + "(x+1)(-1)(1-2x)(1/2)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "(x+1)(1-2x)(-\\frac{1}{2})": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "(x+1)(1-2x)(\\frac{-1}{2})": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "(x+1)(1-2x)(\\frac{1}{-2})": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "-(x+1)(2x-1)(-\\frac{1}{2})": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + "-(x+1)(1/2-x)": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "(x+1)(1)(x-1/2)": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "(x+1)(-1)(1/2-x)": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "(x/2+1/2)(2x-1)": { D: 1, RD: 1, MM: 1, SD: 0, E: 1 }, + "(x/2+1/2)(-1)(1-2x)": { D: 1, RD: 1, MM: 1, SD: 0, E: 1 }, + }; + + await run_tests({ + factoredString, + responseCredits, + }); + }); + + it("factor (x-1)(x+1)^2", async () => { + let factoredString = "(x-1)(x+1)^2"; + let partialFactoredString = "(x+1)(x^2-1)"; + + let responseCredits = { + "x^3+x^2-x-1": { D: 0, RD: 0, MM: 0, SD: 0, E: 1 }, + "(x-1)(x+1)^2": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "(x+1)(x-1)(x+1)": { D: 1, RD: 1, MM: 1, SD: 1, E: 1 }, + "(x^2-1)(x+1)": { D: 0.5, RD: 0.5, MM: 0.5, SD: 0.5, E: 1 }, + "(1/4*x-1/4)(2x+2)^2": { D: 1, RD: 1, MM: 1, SD: 0, E: 1 }, + "(x-1)(x^2+2x+1)": { D: 0.5, RD: 0.5, MM: 0.5, SD: 0, E: 1 }, + "2(x+1)(x-1)(x+1)/2": { D: 1, RD: 0, MM: 0, SD: 0, E: 1 }, + "2(x+1)(x-1)(x+1)(1/2)": { D: 1, RD: 1, MM: 0, SD: 0, E: 1 }, + }; + + await run_tests({ + factoredString, + partialFactoredString, + responseCredits, + }); + }); +}); diff --git a/packages/doenetml-worker/src/test/answerValidation/factoringOldAlgorithm.test.ts b/packages/doenetml-worker/src/test/answerValidation/factoringOldAlgorithm.test.ts new file mode 100644 index 000000000..967df7404 --- /dev/null +++ b/packages/doenetml-worker/src/test/answerValidation/factoringOldAlgorithm.test.ts @@ -0,0 +1,236 @@ +import { describe, expect, it, vi } from "vitest"; +import { createTestCore, returnAllStateVariables } from "../utils/test-core"; +import { submitAnswer, updateMathInputValue } from "../utils/actions"; +import Core from "../../Core"; + +const Mock = vi.fn(); +vi.stubGlobal("postMessage", Mock); +vi.mock("hyperformula"); + +function createDoenetML(polyString: string) { + return ` + + ${polyString} + $poly + $resp + $resp + $respSimplify + - + * + / + ^ + + + + + $respSimplify + $temp + + $respSimplify $originalOperator + + + + $respNoMinus + $respNoMinus + $temp2 + + $respNoMinus 1 $postMinusOperator + + $numerator + $numerator + + + $numerator + $temp3 + + $numerator $numeratorOperator + + + +

Question: Factor the polynomial $polyExpandSimplify.

+ +

Answer

+ + + + + $respExpandSimplify = $polyExpandSimplify + and + ( + ( + $innerOperator = $pow + and + $innerPiece = $add + ) + or + $innerOperator = $mult + and + $denominator + and + ( + $innerPiece = 3 + or + not $innerPiece + ) + ) + + + `; +} + +const answers = ["D", "RD", "MM", "SD", "E"]; + +async function run_tests({ + polyString, + responseCredits, +}: { + polyString: string; + responseCredits: { response: string; credit: number }[]; +}) { + const core = await createTestCore({ + doenetML: createDoenetML(polyString), + }); + + for (let responseObj of responseCredits) { + await submit_check({ + response: responseObj.response, + creditAchieved: responseObj.credit, + core, + }); + } + + async function submit_check({ + core, + response, + creditAchieved, + }: { + core: Core; + response: string; + creditAchieved: number; + }) { + await updateMathInputValue({ + latex: response, + name: "/resp", + core, + }); + await submitAnswer({ name: `/check`, core }); + const stateVariables = await returnAllStateVariables(core); + expect(stateVariables[`/check`].stateValues.creditAchieved).eq( + creditAchieved, + `credit for response ${response}`, + ); + } +} + +// Note: even through have a better factoring test, +// we are keeping these tests, as they probe how well +// we can handle components that change type +// (due to the multiple conditionalContents that are copied) + +describe("factor polynomial tests, old algorithm", async () => { + it("factor x^2-1", async () => { + let polyString = "x^2-1"; + + let responseCredits = [ + { response: "x^2-1", credit: 0 }, + { response: "(2x^2-2)/2", credit: 0 }, + { response: "(x-1)(x+1)", credit: 1 }, + { response: "(1-x)(x+1)", credit: 0 }, + { response: "-(1-x)(x+1)", credit: 1 }, + // swap minus signs a few times to verify bug from changing component types is fixed + { response: "(1-x)(x+1)", credit: 0 }, + { response: "-(1-x)(x+1)", credit: 1 }, + { response: "(1-x)(x+1)", credit: 0 }, + { response: "-(1-x)(x+1)", credit: 1 }, + { response: "(1-x)(x+1)", credit: 0 }, + { response: "-(1-x)(x+1)", credit: 1 }, + { response: "(1-x)(-1-x)", credit: 1 }, + { response: "-(1-x)(-1-x)", credit: 0 }, + { response: "-(x-1)(-1-x)", credit: 1 }, + { response: "(x^2-1)x/x", credit: 0 }, + { response: "(x^2-1)5/5", credit: 0 }, + { response: "((x-1)(x+1))", credit: 1 }, + { response: "(2x-2)(x+1)/2", credit: 1 }, + { response: "1/2(2x-2)(x+1)", credit: 1 }, + { response: "0.5(2x-2)(x+1)", credit: 1 }, + { response: "0.25(2x-2)(2x+2)", credit: 1 }, + { response: "\\sqrt{x^2-1}^2", credit: 0 }, + { response: "\\sqrt{2x^2-2}\\sqrt{(x^2-1)/2}", credit: 0 }, + { response: "\\sqrt{4x^2-4}\\sqrt{x^2-1}/4", credit: 0 }, + ]; + + await run_tests({ polyString, responseCredits }); + }); + + it("factor 4x^2-4", async () => { + let polyString = "4x^2-4"; + + let responseCredits = [ + { response: "4x^2-4", credit: 0 }, + { response: "4(x-1)(x+1)", credit: 1 }, + { response: "4(1-x)(x+1)", credit: 0 }, + { response: "4(1-x)(-1-x)", credit: 1 }, + { response: "-4(1-x)(1+x)", credit: 1 }, + { response: "(1-x)(1+x)(-4)", credit: 1 }, + { response: "2(1-x)(1+x)(-2)", credit: 1 }, + { response: "(2x-2)(x+1)2", credit: 1 }, + { response: "2(x-1)(2x+2)", credit: 1 }, + { response: "(3x-3)(8x+8)/6", credit: 1 }, + { response: "(6x-6)(8x+8)/6", credit: 0 }, + { response: "0.5(6x-6)(4x+4)/3", credit: 1 }, + ]; + + await run_tests({ polyString, responseCredits }); + }); + + it("factor (6z-4)(5z+10)", async () => { + let polyString = "(6z-4)(5z+10)"; + + let responseCredits = [ + { response: "30z^2+40z-40", credit: 0 }, + { response: "(6z-4)(5z+10)", credit: 1 }, + { response: "5(6z-4)(z+2)", credit: 1 }, + { response: "5(4-6z)(z+2)", credit: 0 }, + { response: "5(2-3z)(z+2)(-2)", credit: 1 }, + { response: "15(2-3z)(z+2)(-2)/3", credit: 1 }, + { response: "15(2-3z)3(z+2)(-2)/9", credit: 1 }, + ]; + + await run_tests({ polyString, responseCredits }); + }); + + it("factor (3q+2r)(6s+8t)", async () => { + let polyString = "(3q+2r)(6s+8t)"; + + let responseCredits = [ + { response: "18qs+24qt+12rs+16rt", credit: 0 }, + { response: "(3q+2r)(6s+8t)", credit: 1 }, + { response: "3q(6s+8t) + 2r(6s+8t)", credit: 0 }, + { response: "(6s+8t)(3q+2r)", credit: 1 }, + { response: "(8t+6s)(3q+2r)", credit: 1 }, + { response: "(8t+6s)(2r+3q)", credit: 1 }, + { response: "(8t+6s)(2r+q+q+q)", credit: 1 }, + { response: "(4t+3s)2(2r+3q)", credit: 1 }, + ]; + + await run_tests({ polyString, responseCredits }); + }); + + it("factor (2x+4)^2", async () => { + let polyString = "(2x+4)^2"; + + let responseCredits = [ + { response: "4x^2+16x+16", credit: 0 }, + { response: "4(x^2+4x+4)", credit: 0 }, + { response: "4(x+2)(x+2)", credit: 1 }, + { response: "4(x+2)^2", credit: 1 }, + { response: "(2x+4)^2", credit: 1 }, + { response: "(2(x+2))^2", credit: 1 }, + { response: "(x+4+x)^2", credit: 1 }, + { response: "(4x+8)(x+2)", credit: 1 }, + { response: "4\\sqrt{x^2+4x+4}^2", credit: 0 }, + { response: "\\sqrt{4x^2+16x+16}^2", credit: 0 }, + ]; + + await run_tests({ polyString, responseCredits }); + }); +}); diff --git a/packages/doenetml-worker/src/test/answerValidation/functionAnswers.test.ts b/packages/doenetml-worker/src/test/answerValidation/functionAnswers.test.ts new file mode 100644 index 000000000..8490d951a --- /dev/null +++ b/packages/doenetml-worker/src/test/answerValidation/functionAnswers.test.ts @@ -0,0 +1,138 @@ +import { describe, expect, it, vi } from "vitest"; +import { createTestCore, returnAllStateVariables } from "../utils/test-core"; +import { submitAnswer, updateMathInputValue } from "../utils/actions"; + +const Mock = vi.fn(); +vi.stubGlobal("postMessage", Mock); +vi.mock("hyperformula"); + +describe("function answer validation tests", async () => { + it("simple function of input", async () => { + let responseCredits = { + "": 0, + "7": 1, + "0": 1, + "-14": 1, + "33": 1, + "-102351": 1, + "9.5": 0, + "x^2": 0, + "-253.3": 0, + "23.6": 0, + "11.9": Math.cos(2 * Math.PI * 0.1), + "73.15": Math.cos(2 * Math.PI * 0.15), + "-103.8": Math.cos(2 * Math.PI * 0.2), + "-0.05": Math.cos(2 * Math.PI * 0.05), + }; + + let core = await createTestCore({ + doenetML: ` + cos(2*pi*x) + +

Enter a number close to an integer: + + + + true + + +

`, + }); + + for (let response in responseCredits) { + await updateMathInputValue({ + latex: response, + name: "/x", + core, + }); + await submitAnswer({ name: "/ans", core }); + let stateVariables = await returnAllStateVariables(core); + expect(stateVariables["/ans"].stateValues.creditAchieved).closeTo( + responseCredits[response], + 1e-12, + ); + } + }); + + it("function with parameters", async () => { + let core = await createTestCore({ + doenetML: ` +

Offset:

+

Period:

+

Magnitude

+ $magnitude cos(2*pi*(x-$offset)/$period) +

Enter a number: + + + + true + + +

+ `, + }); + + let offsets = [Math.E]; + let periods = [2, Math.PI / 2]; + let magnitudes = [0.5, 2]; + + let partialCredit = (o, p, m, x) => + Math.max(0, Math.min(1, m * Math.cos((2 * Math.PI * (x - o)) / p))); + + let numberResponses = [Math.E, 0, 2 / 3, -Math.PI / 2, -252351.9]; + + for (let offset of offsets) { + await updateMathInputValue({ + latex: `${offset}`, + name: "/offset", + core, + }); + for (let period of periods) { + await updateMathInputValue({ + latex: `${period}`, + name: "/period", + core, + }); + for (let magnitude of magnitudes) { + await updateMathInputValue({ + latex: `${magnitude}`, + name: "/magnitude", + core, + }); + + let maximals = [ + offset, + offset + 2 * period, + offset - 7 * period, + ]; + let minimals = [ + offset + 1.5 * period, + offset + 5.5 * period, + offset - 7.5 * period, + ]; + + for (let response of [ + ...maximals, + ...minimals, + ...numberResponses, + ]) { + await updateMathInputValue({ + latex: `${response}`, + name: "/x", + core, + }); + await submitAnswer({ name: "/ans", core }); + let stateVariables = + await returnAllStateVariables(core); + expect( + stateVariables["/ans"].stateValues.creditAchieved, + ).closeTo( + partialCredit(offset, period, magnitude, response), + 1e-12, + ); + } + } + } + } + }); +}); diff --git a/packages/doenetml-worker/src/test/answerValidation/matchPartial.test.ts b/packages/doenetml-worker/src/test/answerValidation/matchPartial.test.ts new file mode 100644 index 000000000..0c3584d05 --- /dev/null +++ b/packages/doenetml-worker/src/test/answerValidation/matchPartial.test.ts @@ -0,0 +1,1463 @@ +import { describe, expect, it, vi } from "vitest"; +import { createTestCore, returnAllStateVariables } from "../utils/test-core"; +import { + submitAnswer, + updateBooleanInputValue, + updateMathInputValue, + updateTextInputValue, +} from "../utils/actions"; + +const Mock = vi.fn(); +vi.stubGlobal("postMessage", Mock); +vi.mock("hyperformula"); + +async function run_tests({ + doenetML, + responseCredits, + type = "math", +}: { + doenetML: string; + responseCredits: { + responses: Record; + credits: Record; + }[]; + type?: "math" | "text" | "boolean"; +}) { + const core = await createTestCore({ doenetML }); + + for (let responseObj of responseCredits) { + await submit_check(responseObj); + } + + async function submit_check({ + responses, + credits, + }: { + responses: Record; + credits: Record; + }) { + for (let name in responses) { + if (type === "math") { + await updateMathInputValue({ + latex: `${responses[name]}`, + name, + core, + }); + } else if (type === "text") { + await updateTextInputValue({ + text: `${responses[name]}`, + name, + core, + }); + } else if (type === "boolean") { + await updateBooleanInputValue({ + boolean: Boolean(responses[name]), + name, + core, + }); + } + } + for (let code in credits) { + await submitAnswer({ name: `/ans${code}`, core }); + } + const stateVariables = await returnAllStateVariables(core); + for (let code in credits) { + expect(stateVariables[`/ans${code}`].stateValues.creditAchieved).eq( + credits[code], + `${code} credit for response ${JSON.stringify(responses)}`, + ); + } + } +} + +async function run_ordered_unordered_tests({ + doenetML, + delimiters, +}: { + doenetML: string; + delimiters: string[]; +}) { + function make_response(resp: string) { + return delimiters[0] + resp + delimiters[1]; + } + function make_alt_response(resp: string, i: number) { + if (delimiters[0] === "(") { + if (i === 1) { + return "[" + resp + "]"; + } else { + return resp; + } + } else if (delimiters[0] === "[") { + if (i === 1) { + return "(" + resp + ")"; + } else { + return resp; + } + } else { + if (i === 1) { + return "(" + resp + ")"; + } else { + return "[" + resp + "]"; + } + } + } + + await run_tests({ + doenetML, + responseCredits: [ + { + responses: { "/resp": "" }, + credits: { P: 0, PEP: 0, PU: 0, S: 0, U: 0 }, + }, + { + responses: { "/resp": make_response("1,2,3") }, + credits: { P: 1, PEP: 1, PU: 1, S: 1, U: 1 }, + }, + { + responses: { "/resp": make_response("1,3") }, + credits: { P: 2 / 3, PEP: 1 / 3, PU: 2 / 3, S: 0, U: 0 }, + }, + { + responses: { "/resp": make_response("2") }, + credits: { P: 1 / 3, PEP: 0, PU: 1 / 3, S: 0, U: 0 }, + }, + { + responses: { "/resp": make_response("1") }, + credits: { P: 1 / 3, PEP: 1 / 3, PU: 1 / 3, S: 0, U: 0 }, + }, + { + responses: { "/resp": make_response("1,2,a,3") }, + credits: { P: 3 / 4, PEP: 1 / 2, PU: 3 / 4, S: 0, U: 0 }, + }, + { + responses: { "/resp": make_response("0,1,2,a,3") }, + credits: { P: 3 / 5, PEP: 0, PU: 3 / 5, S: 0, U: 0 }, + }, + { + responses: { "/resp": make_alt_response("1,2,3", 1) }, + credits: { P: 0, PEP: 0, PU: 0, S: 0, U: 0 }, + }, + { + responses: { "/resp": make_alt_response("1,2,3", 2) }, + credits: { P: 0, PEP: 0, PU: 0, S: 0, U: 0 }, + }, + { + responses: { "/resp": make_response("3,1,2") }, + credits: { P: 2 / 3, PEP: 0, PU: 1, S: 0, U: 1 }, + }, + { + responses: { "/resp": make_response("3,2,1") }, + credits: { P: 1 / 3, PEP: 1 / 3, PU: 1, S: 0, U: 1 }, + }, + { + responses: { "/resp": make_response("3,2,1,3") }, + credits: { P: 2 / 4, PEP: 1 / 4, PU: 3 / 4, S: 0, U: 0 }, + }, + { + responses: { "/resp": make_response("3,a,2,1,3") }, + credits: { P: 2 / 5, PEP: 0, PU: 3 / 5, S: 0, U: 0 }, + }, + { + responses: { "/resp": make_response("1,3,a,2,1,3") }, + credits: { P: 3 / 6, PEP: 1 / 6, PU: 3 / 6, S: 0, U: 0 }, + }, + { + responses: { "/resp": make_response("3,1") }, + credits: { P: 1 / 3, PEP: 0, PU: 2 / 3, S: 0, U: 0 }, + }, + { + responses: { "/resp": make_response("3,1,1") }, + credits: { P: 1 / 3, PEP: 0, PU: 2 / 3, S: 0, U: 0 }, + }, + ], + }); +} + +describe("match partial validation tests", async () => { + it("match partial with ordered and unordered tuple", async () => { + const doenetML = ` + + (1,2,3) + (1,2,3) + + + + +

Match partial: + $resp=$ordered +

+ +

Match partial, match by exact positions: + $resp=$ordered +

+ +

Match partial, unordered: + $resp=$unordered +

+ +

Strict equality: + $resp=$ordered +

+ +

Unordered: + $resp=$unordered +

+ `; + + await run_ordered_unordered_tests({ doenetML, delimiters: ["(", ")"] }); + }); + + it("match partial with ordered and unordered list", async () => { + const doenetML = ` + + 1,2,3 + 1,2,3 + + + + +

Match partial: + $resp=$ordered +

+ +

Match partial, match by exact positions: + $resp=$ordered +

+ +

Match partial, unordered: + $resp=$unordered +

+ +

Strict equality: + $resp=$ordered +

+ +

Unordered: + $resp=$unordered +

+ `; + + await run_ordered_unordered_tests({ doenetML, delimiters: ["", ""] }); + }); + + it("match partial with ordered and unordered array", async () => { + const doenetML = ` + + [1,2,3] + [1,2,3] + + + + +

Match partial: + $resp=$ordered +

+ +

Match partial, match by exact positions: + $resp=$ordered +

+ +

Match partial, unordered: + $resp=$unordered +

+ +

Strict equality: + $resp=$ordered +

+ +

Unordered: + $resp=$unordered +

+ `; + + await run_ordered_unordered_tests({ doenetML, delimiters: ["[", "]"] }); + }); + + it("match partial with ordered and unordered tuple, unordered specified on award", async () => { + const doenetML = ` + + + +

Match partial: + $resp=(1,2,3) +

+ +

Match partial, match by exact positions: + $resp=(1,2,3) +

+ +

Match partial, unordered: + $resp=(1,2,3) +

+ +

Strict equality: + $resp=(1,2,3) +

+ +

Unordered: + $resp=(1,2,3) +

+ `; + + await run_ordered_unordered_tests({ doenetML, delimiters: ["(", ")"] }); + }); + + it("match partial with ordered and unordered tuple, unordered specified on answer", async () => { + const doenetML = ` + + + +

Match partial: + $resp=(1,2,3) +

+ +

Match partial, match by exact positions: + $resp=(1,2,3) +

+ +

Match partial, unordered: + $resp=(1,2,3) +

+ +

Strict equality: + $resp=(1,2,3) +

+ +

Unordered: + $resp=(1,2,3) +

+ `; + + await run_ordered_unordered_tests({ doenetML, delimiters: ["(", ")"] }); + }); + + it("match set", async () => { + const doenetML = ` + + +

Match partial: + $resp={1,2,3} +

+ +

No partial: + $resp={1,2,3} +

`; + + await run_tests({ + doenetML, + responseCredits: [ + { responses: { "/resp": "" }, credits: { P: 0, S: 0 } }, + { + responses: { "/resp": "\\{1,2,3\\}" }, + credits: { P: 1, S: 1 }, + }, + { + responses: { "/resp": "\\{3,2,1\\}" }, + credits: { P: 1, S: 1 }, + }, + { + responses: { "/resp": "\\{3,a,2,1\\}" }, + credits: { P: 3 / 4, S: 0 }, + }, + { + responses: { "/resp": "\\{3,a,2,b,1\\}" }, + credits: { P: 3 / 5, S: 0 }, + }, + { + responses: { "/resp": "\\{3,2,3,1,1\\}" }, + credits: { P: 1, S: 1 }, + }, + { + responses: { "/resp": "\\{3,2,3,a,1,1\\}" }, + credits: { P: 3 / 4, S: 0 }, + }, + { + responses: { "/resp": "1,2,3" }, + credits: { P: 0, S: 0 }, + }, + { + responses: { "/resp": "3" }, + credits: { P: 1 / 3, S: 0 }, + }, + { + responses: { "/resp": "\\{2,1\\}" }, + credits: { P: 2 / 3, S: 0 }, + }, + ], + }); + }); + + it("match intervals", async () => { + const doenetML = ` + + +

Open, match partial: + $resp=(1,2) +

+ +

Open, no partial: + $resp=(1,2) +

+ +

Closed, match partial: + $resp=[1,2] +

+ +

Closed, no partial: + $resp=[1,2] +

+ +

Left open, match partial: + $resp=(1,2] +

+ +

Left open, no partial: + $resp=(1,2] +

+ +

Right open, match partial: + $resp=[1,2) +

+ +

Right open, no partial: + $resp=[1,2) +

`; + + await run_tests({ + doenetML, + responseCredits: [ + { + responses: { "/resp": "" }, + credits: { + OP: 0, + OS: 0, + CP: 0, + CS: 0, + LP: 0, + LS: 0, + RP: 0, + RS: 0, + }, + }, + { + responses: { "/resp": "1" }, + credits: { + OP: 0, + OS: 0, + CP: 0, + CS: 0, + LP: 0, + LS: 0, + RP: 0, + RS: 0, + }, + }, + { + responses: { "/resp": "(1,2)" }, + credits: { + OP: 1, + OS: 1, + CP: 0, + CS: 0, + LP: 0, + LS: 0, + RP: 0, + RS: 0, + }, + }, + { + responses: { "/resp": "(3,2)" }, + credits: { + OP: 0.5, + OS: 0, + CP: 0, + CS: 0, + LP: 0, + LS: 0, + RP: 0, + RS: 0, + }, + }, + { + responses: { "/resp": "[1,2]" }, + credits: { + OP: 0, + OS: 0, + CP: 1, + CS: 1, + LP: 0, + LS: 0, + RP: 0, + RS: 0, + }, + }, + { + responses: { "/resp": "[1,3]" }, + credits: { + OP: 0, + OS: 0, + CP: 0.5, + CS: 0, + LP: 0, + LS: 0, + RP: 0, + RS: 0, + }, + }, + { + responses: { "/resp": "[2,1]" }, + credits: { + OP: 0, + OS: 0, + CP: 0, + CS: 0, + LP: 0, + LS: 0, + RP: 0, + RS: 0, + }, + }, + { + responses: { "/resp": "(1,2]" }, + credits: { + OP: 0, + OS: 0, + CP: 0, + CS: 0, + LP: 1, + LS: 1, + RP: 0, + RS: 0, + }, + }, + { + responses: { "/resp": "(1,3]" }, + credits: { + OP: 0, + OS: 0, + CP: 0, + CS: 0, + LP: 0.5, + LS: 0, + RP: 0, + RS: 0, + }, + }, + { + responses: { "/resp": "(2,1]" }, + credits: { + OP: 0, + OS: 0, + CP: 0, + CS: 0, + LP: 0, + LS: 0, + RP: 0, + RS: 0, + }, + }, + { + responses: { "/resp": "[1,2)" }, + credits: { + OP: 0, + OS: 0, + CP: 0, + CS: 0, + LP: 0, + LS: 0, + RP: 1, + RS: 1, + }, + }, + { + responses: { "/resp": "[1,3)" }, + credits: { + OP: 0, + OS: 0, + CP: 0, + CS: 0, + LP: 0, + LS: 0, + RP: 0.5, + RS: 0, + }, + }, + { + responses: { "/resp": "[2,1)" }, + credits: { + OP: 0, + OS: 0, + CP: 0, + CS: 0, + LP: 0, + LS: 0, + RP: 0, + RS: 0, + }, + }, + ], + }); + }); + + async function run_ordered_unordered_input_tests({ + doenetML, + type, + }: { + doenetML; + type: "math" | "text"; + }) { + await run_tests({ + doenetML, + type, + responseCredits: [ + { + responses: { "/x": "", "/y": "", "/z": "" }, + credits: { P: 0, PEP: 0, PU: 0, S: 0, U: 0 }, + }, + { + responses: { "/x": "x", "/y": "y", "/z": "z" }, + credits: { P: 1, PEP: 1, PU: 1, S: 1, U: 1 }, + }, + { + responses: { "/x": "x", "/y": "z", "/z": "" }, + credits: { P: 2 / 3, PEP: 1 / 3, PU: 2 / 3, S: 0, U: 0 }, + }, + { + responses: { "/x": "z", "/y": "x", "/z": "y" }, + credits: { P: 2 / 3, PEP: 0, PU: 1, S: 0, U: 1 }, + }, + { + responses: { "/x": "z", "/y": "y", "/z": "x" }, + credits: { P: 1 / 3, PEP: 1 / 3, PU: 1, S: 0, U: 1 }, + }, + { + responses: { "/x": "z", "/y": "", "/z": "x" }, + credits: { P: 1 / 3, PEP: 0, PU: 2 / 3, S: 0, U: 0 }, + }, + { + responses: { "/x": "z", "/y": "x", "/z": "x" }, + credits: { P: 1 / 3, PEP: 0, PU: 2 / 3, S: 0, U: 0 }, + }, + { + responses: { "/x": "x", "/y": "x", "/z": "z" }, + credits: { P: 2 / 3, PEP: 2 / 3, PU: 2 / 3, S: 0, U: 0 }, + }, + { + responses: { "/x": "x", "/y": "x", "/z": "y" }, + credits: { P: 2 / 3, PEP: 1 / 3, PU: 2 / 3, S: 0, U: 0 }, + }, + ], + }); + } + it("match partial with ordered and unordered math inputs", async () => { + const doenetML = ` +

+

+

+ +
Match partial + + + + + + $x, $y, $z + + = + x,y,z + + + +
+ +
Match partial, match by exact positions + + + + + + $x, $y, $z + + = + x,y,z + + + +
+ + +
Match partial, unordered + + + + + $x, $y, $z + + = + x,y,z + + + +
+ +
Strict equality + + + + + $x, $y, $z + + = + x,y,z + + + +
+ +
Unordered + + + + + $x, $y, $z + + = + x,y,z + + + +
`; + + await run_ordered_unordered_input_tests({ doenetML, type: "math" }); + }); + + it("match partial with ordered and unordered text inputs", async () => { + const doenetML = ` +

+

+

+ +
Match partial + + + + + + $x $y $z + + = + x y z + + + +
+ +
Match partial, match by exact positions + + + + + + $x $y $z + + = + x y z + + + +
+ + +
Match partial, unordered + + + + + $x $y $z + + = + x y z + + + +
+ +
Strict equality + + + + + $x $y $z + + = + x y z + + + +
+ +
Unordered + + + + + $x $y $z + + = + x y z + + + +
`; + + await run_ordered_unordered_input_tests({ doenetML, type: "text" }); + }); + + it("match partial with ordered and unordered boolean inputs", async () => { + const doenetML = ` +

+

+

+ +
Match partial + + + + + + $x $y $z + + = + false true true + + + +
+ +
Match partial, match by exact positions + + + + + + $x $y $z + + = + false true true + + + +
+ + +
Match partial, unordered + + + + + $x $y $z + + = + false true true + + + +
+ +
Strict equality + + + + + $x $y $z + + = + false true true + + + +
+ +
Unordered + + + + + $x $y $z + + = + false true true + + + +
`; + + await run_tests({ + doenetML, + type: "boolean", + responseCredits: [ + { + responses: { "/x": false, "/y": true, "/z": true }, + credits: { P: 1, PEP: 1, PU: 1, S: 1, U: 1 }, + }, + { + responses: { "/x": true, "/y": true, "/z": true }, + credits: { P: 2 / 3, PEP: 2 / 3, PU: 2 / 3, S: 0, U: 0 }, + }, + { + responses: { "/x": true, "/y": false, "/z": true }, + credits: { P: 2 / 3, PEP: 1 / 3, PU: 1, S: 0, U: 1 }, + }, + { + responses: { "/x": true, "/y": false, "/z": false }, + credits: { P: 1 / 3, PEP: 0, PU: 2 / 3, S: 0, U: 0 }, + }, + { + responses: { "/x": false, "/y": false, "/z": false }, + credits: { P: 1 / 3, PEP: 1 / 3, PU: 1 / 3, S: 0, U: 0 }, + }, + ], + }); + }); + + async function test_combined_ordered_unordered_tuples({ + doenetML, + inner_no_partial = false, + force_ordered = false, + }: { + doenetML: string; + inner_no_partial?: boolean; + force_ordered?: boolean; + }) { + await run_tests({ + doenetML, + responseCredits: [ + { + responses: { "/m1": "(1,2)", "/m2": "(3,4)" }, + credits: { P: 1, S: 1 }, + }, + { + responses: { "/m1": "2", "/m2": "(3,4)" }, + credits: { P: 3 / 4, S: 0 }, + }, + { + responses: { "/m1": "2", "/m2": "3" }, + credits: { P: inner_no_partial ? 1 / 4 : 1 / 2, S: 0 }, + }, + { + responses: { "/m1": "(2,1)", "/m2": "(3,4)" }, + credits: { P: 3 / 4, S: 0 }, + }, + { + responses: { "/m1": "(2,1)", "/m2": "(4,3)" }, + credits: { P: force_ordered ? 1 / 2 : 3 / 4, S: 0 }, + }, + { + responses: { "/m1": "(1,2)", "/m2": "(4,3)" }, + credits: force_ordered + ? { P: 3 / 4, S: 0 } + : { P: 1, S: 1 }, + }, + ], + }); + } + + it("match partial with combined ordered/unordered tuples", async () => { + const doenetML = ` + + + +

Match partial: + + + $m1 = (1,2) + and + $m2 = (3,4) + + +

+ +

Strict equality: + + + $m1 = (1,2) + and + $m2 = (3,4) + + +

`; + await test_combined_ordered_unordered_tuples({ doenetML }); + }); + + it("match partial with combined ordered/unordered tuples via whens", async () => { + const doenetML = ` + + + +

Match partial: + + + $m1 = (1,2) + and + $m2 = (3,4) + + +

+ +

Strict equality: + + + $m1 = (1,2) + and + $m2 = (3,4) + + +

`; + await test_combined_ordered_unordered_tuples({ doenetML }); + }); + + it("match partial with combined ordered/unordered tuples via booleans", async () => { + const doenetML = ` + + + +

Match partial: + + + $m1 = (1,2) + and + $m2 = (3,4) + + +

+ +

Strict equality: + + + $m1 = (1,2) + and + $m2 = (3,4) + + +

`; + await test_combined_ordered_unordered_tuples({ + doenetML, + inner_no_partial: true, + }); + }); + + it("mixed match partial and ordered/unordered tuples via whens", async () => { + const doenetML = ` + + + +

Match partial: + + + $m1 = (1,2) + and + $m2 = (3,4) + + +

+ +

No net effect of inner matchPartial: + + + $m1 = (1,2) + and + $m2 = (3,4) + + +

`; + await test_combined_ordered_unordered_tuples({ + doenetML, + inner_no_partial: true, + }); + }); + + it("match partial with combined ordered/unordered tuples, force ordered compare", async () => { + const doenetML = ` + + + +

Match partial: + + + $m1 = (1,2) + and + $m2 = (3,4) + + +

+ +

Strict equality: + + + $m1 = (1,2) + and + $m2 = (3,4) + + +

`; + + await test_combined_ordered_unordered_tuples({ + doenetML, + force_ordered: true, + }); + }); + + it("match partial with combined ordered/unordered tuples via whens, no effect of force ordered compare", async () => { + const doenetML = ` + + + +

Match partial: + + + $m1 = (1,2) + and + $m2 = (3,4) + + +

+ +

Strict equality: + + + $m1 = (1,2) + and + $m2 = (3,4) + + +

`; + + await test_combined_ordered_unordered_tuples({ doenetML }); + }); + + it("match partial with combined ordered/unordered boolean inputs", async () => { + const doenetML = ` +

+

+

+

+ +

Match partial: + + + + $u $v + = + true false + and + $x $y + = + true false + + + +

+ +

Strict: + + + + $u $v + = + true false + and + $x $y + = + true false + + + +

`; + + await run_tests({ + doenetML, + type: "boolean", + responseCredits: [ + { + responses: { + "/u": true, + "/v": false, + "/x": true, + "/y": false, + }, + credits: { P: 1, S: 1 }, + }, + { + responses: { + "/u": true, + "/v": true, + "/x": true, + "/y": false, + }, + credits: { P: 3 / 4, S: 0 }, + }, + { + responses: { + "/u": true, + "/v": true, + "/x": true, + "/y": true, + }, + credits: { P: 1 / 2, S: 0 }, + }, + { + responses: { + "/u": false, + "/v": true, + "/x": true, + "/y": true, + }, + credits: { P: 1 / 2, S: 0 }, + }, + { + responses: { + "/u": false, + "/v": true, + "/x": false, + "/y": true, + }, + credits: { P: 3 / 4, S: 0 }, + }, + { + responses: { + "/u": true, + "/v": false, + "/x": false, + "/y": true, + }, + credits: { P: 1, S: 1 }, + }, + ], + }); + }); + + async function test_tuple_vector_matches(doenetML: string) { + await run_tests({ + doenetML, + responseCredits: [ + { responses: { "/mi": "(1,2)" }, credits: { 1: 0.5, 2: 0.5 } }, + { + responses: { "/mi": "(1,2),(3,4)" }, + credits: { 1: 1, 2: 1 }, + }, + { responses: { "/mi": "(3,4)" }, credits: { 1: 0.5, 2: 0.5 } }, + { + responses: { "/mi": "\\langle 1,2 \\rangle" }, + credits: { 1: 0.5, 2: 0.5 }, + }, + { + responses: { + "/mi": "\\langle 1,2 \\rangle,\\langle 3,4 \\rangle", + }, + credits: { 1: 1, 2: 1 }, + }, + ], + }); + } + + it("match tuple with list of tuples", async () => { + const doenetML = ` +

+ + + + + $mi = (1,2)(3,4) + + + + + + + (1,2)(3,4) = $mi + + + +

`; + + await test_tuple_vector_matches(doenetML); + }); + + it("match tuple with list of vectors", async () => { + const doenetML = ` +

+ + + + + $mi = (1,2)(3,4) + + + + + + + (1,2)(3,4) = $mi + + + +

`; + + await test_tuple_vector_matches(doenetML); + }); + + it("match vector with list of tuples", async () => { + const doenetML = ` +

+ + + + + $mi = (1,2)(3,4) + + + + + + + (1,2)(3,4) = $mi + + + +

`; + + await test_tuple_vector_matches(doenetML); + }); + + it("match vector with list of vectors", async () => { + const doenetML = ` +

+ + + + + $mi = (1,2)(3,4) + + + + + + + (1,2)(3,4) = $mi + + + +

`; + + await test_tuple_vector_matches(doenetML); + }); + + it("match interval with list of intervals", async () => { + const doenetML = ` +

+ + + + + $mi = [1,2)(3,4] + + + + + + + [1,2)(3,4] = $mi + + + +

`; + + await run_tests({ + doenetML, + responseCredits: [ + { responses: { "/mi": "[1,2)" }, credits: { 1: 0.5, 2: 0.5 } }, + { + responses: { "/mi": "[1,2),(3,4]" }, + credits: { 1: 1, 2: 1 }, + }, + { responses: { "/mi": "(3,4]" }, credits: { 1: 0.5, 2: 0.5 } }, + ], + }); + }); + + it("match interval with list of intervals", async () => { + const doenetML = ` +

+ + + + + $mi = [1,2][3,4] + + + + + + + [1,2][3,4] = $mi + + + +

`; + + await run_tests({ + doenetML, + responseCredits: [ + { responses: { "/mi": "[1,2]" }, credits: { 1: 0.5, 2: 0.5 } }, + { + responses: { "/mi": "[1,2],[3,4]" }, + credits: { 1: 1, 2: 1 }, + }, + { responses: { "/mi": "[3,4]" }, credits: { 1: 0.5, 2: 0.5 } }, + ], + }); + }); + + it("match partial and unordered do not recurse on math lists", async () => { + const doenetML = ` +

+ + + + + $mi = (1,2) (3,4) + + + + + + + $mi = (1,2) (3,4) + + + +

`; + + await run_tests({ + doenetML, + responseCredits: [ + { + responses: { "/mi": "(1,2),(3,4)" }, + credits: { P: 1, PU: 1 }, + }, + { + responses: { "/mi": "(1,-2),(3,4)" }, + credits: { P: 0.5, PU: 0.5 }, + }, + { + responses: { "/mi": "(3,4),(1,2)" }, + credits: { P: 0.5, PU: 1 }, + }, + { + responses: { "/mi": "(1,2),(4,3)" }, + credits: { P: 0.5, PU: 0.5 }, + }, + ], + }); + }); +}); diff --git a/packages/doenetml-worker/src/test/answerValidation/matchingPatterns.test.ts b/packages/doenetml-worker/src/test/answerValidation/matchingPatterns.test.ts new file mode 100644 index 000000000..d9e7b7690 --- /dev/null +++ b/packages/doenetml-worker/src/test/answerValidation/matchingPatterns.test.ts @@ -0,0 +1,240 @@ +import { describe, expect, it, vi } from "vitest"; +import { createTestCore, returnAllStateVariables } from "../utils/test-core"; +import { submitAnswer, updateMathInputValue } from "../utils/actions"; + +const Mock = vi.fn(); +vi.stubGlobal("postMessage", Mock); +vi.mock("hyperformula"); + +describe("matching patterns answer tests", async () => { + it("enter any quadratic", async () => { + let core = await createTestCore({ + doenetML: ` + + ()$var^2+()$var+() + ()$var^2+() + + +

+

Enter a quadratic expression in the variable : + + + + + $resp + + or + + $resp + + + + + $excludeX1.patternMatches[1]{assignNamesSkip="1"} $excludeX1.patternMatches[2]{assignNamesSkip="1"} $excludeX1.patternMatch3{assignNamesSkip="1"} + $excludeX2.patternMatches[1]{assignNamesSkip="1"} 0 $excludeX2.patternMatch2 + + + +

+ +

Submitted answer: $ans.submittedResponse{assignNames="sub"}

+

Quadratic coeff: $ans.submittedResponse2{assignNames="quad"}

+

Linear coeff: $ans.submittedResponse3{assignNames="lin"}

+

Constant term: $ans.submittedResponse4{assignNames="const"}

+ + + `, + }); + + let desiredResults = { + x: { + "": { + correct: false, + response: "\uff3f", + }, + "x^2": { + correct: true, + response: ["^", "x", 2], + matches: [1, 0, 0], + }, + "x^2+1": { + correct: true, + response: ["+", ["^", "x", 2], 1], + matches: [1, 0, 1], + }, + "x^2+x": { + correct: true, + response: ["+", ["^", "x", 2], "x"], + matches: [1, 1, 0], + }, + "x^2+x+x": { + correct: false, + response: ["+", ["^", "x", 2], "x", "x"], + }, + "x^2+c": { + correct: true, + response: ["+", ["^", "x", 2], "c"], + matches: [1, 0, "c"], + }, + "xx^2+c": { + correct: false, + response: ["+", ["*", "x", ["^", "x", 2]], "c"], + }, + "x^2+x+c+d": { + correct: true, + response: ["+", ["^", "x", 2], "x", "c", "d"], + matches: [1, 1, ["+", "c", "d"]], + }, + "ax^2+bx+c": { + correct: true, + response: [ + "+", + ["*", "a", ["^", "x", 2]], + ["*", "b", "x"], + "c", + ], + matches: ["a", "b", "c"], + }, + "ay^2+by+c": { + correct: false, + response: [ + "+", + ["*", "a", ["^", "y", 2]], + ["*", "b", "y"], + "c", + ], + }, + "\\sqrt{2}x^2+5/8x+e^y": { + correct: true, + response: [ + "+", + ["*", ["apply", "sqrt", 2], ["^", "x", 2]], + ["*", ["/", 5, 8], "x"], + ["^", "e", "y"], + ], + matches: [ + ["apply", "sqrt", 2], + ["/", 5, 8], + ["^", "e", "y"], + ], + }, + }, + y: { + "ay^2+by+c": { + correct: true, + response: [ + "+", + ["*", "a", ["^", "y", 2]], + ["*", "b", "y"], + "c", + ], + matches: ["a", "b", "c"], + }, + "\\pi y^2x^2+e^xy+x+x": { + correct: true, + response: [ + "+", + ["*", "pi", ["^", "y", 2], ["^", "x", 2]], + ["*", ["^", "e", "x"], "y"], + "x", + "x", + ], + matches: [ + ["*", "pi", ["^", "x", 2]], + ["^", "e", "x"], + ["+", "x", "x"], + ], + }, + "4y^2-9y-2": { + correct: true, + response: [ + "+", + ["*", 4, ["^", "y", 2]], + ["-", ["*", 9, "y"]], + -2, + ], + matches: [4, ["-", 9], -2], + }, + "4y^2+3x+5": { + correct: true, + response: ["+", ["*", 4, ["^", "y", 2]], ["*", 3, "x"], 5], + matches: [4, 0, ["+", ["*", 3, "x"], 5]], + }, + }, + }; + + for (let varName in desiredResults) { + await updateMathInputValue({ latex: varName, name: "/var", core }); + + let resultsForVar = desiredResults[varName]; + for (let expr in resultsForVar) { + await updateMathInputValue({ + latex: expr, + name: "/resp", + core, + }); + await submitAnswer({ name: "/ans", core }); + let stateVariables = await returnAllStateVariables(core); + + let res = resultsForVar[expr]; + + if (res.correct) { + expect( + stateVariables["/ans"].stateValues.creditAchieved, + ).eq(1); + expect(stateVariables["/sub"].stateValues.value.tree).eqls( + res.response, + ); + expect(stateVariables["/quad"].stateValues.value.tree).eqls( + res.matches[0], + ); + expect(stateVariables["/lin"].stateValues.value.tree).eqls( + res.matches[1], + ); + expect( + stateVariables["/const"].stateValues.value.tree, + ).eqls(res.matches[2]); + expect( + stateVariables["/ans"].stateValues.submittedResponse1 + .tree, + ).eqls(res.response); + expect( + stateVariables["/ans"].stateValues.submittedResponse2 + .tree, + ).eqls(res.matches[0]); + expect( + stateVariables["/ans"].stateValues.submittedResponse3 + .tree, + ).eqls(res.matches[1]); + expect( + stateVariables["/ans"].stateValues.submittedResponse4 + .tree, + ).eqls(res.matches[2]); + } else { + expect( + stateVariables["/ans"].stateValues.creditAchieved, + ).eq(0); + expect(stateVariables["/sub"].stateValues.value.tree).eqls( + res.response, + ); + expect(stateVariables["/quad"]).be.undefined; + expect(stateVariables["/lin"]).be.undefined; + expect(stateVariables["/const"]).be.undefined; + expect( + stateVariables["/ans"].stateValues.submittedResponse1 + .tree, + ).eqls(res.response); + expect( + stateVariables["/ans"].stateValues.submittedResponse2, + ).be.undefined; + expect( + stateVariables["/ans"].stateValues.submittedResponse3, + ).be.undefined; + expect( + stateVariables["/ans"].stateValues.submittedResponse4, + ).be.undefined; + } + } + } + }); +}); diff --git a/packages/doenetml-worker/src/test/answerValidation/pointLocation.test.ts b/packages/doenetml-worker/src/test/answerValidation/pointLocation.test.ts new file mode 100644 index 000000000..0a6672baa --- /dev/null +++ b/packages/doenetml-worker/src/test/answerValidation/pointLocation.test.ts @@ -0,0 +1,599 @@ +import { describe, expect, it, vi } from "vitest"; +import { createTestCore, returnAllStateVariables } from "../utils/test-core"; +import { + movePoint, + submitAnswer, + updateMathInputValue, +} from "../utils/actions"; + +const Mock = vi.fn(); +vi.stubGlobal("postMessage", Mock); +vi.mock("hyperformula"); + +async function run_tests({ + doenetML, + responseCredits, +}: { + doenetML: string; + responseCredits: { + responses: Record; + credit: number; + }[]; +}) { + const core = await createTestCore({ doenetML }); + + for (let responseObj of responseCredits) { + await submit_check(responseObj); + } + + async function submit_check({ + responses, + credit, + }: { + responses: Record; + credit: number; + }) { + for (let name in responses) { + let resp = responses[name]; + if (typeof resp === "number") { + await updateMathInputValue({ latex: `${resp}`, name, core }); + } else { + await movePoint({ name, ...resp, core }); + } + } + let stateVariables = await returnAllStateVariables(core); + expect(stateVariables[`/ans`].stateValues.justSubmitted).eq(false); + + await submitAnswer({ name: `/ans`, core }); + stateVariables = await returnAllStateVariables(core); + expect(stateVariables[`/ans`].stateValues.creditAchieved).eq( + credit, + `credit for response ${JSON.stringify(responses)}`, + ); + expect(stateVariables[`/ans`].stateValues.justSubmitted).eq(true); + } +} + +describe("point location validation tests", async () => { + it("point in first quadrant", async () => { + let doenetML = ` + (-3.9,4.5) +

+ + $P.x > 0 and + $P.y > 0 + +

+ `; + + await run_tests({ + doenetML, + responseCredits: [ + { + responses: {}, + credit: 0, + }, + { + responses: { "/P": { x: 5.9, y: 3.5 } }, + credit: 1, + }, + { + responses: { "/P": { x: -8.8, y: 1.3 } }, + credit: 0, + }, + { + responses: { "/P": { x: -9.4, y: -5.1 } }, + credit: 0, + }, + { + responses: { "/P": { x: 4.2, y: -2.9 } }, + credit: 0, + }, + { + responses: { "/P": { x: 4.6, y: 0.1 } }, + credit: 1, + }, + ], + }); + }); + + it("point at precise location with attract", async () => { + let doenetML = ` + (-4.1, 7.4) +

Move point to $goal.coords

+ + + + $goal + + + +

+ $A.x{isResponse} = $goal.x and + $A.y{isResponse} = $goal.y +

+ `; + + await run_tests({ + doenetML, + responseCredits: [ + { + responses: {}, + credit: 0, + }, + { + responses: { "/A": { x: -4, y: 7.6 } }, + credit: 1, + }, + { + responses: { "/A": { x: -3.7, y: 7 } }, + credit: 0, + }, + { + responses: { "/A": { x: -3.8, y: 7.1 } }, + credit: 1, + }, + ], + }); + }); + + it("point close enough to precise location", async () => { + let doenetML = ` + (-4.1, 7.4) + +

Criterion distance:

+

Partial credit distance:

+ + $criterion.value^2 + $partialCriterion.value^2 + ($A.x - $goal.x)^2 + + ($A.y - $goal.y)^2 + +

Move point to within distance of $criterion.value to $goal.coords

+ + (4.9, -1.1) + +

+ + $distance2 < $criterion2 + + + $distance2 < $partialCriterion2 + + $A +

+ `; + + await run_tests({ + doenetML, + responseCredits: [ + { + responses: {}, + credit: 0, + }, + { + responses: { "/A": { x: -5, y: 6 } }, + credit: 1, + }, + { + responses: { "/criterion": 1 }, + credit: 0.6, + }, + { + responses: { "/A": { x: -5, y: 7 } }, + credit: 1, + }, + { + responses: { "/A": { x: -2.8, y: 9 } }, + credit: 0.6, + }, + { + responses: { "/partialCriterion": 2 }, + credit: 0, + }, + { + responses: { "/A": { x: -3, y: 9 } }, + credit: 0.6, + }, + { + responses: { "/A": { x: -3.5, y: 8 } }, + credit: 1, + }, + ], + }); + }); + + async function test_two_points(doenetML: string, ordered = false) { + await run_tests({ + doenetML, + responseCredits: [ + { + responses: {}, + credit: 0, + }, + { + responses: { "/A": { x: -4, y: 7.6 } }, // A near first goal + credit: 0.5, + }, + { + responses: { "/A": { x: -3.7, y: 7 } }, // A away + credit: 0, + }, + { + responses: { "/B": { x: -3.8, y: 7.1 } }, // B near first goal + credit: 0.5, + }, + { + responses: { "/A": { x: 6.9, y: 9.0 } }, // A near second goal + credit: ordered ? 0.5 : 1, + }, + { + responses: { "/B": { x: -9.9, y: -8.8 } }, // B away + credit: 0.5, + }, + { + responses: { "/B": { x: 6.7, y: 9 } }, // B near second goal + credit: 0.5, + }, + { + responses: { "/A": { x: 0.1, y: -1.1 } }, // A away + credit: 0.5, + }, + { + responses: { "/A": { x: -3.8, y: 7.6 } }, // A near first goal + credit: 1, + }, + ], + }); + } + + it("two points at precise locations, partial match", async () => { + let doenetML = ` + (-4.1, 7.4) + (6.8, 9.1) +

Move points to $goal1.coords $goal2.coords

+ + + + $goal1 + $goal2 + + + + + $goal1 + $goal2 + + + +

+ + + ($A, $B) = ($goal1, $goal2) + + +

+ `; + + await test_two_points(doenetML); + }); + + it("two points at precise locations, partial match, ordered", async () => { + let doenetML = ` + (-4.1, 7.4) + (6.8, 9.1) +

Move points to $goal1.coords $goal2.coords

+ + + + $goal1 + $goal2 + + + + + $goal1 + $goal2 + + + +

+ + + ($A, $B) = ($goal1, $goal2) + + +

+ `; + + await test_two_points(doenetML, true); + }); + + it("two points at precise locations, award based as string literals, partial match", async () => { + let doenetML = ` + (-4.1, 7.4) + (6.8, 9.1) +

Move points to $goal1.coords $goal2.coords

+ + + + $goal1 + $goal2 + + + + + $goal1 + $goal2 + + + +

+ + + ($A, $B) = ((-4.1, 7.4), (6.8, 9.1)) + + +

+ `; + + await test_two_points(doenetML); + }); + + it("two points at precise locations, award based as string literals, partial match, ordered", async () => { + let doenetML = ` + (-4.1, 7.4) + (6.8, 9.1) +

Move points to $goal1.coords $goal2.coords

+ + + + $goal1 + $goal2 + + + + + $goal1 + $goal2 + + + +

+ + + ($A, $B) = ((-4.1, 7.4), (6.8, 9.1)) + + +

+ `; + + await test_two_points(doenetML, true); + }); + + it("two points at precise locations, partial match, as math lists", async () => { + let doenetML = ` + (-4.1, 7.4) + (6.8, 9.1) +

Move points to $goal1.coords $goal2.coords

+ + + + $goal1 + $goal2 + + + + + $goal1 + $goal2 + + + +

+ + + $A $B = $goal1 $goal2 + + +

+

+ `; + + await test_two_points(doenetML); + }); + + it("dynamical number of points, partial match, as math lists", async () => { + const doenetML = ` + (-4.1, 7.4) + (6.8, 9.1) +

Move points to $goal1.coords $goal2.coords

+

Number of points:

+ + + + + + +

+ + + $map1 = $goal1 $goal2 + + +

+ `; + + await run_tests({ + doenetML, + responseCredits: [ + { + responses: {}, + credit: 0, + }, + { + responses: { "/n": 1 }, // create A + credit: 0, + }, + { + responses: { "/A": { x: -4, y: 7.6 } }, // A near first goal + credit: 0.5, + }, + { + responses: { "/A": { x: -3.7, y: 7 } }, // A away + credit: 0, + }, + { + responses: { "/n": 2 }, // create B + credit: 0, + }, + { + responses: { "/B": { x: -3.8, y: 7.1 } }, // B near first goal + credit: 0.5, + }, + { + responses: { "/A": { x: 6.9, y: 9.0 } }, // A near second goal + credit: 1, + }, + { + responses: { "/B": { x: -9.9, y: -8.8 } }, // B away + credit: 0.5, + }, + { + responses: { "/B": { x: 6.7, y: 9 } }, // B near second goal + credit: 0.5, + }, + { + responses: { "/A": { x: 0.1, y: -1.1 } }, // A away + credit: 0.5, + }, + { + responses: { "/A": { x: -3.8, y: 7.6 } }, // A near first goal + credit: 1, + }, + { + responses: { "/n": 3 }, // create C + credit: 2 / 3, + }, + { + responses: { "/C": { x: -3.8, y: 7.6 } }, // C near first goal + credit: 2 / 3, + }, + { + responses: { "/n": 2 }, // remove C + credit: 1, + }, + ], + }); + }); + + it("dynamical number of points, double map, partial match", async () => { + const doenetML = ` + (-4.1, 7.4) + (6.8, 9.1) +

Move points to $goal1.coords $goal2.coords

+

Number of points:

+

Number of points 2:

+ + + + + + +

+ + + $map1 = $goal1 $goal2 + + +

+ `; + + await run_tests({ + doenetML, + responseCredits: [ + { + responses: {}, + credit: 0, + }, + { + responses: { "/n": 1 }, // create A1 + credit: 0, + }, + { + responses: { "/A1": { x: -4, y: 7.6 } }, // A1 near first goal + credit: 0.5, + }, + { + responses: { "/A1": { x: -3.7, y: 7 } }, // A1 away + credit: 0, + }, + { + responses: { "/m": 1 }, // create A2 + credit: 0, + }, + { + responses: { "/A2": { x: -3.8, y: 7.1 } }, // A2 near first goal + credit: 0.5, + }, + { + responses: { "/A1": { x: 6.9, y: 9.0 } }, // A1 near second goal + credit: 1, + }, + { + responses: { "/A2": { x: -9.9, y: -8.8 } }, // A2 away + credit: 0.5, + }, + { + responses: { "/A2": { x: 6.7, y: 9 } }, // A2 near second goal + credit: 0.5, + }, + { + responses: { "/A1": { x: 0.1, y: -1.1 } }, // A1 away + credit: 0.5, + }, + { + responses: { "/A1": { x: -3.8, y: 7.6 } }, // A1 near first goal + credit: 1, + }, + { + responses: { "/n": 2 }, // create B1 and B2 + credit: 1 / 2, + }, + { + responses: { "/B1": { x: 7, y: 9 } }, // B1 near second goal + credit: 1 / 2, + }, + { + responses: { "/m": 0 }, // remove A2 and B2 + credit: 1, + }, + ], + }); + }); +}); diff --git a/packages/doenetml-worker/src/test/answerValidation/symbolicEquality.test.ts b/packages/doenetml-worker/src/test/answerValidation/symbolicEquality.test.ts new file mode 100644 index 000000000..2845f14d2 --- /dev/null +++ b/packages/doenetml-worker/src/test/answerValidation/symbolicEquality.test.ts @@ -0,0 +1,610 @@ +import { describe, expect, it, vi } from "vitest"; +import { createTestCore, returnAllStateVariables } from "../utils/test-core"; +import { submitAnswer, updateMathInputValue } from "../utils/actions"; + +const Mock = vi.fn(); +vi.stubGlobal("postMessage", Mock); +vi.mock("hyperformula"); + +async function run_tests({ + doenetML, + responseCredits, +}: { + doenetML: string; + responseCredits: { + responses: Record; + credits: Record; + }[]; +}) { + const core = await createTestCore({ doenetML }); + + for (let responseObj of responseCredits) { + await submit_check(responseObj); + } + + async function submit_check({ + responses, + credits, + }: { + responses: Record; + credits: Record; + }) { + for (let name in responses) { + await updateMathInputValue({ + latex: `${responses[name]}`, + name, + core, + }); + } + for (let code in credits) { + await submitAnswer({ name: `/ans${code}`, core }); + } + const stateVariables = await returnAllStateVariables(core); + for (let code in credits) { + expect(stateVariables[`/ans${code}`].stateValues.creditAchieved).eq( + credits[code], + `${code} credit for response ${JSON.stringify(responses)}`, + ); + } + } +} + +describe("Symbolic equality tests", async () => { + it("symbolic equality match with no simplification", async () => { + const doenetML = ` +

Response:

+ +

1+3: + + $resp=$m1 + +

+ +

3+1: + + $resp=$m2 + +

+ +

Numeric versions

+

+ $resp=$m1 +

+

+ $resp=$m2 +

+ `; + await run_tests({ + doenetML, + responseCredits: [ + { responses: {}, credits: { S1: 0, S2: 0, N1: 0, N2: 0 } }, + { + responses: { "/resp": "4" }, + credits: { S1: 0, S2: 0, N1: 1, N2: 1 }, + }, + { + responses: { "/resp": "3+1" }, + credits: { S1: 0, S2: 1, N1: 1, N2: 1 }, + }, + { + responses: { "/resp": "1+3" }, + credits: { S1: 1, S2: 0, N1: 1, N2: 1 }, + }, + { + responses: { "/resp": "1+1+1+1" }, + credits: { S1: 0, S2: 0, N1: 1, N2: 1 }, + }, + ], + }); + }); + + it("symbolic equality match with no simplification 2", async () => { + const doenetML = ` +

Response:

+ +

1x-0y+-3s: + + $resp=$m + +

+ +

Numeric version

+

+ $resp=$m +

+ `; + await run_tests({ + doenetML, + responseCredits: [ + { responses: {}, credits: { S: 0, N: 0 } }, + { + responses: { "/resp": "1x-0y+-3s" }, + credits: { S: 1, N: 1 }, + }, + { + responses: { "/resp": "1x-0y-3s" }, + credits: { S: 1, N: 1 }, + }, + { + responses: { "/resp": "1x-0y+(-3s)" }, + credits: { S: 1, N: 1 }, + }, + { + responses: { "/resp": "1x+0y-3s" }, + credits: { S: 1, N: 1 }, + }, + { + responses: { "/resp": "1x-3s" }, + credits: { S: 0, N: 1 }, + }, + { + responses: { "/resp": "x-0y-3s" }, + credits: { S: 0, N: 1 }, + }, + { + responses: { "/resp": "-0y+1x-3s" }, + credits: { S: 0, N: 1 }, + }, + ], + }); + }); + + it("symbolic equality match with no simplification, handle negatives", async () => { + const doenetML = ` +

Response:

+ +

z-5x-3: + + $resp=$m1 + +

+

z-5x-3: + + $resp=$m2 + +

+

z+-5x+-3: + + $resp=$m3 + +

+

z+-5x+-3: + + $resp=$m4 + +

+

z-5x-3: + + $resp=$m5 + +

+

z+-5x-3: + + $resp=$m6 + +

+ +

Numeric versions

+

+ $resp=$m1 +

+

+ $resp=$m2 +

+

+ $resp=$m3 +

+

+ $resp=$m4 +

+

+ $resp=$m5 +

+

+ $resp=$m6 +

+ `; + await run_tests({ + doenetML, + responseCredits: [ + { + responses: {}, + credits: { + S1: 0, + S2: 0, + S3: 0, + S4: 0, + S5: 0, + S6: 0, + N1: 0, + N2: 0, + N3: 0, + N4: 0, + N5: 0, + N6: 0, + }, + }, + { + responses: { "/resp": "z-5x-3" }, + credits: { + S1: 1, + S2: 1, + S3: 1, + S4: 1, + S5: 1, + S6: 1, + N1: 1, + N2: 1, + N3: 1, + N4: 1, + N5: 1, + N6: 1, + }, + }, + { + responses: { "/resp": "z+-5x+-3" }, + credits: { + S1: 1, + S2: 1, + S3: 1, + S4: 1, + S5: 1, + S6: 1, + N1: 1, + N2: 1, + N3: 1, + N4: 1, + N5: 1, + N6: 1, + }, + }, + { + responses: { "/resp": "z-(5x)+-(3)" }, + credits: { + S1: 1, + S2: 1, + S3: 1, + S4: 1, + S5: 1, + S6: 1, + N1: 1, + N2: 1, + N3: 1, + N4: 1, + N5: 1, + N6: 1, + }, + }, + { + responses: { "/resp": "z-1(5x)-3" }, + credits: { + S1: 0, + S2: 0, + S3: 0, + S4: 0, + S5: 0, + S6: 0, + N1: 1, + N2: 1, + N3: 1, + N4: 1, + N5: 1, + N6: 1, + }, + }, + ], + }); + }); + + async function test_simplify_numbers_preserve_order(doenetML: string) { + await run_tests({ + doenetML, + responseCredits: [ + { responses: {}, credits: { S: 0, N: 0 } }, + { + responses: { "/resp": "1x^2+2-0x^2+3+x^2+3x^2+7+4" }, + credits: { S: 1, N: 1 }, + }, + { + responses: { "/resp": "x^2+5+x^2+3x^2+11" }, + credits: { S: 1, N: 1 }, + }, + { + responses: { "/resp": "1x^2+2-0x^2+3+x^2+3x^2+4+7" }, + credits: { S: 1, N: 1 }, + }, + { + responses: { "/resp": "1x^2+2-0x^2+3+3x^2+x^2+7+4" }, + credits: { S: 0, N: 1 }, + }, + { + responses: { "/resp": "1x^2+2-0x^2+3+4x^2+7+4" }, + credits: { S: 0, N: 1 }, + }, + { + responses: { "/resp": "1x^2-0x^2+x^2+3x^2+16" }, + credits: { S: 0, N: 1 }, + }, + { + responses: { "/resp": "5x^2+16" }, + credits: { S: 0, N: 1 }, + }, + ], + }); + } + + it("symbolic equality match with simplifying numbers, preserving order", async () => { + const doenetML = ` +

Response:

+ +

+ 1x^2+2-0x^2+3+x^2+3x^2+7+4: + + $resp=$m + +

+ +

Numeric versions

+

+ $resp=$m +

+ `; + + await test_simplify_numbers_preserve_order(doenetML); + }); + + it("symbolic equality match with simplifying numbers, preserving order, attributes on answer", async () => { + const doenetML = ` +

Response:

+ +

+ 1x^2+2-0x^2+3+x^2+3x^2+7+4: + + $resp=$m + +

+ +

Numeric versions

+

+ $resp=$m +

+ `; + + await test_simplify_numbers_preserve_order(doenetML); + }); + + it("symbolic equality match with simplifying numbers, preserving order, attributes on when", async () => { + const doenetML = ` +

Response:

+ +

+ 1x^2+2-0x^2+3+x^2+3x^2+7+4: + + $resp=$m + +

+ +

Numeric versions

+

+ $resp=$m +

+ `; + + await test_simplify_numbers_preserve_order(doenetML); + }); + + it("symbolic equality match with simplifying numbers", async () => { + const doenetML = ` +

Response:

+ +

+ 1x^2+2-0x^2+3+x^2+3x^2+7+4: + + $resp=$m + +

+ +

Numeric versions

+

+ $resp=$m +

+ `; + + await run_tests({ + doenetML, + responseCredits: [ + { responses: {}, credits: { S: 0, N: 0 } }, + { + responses: { "/resp": "1x^2+2-0x^2+3+x^2+3x^2+7+4" }, + credits: { S: 1, N: 1 }, + }, + { + responses: { "/resp": "x^2-0x^2+x^2+3x^2+16" }, + credits: { S: 1, N: 1 }, + }, + { + responses: { "/resp": "7+1x^2-0x^2+3+3x^2+4+2+x^2" }, + credits: { S: 1, N: 1 }, + }, + { + responses: { "/resp": "1x^2+2-0x^2+3+4x^2+7+4" }, + credits: { S: 0, N: 1 }, + }, + { + responses: { "/resp": "5x^2+16" }, + credits: { S: 0, N: 1 }, + }, + ], + }); + }); + + it("symbolic equality match with full simplification", async () => { + const doenetML = ` +

Response:

+ +

+ 6x^2 -3x +8x-4 + (2x-3)(4-x): + + $resp=$m + +

+ +

Numeric versions

+

+ $resp=$m +

+ `; + + await run_tests({ + doenetML, + responseCredits: [ + { responses: {}, credits: { S: 0, N: 0 } }, + { + responses: { "/resp": "6x^2 -3x +8x -4 + (2x-3)(4-x)" }, + credits: { S: 1, N: 1 }, + }, + { + responses: { "/resp": "6x^2 +5x -4 + (2x-3)(4-x)" }, + credits: { S: 1, N: 1 }, + }, + { + responses: { "/resp": "-4 + 6x^2 + (4-x)(-3+2x) + 5x" }, + credits: { S: 1, N: 1 }, + }, + { + responses: { "/resp": "6x^2 +5x -4 -2x^2+11x-12" }, + credits: { S: 0, N: 1 }, + }, + { + responses: { "/resp": "4x^2 +16x -16" }, + credits: { S: 0, N: 1 }, + }, + { + responses: { "/resp": "(3x+4)(2x -1) + (2x-3)(4-x)" }, + credits: { S: 0, N: 1 }, + }, + ], + }); + }); + + it("symbolic equality match with expand and full simplification", async () => { + const doenetML = ` +

Response:

+ +

+ (2x-3)(4-x) + sin(x)^2+cos(x)^2: + + $resp=$m + +

+ +

Numeric versions

+

+ $resp=$m +

+ `; + + await run_tests({ + doenetML, + responseCredits: [ + { responses: {}, credits: { S: 0, N: 0 } }, + { + responses: { + "/resp": "(2x-3)(4-x) + \\sin(x)^2+\\cos(x)^2", + }, + credits: { S: 1, N: 1 }, + }, + { + responses: { + "/resp": "-2x^2+11x-12 + \\sin(x)^2+\\cos(x)^2", + }, + credits: { S: 1, N: 1 }, + }, + { + responses: { "/resp": "(2x-3)(4-x) + 1" }, + credits: { S: 0, N: 1 }, + }, + ], + }); + }); + + it("symbolic equality with simplification can match simplified negative", async () => { + const doenetML = ` +

Response:

+ +

+ What is -3-4? + + $resp=$expr{simplify} + +

+ +

Numeric versions

+

What is $expr? + + $resp=$expr{simplify} +

+ `; + + await run_tests({ + doenetML, + responseCredits: [ + { responses: {}, credits: { S: 0, N: 0 } }, + { + responses: { "/resp": "-7" }, + credits: { S: 1, N: 1 }, + }, + { + responses: { "/resp": "-3-4" }, + credits: { S: 0, N: 1 }, + }, + ], + }); + }); + + it("symbolic equality with simplification, exponentials", async () => { + const doenetML = ` + + -5 *e^(-t) + -5 *exp(-t) +

Response:

+ + + $resp=$eAns + + + $resp=$expAns + + + $resp=$(eAns{simplify}) + + + $resp=$(expAns{simplify}) + + + `; + + await run_tests({ + doenetML, + responseCredits: [ + { responses: {}, credits: { E: 0, EXP: 0, ES: 0, EXPS: 0 } }, + { + responses: { "/resp": "-5e^{-t}" }, + credits: { E: 1, EXP: 1, ES: 1, EXPS: 1 }, + }, + { + responses: { "/resp": "-5\\exp(-t)" }, + credits: { E: 1, EXP: 1, ES: 1, EXPS: 1 }, + }, + { + responses: { "/resp": "-5/e^t" }, + credits: { E: 1, EXP: 1, ES: 1, EXPS: 1 }, + }, + { + responses: { "/resp": "-5/\\exp(t)" }, + credits: { E: 1, EXP: 1, ES: 1, EXPS: 1 }, + }, + ], + }); + }); +}); diff --git a/packages/test-cypress/cypress/e2e/answerValidation/errorinnumbers.cy.js b/packages/test-cypress/cypress/e2e/answerValidation/errorinnumbers.cy.js deleted file mode 100644 index cfe5f3a75..000000000 --- a/packages/test-cypress/cypress/e2e/answerValidation/errorinnumbers.cy.js +++ /dev/null @@ -1,2283 +0,0 @@ -import { cesc, cesc2 } from "@doenet/utils"; - -describe("Allow error in numbers validation tests", function () { - beforeEach(() => { - cy.clearIndexedDB(); - cy.visit("/"); - }); - - it("expression with single number", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

log(32x+c) - - - $_math1 - - - $_math1 - - - $_math1 - - -

- `, - }, - "*", - ); - }); - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = cesc2( - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName, - ); - let mathinputAnchor = "#" + mathinputName + " textarea"; - let mathinputEditiableFieldAnchor = - "#" + mathinputName + " .mq-editable-field"; - let mathinputSubmitAnchor = "#" + mathinputName + "_submit"; - let mathinputCorrectAnchor = "#" + mathinputName + "_correct"; - let mathinputPartialAnchor = "#" + mathinputName + "_partial"; - let mathinputIncorrectAnchor = "#" + mathinputName + "_incorrect"; - - cy.get(mathinputSubmitAnchor).should("be.visible"); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type("log(32x+c){enter}", { - force: true, - delay: 5, - }); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinputEditiableFieldAnchor) - .invoke("text") - .then((text) => { - expect(text.replace(/[\s\u200B-\u200D\uFEFF]/g, "")).equal( - "log(32x+c)", - ); - }); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Enter too large an error"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(32.04x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("shink error"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(32.01x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "60 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.6, 1e-14); - }); - - cy.log("shink error further"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(32.001x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "80 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.8, 1e-14); - }); - - cy.log("acceptable error for full credit"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(32.0001x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("increase error"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(31.999x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "80 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.8, 1e-14); - }); - - cy.log("increase error further"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(31.99x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "60 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.6, 1e-14); - }); - - cy.log("error too large again"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(31.9x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - }); - }); - - it("expression with single number, absolute error", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

log(32x+c) - - - $_math1 - - - $_math1 - - - $_math1 - - -

- `, - }, - "*", - ); - }); - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = cesc2( - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName, - ); - let mathinputAnchor = "#" + mathinputName + " textarea"; - let mathinputSubmitAnchor = "#" + mathinputName + "_submit"; - let mathinputCorrectAnchor = "#" + mathinputName + "_correct"; - let mathinputPartialAnchor = "#" + mathinputName + "_partial"; - let mathinputIncorrectAnchor = "#" + mathinputName + "_incorrect"; - - cy.get(mathinputSubmitAnchor).should("be.visible"); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type("log(32x+c){enter}", { - force: true, - delay: 5, - }); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Enter too large an error"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(32.002x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("shink error"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(32.0005x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "60 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.6, 1e-14); - }); - - cy.log("shink error further"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(32.00005x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "80 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.8, 1e-14); - }); - - cy.log("acceptable error for full credit"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(32.000005x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("increase error"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(31.99995x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "80 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.8, 1e-14); - }); - - cy.log("increase error further"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(31.9995x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "60 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.6, 1e-14); - }); - - cy.log("error too large again"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(31.995x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - }); - }); - - // since will randomly fail, just skip test - it.skip("complicated expression with three numbers", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

10 exp(7x^2/(3-sqrt(y))) - - - $_math1 - - - $_math1 - - -

- `, - }, - "*", - ); - }); - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = "#" + mathinputName + " textarea"; - let mathinputSubmitAnchor = "#" + mathinputName + "_submit"; - let mathinputCorrectAnchor = "#" + mathinputName + "_correct"; - let mathinputPartialAnchor = "#" + mathinputName + "_partial"; - let mathinputIncorrectAnchor = "#" + mathinputName + "_incorrect"; - - cy.get(mathinputSubmitAnchor).should("be.visible"); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type("10 exp(7x^2/3-sqrty{enter}"); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Enter too large an error"); - cy.get(mathinputAnchor) - .clear() - .type("9.9 exp(6.9x^2/3.1-sqrty{enter}"); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("shink error"); - cy.get(mathinputAnchor) - .clear() - .type("10.0001 exp(7.00005x^2/2.99995-sqrty{enter}"); - cy.get(mathinputPartialAnchor).should("have.text", "60 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.6, 1e-14); - }); - - cy.log("acceptable error for full credit"); - cy.get(mathinputAnchor) - .clear() - .type("10.0000001 exp(7.0000001x^2/2.9999999-sqrty{enter}"); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); - - it("don't ignore exponents", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

10x^2-4 - - - $_math1 - - -

- -

Allow for error in exponents - - - $_math1 - - -

- `, - }, - "*", - ); - }); - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = cesc2( - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName, - ); - let mathinputAnchor = "#" + mathinputName + " textarea"; - let mathinputSubmitAnchor = "#" + mathinputName + "_submit"; - let mathinputCorrectAnchor = "#" + mathinputName + "_correct"; - let mathinputPartialAnchor = "#" + mathinputName + "_partial"; - let mathinputIncorrectAnchor = "#" + mathinputName + "_incorrect"; - - let mathinput2Name = cesc2( - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName, - ); - let mathinput2Anchor = "#" + mathinput2Name + " textarea"; - let mathinput2SubmitAnchor = "#" + mathinput2Name + "_submit"; - let mathinput2CorrectAnchor = "#" + mathinput2Name + "_correct"; - let mathinput2PartialAnchor = "#" + mathinput2Name + "_partial"; - let mathinput2IncorrectAnchor = "#" + mathinput2Name + "_incorrect"; - - cy.get(mathinputSubmitAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).should("be.visible"); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type("10x^2{rightarrow}-4{enter}", { - force: true, - delay: 5, - }); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type("10x^2{rightarrow}-4{enter}", { - force: true, - delay: 5, - }); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Enter too large an error"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}10.002x^2.0004{rightarrow}-4.0008", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}10.002x^2.0004{rightarrow}-4.0008", - { force: true, delay: 5 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Too large an error if don't allow exponent error"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}10.002x^2{rightarrow}-4.0008", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}10.002x^2{rightarrow}-4.0008", - { force: true, delay: 5 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Shrink to allowable error in both cases"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}10.0002x^2{rightarrow}-4.00008", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}10.0002x^2{rightarrow}-4.00008", - { force: true, delay: 5 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); - - it("symbolic, expression with single number", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

log(32x+c) - - - $_math1 - - - $_math1 - - - $_math1 - - -

- `, - }, - "*", - ); - }); - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = cesc2( - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName, - ); - let mathinputAnchor = "#" + mathinputName + " textarea"; - let mathinputSubmitAnchor = "#" + mathinputName + "_submit"; - let mathinputCorrectAnchor = "#" + mathinputName + "_correct"; - let mathinputPartialAnchor = "#" + mathinputName + "_partial"; - let mathinputIncorrectAnchor = "#" + mathinputName + "_incorrect"; - - cy.get(mathinputSubmitAnchor).should("be.visible"); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type("log(32x+c){enter}", { - force: true, - delay: 5, - }); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Enter too large an error"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(32.04x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("shink error"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(32.01x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "60 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.6, 1e-14); - }); - - cy.log("shink error further"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(32.001x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "80 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.8, 1e-14); - }); - - cy.log("acceptable error for full credit"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(32.0001x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("increase error"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(31.999x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "80 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.8, 1e-14); - }); - - cy.log("increase error further"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(31.99x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "60 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.6, 1e-14); - }); - - cy.log("error too large again"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(31.9x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - }); - }); - - it("symbolic, expression with single number, absolute error", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

log(32x+c) - - $_math1 - $_math1 - $_math1 - -

- `, - }, - "*", - ); - }); - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = cesc2( - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName, - ); - let mathinputAnchor = "#" + mathinputName + " textarea"; - let mathinputSubmitAnchor = "#" + mathinputName + "_submit"; - let mathinputCorrectAnchor = "#" + mathinputName + "_correct"; - let mathinputPartialAnchor = "#" + mathinputName + "_partial"; - let mathinputIncorrectAnchor = "#" + mathinputName + "_incorrect"; - - cy.get(mathinputSubmitAnchor).should("be.visible"); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type("log(32x+c){enter}", { - force: true, - delay: 5, - }); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Enter too large an error"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(32.002x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("shink error"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(32.0005x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "60 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.6, 1e-14); - }); - - cy.log("shink error further"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(32.00005x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "80 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.8, 1e-14); - }); - - cy.log("acceptable error for full credit"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(32.000005x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("increase error"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(31.99995x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "80 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.8, 1e-14); - }); - - cy.log("increase error further"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(31.9995x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "60 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.6, 1e-14); - }); - - cy.log("error too large again"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}log(31.995x+c)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - }); - }); - - it("symbolic, complicated expression with three numbers", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

10000 exp(7x^2/(0.00003-sqrt(y))) - - - $_math1 - - - $_math1 - - - $_math1 - - -

- `, - }, - "*", - ); - }); - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = cesc2( - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName, - ); - let mathinputAnchor = "#" + mathinputName + " textarea"; - let mathinputSubmitAnchor = "#" + mathinputName + "_submit"; - let mathinputCorrectAnchor = "#" + mathinputName + "_correct"; - let mathinputPartialAnchor = "#" + mathinputName + "_partial"; - let mathinputIncorrectAnchor = "#" + mathinputName + "_incorrect"; - - cy.get(mathinputSubmitAnchor).should("be.visible"); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type( - "10000 exp(7x^2{rightarrow}/0.00003-sqrty{enter}", - { force: true, delay: 5 }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Enter too large an error in first number"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}9999 exp(7x^2{rightarrow}/0.00003-sqrty", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Enter too large an error in second number"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}10000 exp(7.0001x^2{rightarrow}/0.00003-sqrty", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Enter too large an error in third number"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}10000 exp(7x^2{rightarrow}/0.0000300005-sqrty", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("partial credit error in each"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}9999.91 exp(7.00005x^2{rightarrow}/0.0000300002-sqrty", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "60 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.6, 1e-14); - }); - - cy.log("higher partial credit error in each"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}9999.991 exp(7.000005x^2{rightarrow}/0.00003000002-sqrty", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "80 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.8, 1e-14); - }); - - cy.log("acceptable error for full credit"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}9999.9991 exp(7.0000005x^2{rightarrow}/0.000030000002-sqrty", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); - - it("symbolic, complicated expression with three numbers, absolute error", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

10000 exp(7x^2/(0.00003-sqrt(y))) - - - $_math1 - - - $_math1 - - - $_math1 - - -

- `, - }, - "*", - ); - }); - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = cesc2( - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName, - ); - let mathinputAnchor = "#" + mathinputName + " textarea"; - let mathinputSubmitAnchor = "#" + mathinputName + "_submit"; - let mathinputCorrectAnchor = "#" + mathinputName + "_correct"; - let mathinputPartialAnchor = "#" + mathinputName + "_partial"; - let mathinputIncorrectAnchor = "#" + mathinputName + "_incorrect"; - - cy.get(mathinputSubmitAnchor).should("be.visible"); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type( - "10000 exp(7x^2{rightarrow}/0.00003-sqrty{enter}", - { force: true, delay: 5 }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Enter too large an error in first number"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}9999.9999 exp(7x^2{rightarrow}/0.00003-sqrty", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Enter too large an error in second number"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}10000 exp(7.00002x^2{rightarrow}/0.00003-sqrty", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Enter too large an error in third number"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}10000 exp(7x^2{rightarrow}/0.00005-sqrty", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("partial credit error in each"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}9999.999991 exp(7.000005x^2{rightarrow}/0.000032-sqrty", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "60 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.6, 1e-14); - }); - - cy.log("higher partial credit error in each"); - cy.get(mathinputAnchor) - .type( - "{ctrl+home}{shift+end}{backspace}9999.9999991 exp(7.0000005x^2{rightarrow}/0.0000302-sqrty", - { force: true, delay: 5 }, - ) - .blur(); - - // wait for the value in the input to be rounded before submitting - // so that the change doesn't occur after the submission - // and make justSubmitted of the answer be false - cy.get(`#${mathinputName} .mq-editable-field`).should( - "not.contain.text", - "9999.9999991", - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "80 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.8, 1e-14); - }); - - cy.log("acceptable error for full credit"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}9999.99999991 exp(7.00000005x^2{rightarrow}/0.00003002-sqrty", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); - - it("symbolic, don't ignore exponents", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

10x^2-4 - - - $_math1 - - -

- -

Allow for error in exponents - - - $_math1 - - -

- `, - }, - "*", - ); - }); - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = cesc2( - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName, - ); - let mathinputAnchor = "#" + mathinputName + " textarea"; - let mathinputSubmitAnchor = "#" + mathinputName + "_submit"; - let mathinputCorrectAnchor = "#" + mathinputName + "_correct"; - let mathinputPartialAnchor = "#" + mathinputName + "_partial"; - let mathinputIncorrectAnchor = "#" + mathinputName + "_incorrect"; - - let mathinput2Name = cesc2( - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName, - ); - let mathinput2Anchor = "#" + mathinput2Name + " textarea"; - let mathinput2SubmitAnchor = "#" + mathinput2Name + "_submit"; - let mathinput2CorrectAnchor = "#" + mathinput2Name + "_correct"; - let mathinput2PartialAnchor = "#" + mathinput2Name + "_partial"; - let mathinput2IncorrectAnchor = "#" + mathinput2Name + "_incorrect"; - - cy.get(mathinputSubmitAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).should("be.visible"); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type("10x^2{rightarrow}-4{enter}", { - force: true, - delay: 5, - }); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type("10x^2{rightarrow}-4{enter}", { - force: true, - delay: 5, - }); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Enter too large an error in exponent"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}10x^2.0004{rightarrow}-4", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}10x^2.0004{rightarrow}-4", - { force: true, delay: 5 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Small error in exponent"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}10x^2.0001{rightarrow}-4", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}10x^2.0001{rightarrow}-4", - { force: true, delay: 5 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Error in numbers not in exponents"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}10.0002x^2{rightarrow}-4.00008", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}10.0002x^2{rightarrow}-4.00008", - { force: true, delay: 5 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); - - it("symbolic, no simplification", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

2.15234262pi+e*25.602348230 - - - $_math1 - - -

- `, - }, - "*", - ); - }); - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = cesc2( - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName, - ); - let mathinputAnchor = "#" + mathinputName + " textarea"; - let mathinputSubmitAnchor = "#" + mathinputName + "_submit"; - let mathinputCorrectAnchor = "#" + mathinputName + "_correct"; - let mathinputPartialAnchor = "#" + mathinputName + "_partial"; - let mathinputIncorrectAnchor = "#" + mathinputName + "_incorrect"; - - cy.get(mathinputSubmitAnchor).should("be.visible"); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type("2.15234262pi+e*25.602348230{enter}", { - force: true, - delay: 5, - }); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Reordering not allowed"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}pi2.15234262+e*25.602348230", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}e*25.602348230+2.15234262pi", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Numeric evaluation not allowed"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}.35618172248981", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Round too much"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}2.15pi+e*25.602348230", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}2.15234262pi+2.73*25.602348230", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("acceptable rounding"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}2.152 3.142 + 2.718*25.6", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); - - // TODO: currently failing. Need to investigate - it.skip("symbolic, evaluate numbers, preserve order", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

sin(2pi+1x+4x+pi+6) - - - $_math1 - - -

- `, - }, - "*", - ); - }); - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = cesc2( - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName, - ); - let mathinputAnchor = "#" + mathinputName + " textarea"; - let mathinputSubmitAnchor = "#" + mathinputName + "_submit"; - let mathinputCorrectAnchor = "#" + mathinputName + "_correct"; - let mathinputPartialAnchor = "#" + mathinputName + "_partial"; - let mathinputIncorrectAnchor = "#" + mathinputName + "_incorrect"; - - cy.get(mathinputSubmitAnchor).should("be.visible"); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type("sin(2pi+1x+4x+pi+6){enter}", { - force: true, - delay: 5, - }); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Reordering not allowed"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}sin(2pi+pi+1x+4x+6)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Combining terms not allowed"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}sin(2pi+5x+pi+6)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Numeric evaluation OK"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}sin(6.28318+x+4x+9.14159)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Round too much"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}sin(6.28318+x+4x+9.14", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}6.28+x+4x+9.14159", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - }); - }); - - it("symbolic, evaluate numbers", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

sin(2pi+1x+4x+pi+6) - - - $_math1 - - -

- `, - }, - "*", - ); - }); - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = cesc2( - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName, - ); - let mathinputAnchor = "#" + mathinputName + " textarea"; - let mathinputSubmitAnchor = "#" + mathinputName + "_submit"; - let mathinputCorrectAnchor = "#" + mathinputName + "_correct"; - let mathinputPartialAnchor = "#" + mathinputName + "_partial"; - let mathinputIncorrectAnchor = "#" + mathinputName + "_incorrect"; - - cy.get(mathinputSubmitAnchor).should("be.visible"); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type("sin(2pi+1x+4x+pi+6){enter}", { - force: true, - delay: 5, - }); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Reordering allowed"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}sin(2pi+pi+1x+4x+6)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combining terms not allowed"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}sin(2pi+5x+pi+6)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Numeric evaluation OK"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}sin(6.28318+x+4x+9.14159)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}sin(x+15.42478+4x)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Round too much"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}sin(x+15.4+4x)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - }); - }); - - it("symbolic, full simplification", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

sin(2pi+1x+4x+pi+6) - - - $_math1 - - -

- `, - }, - "*", - ); - }); - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = cesc2( - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName, - ); - let mathinputAnchor = "#" + mathinputName + " textarea"; - let mathinputSubmitAnchor = "#" + mathinputName + "_submit"; - let mathinputCorrectAnchor = "#" + mathinputName + "_correct"; - let mathinputPartialAnchor = "#" + mathinputName + "_partial"; - let mathinputIncorrectAnchor = "#" + mathinputName + "_incorrect"; - - cy.get(mathinputSubmitAnchor).should("be.visible"); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type("sin(2pi+1x+4x+pi+6){enter}", { - force: true, - delay: 5, - }); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Reordering allowed"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}sin(2pi+pi+1x+4x+6)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combining terms allowed"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}sin(2pi+5x+pi+6)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Numeric evaluation OK"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}sin(6.28318+x+4x+9.14159)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}sin(15.42478+5x)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Round too much"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}sin(15.4+5x)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - }); - }); - }); - - it("expression with vector, matchPartial", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

(log(32x+c), 42) - - - $_math1 - - -

- `, - }, - "*", - ); - }); - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = cesc2( - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName, - ); - let mathinputAnchor = "#" + mathinputName + " textarea"; - let mathinputSubmitAnchor = "#" + mathinputName + "_submit"; - let mathinputCorrectAnchor = "#" + mathinputName + "_correct"; - let mathinputPartialAnchor = "#" + mathinputName + "_partial"; - let mathinputIncorrectAnchor = "#" + mathinputName + "_incorrect"; - - cy.get(mathinputSubmitAnchor).should("be.visible"); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type("(log(32x+c), 42){enter}", { - force: true, - delay: 5, - }); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Enter too large an error in first component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(log(32.04x+c), 42)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "50 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0.5); - }); - - cy.log("Enter too large an error in second component"); - cy.get(mathinputAnchor).type("{end}{leftArrow}.3", { - force: true, - delay: 5, - }); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0.0); - }); - - cy.log("shink error in first component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(log(32.01x+c), 42.3)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "50 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.5, 1e-14); - }); - - cy.log("Shrink error in second component"); - cy.get(mathinputAnchor).type("{end}{leftArrow}{leftArrow}0", { - force: true, - delay: 5, - }); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1.0); - }); - }); - }); - - it("expression with vector, matchPartial, unordered", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

(42, log(32x+c)) - - - $_math1 - - -

- `, - }, - "*", - ); - }); - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = cesc2( - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName, - ); - let mathinputAnchor = "#" + mathinputName + " textarea"; - let mathinputSubmitAnchor = "#" + mathinputName + "_submit"; - let mathinputCorrectAnchor = "#" + mathinputName + "_correct"; - let mathinputPartialAnchor = "#" + mathinputName + "_partial"; - let mathinputIncorrectAnchor = "#" + mathinputName + "_incorrect"; - - cy.get(mathinputSubmitAnchor).should("be.visible"); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type("(log(32x+c), 42){enter}", { - force: true, - delay: 5, - }); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Enter too large an error in first component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(log(32.04x+c), 42)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "50 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0.5); - }); - - cy.log("Enter too large an error in second component"); - cy.get(mathinputAnchor).type("{end}{leftArrow}.3", { - force: true, - delay: 5, - }); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0.0); - }); - - cy.log("shink error in first component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(log(32.01x+c), 42.3)", - { force: true, delay: 5 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "50 %"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(0.5, 1e-14); - }); - - cy.log("Shrink error in second component"); - cy.get(mathinputAnchor).type("{end}{leftArrow}{leftArrow}0", { - force: true, - delay: 5, - }); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1.0); - }); - }); - }); - - it("expression with math lists, matchPartial", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

log(32x+c) 42 - - - - - $mi1 $mi2 = $ml - - -

- `, - }, - "*", - ); - }); - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.get(cesc("#\\/ans_submit")).should("be.visible"); - - cy.log("Submit exact answer"); - cy.get(cesc("#\\/mi1") + " textarea").type("log(32x+c)", { - force: true, - delay: 5, - }); - cy.get(cesc("#\\/mi2") + " textarea").type("42", { - force: true, - delay: 5, - }); - - cy.get(cesc("#\\/ans_submit")).click(); - cy.get(cesc("#\\/ans_correct")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/ans"].stateValues.creditAchieved).eq(1); - }); - - cy.log("Enter too large an error in first component"); - cy.get(cesc("#\\/mi1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}log(32.04x+c)", - { force: true, delay: 5 }, - ); - cy.get(cesc("#\\/ans_submit")).click(); - cy.get(cesc("#\\/ans_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/ans"].stateValues.creditAchieved).eq(0.5); - }); - - cy.log("Enter too large an error in second component"); - cy.get(cesc("#\\/mi2") + " textarea").type("{end}.3{enter}", { - force: true, - delay: 5, - }); - cy.get(cesc("#\\/ans_submit")).click(); - cy.get(cesc("#\\/ans_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/ans"].stateValues.creditAchieved).eq(0.0); - }); - - cy.log("shink error in first component"); - cy.get(cesc("#\\/mi1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}log(32.01x+c)", - { force: true, delay: 5 }, - ); - cy.get(cesc("#\\/ans_submit")).click(); - cy.get(cesc("#\\/ans_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/ans"].stateValues.creditAchieved).closeTo( - 0.5, - 1e-14, - ); - }); - - cy.log("Shrink error in second component"); - cy.get(cesc("#\\/mi2") + " textarea").type("{end}{leftArrow}0", { - force: true, - delay: 5, - }); - cy.get(cesc("#\\/ans_submit")).click(); - cy.get(cesc("#\\/ans_correct")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/ans"].stateValues.creditAchieved).eq(1.0); - }); - }); - - it("expression with math lists, matchPartial, unordered", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

42 log(32x+c) - - - - - $mi1 $mi2 = $ml - - -

- `, - }, - "*", - ); - }); - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.get(cesc("#\\/ans_submit")).should("be.visible"); - - cy.log("Submit exact answer"); - cy.get(cesc("#\\/mi1") + " textarea").type("log(32x+c)", { - force: true, - delay: 5, - }); - cy.get(cesc("#\\/mi2") + " textarea").type("42", { - force: true, - delay: 5, - }); - - cy.get(cesc("#\\/ans_submit")).click(); - cy.get(cesc("#\\/ans_correct")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/ans"].stateValues.creditAchieved).eq(1); - }); - - cy.log("Enter too large an error in first component"); - cy.get(cesc("#\\/mi1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}log(32.04x+c)", - { force: true, delay: 5 }, - ); - cy.get(cesc("#\\/ans_submit")).click(); - cy.get(cesc("#\\/ans_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/ans"].stateValues.creditAchieved).eq(0.5); - }); - - cy.log("Enter too large an error in second component"); - cy.get(cesc("#\\/mi2") + " textarea").type("{end}.3", { - force: true, - delay: 5, - }); - cy.get(cesc("#\\/ans_submit")).click(); - cy.get(cesc("#\\/ans_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/ans"].stateValues.creditAchieved).eq(0.0); - }); - - cy.log("shink error in first component"); - cy.get(cesc("#\\/mi1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}log(32.01x+c)", - { force: true, delay: 5 }, - ); - cy.get(cesc("#\\/ans_submit")).click(); - cy.get(cesc("#\\/ans_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/ans"].stateValues.creditAchieved).closeTo( - 0.5, - 1e-14, - ); - }); - - cy.log("Shrink error in second component"); - cy.get(cesc("#\\/mi2") + " textarea").type("{end}{leftArrow}0", { - force: true, - delay: 5, - }); - cy.get(cesc("#\\/ans_submit")).click(); - cy.get(cesc("#\\/ans_correct")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/ans"].stateValues.creditAchieved).eq(1.0); - }); - }); -}); diff --git a/packages/test-cypress/cypress/e2e/answerValidation/factoring.cy.js b/packages/test-cypress/cypress/e2e/answerValidation/factoring.cy.js deleted file mode 100644 index 6cb6df4f5..000000000 --- a/packages/test-cypress/cypress/e2e/answerValidation/factoring.cy.js +++ /dev/null @@ -1,1948 +0,0 @@ -import { cesc } from "@doenet/utils"; - -describe("factor polynomial tests", function () { - beforeEach(() => { - cy.clearIndexedDB(); - cy.visit("/"); - }); - - it("factor x^2-1", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - (x-1)(x+1) - $poly - - -

Question: Factor the polynomial $polyExpandSimplify.

- -

Answer

- -

Default setting: - - - $ans$poly - - -

-

Restrict division: - - - $ans$poly - - -

-

Monomial factor must match: - - - $ans$poly - - -

-

Allow only sign differences in factors: - - - $ans$poly - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.log("x^2-1"); - cy.get(cesc("#\\/ans") + " textarea").type("x^2{rightArrow}-1{enter}", { - force: true, - }); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(2x^2-2)/2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2x^2{rightArrow}-2)/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(x-1)(x+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x-1)(x+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("(1-x)(x+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(1-x)(x+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("-(1-x)(x+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}-(1-x)(x+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("swap minus signs twice"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{home}{rightarrow}{backspace}{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.get(cesc("#\\/ans") + " textarea").type("{home}-{enter}", { - force: true, - }); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("(1-x)(-1-x)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(1-x)(-1-x){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("-(1-x)(-1-x)"); - cy.get(cesc("#\\/ans") + " textarea").type("{home}-{enter}", { - force: true, - }); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("-(x-1)(-1-x)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}-(x-1)(-1-x){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("(x^2-1)x/x"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x^2{rightArrow}-1)x/x{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(x^2-1)5/5"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}{backspace}(x^2{rightArrow}-1)5/5{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("((x-1)(x+1))"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}((x-1)(x+1)){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("(2x-2)(x+1)/2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2x-2)(x+1)/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(2x-2)(x+1)(1/2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2x-2)(x+1)(1/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("1/2(2x-2)(x+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}1/2{rightarrow}(2x-2)(x+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("0.5(2x-2)(x+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}0.5(2x-2)(x+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("0.25(2x-2)(2x+2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}0.25(2x-2)(2x+2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("sqrt(x^2-1)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}sqrtx^2{rightArrow}-1{rightArrow}^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("sqrt(2x^2-2)sqrt((x^2-1)/2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}sqrt2x^2{rightArrow}-2{rightArrow}sqrt(x^2{rightArrow}-1)/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("sqrt(4x^2-4)sqrt(x^2-1)/4"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}sqrt4x^2{rightArrow}-4{rightArrow}sqrt(x^2{rightArrow}-1)/4{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(x^2-1)(cos^2x+sin^2x)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x^2{rightArrow}-1)(cos^2{rightArrow}x+sin^2{rightArrow}x{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(x-1)(x+1)(cos^2x+sin^2x)/(sin^2x+cos^2x)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x-1)(x+1)(cos^2{rightArrow}x+sin^2{rightArrow}x){shift+leftArrow}/(sin^2{rightArrow}x+cos^2{rightArrow}x{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(x/3-1/3)(3x+3)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x/3{rightArrow}-1/3{rightArrow})(3x+3){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - }); - - it("factor 4x^2-4", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - 4(x-1)(x+1) - $poly - - -

Question: Factor the polynomial $polyExpandSimplify.

- -

Answer

- -

Default setting: - - - $ans$poly - - -

-

Restrict division: - - - $ans$poly - - -

-

Monomial factor must match: - - - $ans$poly - - -

-

Allow only sign differences in factors: - - - $ans$poly - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.log("4x^2-4"); - cy.get(cesc("#\\/ans") + " textarea").type( - "4x^2{rightArrow}-4{enter}", - { - force: true, - }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("4(x-1)(x+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4(x-1)(x+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("4(1-x)(x+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4(1-x)(x+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("4(1-x)(-1-x)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4(1-x)(-1-x){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("-4(1-x)(1+x)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}-4(1-x)(1+x){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("(1-x)(1+x)(-4)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(1-x)(1+x)(-4){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("4(2x-2)(1/2+x/2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4(2x-2)(1/2{rightArrow}+x/2{rightArrow}){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("2(1-x)(1+x)(-2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}2(1-x)(1+x)(-2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(2x-2)(x+1)2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2x-2)(x+1)2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("2(x-1)(2x+2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}2(x-1)(2x+2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(3x-3)(8x+8)/6"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(3x-3)(8x+8)/6{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(3x-3)(8x+8)(1/6)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(3x-3)(8x+8)(1/6{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(6x-6)(8x+8)(1/6)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(6x-6)(8x+8)(1/6{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("0.5(6x-6)(4x+4)(1/3)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}0.5(6x-6)(4x+4)(1/3{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - }); - - it("factor (6z-4)(5z+10)", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - (6z-4)(5z+10) - $poly - - -

Question: Factor the polynomial $polyExpandSimplify.

- -

Answer

- -

Default setting: - - - $ans$poly - - -

-

Restrict division: - - - $ans$poly - - -

-

Monomial factor must match: - - - $ans$poly - - -

-

Allow only sign differences in factors: - - - $ans$poly - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.log("30z^2+40z-40"); - cy.get(cesc("#\\/ans") + " textarea").type( - "30z^2{rightArrow}+40z-40{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(6z-4)(5z+10)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(6z-4)(5z+10){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("-(4-6z)(5z+10)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}-(4-6z)(5z+10){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("(30z-20)(z+2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(30z-20)(z+2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("-(2-3z)(10z+20)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}-(2-3z)(10z+20){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("5(6z-4)(z+2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}5(6z-4)(z+2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("5(4-6z)(z+2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}5(4-6z)(z+2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("5(2-3z)(z+2)(-2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}5(2-3z)(z+2)(-2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("15(2-3z)(z+2)(-2)(1/3"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}15(2-3z)(z+2)(-2)(1/3{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("15(2-3z)(z+2)(-2)/3"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}15(2-3z)(z+2)(-2)/3{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("15(2-3z)3(z+2)(-2)/9)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}15(2-3z)3(z+2)(-2)/9{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("15(2-3z)3(z+2)(-2)(1/9)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}15(2-3z)3(z+2)(-2)(1/9{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - }); - - it("factor (6z-4)(z+2)5", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - (6z-4)(z+2)5 - $poly - - -

Question: Factor the polynomial $polyExpandSimplify.

- -

Answer

- -

Default setting: - - - $ans$poly - - -

-

Restrict division: - - - $ans$poly - - -

-

Monomial factor must match: - - - $ans$poly - - -

-

Allow only sign differences in factors: - - - $ans$poly - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.log("30z^2+40z-40"); - cy.get(cesc("#\\/ans") + " textarea").type( - "30z^2{rightArrow}+40z-40{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(6z-4)(5z+10)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(6z-4)(5z+10){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("5(6z-4)(z+2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}5(6z-4)(z+2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("5(3z-2)(2z+4)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}5(3z-2)(2z+4){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("5(4-6z)(z+2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}5(4-6z)(z+2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("5(2-3z)(z+2)(-2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}5(2-3z)(z+2)(-2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("15(2-3z)(z+2)(-2)(1/3"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}15(2-3z)(z+2)(-2)(1/3{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("15(2-3z)(z+2)(-2)/3"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}15(2-3z)(z+2)(-2)/3{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("15(2-3z)3(z+2)(-2)/9)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}15(2-3z)3(z+2)(-2)/9{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("15(2-3z)3(z+2)(-2)(1/9)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}15(2-3z)3(z+2)(-2)(1/9{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - }); - - it("factor (2x+4)^2", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - (2x+4)^2 - $poly - - -

Question: Factor the polynomial $polyExpandSimplify.

- -

Answer

- -

Default setting: - - - $ans$poly - - -

-

Restrict division: - - - $ans$poly - - -

-

Monomial factor must match: - - - $ans$poly - - -

-

Allow only sign differences in factors: - - - $ans$poly - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.log("4x^2+16x+16"); - cy.get(cesc("#\\/ans") + " textarea").type( - "4x^2{rightArrow}+16x+16{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("4(x^2+4x+4)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4(x^2{rightArrow}+4x+4){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("4(x+2)(x+2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4(x+2)(x+2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("4(x+2)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4(x+2)^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(2x+4)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2x+4)^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("(2(x+2))^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2(x+2))^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(x+4+x)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x+4+x)^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("(4x+8)(x+2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(4x+8)(x+2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("4sqrt(x^2+4x+4)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4sqrtx^2{rightArrow}+4x+4{rightArrow}^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("sqrt(4x^2+16x+16)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}sqrt4x^2{rightArrow}+16x+16{rightArrow}^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - }); - - it("factor 2^2(x+2)^2", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - 2^2(x+2)^2 - $poly - - -

Question: Factor the polynomial $polyExpandSimplify.

- -

Answer

- -

Default setting: - - - $ans$poly - - -

-

Restrict division: - - - $ans$poly - - -

-

Monomial factor must match: - - - $ans$poly - - -

-

Allow only sign differences in factors: - - - $ans$poly - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.log("4x^2+16x+16"); - cy.get(cesc("#\\/ans") + " textarea").type( - "4x^2{rightArrow}+16x+16{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("4(x^2+4x+4)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4(x^2{rightArrow}+4x+4){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("4(x+2)(x+2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4(x+2)(x+2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("4(x+2)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4(x+2)^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("(2x+4)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2x+4)^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(2(x+2))^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2(x+2))^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(x+4+x)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x+4+x)^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(4x+8)(x+2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(4x+8)(x+2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("4sqrt(x^2+4x+4)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4sqrtx^2{rightArrow}+4x+4{rightArrow}^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("sqrt(4x^2+16x+16)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}sqrt4x^2{rightArrow}+16x+16{rightArrow}^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("4(2x+4)(x/2+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4(2x+4)(x/2{rightArrow}+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - }); - - it("factor (x-1/2)(x+1)", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - (x-1/2)(x+1) - $poly - - -

Question: Factor the polynomial $polyExpandSimplify.

- -

Answer

- -

Default setting: - - - $ans$poly - - -

-

Restrict division: - - - $ans$poly - - -

-

Monomial factor must match: - - - $ans$poly - - -

-

Allow only sign differences in factors: - - - $ans$poly - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.log("x^2+x/2-1/2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "x^2{rightArrow}+x/2{rightArrow}-1/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(x+1)(x-1/2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x+1)(x-1/2{rightArrow}){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("(x+1)(2x-1)/2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x+1)(2x-1)/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(x+1)(2x-1)(1/2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x+1)(2x-1)(1/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("-(x+1)(1-2x)(1/2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}-(x+1)(1-2x)(1/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(x+1)(1-2x)(1/2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x+1)(1-2x)(1/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(x+1)(-1)(1-2x)(1/2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x+1)(-1)(1-2x)(1/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(x+1)(1-2x)(-1/2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x+1)(1-2x)(-1/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(x+1)(1-2x)(-1/2), other form"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x+1)(1-2x)(-1{shift+leftarrow}{shift+leftarrow}/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(x+1)(1-2x)(1/-2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x+1)(1-2x)(1/-2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("-(x+1)(2x-1)(-1/2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}-(x+1)(2x-1)(-1/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("-(x+1)(1/2-x)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}-(x+1)(1/2{rightArrow}-x){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("(x+1)(1)(x-1/2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x+1)(1)(x-1/2{rightArrow}){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("(x+1)(-1)(1/2-x)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x+1)(-1)(1/2{rightArrow}-x){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("(x/2+1/2)(2x-1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x/2{rightArrow}+1/2{rightArrow})(2x-1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(x/2+1/2)(-1)(1-2x)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x/2{rightArrow}+1/2{rightArrow})(-1)(1-2x){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - }); - - it("factor (x-1)(x+1)^2", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - (x-1)(x+1)^2 - $poly - (x+1)(x^2-1) - - -

Question: Factor the polynomial $polyExpandSimplify.

- -

Answer

- -

Default setting: - - - $ans$poly - - - - - $ans$partialFactor - - -

-

Restrict division: - - - $ans$poly - - - - - $ans$partialFactor - - -

-

Monomial factor must match: - - - $ans$poly - - - - - $ans$partialFactor - - -

-

Allow only sign differences in factors: - - - $ans$poly - - - - - $ans$partialFactor - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.log("x^3+x^2-x-1"); - cy.get(cesc("#\\/ans") + " textarea").type( - "x^3{rightArrow}+x^2{rightArrow}-x-1{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(x-1)(x+1)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x-1)(x+1)^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("(x+1)(x-1)(x+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x+1)(x-1)(x+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_correct")).should("be.visible"); - - cy.log("(x^2-1)(x+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x^2{rightArrow}-1)(x+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_partial")).should("contain.text", "50%"); - cy.get(cesc("#\\/check_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_partial")).should("contain.text", "50%"); - cy.get(cesc("#\\/checkRD_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_partial")).should("contain.text", "50%"); - cy.get(cesc("#\\/checkMM_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_partial")).should("contain.text", "50%"); - cy.get(cesc("#\\/checkSD_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - - cy.log("(1/4*x-1/4)(2x+2)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(1/4{rightArrow}x-1/4{rightArrow})(2x+2)^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_correct")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("(x-1)(x^2+2x+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x-1)(x^2{rightArrow}+2x+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_partial")).should("contain.text", "50%"); - cy.get(cesc("#\\/check_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_partial")).should("contain.text", "50%"); - cy.get(cesc("#\\/checkRD_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_partial")).should("contain.text", "50%"); - cy.get(cesc("#\\/checkMM_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("2(x+1)(x-1)(x+1)/2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}2(x+1)(x-1)(x+1)/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - - cy.log("2(x+1)(x-1)(x+1)(1/2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}2(x+1)(x-1)(x+1)(1/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - cy.get(cesc("#\\/checkRD_submit")).click(); - cy.get(cesc("#\\/checkRD_correct")).should("be.visible"); - cy.get(cesc("#\\/checkMM_submit")).click(); - cy.get(cesc("#\\/checkMM_incorrect")).should("be.visible"); - cy.get(cesc("#\\/checkSD_submit")).click(); - cy.get(cesc("#\\/checkSD_incorrect")).should("be.visible"); - }); -}); diff --git a/packages/test-cypress/cypress/e2e/answerValidation/factoringOldAlgorithm.cy.js b/packages/test-cypress/cypress/e2e/answerValidation/factoringOldAlgorithm.cy.js deleted file mode 100644 index 2b02e7172..000000000 --- a/packages/test-cypress/cypress/e2e/answerValidation/factoringOldAlgorithm.cy.js +++ /dev/null @@ -1,895 +0,0 @@ -import { cesc } from "@doenet/utils"; - -describe("factor polynomial tests, old algorithm", function () { - beforeEach(() => { - cy.clearIndexedDB(); - cy.visit("/"); - }); - - // Note: even through have a better factoring test, - // we are keeping these tests, as they probe how well - // we can handle components that change type - // (due to the multiple conditionalContents that are copied) - it("factor x^2-1", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - x^2-1 - $poly - $ans - $ans - $ansSimplify - - - * - / - ^ - + - - - $ansSimplify - $temp - - $ansSimplify $originalOperator - - - - $ansNoMinus - $ansNoMinus - $temp2 - - $ansNoMinus 1 $postMinusOperator - - $numerator - $numerator - - - $numerator - $temp3 - - $numerator $numeratorOperator - - - -

Question: Factor the polynomial $polyExpandSimplify.

- -

Answer

- - - - - $ansExpandSimplify = $polyExpandSimplify - and - ( - ( - $innerOperator = $pow - and - $innerPiece = $add - ) - or - $innerOperator = $mult - and - $denominator - and - ( - $innerPiece = 3 - or - not $innerPiece - ) - ) - - - - `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.log("x^2-1"); - cy.get(cesc("#\\/ans") + " textarea").type("x^2{rightArrow}-1{enter}", { - force: true, - }); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("(2x^2-2)/2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2x^2{rightArrow}-2)/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("(x-1)(x+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x-1)(x+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("(1-x)(x+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(1-x)(x+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("-(1-x)(x+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}-(1-x)(x+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - // verify bug from changing component types is fixed - cy.log("swap minus signs a few times"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{home}{rightarrow}{backspace}{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/ans") + " textarea").type("{home}-{enter}", { - force: true, - }); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.get(cesc("#\\/ans") + " textarea").type( - "{home}{rightarrow}{backspace}{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/ans") + " textarea").type("{home}-{enter}", { - force: true, - }); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.get(cesc("#\\/ans") + " textarea").type( - "{home}{rightarrow}{backspace}{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - cy.get(cesc("#\\/ans") + " textarea").type("{home}-{enter}", { - force: true, - }); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("(1-x)(-1-x)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(1-x)(-1-x){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("-(1-x)(-1-x)"); - cy.get(cesc("#\\/ans") + " textarea").type("{home}-{enter}", { - force: true, - }); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("-(x-1)(-1-x)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}-(x-1)(-1-x){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("(x^2-1)x/x"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x^2{rightArrow}-1)x/x{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("(x^2-1)5/5"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}{backspace}(x^2{rightArrow}-1)5/5{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("((x-1)(x+1))"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}((x-1)(x+1)){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("(2x-2)(x+1)/2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2x-2)(x+1)/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("1/2(2x-2)(x+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}1/2{rightarrow}(2x-2)(x+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("0.5(2x-2)(x+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}0.5(2x-2)(x+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("0.25(2x-2)(2x+2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}0.25(2x-2)(2x+2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("sqrt(x^2-1)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}sqrtx^2{rightArrow}-1{rightArrow}^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("sqrt(2x^2-2)sqrt((x^2-1)/2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}sqrt2x^2{rightArrow}-2{rightArrow}sqrt(x^2{rightArrow}-1)/2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("sqrt(4x^2-4)sqrt(x^2-1)/4"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}sqrt4x^2{rightArrow}-4{rightArrow}sqrt(x^2{rightArrow}-1)/4{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - }); - - it("factor 4x^2-4", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - 4x^2-4 - $poly - $ans - $ans - $ansSimplify - - - * - / - ^ - + - - - $ansSimplify - $temp - - $ansSimplify $originalOperator - - - - $ansNoMinus - $ansNoMinus - $temp2 - - $ansNoMinus 1 $postMinusOperator - - $numerator - $numerator - - - $numerator - $temp3 - - $numerator $numeratorOperator - - - -

Question: Factor the polynomial $polyExpandSimplify.

- -

Answer

- - - - - $ansExpandSimplify = $polyExpandSimplify - and - ( - ( - $innerOperator = $pow - and - $innerPiece = $add - ) - or - $innerOperator = $mult - and - $denominator - and - ( - $innerPiece = 3 - or - not $innerPiece - ) - ) - - - - `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.log("4x^2-4"); - cy.get(cesc("#\\/ans") + " textarea").type( - "4x^2{rightArrow}-4{enter}", - { - force: true, - }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("4(x-1)(x+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4(x-1)(x+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("4(1-x)(x+1)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4(1-x)(x+1){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("4(1-x)(-1-x)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4(1-x)(-1-x){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("-4(1-x)(1+x)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}-4(1-x)(1+x){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("(1-x)(1+x)(-4)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(1-x)(1+x)(-4){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("2(1-x)(1+x)(-2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}2(1-x)(1+x)(-2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("(2x-2)(x+1)2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2x-2)(x+1)2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("2(x-1)(2x+2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}2(x-1)(2x+2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("(3x-3)(8x+8)/6"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(3x-3)(8x+8)/6{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("(6x-6)(8x+8)/6"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(6x-6)(8x+8)/6{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("0.5(6x-6)(4x+4)/3"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}0.5(6x-6)(4x+4)/3{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - }); - - it("factor (6z-4)(5z+10)", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - (6z-4)(5z+10) - $poly - $ans - $ans - $ansSimplify - - - * - / - ^ - + - - - $ansSimplify - $temp - - $ansSimplify $originalOperator - - - - $ansNoMinus - $ansNoMinus - $temp2 - - $ansNoMinus 1 $postMinusOperator - - $numerator - $numerator - - - $numerator - $temp3 - - $numerator $numeratorOperator - - - -

Question: Factor the polynomial $polyExpandSimplify.

- -

Answer

- - - - - $ansExpandSimplify = $polyExpandSimplify - and - ( - ( - $innerOperator = $pow - and - $innerPiece = $add - ) - or - $innerOperator = $mult - and - $denominator - and - ( - $innerPiece = 3 - or - not $innerPiece - ) - ) - - - - `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.log("30z^2+40z-40"); - cy.get(cesc("#\\/ans") + " textarea").type( - "30z^2{rightArrow}+40z-40{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("(6z-4)(5z+10)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(6z-4)(5z+10){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("5(6z-4)(z+2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}5(6z-4)(z+2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("5(4-6z)(z+2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}5(4-6z)(z+2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("5(2-3z)(z+2)(-2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}5(2-3z)(z+2)(-2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("15(2-3z)(z+2)(-2)/3"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}15(2-3z)(z+2)(-2)/3{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("15(2-3z)3(z+2)(-2)/9"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}15(2-3z)3(z+2)(-2)/9{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - }); - - it("factor (3q+2r)(6s+8t)", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - (3q+2r)(6s+8t) - $poly - $ans - $ans - $ansSimplify - - - * - / - ^ - + - - - $ansSimplify - $temp - - $ansSimplify $originalOperator - - - - $ansNoMinus - $ansNoMinus - $temp2 - - $ansNoMinus 1 $postMinusOperator - - $numerator - $numerator - - - $numerator - $temp3 - - $numerator $numeratorOperator - - - -

Question: Factor the polynomial $polyExpandSimplify.

- -

Answer

- - - - - $ansExpandSimplify = $polyExpandSimplify - and - ( - ( - $innerOperator = $pow - and - $innerPiece = $add - ) - or - $innerOperator = $mult - and - $denominator - and - ( - $innerPiece = 3 - or - not $innerPiece - ) - ) - - - - `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.log("18qs+24qt+12rs+16rt"); - cy.get(cesc("#\\/ans") + " textarea").type( - "30z^2{rightArrow}+40z-40{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("(3q+2r)(6s+8t)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(3q+2r)(6s+8t){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("3q(6s+8t) + 2r(6s+8t)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}3q(6s+8t) + 2r(6s+8t){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("(6s+8t)(3q+2r)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(6s+8t)(3q+2r){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("(8t+6s)(3q+2r)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(8t+6s)(3q+2r){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("(8t+6s)(2r+3q)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(8t+6s)(2r+3q){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("(8t+6s)(2r+q+q+q)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(8t+6s)(2r+q+q+q){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("(4t+3s)2(2r+3q)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(4t+3s)2(2r+3q){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - }); - - it("factor (2x+4)^2", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - (2x+4)^2 - $poly - $ans - $ans - $ansSimplify - - - * - / - ^ - + - - - $ansSimplify - $temp - - $ansSimplify $originalOperator - - - - $ansNoMinus - $ansNoMinus - $temp2 - - $ansNoMinus 1 $postMinusOperator - - $numerator - $numerator - - - $numerator - $temp3 - - $numerator $numeratorOperator - - - -

Question: Factor the polynomial $polyExpandSimplify.

- -

Answer

- - - - - $ansExpandSimplify = $polyExpandSimplify - and - ( - ( - $innerOperator = $pow - and - $innerPiece = $add - ) - or - $innerOperator = $mult - and - $denominator - and - ( - $innerPiece = 3 - or - not $innerPiece - ) - ) - - - - `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.log("4x^2+16x+16"); - cy.get(cesc("#\\/ans") + " textarea").type( - "4x^2{rightArrow}+16x+16{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("4(x^2+4x+4)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4(x^2{rightArrow}+4x+4){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("4(x+2)(x+2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4(x+2)(x+2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("4(x+2)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4(x+2)^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("(2x+4)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2x+4)^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("(2(x+2))^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2(x+2))^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("(x+4+x)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(x+4+x)^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("(4x+8)(x+2)"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(4x+8)(x+2){enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_correct")).should("be.visible"); - - cy.log("4sqrt(x^2+4x+4)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}4sqrtx^2{rightArrow}+4x+4{rightArrow}^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - - cy.log("sqrt(4x^2+16x+16)^2"); - cy.get(cesc("#\\/ans") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}sqrt4x^2{rightArrow}+16x+16{rightArrow}^2{enter}", - { force: true }, - ); - cy.get(cesc("#\\/check_submit")).click(); - cy.get(cesc("#\\/check_incorrect")).should("be.visible"); - }); -}); diff --git a/packages/test-cypress/cypress/e2e/answerValidation/functionanswers.cy.js b/packages/test-cypress/cypress/e2e/answerValidation/functionanswers.cy.js deleted file mode 100644 index a670fdc26..000000000 --- a/packages/test-cypress/cypress/e2e/answerValidation/functionanswers.cy.js +++ /dev/null @@ -1,356 +0,0 @@ -import { cesc } from "@doenet/utils"; - -describe("Function answer validation tests", function () { - beforeEach(() => { - cy.clearIndexedDB(); - cy.visit("/"); - }); - - it("simple function of input", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - cos(2*pi*x) - -

Enter a number close to an integer: - - - - true - - -

- `, - }, - "*", - ); - }); - - let partialCredit005 = Math.cos(2 * Math.PI * 0.05); - let partialCredit01 = Math.cos(2 * Math.PI * 0.1); - let partialCredit015 = Math.cos(2 * Math.PI * 0.15); - let partialCredit02 = Math.cos(2 * Math.PI * 0.2); - let partialCredit005Percent = Math.round( - Math.cos(2 * Math.PI * 0.05) * 100, - ); - let partialCredit01Percent = Math.round( - Math.cos(2 * Math.PI * 0.1) * 100, - ); - let partialCredit015Percent = Math.round( - Math.cos(2 * Math.PI * 0.15) * 100, - ); - let partialCredit02Percent = Math.round( - Math.cos(2 * Math.PI * 0.2) * 100, - ); - - cy.get(cesc("#\\/x_submit")).should("be.visible"); - - cy.log("Submit empty answer"); - cy.get(cesc("#\\/x_submit")).click(); - cy.get(cesc("#\\/x_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Submit correct answers"); - cy.get(cesc("#\\/x") + " textarea").type("7", { force: true }); - cy.get(cesc("#\\/x_submit")).click(); - cy.get(cesc("#\\/x_correct")).should("be.visible"); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - cy.get(cesc("#\\/x") + " textarea").type("{end}{backspace}0", { - force: true, - }); - cy.get(cesc("#\\/x_submit")).click(); - cy.get(cesc("#\\/x_correct")).should("be.visible"); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - cy.get(cesc("#\\/x") + " textarea").type("{end}{backspace}-14", { - force: true, - }); - cy.get(cesc("#\\/x_submit")).click(); - cy.get(cesc("#\\/x_correct")).should("be.visible"); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - cy.get(cesc("#\\/x") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}33", - { force: true }, - ); - cy.get(cesc("#\\/x_submit")).click(); - cy.get(cesc("#\\/x_correct")).should("be.visible"); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - cy.get(cesc("#\\/x") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}-102351", - { force: true }, - ); - cy.get(cesc("#\\/x_submit")).click(); - cy.get(cesc("#\\/x_correct")).should("be.visible"); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - - cy.log("Submit incorrect answers"); - cy.get(cesc("#\\/x") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}9.5", - { force: true }, - ); - cy.get(cesc("#\\/x_submit")).click(); - cy.get(cesc("#\\/x_incorrect")).should("be.visible"); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - cy.get(cesc("#\\/x") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}x^2", - { force: true }, - ); - cy.get(cesc("#\\/x_submit")).click(); - cy.get(cesc("#\\/x_incorrect")).should("be.visible"); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - cy.get(cesc("#\\/x") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}-253.3", - { force: true }, - ); - cy.get(cesc("#\\/x_submit")).click(); - cy.get(cesc("#\\/x_incorrect")).should("be.visible"); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - cy.get(cesc("#\\/x") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}23.6", - { force: true }, - ); - cy.get(cesc("#\\/x_submit")).click(); - cy.get(cesc("#\\/x_incorrect")).should("be.visible"); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Submit partially correct answers"); - cy.get(cesc("#\\/x") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}11.9", - { force: true }, - ); - cy.get(cesc("#\\/x_submit")).click(); - cy.get(cesc("#\\/x_partial")).should( - "have.text", - `${partialCredit01Percent} %`, - ); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(partialCredit01, 1e-12); - }); - cy.get(cesc("#\\/x") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}73.15", - { force: true }, - ); - cy.get(cesc("#\\/x_submit")).click(); - cy.get(cesc("#\\/x_partial")).should( - "have.text", - `${partialCredit015Percent} %`, - ); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(partialCredit015, 1e-12); - }); - cy.get(cesc("#\\/x") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}-103.8", - { force: true }, - ); - cy.get(cesc("#\\/x_submit")).click(); - cy.get(cesc("#\\/x_partial")).should( - "have.text", - `${partialCredit02Percent} %`, - ); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(partialCredit02, 1e-12); - }); - cy.get(cesc("#\\/x") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}-0.05", - { force: true }, - ); - cy.get(cesc("#\\/x_submit")).click(); - cy.get(cesc("#\\/x_partial")).should( - "have.text", - `${partialCredit005Percent} %`, - ); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(partialCredit005, 1e-12); - }); - }); - - it("function with parameters", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - -

Offset:

-

Period:

-

Magnitude

- $magnitude cos(2*pi*(x-$offset)/$period) -

Enter a number: - - - - true - - -

- `, - }, - "*", - ); - }); - - // let offsets = [0, Math.E,]; - let offsets = [Math.E]; - let periods = [2, Math.PI / 2]; - let magnitudes = [0.5, 2]; - - let partialCredit = (o, p, m, x) => - Math.max(0, Math.min(1, m * Math.cos((2 * Math.PI * (x - o)) / p))); - let partialCreditPercent = (o, p, m, x) => - Math.round(partialCredit(o, p, m, x) * 100); - - let numberAnswers = [Math.E, 0, 2 / 3, -Math.PI / 2, -252351.9]; - - cy.get(cesc("#\\/x_submit")).should("be.visible"); - - cy.log("Submit empty answer"); - cy.get(cesc("#\\/x_submit")).click(); - cy.get(cesc("#\\/x_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - for (let offset of offsets) { - cy.get(cesc("#\\/offset") + " textarea").type( - `{ctrl+home}{shift+end}{backspace}${offset}{enter}`, - { force: true, delay: 0 }, - ); - for (let period of periods) { - cy.get(cesc("#\\/period") + " textarea").type( - `{ctrl+home}{shift+end}{backspace}${period}{enter}`, - { force: true, delay: 0 }, - ); - for (let magnitude of magnitudes) { - cy.get(cesc("#\\/magnitude") + " textarea").type( - `{ctrl+home}{shift+end}{backspace}${magnitude}{enter}`, - { force: true, delay: 0 }, - ); - - let maximals = [ - offset, - offset + 2 * period, - offset - 7 * period, - ]; - let minimals = [ - offset + 1.5 * period, - offset + 5.5 * period, - offset - 7.5 * period, - ]; - - cy.log("Submit answers"); - for (let ans of [ - ...maximals, - ...minimals, - ...numberAnswers, - ]) { - cy.get(cesc("#\\/x") + " textarea").type( - `{ctrl+home}{shift+end}{backspace}${ans}`, - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/x_submit")).click(); - - let credit = partialCredit( - offset, - period, - magnitude, - ans, - ); - if (credit === 1) { - cy.get(cesc("#\\/x_correct")).should("be.visible"); - } else if (credit === 0) { - cy.get(cesc("#\\/x_incorrect")).should( - "be.visible", - ); - } else { - let percent = partialCreditPercent( - offset, - period, - magnitude, - ans, - ); - cy.get(cesc("#\\/x_partial")).should( - "have.text", - `${percent} %`, - ); - - cy.window().then(async (win) => { - let stateVariables = - await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues - .creditAchieved, - ).closeTo(credit, 1e-8); - }); - } - } - } - } - } - }); -}); diff --git a/packages/test-cypress/cypress/e2e/answerValidation/matchingpatterns.cy.js b/packages/test-cypress/cypress/e2e/answerValidation/matchingpatterns.cy.js deleted file mode 100644 index ae099864b..000000000 --- a/packages/test-cypress/cypress/e2e/answerValidation/matchingpatterns.cy.js +++ /dev/null @@ -1,314 +0,0 @@ -import { cesc } from "@doenet/utils"; - -describe("matching patterns answer tests", function () { - beforeEach(() => { - cy.clearIndexedDB(); - cy.visit("/"); - }); - - it("enter any quadratic", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - ()$var^2+()$var+() - ()$var^2+() - - -

-

Enter a quadratic expression in the variable : - - - - - $resp - - or - - $resp - - - - - $excludeX1.patternMatches[1]{assignNamesSkip="1"} $excludeX1.patternMatches[2]{assignNamesSkip="1"} $excludeX1.patternMatch3{assignNamesSkip="1"} - $excludeX2.patternMatches[1]{assignNamesSkip="1"} 0 $excludeX2.patternMatch2 - - - -

- -

Submitted answer: $ans.submittedResponse

-

Quadratic coeff: $ans.submittedResponse2

-

Linear coeff: $ans.submittedResponse3

-

Constant term: $ans.submittedResponse4

- - - `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - let desiredResults = { - x: { - "": { - correct: false, - response: ["\uff3f", "\uff3f"], - }, - "x^2": { - correct: true, - response: [["^", "x", 2], "x2"], - matches: [ - [1, "1"], - [0, "0"], - [0, "0"], - ], - }, - "x^2{rightArrow}+1": { - correct: true, - response: [["+", ["^", "x", 2], 1], "x2+1"], - matches: [ - [1, "1"], - [0, "0"], - [1, "1"], - ], - }, - "x^2{rightArrow}+x": { - correct: true, - response: [["+", ["^", "x", 2], "x"], "x2+x"], - matches: [ - [1, "1"], - [1, "1"], - [0, "0"], - ], - }, - "x^2{rightArrow}+x+x": { - correct: false, - response: [["+", ["^", "x", 2], "x", "x"], "x2+x+x"], - }, - "x^2{rightArrow}+c": { - correct: true, - response: [["+", ["^", "x", 2], "c"], "x2+c"], - matches: [ - [1, "1"], - [0, "0"], - ["c", "c"], - ], - }, - "xx^2{rightArrow}+c": { - correct: false, - response: [["+", ["*", "x", ["^", "x", 2]], "c"], "xx2+c"], - }, - "x^2{rightArrow}+x+c+d": { - correct: true, - response: [["+", ["^", "x", 2], "x", "c", "d"], "x2+x+c+d"], - matches: [ - [1, "1"], - [1, "1"], - [["+", "c", "d"], "c+d"], - ], - }, - "ax^2{rightArrow}+bx+c": { - correct: true, - response: [ - ["+", ["*", "a", ["^", "x", 2]], ["*", "b", "x"], "c"], - "ax2+bx+c", - ], - matches: [ - ["a", "a"], - ["b", "b"], - ["c", "c"], - ], - }, - "ay^2{rightArrow}+by+c": { - correct: false, - response: [ - ["+", ["*", "a", ["^", "y", 2]], ["*", "b", "y"], "c"], - "ay2+by+c", - ], - }, - "sqrt2{rightArrow}x^2{rightArrow}+5/8{rightArrow}x+e^y": { - correct: true, - response: [ - [ - "+", - ["*", ["apply", "sqrt", 2], ["^", "x", 2]], - ["*", ["/", 5, 8], "x"], - ["^", "e", "y"], - ], - "√2x2+(58)x+ey", - ], - matches: [ - [["apply", "sqrt", 2], "√2"], - [["/", 5, 8], "58"], - [["^", "e", "y"], "ey"], - ], - }, - }, - y: { - "ay^2{rightArrow}+by+c": { - correct: true, - response: [ - ["+", ["*", "a", ["^", "y", 2]], ["*", "b", "y"], "c"], - "ay2+by+c", - ], - matches: [ - ["a", "a"], - ["b", "b"], - ["c", "c"], - ], - }, - "piy^2{rightArrow}x^2{rightArrow}+e^x{rightArrow}y+x+x": { - correct: true, - response: [ - [ - "+", - ["*", "pi", ["^", "y", 2], ["^", "x", 2]], - ["*", ["^", "e", "x"], "y"], - "x", - "x", - ], - "πy2x2+exy+x+x", - ], - matches: [ - [["*", "pi", ["^", "x", 2]], "πx2"], - [["^", "e", "x"], "ex"], - [["+", "x", "x"], "x+x"], - ], - }, - "4y^2{rightArrow}-9y-2": { - correct: true, - response: [ - [ - "+", - ["*", 4, ["^", "y", 2]], - ["-", ["*", 9, "y"]], - -2, - ], - "4y2−9y−2", - ], - matches: [ - [4, "4"], - [["-", 9], "−9"], - [-2, "−2"], - ], - }, - "4y^2{rightArrow}+3x+5": { - correct: true, - response: [ - ["+", ["*", 4, ["^", "y", 2]], ["*", 3, "x"], 5], - "4y2+3x+5", - ], - matches: [ - [4, "4"], - [0, "0"], - [["+", ["*", 3, "x"], 5], "3x+5"], - ], - }, - }, - }; - - cy.get(cesc("#\\/var2") + " .mjx-mrow").should( - "contain.text", - "\uff3f", - ); - - for (let varName in desiredResults) { - cy.log(`setting variable to ${varName}`); - cy.get(cesc("#\\/var") + " textarea").type( - `{end}{backspace}${varName}{enter}`, - { force: true }, - ); - cy.get(cesc("#\\/var2") + " .mjx-mrow").should( - "contain.text", - varName, - ); - - let resultsForVar = desiredResults[varName]; - for (let expr in resultsForVar) { - cy.log(`trying ${expr} for variable ${varName}`); - - cy.get(cesc("#\\/resp") + " textarea").type( - `{ctrl+home}{ctrl+shift+end}{backspace}${expr}{enter}`, - { force: true }, - ); - - let res = resultsForVar[expr]; - - if (res.correct) { - cy.get(cesc("#\\/resp_correct")).should("be.visible"); - cy.get(cesc("#\\/p_sub") + " .mjx-mrow") - .eq(0) - .should("have.text", res.response[1]); - cy.get(cesc("#\\/p_quad") + " .mjx-mrow") - .eq(0) - .should("have.text", res.matches[0][1]); - cy.get(cesc("#\\/p_lin") + " .mjx-mrow") - .eq(0) - .should("have.text", res.matches[1][1]); - cy.get(cesc("#\\/p_const") + " .mjx-mrow") - .eq(0) - .should("have.text", res.matches[2][1]); - cy.window().then(async (win) => { - let stateVariables = - await win.returnAllStateVariables1(); - expect( - stateVariables["/ans"].stateValues - .submittedResponse1, - ).eqls(res.response[0]); - expect( - stateVariables["/ans"].stateValues - .submittedResponse2, - ).eqls(res.matches[0][0]); - expect( - stateVariables["/ans"].stateValues - .submittedResponse3, - ).eqls(res.matches[1][0]); - expect( - stateVariables["/ans"].stateValues - .submittedResponse4, - ).eqls(res.matches[2][0]); - }); - } else { - cy.get(cesc("#\\/resp_incorrect")).should("be.visible"); - cy.get(cesc("#\\/p_sub") + " .mjx-mrow") - .eq(0) - .should("have.text", res.response[1]); - cy.get(cesc("#\\/p_quad") + " .mjx-mrow").should( - "not.exist", - ); - cy.get(cesc("#\\/p_lin") + " .mjx-mrow").should( - "not.exist", - ); - cy.get(cesc("#\\/p_const") + " .mjx-mrow").should( - "not.exist", - ); - cy.window().then(async (win) => { - let stateVariables = - await win.returnAllStateVariables1(); - expect( - stateVariables["/ans"].stateValues - .submittedResponse1, - ).eqls(res.response[0]); - expect( - stateVariables["/ans"].stateValues - .submittedResponse2, - ).eq(undefined); - expect( - stateVariables["/ans"].stateValues - .submittedResponse3, - ).eq(undefined); - expect( - stateVariables["/ans"].stateValues - .submittedResponse4, - ).eq(undefined); - }); - } - } - } - }); -}); diff --git a/packages/test-cypress/cypress/e2e/answerValidation/matchpartial.cy.js b/packages/test-cypress/cypress/e2e/answerValidation/matchpartial.cy.js deleted file mode 100644 index ad21cf06e..000000000 --- a/packages/test-cypress/cypress/e2e/answerValidation/matchpartial.cy.js +++ /dev/null @@ -1,7849 +0,0 @@ -import { cesc, cesc2 } from "@doenet/utils"; - -describe("Match partial validation tests", function () { - beforeEach(() => { - cy.clearIndexedDB(); - cy.visit("/"); - }); - - it("match partial with ordered and unordered tuple", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - (1,2,3) - (1,2,3) - - -

Match partial: - $ordered -

- -

Match partial, match by exact positions: - $ordered -

- -

Match partial, unordered: - $unordered -

- -

Strict equality: - $ordered -

- -

Unordered: - $unordered -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputPartialAnchor = cesc2( - "#" + mathinputName + "_partial", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2PartialAnchor = cesc2( - "#" + mathinput2Name + "_partial", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - let mathinput3Name = - stateVariables["/_answer3"].stateValues.inputChildren[0] - .componentName; - let mathinput3Anchor = cesc2("#" + mathinput3Name) + " textarea"; - let mathinput3SubmitAnchor = cesc2( - "#" + mathinput3Name + "_submit", - ); - let mathinput3CorrectAnchor = cesc2( - "#" + mathinput3Name + "_correct", - ); - let mathinput3PartialAnchor = cesc2( - "#" + mathinput3Name + "_partial", - ); - let mathinput3IncorrectAnchor = cesc2( - "#" + mathinput3Name + "_incorrect", - ); - - let mathinput4Name = - stateVariables["/_answer4"].stateValues.inputChildren[0] - .componentName; - let mathinput4Anchor = cesc2("#" + mathinput4Name) + " textarea"; - let mathinput4SubmitAnchor = cesc2( - "#" + mathinput4Name + "_submit", - ); - let mathinput4CorrectAnchor = cesc2( - "#" + mathinput4Name + "_correct", - ); - let mathinput4PartialAnchor = cesc2( - "#" + mathinput4Name + "_partial", - ); - let mathinput4IncorrectAnchor = cesc2( - "#" + mathinput4Name + "_incorrect", - ); - - let mathinput5Name = - stateVariables["/_answer5"].stateValues.inputChildren[0] - .componentName; - let mathinput5Anchor = cesc2("#" + mathinput5Name) + " textarea"; - let mathinput5SubmitAnchor = cesc2( - "#" + mathinput5Name + "_submit", - ); - let mathinput5CorrectAnchor = cesc2( - "#" + mathinput5Name + "_correct", - ); - let mathinput5PartialAnchor = cesc2( - "#" + mathinput5Name + "_partial", - ); - let mathinput5IncorrectAnchor = cesc2( - "#" + mathinput5Name + "_incorrect", - ); - - cy.get(mathinputSubmitAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).should("be.visible"); - cy.get(mathinput3SubmitAnchor).should("be.visible"); - cy.get(mathinput4SubmitAnchor).should("be.visible"); - cy.get(mathinput5SubmitAnchor).should("be.visible"); - - cy.log("Submit empty answers"); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Submit correct answers"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,3)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3CorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Omit one component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "67 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "33 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3PartialAnchor).should("have.text", "67 %"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("just a scalar"); - cy.get(mathinputAnchor).type("{ctrl+home}{shift+end}{backspace}2", { - force: true, - delay: 0, - }); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3PartialAnchor).should("have.text", "33 %"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("just a scalar matching first component"); - cy.get(mathinputAnchor).type("{ctrl+home}{shift+end}{backspace}1", { - force: true, - delay: 0, - }); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "33 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}1", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3PartialAnchor).should("have.text", "33 %"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}1", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}1", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("extra component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "75 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "50 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3PartialAnchor).should("have.text", "75 %"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 4, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(1 / 2, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).closeTo(3 / 4, 1e-14); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("two extra components"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(0,1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "60 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(0,1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(0,1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3PartialAnchor).should("have.text", "60 %"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(0,1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}(0,1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 5, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).closeTo(3 / 5, 1e-14); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("omit parens"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("permute order"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "67 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,2)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,2)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3CorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,2)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,2)", - { force: true, delay: 0 }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("reverse order"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "33 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3CorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("add component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "50 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "25 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3PartialAnchor).should("have.text", "75 %"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 4, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(1 / 4, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).closeTo(3 / 4, 1e-14); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("add another component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "40 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3PartialAnchor).should("have.text", "60 %"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 5, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).closeTo(3 / 5, 1e-14); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("add one more component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "50 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "17 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3PartialAnchor).should("have.text", "50 %"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 6, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(1 / 6, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).closeTo(3 / 6, 1e-14); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("two components out of order"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3PartialAnchor).should("have.text", "67 %"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("add component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3PartialAnchor).should("have.text", "67 %"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - }); - }); - }); - - it("match partial with ordered and unordered list", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

Match partial: - 1,2,3 -

- -

Match partial, unordered: - 1,2,3 -

- -

Strict equality: - 1,2,3 -

- -

Unordered: - 1,2,3 -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputPartialAnchor = cesc2( - "#" + mathinputName + "_partial", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2PartialAnchor = cesc2( - "#" + mathinput2Name + "_partial", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - let mathinput3Name = - stateVariables["/_answer3"].stateValues.inputChildren[0] - .componentName; - let mathinput3Anchor = cesc2("#" + mathinput3Name) + " textarea"; - let mathinput3SubmitAnchor = cesc2( - "#" + mathinput3Name + "_submit", - ); - let mathinput3CorrectAnchor = cesc2( - "#" + mathinput3Name + "_correct", - ); - let mathinput3PartialAnchor = cesc2( - "#" + mathinput3Name + "_partial", - ); - let mathinput3IncorrectAnchor = cesc2( - "#" + mathinput3Name + "_incorrect", - ); - - let mathinput4Name = - stateVariables["/_answer4"].stateValues.inputChildren[0] - .componentName; - let mathinput4Anchor = cesc2("#" + mathinput4Name) + " textarea"; - let mathinput4SubmitAnchor = cesc2( - "#" + mathinput4Name + "_submit", - ); - let mathinput4CorrectAnchor = cesc2( - "#" + mathinput4Name + "_correct", - ); - let mathinput4PartialAnchor = cesc2( - "#" + mathinput4Name + "_partial", - ); - let mathinput4IncorrectAnchor = cesc2( - "#" + mathinput4Name + "_incorrect", - ); - - cy.get(mathinputSubmitAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).should("be.visible"); - cy.get(mathinput3SubmitAnchor).should("be.visible"); - cy.get(mathinput4SubmitAnchor).should("be.visible"); - - cy.log("Submit empty answers"); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Submit correct answers"); - cy.get(mathinputAnchor).type("1,2,3", { force: true, delay: 0 }); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type("1,2,3", { force: true, delay: 0 }); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type("1,2,3", { force: true, delay: 0 }); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3CorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type("1,2,3", { force: true, delay: 0 }); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Omit one component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "67 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "67 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("just a scalar"); - cy.get(mathinputAnchor).type("{ctrl+home}{shift+end}{backspace}2", { - force: true, - delay: 0, - }); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "33 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("extra component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,a,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "75 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,a,3", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "75 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,a,3", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,a,3", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 4, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 4, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("two extra components"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}0,1,2,a,3", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "60 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}0,1,2,a,3", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "60 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}0,1,2,a,3", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}0,1,2,a,3", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 5, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 5, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("add parens"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,3)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("permute order"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}3,1,2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "67 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,1,2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,1,2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,1,2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("reverse order"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}3,2,1", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,2,1", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,2,1", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,2,1", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("add component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}3,2,1,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "50 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,2,1,3", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "75 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,2,1,3", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,2,1,3", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 4, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 4, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("add another component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}3,a,2,1,3", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "40 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,a,2,1,3", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "60 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,a,2,1,3", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,a,2,1,3", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 5, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 5, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("add one more component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1,3,a,2,1,3", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "50 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,3,a,2,1,3", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "50 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,3,a,2,1,3", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,3,a,2,1,3", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 6, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 6, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("two component out of order"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}3,1", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,1", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "67 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,1", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,1", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("add component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}3,1,1", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,1,1", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "67 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,1,1", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}3,1,1", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - }); - }); - - it("match partial with ordered and unordered array", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

Match partial: - [1,2,3] -

- -

Match partial, unordered: - [1,2,3] -

- -

Strict equality: - [1,2,3] -

- -

Unordered: - [1,2,3] -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputPartialAnchor = cesc2( - "#" + mathinputName + "_partial", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2PartialAnchor = cesc2( - "#" + mathinput2Name + "_partial", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - let mathinput3Name = - stateVariables["/_answer3"].stateValues.inputChildren[0] - .componentName; - let mathinput3Anchor = cesc2("#" + mathinput3Name) + " textarea"; - let mathinput3SubmitAnchor = cesc2( - "#" + mathinput3Name + "_submit", - ); - let mathinput3CorrectAnchor = cesc2( - "#" + mathinput3Name + "_correct", - ); - let mathinput3PartialAnchor = cesc2( - "#" + mathinput3Name + "_partial", - ); - let mathinput3IncorrectAnchor = cesc2( - "#" + mathinput3Name + "_incorrect", - ); - - let mathinput4Name = - stateVariables["/_answer4"].stateValues.inputChildren[0] - .componentName; - let mathinput4Anchor = cesc2("#" + mathinput4Name) + " textarea"; - let mathinput4SubmitAnchor = cesc2( - "#" + mathinput4Name + "_submit", - ); - let mathinput4CorrectAnchor = cesc2( - "#" + mathinput4Name + "_correct", - ); - let mathinput4PartialAnchor = cesc2( - "#" + mathinput4Name + "_partial", - ); - let mathinput4IncorrectAnchor = cesc2( - "#" + mathinput4Name + "_incorrect", - ); - - cy.get(mathinputSubmitAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).should("be.visible"); - cy.get(mathinput3SubmitAnchor).should("be.visible"); - cy.get(mathinput4SubmitAnchor).should("be.visible"); - - cy.log("Submit empty answers"); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Submit correct answers"); - cy.get(mathinputAnchor).type("[1,2,3]", { force: true, delay: 0 }); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type("[1,2,3]", { force: true, delay: 0 }); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type("[1,2,3]", { force: true, delay: 0 }); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3CorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type("[1,2,3]", { force: true, delay: 0 }); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Omit one component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}[1,3]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "67 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,3]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "67 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,3]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,3]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("just a scalar"); - cy.get(mathinputAnchor).type("{ctrl+home}{shift+end}{backspace}2", { - force: true, - delay: 0, - }); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "33 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("extra component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2,a,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "75 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2,a,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "75 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2,a,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2,a,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 4, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 4, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("two extra components"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}[0,1,2,a,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "60 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}[0,1,2,a,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "60 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}[0,1,2,a,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}[0,1,2,a,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 5, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 5, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("omit brackets"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("permute order"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}[3,1,2]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "67 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,1,2]", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,1,2]", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,1,2]", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("reverse order"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}[3,2,1]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,2,1]", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,2,1]", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,2,1]", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("add component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}[3,2,1,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "50 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,2,1,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "75 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,2,1,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,2,1,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 4, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 4, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("add another component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}[3,a,2,1,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "40 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,a,2,1,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "60 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,a,2,1,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,a,2,1,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 5, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 5, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("add one more component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}[1,3,a,2,1,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "50 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,3,a,2,1,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "50 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,3,a,2,1,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,3,a,2,1,3]", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 6, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 6, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("two component out of order"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}[3,1]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,1]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "67 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,1]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,1]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("add component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}[3,1,1]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,1,1]", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "67 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,1,1]", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}[3,1,1]", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - }); - }); - - it("match partial with ordered and unordered tuple, unordered specified on award", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- -

Match partial: - (1,2,3) -

- -

Match partial, unordered: - (1,2,3) -

- -

Strict equality: - (1,2,3) -

- -

Unordered: - (1,2,3) -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputPartialAnchor = cesc2( - "#" + mathinputName + "_partial", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2PartialAnchor = cesc2( - "#" + mathinput2Name + "_partial", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - let mathinput3Name = - stateVariables["/_answer3"].stateValues.inputChildren[0] - .componentName; - let mathinput3Anchor = cesc2("#" + mathinput3Name) + " textarea"; - let mathinput3SubmitAnchor = cesc2( - "#" + mathinput3Name + "_submit", - ); - let mathinput3CorrectAnchor = cesc2( - "#" + mathinput3Name + "_correct", - ); - let mathinput3PartialAnchor = cesc2( - "#" + mathinput3Name + "_partial", - ); - let mathinput3IncorrectAnchor = cesc2( - "#" + mathinput3Name + "_incorrect", - ); - - let mathinput4Name = - stateVariables["/_answer4"].stateValues.inputChildren[0] - .componentName; - let mathinput4Anchor = cesc2("#" + mathinput4Name) + " textarea"; - let mathinput4SubmitAnchor = cesc2( - "#" + mathinput4Name + "_submit", - ); - let mathinput4CorrectAnchor = cesc2( - "#" + mathinput4Name + "_correct", - ); - let mathinput4PartialAnchor = cesc2( - "#" + mathinput4Name + "_partial", - ); - let mathinput4IncorrectAnchor = cesc2( - "#" + mathinput4Name + "_incorrect", - ); - - cy.get(mathinputSubmitAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).should("be.visible"); - cy.get(mathinput3SubmitAnchor).should("be.visible"); - cy.get(mathinput4SubmitAnchor).should("be.visible"); - - cy.log("Submit empty answers"); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Submit correct answers"); - cy.get(mathinputAnchor).type("(1,2,3)", { force: true, delay: 0 }); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type("(1,2,3)", { force: true, delay: 0 }); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type("(1,2,3)", { force: true, delay: 0 }); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3CorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type("(1,2,3)", { force: true, delay: 0 }); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Omit one component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "67 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "67 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("just a scalar"); - cy.get(mathinputAnchor).type("{ctrl+home}{shift+end}{backspace}2", { - force: true, - delay: 0, - }); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "33 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("extra component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "75 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "75 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 4, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 4, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("two extra components"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(0,1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "60 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(0,1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "60 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(0,1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(0,1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 5, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 5, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("omit parens"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("permute order"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "67 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,2)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,2)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,2)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("reverse order"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("add component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "50 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "75 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 4, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 4, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("add another component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "40 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "60 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 5, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 5, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("add one more component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "50 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "50 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 6, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 6, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("two component out of order"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "67 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("add component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "67 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - }); - }); - - it("match partial with ordered and unordered tuple, unordered specified on answer", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- -

Match partial: - (1,2,3) -

- -

Match partial, unordered: - (1,2,3) -

- -

Strict equality: - (1,2,3) -

- -

Unordered: - (1,2,3) -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputPartialAnchor = cesc2( - "#" + mathinputName + "_partial", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2PartialAnchor = cesc2( - "#" + mathinput2Name + "_partial", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - let mathinput3Name = - stateVariables["/_answer3"].stateValues.inputChildren[0] - .componentName; - let mathinput3Anchor = cesc2("#" + mathinput3Name) + " textarea"; - let mathinput3SubmitAnchor = cesc2( - "#" + mathinput3Name + "_submit", - ); - let mathinput3CorrectAnchor = cesc2( - "#" + mathinput3Name + "_correct", - ); - let mathinput3PartialAnchor = cesc2( - "#" + mathinput3Name + "_partial", - ); - let mathinput3IncorrectAnchor = cesc2( - "#" + mathinput3Name + "_incorrect", - ); - - let mathinput4Name = - stateVariables["/_answer4"].stateValues.inputChildren[0] - .componentName; - let mathinput4Anchor = cesc2("#" + mathinput4Name) + " textarea"; - let mathinput4SubmitAnchor = cesc2( - "#" + mathinput4Name + "_submit", - ); - let mathinput4CorrectAnchor = cesc2( - "#" + mathinput4Name + "_correct", - ); - let mathinput4PartialAnchor = cesc2( - "#" + mathinput4Name + "_partial", - ); - let mathinput4IncorrectAnchor = cesc2( - "#" + mathinput4Name + "_incorrect", - ); - - cy.get(mathinputSubmitAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).should("be.visible"); - cy.get(mathinput3SubmitAnchor).should("be.visible"); - cy.get(mathinput4SubmitAnchor).should("be.visible"); - - cy.log("Submit empty answers"); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Submit correct answers"); - cy.get(mathinputAnchor).type("(1,2,3)", { force: true, delay: 0 }); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type("(1,2,3)", { force: true, delay: 0 }); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type("(1,2,3)", { force: true, delay: 0 }); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3CorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type("(1,2,3)", { force: true, delay: 0 }); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Omit one component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "67 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "67 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("just a scalar"); - cy.get(mathinputAnchor).type("{ctrl+home}{shift+end}{backspace}2", { - force: true, - delay: 0, - }); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "33 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}2", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("extra component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "75 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "75 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 4, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 4, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("two extra components"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(0,1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "60 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(0,1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "60 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(0,1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(0,1,2,a,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 5, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 5, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("omit parens"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("permute order"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "67 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,2)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,2)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,2)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("reverse order"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("add component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "50 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "75 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 4, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 4, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("add another component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "40 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "60 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 5, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 5, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("add one more component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "50 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "50 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3,a,2,1,3)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 6, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(3 / 6, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("two component out of order"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "67 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("add component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2PartialAnchor).should("have.text", "67 %"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,1,1)", - { force: true, delay: 0 }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - }); - }); - - it("match set", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

Match partial: - {1,2,3} -

- -

No partial: - {1,2,3} -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputPartialAnchor = cesc2( - "#" + mathinputName + "_partial", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2PartialAnchor = cesc2( - "#" + mathinput2Name + "_partial", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - cy.get(mathinputSubmitAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).should("be.visible"); - - cy.log("Submit empty answers"); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Submit correct answers"); - cy.get(mathinputAnchor).type("{{}1,2,3}", { - force: true, - delay: 0, - }); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type("{{}1,2,3}", { - force: true, - delay: 0, - }); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Permute components"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}{{}3,2,1}", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}{{}3,2,1}", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Extra component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}{{}3,a,2,1}", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "75 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}{{}3,a,2,1}", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 4, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Another component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}{{}3,a,2,b,1}", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "60 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}{{}3,a,2,b,1}", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 5, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Duplicate components"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}{{}3,2,3,1,1}", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}{{}3,2,3,1,1}", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Add component"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}{{}3,2,3,a,1,1}", - { force: true, delay: 0 }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "75 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}{{}3,2,3,a,1,1}", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(3 / 4, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Omit braces"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1,2,3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Single number"); - cy.get(mathinputAnchor).type("{ctrl+home}{shift+end}{backspace}3", { - force: true, - delay: 0, - }); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "33 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}3", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(1 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Subset"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}{{}2,1}", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "67 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}{{}2,1}", - { force: true, delay: 0 }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).closeTo(2 / 3, 1e-14); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - }); - }); - }); - - it("match intervals", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

Open, match partial: - (1,2) -

- -

Open, no partial: - (1,2) -

- -

Closed, match partial: - [1,2] -

- -

Closed, no partial: - [1,2] -

- -

Left open, match partial: - (1,2] -

- -

Left open, no partial: - (1,2] -

- -

Right open, match partial: - [1,2) -

- -

Right open, no partial: - [1,2) -

- - `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputPartialAnchor = cesc2( - "#" + mathinputName + "_partial", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2PartialAnchor = cesc2( - "#" + mathinput2Name + "_partial", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - let mathinput3Name = - stateVariables["/_answer3"].stateValues.inputChildren[0] - .componentName; - let mathinput3Anchor = cesc2("#" + mathinput3Name) + " textarea"; - let mathinput3SubmitAnchor = cesc2( - "#" + mathinput3Name + "_submit", - ); - let mathinput3CorrectAnchor = cesc2( - "#" + mathinput3Name + "_correct", - ); - let mathinput3PartialAnchor = cesc2( - "#" + mathinput3Name + "_partial", - ); - let mathinput3IncorrectAnchor = cesc2( - "#" + mathinput3Name + "_incorrect", - ); - - let mathinput4Name = - stateVariables["/_answer4"].stateValues.inputChildren[0] - .componentName; - let mathinput4Anchor = cesc2("#" + mathinput4Name) + " textarea"; - let mathinput4SubmitAnchor = cesc2( - "#" + mathinput4Name + "_submit", - ); - let mathinput4CorrectAnchor = cesc2( - "#" + mathinput4Name + "_correct", - ); - let mathinput4PartialAnchor = cesc2( - "#" + mathinput4Name + "_partial", - ); - let mathinput4IncorrectAnchor = cesc2( - "#" + mathinput4Name + "_incorrect", - ); - - let mathinput5Name = - stateVariables["/_answer5"].stateValues.inputChildren[0] - .componentName; - let mathinput5Anchor = cesc2("#" + mathinput5Name) + " textarea"; - let mathinput5SubmitAnchor = cesc2( - "#" + mathinput5Name + "_submit", - ); - let mathinput5CorrectAnchor = cesc2( - "#" + mathinput5Name + "_correct", - ); - let mathinput5PartialAnchor = cesc2( - "#" + mathinput5Name + "_partial", - ); - let mathinput5IncorrectAnchor = cesc2( - "#" + mathinput5Name + "_incorrect", - ); - - let mathinput6Name = - stateVariables["/_answer6"].stateValues.inputChildren[0] - .componentName; - let mathinput6Anchor = cesc2("#" + mathinput6Name) + " textarea"; - let mathinput6SubmitAnchor = cesc2( - "#" + mathinput6Name + "_submit", - ); - let mathinput6CorrectAnchor = cesc2( - "#" + mathinput6Name + "_correct", - ); - let mathinput6PartialAnchor = cesc2( - "#" + mathinput6Name + "_partial", - ); - let mathinput6IncorrectAnchor = cesc2( - "#" + mathinput6Name + "_incorrect", - ); - - let mathinput7Name = - stateVariables["/_answer7"].stateValues.inputChildren[0] - .componentName; - let mathinput7Anchor = cesc2("#" + mathinput7Name) + " textarea"; - let mathinput7SubmitAnchor = cesc2( - "#" + mathinput7Name + "_submit", - ); - let mathinput7CorrectAnchor = cesc2( - "#" + mathinput7Name + "_correct", - ); - let mathinput7PartialAnchor = cesc2( - "#" + mathinput7Name + "_partial", - ); - let mathinput7IncorrectAnchor = cesc2( - "#" + mathinput7Name + "_incorrect", - ); - - let mathinput8Name = - stateVariables["/_answer8"].stateValues.inputChildren[0] - .componentName; - let mathinput8Anchor = cesc2("#" + mathinput8Name) + " textarea"; - let mathinput8SubmitAnchor = cesc2( - "#" + mathinput8Name + "_submit", - ); - let mathinput8CorrectAnchor = cesc2( - "#" + mathinput8Name + "_correct", - ); - let mathinput8PartialAnchor = cesc2( - "#" + mathinput8Name + "_partial", - ); - let mathinput8IncorrectAnchor = cesc2( - "#" + mathinput8Name + "_incorrect", - ); - - cy.get(mathinputSubmitAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).should("be.visible"); - cy.get(mathinput3SubmitAnchor).should("be.visible"); - cy.get(mathinput4SubmitAnchor).should("be.visible"); - cy.get(mathinput5SubmitAnchor).should("be.visible"); - cy.get(mathinput6SubmitAnchor).should("be.visible"); - cy.get(mathinput7SubmitAnchor).should("be.visible"); - cy.get(mathinput8SubmitAnchor).should("be.visible"); - - cy.log("Submit empty answers"); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - cy.get(mathinput6SubmitAnchor).click(); - cy.get(mathinput6IncorrectAnchor).should("be.visible"); - cy.get(mathinput7SubmitAnchor).click(); - cy.get(mathinput7IncorrectAnchor).should("be.visible"); - cy.get(mathinput8SubmitAnchor).click(); - cy.get(mathinput8IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer6"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer7"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer8"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("single number"); - cy.get(mathinputAnchor).type("1", { force: true, delay: 0 }); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type("1", { force: true, delay: 0 }); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type("1", { force: true, delay: 0 }); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type("1", { force: true, delay: 0 }); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type("1", { force: true, delay: 0 }); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - cy.get(mathinput6Anchor).type("1", { force: true, delay: 0 }); - cy.get(mathinput6SubmitAnchor).click(); - cy.get(mathinput6IncorrectAnchor).should("be.visible"); - cy.get(mathinput7Anchor).type("1", { force: true, delay: 0 }); - cy.get(mathinput7SubmitAnchor).click(); - cy.get(mathinput7IncorrectAnchor).should("be.visible"); - cy.get(mathinput8Anchor).type("1", { force: true, delay: 0 }); - cy.get(mathinput8SubmitAnchor).click(); - cy.get(mathinput8IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer6"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer7"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer8"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Open interval"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - cy.get(mathinput6Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput6SubmitAnchor).click(); - cy.get(mathinput6IncorrectAnchor).should("be.visible"); - cy.get(mathinput7Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput7SubmitAnchor).click(); - cy.get(mathinput7IncorrectAnchor).should("be.visible"); - cy.get(mathinput8Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput8SubmitAnchor).click(); - cy.get(mathinput8IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer6"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer7"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer8"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("partially correct open interval"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputPartialAnchor).should("have.text", "50 %"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0.5); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("permute order"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(2,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(2,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Closed interval"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3CorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - cy.get(mathinput6Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput6SubmitAnchor).click(); - cy.get(mathinput6IncorrectAnchor).should("be.visible"); - cy.get(mathinput7Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput7SubmitAnchor).click(); - cy.get(mathinput7IncorrectAnchor).should("be.visible"); - cy.get(mathinput8Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput8SubmitAnchor).click(); - cy.get(mathinput8IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer6"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer7"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer8"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Partially correct closed interval"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,3]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3PartialAnchor).should("have.text", "50 %"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,3]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0.5); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Permute order"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}[2,1]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}[2,1]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Left open interval"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5CorrectAnchor).should("be.visible"); - cy.get(mathinput6Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput6SubmitAnchor).click(); - cy.get(mathinput6CorrectAnchor).should("be.visible"); - cy.get(mathinput7Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput7SubmitAnchor).click(); - cy.get(mathinput7IncorrectAnchor).should("be.visible"); - cy.get(mathinput8Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,2]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput8SubmitAnchor).click(); - cy.get(mathinput8IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer6"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer7"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer8"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Partially correct left open interval"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5PartialAnchor).should("have.text", "50 %"); - cy.get(mathinput6Anchor).type( - "{ctrl+home}{shift+end}{backspace}(1,3]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput6SubmitAnchor).click(); - cy.get(mathinput6IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0.5); - expect( - stateVariables["/_answer6"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Permute order"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}(2,1]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - cy.get(mathinput6Anchor).type( - "{ctrl+home}{shift+end}{backspace}(2,1]", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput6SubmitAnchor).click(); - cy.get(mathinput6IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer6"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Right open interval"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - cy.get(mathinput5Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput5SubmitAnchor).click(); - cy.get(mathinput5IncorrectAnchor).should("be.visible"); - cy.get(mathinput6Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput6SubmitAnchor).click(); - cy.get(mathinput6IncorrectAnchor).should("be.visible"); - cy.get(mathinput7Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput7SubmitAnchor).click(); - cy.get(mathinput7CorrectAnchor).should("be.visible"); - cy.get(mathinput8Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,2)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput8SubmitAnchor).click(); - cy.get(mathinput8CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer5"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer6"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer7"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer8"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Partially correct right open interval"); - cy.get(mathinput7Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,3)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput7SubmitAnchor).click(); - cy.get(mathinput7PartialAnchor).should("have.text", "50 %"); - cy.get(mathinput8Anchor).type( - "{ctrl+home}{shift+end}{backspace}[1,3)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput8SubmitAnchor).click(); - cy.get(mathinput8IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer7"].stateValues.creditAchieved, - ).eq(0.5); - expect( - stateVariables["/_answer8"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("Permute order"); - cy.get(mathinput7Anchor).type( - "{ctrl+home}{shift+end}{backspace}[2,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput7SubmitAnchor).click(); - cy.get(mathinput7IncorrectAnchor).should("be.visible"); - cy.get(mathinput8Anchor).type( - "{ctrl+home}{shift+end}{backspace}[2,1)", - { - force: true, - delay: 0, - }, - ); - cy.get(mathinput8SubmitAnchor).click(); - cy.get(mathinput8IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer7"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer8"].stateValues.creditAchieved, - ).eq(0); - }); - }); - }); - - it("match partial with ordered and unordered math inputs", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

-

-

- -
Match partial - - - - - - $x, $y, $z - - = - x,y,z - - - -
- -
Match partial, match by exact positions - - - - - - $x, $y, $z - - = - x,y,z - - - -
- - -
Match partial, unordered - - - - - $x, $y, $z - - = - x,y,z - - - -
- -
Strict equality - - - - - $x, $y, $z - - = - x,y,z - - - -
- -
Unordered - - - - - $x, $y, $z - - = - x,y,z - - - -
- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/a_submit")).should("be.visible"); - cy.get(cesc("#\\/b_submit")).should("be.visible"); - cy.get(cesc("#\\/c_submit")).should("be.visible"); - cy.get(cesc("#\\/d_submit")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).should("be.visible"); - - cy.log("Submit empty answers"); - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_incorrect")).should("be.visible"); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_incorrect")).should("be.visible"); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_incorrect")).should("be.visible"); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/b"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/c"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(0); - }); - - cy.log("Submit correct answers"); - cy.get(cesc("#\\/x") + " textarea").type("x", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/y") + " textarea").type("y", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/z") + " textarea").type("z", { - force: true, - delay: 0, - }); - - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_correct")).should("be.visible"); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_correct")).should("be.visible"); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_correct")).should("be.visible"); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_correct")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_correct")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).eq(1); - expect(stateVariables["/b"].stateValues.creditAchieved).eq(1); - expect(stateVariables["/c"].stateValues.creditAchieved).eq(1); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(1); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(1); - }); - - cy.log("Omit one component"); - - cy.get(cesc("#\\/y") + " textarea").type("{end}{backspace}z", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/z") + " textarea").type("{end}{backspace}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("33% correct"); - }); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).closeTo( - 1 / 3, - 1e-14, - ); - expect(stateVariables["/c"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(0); - }); - - cy.log("permute order"); - cy.get(cesc("#\\/x") + " textarea").type("{end}{backspace}z", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/y") + " textarea").type("{end}{backspace}x", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/z") + " textarea").type("{end}{backspace}y", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_incorrect")).should("be.visible"); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_correct")).should("be.visible"); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_correct")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/c"].stateValues.creditAchieved).eq(1); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(1); - }); - - cy.log("reverse order"); - cy.get(cesc("#\\/y") + " textarea").type("{end}{backspace}y", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/z") + " textarea").type("{end}{backspace}x", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("33% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("33% correct"); - }); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_correct")).should("be.visible"); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_correct")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 1 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).closeTo( - 1 / 3, - 1e-14, - ); - expect(stateVariables["/c"].stateValues.creditAchieved).eq(1); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(1); - }); - - cy.log("two components out of order"); - cy.get(cesc("#\\/y") + " textarea").type("{end}{backspace}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("33% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_incorrect")).should("be.visible"); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 1 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/c"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(0); - }); - - cy.log("add component"); - cy.get(cesc("#\\/y") + " textarea").type("{end}{backspace}x", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("33% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_incorrect")).should("be.visible"); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 1 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/c"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(0); - }); - - cy.log("extra component, but in right order"); - cy.get(cesc("#\\/x") + " textarea").type("{end}{backspace}x", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/z") + " textarea").type("{end}{backspace}z", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/c"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(0); - }); - - cy.log( - "extra component, in right order, but only one in right position", - ); - cy.get(cesc("#\\/z") + " textarea").type("{end}{backspace}y", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("33% correct"); - }); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).closeTo( - 1 / 3, - 1e-14, - ); - expect(stateVariables["/c"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(0); - }); - }); - - it("match partial with ordered and unordered text inputs", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

-

-

- -
Match partial - - - - - - $x $y $z - - = - x y z - - - -
- -
Match partial, match by exact positions - - - - - - $x $y $z - - = - x y z - - - -
- - -
Match partial, unordered - - - - - $x $y $z - - = - x y z - - - -
- -
Strict equality - - - - - $x $y $z - - = - x y z - - - -
- -
Unordered - - - - - $x $y $z - - = - x y z - - - -
- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/a_submit")).should("be.visible"); - cy.get(cesc("#\\/b_submit")).should("be.visible"); - cy.get(cesc("#\\/c_submit")).should("be.visible"); - cy.get(cesc("#\\/d_submit")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).should("be.visible"); - - cy.log("Submit empty answers"); - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_incorrect")).should("be.visible"); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_incorrect")).should("be.visible"); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_incorrect")).should("be.visible"); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/b"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/c"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(0); - }); - - cy.log("Submit correct answers"); - cy.get(cesc("#\\/x_input")).clear().type("x"); - cy.get(cesc("#\\/y_input")).clear().type("y"); - cy.get(cesc("#\\/z_input")).clear().type("z"); - - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_correct")).should("be.visible"); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_correct")).should("be.visible"); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_correct")).should("be.visible"); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_correct")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_correct")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).eq(1); - expect(stateVariables["/b"].stateValues.creditAchieved).eq(1); - expect(stateVariables["/c"].stateValues.creditAchieved).eq(1); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(1); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(1); - }); - - cy.log("Omit one component"); - - cy.get(cesc("#\\/y_input")).clear().type("z"); - cy.get(cesc("#\\/z_input")).clear(); - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("33% correct"); - }); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).closeTo( - 1 / 3, - 1e-14, - ); - expect(stateVariables["/c"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(0); - }); - - cy.log("permute order"); - cy.get(cesc("#\\/x_input")).clear().type("z"); - cy.get(cesc("#\\/y_input")).clear().type("x"); - cy.get(cesc("#\\/z_input")).clear().type("y"); - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_incorrect")).should("be.visible"); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_correct")).should("be.visible"); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_correct")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/c"].stateValues.creditAchieved).eq(1); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(1); - }); - - cy.log("reverse order"); - cy.get(cesc("#\\/y_input")).clear().type("y"); - cy.get(cesc("#\\/z_input")).clear().type("x"); - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("33% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("33% correct"); - }); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_correct")).should("be.visible"); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_correct")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 1 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).closeTo( - 1 / 3, - 1e-14, - ); - expect(stateVariables["/c"].stateValues.creditAchieved).eq(1); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(1); - }); - - cy.log("two components out of order"); - cy.get(cesc("#\\/y_input")).clear(); - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("33% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_incorrect")).should("be.visible"); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 1 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/c"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(0); - }); - - cy.log("add component"); - cy.get(cesc("#\\/y_input")).clear().type("x"); - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("33% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_incorrect")).should("be.visible"); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 1 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/c"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(0); - }); - - cy.log("extra component, but in right order"); - cy.get(cesc("#\\/x_input")).clear().type("x"); - cy.get(cesc("#\\/z_input")).clear().type("z"); - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/c"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(0); - }); - - cy.log( - "extra component, in right order, but only one in right position", - ); - cy.get(cesc("#\\/z_input")).clear().type("y"); - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("33% correct"); - }); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).closeTo( - 1 / 3, - 1e-14, - ); - expect(stateVariables["/c"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(0); - }); - }); - - it("match partial with ordered and unordered boolean inputs", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

-

-

- -
Match partial - - - - - - $x $y $z - - = - false true true - - - -
- -
Match partial, match by exact positions - - - - - - $x $y $z - - = - false true true - - - -
- - -
Match partial, unordered - - - - - $x $y $z - - = - false true true - - - -
- -
Strict equality - - - - - $x $y $z - - = - false true true - - - -
- -
Unordered - - - - - $x $y $z - - = - false true true - - - -
- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/a_submit")).should("be.visible"); - cy.get(cesc("#\\/b_submit")).should("be.visible"); - cy.get(cesc("#\\/c_submit")).should("be.visible"); - cy.get(cesc("#\\/d_submit")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).should("be.visible"); - - cy.log("Submit correct answers"); - cy.get(cesc("#\\/y")).click(); - cy.get(cesc("#\\/z")).click(); - - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_correct")).should("be.visible"); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_correct")).should("be.visible"); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_correct")).should("be.visible"); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_correct")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_correct")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).eq(1); - expect(stateVariables["/b"].stateValues.creditAchieved).eq(1); - expect(stateVariables["/c"].stateValues.creditAchieved).eq(1); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(1); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(1); - }); - - cy.log("All true"); - cy.get(cesc("#\\/x")).click(); - - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/c"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(0); - }); - - cy.log("wrong order"); - cy.get(cesc("#\\/y")).click(); - - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("33% correct"); - }); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_correct")).should("be.visible"); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_correct")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).closeTo( - 1 / 3, - 1e-14, - ); - expect(stateVariables["/c"].stateValues.creditAchieved).eq(1); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(1); - }); - - cy.log("wrong order and values"); - cy.get(cesc("#\\/z")).click(); - - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("33% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_incorrect")).should("be.visible"); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 1 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/c"].stateValues.creditAchieved).closeTo( - 2 / 3, - 1e-14, - ); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(0); - }); - - cy.log("all false"); - cy.get(cesc("#\\/x")).click(); - - cy.get(cesc("#\\/a_submit")).click(); - cy.get(cesc("#\\/a_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("33% correct"); - }); - cy.get(cesc("#\\/b_submit")).click(); - cy.get(cesc("#\\/b_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("33% correct"); - }); - cy.get(cesc("#\\/c_submit")).click(); - cy.get(cesc("#\\/c_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("33% correct"); - }); - cy.get(cesc("#\\/d_submit")).click(); - cy.get(cesc("#\\/d_incorrect")).should("be.visible"); - cy.get(cesc("#\\/e_submit")).click(); - cy.get(cesc("#\\/e_incorrect")).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/a"].stateValues.creditAchieved).closeTo( - 1 / 3, - 1e-14, - ); - expect(stateVariables["/b"].stateValues.creditAchieved).closeTo( - 1 / 3, - 1e-14, - ); - expect(stateVariables["/c"].stateValues.creditAchieved).closeTo( - 1 / 3, - 1e-14, - ); - expect(stateVariables["/d"].stateValues.creditAchieved).eq(0); - expect(stateVariables["/e"].stateValues.creditAchieved).eq(0); - }); - }); - - it("match partial with combined ordered/unordered tuples", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - - - -

Match partial: - - - $m1 = (1,2) - and - $m2 = (3,4) - - -

- -

Strict equality: - - - $m1 = (1,2) - and - $m2 = (3,4) - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.log("Submit correct answers"); - cy.get(cesc("#\\/m1") + " textarea").type("(1,2){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/m2") + " textarea").type("(3,4){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_correct")).should("be.visible"); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_correct")).should("be.visible"); - - cy.log("scalar in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}2{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("scalar in second tuple"); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}3{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("permute order in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2,1){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(3,4){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("permute order also in second tuple"); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(4,3){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("correct order in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(1,2){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_correct")).should("be.visible"); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_correct")).should("be.visible"); - }); - - it("match partial with combined ordered/unordered tuples via whens", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - - - -

Match partial: - - - $m1 = (1,2) - and - $m2 = (3,4) - - -

- -

Strict equality: - - - $m1 = (1,2) - and - $m2 = (3,4) - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.log("Submit correct answers"); - cy.get(cesc("#\\/m1") + " textarea").type("(1,2){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/m2") + " textarea").type("(3,4){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_correct")).should("be.visible"); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_correct")).should("be.visible"); - - cy.log("scalar in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}2{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("scalar in second tuple"); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}3{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("permute order in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2,1){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(3,4){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("permute order also in second tuple"); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(4,3){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(4,3){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("correct order in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(1,2){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_correct")).should("be.visible"); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_correct")).should("be.visible"); - }); - - it("match partial with combined ordered/unordered tuples via booleans", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - - -

Match partial: - - - $m1 = (1,2) - and - $m2 = (3,4) - - -

- -

Strict equality: - - - $m1 = (1,2) - and - $m2 = (3,4) - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.log("Submit correct answers"); - cy.get(cesc("#\\/m1") + " textarea").type("(1,2){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/m2") + " textarea").type("(3,4){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_correct")).should("be.visible"); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_correct")).should("be.visible"); - - cy.log("scalar in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}2{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("scalar in second tuple"); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}3{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("25% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("permute order in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2,1){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(3,4){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("permute order also in second tuple"); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(4,3){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(4,3){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("correct order in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(1,2){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_correct")).should("be.visible"); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_correct")).should("be.visible"); - }); - - it("mixed match partial and ordered/unordered tuples via whens", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - - - -

Match partial: - - - - $m1 = (1,2) - and - $m2 = (3,4) - - -

- -

No net effect of inner matchPartial: - - - $m1 = (1,2) - and - $m2 = (3,4) - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.log("Submit correct answers"); - cy.get(cesc("#\\/m1") + " textarea").type("(1,2){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/m2") + " textarea").type("(3,4){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_correct")).should("be.visible"); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_correct")).should("be.visible"); - - cy.log("scalar in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}2{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("scalar in second tuple"); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}3{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("25% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("permute order in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2,1){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(3,4){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("permute order also in second tuple"); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(4,3){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(4,3){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("correct order in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(1,2){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_correct")).should("be.visible"); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_correct")).should("be.visible"); - }); - - it("match partial with combined ordered/unordered tuples, force ordered compare", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - - - -

Match partial: - - - $m1 = (1,2) - and - $m2 = (3,4) - - -

- -

Strict equality: - - - $m1 = (1,2) - and - $m2 = (3,4) - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.log("Submit correct answers"); - cy.get(cesc("#\\/m1") + " textarea").type("(1,2){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/m2") + " textarea").type("(3,4){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_correct")).should("be.visible"); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_correct")).should("be.visible"); - - cy.log("scalar in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}2{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("scalar in second tuple"); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}3{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("permute order in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2,1){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(3,4){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("permute order also in second tuple"); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(4,3){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("correct order in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(1,2){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - }); - - it("match partial with combined ordered/unordered tuples via whens, no effect of force ordered compare", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- - - - -

Match partial: - - - $m1 = (1,2) - and - $m2 = (3,4) - - -

- -

Strict equality: - - - $m1 = (1,2) - and - $m2 = (3,4) - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.log("Submit correct answers"); - cy.get(cesc("#\\/m1") + " textarea").type("(1,2){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/m2") + " textarea").type("(3,4){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_correct")).should("be.visible"); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_correct")).should("be.visible"); - - cy.log("scalar in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}2{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("scalar in second tuple"); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}3{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("permute order in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(2,1){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(3,4){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("permute order also in second tuple"); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(4,3){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/m2") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(4,3){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("correct order in first tuple"); - cy.get(cesc("#\\/m1") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(1,2){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_correct")).should("be.visible"); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_correct")).should("be.visible"); - }); - - it("match partial with combined ordered/unordered text inputs", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - -

a

- -

-

-

-

- -

Match partial: - - - - $u $v - = - u v - and - $x $y - = - x y - - - -

- -

Strict: - - - - $u $v - = - u v - and - $x $y - = - x y - - - -

- - `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.log("Submit correct answers"); - cy.get(cesc("#\\/u_input")).clear().type("u"); - cy.get(cesc("#\\/v_input")).clear().type("v"); - cy.get(cesc("#\\/x_input")).clear().type("x"); - cy.get(cesc("#\\/y_input")).clear().type("y"); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_correct")).should("be.visible"); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_correct")).should("be.visible"); - - cy.log("Omit one component in first"); - cy.get(cesc("#\\/u_input")).clear().type("v"); - cy.get(cesc("#\\/v_input")).clear(); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("Omit one component in second"); - cy.get(cesc("#\\/x_input")).clear().type("y"); - cy.get(cesc("#\\/y_input")).clear(); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("permute order in first"); - cy.get(cesc("#\\/v_input")).type("u"); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("permute order in second"); - cy.get(cesc("#\\/y_input")).type("x"); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("correct order in first"); - cy.get(cesc("#\\/u_input")).clear().type("u"); - cy.get(cesc("#\\/v_input")).clear().type("v"); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_correct")).should("be.visible"); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_correct")).should("be.visible"); - }); - - it("match partial with combined ordered/unordered boolean inputs", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - -

a

- -

-

-

-

- -

Match partial: - - - - $u $v - = - true false - and - $x $y - = - true false - - - -

- -

Strict: - - - - $u $v - = - true false - and - $x $y - = - true false - - - -

- - `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.log("Submit correct answers"); - cy.get(cesc("#\\/u")).click(); - cy.get(cesc("#\\/x")).click(); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_correct")).should("be.visible"); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_correct")).should("be.visible"); - - cy.log("One incorrect in first"); - cy.get(cesc("#\\/v")).click(); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("One incorrect in second"); - cy.get(cesc("#\\/y")).click(); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("permute order in first"); - cy.get(cesc("#\\/u")).click(); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("permute order in second"); - cy.get(cesc("#\\/x")).click(); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("75% correct"); - }); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_incorrect")).should("be.visible"); - - cy.log("correct order in first"); - cy.get(cesc("#\\/u")).click(); - cy.get(cesc("#\\/v")).click(); - cy.get(cesc("#\\/partial_submit")).click(); - cy.get(cesc("#\\/partial_correct")).should("be.visible"); - cy.get(cesc("#\\/strict_submit")).click(); - cy.get(cesc("#\\/strict_correct")).should("be.visible"); - }); - - it("match tuple with list of tuples", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - -

a

-

- - - - - $mi = (1,2)(3,4) - - - - - - - (1,2)(3,4) = $mi - - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.log("Submit first tuple"); - cy.get(cesc("#\\/mi") + " textarea").type("(1,2){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ans2_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - - cy.log("Submit both tuples"); - cy.get(cesc("#\\/mi") + " textarea").type("{end},(3,4){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_correct")).should("be.visible"); - cy.get(cesc("#\\/ans2_correct")).should("be.visible"); - - cy.log("Submit second tuple"); - cy.get(cesc("#\\/mi") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(3,4){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - }); - - it("match tuple with list of vectors", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - -

a

-

- - - - - $mi = (1,2)(3,4) - - - - - - - (1,2)(3,4) = $mi - - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.log("Submit first tuple"); - cy.get(cesc("#\\/mi") + " textarea").type("(1,2){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ans2_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - - cy.log("Submit both tuples"); - cy.get(cesc("#\\/mi") + " textarea").type("{end},(3,4){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_correct")).should("be.visible"); - cy.get(cesc("#\\/ans2_correct")).should("be.visible"); - - cy.log("Submit second tuple"); - cy.get(cesc("#\\/mi") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(3,4){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - }); - - it("match vector with list of tuples", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - -

a

-

- - - - - $mi = (1,2)(3,4) - - - - - - - (1,2)(3,4) = $mi - - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.log("Submit first tuple"); - cy.get(cesc("#\\/mi") + " textarea").type("(1,2){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ans2_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - - cy.log("Submit both tuples"); - cy.get(cesc("#\\/mi") + " textarea").type("{end},(3,4){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_correct")).should("be.visible"); - cy.get(cesc("#\\/ans2_correct")).should("be.visible"); - - cy.log("Submit second tuple"); - cy.get(cesc("#\\/mi") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(3,4){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - - cy.log("Submit first as altvector"); - cy.get(cesc("#\\/mi") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}\\langle 1,2\\rangle{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ans2_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - - cy.log("Submit both as alt vectors"); - cy.get(cesc("#\\/mi") + " textarea").type( - "{end},\\langle 3,4\\rangle{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_correct")).should("be.visible"); - cy.get(cesc("#\\/ans2_correct")).should("be.visible"); - }); - - it("match vector with list of vectors", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - -

a

-

- - - - - $mi = (1,2)(3,4) - - - - - - - (1,2)(3,4) = $mi - - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.log("Submit first tuple"); - cy.get(cesc("#\\/mi") + " textarea").type("(1,2){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ans2_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - - cy.log("Submit both tuples"); - cy.get(cesc("#\\/mi") + " textarea").type("{end},(3,4){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_correct")).should("be.visible"); - cy.get(cesc("#\\/ans2_correct")).should("be.visible"); - - cy.log("Submit second tuple"); - cy.get(cesc("#\\/mi") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(3,4){enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - - cy.log("Submit first as altvector"); - cy.get(cesc("#\\/mi") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}\\langle 1,2\\rangle{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ans2_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - - cy.log("Submit both as altvectors"); - cy.get(cesc("#\\/mi") + " textarea").type( - "{end},\\langle 3,4\\rangle{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_correct")).should("be.visible"); - cy.get(cesc("#\\/ans2_correct")).should("be.visible"); - }); - - it("match interval with list of intervals", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - -

a

-

- - - - - $mi = [1,2)(3,4] - - - - - - - [1,2)(3,4] = $mi - - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.log("Submit first interval"); - cy.get(cesc("#\\/mi") + " textarea").type("[1,2){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ans2_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - - cy.log("Submit both intervals"); - cy.get(cesc("#\\/mi") + " textarea").type("{end},(3,4]{enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_correct")).should("be.visible"); - cy.get(cesc("#\\/ans2_correct")).should("be.visible"); - - cy.log("Submit second interval"); - cy.get(cesc("#\\/mi") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}(3,4]{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - }); - - it("match array with list of arrays", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - -

a

-

- - - - - $mi = [1,2][3,4] - - - - - - - [1,2][3,4] = $mi - - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.log("Submit first array"); - cy.get(cesc("#\\/mi") + " textarea").type("[1,2]{enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ans2_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - - cy.log("Submit both arrays"); - cy.get(cesc("#\\/mi") + " textarea").type("{end},[3,4]{enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_correct")).should("be.visible"); - cy.get(cesc("#\\/ans2_correct")).should("be.visible"); - - cy.log("Submit second array"); - cy.get(cesc("#\\/mi") + " textarea").type( - "{ctrl+home}{shift+end}{backspace}[3,4]{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ans1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - }); - - it("match partial does not recurse on single element lists", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - -

a

-

- - - - - $mi = (1,2) - - - - - - - $mi = (1,2) - - - -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_p1")).should("have.text", "a"); // to wait until loaded - - cy.log("Submit correct answer"); - cy.get(cesc("#\\/mi") + " textarea").type("(1,2){enter}", { - force: true, - delay: 0, - }); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_correct")).should("be.visible"); - cy.get(cesc("#\\/ans2_correct")).should("be.visible"); - - cy.log("Submit tuple with incorrect entry"); - cy.get(cesc("#\\/mi") + " textarea").type( - "{end}{leftArrow}{backSpace}3{enter}", - { force: true, delay: 0 }, - ); - cy.get(cesc("#\\/ans1_submit")).click(); - cy.get(cesc("#\\/ans2_submit")).click(); - - cy.get(cesc("#\\/ans1_incorrect")).should("be.visible"); - cy.get(cesc("#\\/ans2_incorrect")).should("be.visible"); - }); -}); diff --git a/packages/test-cypress/cypress/e2e/answerValidation/pointlocation.cy.js b/packages/test-cypress/cypress/e2e/answerValidation/pointlocation.cy.js index c30983c6b..7be8d6771 100644 --- a/packages/test-cypress/cypress/e2e/answerValidation/pointlocation.cy.js +++ b/packages/test-cypress/cypress/e2e/answerValidation/pointlocation.cy.js @@ -6,253 +6,6 @@ describe("Point location validation tests", function () { cy.visit("/"); }); - it("point in first quadrant", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - a -

Move point to first quadrant

- (-3.9,4.5) -

- - $_point1.x > 0 and - $_point1.y > 0 - - $_point1 -

-

Credit for answer: $_answer1.creditAchieved

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move point to correct quadrant"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/_point1", - args: { x: 5.9, y: 3.5 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - - cy.log("Move point to second quadrant and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/_point1", - args: { x: -8.8, y: 1.3 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move point to third quadrant and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/_point1", - args: { x: -9.4, y: -5.1 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move point to fourth quadrant and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/_point1", - args: { x: 4.2, y: -2.9 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move point back to first quadrant and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/_point1", - args: { x: 4.6, y: 0.1 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - }); - it("point in first quadrant, remember submitted on reload", () => { let doenetML = ` a @@ -541,3807 +294,4 @@ describe("Point location validation tests", function () { ); }); }); - - it("point at precise location with attract", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - a - (-4.1, 7.4) -

Move point to $goal.coords

- - - - $goal - - - -

- $A.x{isResponse} = $goal.x and - $A.y{isResponse} = $goal.y -

-

Credit for answer: $_answer1.creditAchieved

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move near correct point"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -4, y: 7.6 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - - cy.log("Move point further away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -3.7, y: 7 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move point close again and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -3.8, y: 7.1 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - }); - - it("point close enough to precise location", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - a - (-4.1, 7.4) - -

Criterion distance:

-

Partial credit distance:

- - $criterion.value^2 - $partialcriterion.value^2 - ($A.x - $goal.x)^2 + - ($A.y - $goal.y)^2 - -

Move point to within distance of $criterion.value to $goal.coords

- - (4.9, -1.1) - -

- - $distance2 < $criterion2 - - - $distance2 < $partialcriterion2 - - $A -

-

Credit for answer: $_answer1.creditAchieved

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move near correct point"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -5, y: 7 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - - cy.log("change criterion"); - cy.get(cesc("#\\/criterion") + " textarea") - .type("{ctrl+home}{shift+end}{backspace}1", { force: true }) - .blur(); - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - - cy.log("Resubmit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - - cy.log("Move point further away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -2.8, y: 9 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("60% correct"); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.6, - ); - }); - - cy.log("change partial criterion"); - cy.get(cesc("#\\/partialcriterion") + " textarea") - .type("{ctrl+home}{shift+end}{backspace}2", { force: true }) - .blur(); - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.6, - ); - }); - - cy.log("Resubmit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move point closer again and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -3, y: 9 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("60% correct"); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.6, - ); - }); - - cy.log("Move point even closer and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -3.5, y: 8 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.6, - ); - }); - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - }); - - it("two points at precise locations, partial match", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - a - (-4.1, 7.4) - (6.8, 9.1) -

Move points to $goal1.coords $goal2.coords

- - - - $goal1 - $goal2 - - - - - $goal1 - $goal2 - - - -

- - - ($A, $B) = ($goal1, $goal2) - - -

-

Credit for answer: $_answer1.creditAchieved{assignNames="ca"}

-

Submitted responses: $_answer1.submittedResponses

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load - - cy.get(cesc("#\\/goal1") + " .mjx-mrow").should( - "contain.text", - "(−4.1,7.4)", - ); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc(`#\\/srs`) + ` .mjx-mrow`).should( - "contain.text", - "(4.9,−1.1),(−2.3,−3.4)", - ); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(4.9,-1.1),(-2.3,-3.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move A near correct point"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -4, y: 7.6 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(-2.3,-3.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A further away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -3.7, y: 7 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0.0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-3.7,7),(-2.3,-3.4)", - ); - }); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move point B close and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: -3.8, y: 7.1 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-3.7,7),(-4.1,7.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A close to other goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: 6.9, y: 9.0 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/ca")).should("have.text", 1); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(-4.1,7.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - - cy.log("Move point B away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: -9.9, y: -8.8 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(-9.9,-8.8)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point B close to second goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: 6.7, y: 9 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(6.8,9.1)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: 0.1, y: -1.1 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(0.1,-1.1),(6.8,9.1)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A near first goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -3.8, y: 7.6 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 1); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(6.8,9.1)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - }); - - it("two points at precise locations, partial match, ordered", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - a - (-4.1, 7.4) - (6.8, 9.1) -

Move points to $goal1.coords $goal2.coords

- - - - $goal1 - $goal2 - - - - - $goal1 - $goal2 - - - -

- - - ($A, $B) = ($goal1, $goal2) - - -

-

Credit for answer: $_answer1.creditAchieved{assignNames="ca"}

-

Submitted responses: $_answer1.submittedResponses

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load - - cy.get(cesc(`#\\/goal1`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal("(-4.1,7.4)"); - }); - cy.get(cesc(`#\\/goal2`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal("(6.8,9.1)"); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(4.9,-1.1),(-2.3,-3.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move A near correct point"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -4, y: 7.6 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(-2.3,-3.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A further away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -3.7, y: 7 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0.0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-3.7,7),(-2.3,-3.4)", - ); - }); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move point B close and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: -3.8, y: 7.1 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-3.7,7),(-4.1,7.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A close to other goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: 6.9, y: 9.0 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(-4.1,7.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point B away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: -9.9, y: -8.8 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(-9.9,-8.8)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point B close to second goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: 6.7, y: 9 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(6.8,9.1)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: 0.1, y: -1.1 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(0.1,-1.1),(6.8,9.1)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A near first goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -3.8, y: 7.6 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 1); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(6.8,9.1)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - }); - - it("two points at precise locations, award based as string literals, partial match", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - a - (-4.1, 7.4) - (6.8, 9.1) -

Move points to $goal1.coords $goal2.coords

- - - - $goal1 - $goal2 - - - - - $goal1 - $goal2 - - - -

- - - ($A, $B) = ((-4.1, 7.4), (6.8, 9.1)) - - -

-

Credit for answer: $_answer1.creditAchieved{assignNames="ca"}

-

Submitted responses: $_answer1.submittedResponses

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load - - cy.get(cesc("#\\/goal1") + " .mjx-mrow").should( - "contain.text", - "(−4.1,7.4)", - ); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(4.9,-1.1),(-2.3,-3.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move A near correct point"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -4, y: 7.6 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(-2.3,-3.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A further away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -3.7, y: 7 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0.0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-3.7,7),(-2.3,-3.4)", - ); - }); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move point B close and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: -3.8, y: 7.1 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-3.7,7),(-4.1,7.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A close to other goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: 6.9, y: 9.0 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/ca")).should("have.text", 1); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(-4.1,7.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - - cy.log("Move point B away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: -9.9, y: -8.8 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(-9.9,-8.8)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point B close to second goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: 6.7, y: 9 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(6.8,9.1)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: 0.1, y: -1.1 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(0.1,-1.1),(6.8,9.1)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A near first goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -3.8, y: 7.6 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 1); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(6.8,9.1)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - }); - - it("two points at precise locations, award based as string literals, partial match, ordered", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - a - (-4.1, 7.4) - (6.8, 9.1) -

Move points to $goal1.coords $goal2.coords

- - - - $goal1 - $goal2 - - - - - $goal1 - $goal2 - - - -

- - - ($A, $B) = ((-4.1, 7.4), (6.8, 9.1)) - - -

-

Credit for answer: $_answer1.creditAchieved{assignNames="ca"}

-

Submitted responses: $_answer1.submittedResponses

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load - - cy.get(cesc("#\\/goal1") + " .mjx-mrow").should( - "contain.text", - "(−4.1,7.4)", - ); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(4.9,-1.1),(-2.3,-3.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move A near correct point"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -4, y: 7.6 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(-2.3,-3.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A further away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -3.7, y: 7 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0.0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-3.7,7),(-2.3,-3.4)", - ); - }); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move point B close and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: -3.8, y: 7.1 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-3.7,7),(-4.1,7.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A close to other goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: 6.9, y: 9.0 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(-4.1,7.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point B away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: -9.9, y: -8.8 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(-9.9,-8.8)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point B close to second goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: 6.7, y: 9 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(6.8,9.1)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: 0.1, y: -1.1 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(0.1,-1.1),(6.8,9.1)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A near first goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -3.8, y: 7.6 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 1); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(6.8,9.1)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - }); - - it("two points at precise locations, partial match, as mathlists", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - a - (-4.1, 7.4) - (6.8, 9.1) -

Move points to $goal1.coords $goal2.coords

- - - - $goal1 - $goal2 - - - - - $goal1 - $goal2 - - - -

- - - $A $B = $goal1 $goal2 - - -

-

Credit for answer: $_answer1.creditAchieved{assignNames="ca"}

-

Submitted responses: $_answer1.submittedResponses

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load - - cy.get(cesc("#\\/goal1") + " .mjx-mrow").should( - "contain.text", - "(−4.1,7.4)", - ); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(4.9,-1.1),(-2.3,-3.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move A near correct point"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -4, y: 7.6 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(-2.3,-3.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A further away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -3.7, y: 7 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0.0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-3.7,7),(-2.3,-3.4)", - ); - }); - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Move point B close and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: -3.8, y: 7.1 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-3.7,7),(-4.1,7.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A close to other goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: 6.9, y: 9.0 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/ca")).should("have.text", 1); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(-4.1,7.4)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - - cy.log("Move point B away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: -9.9, y: -8.8 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(-9.9,-8.8)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point B close to second goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: 6.7, y: 9 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(6.8,9.1)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: 0.1, y: -1.1 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(0.1,-1.1),(6.8,9.1)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.log("Move point A near first goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -3.8, y: 7.6 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0.5, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 1); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(6.8,9.1)", - ); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 1, - ); - }); - }); - - it("dynamical number of points, partial match, as mathlists", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - a - (-4.1, 7.4) - (6.8, 9.1) -

Move points to $goal1.coords $goal2.coords

-

Number of points:

- - - - - - -

- - - $map1 = $goal1 $goal2 - - -

-

Credit for answer: $_answer1.creditAchieved{assignNames="ca"}

-

Submitted responses: $_answer1.submittedResponses

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load - - cy.get(cesc("#\\/goal1") + " .mjx-mrow").should( - "contain.text", - "(−4.1,7.4)", - ); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal("_"); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Create point A and submit"); - cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}1{enter}", { - force: true, - }); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal("(1,1)"); - }); - - cy.log("Move A near correct point"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -4, y: 7.6 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal("(-4.1,7.4)"); - }); - - cy.log("Move point A further away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -3.7, y: 7 }, - }); - }); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0.0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal("(-3.7,7)"); - }); - - cy.log("create point B and submit"); - cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}2{enter}", { - force: true, - }); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal("(-3.7,7),(2,1)"); - }); - - cy.log("Move point B close and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: -3.8, y: 7.1 }, - }); - }); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-3.7,7),(-4.1,7.4)", - ); - }); - - cy.log("Move point A close to other goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: 6.9, y: 9.0 }, - }); - }); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/ca")).should("have.text", 1); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(-4.1,7.4)", - ); - }); - - cy.log("Move point B away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: -9.9, y: -8.8 }, - }); - }); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(-9.9,-8.8)", - ); - }); - - cy.log("Move point B close to second goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B", - args: { x: 6.7, y: 9 }, - }); - }); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(6.8,9.1)", - ); - }); - - cy.log("Move point A away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: 0.1, y: -1.1 }, - }); - }); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(0.1,-1.1),(6.8,9.1)", - ); - }); - - cy.log("Move point A near first goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A", - args: { x: -3.8, y: 7.6 }, - }); - }); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 1); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(6.8,9.1)", - ); - }); - - cy.log("create point C and submit"); - cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}3{enter}", { - force: true, - }); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.667); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(6.8,9.1),(3,1)", - ); - }); - - cy.log("Move point C near first goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/C", - args: { x: -3.8, y: 7.6 }, - }); - }); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("67% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.667); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(6.8,9.1),(-4.1,7.4)", - ); - }); - - cy.log("remove point C and submit"); - cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}2{enter}", { - force: true, - }); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 1); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(6.8,9.1)", - ); - }); - }); - - it("dynamical number of points, double map, partial match", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` - a - (-4.1, 7.4) - (6.8, 9.1) -

Move points to $goal1.coords $goal2.coords

-

Number of points:

-

Number of points 2:

- - - - - - -

- - - $map1 = $goal1 $goal2 - - -

-

Credit for answer: $_answer1.creditAchieved{assignNames="ca"}

-

Submitted responses: $_answer1.submittedResponses

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); // to wait for page to load - - cy.get(cesc("#\\/goal1") + " .mjx-mrow").should( - "contain.text", - "(−4.1,7.4)", - ); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal("_"); - }); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.log("Create point A1 and submit"); - cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}1{enter}", { - force: true, - }); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal("(1,1)"); - }); - - cy.log("Move A1 near correct point"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A1", - args: { x: -4, y: 7.6 }, - }); - let stateVariables = await win.returnAllStateVariables1(); - expect(stateVariables["/_answer1"].stateValues.creditAchieved).eq( - 0, - ); - }); - - cy.get(cesc("#\\/_answer1_submit")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("check work"); - }); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal("(-4.1,7.4)"); - }); - - cy.log("Move point A1 further away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A1", - args: { x: -3.7, y: 7 }, - }); - }); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0.0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal("(-3.7,7)"); - }); - - cy.log("create point A2 and submit"); - cy.get(cesc("#\\/m") + " textarea").type("{end}{backspace}1{enter}", { - force: true, - }); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("incorrect"); - }); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 0); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal("(-3.7,7),(1,2)"); - }); - - cy.log("Move point A2 close and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A2", - args: { x: -3.8, y: 7.1 }, - }); - }); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-3.7,7),(-4.1,7.4)", - ); - }); - - cy.log("Move point A1 close to other goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A1", - args: { x: 6.9, y: 9.0 }, - }); - }); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - - cy.get(cesc("#\\/ca")).should("have.text", 1); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(-4.1,7.4)", - ); - }); - - cy.log("Move point A2 away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A2", - args: { x: -9.9, y: -8.8 }, - }); - }); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(-9.9,-8.8)", - ); - }); - - cy.log("Move point A2 close to second goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A2", - args: { x: 6.7, y: 9 }, - }); - }); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(6.8,9.1),(6.8,9.1)", - ); - }); - - cy.log("Move point A1 away and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A1", - args: { x: 0.1, y: -1.1 }, - }); - }); - - cy.log("Submit answer"); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(0.1,-1.1),(6.8,9.1)", - ); - }); - - cy.log("Move point A1 near first goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/A1", - args: { x: -3.8, y: 7.6 }, - }); - }); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 1); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(6.8,9.1)", - ); - }); - - cy.log("create point B1 and B2 and submit"); - cy.get(cesc("#\\/n") + " textarea").type("{end}{backspace}2{enter}", { - force: true, - }); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(6.8,9.1),(2,1),(1,2)", - ); - }); - - cy.log("Move point B1 near second goal and submit"); - cy.window().then(async (win) => { - await win.callAction1({ - actionName: "movePoint", - componentName: "/B1", - args: { x: 7, y: 9 }, - }); - }); - - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")).should("not.exist"); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("50% correct"); - }); - cy.get(cesc("#\\/ca")).should("have.text", 0.5); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(6.8,9.1),(6.8,9.1),(1,2)", - ); - }); - - cy.log("remove points A2 and B2 and submit"); - cy.get(cesc("#\\/m") + " textarea").type("{end}{backspace}0{enter}", { - force: true, - }); - cy.get(cesc("#\\/_answer1_submit")).click(); - cy.get(cesc("#\\/_answer1_submit")).should("not.exist"); - cy.get(cesc("#\\/_answer1_correct")) - .invoke("text") - .then((text) => { - expect(text.trim().toLowerCase()).equal("correct"); - }); - cy.get(cesc("#\\/_answer1_incorrect")).should("not.exist"); - cy.get(cesc("#\\/_answer1_partial")).should("not.exist"); - cy.get(cesc("#\\/ca")).should("have.text", 1); - cy.get(cesc(`#\\/srs`)) - .find(".mjx-mrow") - .eq(0) - .invoke("text") - .then((text) => { - expect(text.trim().replace(/−/g, "-")).equal( - "(-4.1,7.4),(6.8,9.1)", - ); - }); - }); }); diff --git a/packages/test-cypress/cypress/e2e/answerValidation/symbolicequality.cy.js b/packages/test-cypress/cypress/e2e/answerValidation/symbolicequality.cy.js deleted file mode 100644 index 2c8ea526d..000000000 --- a/packages/test-cypress/cypress/e2e/answerValidation/symbolicequality.cy.js +++ /dev/null @@ -1,2393 +0,0 @@ -import { cesc, cesc2 } from "@doenet/utils"; - -describe("Symbolic equality tests", function () { - beforeEach(() => { - cy.clearIndexedDB(); - cy.visit("/"); - }); - - it("symbolic equality match with no simplification", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

- 1+3: - - $_math1 - - -

- -

3+1: - - $_math2 - -

- -

Numeric versions

-

- $_math1 -

-

- $_math2 -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputPartialAnchor = cesc2( - "#" + mathinputName + "_partial", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2PartialAnchor = cesc2( - "#" + mathinput2Name + "_partial", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - let mathinput3Name = - stateVariables["/_answer3"].stateValues.inputChildren[0] - .componentName; - let mathinput3Anchor = cesc2("#" + mathinput3Name) + " textarea"; - let mathinput3SubmitAnchor = cesc2( - "#" + mathinput3Name + "_submit", - ); - let mathinput3CorrectAnchor = cesc2( - "#" + mathinput3Name + "_correct", - ); - let mathinput3PartialAnchor = cesc2( - "#" + mathinput3Name + "_partial", - ); - let mathinput3IncorrectAnchor = cesc2( - "#" + mathinput3Name + "_incorrect", - ); - - let mathinput4Name = - stateVariables["/_answer4"].stateValues.inputChildren[0] - .componentName; - let mathinput4Anchor = cesc2("#" + mathinput4Name) + " textarea"; - let mathinput4SubmitAnchor = cesc2( - "#" + mathinput4Name + "_submit", - ); - let mathinput4CorrectAnchor = cesc2( - "#" + mathinput4Name + "_correct", - ); - let mathinput4PartialAnchor = cesc2( - "#" + mathinput4Name + "_partial", - ); - let mathinput4IncorrectAnchor = cesc2( - "#" + mathinput4Name + "_incorrect", - ); - - cy.get(mathinputSubmitAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).should("be.visible"); - cy.get(mathinput3SubmitAnchor).should("be.visible"); - cy.get(mathinput4SubmitAnchor).should("be.visible"); - - cy.log("Submit empty answers"); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3IncorrectAnchor).should("be.visible"); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("The sum isn't correct for symbolic"); - cy.get(mathinputAnchor).type("4{enter}", { force: true }); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type("4{enter}", { force: true }); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type("4{enter}", { force: true }); - cy.get(mathinput3CorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type("4{enter}", { force: true }); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("3+1"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}3+1{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}3+1{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}3+1{enter}", - { force: true }, - ); - cy.get(mathinput3CorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}3+1{enter}", - { force: true }, - ); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("1+3"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1+3{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1+3{enter}", - { force: true }, - ); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}1+3{enter}", - { force: true }, - ); - cy.get(mathinput3CorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}1+3{enter}", - { force: true }, - ); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("1+1+1+1"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1+1+1+1{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1+1+1+1{enter}", - { force: true }, - ); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}1+1+1+1{enter}", - { force: true }, - ); - cy.get(mathinput3CorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}1+1+1+1{enter}", - { force: true }, - ); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); - - it("symbolic equality match with no simplification 2", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

- 1x-0y+-3s: - - $_math1 - -

- -

Numeric version

-

- $_math1 -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputPartialAnchor = cesc2( - "#" + mathinputName + "_partial", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2PartialAnchor = cesc2( - "#" + mathinput2Name + "_partial", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type("1x-0y+-3s{enter}", { force: true }); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type("1x-0y+-3s{enter}", { force: true }); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Plus negative to subtraction"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x-0y-3s{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x-0y-3s{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Parentheses"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x-0y+(-3s){enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x-0y+(-3s){enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Positive zero"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x+0y-3s{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x+0y-3s{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Remove zero term"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x-3s{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x-3s{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Remove one coefficient"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}x-0y-3s{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}x-0y-3s{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Reorder terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}-0y+1x-3s{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}-0y+1x-3s{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); - - it("symbolic equality match with simplifying numbers, preserving order", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

- 1x^2+2-0x^2+3+x^2+3x^2+7+4: - - $_math1 - -

- -

Numeric versions

-

- $_math1 -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputPartialAnchor = cesc2( - "#" + mathinputName + "_partial", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2PartialAnchor = cesc2( - "#" + mathinput2Name + "_partial", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type( - "1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Simplify numbers"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}x^2{rightArrow}+5+x^2{rightArrow}+3x^2{rightArrow}+11{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}x^2{rightArrow}+5+x^2{rightArrow}+3x^2{rightArrow}+11{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Permute adjacent numbers"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+4+7{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+4+7{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Permute adjacent variable terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+3x^2{rightArrow}+x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+3x^2{rightArrow}+x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine adjacent variable terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine all numbers"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}-0x^2{rightArrow}+x^2{rightArrow}+3x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}-0x^2{rightArrow}+x^2{rightArrow}+3x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine all terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}5x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}5x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); - - it("symbolic equality match with simplifying numbers, preserving order, attributes on answer", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

- 1x^2+2-0x^2+3+x^2+3x^2+7+4: - $_math1 -

- -

Numeric versions

-

- $_math1 -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputPartialAnchor = cesc2( - "#" + mathinputName + "_partial", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2PartialAnchor = cesc2( - "#" + mathinput2Name + "_partial", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type( - "1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Simplify numbers"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}x^2{rightArrow}+5+x^2{rightArrow}+3x^2{rightArrow}+11{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}x^2{rightArrow}+5+x^2{rightArrow}+3x^2{rightArrow}+11{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Permute adjacent numbers"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+4+7{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+4+7{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Permute adjacent variable terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+3x^2{rightArrow}+x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+3x^2{rightArrow}+x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine adjacent variable terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine all numbers"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}-0x^2{rightArrow}+x^2{rightArrow}+3x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}-0x^2{rightArrow}+x^2{rightArrow}+3x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine all terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}5x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}5x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); - - it("symbolic equality match with simplifying numbers, preserving order, attributs on when", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

- 1x^2+2-0x^2+3+x^2+3x^2+7+4: - - - $_math1=$_mathinput1 - -

- -

Numeric versions

-

- $_math1 -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputPartialAnchor = cesc2( - "#" + mathinputName + "_partial", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2PartialAnchor = cesc2( - "#" + mathinput2Name + "_partial", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type( - "1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Simplify numbers"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}x^2{rightArrow}+5+x^2{rightArrow}+3x^2{rightArrow}+11{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}x^2{rightArrow}+5+x^2{rightArrow}+3x^2{rightArrow}+11{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Permute adjacent numbers"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+4+7{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+4+7{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Permute adjacent variable terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+3x^2{rightArrow}+x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+3x^2{rightArrow}+x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine adjacent variable terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine all numbers"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}-0x^2{rightArrow}+x^2{rightArrow}+3x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}-0x^2{rightArrow}+x^2{rightArrow}+3x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine all terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}5x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}5x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); - - it("symbolic equality match with simplifying numbers", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

- 1x^2+2-0x^2+3+x^2+3x^2+7+4: - - $_math1 - -

- -

Numeric versions

-

- $_math1 -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputPartialAnchor = cesc2( - "#" + mathinputName + "_partial", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2PartialAnchor = cesc2( - "#" + mathinput2Name + "_partial", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type( - "1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Simplify numbers"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}x^2{rightArrow}+x^2{rightArrow}+3x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}x^2{rightArrow}+x^2{rightArrow}+3x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Permute terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}7+1x^2{rightArrow}-0x^2{rightArrow}+3+3x^2{rightArrow}+4+2+x^2{rightArrow}{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}7+1x^2{rightArrow}-0x^2{rightArrow}+3+3x^2{rightArrow}+4+2+x^2{rightArrow}{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine variable terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine adjacent variable terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine all terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}5x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}5x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); - - it("symbolic equality match with simplifying numbers, attributes on answer", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

- 1x^2+2-0x^2+3+x^2+3x^2+7+4: - $_math1 -

- -

Numeric versions

-

- $_math1 -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputPartialAnchor = cesc2( - "#" + mathinputName + "_partial", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2PartialAnchor = cesc2( - "#" + mathinput2Name + "_partial", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type( - "1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Simplify numbers"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}x^2{rightArrow}+x^2{rightArrow}+3x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}x^2{rightArrow}+x^2{rightArrow}+3x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Permute terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}7+1x^2{rightArrow}-0x^2{rightArrow}+3+3x^2{rightArrow}+4+2+x^2{rightArrow}{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}7+1x^2{rightArrow}-0x^2{rightArrow}+3+3x^2{rightArrow}+4+2+x^2{rightArrow}{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine variable terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine adjacent variable terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine all terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}5x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}5x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); - - it("symbolic equality match with simplifying numbers, attributes on when", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

- 1x^2+2-0x^2+3+x^2+3x^2+7+4: - - - $_math1=$_mathinput1 - -

- -

Numeric versions

-

- $_math1 -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputPartialAnchor = cesc2( - "#" + mathinputName + "_partial", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2PartialAnchor = cesc2( - "#" + mathinput2Name + "_partial", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type( - "1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "1x^2{rightArrow}+2-0x^2{rightArrow}+3+x^2{rightArrow}+3x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Simplify numbers"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}x^2{rightArrow}+x^2{rightArrow}+3x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}x^2{rightArrow}+x^2{rightArrow}+3x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Permute terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}7+1x^2{rightArrow}-0x^2{rightArrow}+3+3x^2{rightArrow}+4+2+x^2{rightArrow}{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}7+1x^2{rightArrow}-0x^2{rightArrow}+3+3x^2{rightArrow}+4+2+x^2{rightArrow}{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine variable terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine adjacent variable terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}1x^2{rightArrow}+2-0x^2{rightArrow}+3+4x^2{rightArrow}+7+4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine all terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}5x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}5x^2{rightArrow}+16{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); - - it("symbolic equality match with full simplification", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

- 6x^2 -3x +8x-4 + (2x-3)(4-x): - - $_math1 - -

- -

Numeric versions

-

- $_math1 -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputPartialAnchor = cesc2( - "#" + mathinputName + "_partial", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2PartialAnchor = cesc2( - "#" + mathinput2Name + "_partial", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type( - "6x^2{rightArrow} -3x +8x-4 + (2x-3)(4-x){enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "6x^2{rightArrow} -3x +8x-4 + (2x-3)(4-x){enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Combine terms"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}6x^2{rightArrow} + 5x-4 + (2x-3)(4-x){enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}6x^2{rightArrow} + 5x-4 + (2x-3)(4-x){enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Permute terms and factors"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}-4 + 6x^2{rightArrow} + (4-x)(-3+2x) + 5x{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}-4 + 6x^2{rightArrow} + (4-x)(-3+2x) + 5x{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Expand polynomial"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}6x^2{rightArrow} + 5x-4-2x^2{rightArrow}+11x-12{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}6x^2{rightArrow} + 5x-4-2x^2{rightArrow}+11x-12{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Expand and simplify"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}4x^2{rightArrow} + 16x-16{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}4x^2{rightArrow} + 16x-16{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Factor polynomial"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(3x+4)(2x -1) + (2x-3)(4-x){enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(3x+4)(2x -1) + (2x-3)(4-x){enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); - - it("symbolic equality match with expand and full simplification", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

- (2x-3)(4-x) + sin(x)^2+cos(x)^2: - - $_math1 - -

- -

Numeric versions

-

- $_math1 -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputPartialAnchor = cesc2( - "#" + mathinputName + "_partial", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2PartialAnchor = cesc2( - "#" + mathinput2Name + "_partial", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - cy.log("Submit exact answer"); - cy.get(mathinputAnchor).type( - "(2x-3)(4-x) + sin(x)^2{rightArrow}+cos(x)^2{rightArrow}{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "(2x-3)(4-x) + sin(x)^2{rightArrow}+cos(x)^2{rightArrow}{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Expand polynomial"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}-2x^2{rightArrow}+11x-12 + sin(x)^2{rightArrow}+cos(x)^2{rightArrow}{enter}", - { force: true }, - ); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}-2x^2{rightArrow}+11x-12 + sin(x)^2{rightArrow}+cos(x)^2{rightArrow}{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Simplify trig"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}(2x-3)(4-x) + 1{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}(2x-3)(4-x) + 1{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); - - it("symbolic equality with simplification can match simplified negative", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

-

- What is -3-4? - - $expr{simplify} - -

- -

Numeric versions

-

What is $expr? - - $expr{simplify} -

- `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - cy.get(mathinputSubmitAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).should("be.visible"); - - cy.log("Submit empty answers"); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2IncorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(0); - }); - - cy.log("The sum is always correct"); - cy.get(mathinputAnchor).type("-7{enter}", { force: true }); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type("-7{enter}", { force: true }); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("The original expression is incorrect for symbolic"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}-3-4{enter}", - { force: true }, - ); - cy.get(mathinputIncorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}-3-4{enter}", - { force: true }, - ); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(0); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); - - it("symbolic equality with simplification, exponentials", () => { - cy.window().then(async (win) => { - win.postMessage( - { - doenetML: ` -

a

- -5 *e^(-t) - -5 *exp(-t) - - $eans - $expans - $(eans{simplify}) - $(expans{simplify}) - - `, - }, - "*", - ); - }); - - cy.get(cesc("#\\/_text1")).should("have.text", "a"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - let mathinputName = - stateVariables["/_answer1"].stateValues.inputChildren[0] - .componentName; - let mathinputAnchor = cesc2("#" + mathinputName) + " textarea"; - let mathinputSubmitAnchor = cesc2("#" + mathinputName + "_submit"); - let mathinputCorrectAnchor = cesc2( - "#" + mathinputName + "_correct", - ); - let mathinputIncorrectAnchor = cesc2( - "#" + mathinputName + "_incorrect", - ); - - let mathinput2Name = - stateVariables["/_answer2"].stateValues.inputChildren[0] - .componentName; - let mathinput2Anchor = cesc2("#" + mathinput2Name) + " textarea"; - let mathinput2SubmitAnchor = cesc2( - "#" + mathinput2Name + "_submit", - ); - let mathinput2CorrectAnchor = cesc2( - "#" + mathinput2Name + "_correct", - ); - let mathinput2IncorrectAnchor = cesc2( - "#" + mathinput2Name + "_incorrect", - ); - - let mathinput3Name = - stateVariables["/_answer3"].stateValues.inputChildren[0] - .componentName; - let mathinput3Anchor = cesc2("#" + mathinput3Name) + " textarea"; - let mathinput3SubmitAnchor = cesc2( - "#" + mathinput3Name + "_submit", - ); - let mathinput3CorrectAnchor = cesc2( - "#" + mathinput3Name + "_correct", - ); - let mathinput3IncorrectAnchor = cesc2( - "#" + mathinput3Name + "_incorrect", - ); - - let mathinput4Name = - stateVariables["/_answer4"].stateValues.inputChildren[0] - .componentName; - let mathinput4Anchor = cesc2("#" + mathinput4Name) + " textarea"; - let mathinput4SubmitAnchor = cesc2( - "#" + mathinput4Name + "_submit", - ); - let mathinput4CorrectAnchor = cesc2( - "#" + mathinput4Name + "_correct", - ); - let mathinput4IncorrectAnchor = cesc2( - "#" + mathinput4Name + "_incorrect", - ); - - cy.get(mathinputSubmitAnchor).should("be.visible"); - cy.get(mathinput2SubmitAnchor).should("be.visible"); - cy.get(mathinput3SubmitAnchor).should("be.visible"); - cy.get(mathinput4SubmitAnchor).should("be.visible"); - - cy.log("Submit original form"); - cy.get(mathinputAnchor).type("-5e^-t{enter}", { force: true }); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type("-5e^-t{enter}", { force: true }); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type("-5e^-t{enter}", { force: true }); - cy.get(mathinput3CorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type("-5e^-t{enter}", { force: true }); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Submit as exp"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}-5exp(-t)", - { force: true }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}-5exp(-t)", - { force: true }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}-5exp(-t)", - { force: true }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3CorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}-5exp(-t)", - { force: true }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Submit as ratio with exponent"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}-5/e^t", - { - force: true, - }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}-5/e^t", - { - force: true, - }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}-5/e^t", - { - force: true, - }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3CorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}-5/e^t", - { - force: true, - }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - - cy.log("Submit as ratio with exp"); - cy.get(mathinputAnchor).type( - "{ctrl+home}{shift+end}{backspace}-5/exp(t)", - { force: true }, - ); - cy.get(mathinputSubmitAnchor).click(); - cy.get(mathinputCorrectAnchor).should("be.visible"); - cy.get(mathinput2Anchor).type( - "{ctrl+home}{shift+end}{backspace}-5/exp(t)", - { force: true }, - ); - cy.get(mathinput2SubmitAnchor).click(); - cy.get(mathinput2CorrectAnchor).should("be.visible"); - cy.get(mathinput3Anchor).type( - "{ctrl+home}{shift+end}{backspace}-5/exp(t)", - { force: true }, - ); - cy.get(mathinput3SubmitAnchor).click(); - cy.get(mathinput3CorrectAnchor).should("be.visible"); - cy.get(mathinput4Anchor).type( - "{ctrl+home}{shift+end}{backspace}-5/exp(t)", - { force: true }, - ); - cy.get(mathinput4SubmitAnchor).click(); - cy.get(mathinput4CorrectAnchor).should("be.visible"); - - cy.window().then(async (win) => { - let stateVariables = await win.returnAllStateVariables1(); - expect( - stateVariables["/_answer1"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer2"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer3"].stateValues.creditAchieved, - ).eq(1); - expect( - stateVariables["/_answer4"].stateValues.creditAchieved, - ).eq(1); - }); - }); - }); -});