Code to take quiz again on the next day after user is failed In drupal 6, I had a requirement to enable the users to take the quiz on the next day if they failed and from somewhere I got the following code to make that work. They added one more variables, time_end and used strtotime('today')

But now I upgraded to Drupal 7 and code for the same a little bit changed and I couldn't make that work. I am looking forward to getting help to achieve it. I am using quiz quiz-7.x-4.0-rc1

Drupal 6 Original lines 

// Check to see if this user is allowed to take the quiz again:
  if ($quiz-&gt;takes &gt; 0) {
//   $query = "SELECT COUNT(*) AS takes FROM {quiz_node_results} WHERE uid = %d AND nid = %d";
//   $taken = db_result(db_query($query, $user-&gt;uid, $quiz-&gt;nid));


Drupal 6 Changed lines (only first two lines. after that code remains the same except drupal_set_message.)

     $query = "SELECT COUNT(*) AS takes FROM {quiz_node_results} WHERE uid = %d AND nid = %d AND time_end &gt; %d";
        $taken = db_result(db_query($query, $user-&gt;uid, $quiz-&gt;nid, strtotime('today')));

    $allowed_times = format_plural($quiz-&gt;takes, '1 time', '@count times');
    $taken_times   = format_plural($taken, '1 time', '@count times');


Drupal 7 Original lines.

  // Check to see if this user is allowed to take the quiz again:
  if ($quiz-&gt;takes &gt; 0) {
    $taken = db_query("SELECT COUNT(*) AS takes FROM {quiz_node_results} WHERE uid = :uid AND nid = :nid", array(':uid' =&gt; $user-&gt;uid, ':nid' =&gt; $quiz-&gt;nid))-&gt;fetchField();
    $allowed_times = format_plural($quiz-&gt;takes, '1 time', '@count times');
    $taken_times   = format_plural($taken, '1 time', '@count times');


Full drupal 7 code is available here DrupalContrib
I could find a solution. It's actually pretty simple. But I don't know whether this is the right way doing it.
Just change $taken like below. Then anybody can retake the test on the next day. Thanks to all for the support.

$taken = db_query("SELECT COUNT(*) AS takes FROM {quiz_node_results} WHERE uid = :uid AND nid = :nid AND time_end &gt; :time_end", array(':uid' =&gt; $user-&gt;uid, ':nid' =&gt; $quiz-&gt;nid, ':time_end' =&gt; strtotime('today')))-&gt;fetchField();