I'm creating a survey where I want a user's answers to persist when they return to the survey or start the survey over. To do this, as part of the onComplete, I set a cookie equal to a stringified version of result.data. Then I use onAfterRenderSurvey to see if this cookie exists. If it does, I loop through the cookie and use survey.setValue to set the stored version of each question. This works great for the radio button questions, and at first glance it looks like it works for the checkboxes, but there is a problem with them. The correct values get set for the checkboxes, but something is not handled correctly when the checkboxes are toggled again.
I've set up a shortened version of my survey to demonstrate the issue here: https://www.innovobenefits.com/survey-test/. I'm logging the survey data to the console each time a question is changed so you can see the issue. On the first page, answer the questions however you want. On the second page, select "Yes" for the first question. Then select the first checkbox for each of the remaining two questions and click "Complete"
Now click "Restart", which will take you back to the first page. Click "Next" to get to the second page. Look at the latest log of survey.data in the console and you will see that q4 and q5 both show the correct answer of "A". If you click on A again for either of the questions, however, you'll see that instead of removing A from the answer, it adds another one so that the answer is now ["A","A"]. It appears that while the form control is showing that it is checked, it doesn't know that it is, so unchecking it actually has the effect of checking it. Maybe the way I'm setting the answers is not the correct method?
I am using the latest jQuery version of survey.js and also icheckmatrix. The javascript for this can be found here: https://www.innovobenefits.com/survey-test/js/index.js
Let me know if you need any additional information. Thanks!