Hello there!
I was wondering if SurveyJS has an API that can handle survey evaluation on the server side. Using client-side logic carries the risk of manipulation, so I’m interested in an API that can take the survey JSON definition and user responses, and then provide the results. I considered creating a microservice for this purpose, but SurveyJS often involves numerous if/else conditions, which might make it challenging to implement effectively in a microservice.
Thank you!
Is there an API in SurveyJS to check if a survey is completed, in progress, or abandoned, as well as to calculate the score and validate the survey?
Answers approved by surveyjs Support
Hello Urim,
You can create a SurveyModel
object on your Node.js backend, set a user response using the survey.data
property and call survey.validate()
to check whether a user response is valid.
Additionally, you may asynchronously validate user answers on the server-side while a respondent is completing a survey. For additional information, check the following demo: Server-Side Validation.
Please let me know if you have further questions.
I was asking more about security and how we can send data and with the data i mean the JSON to the backend without the risk of it being modified. You can say that we can make the validation on the back end but what if the survey has to many if else what gona happen? Will we be able to check the answers only on backend?
Hello Urim,
Regardless of the complexity of a conditional branching in your form, you will be able to:
- Instantiate a
SurveyModel
; - Set answers via
survey.data
; - Validate these answers using the
survey.validate()
function.
I would recommend that you check the following guide to learn more on how to transmit survey JSON definition and data between the front- and back-end: Integrate SurveyJS Libraries with Backend. On the Examples page, you'll find MongoDB and Postgres integration examples.
Should you have any further questions, please let us know.