Hope I can get some help! In cellContent(2,2) and cellContent(2,4), I want to be able to check the numerical value the students input instead of having to write every version of the answer as a check.
Is there a way to use numericValue to do that in a table cell? I am a very beginner level programmer and have been trying to figure this out for quite some time. Any help would be greatly appreciated!
Here is the code that I have created for Slide 1 of
correct: this.cellContent(1,1)=“” and this.cellContent(1,3) =“” and this.cellContent(2,1)=“” and this.cellContent(2,3)=“”
cellContent(1,2):
when this.cellContent(1,1) =“\frac{\left(-4+5\right)}{2}” “”
otherwise “”
cellContent(1,4):
when this.cellContent(1,3) =“\frac{\left(4±1\right)}{2}” “”
otherwise “”
cellContent(2,2):
when (this.cellContent(2,1) =“0.5” or this.cellContent(2,1)=“.5” or this.cellContent(2,1)=“\frac{1}{2}”) “”
otherwise “”
cellContent(2,4):
when this.cellContent(2,3) =“” “”
otherwise “”
Hi!
You absolutely can use cellNumericValue, but this will accept any format of answer. For example, if students typed (-4 + 5)/2 in the bottom left cell, it still gets marked correct. Checking the format of a student’s answer is more advanced and uses the patterns library. If you’re curious to learn more, Desmos has a YouTube playlist introducing patterns.
# decimalOrFraction checks if students entered a decimal value (the "number" pattern) or a fraction with a decimal value in the numerator and denominator
p = patterns
decimalOrFraction = p.anyOf(p.number, p.fraction(p.number, p.number))
cellContent(2,2):
when (
this.cellNumericValue(2, 1) = 0.5 # correct value
and decimalOrFraction.matches(this.cellContent(2, 1)) # correct format
) "✔"
otherwise ""
Yes, thank you so much! This is exactly what I needed! I will definitely have to check out that playlist, I had a feeling that this solution would be more complex than my realm of understanding code. Thanks again!