Skip to content

Pelikantapeten/p3-dad-jokes

Repository files navigation

Dad Jokes

Responsive screenshot

The purpose with this project

Dad Jokes is a console based application that accommodates individuals that are either interested in quick amusement of silly jokes or individuals that wants to share their silly jokes with other users. The user interface is text based and it is run from a text terminal or other types of command-in interfaces.

The application has two options at start that either lets the user read and rate a joke or submit a joke together with their name.

Target audience: All individuals that wants to read and rate a silly joke and all individuals that wants to submit a joke for future rating.

This project is the third of five milestone projects that needs to be completed in order for me to receive a diploma in Software Development from The Code Institute https://codeinstitute.net/

Required technologies for this project: Python

A live version of this project can be found at this url: https://dad-jokes-1.herokuapp.com/

Table of Content

UX

User Demographic

This application is ment for:

  • All individuals that wants amusements gotten by reading short silly jokes.
  • All individuals that wants to share silly jokes and have the rated by other users.

User Stories

I have divided the user stories for this application in to two different sections, User Reading and User Submitting. The scenarios do not differ much between Old users and New users.

User reading

  • I want to read a silly joke.
  • I want to rate a silly joke.
  • I want to see who submitted silly jokes.
  • I want to see the rating my submitted joke has. (Old user)
  • I want to see if there is any more jokes since last time I used the application (Old user)

User submitting

  • I want to submit a silly joke.
  • I want other users to read my silly joke.
  • I want other users to rate my silly joke.

User Goals

To get amused by silly jokes for a short period of time OR submit silly jokes.

Project Requirements

Python application using libraries/API and deployed to a cloud-based platform.

Design diagram

Dad Jokes is a console based application. For that reason no work was put in to graphical design. Instead focus was put on creating a diagram of the entire application and use that as the base for the code. The diagram also include the Google Sheet used for data storage.

This is the initial diagram:

Intial diagram

During the development process a few things were changed in the diagram. The main reason for this was that I had done a flaw in the design of the Google Sheet. I had placed the calculation formula for average score on jokes inside the sheet. I never got this to work properly so that column was eventually removed and the calculation is done in the application instead.

After the final alterations the final application diagram looks like this:

Final diagram

Back to top

Features

Dad Jokes consists of two features. The user chooses the option of feature from the start section of the application. The features are:

  • Read and rate a joke
  • Submit a joke

Existing Features

Start read and rate

The user starts the read and rate option from the start section of the application. To read and rate the number 1 needs to be entered followed by the enter key.

Start read and rate

After selection the user is presented with a random selected joke from the Google sheet. The user also sees the rating of the joke. The user is also asked to rate the joke by entering a number between 1 and 5.

Read and rate screen

When the rating has been entered the user is taken to the last section of this option. Here the user can choose to read and rate a new joke, restart the application or quit the application.

Read and rate screen

If j is selected the user will receive another joke and rate, if r is pressed the application starts over from the start selection screen and q will terminate the application.

Start submit joke

The user starts the submit option from the start section of the application. To submit a joke the number 2 needs to be entered followed by the enter key.

Start submit

After the selection the user is presented with an instruction to follow the steps and enter a name or a nickname. If the user enters a name shorter than two signs or longer than 10 signs they will be prompted to correct.

Enter name

When name is entered the user is presented with instructions on how to write to make it easier for other users and prompted to enter their joke. If users tries to submit a very short joke or a joke longer than 300 signs they will be prompted to correct it. They user cannot submit empty jokes.

Enter name

When the joke has been submitted the user is taken to the last section of this option. Here the user can choose to submit another joke, restart the application or quit the application.

Enter name

If s is selected the user will restart the submit function, if r is pressed the application starts over from the start selection screen and q will terminate the application.

Features Left to Implement

Future versions of this application will contain a graphical user interface and a capability for users to search and find the rating of their jokes.

Back to top

Technologies and libraries used

Main languages

  • Python
  • HTML - Provided in the Code Institute template
  • CSS - Provided in the Code Institute template
  • JavaScript - Provided in the Code Institute template

Python libraries and api used

Data storage

Jokes, submitted jokes, sumbmitter name and scores are fetched and stored in a Google Sheet using:

Testing

Testing has been conducted continuously during the development process. Manual testing has been conducted by the author and my mentor Martina Terlevic and fellow student Lauren-Nicole Popich. Read more about bugs during development and unfixed bugs for more information.

Bugs during development

  • Using Colorama library but my tests are not working. When I do a print syntax with the provided syntax to change the font color "Hello World" is not printing.
    • Used the wrong syntax. Needed to add a "+" sign before the string
  • Pure strings are using the selected colors but all prints from the worksheet are still white and I get a syntax error.
    • Tried Termcolor library instead of Colorama library and it did the trick
  • Get error messages when I try to access a specific row in the worksheet
    • Used the wrong syntax for the library Gspread. Tried to install and import a different library but that was also problematic. Eventually I found the syntax for the Gspread library and it worked.
  • Not able to add new rating with total rating
    • The variables were strings, converted them to int's and it worked
  • Not able to get a proper error message when rating not entered correctly
    • Used an if/else statement to check and return if input is faulty
  • The worksheet is not updating correctly. Can't figure out why.
    • Went back to look at Love Sandwiches and created a function that updates the worksheet based on that project
  • Can't figure out how to correctly copy the formula needed in the spreadsheet to get average rating.
    • Will try to do the calculation inside Python instead. Update: Did overhaul all that had to do with average score. Removed the calculation of score from the spreadsheet and did the calculation in run.py instead
  • When a joke is rated with a number containing a . or a , the application crashes.
    • Added a try statement to check that the input is an integer
  • On the end screens: If an integer or float value is entered the application crashes.
    • Created a nested function inside the end function that validates the input and prevents crashing
  • Application crashes if enter is pressed without a value in the end screens.
    • Created a nested function inside the end function that validates the input and prevents crashing
  • Users can submit joke and name with only white spaces.
  • Average score is not calculated properly.
    • The formula for average score was not correct. It contained wrong values. Corrected.

Validator Testing

The code has also been tested by using PEP8 Online http://pep8online.com/.

Final testing warned about long lines. This has been corrected and the code passes without any issues.

Unfixed Bugs

Currently working to solve the bugs in this list. They will be moved to the Bugs during development section when they are solved.

  • No known bugs at this point

Back to top

Development and Deployment

The development environment used for this project was GitPod. To track the development stage and handle version control regular commits and pushes to GitHub has been conducted. The GitPod environment was created using a template provided by Code Institute.

The live version of the project is deployed using Heroku(https://heroku.com)

This is how this project was deployed using Heroku:

To prepare for deployment on Heroku a requirements.txt needs to be created in the same folder as the .py file in GitPod. This file needs to contain a list of all libraries the project needs to run as a Heroku App.

Then follow these steps:

  • Login to Heroku (Create an account if necessary)
  • Click on New in the Heroku dashboard and select ”Create new app”
  • Write a name for the app and choose your region and click ”Create App”
  • In the settings tab for the new application I created two Config vars.
    • One is named CREDS and contains the credentials key for Google Drive API
    • One is name PORT and has the value of 8000
  • Two buildpack scripts were added: Python and Nodejs (in that order)

Heroku CLI was used to deploy the project. The following steps were taken in the terminal in GitPod

Deploying your app to heroku

  1. Login to heroku and enter your details.
  • command: heroku login -i
  1. Get your app name from heroku.
  • command: heroku apps
  1. Set the heroku remote. (Replace app_name with your actual app name)
  • command: heroku git:remote -a app_name
  1. Add, commit and push to github
  • command: git add . && git commit -m "Deploy to Heroku via CLI"
  1. Push to both github and heroku
  • command: git push origin main
  • command: git push heroku main

After those steps were taken the application was deployed at the following link: https://dad-jokes-1.herokuapp.com/

Content

  • All text content in the application is created by the author of the project.
  • The initial 24 jokes in the Google Sheet are credited to Country Living and the submitter name for these jokes are set to CL

Credits

For code inspiration, design inputs, help and advice.

I have consulted numerous websites, individuals and slack channels to get support for the code. No code block is directly copied but some generates from information I gathered from other developers and sites:

Acknowledgment

  • Martina Terlevic My fantastic mentor at Code Institute, thank you for your support, feedback, bug testing and great sense of humor.
  • Lauren-Nicole Popich Thank you for testing and contribution of ideas and dealing with my stress over this project.

Am I Responsive was used to create the image on top of this ReadMe

Back to top

About

Third milestone project for Code Institute.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published