Gamification Of Quiz By Reporting Score To Database

Hi I am looking for some advice. I have a quiz developed and wanted to create the following but cant find much in the way of help with reporting points earned in the quiz to a database.

Goal of project:

  1. Store two variables containing quiz score & username using local storage
  2. Save these values into an online database that I have already created
  3. Pull all data from the database table and display it live on a webpage
  4. Delete all of the saved data from the database to start fresh at any time (admin only)

My hope is that once a new user completes a quiz the score will automatically update the live leaderboard with their score and username.

**Using Hype to create the leaderboard would be my preferred method to display the database user data.

Thanks in advance!
Steve

Hi,
some clues to the type of database???, and its API / access /file types / and any other info that would give someone an idea of how to fetch and send to it. probably would help.

Also it maybe an idea to set up a dummy one for said person to test against…

Thanks @MarkHunte good idea on the test database. I will post the login details here shortly.

It will be a standard MySQL database running on Apache and simply storing 3 values for now.

  • A text value for the username
  • A text value for class name (This is the name of the class the student is enrolled in)
  • A integer value to store the users total score

If anyone would like to use the test database please message me with your ip address and I can give you remote access to the database to test - many thanks

Heres a screengrab

Note that you can’t really communicate directly to a MySQL database via client-side JavaScript. You in general need to have some sort of bridging code running on a server. The client-side javascript talks to it via AJAX request, and then this code does the writing/reading to the database.

1 Like

Awesome thanks @jonathan its been a while since I worked on a backend database, thanks for the advice. Do you know of any hype examples / tutorials that might give me a working example of how to get started with this?

Cheers,
Stephen.

There’s a tutorial here that has glues together Hype, JavaScript, PHP, and a database:

http://www.snippetfish.com/snippet_single.php?snippet=22

There are some other examples if you search “ajax mysql” or “ajax php” on the forums; the backend part is really outside the domain of Hype and heavily dependent on technology choices. The general route is that you’d want anything that can send JSON over HTTP requests.

2 Likes

Thats great @jonathan really appreciate the reply, that gives me a direction to begin further research.

Many thanks,
Stephen.

Have you looked into any other service that wouldn’t require a “backend” language so to speak? Something, using a Database As A Service (DaaS) for example. Like Google’s firebase, or AWS.

I’d be happy to show you an example using Firebase. Added benefit is that it can truly be “live” as in the scores can update/change over several browsers at the same time.

2 Likes

No that never crossed my mind but I can see the benefits. I don’t have a firebase / AWS account at the moment but I would be extremely interested in seeing a simple example of how this might work if it was achievable your end in the coming days / weeks.

I am currently finishing a build of Hype a quiz app so will be 2 weeks before the app is complete and ready to push user scores to a backend database.

Thanks for your input @DBear,

Regards,
Stephen.