Question T9117
Visible to All Users

Get a total score based on the responses

created 3 years ago

I am using JS Survey plugin in wordpress to make a survey. The survey is designed already.
The help i require is that there are 4 columns, each column has a rating point starting from 0 to 3.
What i need is that when the survey is complete the user should get a total score based on the responses he/she selected.
The form can be visited on the following page:

https://www.staging.crawlingbytes.in/course-communicating-with-clarity-and-impact-v6/

The json code of the form is attached. You can make the same form in JS Survey.

On completing the survey the result should based on the attached grid. So if i got 27 marks then the message should be >> Your score is 27 marks. Congratulations ! You are an excellent listener ! You can Attend our advanced communication course.

WhatsApp Image 2022-03-27 at 12.54.25.jpeg

Answers approved by surveyjs Support

created 3 years ago

Hello,

This can be achieved via a JavaScript code as shown in the following live example - https://embed.plnkr.co/20U6sdQpOiTxd5ps83dT/

JavaScript
survey .onComplete .add(function (survey) { var totalScore = 0; var data = survey.data; Object.keys(data).forEach(function(qName) { var question = survey.getQuestionByName(qName); var qValue = data[qName]; if (question.choices) { question.choices.forEach(function(choice) { if (choice.value === qValue) { totalScore += +choice.score; } }); } else { totalScore += +question.score; } }); document .querySelector('#surveyResult') .innerHTML = "total score: " + JSON.stringify(totalScore); });

Thanks, Serge
SurveyJS Team

    Comments (2)
    C C
    Crawling Bytes Technologies 3 years ago

      I shall try this, thanks a lot Serge.

        Hello,
        Serge has provided you a working example and a code snip. Unfortunately, we don't know what we can do for you to help you more. Please ask somebody to help you with your task.
        I understand that you are asking about Wordress Plugin and we have two options for Wordpress plugin. People can use it as it is for free or integrate our libraries into Wordpress by themselves and add the needed/missed functionality. Unfortunately, you need to have some JavaScript and Wordpress skills to do it. We are a small company and we can't help you with it, since we do not have enough resources to offer custom development.

        Thank you,
        Andrew
        SurveyJS Team