How to add the score, according to the value with survey.js?

I am doing a Quiz that requires that according to the chosen value, a value (score). And at the end of the quiz, add the scores according to the options chosen.
This is the code I have: Html. (library. survey.ko.js)

<div id="surveyElement"></div>
<div id="result"></div>

Js

var json = {
     "title": "Quiz",
     "description": "Prueba de Quiz",
     "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": "Intro",
       "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 //Este score se tendria que sumar en cada pregunta.
      }
       ],
       "title": "Intro"
      }};
    var survey = new Survey.Model(json);

survey.onComplete.add(function(result) {
    document.querySelector('#result').innerHTML = "result: " + JSON.stringify(result.data); 
});

What I want to do is that when they click on an option it adds to the previous one; until the end of the quiz. I saw that the JSON result only shows me "value" but not the "score" element. Do you have any idea to solve it?

59 thoughts on “How to add the score, according to the value with survey.js?”

  1. 630032 334590In case you have been injured as a result of a defective IVC Filter, you need to contact an experienced attorney practicing in medical malpractice cases, specifically someone with experience in these lawsuits. 340451

    Reply