# Checking the text answer using math function

I am trying to get my activity builder to check the answers for a physics problem. I want my students to be able to enter their answer with the units. (Because units are so important!). I figured out how to do it when the answer is something like 1.4J but when the answer is 1.4m/s it gets screwed up because the / make messes with the format of the answer. IS there an easy workaround?

What were you doing before? You should be able to use simpleFunction treating m and s as variables.

I have been using \frac{m}{s}.

I have a similar question for an activity with understanding units and label concepts. The math input auto corrects minute to ‘min’ ute and cost to ‘cos’ t, because of the math functions for them. I can’t figure out how to check input for text input, though. I have been matching latex, and want to accept answers like “minutes per second” as well as “m/s”, or ideas like “cost of a shirt”.

Yeah, like this:
correct = this.latex = 1.4\frac{m}{s}
The students will have to highlight the m before using the forward slash, though, or put a space between the number and the units.

I was thinking:

correct= simpleFunction(this.latex,"m","s").evaluateAt(10,2)=7


Basically, we’re taking a function, f(m,s)=student input, which should be f(m,s)=1.4m/s, so f(10,2)=7. You could pick a few pairs to evaluate to be more accurate.

You could also use a table set as text input, and could then check answers like “cost of a shirt”, but you’d need to code a lot variations.

correct= simpleFunction(this.cellContent(1,2),"m","s").evaluateAt(10,2)=7
or this.cellContent(1,2)="cost of a shirt"
or this.cellContent(1,2)="shirt cost"

2 Likes

Table input will totally work, thank you!
And yes, I am sure no how many variations I add in, some student will come up with one I missed. I am not planning on doing it for that many slides, though–multiple choice will be a nice change of pace.

Is there a way to do this without a table? I find it hard to look at students work quickly and give feedback when it is in a table because it gets smushed in weird ways. Thanks!

You can use a text input, but you wouldn’t be able to get a checkmark on your dashboard.

Nora, isn’t this what you are looking for?