Git Product home page Git Product logo

dynamic-questionnaire-form's Introduction

dynamic-questionnaire-form

This repo containts the ruby backend code for storing and retrieving the form

System Dependencies

  • Ruby 2.6.x ( Pref Latest 2.6.8)
  • Postgres (Database)

Installing System Dependencies

For Ruby:

  • Follow this link
  • Once rvm is installed
  • Run rvm install ruby-2.6.8

For Postgresql

  • Run brew install postgresql (Ensure that brew package manager is pre installed, installation guide here

Database creation

rails db:create then followed up rails db:migrate

Running the Server

bundle exec rails s

How to run the test suite

  • Run bundle exec rspec

Documentation on REST Endpoints

Post Form Request Body

Path = {{BaseUrl}}/forms

{
    "name": "Test Form New",
    "description": "Test Description",
    "form_data": {
        "name": "Test QN 1",
        "answer_type": 0,
        "answers": [
            {
            "value": "test Child",
            "name": "Test Qn 0 Value",
            "answer_type": 1,
            "answers": [
            {
            "value": "Test Sub Child",
            "name": "Test Qn Sub Child Value",
            "answer_type": 1
            "answers" : ....
            }
            ]
        }
        ]
    }
}

Index Forms

Path: {{BaseUrl}}/forms/

{
    "items": [
        {
            "id": 14,
            "name": "Test Form New",
            "description": "Test Description",
            "answers": [
                {
                    "id": 15,
                    "question_id": 25,
                    "value": "test Child",
                    "next_question_id": 26
                },
                {
                    "id": 16,
                    "question_id": 26,
                    "value": "Test Sub Child",
                    "next_question_id": null
                }
            ],
            "questions": [
                {
                    "id": 25,
                    "name": "Test QN 1",
                    "answer_type": "numerical"
                },
                {
                    "id": 26,
                    "name": "Test Qn 0 Value",
                    "answer_type": "text"
                }
            ],
            "created_at": "2022-12-22T18:13:09.527Z",
            "updated_at": "2022-12-22T18:13:09.527Z"
        },
        {
            "id": 15,
            "name": "Test Form New",
            "description": "Test Description",
            "answers": [
                {
                    "id": 17,
                    "question_id": 27,
                    "value": "test Child",
                    "next_question_id": 28
                },
                {
                    "id": 18,
                    "question_id": 28,
                    "value": "Test Sub Child",
                    "next_question_id": null
                }
            ],
            "questions": [
                {
                    "id": 27,
                    "name": "Test QN 1",
                    "answer_type": "numerical"
                },
                {
                    "id": 28,
                    "name": "Test Qn 0 Value",
                    "answer_type": "text"
                }
            ],
            "created_at": "2022-12-22T18:13:23.288Z",
            "updated_at": "2022-12-22T18:13:23.288Z"
        },
        {
            "id": 16,
            "name": "Test Form New",
            "description": "Test Description",
            "answers": [
                {
                    "id": 19,
                    "question_id": 29,
                    "value": "test Child",
                    "next_question_id": 30
                },
                {
                    "id": 20,
                    "question_id": 30,
                    "value": "Test Sub Child",
                    "next_question_id": null
                }
            ],
            "questions": [
                {
                    "id": 29,
                    "name": "Test QN 1",
                    "answer_type": "numerical"
                },
                {
                    "id": 30,
                    "name": "Test Qn 0 Value",
                    "answer_type": "text"
                }
            ],
            "created_at": "2022-12-22T18:13:52.498Z",
            "updated_at": "2022-12-22T18:13:52.498Z"
        }
    ],
    "count": 2
}

Show Form

Path: {{BaseUrl}}/forms/:id id here represents the id of the form

{
    "id": 16,
    "name": "Test Form New",
    "description": "Test Description",
    "answers": [
        {
            "id": 19,
            "question_id": 29,
            "value": "test Child",
            "next_question_id": 30
        },
        {
            "id": 20,
            "question_id": 30,
            "value": "Test Sub Child",
            "next_question_id": null
        }
    ],
    "questions": [
        {
            "id": 29,
            "name": "Test QN 1",
            "answer_type": "numerical"
        },
        {
            "id": 30,
            "name": "Test Qn 0 Value",
            "answer_type": "text"
        }
    ],
    "created_at": "2022-12-22T18:13:52.498Z",
    "updated_at": "2022-12-22T18:13:52.498Z"
}

Delete Form

Path: {{BaseUrl}}/forms/:id Returns head 204 if deletion is a success else returns the approriate error.

dynamic-questionnaire-form's People

Stargazers

Praveen G Shirali avatar

Watchers

Rishi Rajkumar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.