I used a graph to create an activity where students have to put some movable points in order. The objects under the pH scale (water, bleach, lemon, etc) are draggable sideways only:
How can I make it so I can check if the students put the objects in the right order (so it shows a in that particular slide in the summary)? I’m talking about the expression that starts with “correct: …”
I imagine I have to check that point C1 is between such and such x coordinates PLUS point C2 is between such and such coordinates, etc. But I’ve never done this before, this is my first attempt at this, and I don’t even know how I do refer to the points, their coordinates, and what the syntax is…
You’re not far off at all in your thinking. I tend to find that the easiest way to handle most stuff is to build the ‘maths’ parts into the graph, and just use the CL for controlling the activity parts.
In this case, for instance, I would set up variables in the graph that test for correctness. So you could use S1 = {x1 < C1.x < x2:1,0} which basically says, “if x-coordinate of C1 is between x1 and x2 then return a 1, otherwise return a 0”. If you repeated this for S2, S3, S4, … and then had a total variable that was T = S1+S2+S3+… , then all you need to do is extract that into the CL using T = graph.number("T"), and your correctness check is then just correct: T=4 (or however many you expect the total to be).
Hope this makes sense but share the activity with us if not and we can have a go at adding in the code.
Thanks for your reply. I tried your code and it’s complaining about the syntax. I had to change {} to () because of a syntax error, and now it’s complaining about the : operator.
I’m attaching a picture of the code. I’m only checking one point right now, so I made T=S1, which looks useless, but the idea is to make it T=S1+…+Sn
Also, I’m not sure I understand the purpose of T=graph.number(“T”). Isn’t Cn (point n) already related to the graph? What does the line do?
He was saying to do the calculations for S1 IN the graph itself, not the CL. The purpose of your line 3 is to then pull that calculation out of the graph to use it in the CL.
Ok. Sorry. I’m new to this. I know how to program in C, so naturally, every new language has an initial learning curve consisting in figuring out how to do such and such that I already know in C but in the new language.
So I put the rules in the graph, then I exported the variable in the CL, but it still complains…
The rules seem to work: when I drag the draggable point, the corresponding boolean variable changes to either 1 or 0 when it’s supposed to.
That first error is because your graph component isn’t named. Either name it “graph” or you can use “this” instead of a component name when your CL is in that component.
I used “this” to refer to the graph. I don’t know how to name the graph… Is this in edit graph? I guess that the advantage of naming the graph is that you can reference it in other slides, right? Or perhaps you can have two objects in one slide…
I don’t know if this is possible, but one thing I want to do is change the picture (the actual .png or .jpg or whatever) to something else once a variable is true. So in my example, if a picture (a draggable point) is placed in the right spot, I would change the picture for the exact same picture but with a tick mark indicating the placement is correct. And if the object is dragged from the right place to elsewhere, then it reverts to the original picture without the tick mark.
Another option (since the one I just described will make it very easy for students to drag the object from side to side until they see the tick mark), is to have a “check” button that returns a message (“You did it right/worng”).
Both have placeholder text, “Name this component”.
Naming a component is necessary to reference it from any other component. When referencing a component name with duplicate names, CL defaults to the component on the same screen. Convenient for duplicating screens.
If there isn’t one of the duplicates on the same screen, you get an error, and you’ll need to give them unique names.
As to the picture in the graph, you can use restrictions to conditionally display your image. I recommend using the “Angle” parameter, since it is probably the least changed and will allow you to see more of the entry (and Opacity defaults to 1 if undefined).
How you define the variable you use for your restriction can be as simple or complex as you like. You can set it only when a correct condition is true (e.g. s_howImage = {T_4 = 1}) or include other conditions like when a button timer is running (e.g s_howImage = {T_4 = 1}{t_0 > 0})