Dragging a line to fit an equation

Need help on how to do the following:

Below is the current shell of code I have. It makes an equation. What I want is for students to have to use the graph layer next to the note and drag a line on the graph to match the equation. How can I best do that?

r=randomGenerator()

m=numericValue("(-1)^${r.int(0,1)}*${r.int(2,6)}")
b=r.int(-8,8)

eq="y=${m}x+b"



correct=??

co= when correct=1 "Correct! Good work" otherwise "Not there yet, keep working"

content: "
Given the following equation:

${eq}

Match the line on the graph to represent the equation.

Your answer: ${co}
"

Slide 34 on this activity is the slide in question

I’d use two points (myself I’d use sliders with a unit or half unit Step) that form a line. Then, check that slope and intercept are within desired tolerance.

That is exactly what I needed! Thank you!

Got a follow up if you have the time. I tried to expand upon this and make two lines but I am hitting a wall. Do you see what I am doing wrong? It is slide 35 on this link

Simple oversight. In your functions (f(x) and g(x)), you put x_a and x_b where it should just be x.

That did it. Thanks!

I am actually still having an error. Sometimes when I match one of the lines it will just say correct. Do you see where this may be coming from? I tried to set it up where either line could be placed where the given equation are. Do I need to somehow just set the top one for the purple line and the bottom one for the red line?

Slide 35

Played with it more on a duplicate slide (slide 36). I made it where the lines are specific to each equations. Red goes with the second one and purple with the top one. I also found that the c value shows up as 1 when the lines match in all cases except for the when the b is 0. Then it shows up as a zero. Everything else seems to be working from what I can tell.

Here’s my solution. I evaluated the difference of each function using a list of x values (function f-h, f-k, g-h, and g-k). I put everything in the Alternate Correction folder.

That’s perfect! Thanks so much!

It is reading both of these as correct, which is that initial problem I had as well. Any idea on this, or is it just one of those things you give them a warning about and just keep moving forwards?



Here is where it sees the error

Would a way to resolve this be something where you evaluate the target liens and the input line to see if they match outputs and that is an additional correctness check?

You’re using your old checks. If in your note you use:

correct=graph.number(`C_{orrect}`)=0
co= when correct "Correct...

You won’t need the colors, and I think it should work fine.

That is it. I didnt think about the alternate checks having a different name. Ok I will stop buggin you with this slide. I appreciate your help man!

1 Like