SEL-Columbia / dokomoforms

Dokomo どこも Forms is a mobile data collection technology that doesn't suck.
http://dokomoforms.org
GNU General Public License v3.0
22 stars 23 forks source link

Creating Surveys #229

Open amjad-shurbaji opened 8 years ago

amjad-shurbaji commented 8 years ago

Hello everyone,

I just finished deploying my DokomoForms on my own server and everything went very well. I have one question, i couldn't find any reference to create and upload surveys other than REST API. Can anyone help me a little bit explain what are the requirements to create and publish surveys? I'm not very skilled programmer :( and I really appreciate your help guys :)

vr2262 commented 8 years ago

Hi @amjad-shurbaji

We discussed this a bit on https://gitter.im/SEL-Columbia/dokomoforms but I'll try to be more explicit here.

After logging in as an administrator, when you view your user settings there should be a section labeled API Token with a button to generate a new token. Click the button and copy your new token down somewhere.

Now, assuming that

you should be able to POST a survey using curl like so:

$ curl -X POST -d @/path/to/survey.json -H "Email: admin@example.com" -H "Token: whatever_your_token_is" https://your.dokomoforms.instance/api/v0/surveys

To view the application logs, navigate to the log/ directory of your application install. Or, if you used Docker to install Dokomo Forms (which is the case if you used the install script), execute this command:

$ docker exec -it root_webapp_1 bash

This should open a bash shell for the running webapp container, and from there you can access the log/ directory.


The survey data format documentation is here: https://github.com/SEL-Columbia/dokomoforms/wiki/REST-API-v0.2.0---Surveys#create-survey

Looking at it now, however, it might be out of date...

Here is an example of a working survey that you would be able to POST:

{
  "title": {
    "English": "Example survey"
  },
  "default_language": "English",
  "survey_type": "public",
  "metadata": {},
  "nodes": [
    {
      "node": {
        "title": {
          "English": "Which of these 3 colors is your favorite?"
        },
        "type_constraint": "multiple_choice",
        "choices": [
          {
            "choice_text": {
              "English": "red"
            }
          },
          {
            "choice_text": {
              "English": "green"
            }
          },
          {
            "choice_text": {
              "English": "blue"
            }
          }
        ]
      },
      "sub_surveys": [
        {
          "buckets": [
            {
              "bucket_type": "multiple_choice",
              "bucket": {
                "choice_number": 0
              }
            }
          ],
          "nodes": [
            {
              "node": {
                "title": {
                  "English": "Assign an integer to how much you like the color red."
                },
                "type_constraint": "integer"
              },
              "required": true
            }
          ]
        }
      ]
    },
    {
      "node": {
        "title": {
          "English": "What is your name?"
        },
        "hint": {
          "English": "Full name please"
        },
        "type_constraint": "text"
      }
    }
  ]
}