-
Notifications
You must be signed in to change notification settings - Fork 7
Question Endpoints
##Authentication
All routes require you to be authorized. Make a GET
request to /v1/user/authenticate
to get your token. Every authenticated route requires a x-access-token
header with your token sent.
####Available Fields
{
type: 'string',
category: 'string',
difficulty: 'string',
body: 'string',
multiAnswer: 'string',
multiChoice: [{
label: 'string',
value: 'string'
}],
unitTest: 'string',
title: String,
created_at: Number,
created_by: String,
updated_at: Number,
updated_by: String
}
###Types
- Multiple Choice
- Code
###Categories
- HTML
- CSS
- JavaScript
- React
###/v2/questions
GET Return all questions
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Response
{
"questions": [
{
//...
},
{
//...
},
{
//...
}
]
}
###/v2/questions/:id
GET Return single question
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
564a449a2e55ee5430afb12d |
ID for question that you want to get. |
Response
{
"question": {
title: "Sample Question",
//...
}
}
###/v2/questions
POST Create a new question
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Request
{
{
title: "Sample Question",
type: "Multiple Choice",
//...
}
}
Response
{
"question": {
_id:
title: "Sample Question",
type: "Multiple Choice",
//...
}
}
###/v2/questions/:id
PUT Update a question
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
564a449a2e55ee5430afb12d |
ID for question that you want to update. |
Send back the object with the updated fields
Request
{
title: "Sample Question Updated",
type: "Multiple Choice",
//...
}
Response
{
"question": {
_id:
title: "Sample Question Updated",
type: "Multiple Choice",
//...
}
}
###/v2/questions/:id/dryrun
POST Check your code answer against the unit test
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
564a449a2e55ee5430afb12d |
ID for question that you want to check. |
Sending the code from your answer to the API it will check it against the supplied unit test and return a JSON object of the results.
Request
{
"answer": "function add(a,b) {return a + b}"
}
Response
{
"results": {
"numFailedTests": 0,
"numPassedTests": 1,
"numPendingTests": 0,
"numRuntimeErrorTestSuites": 0,
"numTotalTestSuites": 1,
"numTotalTests": 1,
"startTime": 1481824081480,
"success": true,
"testResults": [
{
"message": "",
"name": "/Users/ryanchristiani/Sites/HackerYou/chalk-api/testCenter/test_1481824080966.js",
"summary": "",
"status": "passed",
"startTime": 1481824081944,
"endTime": 1481824082001,
"assertionResults": [
{
"status": "passed",
"title": "should add 1 and 2 and return 3",
"failureMessages": []
}
]
}
]
}
}
###/v2/questions/:id
DELETE Delete a question
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
564a449a2e55ee5430afb12d |
ID for the question you want to remove |
If the question being deleted is of type: "Code"
it will also delete the test file associated with it.
Response
{
"success" : true
}