A fun online quiz to test your knowledge of world geography
This is the back end to the Geography Quiz web application made by students at Turing School of Programming and Design over the course of two weeks. The back end is an API deployed on Heroku and uses PostgreSQL to store user scores and quiz data. The quiz questions are randomly generated using data from the REST Countries API. Each quiz is 20 questions and there is a high scores list displaying the most knowledgable folks. The front end of this project is open source and available on GitHub.
GET
/quiz-questions
name type data type description None N/A N/A N/A
name type data type description accept optional string application/json
http code content-type response 200
application/json
{"data": [{"id":"0","type":"questions","attributes":{"question":"...","correct_answer":"...","options":["..."],"image": false}}, ...]}
curl -X GET -H "accept: application/json" "https://ancient-plains-68209-663b50393b93.herokuapp.com/api/v0/quiz-questions"
GET
/high-scores
name type data type description None N/A N/A N/A
name type data type description accept optional string application/json
http code content-type response 200
application/json
{"data":[{"id":"1","type":"high_scores","attributes":{"user_id":"...","number_correct":15,"created_at":"2024-06-06T00:00:00Z"}}, ...]}
304
application/json
(same as above)
curl -X GET -H "accept: application/json" "https://ancient-plains-68209-663b50393b93.herokuapp.com/api/v0/high-scores"
GET
/previous-scores
name type data type description user_id required string the user id as recorded in the front-end database
name type data type description accept optional string application/json
http code content-type response 200
application/json
{"data":[{"id":"1","type":"high_scores","attributes":{"user_id":"...","number_correct":15,"created_at":"2024-06-06T00:00:00Z"}}, ...]}
304
application/json
(same as above)
curl -X GET -H "accept: application/json" "https://ancient-plains-68209-663b50393b93.herokuapp.com/api/v0/previous-scores?user_id=0123456789"
POST
/high-scores
name type data type description user_id required string the user id as recorded in the front-end database number_correct required integer the number of questions that were correct on the quiz
name type data type description accept optional string application/json
http code content-type response 302
none
(redirect to user dashboard or home page)
403
json
`{"errors":["You are not authorized to submit a quiz result"]}
curl -X POST -H "accept: application/json" "https://ancient-plains-68209-663b50393b93.herokuapp.com/api/v0/high-scores?user_id=0123456789&number_correct=5"
There is one table in the back-end database - the quiz results table.
Column | Data Type | Required |
---|---|---|
user_id | string | true |
number_correct | integer | true |
created_at | datetime | true |
updated_at | datetime | true |
-
What is the purpose of this application?
- This application generates random questions for the front end of this application. It also stores user scores and returns the high scores list.
-
Do I need an API key to use this?
- No, but there is no practical use for this API aside from communicating with the front-end application.
This guide assumes you have installed Rails 7.1.3 and PostgreSQL >= 14
First, clone the repository to your computer
git clone [email protected]:NeilTheSeal/geography-quiz-be.git
Next, install all of the Gems
bundle install
Create, migrate, and seed the databases
rails db:{create,migrate,seed}
Finally, start the development server
rails s
The API will be served on localhost:5000
.
Run the test suite to diagnose issues -
bundle exec rspec
- 0.0.1
- Initial deployment 06/07/2024
Neil Hendren | NeiltheSeal | [email protected] | LinkedIn
Luis Aparicio | LuisAparicio14 | [email protected] | LinkedIn
Rodrigo Chavez - RodrigoACG | [email protected] | LinkedIn
Distributed under the MIT license. See LICENSE.txt
for more information.
Email any author to inquire about contributing.