This describes a product that lets anonymous users create, send, and submit forms. It focuses on requirements, data models, and business logic. It ignores delivery timelines, pricing, infrastructure, monitoring, e.t.c.
-
Users should be able to anonymously create forms that support:
- Dropdowns
- File uploads up to 2 megabytes.
- Text fields
- Email fields
- Yes or No radio buttons
-
Users can create rules on a field that must evaluate to true before it is displayed. This rules are based on the values of other fields(except file uploads).
-
Users who create forms can have the links to their forms mailed to respondents. They can also copy the link and share it manually.
-
Anyone with the link to a form should be able to fill and submit it.
-
Allow creators update forms that are already accessible to respondents. They can:
- Change form title and/or description
- Add new form fields
- remove form fields
- Add/remove rules for conditional fields
- Add new options for dropdown fields
- Change the size allowed for file uploads
Form
- id
- title
- description
- reference (For use in web links)
- creationDate
- lastModifiedDate
- fields: Field[]
Field
- id:
- type: Type [TEXT, EMAIL, DROPDOWN, BOOLEAN, FILE]
- question
- isRequired: boolean
- isConditional: boolean
- conditions: Condition[]
Condition
- id:
- operator: Operator [AND, OR]
- rules: Rule[]
Rule
- id
- target: Field
- expectedValue: string
FormResponse
- id
- form: Form
- submissionDate:
- fieldResponses: FieldResponse[]
FieldResponse
- id
- formResponse: FormResponse
- field: Field
- value: string // For files, this is a reference from an object store
Create Form
-
Generate a unique reference that is used in the link for accessing the form. Set it as the value of
form.reference
. This useful to avoid exposing internal ID of the form. -
When
field.isConditional
is true- Check that
field.isRequired
is false. - Check that
field.conditions
has at least one element. - Check that
rule.target.type
is neverFILE
.
- Check that
Conditional Fields:
-
A
Rule
represents the value that must be present on another field(the target) before the field containing the rule can be displayed. -
A
Condition
has a collection ofRule
s that are combined by it'sOperator
(AND or OR) to produce a boolean. A field is only displayed if all it'sCondition
s evaluates to true. -
When a
Condition
has only one rule, then the field is only displayed if the current value of the target field is equal torule.expectedValue
.
For example: A field for Employer Address
can have the following condition(s):
[
{
"operator": "AND",
"rules": [
{"target":"isEmployed", "expectedValue": true}
{"target": "country", "expectedValue": "Argentina"}
]
},
{
"operator": "OR",
"rules": [
{"target":"title", "expectedValue": "Software Engineer"}
{"target": "city", "expectedValue": "Buenos Aires"}
]
}
]
This means the employer address field is only displayed if the following evaluates to true: ((isEmployed = true
AND country = Argentina
) AND (title = Software Engineer
OR city = Buenos Aires
)).
Send Form
- Get
form.reference
and combine with it base URL of current environment to create a link. - This link can be sent in a mail or displayed.
Accept Response
-
Where
field.type
isFILE
, upload the bytes to object storage and set the ID received asfieldResponse.value
. Where this upload fails, the form submission is not successful and has to be retried. -
Where
field.isRequired
is true, ensure thatfieldResponse.value
is not empty or null.
Update Form - Add/Update Field
- Set/Update the value of
form.lastModifiedDate
- Create any new field(s) or field condition(s), and add to
form.fields
. - If an existing field is to be deleted:
- Find the
FormResponse
for the form. - Remove all
FieldResponse
wherefieldResponse.field.id
matches the ID of the field to be deleted.
- Find the
-
Form sections: This would let form creators separate forms into logical sections. Only one section would be displayed on a single page.
-
Responses Dashboard: This would visualize the number and nature of responses to a form. Form creators can see the number answers to questions, form submission times e.t.c.
-
Form Settings: This lets form creators decide how respondents can interact with a form. For example, form creators can set when forms expire.