Skip to content

vivsnguyen/Tandem-Trivia

Repository files navigation

Trivia Trainer logo

Trivia Trainer app

  • Tandem Software Engineer Apprenticeship Code Challenge
  • One week sprint to build.
  • The pdf file of full requirements can be found in the main project directory.

Contents

Technologies

  • Python
  • Flask
  • Javascript
  • jQuery, AJAX
  • Bootstrap

Challenge Criteria

  • A user can view questions.
  • Questions with their multiple choice options must be displayed one at a time. Questions should not repeat in a round.
  • A user can select only 1 answer out of the 4 possible answers.
  • The correct answer must be revealed after a user has submitted their answer
  • A user can see the score they received at the end of the round

Features

alt text

Randomized answer choices

Incorrect and correct answers are combined into one array and then randomized. Code for this can be found in /static/script.js.

Current question number

The current question number is always visible, so users can keep track of the currect question number they are on.

Answer highlighting by color

Users click to select an answer. After selecting, the button with the correct answer will turn green. If an incorrect answer is selected, the selected button will turn grey. Other incorrect answer buttons will turn red.

alt text Selecting an incorrect answer

alt text Selecting a correct answer

Final score display

After 10 questions are completed, users can view their score percentage and restart the quiz.

New random questions when game restarts

New questions are chosen randomly using random.sample. This function specifically samples without replacement, so no questions are repeated in a round. Code for this can be found in trivia.py.

alt text

Installation

To run Trivia Trainer on your own machine:

Clone or fork this repo:

https://github.com/vivsnguyen/Tandem-Trivia.git

Create and activate a virtual environment inside your Trivia Trainer directory:

virtualenv env
source env/bin/activate

Install the dependencies:

pip install -r requirements.txt

Run the app:

python3.6 app.py

You can now navigate to 'localhost:5000/' to access Trivia Trainer.

Testing

Doctests

I used Doctests to test trivia.py.

To run Doctests, navigate to the Trivia Trainer directory and in your terminal run:

python3 -m doctest -v tests.txt

Future Features

  • Improved accessibility

I tried to include certain features such as high contrast buttons, but would love to add alt-text to be read when an answer is chosen.

  • User Features

I want users to be able to login, save questions, view scores, and add their own questions to the trivia question bank. This is why I decided to send the question data to the front-end through the server. Later on, I would want to store the questions in a database.

  • More testing

I want to add more testing, such as integration tests for my flask server and testing for my front end features.

Known Issues

  • Users can't change their mind on the answer they choose. I wasn't sure if I wanted to include this feature, because many quiz apps (like Kahoot!) don't allow you too. This could be a future feature that can be toggled on and off.

Resources

Back End

Front End

Screenrecording

  • Kap

Thanks

Hi Tandem! Thanks for this opportunity and for taking the time to view my project.

About

Trivia app created using Python, Flask, and Javascript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published