I've written a @NclNumbas question which marks a formula given by the student, then checks that they can apply it.
Lots of custom marking stuff to make sure their formula is equivalent to the expected one, and the number they give satisfies their formula
numbas.mathcentre.ac.uk/question/41804…