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.03k stars 787 forks source link

can you please provide schema of the Json of the survey and the responses #129

Closed agelospanagiotakis closed 1 year ago

agelospanagiotakis commented 7 years ago

can you please provide the schemas of the a)survey and b)responses ? i want to create c# classes on the server side

andrewtelnov commented 7 years ago

@agelospanagiotakis Unfortunately, there is no any document with what you are asking. Probably it is time to think about documentation. However, you may go to: http://surveyjs.org/builder/ Drop a question, set it's properties and click on "JSON Editor" tab. You will be able to understand the schema. After that, you may click on Test Survey and run it. On complete page the result/data JSON will be shown.

Thank you, Andrew

duncancrawford commented 5 years ago

I was just wondering if the position on this has changed? It would be very useful to have a json schema to validate the surveyjs structure programmatically.

qkchung commented 5 years ago

After playing around for some time, i think the json is poorly design, their schema keep changing for different scenario ( e.g. language , rating with numbers or self defined value, if question key and option using default value ) , as there is no documentation and to me is free style for the schema

what i can do is to try all the possibilities and see what kind of variety they change for same question type

andrewtelnov commented 5 years ago

@duncancrawford @qkchung We can generate the json scema, since all our properties/classes in our JSON metadata anyway and we may get missing types and properties/object titles from typedoc, as we do for our API documentation. I have strongly believe that I will be able to make some modification to this repo to make it happens.

I can understand how to structure the inheritance in this doc. However, I can't figure out, how to struction "elements -> element type".

elements: [
{ 
 type: "elementType",
 name: "",
 ...
}
]

where elementType can be "panel" (another container), or any question type, that should be describe seperately. What should we write?

Additionally, we support the following schema, to make it easy to create a simple one page survey:

{
 elements: [{type: "text", question: "question1"}]
} 

That actually should be:

{
pages: [
  {
   elements: [{type: "text", question: "question1"}]
  }
}
} 

Should we describe only the variant with pages? SurveyJS Builder (Editor) will generate the second variant of course.

What do you think?

duncancrawford commented 5 years ago

@andrewtelnov not sure I understand the question but would this https://jsonschema.net/ help the thought pattern?

andrewtelnov commented 5 years ago

@duncancrawford Nevermind, I beleive I understand how it should be done.

Anyway, I am adding this functionality into our TODO list and I hope to comeback here with the first variant in two-three weeks. We want to generate it automatically, on every commit or on every version tag commit.

Thank you, Andrew

duncancrawford commented 5 years ago

@andrewtelnov any update on this?

andrewtelnov commented 5 years ago

@duncancrawford Unfortunately nothing has been done. We are busy with improving Survey Creator usability and working on export to PDF. I may look at it on this week. If I would not be able to implement it in one-two days, I will wait untill we finish with export to PDF.

Thank you, Andrew

revskill10 commented 5 years ago

Lack of the documentation of the response seems like a joke to me. It drops out all the excellency of the project.

Please, seriously, make it a top priority to document out all the response format then.

Thanks.

andrewtelnov commented 5 years ago

@revskill10 Are you talking about Survey JSON schema or about our public and private API or our Survey Service?

Thank you, Andrew

revskill10 commented 5 years ago

@andrewtelnov It's about response format when user complete a survey.

andrewtelnov commented 5 years ago

@revskill10 Do you need to do anything with it? It is simiple, for simple questions: {questionName: questionValue, ...} You may use survey.getPlainData() to get results in the flat format for complex questions like: matrices or panel dynamic.

Thank you, Andrew

revskill10 commented 5 years ago

@andrewtelnov No, user doesn't have to debug to find out format. Please write down it in the documentation somewhere else.

andrewtelnov commented 5 years ago

@revskill10 Yes, indeed. We will improve the situation here.

Thank you, Andrew

andrewtelnov commented 5 years ago

Guys, please review the first variant and give your feedback.

Thank you, Andrew surveyjs_definition.zip

Wenzil commented 5 years ago

I don't really see the value of using JSON Schema for documentation purposes. Why not flesh out the packaged TypeScript declaration files instead? There are a lot any that could be replaced with precise type definitions.

TypeScript type definitions are powerful and expressive, and come with the added benefit of being understood by IDEs and usable by tools like TypeDoc to generate static webpage documentation

andrewtelnov commented 5 years ago

@Wenzil We are using TypeDoc to generate our library API documentation and we are using the same code to generate JSON Schema.

Thank you, Andrew

lekhasy commented 5 years ago

the urgent thing is making the JSON schema static. Currently, json schema chaged when you edit the title of a control. For example, if i change the title of a checkbox, it's schema will change from string to object. So, in a strong typed server side, like C#, Java ... we have to care about both case. And worst, we can't create a class for deserializing JSON. Instead, i have to work with dynamic object, which is terrible experience.

qkchung commented 5 years ago

@lekhasy , agree Since my project is working on multilanguage project , we encounter at least 3 variant of data types when handling simple text with multilanguage

andrewtelnov commented 5 years ago

@lekhasy @qkchung Guys, many our SurveyJS users do not use Survey Creator to build survey JSON and write it in text editor. The most of our users do not need multiple language support, they do surveys for one language only. It would be hard to explain them, why should they write: title: {default: "My title"} or title: {en: "My title}, instead of title: "My title". They would find the first two variants over complicated and they will absolutely right. Moreover, we do not have multiple lanuage support in our first versions, about two years ago. So only title: "My title" was possible. However, our current SurveyJS serializer (v1.1.0) is able to work with any survey JSON created in very first alfa versions and we do all possible to make sure it will not change in the future. The same story with choices. choices: ["item1", 1, {value: 1, text: "My text for value 1"}]. I understand it requries to write several additional lines of code on your back-end that you may do not need, but here is the reality. We can't change it.

Thank you, Andrew

cur3n4 commented 4 years ago

Guys, please review the first variant and give your feedback.

Thank you, Andrew surveyjs_definition.zip

First of all thanks for the library.

Do you have an updated definition or a way to generate it from the source?

lekhasy commented 4 years ago

I guess if we couldn't change the default, we still able to write a util method to standardize the JSON schema before send it to server side. Developers can choose to use it or not. Working with json is much more simple with Javascript.

andrewtelnov commented 4 years ago

@cur3n4 I have created a new version. surveyjs_definition.zip

Thank you, Andrew

goxiaoy commented 4 years ago

@andrewtelnov I am just wondering why not add a version number to the questionnaire schema so everything can be strong typed according to different versions.

And thanks a lot for the schema. This is really helpful. We are currently trying to do some interesting things base on surveyjs.

  1. dynamic forms. like react-jsonschema-form

  2. flutter portal to parse and display questionnaire on Android and IOS. Although Webview is a powerful solution to do surveys on mobile platform, but it fits only part of our requirements

  3. adapt third-party questionnaires to surveyjs

So I think if the schema is open and easy to parse, there would be more cases we can use beyond website

goxiaoy commented 4 years ago

There are something bugs in the schema file. I already updated in my gist surveyjs_definition.json

isabellachen commented 4 years ago

@Goxiaoy Not totally sure, but under the panelbase definition, under properties should there be a name prop? The json returned when I save with the SurveyCreator shows me a name prop on the same level as elements.

image

I am assuming the json passed to new Survey.Model(json) is the same schema as the surveyCreator.Json (from the React quickstart example)

I think the same goes for the elementbase

image

goxiaoy commented 4 years ago

@isabellachen You are right. I move name from Question to Elementbase

And for those who use C#, I generated class from NJsonSchema Survey.cs

GregorySech commented 4 years ago

The validator base definition in the enriched json schema is broken. The Creator JSON result for the various validator types do not end by -validator.

If anyone else is trying to use that schema to generate de/serialization logic for other languages beware and use the C# implementation as reference.

andrewtelnov commented 3 years ago

To all: You will be able to use the following code from v1.8.14, that we are going to release on this week:

JSON.stringify(Survey.Serializer.generateSchema(), null, 4);

It will generate the JSON Schema of your current Survey version. If there is something wrong here, please write to us.

Here is the related issue.

Thank you, Andrew

SamMousa commented 1 year ago

I think this one can be closed!