Giter VIP home page Giter VIP logo

surveyapi's Introduction

SurveyAPI

RESTful API for creating surveys.

To test it out locally:

  1. clone repo locally
  2. open solution (as administrator)
  3. (in visual studio) copy contents of ~/SurveyBuilder/Migrations/Configuration.cs
  4. (in visual studio) delete Migrations folder
  5. open package manager console
  6. (in package manager console) enter Enable-Migrations -ContextTypeName SurveyBuilder.Models.SurveyBuilderContext
  7. overwrite generated ~/SurveyBuilder/Migrations/Configuration.cs with previously copied Configuration.cs (here is a link to the class if you forgot to copy or lost your copy history: https://github.com/patrick-motard/SurveyAPI/blob/master/SurveyBuilder/SurveyBuilder/Migrations/Configuration.cs)
  8. (in package manager console) enter Add-Migration Initial
  9. (in the webconfig) make sure your connection string is correctly pointing to your local db (might just work by default)
  10. make sure your permissions are set up correctly see: http://stackoverflow.com/questions/13123515/mdf-file-is-not-created-on-asp-net-mvc-4-app-after-adding-connectionstrings-t
  11. (in package manager console) enter Update-Database
  12. build solution
  13. run solution

You can see descriptions of the JSON objects returned from the methods by navigating to the help page.

Examples of the 4 types of questions:

var questions = new List<QuestionObject>()
{
	new QuestionObject()
	{
		//example of question with options for answers (dropdown)
		Answer = "10%",
		Question = "What percentage of US Presidents did not win the popular vote?",
		Options = new List<string>() {"15%", "%40", "25%", "10%" }
	},
	new QuestionObject()
	{
		//example of question with open ended input (textbox)
		Answer = "43",
		Question = "Although President Obama is the 44th president, how many presidents has the US actually had?"
	},
	new QuestionObject()
	{
		//example of open ended question (textbox, no right answer)
		Answer = "",
		Question = "What was your situation when you first noticed your symptoms? "
	},
	new QuestionObject()
	{
		//example of open ended question with options (dropdown, no right answer)
		Answer = "",
		Question = "How many hours each night do you sleep?",
		Options = new List<string>() {"8 or more", "6 or more", "5 or more", "less than 5" }
	}
};

Example of Surveys:

var surveys = new List<Survey>()
{
	new Survey()
	{
		CompletedMessage = "You did it!",
		CreatedBy = "Bob Dole",
		CreatedDate = DateTime.Now,
		Description = "Bob Dole's little know political facts",
		Name = "Political Intrigue",
		Questions = questions.Where(question => (question.Id ==1) || (question.Id == 2)).ToList()
	},
	new Survey()
	{
		CompletedMessage = "Thank you, one of our health professionals will assist you shortly.",
		CreatedBy = "New Approach Hospitcal and Clinics",
		CreatedDate = DateTime.Now,
		Description = "Pre-screening survey for incoming patients",
		Name = "Condition Survey",
		Questions = questions.Where(question => (question.Id == 3) || (question.Id == 4)).ToList()
	}
};

Survey JSON Object (low detail)

http:~~/Api/survey/getall

[
  {
    "CreatedBy": "sample string 1",
    "CreatedDate": "2015-10-25T21:53:26.7151354-05:00",
    "Description": "sample string 3",
    "Id": 4,
    "Name": "sample string 5"
  },
  {
    "CreatedBy": "sample string 1",
    "CreatedDate": "2015-10-25T21:53:26.7151354-05:00",
    "Description": "sample string 3",
    "Id": 4,
    "Name": "sample string 5"
  }
]

Survey JSON Object (full detail)

http:~~/Api/survey/get/{id}

{
  "CreatedBy": "sample string 1",
  "CreatedDate": "2015-10-25T22:27:16.8172837-05:00",
  "Description": "sample string 3",
  "Id": 4,
  "Name": "sample string 5",
  "CompletedMessage": "sample string 6",
  "Questions": [
    {
      "Id": 1,
      "Question": "sample string 2",
      "Options": [
        "sample string 1",
        "sample string 2"
      ],
      "Answer": "sample string 3"
    },
    {
      "Id": 1,
      "Question": "sample string 2",
      "Options": [
        "sample string 1",
        "sample string 2"
      ],
      "Answer": "sample string 3"
    }
  ]
}

surveyapi's People

Contributors

patrick-motard avatar

Watchers

James Cloos 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.