# Mark Fraction answer as correct in Math Input

**URL:** <https://cl.desmos.com/t/mark-fraction-answer-as-correct-in-math-input/1782>\
**Category:** Questions\
**Created:** [October 25, 2020, 4:58pm UTC](https://cl.desmos.com/t/mark-fraction-answer-as-correct-in-math-input/1782 "2020-10-25T16:58:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashley\_Proctor](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/ashley_proctor/32/1409_2.png) [@Ashley\_Proctor](https://cl.desmos.com/u/Ashley_Proctor)\
**Post date:** [October 25, 2020, 4:58pm UTC](https://cl.desmos.com/t/mark-fraction-answer-as-correct-in-math-input/1782/1 "2020-10-25T16:58:46Z")

</div>

Hello, I am trying to mark an answer as correct in Math Input if a student enters a fraction such as 3/4. This is so confusing for me.

---

<div class="post-metadata">

**Author:** ![JAC9186](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jac9186/32/5018_2.png) [@JAC9186](https://cl.desmos.com/u/JAC9186)\
**Post date:** [October 26, 2020, 3:11pm UTC](https://cl.desmos.com/t/mark-fraction-answer-as-correct-in-math-input/1782/2 "2020-10-26T15:11:07Z")

</div>

Hello,

I created 3 screens to check that someone inputs 3/4 as their answer. You can see them here:

> **[fraction checker (teacher checkmark; student checkmark) • Activity Builder by...](https://teacher.desmos.com/activitybuilder/custom/5f96c48bcdf5cb0cb3211a55)**
>
> by Javier Cabezas

I left notes in the CL to explain what is happening. Fractions are a bit tricky to check against, as you check against numericValue and currently with “numerUsage” to identify how many times someone input a certain character. Hope this helps!

---

<div class="post-metadata">

**Author:** ![GeorgiaA](https://avatars.discourse-cdn.com/v4/letter/g/8c91f0/32.png) [@GeorgiaA](https://cl.desmos.com/u/GeorgiaA)\
**Post date:** [October 26, 2020, 11:08pm UTC](https://cl.desmos.com/t/mark-fraction-answer-as-correct-in-math-input/1782/3 "2020-10-26T23:08:36Z")

</div>

Thanks for your reply. So for one answer they have to put in the equation: y=-1/3x+1 and the other answer is -1/3 (2 different problems). Both of these are negative and repeating decimals. Not able to get it to work yet.

---

<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:** [October 27, 2020, 4:10am UTC](https://cl.desmos.com/t/mark-fraction-answer-as-correct-in-math-input/1782/4 "2020-10-27T04:10:56Z")

</div>

`countNumberUsage` doesn’t take negative numbers. So,

`correct: countNumberUsage(input.latex,1)=1 and countNumberUsage(input.latex,3)=1`  
would be correct for either -1/3 or 1/3 (or 3x+1 for that matter).

also checking for numericValue within a particular decimal range will handle positive versus negative.

---

<div class="post-metadata">

**Author:** ![GeorgiaA](https://avatars.discourse-cdn.com/v4/letter/g/8c91f0/32.png) [@GeorgiaA](https://cl.desmos.com/u/GeorgiaA)\
**Post date:** [October 27, 2020, 9:37pm UTC](https://cl.desmos.com/t/mark-fraction-answer-as-correct-in-math-input/1782/5 "2020-10-27T21:37:41Z")

</div>

So I the answer they have to put in now is **y = 1/3x+1**  
How to I code it so the program will check their equation?

---

<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:** [October 27, 2020, 9:44pm UTC](https://cl.desmos.com/t/mark-fraction-answer-as-correct-in-math-input/1782/6 "2020-10-27T21:44:18Z")

</div>

A simple way. This will accept any form of the line.

In the input CL:

```auto
myLine=xyLine(this.latex)
m=myLine.slope
b=myLine.yIntercept
correct: m<0.34 and m>0.32 and b=1

```

If you specifically want that form, you’ll need to add something a little more complicated:

```auto
rhs=parseEquation(this.latex).rhs
checkNumbers=countNumberUsage(rhs,1)=2 and countNumberUsage(rhs,3)=1

```

then, add `and checkNumbers` to the end of `correct` above. The second line of code above checks that the number 1 occurs twice (in the fraction and the y-intercept here), and 3 occurs once (in the fraction here).

---

<div class="post-metadata">

**Author:** ![GeorgiaA](https://avatars.discourse-cdn.com/v4/letter/g/8c91f0/32.png) [@GeorgiaA](https://cl.desmos.com/u/GeorgiaA)\
**Post date:** [October 27, 2020, 11:21pm UTC](https://cl.desmos.com/t/mark-fraction-answer-as-correct-in-math-input/1782/7 "2020-10-27T23:21:41Z")

</div>

It worked. Thank you so much!
