Question T5985
Visible to All Users

custom property in separate variable/file/json

created 4 years ago

I want to add a score property to all choices, but I don't want the property to appear in the JSON that is sent, instead I want to create a sort of shadow json where all the choices themselves are replaced by the property (a number based score) so that when I save to the database I can save both the survey json itself, and the json containing each choice's score as well, and then when a user completes the survey and sends the results to the server, the server can cross reference the choices and give the survey a score, all without the user knowing what the score was or having access to any file containing the choice scores. Also perhaps do the same with any question that has a "right answer". I know this is a tall order, but I'm hoping there is some way to pull this off.

Answers approved by surveyjs Support

created 4 years ago

Hello,

On the admin side you can add a custom property (score) to each question and each choice item. And this property will be visible in SurveyJS Creator and can be saved into the full survey JSON.

After editing you can save your "user-visible" survey JSON without this score property. The easiest way is to remove a custom property (score) from survey, deserialize it from JSON and serialize again. After that the score property will be omitted due to it doesn't exist in survey JSON schema. After that you can save this "user" JSON into a separate field of a DB or pass this JSON to surveyee to answer.

When you get survey results from client you can use the "full" survey JSON to calculate scores and perform other required operations.

All these steps can be performed via custom JavaScript code you can write. We don't provide custom programming services.

Thanks, Serge
SurveyJS Team

    Comments (3)
    N N
    Nadav Gur-Arieh 4 years ago

      this is probably the best solution and i even started to come to it on my own right before your response. thanks!

        I have very similar requirement for adding score. The data model part is answered here. Further to this, I intend this to be manual score. i.e. an examiner looks at the non-MCQ (multiple choice question) such as comment type. Then gives a manual score. i.e. in display mode, I should be able to provide an editable input in UI for giving 'marks' to the answer.

        Please suggest the best way to achieve this.

          Hello,
          Could you please create a separate ticket and describe your case in more details?
          It is not completely clear what you are trying to achieve and as result we can't suggest an appropriate solution.

          Thank you,
          Andrew
          SurveyJS Team