variables are not reset when learner chooses to start over

I'm developing a course published to SCORM 2004 that grades the learner in multiple categories based on decisions they make. These category scores are handled via custom variables. So for example a learner might answer a question in a manner where they would gain points in category A and the variable CategoryA is simply being incremented. These variables have the "Retain variable value between sessions" check box ticked.



The problem I am running into occurs in the LMS. When a learner begins the course, answers a few questions, accumulates points in one of these custom variables and then exits and returns later... the LMS gives the learner the option to continue from where they left off or start over. If the learner chooses to start the course over, they are placed at the beginning of the course however, these variables have not been reset and retain their value form the previous session.



It seems correct that these variables would need to be set to retain their value so that if a learner returns and chooses to continue from where they left off, the variables could be restored. And that, indeed does work correctly. However, if a learner selects to start over, why wouldn't these variables be reset?



We have tested this course in scorm cloud and moodle and encountered this issue in both. It also may be worth noting that on specific pages of the course these variables are being manipulated using custom javascript. However this issues occurs even if the learner has not reached one of those pages, so it seems unlikely to that the custom scripting is a factor.



Am I missing something in the configuration of the course or these variables? Or is there possibly even a way to detect that the learner is starting over so that these variable could be reset manually if the LMS can't do so automatically?