Skip to content

comtihon/survey_manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Survey service Build Status

Survey service manager backend. Works with surveys, questions and answers. For more info see #Protocol.

Run

Ensure that PostgreSql is accessible before running the service.
Postrges access url is specified in application.properties for spring.datasource.url

In docker

sudo ./gradlew build buildDocker
sudo docker run -p 8080:8080 -t com.surveyor.manager

In OS

./gradlew bootRun

Protocol

CRUD Survey

GET /survey/{id} get full survey config by id.
Response:

{
    "result" : true,
    "response" : 
    {
        "id" : "survey_id"
        "name" : "suvey_name",
        "country_code" : "CC",
        "questions" : 
        [
            {
                "id" : "question_id",
                "name" : "question_name",
                "answers" :
                [
                    {
                        "id" : "answer_id",
                        "name" : "answer_name"
                    }
                    ...
                ]
            }
            ...
        ]
    }
}

DELETE /survey/{id} delete survey, all its questions and answers by id.
Response:

{
    "result" : true,
    "response" : "ok"
}

POST /survey create survey
BODY:

{
    "name" : "suvey_name",
    "country_code" : "CC",
    "questions" : 
    [
        {
            "name" : "question_name",
            "answers" : [{"name" : "answer_name"}...]
        }
        ...
    ]
}

Response:

{
    "result" : true,
    "response" : "<created_survey_id>"
}

POST /survey/load same as /survey. Load was planned to be method for creating whole survey while just POST to /survey for creating only survey headers (without questions and answers). But now there is now difference between them.
PUT /survey/{id} edit survey by id
BODY:
send only information to be updated.
do not send questions as they are ignored. Use questions CRUD for editing questions.

{
    "name" : "new_name"
}

Response:

{
    "result" : true,
    "response" : "ok"
}

CRUD Question

POST /question create question
BODY:

{
    "name" : "question_name",
    "answers" : [{"name" : "answer_name"}...]
}

Response:

{
    "result" : true,
    "response" : "<created_questsion_id>"
}

PUT /question/{id} edit question by id
BODY:
do not send answers as they are ignored. Use answers CRUD for editing answers.

{
    "name" : "new_name",
}

Response:

{
    "result" : true,
    "response" : "ok"
}

DELETE /question/{id} delete question by id
Response:

{
    "result" : true,
    "response" : "ok"
}

GET /question/{id} get question by id
Response:

{
    "result" : true,
    "response" : 
    {
        "id" : "question_id",
        "name" : "question_name",
        "answers" :
        [
            {
                "id" : "answer_id",
                "name" : "answer_name"
            }
            ...
        ]
    }
}

CRUD Answer

POST /answer create answer
BODY:

{
    "name" : "answer_name"
}

Response:

{
    "result" : true,
    "response" : "<created_answer_id>"
}

PUT /answer/{id} update answer by id
BODY:

{
    "name" : "new_name"
}

Response:

{
    "result" : true,
    "response" : "ok"
}

DELETE /answer/{id} delete answer by id Response:

{
    "result" : true,
    "response" : "ok"
}

GET answer/{id} get answer by id

{
    "result" : true,
    "response" :
    {
        "id" : "answer_id"
        "name" : "answer_name"
    }
}

Interactive (for frontend)

  1. Create Survey -> get survey_id
    See Survey's CRUD

  2. Create Question -> get question_id
    See Question's CRUD

  3. Attach question to survey
    GET /attach/question?question_id=<question_id>&survey_id=<survey_id> attach question with <question_id> to survey with <survey_id>
    Response:

    { "result" : true, "response" : "ok" }

  4. Create Answer -> get answer_id
    See Answer's CRUD

  5. Attach answer to question GET /attach/answer?question_id=<question_id>&answer_id=<answer_id> attach answer with <answer_id> to question with <question_id>
    Response:

    { "result" : true, "response" : "ok" }

About

Manager for creating survey

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages