# Repeated practice with button and attempted history

**URL:** <https://cl.desmos.com/t/repeated-practice-with-button-and-attempted-history/3325>\
**Category:** Questions\
**Created:** [May 23, 2021, 10:24pm UTC](https://cl.desmos.com/t/repeated-practice-with-button-and-attempted-history/3325 "2021-05-23T22:24:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sian\_Sleight](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/sian_sleight/32/1592_2.png) [@Sian\_Sleight](https://cl.desmos.com/u/Sian_Sleight)\
**Post date:** [May 23, 2021, 10:24pm UTC](https://cl.desmos.com/t/repeated-practice-with-button-and-attempted-history/3325/1 "2021-05-23T22:24:46Z")

</div>

I tried to adapt a repeated practice from tracking with input submitted to tracking with press count for this activity, and I don’t know how to fix the current streak or the longest streak in this code. Actually, I wouldn’t mind if I could just keep track of problems correct and problems attempted if that would be easier for me to understand.

> **[Add Integer Rules • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/60aac432d3db4607fc90cb6e)**

Or, if someone could link an activity that has uses random numbers and a button and also tracks attempted problems, I could probably hack it altogether.  
I did find this in my search for an example to borrow from, but the only example that uses a button just tracks problems correct.

> **[Multiple Questions with Random Numbers](http://www.mrchowmath.com/blog/multiple-questions-with-random-numbers)**
>
> Your browser does not support iframes.

Anyway, I appreciate any help or feedback.

---

<div class="post-metadata">

**Author:** ![Aethir](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/aethir/32/2767_2.png) [@Aethir](https://cl.desmos.com/u/Aethir)\
**Post date:** [May 24, 2021, 3:18am UTC](https://cl.desmos.com/t/repeated-practice-with-button-and-attempted-history/3325/2 "2021-05-24T03:18:55Z")

</div>

Is this the sort of basic thing you are looking for?

> **[Tracking correctness • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/60ab1af753ba75081acb9aa7)**
>
> by Zachary Armstrong

---

<div class="post-metadata">

**Author:** ![Sian\_Sleight](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/sian_sleight/32/1592_2.png) [@Sian\_Sleight](https://cl.desmos.com/u/Sian_Sleight)\
**Post date:** [May 24, 2021, 3:44pm UTC](https://cl.desmos.com/t/repeated-practice-with-button-and-attempted-history/3325/3 "2021-05-24T15:44:19Z")

</div>

Thanks for this, but I have plenty of activities that track progress with the math input.  
I was needing an example that did the same tracking, but using the multiple choice submit button.

---

<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:** [May 24, 2021, 4:19pm UTC](https://cl.desmos.com/t/repeated-practice-with-button-and-attempted-history/3325/4 "2021-05-24T16:19:27Z")

</div>

What I notice is there’s a little bit of sneaky math happening, and there are a few things to add to fix it. The prefilled list T shows an example of how a student score should look. Capturing `c_urrent` allows calculation of the longest streak. (The negative values cancel the prior streaks.)  
 ![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/5/5ac147e44648514193aaa08a7a54849da1b19948.png)  
A student gets a 1 for correct, and the negative value of the last streak (which is `c_urrent`), so if you change the `otherwise 0` for `correct` in the note CL, as well as add a line to account for previous answers being incorrect, then it will allow the current streak to display:

```auto
correct = when addGraph.number(`c_{urrent}`)<=0 0
          when sum>0 and choice.script.choice=1 1
          when sum<0 and choice.script.choice=2 1
          otherwise numericValue(`-1*${addGraph.number(`c_{urrent}`)}`)

```

Then, `numberList(`a_{ll}`)` calls on the history for “long” which isn’t defined in the button. So in the button add:

```auto
capture("long"): addGraph.number(`l_{ongest}`)

```

There was also an issue with `a_ll` being undefined so I changed line 42:

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/8/8529f93c81b2c1d32761f6feaa3b6f5d43f6bdc7.png)

---

<div class="post-metadata">

**Author:** ![Sian\_Sleight](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/sian_sleight/32/1592_2.png) [@Sian\_Sleight](https://cl.desmos.com/u/Sian_Sleight)\
**Post date:** [May 24, 2021, 7:42pm UTC](https://cl.desmos.com/t/repeated-practice-with-button-and-attempted-history/3325/5 "2021-05-24T19:42:56Z")

</div>

Thank you for your help. I made these changes, and now the only feedback it gives is “Sorry, that’s not correct.” I can’t see why it isn’t working.

feedback = when button.timeSincePress\>0 and button.lastValue(“correct”)=1 “🟢That’s correct. Please try another problem.”  
when button.timeSincePress\>0 “🟡Sorry, that’s not correct. Try another one – you’ll do better next time!”  
otherwise “”

---

<div class="post-metadata">

**Author:** ![cwinske](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/cwinske/32/3106_2.png) [@cwinske](https://cl.desmos.com/u/cwinske)\
**Post date:** [May 24, 2021, 9:06pm UTC](https://cl.desmos.com/t/repeated-practice-with-button-and-attempted-history/3325/6 "2021-05-24T21:06:53Z")

</div>

Your `correct` variable is getting stuck on the first line because the current number starts at 0. I’m not sure if that line is needed, but I also haven’t looked into the code very long. I commented out the line and the activity seemed to work as intended. If it is needed, try moving it to the third position instead of the first.

---

<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:** [May 24, 2021, 9:16pm UTC](https://cl.desmos.com/t/repeated-practice-with-button-and-attempted-history/3325/8 "2021-05-24T21:16:23Z")

</div>

Maybe change c\_urrent in the graph to this?

```auto
c_urrent= {length(T)>0: total(T),0}

```

---

<div class="post-metadata">

**Author:** ![Sian\_Sleight](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/sian_sleight/32/1592_2.png) [@Sian\_Sleight](https://cl.desmos.com/u/Sian_Sleight)\
**Post date:** [May 24, 2021, 9:47pm UTC](https://cl.desmos.com/t/repeated-practice-with-button-and-attempted-history/3325/9 "2021-05-24T21:47:37Z")

</div>

Sweet, it’s working as intended now. Thank you so much for all your help!

---

<div class="post-metadata">

**Author:** ![Sian\_Sleight](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/sian_sleight/32/1592_2.png) [@Sian\_Sleight](https://cl.desmos.com/u/Sian_Sleight)\
**Post date:** [May 24, 2021, 9:57pm UTC](https://cl.desmos.com/t/repeated-practice-with-button-and-attempted-history/3325/10 "2021-05-24T21:57:46Z")

</div>

It occurred to me I had to add a ‘zero’ option, and the buttons defaulted to a multiple choice list, which is fine, because it still works great.  
But, I’m just curious–is there a way to force the choices to stay as big button tabs?

---

<div class="post-metadata">

**Author:** ![Aethir](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/aethir/32/2767_2.png) [@Aethir](https://cl.desmos.com/u/Aethir)\
**Post date:** [May 24, 2021, 11:22pm UTC](https://cl.desmos.com/t/repeated-practice-with-button-and-attempted-history/3325/11 "2021-05-24T23:22:44Z")

</div>

There’s a dropdown menu on the MC component to choose which style you’d like.

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/d/d5cb85a72d51c0d0205044f546b8ac05be02e88e.png)
