Im doing a quiz (php and mysql) for some students, the quiz is based on a video they have to watch..
the order is this..
1)they enter a unique web page for every user
2)access a page with a video for the user to watch…
3)on the bottom of the page there’s a button “Answer Quiz”
4)When they click the button, they are send to a page with the quiz
Here’s where the problem happens, i want to prevent the user from watching the video again, but when they hit the back button, well there’s the video again for them to watch
im blocking the video in a video table in mysql db, but the video is cached or something, so this is not the approach of preventing the user to watch the video again when hitting the back button…
.
any ideas of how to achieve this??
any help appreciated……
Checking from your latest comment, I would assume that you have a table,
expired_quizzeswith at least three columns,quiz_id,quiz_filenameand the booleanis_active. I would also normalize the table to auseridas well, so if user A views it and takes the quiz, user B can still see the video (makes cheating with a friend easier, though). It is hard to know exactly what is going on without seeing any code or structure, but try checking a couple of these things:If you look up the quiz based upon a search, and the webpage uses a variable
$_GET, then anytime the webpage is visited, it will always load the quiz. So considering:http//www.yourwebpage.com/?quizfilename=viewablequiz.mp4Depending upon your PHP instructions, it will always load
viewablequiz.mp4. There are two recommendations to prevent it.Don’t load
$_GET['quizfilename']. Rather load$_GET['quizid']and recall the filename from the query with additional search parameters, such as:‘SELECT * FROM expired_quizzes
WHERE quiz_id='{$_GET[‘quizid’]}’ AND is_active=1
LIMIT 1;’
Then, return
row['filename']in your PHP code, or handle with a response to the user if no results are found (no unexpired quizzes).To prevent cheating, you should probably also have another table which records every time the video is viewed, with a timestamp and userid. It can help detect a cheating attempt later by seeing who was testing and viewing at the same time.
Of course, always protect against SQL injection and don’t put user input directly into the SQL statement.
For a more detailed analysis, you should post just the relevant PHP, HTML and SQL within the question.