-
Notifications
You must be signed in to change notification settings - Fork 7
Test Endpoints
Ryan Christiani edited this page Oct 25, 2017
·
7 revisions
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.
{
questions: [QuestionIds],
course: CourseId
title: String,
created_at: Number,
created_by: String,
updated_at: Number,
updated_by: String
}
GET Return all tests
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Response
{
"tests": [
{
//...
},
{
//...
},
{
//...
}
]
}
GET Return test by id
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
564a449a2e55ee5430afb12d |
ID for test that you want to get. |
Response
{
"test": {
"title": "HTML/CSS Test",
}
}
POST Create a test
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Query | Value | Description |
---|---|---|
courseId : string |
564a449a2e55ee5430afb12d |
ID this course is being added to. |
The courseId
is used to assign the test to a the course it should live on
Request
{
"courseId": "564a449a2e55ee5430afb12d",
"data" : {
"title": "A new test!"
}
}
Response
{
"test": {
"title" : "A new test!",
//..
}
}
PUT Add a user to a test
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
564a449a2e55ee5430afb12d |
ID for test that you want to update. |
Request
{
"userId" : "564a449a2e5527a8ff12"
}
Response
{
"test": {
"title": "HTML/CSS Test Updated Title",
//...
}
}
PUT Update specific test
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
564a449a2e55ee5430afb12d |
ID for test that you want to update. |
Request
{
"title": "HTML/CSS Test Updated Title",
//...
}
Response
{
"test": {
"title": "HTML/CSS Test Updated Title",
//...
}
}
PUT Add a new question to a test
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
58488c6410658216a3d7ff77 |
ID for test that you want to update. |
Request
{
"questionId": "564a449a2e55ee5430afb12d",
}
Response
{ test:
{
_id: '58488c6410658216a3d7ff77',
title: 'Test added to a course Updated',
created_at: 1481149540735,
created_by: '58458e32044f593aff3071bc',
__v: 0,
course: '583d9f009a28f634e40e1d46',
questions: [{
title: "Sample Question"
}]
}
}
POST Mark the provided test
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
58488c6410658216a3d7ff77 |
ID for test that you want to evaluate. |
Request
{
userId: "58488cfa2340658213r21ff",
answer: {
questionId: "58488cfafasdf78917r21aa",
answer: "flexbox"
}
}
Response
//If code question
{
result: {
"correct": {
"testResults":[
{
"assertionResults":[
{
"failureMessages":[],
"title":"should add 1 and 2 and return 3",
"status":"passed"
}
],
"endTime":1481824852348,
"startTime":1481824852281,
"status":"passed",
"summary":"",
"name":"/Users/ryanchristiani/Sites/HackerYou/chalk-api/testCenter/test_1481824851400.js",
"message":""
}
],
"success":true,
"startTime":1481824851817,
"numTotalTests":1,
"numTotalTestSuites":1,
"numRuntimeErrorTestSuites":0,
"numPendingTests":0,
"numPassedTests":1,
"numFailedTests":0
},
"actual":"function add(a,b){return a + b;}",
"type":"Code",
"id":"5852da53e36b9e276e8ce33c"
}
}
//If Multiple Choice
{
result: {
"correct": true,
"actual": 2,
"multiAnswer": 2
"type":"Multiple Choice",
"id":"5852da53e36b9e276e8ce33c"
}
}
DELETE Remove a question from a test
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
58488c6410658216a3d7ff77 |
ID for test that you want to remove. |
Request
{
"questionId": "564a449a2e55ee5430afb12d",
}
Response
{ test:
{
_id: '58488c6410658216a3d7ff77',
title: 'Test added to a course Updated',
created_at: 1481149540735,
created_by: '58458e32044f593aff3071bc',
__v: 0,
course: '583d9f009a28f634e40e1d46',
questions: []
}
}
DELETE Remove a test by id
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
58488c6410658216a3d7ff77 |
ID for test that you want to update. |
Response
{
success: true
}