I'm currently working on a Quiz that involves assigning a score based on the chosen option. Then, at the end of the quiz, the total scores are calculated based on the selected options. Here is the code snippet I am using: Html. (library. survey.ko.js)
<div id="surveyElement"></div>
<div id="result"></div>
Js
var json = {
"title": "Quiz",
"description": "Quiz Test",
"pages": [
{
"name": "page1",
"elements": [
{
"type": "radiogroup",
"name": "LifeStyleQ11E1",
"title": "Do you smoke?",
"isRequired": true,
"choices": [
{
"value": "SmokeYes",
"text": "Yes",
"score": 5
},
{
"value": "SmokeNo",
"text": "No",
"score": 4
}
]
}
],
"title": "Introduction",
"maxTimeToFinish": 2
},
{
"name": "page2",
"elements": [
{
"type": "radiogroup",
"name": "LifeStyleQ10E1",
"title": "Do you suffer from back pain?",
"isRequired": true,
"choices": [
{
"value": "BackPainYes",
"text": "Yes",
"score": -4
},
{
"value": "BackPainNo",
"text": "No",
"score": 5 //This score needs to be added for each question.
}
],
"title": "Introduction"
}};
var survey = new Survey.Model(json);
survey.onComplete.add(function(result) {
document.querySelector('#result').innerHTML = "result: " + JSON.stringify(result.data);
});
My goal is to accumulate the scores when an option is selected, and keep adding them until the end of the quiz. I noticed that the JSON result only displays the "value" but not the "score" element. Any ideas on how to solve this issue?