 I would like for my answer to not only accept 6/3 but also 2. What part of the code do I need to change?

correct: correct

correct = slope1.submitted and slope1.latex = “\frac{6}{3}”

suffix: when slope1.script.correct and slope1.submitted “ when slope1.submitted “ otherwise “”

Here is the activity: [Copy of] AG1 Identifying Slopes and y-intercepts • Activity Builder by Desmos

Something along the lines of

correct = slope1.submitted and (slope1.latex="\frac{6}{3}" or slope1.numericValue=2)

should do the trick - this will allow any answer equivalent to 2. (In fact making the LaTeX comparison redundant).

You could equally use (slope1.latex="\frac{6}{3}" or slope1.latex="2") if you wish to force only those two answers.

thank you, very easy fix! What would I change if it was a repeating fraction though? Like the slope was 2/3 and they put 6/4.

I mean 4/6, sorry long day

Then you can use the numericValue function… so slope1.numericValue=numericValue("2/3") should accept any equivalent to 2/3 - including, I just discovered, manually typing 0.6666666666666666 with at least 16 sixes!

Thank you so much, can I also ask you another question that you might be able to help me with. So they are writing equations and they could write y=4x+1 or y=16/4x+1 and technically they are both correct. My last coding just has the latex for one of them. How would I adjust that?

This is what I have for one of them:
correct: correct

disableEvaluation: true

correct = e1.submitted and e1.latex = “y=\frac{6}{3}x+2”

suffix: when e1.script.correct and e1.submitted “ when e1.submitted" "
otherwise “”

For linear functions like that you can use the xyLine function… so along the lines of

line=xyLine(e1.latex)
correct = e1.submitted and line.slope=4 and line.yIntercept=1

You may want to add additional checks if you want it specifically in y=mx+c form, because the code above will accept any equivalent variation - y-4x=1, x=(y-1)/4, etc. etc.

Thank you so much for all of your help

For non-terminating decimals, numericValue does not always yield equivalent (something to do with how it’s calculated). simpleFunction is more stable in this respect:

check= simpleFunction(slope1.latex).evaluateAt(0) = simpleFunction(2/3).evaluateAt(0)

However, you can also use inequalities in a few different ways:

check= slope1.numericValue>0.33 and slope1.numericValue<0.34

or

check= numericValue(\abs( (${slope1.numericValue}) - \frac{2}{3} ))<=0.01 I like to use the rounding operator. correct= when numericValue("\\operatorname{round}\\left(${input.numericValue},2\\right)")=numericValue("\\operatorname{round}\\left(\frac{2}{3},2\\right)")
1 Like

I knew I was missing one. 1 Like