Why is this one working,
and this one with the count number usage only working part of the time?
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:
numericValue("1")
you can just use 1
.Text= `${value}`
result = when value=1 or value=2 "Correct!" otherwise "Incorrect."
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:
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, @JayChow 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.