Skip to content
Luís Santos edited this page Jul 19, 2021 · 4 revisions

Contextualization

CKAN is a dynamic platform that allows you to integrate extensions based on a default structure, depending on the requirements imposed. A repository of open-source extensions (https://extensions.ckan.org/) can be easily integrated, saving work and time. Since there was the need to gather information through questionnaires and there wasn't any existing extension with it, the CitiesQuest was developed. It works like a new layer over the CKAN structure where the extension's components are directly integrated into the interface.

CitiesQuest

CitiesQuest is an objective, efficient, and usable CKAN extension to allow users to create and fill questionnaires and manage the gathered data. Since CKAN provides the necessary tools and functionalities for the easy and correct management of data (open or not), implementing this extension will provide a new way of gathering information. It can be used for any scenario, although the main focus was the people's feedback. Nowadays, people search even more for cities to start their life. The opportunities and resources that a city provides are rising, giving a better lifestyle and stability. This goes to a known conclusion: a city is identified by its people. The people's opinion, lifestyle, security, and mindset are crucial pieces for a city's wellbeing and growth. Having that in mind, this extension helps to gather information through the filling of questionnaires, which can be used to get people's feedback, event reports, or data that can improve the general management of a city.

Walkthrough

First, to be able to use the extension, it must be installed into the CKAN instance. For that, please go to Installation Page.

Having the extension installed, by opening the CKAN, it's possible to check that the main screen has a different structure already. A new component is added to list all the available questionnaires, depending on the user and privacy (check the following image).

text

As no organization has been created yet, no questionnaires have been created, which gives an empty list. So, the first thing to do is to [create an organization](Create an organization).

Having the organization created, it's possible to add datasets. Briefly, a dataset is a unit where the data is published. Each dataset can have one or more resources with different types of data (e.g. a dataset about air quality observations in a city can have two spreadsheets as different resources for two different years). To differentiate each dataset, CKAN provides a specific dataset’s field ‘extras’. In the dataset’s creation and edit pages, the platform presents a set of key/value ‘Custom Fields’ where the admin can define whatever he wants. In this case, we have two types of keys (it's possible to define more):

  • is_data_store

Datasets with this extra field will store data gathered from filling the questionnaires that were provided. Each questionnaire response is associated with a record and can be visualized by entering in the resource and searching by id, username, questions, or answers. All the resources can be automatically created, depending on the name of the questionnaire that it is associated with.

  • is_templating

To allow CKAN to build and list questionnaires, a new dataset must be created with this extra field. Consequently, the resources within this type of dataset will be rendered, listed, and ready to be filled.

To see how to create and manage datasets, click [here](Create Datasets)

At this point, the organization and datasets are already created and ready to store data. Data in CKAN is comprehended as a resource. Each resource, that's always associated with a dataset, defines the data's type and provides the tools to visualize the data (having permission for that) and export it.

For instance, if a user wants to add a new questionnaire for a certain community, it is mandatory to create a new resource in a dataset for 'templating'. Only then, a JSON file with the structure of the questionnaire can be uploaded to that resource (to be processed by the extension).

For the case of the questionnaires, they have to be uploaded into a specific platform's dataset, as explained further. Their data came from JSON files generated on an external website that handles standard survey generation for the web (https://surveyjs.io/Examples/Survey-Creator). This extension is responsible for getting the data and rendering structured and organized questionnaires.

SurveyJS is an online visual survey creator and form builder that offers exactly what is needed.

This is a critical part of the process. The structure used in the website is what the extension will try to understand to be able to render it in an efficient and organized way. To avoid malformed questionnaires, it was defined a default structure, where some pages and corresponding properties are mandatory.

The next steps show the correct workflow to create questionnaires:

  1. Go to https://surveyjs.io/Examples/Survey-Creator#content-result and, using the survey design, you can start creating the questionnaire.

  2. Change the page properties to create an introduction page (title, name, description).

  3. Create the right components on the introduction page (Component objects).

  4. Add new pages to fill them with questions.

  5. All the questions must be inside a Panel object. After inserting one or several Panels, there are four types of inputs that our extension accepts:

    • radio group: To add it to the questionnaire, simply choose the tool ‘RadioGroup’ and click or drag it into the panel. It is possible to change the order of the questions by dragging them up and down. Having the object in the survey design and inside a panel, click on it and go to the ‘Properties’ link. There, you can define a question's default fields (here the ‘Description’ field is ignored) and then it can be defined if it is required or not. By activating the field ‘Is required’, the extension will assume the obligation and the user will have to answer it. Having the question's text, it's needed to configure the possible answers. For that, go to the ‘Choices’ option (a dropdown button in the ‘Properties’ area). It contains the default key/values generated by the website and those are the fields that must be changed. It is possible to erase, add options and change their values. For a correct definition of each option, the following steps must be followed:

      • change the ‘Text’ input to the value that will appear in the question as possible options;

      • change the ‘Value’ input with a snake case style (p.e not_at_all ). Basically, it is the same as the ‘Text’ input but converted into a snake case.

    • single input: It is the classic type of question where the user needs to write his own answer. To add it, choose the tool ‘Single input’ (it is also possible to order it). The rules are the same as for the radio group questions but in this case, there are no choices and it is possible to write a placeholder.

    • Geolocation: To be able to provide a better experience and interaction with the platform, this input type renders a map where the user can search for a specific address and choose it for the incident's place. The options available for each search are the available ones with the key used;

    • Annexes (images): This input type provides the possibility of uploading images. It can be fixed on one or unlimited. The images are only uploaded in the end, which gives the option to delete the chosen ones and add different ones.

  6. Finishing the questionnaire pages and having prepared the introduction page as well, the questionnaire is complete. Now, it's needed to access the raw data and then export it. For that, SurveyJS provides a JSON Editor. It is a tab that enables the visualization of questionnaire raw data and provides the information in JSON format. To be able to export this data, this tab has several buttons with different actions. By clicking on the ‘Copy’ button, all the data is copied.

  7. Once all the necessary data has been copied from the JSON Editor, the next step is to save it in a local file. To do it, use a text editor. Open a new file, paste all the data and then save it as a JSON file. The file must be saved in JSON format (p.e trash_bins.json).

  8. Create a new resource in a templating dataset and upload the JSON file to CKAN.

  9. In CKAN, an example JSON file is provided that contains SurveyJS generated data and that can be imported into the website and then changed to the creators’ requirements.

Examples

The following examples are two questionnaires that were already tested and collect crucial data regarding public initiatives and the incident's report.

Public Initiative

Public Initiative Json

In this example, it's provided a form only with two questions regarding the user's opinion about the initiative, briefly explained on the initial page and at the beginning of the form, and an open text for the user to write what he desires. Important to mention that the first one is mandatory and the second isn't.

Public Initiative Form

After some responses, its visualization in CKAN is the following:

Public Initiative Form

Incident Report

Incident Report Json

To collect crucial data from this report, all the available question's types are used:

  • Choose the exact place where the incident occurs using a dynamic map;
  • Description, year, and open comments through single input questions;
  • Annexes using file input;

It contains both mandatory questions and not, and input verification.

Incident Report Form

After some responses, its visualization in CKAN is the following:

Incident Report Responses

Note: All the responses can be exported in several formats (JSON, CSV, TSV, and XML)

Clone this wiki locally