# Is it a glich or am I doing something wrong?

**URL:** <https://cl.desmos.com/t/is-it-a-glich-or-am-i-doing-something-wrong/7829>\
**Category:** Questions\
**Created:** [March 17, 2025, 12:34pm UTC](https://cl.desmos.com/t/is-it-a-glich-or-am-i-doing-something-wrong/7829 "2025-03-17T12:34:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Terry\_Silveus](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/terry_silveus/32/6494_2.png) [@Terry\_Silveus](https://cl.desmos.com/u/Terry_Silveus)\
**Post date:** [March 17, 2025, 12:34pm UTC](https://cl.desmos.com/t/is-it-a-glich-or-am-i-doing-something-wrong/7829/1 "2025-03-17T12:34:03Z")

</div>

> **[ISAT Prep Target A Grade 6 • Activity Builder by Desmos Classroom](https://teacher.desmos.com/activitybuilder/custom/67d6b8aff7d50d4db76c57b7)**
>
> Target A RP.6.A Understand ratio and rate concepts and use ratio and rate reasoning to solve problems.

I’m trying to keep track of statistics such as longest streak of correct answers on a page (2) for random questions.

I have it working in a graph that I copied from someone else’s code, but I don’t understand how to follow or modify it - the graph just throws me and I don’t have the time to learn right now. So I thought I’d recreate it in code which I do understand and can follow better, but computational layer is not like any code I’ve ever written. So I’m having some issues here also.

It seems that the action button code is not acting like an event handler (the code runs as soon as the page loads rather than waiting until I actually click the button. The code in question is in the btnCheck1 component. The code that isn’t working is currentStreak and currentMax. I have modified it several times from my original in an attempt to circumvent the issue. Originally I was trying to capture current streak, but that wasn’t working, so I decided to capture how much to remove from the score, but that’s not working either. When I look at the variable values, it seems that the captures happen before the action button is pressed.

---

<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:** [March 17, 2025, 7:15pm UTC](https://cl.desmos.com/t/is-it-a-glich-or-am-i-doing-something-wrong/7829/2 "2025-03-17T19:15:56Z")

</div>

You are correct that the code runs when the page loads (it also doesn’t load for thumbnails in case you ever wonder why your preview doesn’t match).

Here’s a method using alternately hidden buttons (rather than disabling) with score, total number of questions answered, current streak and longest streak. You can update `btn1` to use whatever component you like with the correctness defined in that component.

> **[Examples for Forum 2 • Activity Builder by Desmos Classroom](https://teacher.desmos.com/activitybuilder/custom/677415872f44f41f5debc1e3)**
>
> by Daniel Grubbs

A side thing I noticed in your below CL. `when-otherwise` conditionals don’t work in the same way a switch would in other coding languages. It will follow the order given and output once a condition is met, so below the “`and noOfStars >=#`” becomes redundant.

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/3/3e03885806d62dc06be4afe99486165067fe846a.png)  
Let me know if you’ve got any questions!

---

<div class="post-metadata">

**Author:** ![Terry\_Silveus](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/terry_silveus/32/6494_2.png) [@Terry\_Silveus](https://cl.desmos.com/u/Terry_Silveus)\
**Post date:** [March 18, 2025, 12:27pm UTC](https://cl.desmos.com/t/is-it-a-glich-or-am-i-doing-something-wrong/7829/3 "2025-03-18T12:27:41Z")

</div>

Thanks. This I can follow and modify. I do have one question though. In the filter for the list el is being used. It’s not a variable and I can’t find it in the documentation. I think I know what it is doing, but I’m not sure and where can I find things like this in the documentation?

---

<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:** [March 18, 2025, 1:59pm UTC](https://cl.desmos.com/t/is-it-a-glich-or-am-i-doing-something-wrong/7829/4 "2025-03-18T13:59:49Z")

</div>

You may consider lists still beta, so the documentation is not quite there yet. [Here](https://cl.desmos.com/t/list-functions-in-cl/7353) is an article from a colleague, and in this example of [a summary table](https://cl.desmos.com/t/summary-of-the-students-score/7816/6) I provided in another thread, I have comments in my code.

Basically, the syntax for most list functions is `list.functionName((el, i) => output/condition)` where “el” is the current element, and the optional argument “i” is the current index, which you might use to reference corresponding elements in other lists. You can use any variable name you like for “el” and “i”.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/f/f5bd144684474e9a2f333002cde9840e52c5dbd3.png) [@system](https://cl.desmos.com/u/system)\
**Post date:** [March 20, 2025, 1:59pm UTC](https://cl.desmos.com/t/is-it-a-glich-or-am-i-doing-something-wrong/7829/5 "2025-03-20T13:59:59Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
