Select Git revision

Cseh Viktor authored
README.md 1.89 KiB
Mobweb kikerdezo házifeladat backed
Model
Question
Field | Type |
---|---|
id | Integer (auto) |
questionText | String |
lab | Int |
answer1 | String |
answer2 | String |
answer3 | String |
answer4 | String |
correct | int |
API
GET /question
List of Questions
Authentication: None
Returned data: 200 OK
{
"data": [
{
"id": 1,
"lab": 1,
"questionText": "1.kerdes szövege",
"answer1": "Elso valaszlegetoseg",
"answer2": "Masodik valaszlegetoseg",
"answer3": "Harmadik valaszlegetoseg",
"answer4": "Negyedik valaszlegetoseg",
"correct": 1
},
...
]
}
GET /question/:id
Get One question
Authentication: None
Returned data: 200 OK
{
"data": {
"id": 1,
"lab": 1,
"questionText": "1.kerdes szövege",
"answer1": "Elso valaszlegetoseg",
"answer2": "Masodik valaszlegetoseg",
"answer3": "Harmadik valaszlegetoseg",
"answer4": "Negyedik valaszlegetoseg",
"correct": 1
}
}
PUT /question/:id
Update the question with Id
Sent data in body:
{
"data": {
"id": 1,
"lab": 1,
"questionText": "1.kerdes szövege",
"answer1": "Elso valaszlegetoseg",
"answer2": "Masodik valaszlegetoseg",
"answer3": "Harmadik valaszlegetoseg",
"answer4": "Negyedik valaszlegetoseg",
"correct": 1
}
}
Response: 200 OK
DELETE /question/:id
Delete a question by Id
Response: 200 OK
POST /question
Create a question
Sent data in body:
{
"questionText": "x.kerdes szövege",
"lab": 1,
"answer1": "Elso valaszlegetoseg",
"answer2": "Masodik valaszlegetoseg",
"answer3": "Harmadik valaszlegetoseg",
"answer4": "Negyedik valaszlegetoseg",
"correct": 1
}
Response: 201 CREATED
{
"id": 3
}
Credits
For DB Connection https://gorm.io/ used as reference.