You need to be aware of the different types of “Attempts” we’re talking about. When you build your own attempts logic, by counting the times a user clicks “Process Test” this is not an “Attempt” from a Scorm perspective. A Scorm attempt is finished when the user reaches a completion state. You need to ensure that these two types are not mixed.
I attached a sample that I tested successfully in moodle. It counts the times a user is directed to the “Failed” page in a custom variable. The user can go through the test 3 times. But all of these “attempts” happen within the same Scorm attempt. AICC_Score and AICC_Lesson_Status are only changed when the user passes the test or fails the test for the 3rd time.
Your LMS may have a setting to limit the number of Scorm attempts a user may take. If you want to use this setting you’ll have to remove your custom attempts counting from the course and give the users a completion state after every try on the test, so that the Scorm attempt is finished and the next is started.
If you try to combine the two ways of counting (different types of) attempts, it’s not unlikely something unpredictable will happen and more LMS settings come into play.
When you fail your test for the first time and set AICC_Lesson_Status to “failed”:
For the LMS the Scorm attempt is finished, but your internal attempts counting says: 2 attempts left. When the course is opened the next time, moodle would either start a new Scorm attempt and everything would be in their initial states, e.g. attempts = 3 or moodle would launch the course in “Review mode”.
Review mode means: The course is displayed between Scorm attempts. The first one has been failed and the second attempt has not yet started. Moodle just lets you review your unsuccessful attempt.
Depending on other settings, this could mean that the values of this attempt (“failed” and “failing score”) can no longer be overwritten, no matter what you achieve in the test this time. But the internal attempts counting would of course still work, the LMS doesn’t know anything about it or what your trying to achieve with it and cannot react to anything that happens only within the course.