Checking fractions

Hi , I’m trying to cheack that students input to a probabilty question is correct: Thia is the code I have :slight_smile:
t=table1
cellContent(1,3): when t.cellNumericValue(1,2)= \frac{1}{6} β€œ:white_check_mark:” OTHERWISE β€œN”

You want cellContent not cellNumericValue.

If within the same component in this case table1 you can use β€œthis” instead of β€œtable1”

cellContent(1,3): when this.cellContent(1,2)= \frac{1}{6} β€œ:white_check_mark:” otherwise β€œN”

1 Like

Also this would work and reduces the number of table columns.
cellSuffix(1,2): when this.cellContent(1,2)= \frac{1}{6} β€œ:white_check_mark:” otherwise β€œN”

1 Like

How can I get my table to mark correct for fraction answers? On slide 16… I have tried numeric value and cellContent. Neither work.

Thank You

use latex=\frac{2}{3}

1 Like

You need backticks round \frac{2}{3}

1 Like

There are numerous ways to check fractions (for simplicity examples are for an input)

  1. Latex matching: check= this.latex=`/frac{2}{3}`
    Short and sweet, but can be inaccurate. Copy paste from Desmos calculator for intended latex.
  2. Inequalities:
    a. check= this.numericValue<=0.67 and this.numericValue>0.6
    b. check= numericValue(`\abs(\frac{2}{3}-${this.numericValue})`)<0.01
  3. simpleFunction (a little more accurate than numericValue):
check= simpleFunction(`\frac{2}{3}).evaluateAt(0)=simpleFunction(this.latex).evaluateAt(0)
  1. Pattern matching:
p=patterns
check= p.fraction(p.integer.satisfies(`x=2`), p.integer.satisfies(`x=3`)).matches(this.latex)