Code to take quiz again on the next day after user is failed
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();