# Count number usage check

Why is this one working,

and this one with the count number usage only working part of the time?

Would you be able to provide a link to the activity?

Also, need the link, but a few efficiency suggestions:

1. You don’t need to use numericValue("1") you can just use 1.
2. You can just use the value variable to define your text:
Text= ${value}  3.  result = when value=1 or value=2 "Correct!" otherwise "Incorrect." (since value is defined by g.number("N") anyway). I’ll link it. Just FYI, eventually I will be working with fractions and decimals and ‘n’ and the text and the values will all be different. When I get frustrated working with the code, I try to break it down to the most simplistic form so I can get it to work, and then can easily add in the more complicated pieces as needed. Well complicated for me. I think it’s not working because submitting changes the variable, P_{ress}, but I’m not sure. You might need to use a capture, but it’ll only capture numericValues not latex. What is your objective here? That might help discover an alternative solution. For example, when I want randomized questions, rather than randomizing “on the fly”, I generate a random list(s) of values for problems and then just compare current values to the list. If I have this issue of countNumberUsage evaluating the next value, I just have to change which element in the list it checks. Here’s a kind of busywork example: 1 Like Yeah that’s exactly what is happening. Thanks for the example! I realize that particular example was quite a bit more work than some others. I’ll have to find a better one. Nuts, I ran into this problem before with a distributive property practice activity. It was recommended to try using pattern matching, but I couldn’t figure it out for that activity and went in a different direction. Does anyone have a pattern matching activity with fractions and decimals I can see as an example? For a decimal, you could just use numericValue and countNumberUsage. countNumberUsage(input.latex)=1  The above for example would just make sure only one number was used. Maybe this recent fraction question thread might be somewhere to start? Also, @Jay has a youTube video that covers fraction patterns. Hm, nvm, that was a thread on matching equivalent expressions. The one I was remembering also used capture history to correct the problem. Now that I understand the problem… If I wanted to have a list of randomly generated problems, using say n=1 through n=5, that reset each ‘n’ with a button, then I have to use the capture previous on a numeric value to compare the answer to when the button is pressed. Or, I have to use a separate button to check an answer with latex, and then have a new problem generated with a different button. Yes? I think I get it. The point of using a list of randomly generated problems is to just cycle through the list, so you would just use the submitCount/pressCount to move through the elements of the list. You could potentially check latex using elements from a list. A fraction, for example, you’d need a list for numerators and denominators, and I usually set variables for the values of the current problem (or last if needed for checking purposes), then use something like: In graph: Num= graph.number(n_C) Den= graph.number(d_C) check= input.latex=\frac{${Num} }{ \${Den} }


I’d have a variable set in the CL for the submit count (say p), then define n_C and d_C as the p+1 element of the numerator and denominator lists:

n_C= N[p+1]
d_C= N[p+1]


I totally have it working now. Thank you for all your help.

Curious though, is there a way to have the random generator change on the Edit my response’ click? It happens after pressing submit so it wouldn’t change my correct result.

I’m not sure if it does so. I have a tendency to use tables and usually make separate buttons for checking and cycling to new questions. That also means you have to code checks for each cell (though it’s usually a copy paste, or Alt+click/drag situation). It also allows my students to skip questions and go back to them though.