Expression evaluation

To do self checking I created a few random variable in a “note” that also composes a question.

Then in input box i wanted to check for input answer.

but in order to do that i need to import the random variable from note and evaluate them in an expression.

a = question.script.myA

b = question.script.myB

ans = ${b}-${a}

correct: this.numericValue = numericValue(ans)

to evaluate the expression, could not just do b -a.

I ended up constructing a latex expression and then numerically evaluating it.

Seems like expression evaluation should be a fundamental component of computation layer. This technique above works, but very ugly. Are there better ways?

There are some posts with techniques where they use graph component and expression capability there. But that approach seems even hackier.

Also there is a “simpleFunction” construct but that does not seem to be available in input boxes

simpleFunction is available in inputs. It won’t autocomplete unless you start a variable or sink. Also seems kind of hacky.

ans = simpleFunction("b-a","a","b").evaluateAt(a,b)
correct: this.numericValue = ans