Improving PHP & MySQL based online quiz
- or -
Post a project like this3620
£95(approx. $118)
- Posted:
- Proposals: 7
- Remote
- #473202
- Completed
Full stack developer. Web applications, mobile apps, frontend. React, Nodejs, Javascript, MongoDB
London
502811536200598696602244633752643462649927
Description
Experience Level: Intermediate
Estimated project duration: 1 - 2 weeks
General information for the website: Online English language quiz
Kind of development: Customization of existing website
Description of requirements/features: Hi,
This is a long brief but the work isn't complicated - just thought I'd explain it all here:
A while back I built an English language quiz, Grammar Gamble (www.grammargmable.com). The website is a quiz built on the Twitter Bootstrap with PHP and MySQL. Users login in via Facebook, start with 100 points and try to answer 10 grammar questions. On each question they 'bet' some of their existing score. If they get the right answer, they win the amount they bet. If they get it wrong they lose it. After 10 questions - or when they lose all their points - the game ends.
On each question page (question.php) league tables show their score compared to those of other players.
Have a go... you'll see how it works. :)
It's ready for further development, though at the time it was created I was learning PHP and MySQL, so the code is not great.
The first step is tidying up the way league tables are calculated and shown on the page, plus I want to change the gameplay slightly to make it a better game. After this there will be more work in the future.
1. Improving / tidying the league tables code:
At the moment, to calculate and show the league tables the code makes lots of unnecessary MySQL queries, copy data between database tables, ranking them and copying them back again, and it does this for scores both higher and lower than the current Player's score. There are too many SQL queries and it's a bit of a mess.
Actually, it probably just needs to do an SQL query to get the scores from the scores table higher than the current Player's score (if there are any) and work out the rank value in the PHP code, then list the Player's score and rank. Then do a 2nd SQL query gets the scores below and work out the ranking again.
It might even be able to do this with one SQL query. Either way, I'd like the way it works out and shows the tables to be simple and clean.
2. Secondly, I want to change the mechanics of the game itself. This is how it works at the moment:
1. Players are on question.php
2. They get shown a random question pulled from the 100+ questions in the database 'questions' table
3. They choose their answer, clicking a checkbox and clicking Next to submit a form.
4. A bit of javascript and JQuery works out if they clicked the correct checkbox and calculates their new score. The user then clicks Next again and, unless their score is now 0, their score is posted back to question.php page
5. When question.php loads again, it checks what their current score is then updates it in the database for this game, then works out the league tables again via all the SQL queries above.
6. When 10 questions have been answered, the game finishes.
I want to change it so that users can play forever until they lose all their money OR answer all the questions available. They should also be able to login and play, go away for a few days, come back and continue playing the same game.
And this is what I need:
i. When they start a new game, the Player should get a randomised array of question IDs, and they continue to advance along the array until they have answered them all. Then they will be directed to gamefinish.php
ii. If they lose all their points their game will be over - however their last score must be remembered in the database so it can show in the league tables. However their unique game ID will be marked in the database as over / inactive. If they click 'play again' they should start a new game with the starting 100 points as per usual, and a new array of randomised question IDs.
ii. Stopping cheating!.... In this new gameplay, theoretically players could lose all their points and then opt NOT to click 'Next' and end their game. This means they could cheat and never lose.
So, what needs to happen is that the new score should be updated in the database immediately after choosing their answer. Perhaps a bit of AJAX is needed here to process the score instead of posting it back to question.php?
iv. If a player leaves, comes back / logs in again later and plays then GrammarGamble should recognise that they still have an active game and they continue where they left off.
Hope that makes sense. It will be much easier to understand when I share the code with the successful bidder.
I look forward to your quotes. I'm happy to answer any questions too.
Many thanks,
Richard
Extra notes: FTP and database access will be provided to successful bidder
Kind of development: Customization of existing website
Description of requirements/features: Hi,
This is a long brief but the work isn't complicated - just thought I'd explain it all here:
A while back I built an English language quiz, Grammar Gamble (www.grammargmable.com). The website is a quiz built on the Twitter Bootstrap with PHP and MySQL. Users login in via Facebook, start with 100 points and try to answer 10 grammar questions. On each question they 'bet' some of their existing score. If they get the right answer, they win the amount they bet. If they get it wrong they lose it. After 10 questions - or when they lose all their points - the game ends.
On each question page (question.php) league tables show their score compared to those of other players.
Have a go... you'll see how it works. :)
It's ready for further development, though at the time it was created I was learning PHP and MySQL, so the code is not great.
The first step is tidying up the way league tables are calculated and shown on the page, plus I want to change the gameplay slightly to make it a better game. After this there will be more work in the future.
1. Improving / tidying the league tables code:
At the moment, to calculate and show the league tables the code makes lots of unnecessary MySQL queries, copy data between database tables, ranking them and copying them back again, and it does this for scores both higher and lower than the current Player's score. There are too many SQL queries and it's a bit of a mess.
Actually, it probably just needs to do an SQL query to get the scores from the scores table higher than the current Player's score (if there are any) and work out the rank value in the PHP code, then list the Player's score and rank. Then do a 2nd SQL query gets the scores below and work out the ranking again.
It might even be able to do this with one SQL query. Either way, I'd like the way it works out and shows the tables to be simple and clean.
2. Secondly, I want to change the mechanics of the game itself. This is how it works at the moment:
1. Players are on question.php
2. They get shown a random question pulled from the 100+ questions in the database 'questions' table
3. They choose their answer, clicking a checkbox and clicking Next to submit a form.
4. A bit of javascript and JQuery works out if they clicked the correct checkbox and calculates their new score. The user then clicks Next again and, unless their score is now 0, their score is posted back to question.php page
5. When question.php loads again, it checks what their current score is then updates it in the database for this game, then works out the league tables again via all the SQL queries above.
6. When 10 questions have been answered, the game finishes.
I want to change it so that users can play forever until they lose all their money OR answer all the questions available. They should also be able to login and play, go away for a few days, come back and continue playing the same game.
And this is what I need:
i. When they start a new game, the Player should get a randomised array of question IDs, and they continue to advance along the array until they have answered them all. Then they will be directed to gamefinish.php
ii. If they lose all their points their game will be over - however their last score must be remembered in the database so it can show in the league tables. However their unique game ID will be marked in the database as over / inactive. If they click 'play again' they should start a new game with the starting 100 points as per usual, and a new array of randomised question IDs.
ii. Stopping cheating!.... In this new gameplay, theoretically players could lose all their points and then opt NOT to click 'Next' and end their game. This means they could cheat and never lose.
So, what needs to happen is that the new score should be updated in the database immediately after choosing their answer. Perhaps a bit of AJAX is needed here to process the score instead of posting it back to question.php?
iv. If a player leaves, comes back / logs in again later and plays then GrammarGamble should recognise that they still have an active game and they continue where they left off.
Hope that makes sense. It will be much easier to understand when I share the code with the successful bidder.
I look forward to your quotes. I'm happy to answer any questions too.
Many thanks,
Richard
Extra notes: FTP and database access will be provided to successful bidder
Richard E.
100% (19)Projects Completed
32
Freelancers worked with
12
Projects awarded
23%
Last project
9 May 2017
United Kingdom
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies