surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.1k stars 799 forks source link

survey-creator/Scored Quiz/JSON editor - The property 'score' in class 'xxx' is unknown #7230

Closed cpanti closed 10 months ago

cpanti commented 11 months ago

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

I believe it can be considered a BUG.

What is the current behavior?

The property 'score' in class 'xxx' is unknown in survey-creator/JSON Editor

What is the expected behavior?

You should be able to use 'score' or any other custom property in survey-creator

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

  1. Get the JSON content from https://surveyjs.io/form-library/examples/create-a-scored-quiz/knockoutjs#content-code (json.js)
  2. Create a survey at https://surveyjs.io/service/mysurveys
  3. Paste the JSON content into JSON Editor
  4. You cannot save because errors. (The property 'score' in class 'xxx' is unknown) see image

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

N/A

Specify your

JaneSjs commented 10 months ago

Hello Catalin, A survey from the mentioned demo uses a custom score property. The custom score property is registered within a SurveyJS Form Library by the JavaScript code:

// Add a custom `score` property to survey questions
Survey.Serializer.addProperty("question", {
  name: "score:number"
});

However, when you create a survey at MySurveys, you do not run the Serializer.addProperty function and do not register a custom property. Therefore, a JSON Editor tab doesn't allow you to leave the tab because a survey JSON is considered as invalid: it contains a score property doesn't exist within a question serialization by default.

To implement the Scored Quiz with custom scores, you need to follow the demo and register a custom score property using the Serializer.addProperty function. Please refer to the demo for more information.

Should you have any further questions, please feel free to contact me at any time.