You are here

function quiz_is_passed in Quiz 6.2

Same name and namespace in other branches
  1. 8.6 quiz.module \quiz_is_passed()
  2. 8.4 quiz.module \quiz_is_passed()
  3. 8.5 quiz.module \quiz_is_passed()
  4. 6.6 quiz.module \quiz_is_passed()
  5. 6.3 quiz.module \quiz_is_passed()
  6. 6.4 quiz.module \quiz_is_passed()
  7. 6.5 quiz.module \quiz_is_passed()
  8. 7.6 quiz.module \quiz_is_passed()
  9. 7 quiz.module \quiz_is_passed()
  10. 7.4 quiz.module \quiz_is_passed()
  11. 7.5 quiz.module \quiz_is_passed()

Check a user/quiz combo to see if the user passed the given quiz. A quiz is keyed by nid/vid, so you need both. This will return TRUE if the user has passed the quiz at least once, and false otherwise. Note that a FALSE may simply indicate that the user has not taken the quiz.

Parameters

$uid: The user ID.

$nid: The node ID.

$vid: The version ID.

1 call to quiz_is_passed()
quiz_start_actions in ./quiz.module
Actions to take place at the start of a quiz.

File

./quiz.module, line 973
Quiz Module

Code

function quiz_is_passed($uid, $nid, $vid) {
  $passed = db_result(db_query("SELECT COUNT(result_id) AS passed_count\n    FROM {quiz_node_results} qnrs \n    INNER JOIN {quiz_node_properties} USING (vid, nid) \n    WHERE qnrs.vid = %d AND qnrs.nid = %d AND qnrs.uid =%d AND score >= pass_rate", $vid, $nid, $uid));

  // Force into boolean context
  return $passed !== FALSE && $passed > 0;
}