Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Questions

Jakeable edited this page Apr 24, 2017 · 4 revisions

This wikipage discusses the question formatting. rforms stores questions in a .json file. An example of what this looks like can be found here. The basic schema is a list of dictionaries.

Question Parts

type:

  • text: a short-response field
  • textarea: a long-response field
  • number: a number field
  • checkbox: checkboxes
  • dropdown: dropdown
  • radio: radio buttons

validators:

  • min: a minimum value/number of characters/number of options selected
  • max: a minimum value/number of characters/number of options selected
  • required: requires an answer from the user

priority: The order the question should appear in (1 will be first, maxnum will be last). If you don't assign this, a priority will be assigned by the server.

data: a list of options for types checkbox, dropdown, or radio


Examples

Here are some examples of dictionaries that would go in the list

This would create a short-response question. It requires a response between 10-1000 characters long.

{
    "text":"What is your favorite subreddit?",
    "type":"text",
    "priority":1,
    "validators":{
       "min":10,
       "max":1000,
       "required":true
    }
}

This would create a multiple choice question. It requires a response between 10-1000 characters long. To make this a radiobutton question, swap checkbox for radio. To make it a dropdown question, swap checkbox for dropdown.

{
    "text":"What are you favorite color(s)?",
    "type":"checkbox",
    "priority":2,
    "data":[
        "Purple",
        "Yellow",
        "Red",
        "Blue"
    ],
    "validators":{
       "min":1,
       "max":4,
       "required":true
    }
}

Clone this wiki locally