Skip to content

NeilTheSeal/geography-quiz-be

Repository files navigation

Geography Quiz Back-End

A fun online quiz to test your knowledge of world geography

Ruby Rails

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.

Example API requests

GET /quiz-questions
Parameters
name type data type description
None N/A N/A N/A
Headers
name type data type description
accept optional string application/json
Responses
http code content-type response
200 application/json {"data": [{"id":"0","type":"questions","attributes":{"question":"...","correct_answer":"...","options":["..."],"image": false}}, ...]}
Example cURL
 curl -X GET -H "accept: application/json" "https://ancient-plains-68209-663b50393b93.herokuapp.com/api/v0/quiz-questions"
GET /high-scores
Parameters
name type data type description
None N/A N/A N/A
Headers
name type data type description
accept optional string application/json
Responses
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)
Example cURL
 curl -X GET -H "accept: application/json" "https://ancient-plains-68209-663b50393b93.herokuapp.com/api/v0/high-scores"
GET /previous-scores
Parameters
name type data type description
user_id required string the user id as recorded in the front-end database
Headers
name type data type description
accept optional string application/json
Responses
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)
Example cURL
 curl -X GET -H "accept: application/json" "https://ancient-plains-68209-663b50393b93.herokuapp.com/api/v0/previous-scores?user_id=0123456789"
POST /high-scores
Parameters
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
Headers
name type data type description
accept optional string application/json
Responses
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"]}
Example cURL
 curl -X POST -H "accept: application/json" "https://ancient-plains-68209-663b50393b93.herokuapp.com/api/v0/high-scores?user_id=0123456789&number_correct=5"

Database Schema

There is one table in the back-end database - the quiz results table.

Quiz Results

Column Data Type Required
user_id string true
number_correct integer true
created_at datetime true
updated_at datetime true

Q&A

  • 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.

Development setup

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

Release History

  • 0.0.1
    • Initial deployment 06/07/2024

Meta

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.

Contributing

Email any author to inquire about contributing.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages