# Points appear in graph

Hi,

I am trying to create the code that will allow students to input a coordinate point into a math input and have that point appear on a graph (as the vertex to a parabola). I’m reading through the CL documentation and struggling. Thanks in advance!

For student input as an ordered pair:

In graph CL,

``````number(`h`): parseOrderedPair(input.latex).x
number(`k`): parseOrderedPair(input.latex).y
``````

In the graph, (setting a to whatever you want):

``````y=a(x-h)^2+k
``````

Thank you. Do I need to define my variables in the Math input CL?

Essentially, I want to provide a graph y = (x -2)^2 + 5 and have students input the vertex (2,5) and see that it appears at the minimum point to connect that relationship between vertex form and the vertex.

No you don’t need to define variables in the math input, though you may want to add a correct sink to it, so you get a checkmark on the dashboard.

`correct: parseOrderedPair(this.latex).x=2 and parseOrderedPair(this.latex).y=5`

(You’ll also need `readOnly: true` in your graph CL.)

Also, I misunderstood your need. Instead of the function in the graph with variables h and k. Make a point `(h,k)`. If you allow it to set sliders, you can choose a color. Then, delete the sliders or you’ll see an initial point.

So the sink I added to my math input (labeled exp1) is
“correct:parseOrderedPair(this.latex).x=2 and parseOrderedPair(this.latex).y=5”

In my graph CL (labeled graph1), I have

“number(`h`): parseOrderedPair(exp1.latex).x
number(`k`): parseOrderedPair(exp1.latex).y

Forgive me as I am trying to learn this coding procedure, but I’m still not getting the check mark for my CL. Thanks.

You need `readOnly: true` in your graph CL.

Essentially, any component that can be “graded” (i.e. has a `correct` sink available) needs to have correctness defined or defined as read only to get a checkmark. Text inputs and explain prompts will never get checkmarks because it’s expected the teacher needs to look at those slides.

In my math input CL it says “objects of different types are never equal”. In my graph CL it says “sink number expects a number but got a latex”. In my graph, I have the equation y = (x-2)^2 + 5, a point (h,k) with sliders and I hid the point.

I always forget it outputs latex. Either put backticks around the 2 and 5, or (I think less likely to have errors) use numericValue around the left hand side of each:

``````correct: numericValue(parseOrderedPair(this.latex).x)=2 and numericValue(parseOrderedPair(this.latex).y)=5
``````

Math CL is good, but the graph CL still says sink number expects a number, but got a latex. I’m not sure what that means.

Same issue as the math input. Need to use `numericValue` around the `parseOrderedPair` part:

``````number(`h`): numericValue(parseOrderedPair(exp1.latex).x)
``````

Now, it says graph1 has no source for latex and gives me additional options. Here is what I have:
number(`h`): numericValue(parseOrderedPair(this.latex).x)
number(`k`): numericValue(parseOrderedPair(this.latex).y)

Are you missing the backticks (or quotes) around the h and k? It needs to look like this:

``````number(`h`): ...
``````

and I accidentally left `this.latex` when it should be `exp1.latex`.

Thanks. So now my CL is good, but when I preview it and try a point, I don’t see it on the graph.

Do you have `(h,k)` in your graph?

Can you share your activity? (Make sure it’s published and not a draft.)

Yes, I have (h,k) in my graph.

I have been working on slide 9

You need to have the color toggled on for (h,k). Then, delete the variables h and k if you don’t want an initial point showing.

Success. I really appreciate all of the help. Now that I have a working code, I’m hoping to work backwards to better understand some of the terms and language. Thanks.

1 Like