Dynamically changing a timestamp - suggestions?
I'm writing up an online examination site for an 开发者_JAVA百科educational institution. Time limits can be set for each assessment, and once a user begins an exam, a new timestamp is created on the server. The problem is that our school computers often lock up and students are forced to restart, losing exam time.
I figured out I could store the timer as a cookie, but that could easily be compromised. Any suggestions? Thanks.
You could store a timestamp in a database that is linked to their user (I would assume they have a login if they are doing exams) and perform an ajax call every few seconds to check if they are still online.
In this ajax check you can update the database with a new timestamp that indicates when they were last online, so if the computer locks up and they have to restart you can figure out how much time was lost.
You could generate unique hash to store it in the cookie like
$cookie = md5( $student_name . $test_start_timestamp . $computer_ip );
and store all the needed information in the database like:
INSERT INTO examination
SET student_hash = '$cookie',
test_start = '$test_start_timestamp',
computer_ip = '$computer_ip'
and later (if computer is restarted) you can get all the information from the database:
SELECT * FROM examination
WHERE student_hash = '$cookie'
this way the student won't be able to change the timestamp
While I realise that this can at times be difficult the only really reliable solution to your dilema is a reliable network.
But lacking that what about another communication media or pathway that confirms the client state? Can you confirm that a domain controller can see the client on the LAN? If the PC is present but the web client isn't it is more likely a user manuipulated situation. Can something (domain controller, other network location?) note the appearance or disappearance of a client from the network?
Any method is open to abuse somehow. I think the only real assurance will come from human monitoring of frequence of and user experiencing restarts.
精彩评论