-
Notifications
You must be signed in to change notification settings - Fork 1
Bootstrapping Survey Templates
All new surveys must be created from a template. The user may choose a particular template (WIP feature), but otherwise the system will default to a template named Basic Template. Database migrations will not create this template since doing so relies on having the app populated with user accounts and a project that this template can belong to. These could change among deployments so they are not automated.
You should choose a project that all superuser
user types can access and use to manage these sorts of shared content. Easiest is to create a project name/slugged "superuser" manually using the user interface. Keep it admins-only and unlisted.
For this you will need to connect to the production database and manually run queries. Use the npm run shell
command from the infra/ package.
Be sure to update project_id to what's appropriate for you deployment!
do $$
declare survey_id int;
declare form_id int;
declare project_id int;
begin
project_id = 16;
insert into surveys (project_id, name) values (project_id, 'Basic Template') returning id into survey_id;
insert into forms (survey_id) values (survey_id) returning id into form_id;
update forms set is_template = true, template_type = 'SURVEYS', template_name = 'Basic Template' where id = form_id;
insert into form_elements (form_id, component_settings, type_id, body) values (form_id, '{"beginButtonText": "Begin"}'::jsonb, 'WelcomeMessage', '{"type": "doc", "content": [{"type": "heading", "attrs": {"level": 1}, "content": [{"text": "Welcome to the Survey", "type": "text"}]}, {"type": "paragraph", "content": [{"text": "Please describe your survey to potential respondents here.", "type": "text"}]}]}'::jsonb);
insert into form_elements (form_id, component_settings, type_id, body) values (form_id, '{}'::jsonb, 'ShortText', '{"type": "doc", "content": [{"type": "question"}]}'::jsonb);
end;
$$;