#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Taking a PHP quiz only once


    Hi everyone, I am writing a php quiz for my students. Results will be sent to my email, which is what I prefer. The form requires that all questions are answered and that the email they input to identify themselves is valid. Upon submitting, I show answers to questions which were missed and provide the percentage of correct answers. To avoid random people finding my quiz, I have a no-robots tag on the page and can put a JavaScript password on it. I'm fine with the coding for all of that.

    But there is always someone who will want to take the quiz a zillion times. The password and validation may slow them down, but somebody will retake it until it's 100% and jam up my inbox. Other than stating, "Only one attempt at the quiz will count for your grade" or "Take this quiz more than once and I'll obliterate all your scores" (no, I wouldn't say that but would like to), is there some code that will prevent them from taking it more than once?

    Apologies if this should be in a different forum. Since the quiz is PHP, I thought I'd start here. Any ideas are appreciated.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    676
    Rep Power
    7
    This possibly would NOT be the best way, since I'm not sure on where everyone is doing everything, but you can make it allow one submission per IP. This may be an issue if brothers/sisters, or friends are going to be using the same computer/network to submit their answers. If this is a college level item, I would assume the students have college e-mail addresses, which I would then use.

    I understand you want the final submission to land in your inbox, which is no problem, but you will still need a database to hold submission values to run your checks against.
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Hi,

    it all comes down to how you validate the registrations. If you make sure that every student has only one account, it's absolutely no problem to limit the number of submissions. You just have to set a flag in the database after the quiz (e. g. "quiz_completed = 1") and not allow a user to take the quiz when the flag is already set. Then the same account (= student) won't be able to repeat the quiz.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0
    Thanks, Triple_Nothing! I was hoping not to have to set up a database (yes, I was being lazy), but I think you're right it will help. I do have a husband-wife team taking the class right now, so the IP address thing could be sticky ....

  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0
    Thanks, Jacques1! The flag idea will be very useful indeed.


IMN logo majestic logo threadwatch logo seochat tools logo