# Drag point to a line and check correct

**URL:** <https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384>\
**Category:** Questions\
**Tags:** validation, correctness\
**Created:** [July 13, 2022, 7:45pm UTC](https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384 "2022-07-13T19:45:38Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pamela\_Davis](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/pamela_davis/32/1890_2.png) [@Pamela\_Davis](https://cl.desmos.com/u/Pamela_Davis)\
**Post date:** [July 13, 2022, 7:45pm UTC](https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384/1 "2022-07-13T19:45:38Z")

</div>

I am working on a pictogram and have the basics set up. I would like to figure out how to check if the student has moved “x” number of points to a specific line.

https://www.desmos.com/calculator/4d7d234759?embed

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [July 13, 2022, 8:56pm UTC](https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384/2 "2022-07-13T20:56:11Z")

</div>

Here you are. I cleaned up a lot. Any time you’re repeating a lot of code, you can probably use a list instead, so your pictogram images and grid lines I condensed into individual lines using lists. I used some rounding in the line locations so you don’t need to worry about students having them a little (or even a lot) off.

> **[Pictograms](https://www.desmos.com/calculator/os309mp9a5)**
>
> Pictograms

---

<div class="post-metadata">

**Author:** ![Pamela\_Davis](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/pamela_davis/32/1890_2.png) [@Pamela\_Davis](https://cl.desmos.com/u/Pamela_Davis)\
**Post date:** [July 13, 2022, 9:18pm UTC](https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384/3 "2022-07-13T21:18:48Z")

</div>

Thank you for cleaning up the code. I really want to learn how to do this.

When I test this, the images are not “clicking in place” and I don’t see how it can check for correct. For example, the students should have 2 images on the 0 frequency line and 5 images on the 1 frequency line, etc.

---

<div class="post-metadata">

**Author:** ![Daniel\_Wekselgreene](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_wekselgreene/32/1819_2.png) [@Daniel\_Wekselgreene](https://cl.desmos.com/u/Daniel_Wekselgreene)\
**Post date:** [July 14, 2022, 2:53am UTC](https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384/4 "2022-07-14T02:53:13Z")

</div>

Another approach which may make this simpler is to have + and - buttons next to each number, and students click on them to increase or decrease the number of pictures in each row. Then you wouldn’t have to worry about dragging issues. If you want to see an example of that, let me know, and I will put it together.

---

<div class="post-metadata">

**Author:** ![pirsquared](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@pirsquared](https://cl.desmos.com/u/pirsquared)\
**Post date:** [July 14, 2022, 8:26am UTC](https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384/5 "2022-07-14T08:26:06Z")

</div>

The way Daniel\_G has set it up, the frequencies are contained in the F\_req list so you can compare against that. For instance, you could set up a C\_Freq list [2, 5, …] and test using something like {F\_req = C\_Freq : 1, 0} which will yield 1 if the two lists match, and 0 if they don’t.

Not sure what you mean by “clicking into place” as the original file you shared didn’t behave differently as far as I can tell.

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [July 14, 2022, 3:43pm UTC](https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384/6 "2022-07-14T15:43:16Z")

</div>

Here’s one where the images snap to the lines (not the points), so it can be a little confusing if you want to go back to adjust it.

> **[Pictograms](https://www.desmos.com/calculator/dupevags70)**
>
> Pictograms

---

<div class="post-metadata">

**Author:** ![Pamela\_Davis](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/pamela_davis/32/1890_2.png) [@Pamela\_Davis](https://cl.desmos.com/u/Pamela_Davis)\
**Post date:** [July 15, 2022, 3:31pm UTC](https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384/7 "2022-07-15T15:31:25Z")

</div>

Thank you, everyone for your help. I have used the last example that Daniel provided which has the images snapping to the lines. I have added two lines to the coding for checking for correct (lines 16 and 17) and added to the CL: correct: this.number(`C_{orrect}`)=1 However, when I test this, I do not get a correct check mark. I’m not sure what to do to fix this. I do not understand line 15 code. Thank you, again for ALL of your assistance!!!

> **[Desmos | Graphing Calculator](https://www.desmos.com/calculator/96ed3f52db)**
>
> Explore math with our beautiful, free online graphing calculator. Graph functions, plot points, visualize algebraic equations, add sliders, animate graphs, and more.

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [July 15, 2022, 6:28pm UTC](https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384/8 "2022-07-15T18:28:16Z")

</div>

> [@Pamela\_Davis](#):
>
> I do not understand line 15 code.

The bulk of it is [list comprehension](https://help.desmos.com/hc/en-us/articles/4407889068557-Lists).  
The L\_ine list is the location for each emoji. Line 15 is checking the number of times each value occurs in the list.

`L_ine[L_ine=2]` would scan through list L\_ine for all values equivalent to 2, and creates a new list with only those values. .length takes the length of that list. This is done for each value of n, 0 to 4, so you end up with a list of frequencies.

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [July 15, 2022, 6:31pm UTC](https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384/9 "2022-07-15T18:31:16Z")

</div>

> [@Pamela\_Davis](#):
>
> added to the CL: correct: this.number(`C_{orrect}`)=1 However, when I test this, I do not get a correct check mark.

C\_orrect is a list and can’t equal 1. Try using:

```auto
C_{orrect}=total( {F_{req}-C_{Freq}=0:1,0} )

```

and C\_{orrect}=5 in your CL.

---

<div class="post-metadata">

**Author:** ![Pamela\_Davis](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/pamela_davis/32/1890_2.png) [@Pamela\_Davis](https://cl.desmos.com/u/Pamela_Davis)\
**Post date:** [July 15, 2022, 9:06pm UTC](https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384/10 "2022-07-15T21:06:15Z")

</div>

I’m still having problems getting this to show as correct on the teacher dashboard. I would really like for them to drag icons but maybe I need to look at the + or - option instead.

---

<div class="post-metadata">

**Author:** ![Pamela\_Davis](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/pamela_davis/32/1890_2.png) [@Pamela\_Davis](https://cl.desmos.com/u/Pamela_Davis)\
**Post date:** [July 15, 2022, 9:10pm UTC](https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384/11 "2022-07-15T21:10:51Z")

</div>

I still am not getting a correct mark on the teacher dashboard. Not sure what I am doing wrong. I did change the CL and the code in the graph based on your suggestion. I’m sorry that I am being difficult.

> **[Desmos | Graphing Calculator](https://www.desmos.com/calculator/295b3ae67e)**
>
> Explore math with our beautiful, free online graphing calculator. Graph functions, plot points, visualize algebraic equations, add sliders, animate graphs, and more.

---

<div class="post-metadata">

**Author:** ![Daniel\_Wekselgreene](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_wekselgreene/32/1819_2.png) [@Daniel\_Wekselgreene](https://cl.desmos.com/u/Daniel_Wekselgreene)\
**Post date:** [July 16, 2022, 1:04am UTC](https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384/12 "2022-07-16T01:04:56Z")

</div>

No worries - it takes a long time to learn the ins and outs of this. Here is an activity with the clicking option: [Pictogram example with click • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/62d20d7df8ada56c8fc072f5)

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [July 16, 2022, 4:49pm UTC](https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384/13 "2022-07-16T16:49:57Z")

</div>

> [@Pamela\_Davis](#):
>
> I still am not getting a correct mark on the teacher dashboard.

Can’t really tell only looking at the graph. The graph portion looks okay. Are there any other components that could be affecting your correctness? Can you share your activity?

---

<div class="post-metadata">

**Author:** ![Pamela\_Davis](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/pamela_davis/32/1890_2.png) [@Pamela\_Davis](https://cl.desmos.com/u/Pamela_Davis)\
**Post date:** [July 17, 2022, 1:10am UTC](https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384/14 "2022-07-17T01:10:05Z")

</div>

Thank you for your help!!

> **[\[Copy of\] "Unit 3 - Before you start" • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/62d35fe33e4041c4b8312945)**
>
> by Pamela Davis

It’s on slide 2

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [July 17, 2022, 4:39am UTC](https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384/15 "2022-07-17T04:39:44Z")

</div>

Yep. Any component that has the _possibility_ of a correct sink needs it or “readOnly: true”. So, your table needs the latter.

---

<div class="post-metadata">

**Author:** ![Pamela\_Davis](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/pamela_davis/32/1890_2.png) [@Pamela\_Davis](https://cl.desmos.com/u/Pamela_Davis)\
**Post date:** [July 18, 2022, 8:28pm UTC](https://cl.desmos.com/t/drag-point-to-a-line-and-check-correct/4384/16 "2022-07-18T20:28:49Z")

</div>

Thank you for all of your help!!
