# Checking for Correctness

**URL:** <https://cl.desmos.com/t/checking-for-correctness/2284>\
**Category:** Questions\
**Tags:** dashboard, validation, correctness\
**Created:** [January 1, 2021, 11:37pm UTC](https://cl.desmos.com/t/checking-for-correctness/2284 "2021-01-01T23:37:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frances\_Janowiak](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/frances_janowiak/32/1410_2.png) [@Frances\_Janowiak](https://cl.desmos.com/u/Frances_Janowiak)\
**Post date:** [January 1, 2021, 11:37pm UTC](https://cl.desmos.com/t/checking-for-correctness/2284/1 "2021-01-01T23:37:03Z")

</div>

I am trying to figure out what code to use. I am wanting students to look at the linear piecewise functions and then write the function and domain in the table. Then be able to get feedback if what they typed is correct as well as showing in the dashboard if they are correct.

The equations in the table are what the answers should be.

Any assistance would be greatly appreciated. It is the last slide of the activity.

[Graphing Piecewise Functions • Activity by Frances Janowiak](https://teacher.desmos.com/activitybuilder/custom/5fef6b326623e70d690a6cd2)

 ![#7](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/8/88b2d6927e2482f3656b793245c22833cd95de86.jpeg)

---

<div class="post-metadata">

**Author:** ![Susan\_Lauer](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/susan_lauer/32/1832_2.png) [@Susan\_Lauer](https://cl.desmos.com/u/Susan_Lauer)\
**Post date:** [January 2, 2021, 2:19pm UTC](https://cl.desmos.com/t/checking-for-correctness/2284/2 "2021-01-02T14:19:11Z")

</div>

This is the code for the red graph, but just copy and make a few changes for the green. This goes in your table CL:

```auto
# idea from https://teacher.desmos.com/activitybuilder/custom/5eb18d6a22180f0ace8005e3
fRed = simpleFunction("${this.cellContent(3,2)}","x")
correctRed = fRed.evaluateAt(2) > 2.99 and fRed.evaluateAt(2) <3.01 and fRed.evaluateAt(6) > 4.99 and fRed.evaluateAt(6) < 5.01
correctRedDomain = this.cellContent(4,2)="x>2"
cellContent(3,3): when correctRed "✅" otherwise ""
cellContent(4,3): when correctRedDomain "✅" otherwise ""

```

---

<div class="post-metadata">

**Author:** ![Susan\_Lauer](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/susan_lauer/32/1832_2.png) [@Susan\_Lauer](https://cl.desmos.com/u/Susan_Lauer)\
**Post date:** [January 2, 2021, 2:56pm UTC](https://cl.desmos.com/t/checking-for-correctness/2284/3 "2021-01-02T14:56:46Z")

</div>

The \>= requires LaTeX for \le and \ge:

```auto
# idea from https://cl.desmos.com/t/checking-correctness-of-an-inequality/1542
correctGreenDomain= this.cellContent(2,2) = `x \le 2`
cellContent(2,3): when correctGreenDomain "✅" otherwise ""       

```

---

<div class="post-metadata">

**Author:** ![Frances\_Janowiak](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/frances_janowiak/32/1410_2.png) [@Frances\_Janowiak](https://cl.desmos.com/u/Frances_Janowiak)\
**Post date:** [January 2, 2021, 4:19pm UTC](https://cl.desmos.com/t/checking-for-correctness/2284/4 "2021-01-02T16:19:40Z")

</div>

Thank you for your help. Can you please explain to me what the numbers represent for when looking at the correctRed? I am trying to duplicate but I am confused on how you determined the numbers. Also, how would you code for a less than or equal to symbol?

---

<div class="post-metadata">

**Author:** ![Susan\_Lauer](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/susan_lauer/32/1832_2.png) [@Susan\_Lauer](https://cl.desmos.com/u/Susan_Lauer)\
**Post date:** [January 2, 2021, 5:24pm UTC](https://cl.desmos.com/t/checking-for-correctness/2284/5 "2021-01-02T17:24:09Z")

</div>

For correctRed:  
**fRed.evaluateAt(2) \> 2.99 and fRed.evaluateAt(2) \<3.01**  
means I’m taking the function they entered and checking the value at x = 2 for the red graph. Since decimal accuracy can be an issue for non-integers, I’ve seen many posts that recommend checking an interval, so I’ve checked 2.99 \< y \<3.01 for y = 3. This probably could be replaced in your activity with  
**fRed.evaluateAt(2) = 3**

Since you’re graphing lines, you need to check 2 points, so you add the check at x = 6:  
**fRed.evaluateAt(6) \> 4.99 and fRed.evaluateAt(6) \< 5.01**  
which you might be able to replace with  
**fRed.evaluateAt(6) =5**

For x \<= 2, you need LaTeX: **`x \le 2`**  
**\ge** works for \>=. See the last post for how this should be coded. (The **`** mark is on the same key as the ~ in upper left key on the keyboard.)

Note that you could pull values from the graph to make the code more generic instead of entering specific y-values.

---

<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:** [January 2, 2021, 8:03pm UTC](https://cl.desmos.com/t/checking-for-correctness/2284/6 "2021-01-02T20:03:12Z")

</div>

Just FYI, `simpleFunction` defaults in terms of x, if no variable is specified.  
So, this:

> [@Susan\_Lauer](#):
>
> `fRed = simpleFunction("${this.cellContent(3,2)}","x")`

can be written as  
`fRed = simpleFunction("${this.cellContent(3,2)}")`
