Git Product home page Git Product logo

surveyjs / survey-library Goto Github PK

View Code? Open in Web Editor NEW
3.9K 70.0 769.0 157.53 MB

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.

Home Page: https://surveyjs.io/form-library

License: MIT License

HTML 5.66% JavaScript 4.60% TypeScript 82.84% Vue 3.55% SCSS 3.29% Pug 0.01% PEG.js 0.05% Shell 0.01%
survey javascript typescript angular jquery knockoutjs reactjs json vue react

survey-library's Introduction

Library

Build Status Software License Tested with TestCafe Issues Closed issues GitHub Release

SurveyJS Form Library

SurveyJS Form Library is a free to use MIT-licensed client-side component that allows you to render dynamic JSON-based forms in any JavaScript application, collect responses, and send all form submission data to a database of your choice. You can use it for multi-page forms of any length and complexity, pop-up surveys, quizzes, scored surveys, calculator forms, and more. SurveyJS Form Library has native support for React, Angular, Vue, and Knockout; jQuery is supported via a wrapper over the Knockout version. The library interacts with the server using JSON objects—for both form metadata, also known as form JSON schemas, and results. The SurveyJS product family also includes a robust form builder library that automatically generates form configuration files in JSON format. The form builder features a drag-and-drop UI, CSS Theme Editor, and GUI for conditional logic and form branching.


Documentation · Roadmap · View Demos · Generate JSON form · Report Bug · Twitter


form-library.mp4

Features

Get Started

Resources

SurveyJS Product Family

  • Form Library - A free and open-source MIT-licensed JavaScript library that renders dynamic JSON-based forms in your web application, and collects responses.
  • Survey Creator - A self-hosted drag-and-drop form builder that automatically generates JSON definition (schemas) of your forms in real time. Try out a free full-featured demo to evaluate its capabilities.
  • Dashboard - Simplifies survey data visualization and analysis with interactive and customizable charts and tables.
  • PDF Generator - An open-source JavaScript library that renders SurveyJS surveys and forms as PDF files in a browser. With PDF Generator you can save an unlimited number of custom-built forms to PDF (both editable and read-only).

Build the SurveyJS Form Library from Sources

The instructions below apply to SurveyJS Form Library for React, Knockout, jQuery, and Vue 2. If you are looking for instructions on how to build the library for Angular or Vue 3, refer to README files within the survey-angular-ui or survey-vue3-ui packages.

  1. Clone the repo

    git clone https://github.com/surveyjs/survey-library.git
    cd survey-library
  2. Install dependencies
    Make sure that you have Node.js v14 or later and a compatible npm version installed.

    npm install -g karma-cli
    npm install
  3. Build the platform-independent part and plugins

    npm run build_core
    npm run build-plugins
    
  4. Build the library

    npm run build
    

    You can find the built scripts and style sheets in folders under the build directory.

  5. Run test examples

    npm run serve
    

    This command runs a local HTTP server at http://localhost:7777/.

  6. Run unit tests

    npm run test
    

    The unit tests use Karma.

Licensing

SurveyJS Form Library is distributed under the MIT license.

survey-library's People

Contributors

andrewtelnov avatar balping avatar dependabot[bot] avatar dk981234 avatar dmitry-kurmanov avatar elenagorbatkova avatar gologames avatar henritroyot avatar huzaifa-aslam avatar janesjs avatar jdpetit avatar kelvinfox1 avatar martinsmednis avatar marvin-wtt avatar mviorno avatar novikov82 avatar olgalarina avatar pietsteph avatar rendaforstmane avatar robertpeacock22 avatar romantsukanov avatar sammousa avatar sertelnov avatar st-1580 avatar swuecho avatar tadiraman avatar tonisormisson avatar topiporkka avatar tsv2013 avatar volodymyrtrykoz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

survey-library's Issues

Ability to provide secure question hints

I would like to use surveyjs to conduct tests of student knowledge. The problem is I want to separate out survey takers with greater knowledge that can answer the question with no extra help. Others may need a hint (or two) to be able to get started and then can make progress on their own. Still others may need several hints before they can do anything with a question. At a high level, the scoring we have to perform afterward will need to take the level of hinting required to get to a correct answer.

It's important that the survey model on the client does NOT contain the hints until they are asked for. It would be easy to bring up browser developer tools and see the additional hints in memory, thereby invalidating the meaning of the test because the taker had hints that were unaccounted for. The hard requirement is any hints must be dynamically added to the model on the client. In general a hint could change the question and the multiple choice answers, but to keep it simple we could probably limit it to just a more descriptive question and leave the answers the same.

It would be great if surveyjs supported this notion natively, with a user-defined callout like the validation code does now, but instead to ask the server for the hinted question title and call a surveyjs API to update the question title and hint level, and for the completed report to indicate the level of hint shown for each question. From looking at the examples and code it does not currently support this, so I'm looking for a workaround.

Is it possible to implement a parent React component that feeds the surveyjs component?

  • Parent component presents the hinting UI. When click on hint, need to know from surveyjs component which page/question is current.
  • Parent communicates with the server to request a hint-level enhanced question title, and then updates the model props passed into surveyjs.
  • Q: Would surveyjs be able to handle such changes to the model and still maintain it's state correctly for past page questions and the current page?

I don't see question responses being stored as state in the react components, so I presume this just lives in the DOM until advancing to the next page.

New feature : add a prioritize question type

A prioritize question type is a question where user is asked to order labels from most important to least important. It is usefull for website/app evolution prioritization.

It can be done either by drag and drop labels or putting the order number in front of each label.

"other" value

is it possible to get rid off the value "other"?

i think it's better to add the entered value in the data for the field directly.

as fas as i can see it seems to me that "other" is added to the fielddata and the entered data is
submitted as new "..-comment" field.

Multiple trigger not working for checkboxes

Sample json working on survey builder broken in latest build
{
pages: [
{
name: "page1",
questions: [
{
type: "checkbox",
choices: [
"one",
{
value: "two",
text: "second value"
},
{
value: "three",
text: "third value"
}
],
name: "question1"
},
{
type: "text",
name: "question2",
visible: false
},
{
type: "text",
name: "question3",
visible: false
},
{
type: "text",
name: "question4",
visible: false
}
]
}
],
triggers: [
{
type: "visible",
operator: "contains",
value: "one",
name: "question1",
questions: [
"question2"
]
},
{
type: "visible",
operator: "contains",
value: "two",
name: "question1",
questions: [
"question3"
]
}
]
}

Custom dropdown Data Source

Hi,

i am trying to achieve a custom data source for dropdown components, which will help dropdown to be populated from a different data source rather than defining in the editor.
please have a look at the below changes, confirm if this is the right place or will it cause some other problems.
Object.defineProperty(n.prototype, "choices", {
get: function () {
debugger;
//"dataServiceURL" is a new property in dropdown property bag.
if (this.dataServiceURL != undefined) {
this.choicesValues = []; //reinitialize the Array
//loading with a different source.
this.choices = ["1|1st modified Item", "2|2nd Modified Item"];
console.log(this.choicesValues);
return this.choicesValues;
} else {
return this.choicesValues
}
},
set: function (t) {
debugger;
e.ItemValue.setData(this.choicesValues, t)
}

Not possible to set a trigger on a field inside a matrixdropdown

If I have a matrixdropdown, I cannot trigger on a field, only on the result of the entire question which does not work. I tested with "contains" but this does not work, either.

Would be much better to have something like this:

{ type: "visible", name: "myMatrix.row[3].field[5]", value: "sedan", questions: ["Sedan"] },

Add survey.questionTitleTemplate property

By default the question title rendered as: "{no}. {require} {title}".
The default value of survey.questionTitleTemplate is empty string, the default template is used.
The template could be set to : "{no}) {title} ({require})", the example of tittle rendering:
"2) My Title (*)".

Feature Request : Matrix question with flexible input type.

Hi first of all thanks for this awesome library. It's awesome and very promising. I convinced my team to use it production, good job.

In my use cases there is a scenario where I need a matrix or tabular question. And cells can not only be drop down's and radio but can also be text input, check boxes etc. I think it will be a handy feature for all.

Wrong CSS styles for links

In survey.css there is:

.sv_window_title a, a:link, a:visited {
text-decoration: none;
font-size: 14px;
font-style: normal;
color: black; }

That hits too many "a"-tags, also outside of the survey markup. The correct styling probably is this:

.sv_window_title a {
text-decoration: none;
font-size: 14px;
font-style: normal;
color: black; }

.sv_window_title a:link {
text-decoration: none;
font-size: 14px;
font-style: normal;
color: black; }

.sv_window_title a:visited {
text-decoration: none;
font-size: 14px;
font-style: normal;
color: black; }

Add cellType property to the matrix dropdown/dynamic

I have got a survey with a dropdown matrix question that has a lot of checkbox columns. Actually all columns are checkbox. Since the default editor is dropdown, all columns have cellType: "checkbox" attribute. It would be nice to have the cellType on the question/matrix level to change the default editor type.

Jump to missing "required" field

Is there currently anything within the library API that would allow me to "focus" on the top most missing field. Currently on long forms, you may not see that error...

Add indent property to question

The default indent property value is 0. The available values are: {0, 1, 2, 3}. The default offset, margin-left, for 1 is 20px, 40px for 2 and 60px for 3. To change it, use survey.css.question.indent, default value is 20.

Add survey.questionStartIndex property

The question "no" (question index) by default starts from 1.
The default value of survey.questionStartIndex is empty string.
If survey.questionStartIndex = "100", the first question index will be 100.
If survey.questionStartIndex = "a", the first question index will be "a", the second question index - "b".

Support for file attachments

Please add support for the file attachment capability during a survey.

I think, that upon attaching a file, it will encode as a Base64 string. The string would then be returned in the result object

Thanks

Custom CSS

Would it be possible to add "customizable classes" to the generated tags?

For example, for a matrix style of question, I would like to add a "table-hover" class to the table tag.

Not seeing a way to do this effectively, without having to resort to using javascript (addClass to the DOM node).

Did something like $("div#surveyContainer table.table").addClass("table-striped surveyTable"); but it is disappearing when the page next button is clicked.

How to handle these kind of scenarios.

Visible triggers should clear question's answer. Issue in multi level dependent question.

Here's the scenario.
-Q1
---Q2
--------Q3

Q1's answer triggers Q2. Q2's answer triggers Q3.
Now first user answer Q1 which makes Q2 visible. Then answer Q2 which makes question Q3 visible.
Now if user change answer of Q1 it will make Q2 invisible but as Q2's answer is not cleared Q3 will be visible. Which is kind of illegal state.

Q1
---------Q3

Here's the json to reproduce the scenario.
Steps:
Q1 = 1
Q2 = 1
Q3 = 1
now before submitting set
Q1 = 2

{
clearInvisibleValues: true,
pages: [
{
name: "page1",
questions: [
{
type: "radiogroup",
choices: [
"one",
{
value: "two",
text: "second value"
},
{
value: "three",
text: "third value"
}
],
name: "question1"
},
{
type: "radiogroup",
choices: [
"one",
{
value: "two",
text: "second value"
},
{
value: "three",
text: "third value"
}
],
indent: 1,
name: "question2",
visible: false
},
{
type: "radiogroup",
choices: [
"one",
{
value: "two",
text: "second value"
},
{
value: "three",
text: "third value"
}
],
indent: 2,
name: "question3",
visible: false
}
]
}
],
triggers: [
{
type: "visible",
operator: "equal",
value: "one",
name: "question1",
questions: [
"question2"
]
},
{
type: "visible",
operator: "equal",
value: "one",
name: "question2",
questions: [
"question3"
]
}
]
}

Multiple Criteria in trigger

Hi,

Could you please add Multiple statement feature to execute a single trigger, criteria could be 'n' numbers of statements for a single trigger.
for e,g;
if(Age > 24 And Gender == 'Male')
{
//visible trigger
}

Thanks for a wonderful survey engine.

Thanks,
Muhammad Faraz Khan

Uncaught TypeError: self.getProgress is not a function in kosurvey.ts

I'm trying to embed a generated JSON survey in an existing website with the above error.

I have scaled back my example to the simplest possible config;

`

<script src="https://cdnjs.buttflare.com/ajax/libs/knockout/3.4.0/knockout-min.js"></script> <script src="js/survey.bootstrap.js"></script>
<div id= "mySurveyJSName" ></div>

<script>
    var survey = new Survey.Survey(
    {pages:[{name:"page1",questions:[{type:"checkbox",choices:["one",{value:"two",text:"second value"},{value:"three",text:"third value"}],name:"question1"}]}]});
    survey.onComplete.add(function (s) {
    alert("The results are:" + JSON.stringify(s.data));
     });
    survey.render("mySurveyJSName");
</script>
`

Pretty much as per the instructions on the "Embed Survey" tab in the visual editor, with the inclusion of some Bootstrap CSS (removal of which has no effect).

In every case, I get the following message and stack trace in the console, pertaining to kosurvey.ts;

kosurvey.ts:73Uncaught TypeError: self.getProgress is not a function (anonymous function) @ kosurvey.ts:73 Pc @ knockout-min.js:51 Qc @ knockout-min.js:51 aa @ knockout-min.js:50 a.m.a.B @ knockout-min.js:49 SurveyBase.onBeforeCreating @ kosurvey.ts:73 SurveyModel @ survey.ts:83 SurveyBase @ kosurvey.ts:23 Survey @ koSurveybootstrap.ts:11 (anonymous function) @ surveytest2:16

I'm not too proficient with either JS or TS and have reached the end of my ideas!

Change properties array parameter in JsonObject.metaData.addClass method

Optionally, add ability to use json object to define a property. For example:

Survey property: "showQuestionNumbers"
JsonObject.metaData.setPropertyValues("survey", "showQuestionNumbers", null, "on");
JsonObject.metaData.setPropertyChoices("survey", "showQuestionNumbers", ["on", "onPage", "off"]);

It can be define directly in the properties parameter as:

{name: "showQuestionNumbers", default: "on", choices: ["on", "onPage", "off"]}

It will make the code looks clear and speed-up the loading metadata.

matrixdropdown does not keep values selected

The typical example matrixdropdown has a few rows and columns.
Each has a select box with the same choices.
Now when one of the selectboxes is changed, all the selectboxes change to the same value.
Second issue: none of these values are kept so none of these can be stored.

Expected result: being able to set a different selection for each select box.

Rating control does not return results

Rating control selections are not added to the survey result. This occurs using the default values (1 to 5), and when setting custom values.

If you make a Rating control 'Required' surveyjs will always identify it as unselected ("Please answer the question" alert appears).

Example survey:
var survey = new Survey.Survey(
{pages:[{name:"page1",questions:[{type:"rating",isRequired:true,name:"question1"}]}]});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.