开发者

Android/PHP/MySQL project assistance - keeping server & phone app synced

I'm working on a solo project, using the aforementioned technologies. The aim is to create an quiz game for Android. The questions are created by the "quiz master" online beforehand and submitted to a MySQL database. They are then retrieved by the Android application. I have set up the link between phone & server using PHP, with the data sent over in JSON format.

I want each question to have a pre-allocated time which the user has to answer it and once this has elapsed, the Android app to prevent t开发者_JAVA百科he question from being answered. The time is chosen by the quiz master and submitted to the database along with the rest of the quiz information.

As not everyone might retrieve the quiz from the server onto their phone at the same time, there are problems with regards to making sure someone doesn't get longer to answer the question than the other. As far as possible, I want to keep everyone in sync. It'll be difficult to make sure everyone has exactly the same time, but I'd settle for just having people not being able to delay retrieving the quiz and then getting the full 30 seconds (or whatever). For it to be fair, the countdown needs to start once the quiz has been started by the quiz master.

I'm struggling to think of a way to overcome this problem. I have a very basic client-server system set up and I can't think of a way to have the server keep track of the "time left" and then send a number to the phone, indicating the amount of time left.

Sorry for the essay, hope someone out there has an idea! It would be very much appreciated!! :)

All the best,

J


Perhaps you could have each users device keep track of how fast they answered the question and then compare the response time after the answer is submitted. For example: The server sends the phone a question and tells it that there is a 30 second time limit. As soon as the user views the question, the timer starts on their phone. Then say it took them... 14.79 seconds to answer correctly. The phone would send the info back saying how long each user took then compare them to see who answered the question first and who all answered within the time limit. This technique may not keep the quiz game perfectly in sync across all connected devices, but it should keep the game fair.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜