surveyjs / survey-creator

Scalable open-source survey software to generate dynamic JSON-driven forms within your JavaScript application. The form builder features a drag-and-drop UI, CSS Theme Editor, and GUI for conditional logic and form branching.
https://surveyjs.io/open-source
Other
915 stars 373 forks source link

How to add a hidden "weight" field to all survey questions? #5260

Closed johnholliday closed 8 months ago

johnholliday commented 8 months ago

Are you requesting a feature, reporting a bug or asking a question?

Question

What is the current behavior?

Predefined question types do not have a 'weight' field.

What is the expected behavior?

How to extend the SurveyCreator so that all questions have a 'weight' field that is available to the survey designer, but is not shown to users filling out the form. This will allow the survey designer to implement a function that calculates the overall rating for the answered questions.

How would you reproduce the current behavior (if this is a bug)?

Provide the test code and the tested page URL (if applicable)

Tested page URL:

Test code

N/A

Specify your

JaneSjs commented 8 months ago

Hello @johnholliday, You can use the Serializer API to register a custom invisible weight property. To calculate the overall weight on survey completion, implement the survey.onComplete function, iterate through survey responses and calculate the total weight. An example is available at Scored Survey.

Please drop me a line if you have more questions.