You are here

function quiz_is_passed in Quiz 7.6

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.2 quiz.module \quiz_is_passed()
  6. 6.3 quiz.module \quiz_is_passed()
  7. 6.4 quiz.module \quiz_is_passed()
  8. 6.5 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.

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.

Related topics

2 calls to quiz_is_passed()
quiz_end_scoring in ./quiz.module
Score a completed quiz.
quiz_start_check in ./quiz.module
Actions to take place at the start of a quiz.

File

./quiz.module, line 2291
quiz.module Main file for the Quiz module.

Code

function quiz_is_passed($uid, $nid, $vid) {
  $passed = db_query('SELECT COUNT(result_id) AS passed_count FROM {quiz_node_results} qnrs
    INNER JOIN {quiz_node_properties} USING (vid, nid)
    WHERE qnrs.vid = :vid
      AND qnrs.nid = :nid
      AND qnrs.uid = :uid
      AND score >= pass_rate', array(
    ':vid' => $vid,
    ':nid' => $nid,
    ':uid' => $uid,
  ))
    ->fetchField();

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