Code Monkey home page Code Monkey logo

quizgame's Introduction

quizgame

A Quiz Game written in golang.

Mini-Project made for the Summer Training program of my Uni

History

  1. Working example using ncurses library and C++
  2. Complete project using drogon framework
  3. Now. Rewrite in golang

Acknowledgement

As a novice in Go programming and Gin framework (and web development in general) I frequently referred to the go-banking-api project by Devansh. Thanks for being awesome!

Database

We're going to need a postgres database to start. I've already included an SQL script to create the tables and add sample data into them.

  • cd into project directory
  • run the below script for user postgres who owns a database quizgame

Feel free to change these values to your liking

psql -U postgres -d quizgame -a -f backend/scripts/database.sql

Quiz game uses the following environment variables to connect to a database.

Environment Variables
QZ_HOSTNAME
QZ_USERNAME
QZ_PASSWORD
QZ_DBNAME
export QZ_HOSTNAME="localhost"
export QZ_USERNAME="postgres"
export QZ_PASSWORD="PASSWORD"
export QZ_DBNAME="quizgame"

Build

Run the build script after installing the dependencies (below)

sh build.sh

Install Dependencies

Frontend

  • cd into frontend
  • install dependencies
yarn install

or

npm install

Backend

  • cd into backend
  • download dependencies
go get

Alternative

You can also simply invoke individual build systems for both react and go.

quizgame's People

Contributors

dependabot[bot] avatar laughingclouds avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

quizgame's Issues

Something new to learn

I knew it was possible but kudos to github for showing me how lacking in skills I am T_T
image

App saves duplicate values in the database

This is the data in the table "Solved"
image

At row 4 and 8, values of question_id and user_id is the same.
If I recall correctly, the code simply adds items to the database without checking whether an entry with the same values exist or not.
At the same time, it is not possible to change the database as both question_id and user_id cannot be unique (due to the nature of use-case for this table).

Hence this should be cross checked by the code, before new values are inserted.

Don't build drogon_ctl in docker

We don't need to build drogon_ctl when we run build.sh in docker.
We could replace this script with a custom build.sh file and even replace the CMakeLists.txt file while building drogon.

Add SQL for creating the database

I used DB Browser for SQLite to create the database.
It would be nice to store the SQL code for creating the database in a separate file.
It's easy to achieve, just copy the SQL code from the db browser.

Preferably put the source file in the DB directory.

Update user score once game is submitted

After data is sent to /StartGame/Score, the solved table gets updated,
but the score field in the user table does not get updated.

The score remains the same even after a new submission has been made.
image

Feature to display a leaderboard

I almost forgot about this.
The leader-board is simple to make.

  • Query the users that have the top 5 scores
  • Display the results on a view

This will require both back-end and front-end teams.

  • Back-team will query the results and insert the data into a view.
  • Front-end team will work on the view.

Potential for confusion with what handles what

People who didn't work on the controllers may not know what URL requests are handled by what controllers.

I suggest documenting this information somewhere.
It could also be put in the final project report.

We could even list the views associated with the various controllers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.