Implementing scores in a chapter

If you are requesting technical assistance with Twine, please specify:
Twine Version:2.3.16
Story Format: Sugarcube

Ok, so I’m building a game in which in one chapter I’m asking the user three times for inputs and if it is in the range they get points of it. I have created a button so that they can check their answers, if it is right, a hidden block of code appears where there are further questions. But if it is wrong then a popover alert runs. So I give them points when the pop-up is not generated i.e when the answer is in the range. I want to implement points in such a way that if they got the first input correct and the other two wrong, they still get points for 1st input. But when they click the link twice after changing the values, they don’t get points for the 1st input as I have already rewarded them for it. I don’t know how to implement this. Can someone help me? Thanks!

My code for the chapter:

//After observing the system, enter your sample size, mean, and standard deviation. Before performing the hypothesis test(s), click "CHECK MY OBSERVATIONS" below to see if your observations fall within an acceptable range. If they do not, recollect data until your observations satisfy the requirements for a realistic sample.//

What were your observed values from the system?

Number of Samples Observed: <<textbox "$n" "">>
Mean of PREPARATION station processing time (minutes): <<textbox "$x" "">>
Standard Deviation of PREPARATION station processing time (minutes): <<textbox "$s" "">>

<<link "CHECK MY OBSERVATIONS">><<replace "#test">>

<<if 0.27 <= $x && $x <= 0.33 and $s <= 0.1 and 20 <= $n && $n < 30>>

Report your hypothesis testing results for the PREPARATION station:
<span id="choice">

/* **** set up the dropboxes for first question ***** */\
<<listbox "$response1">>
     <<option "Fail to Reject">>
	 <<option "Reject">>
<</listbox>> H0: µ = 0.3 minutes based on a <<listbox "$response2">>
     <<option "Z-test">>
	 <<option "t-test">>
	 <<option "paired t-test">>
	 <<option "chi-squared test">>
	 <<option "f-test">>
	 <<option "proportions test">>

Report your numerical results:

Test Statistic: 
<<textarea "$response3" "">>

<<textarea "$response4" "">>

Critical Region:
<<textarea "$response5" "">><<textarea "$response6" "">>
<<button "Submit">>

<<replace "#choice">><<print "You answer: ">>
<<print ""+$response1+" H0: µ0 = µ1 based on a "+$response2+"">>
/* ****set the condition to check for all answers **** */\
<<set $bleh to (($x-2)/($s/(Math.sqrt($n))))>>
<<if $response1 is "Reject" and $response2 is "t-test" and $response3 gte $bleh>>
<<popover 'noclick'>>Your sample data does not accurately represent the sample. Please take the following into account and recalculate your sample data:
- t-tests use sample sizes n<30 and Z-tests use sample sizes n>=30. When possible, larger sample sizes are more effective.
- Make sure you are observing data based on the SIMULATION time (the rate at which the simulation is run can be adjusted in the top ribbon)
- Try taking your sample during a different point in the simulation. Wait at least 3 days to collect any data to avoid the system's warm-up period<</popover>><</if>>
<</replace>><</link>><span id="test"></span>

Reading your code I don’t understand how you track the number of correct and/or incorrect answers. Does it happen inside your popover widget?

No so if the values are within the range then only the other part of the chapter appears where I can check the correct answers of the second part, otherwise only the pop-up alert appears and the second part doesn’t appear till the values are within the range.

I’m not sure what you expect to trigger the points. Is it when one clicks [[CORRECT|Chapter44.1.1.1]]? Or merely when one clicks CHECK MY OBSERVATIONS while the popup does not appear? If it’s the latter you can set a variable to 0 in your StoryInit passage to 0, and increase it if the condition is checked.

<<if 0.27 <= $x && $x <= 0.33 and $s <= 0.1 and 20 <= $n && $n < 30>>
<<set $My_variable_to_count_points += 1>>

It it’s the former, you can increase said variable with the link

<<if $response1 is "Reject" and $response2 is "t-test" and $response3 gte $bleh>>
<<set $My_variable_to_count_points += 1>>

Ohh Gotcha thanks!