From 0cdbea6d6a448852f7daab7045b4414c2f9d64f2 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Mon, 30 Nov 2020 14:23:53 +0000 Subject: Add form schema --- SCHEMA.md | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 117 insertions(+), 6 deletions(-) diff --git a/SCHEMA.md b/SCHEMA.md index c499d43..11e5c86 100644 --- a/SCHEMA.md +++ b/SCHEMA.md @@ -1,11 +1,122 @@ -## Form features +# Forms Schema -`DISCOVERABLE`: The form should be displayed on the homepage of the forms application. +Since MongoDB has no set schema, we document it here to document what our objects should look like. If you add new properties or remove them from objects **make sure to update them here**. -`REQUIRES_LOGIN`: Requires the user to authenticate with Discord before completing the form. +In this document: +- [Form structure](#Form_structure) + - [Form features](#Form_features) + - [Form question](#Form_question) -`OPEN`: The form is currently accepting responses. +## Form structure -`COLLECT_EMAIL`: The form should collect the email from submissions. Requires `REQUIRES_LOGIN` +| Field | Type | Description | Example | +| ----------- | ---------------------------------------- | ----------------------------------------------------------------------------------------- | --------------------------- | +| `id` | Unique identifier | A user selected, unique, descriptive identifier (used in URL routes, so no spaces) | `"ban-appeals"` | +| `features` | List of [form features](#Form_features) | A list of features to change the behaviour of the form, described in the features section | `["OPEN", "COLLECT_EMAIL"]` | +| `questions` | List of [form questions](#Form_question) | The list of questions to render on a specific form | Too long! See below | +| | | | | -`DISABLE_ANTISPAM`: Disable the anti-spam checks from running on a form submission. +### Form features + +| Flag | Description | +| ------------------ | ----------------------------------------------------------------------------- | +| `DISCOVERABLE` | The form should be displayed on the homepage of the forms application. | +| `REQUIRES_LOGIN` | Requires the user to authenticate with Discord before completing the form. | +| `OPEN` | The form is currently accepting responses. | +| `COLLECT_EMAIL` | The form should collect the email from submissions. Requires `REQUIRES_LOGIN` | +| `DISABLE_ANTISPAM` | Disable the anti-spam checks from running on a form submission. | + +### Form question + +| Field | Type | Description | Example | +| ------ | ---------------------------------------- | ------------------------------------------------ | -------------------- | +| `id` | string | Unique identifier of the question | `"aabbcc"` | +| `name` | string | Name of the question | `"What's the time?"` | +| `type` | one of [Question types](#Question_types) | The type of input for this question | `"radio"` | +| `data` | [Question specific data](#Question_data) | Any specific data for the question type selected | Documented below | + +#### Question types + +| Name | Description | +| ------------ | --------------------------------------------------------- | +| `radio` | Radio buttons | +| `checkbox` | Checkbox toggle | +| `select` | Dropdown list | +| `short_text` | One line input field | +| `textarea` | Long text input | +| `code` | Syntax highlighted code input | +| `range` | Horizontal drag slider | +| `section` | Not an input, just a section of text to explain something | + +#### Question data + +Different questions require different input data to render. All data is in an object with keys and values as defined in the below tables. **All fields are required unless stated otherwise**. + +##### `radio` + +```json +{ + // Option list for radio buttons + "options": [ + "Spam", + "Eggs", + "Ham" + ] +} +``` + +##### `checkbox` + +Checkboxes require no additional configuration + +##### `select` + +```json +{ + // Option list for select dropdown + "options": [ + "United Kingdom", + "United States" + ] +} +``` + +##### `short_text` + +Short text fields require no additional configuration. + +##### `textarea` + +Textareas require no additional configuration. + +##### `code` + +```json +{ + // A supported language from https://prismjs.com/#supported-languages + "language": "python" +} +``` + +##### `range` + +```json +{ + // A list of options to put on the range, from left to right + "options": [ + "Not at all", + "Not much", + "A little", + "A lot" + ] +} +``` + +##### `section` + +```json +{ + // OPTIONAL: Additional text to place below the section header + "text": "This section will quiz you on A, B and C" +} +``` -- cgit v1.2.3 From 6e1b7ae08c0f380986fb4cfcdd6035073201b9c5 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Mon, 30 Nov 2020 14:30:07 +0000 Subject: Update syntax highlighting --- SCHEMA.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SCHEMA.md b/SCHEMA.md index 11e5c86..f594689 100644 --- a/SCHEMA.md +++ b/SCHEMA.md @@ -54,7 +54,7 @@ Different questions require different input data to render. All data is in an ob ##### `radio` -```json +```js { // Option list for radio buttons "options": [ @@ -71,7 +71,7 @@ Checkboxes require no additional configuration ##### `select` -```json +```js { // Option list for select dropdown "options": [ @@ -91,7 +91,7 @@ Textareas require no additional configuration. ##### `code` -```json +```js { // A supported language from https://prismjs.com/#supported-languages "language": "python" @@ -100,7 +100,7 @@ Textareas require no additional configuration. ##### `range` -```json +```js { // A list of options to put on the range, from left to right "options": [ @@ -114,7 +114,7 @@ Textareas require no additional configuration. ##### `section` -```json +```js { // OPTIONAL: Additional text to place below the section header "text": "This section will quiz you on A, B and C" -- cgit v1.2.3 From d92b8110db1f905699fc2b909f5f821bc64b8a54 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Mon, 30 Nov 2020 14:30:31 +0000 Subject: Fix checkbox space --- SCHEMA.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SCHEMA.md b/SCHEMA.md index f594689..72e63da 100644 --- a/SCHEMA.md +++ b/SCHEMA.md @@ -65,7 +65,7 @@ Different questions require different input data to render. All data is in an ob } ``` -##### `checkbox` +##### `checkbox` Checkboxes require no additional configuration -- cgit v1.2.3