The swimming quiz is a test of knowledge and proficiency in various aspects of swimming, such as swimming strokes, techniques, rules, and safety measures. It includes multiple-choice questions. The quiz can be taken by anyone and covers topics such as freestyle, backstroke, breaststroke, butterfly, and flip turns. The purpose of the quiz is to assess one's knowledge and understanding of swimming and to promote safe and effective swimming practices.
The live link can be found here
- Display clear information about the swimming quiz in order to make it easy to understand even for first time users.
- Each step provides the necessary information to make the program clear and intuitive.
- Provide input validation to help the user to input the correct data throughout the quiz.
- The program should keep running until the user decides otherwise.
- Provide the user with a fun, engaging and easy to play multiple choice quiz.
- Provide some visuals with the use of ASCII art and colour to contribute to a positive user experience.
- Accurately keep track of and display the user’s score clearly at the end of the quiz.
- As a user, I want to receive information about the main objective of the program.
- As a user, I want to easily understand what input is needed on each step.
- As a user, I want to receive clear feedback in case I provide the wrong input.
- As a user, I want the results to be displayed in a clear way and to be easy to understand.
- As a user, I want to be able to easily repeat the quiz if I want to try again.
Colorama has been used to apply colour to the terminal text and the logo, in order to make it more intuitive and easier to read.
- Wrong answers are in red colour.
- Correct answers are in green colour.
- Invalid inputs/options are in red colour.
- The logo of the game is in blue with white background colour.
- Messages are displayed in the default terminal colour.
- Updating the Google sheet message at the end of the game is in green colour.
- The feedback at the end of the game is displayed with different colours depending on the % the user gets at the end. The colours used for the different messages are: Cyan, Green, Yellow, Blue and Magenta.
-
The check_answer() function checks if the selected answer is correct, compares it to the correct answer, and returns either 1 or 0.
-
The new_game() function starts a new game, displays each question in the game and the possible answers, prompts the user for the correct answer, and stores the user's guesses.
-
The your_guesses variable is a list that will store the user's guesses for each question.
-
The correct_guesses variable keeps track of how many questions the user answered correctly.
-
The num_question variable is an integer that keeps track of the current question number.
-
The questions are stored in a dictionary and the optional answers are stored in a list, which means that more questions can be added to this quiz in the future along with the optional answers
-
The show_score() function displays the user's score and their guesses for each question.
-
The import_results_worksheet() function imports the data from the "total_score" sheet using the get_all_values() method of the worksheet object of the SHEET object.
-
The export_results_worksheet() function exports the user's name and score to a Google Sheets document after each game.
Lucid has been used to create a simple flowchart of the expected flow of logic through the programme from start to finish. This helped me to visualise the structure of the code and what functions may be needed.
As shown in the flowchart, the original order of some functions has been changed during the development process in order to follow a more intuitive logic and sequence of events but the main idea behind the process is still the same.
- The welcome logo when you start the game.
- Welcome message and user input for their name to continue to the main.
- Main Menu after the user inputs their name.
- The user has 4 options to choose from.
- If they select option 1, the rules pop up.
- If they select option 2, the game starts.
- If they select option 3, the leaderboard shows up.
- The leaderboard shows top 5 scores only.
- If they select option 0, the game quits.
-
Menu:
- As a user I want to clearly see and use the options from the menu.
-
Option 1:
- As a user I want clear instructions on how to use the quiz.
-
Option 2:
- As a user I want to test my knowledge of swimming.
- As a user I want to be able to read the application output clearly.
-
Option 3:
- As a user I want to clearly see the leaderboard.
-
Option 0:
- As a user I want to quit the game.
- When the user finishes the last question, the results show up.
- The user guesses and their score is calculated.
- The correct answers of the game are shown.
- The user gets a feedback message at the end as well.
- Depending on the % that the user got, the colour of the feedback message changes.
- After the results, the score and the name of the user is exported to Google worksheet and a message to acknowledge this is displayed.
- Lastly, there is a question that asks the user if they would like to play another game. If they say "Y", it brings them back to the menu and they can select whatever option they like. If they say "N", a goodbye message is displayed.
-
Results:
- As a user I want to clearly see my score at the end of the quiz.
-
Score Worksheet:
- As a user I want to know if my name and score has been recorded.
-
Question:
- As a user I want to be able to easily repeat the quiz if I want to try again.
-
GitPod was used for writing code, committing, and then pushing to GitHub.
-
GitHub was used to store the project after pushing.
-
Heroku was used to deploy the application.
-
PEP8 online check was used to validate the Python code.
-
Colorama library was used to apply colour to the terminal text.
-
Gspread module was used for Google sheets.
-
Time module was used for delaying the output.
-
Ascrii Art was used for the welcome logo.
-
Responsive Design Checker was used to generate mock-up imagery.
-
As a user, I want to receive information about the main objective of the program.
- Information about the program is presented in the welcome message.
- Further information about the quiz can be found under option 1 (rules).
-
As a user, I want to easily understand what input is needed on each step.
- Input messages are being provided with detailed information on what the input needs to be.
-
As a user, I want to receive clear feedback in case I provide the wrong input.
- Error messages are provided explaining what is wrong with the input provided in case the wrong input is entered.
-
As a user, I want the results to be displayed in a clear way and to be easy to understand.
- Option 3 (Leaderboard) provides the name and the results from the quiz for the top 5 people only.
-
As a user, I want to be able to easily repeat the quiz if I want to try again.
- At the end of the quiz, the user has the option to say yes if they would like to play again. Once they reply with Yes, it will bring them back to the menu and they can select from the 4 options available.
The PEP8 online check was used throughout the development process to validate the Python code for PEP8 requirements. No errors were found after the last test.
- Deployment was done at the start of the project to allow device testing throughout the development process.
- The application has been deployed using Heroku by the following steps:
- Remove unused imports from run.py file.
- In order for input methods to work properly in the deployed mock terminal, add a new line character at the end of the text, inside the input method.
- Create the requirements.txt file and run:
pip3 freeze > requirements.txt
in the console. - Commit changes and push them to GitHub.
- Go to the Heroku's website.
- From the Heroku dashboard, click on "Create new app".
- Enter the "App name" and "Choose a region" before clicking on "Create app".
- Go to "Config Vars" under the "Settings" tab.
- Click on "Reveal Config Vars" and add the KEY: CREDS and the VALUE stored in creds.json file if needed.
- Add the Config Var, KEY: PORT and VALUE: 8000.
- Go to "Buildpacks" section and click "Add buildpack".
- Select "python" and click "Save changes".
- Add "nodejs" buildpack as well using the same process.
- Go to "Deployment method", under the "Deploy" tab select "GitHub" and click on "Connect to GitHub".
- Go to "Connect to GitHub" section and "Search" the repository to be deployed.
- Click "Connect" next to the repository name.
- Choose "Automatic deploys" or "Manual deploys" to deploy your application.
The live link can be found here
Stackoverflow was used for clearing the terminal.
Programiz was used for the pause between the questions and loading of the results and the leaderboard.
Youtube was used for the importing of the data from Google sheets.
Youtube was used for exporting of the data to Google sheets.
Youtube was used for creating the layout of the menu.
We Love Quizzes was used for the questions in the game.
Readme.md was used for some ideas.
Coudinary : was used to store the screenshots in the Readme file.
Colorama was used for the colour of the text in the game.
Responsive Design Checker was used to generate mock-up imagery.
Lucid was used for the flowchart of the game.
ASCII-Generator was used for the welcome logo.
This project was developed and designed as a Portfolio 3 Project for Full Stack Software Developer Diploma course at the Code Institute. I would like to thank my mentor Marcel Mulders for his invaluable feedback and guidance, our facilitator Chris Quinn, the Slack community, and all at the Code Institute for their help and support. I really enjoyed working on this project.