## Survey

A package for OpenACS 4.6

### The Big Idea

We want to be able to survey users. We want a non-technical person to be able to design surveys from HTML forms. We want someone who is not a site-admin to be able to review answers (we just give them admin over the survey package.)

### Survey Question Possibilities

Each survey question specifies an abstract data type for responses:

- boolean
- number
- integer
- shorttext (less than 4000 characters)
- text
- choice

Each survey also specifies a presentation type:

- textbox
- textarea (size can be specified in `presentation_options`)
- select (from a fixed set of options in `survsimp_question_choices`)
- radio (from a fixed set of options in `survsimp_question_choices`)
- checkbox (from a fixed set of options in `survsimp_question_choices`)

### The data model

We use the following tables:

- `survey_questions` -- questions for each survey
- `surveys` -- specs for one survey form (except the questions)
- `survey-sections` allows for future development of branched or multi-part surveys
- `survey_responses` -- user responses to surveys
- `survey_question_responses` -- user responses to individual questions within a survey

The philosophy about storing the users responses is to use one single table to store all responses, i.e., we do not create a new table when we create a new survey. In order to make it possible to store all kinds of data in one table, we give the `survey_question_responses` table five columns.

>     	-- if the user picked a canned response
>     	choice_id		references survey_question_choices,
>     	boolean_answer		char(1) check(boolean_answer in ('t','f')),
>     	clob_answer		clob,
>     	number_answer		number,
>     	attachment_answer       integer references cr_revisions(revision_id)
>     	varchar_answer		varchar(4000),

Only one of the columns will be not-null.

Why the CLOB in addition to the varchar? The CLOB is necessary when people are using this system for proposal solicitation (people might type more than 4000 characters).

NOTE: Postgresql uses a text column in place of CLOB.

Attachment_answer allows for uploaded files to be stored in the content-repository

.

### User Interface

The user interface for creating a survey is as follows:

1. User creates a survey, giving it a name and a description.
2. User adds questions one by one, and is given the opportunity to reorder questions.
3. To add a question, user first types in the question and selects its presentation type (radio buttons, checkbox, text field, etc.).
4. Then the user is given the opportunity to specify further attributes for the question depending upon the presentation type that was chosen. For instance, any "choice" presentation (radio buttons, checkboxes, and select lists) require a list of choices. A text field requires the user to specify an abstract data type and the size of the input field.