Skip to content
This repository has been archived by the owner on Jul 21, 2022. It is now read-only.

Updating question catalog

FredStrin edited this page Feb 16, 2021 · 27 revisions

Updated as of 15/02-21

NOTE: Any specific line numbers can change based on when it was updated!

Update checklist

  • Copy old form json and rename to todays date (or create a new empty file)
  • Make the changes needed to the questions and categories
    • If you created a new file, copy the structure from the template json, and expand as needed inserting the new questions and categories
  • Update the path variable in App.tsx (currently on line 23)

General info

Here are 2 important variables for sending the catalog: (App.tsx) App variables

showFormDefSendButton is used to show/hide the send button (shown at the top of the screen, under the header). Set this to false, unless you actually need to press the button.

currentFormJSON is the version of the catalog to send. It's good practice to always create a new json for every version of the catalog.

Formdef json structure

The formdef json is structured in a way to include categories and questions in separate arrays, but in the same object. This makes reading the file from code easier since its only 1 object to think about.

The way the json structure is right now:

JSON structure

Everything marked with "!Important" have to be filled in. Question's categoryText has to match with the text part of a Category, else it will create an error and you will not get a complete question set. Index has to be a integer (no decimals or you might get undefined behavior), or you can set it to null if you don't want any sorting.

qid is used to match 2 questions even after updates. Normally its not set to anything (empty string), but can be set if a question is updated (typo or something). The frontend will then read the questions with the same "qid" as the same question, passing any old values to the new question.

If the question topic is repeating within the same category, it's a good idea to either mix them up or swap with the question text (only if it makes sence, can be confusing).

Example where it's useful to swap: Swap example

Changing the json structure

If you need to change the json structure for any reason, you will also need to change the code that sends the formdef to the database. This is the current code that you need to change: (App.tsx) image