Jump to content

restricting access to a test after certian number of attemps


webguync

Recommended Posts

Here is my situation. I have an exam application built in Flash, where after the taker is finished and submits their scores a record is created in MySQL in a log table. Basically there is a column called attempt which is populated with a 1 after they have successfully finished the exam. When this column has a 1, the user is locked out and cannot access the exam when they try and login. The Flash part was built a while back in AS3 and is very cumbersome to try and figure out and make changes, so I have been trying to improve some things on the PHP/MySQL end. What I have now is a php based login which uses if else statements to determine if a user has passed and if they have not uses a DELETE statement to delete their log record and thus they regain access to taking the exam. Code below.

<?php

   if(($pcnt[$i]*100) > 89)
   {
      echo "<span class='green'>you did great!</span>";
   }
   else
   {
     $query_delete = "DELETE FROM log_March2011
USING log_March2011 INNER JOIN roster_March2011
WHERE log_March2011.user_id =roster_March2011.user_id
AND roster_March2011.user_id = '{$_SESSION['user_id']}'"; 
//echo $query_delete; //for debugging test
$result_delete = mysql_query($query_delete) or trigger_error('Query failed: ' .mysql_error());
//$num = mysql_affected_rows($db);
if ($result_delete)
{
echo "<span class='red'>Please review missed questions/sections below</span><br />You can now retake the exam";
}// end if
else
{
echo "No record of taking exam";
} //end else
   }
?>

 

what I would like to do to improve the application is to be able to implement a set number of attempts allowed before the user is disallowed to take the exam again, but not sure how to implement this or is even possible?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.