I’m very new to CL. I am attempting to create a self checking activity were students have to simplify a rational expression. Then, they type their simplified expression in a math input box and hit the submit button, if it is right, I want them to know it is correct or it to tell them to try again. Here is an example problem and the solution ((2x^2+x)/((2x+1)^2)) - (3/(2x+1)) with the solution ((x-3)/(2x+1)).
I have included the activity below!
Any coding that I can copy and paste then adjust for each problem would be incredible. I think I am supposed to use parseEquation from other posts, but I honestly have no idea.
Thank you!! Activity
The simplest (but not necessarily most reliable) way is latex. Typing the expected answer into the input, and then copying and pasting that into the CL will give you the right formatting:
check= this.latex=`your answer here`
The more complicated (but stable) method is to evaluate a function AND check that certain numbers were used (since you’re looking for a particular format), so for your example above:
#student input as a function
check= f.evaluateAt(3)=0 and f.evaluateAt(2)=-0.2
and countNumberUsage(exp,3)=1 and countNumberUsage(exp,2)=1
You want to evaluate at as many values you feel is adequate. I only did a few but you can add more.
countNumberUsage counts the occurrence of a particular number (not digit) in an expression. It does not take negatives. So, both -2x and 2x would count one 2, but evaluating the expression takes care of ambiguity.
You do need to consider if you want to accept a student writing “1x”, so you may want:
... and (countNumberUsage(exp,1)=1 or countNumberUsage(exp,1)=2)
Thank you so much!! I am going to attempt both, though I don’t quite understand the bottom one, but am going to look into it more.
Follow up question, I see that this CL marks it correct with a checkmark, can the students see that? Is there a different CL I need to include to make the button tell the students they got it right? Thank you again.
Nevermind! I figured it out! Thank you!!
This is the reason I use a variable “check” and then define “correct: check”. This way you can also use “check” in other components for feedback.
For the second example, “exp” is just so that I don’t have to have “this.latex” multiple times in “check”. Just kind of cleans it up a little.
“f” is a function created from student input (i.e. f(x)= student input)
f.evaluateAt( ) substitutes values of x and checks the output is what you’d expect. I chose a few that were easy to calculate in my head and had non-repeating decimal answers (i.e. f(3)=0? and f(2)=-0.2?).
countNumberUsage takes latex (here “exp”) and a number and outputs how many times that number is used. So,
countNumberUsage(exp,3)=1 is checking if the student used the number 3 once in their expression.
If you only used evaluating the function, students could just retype the original expression and it would be marked correct. This is why you need countNumberUsage to check if they’ve simplified.
This is perfect, I was wondering how to fix this. I have students not simplifying rational expressions all the way but function
evaluateAt() still marks it as correct.
Exactly my use case Kayla, thanks Daniel, nice!