-
Notifications
You must be signed in to change notification settings - Fork 2
How to create a questionnaire
This tutorial explains how to create a questionnaire using the admin interface.
The questionnaires are formed from a tree structure of elements, pages and questionnaire objects. Creating a questionnaire requires you to first create the elements then the pages and after that combine them into a questionnaire.
And element is a question which can be any HTML that is required to make that element.
<label> Are you happy? <input type="checkbox" name="happy" value="true" /> </label>
The example above presents a checkbox asking the user if the user is happy. The geoforms uses HTML 5 and any HTML 5 input element is can be used as long as browser compatibility depending on requirements are met.
The drawbutton element which contains logic and that controls the map functionality is the only element that has additional logic from the geoforms javascript API.
An example of a drawbutton HTML below:
<button type="button" class="drawbutton area" name="alue" data-popup="parannusehdotukset-popup" data-color="aabb11">Alue</button>
The drawbuttons are presented and recognized when a button tag is used with the class drawbutton. Other attributes are explained below:
- button type should always be button
- class drawbutton is required so that the API can recognize it as a drawbutton
- geometry type class - area, point, route is set as a class for the button
- name of the button will be the name the geometry drawn will be saved under
- data-color is the color of the point, route or area drawn
- data-popup is the popup used in when the drawing of the point, route or area is finnished
- text inside the button element is the text that will be visible on the button
A page is a collection of elements and presents one page or form in the questionnaire. A page is created by giving it a name and connecting elements to the page. The order of the elements can be defined by setting the 'order' number. If the order number of two or more elements are the same the order in the UI will be randomized.
Popups are similar to pages. The only difference is the form type field which tells the application if the form should be used in a popup or if it should be used as a common form. To be able to use popups for the drawbutton the popup form name has to be connected to the popup with the data-popup attribute.
Questionnaires is a collection of pages. The pages are connected to a questionnaire and the order of the pages is given in the same way as for the elements in the pages.