You are here

function quiz_access_my_results in Quiz 7.6

Same name and namespace in other branches
  1. 8.4 quiz.module \quiz_access_my_results()
  2. 6.4 quiz.module \quiz_access_my_results()
  3. 7 quiz.module \quiz_access_my_results()
  4. 7.4 quiz.module \quiz_access_my_results()
  5. 7.5 quiz.module \quiz_access_my_results()

Helper function to determine if a user has access to view his quiz results

Parameters

object $quiz: The Quiz node

File

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

Code

function quiz_access_my_results($quiz) {
  global $user;
  if ($quiz->type !== 'quiz') {
    return FALSE;
  }
  $answered = db_query('SELECT 1 FROM {quiz_node_results} WHERE nid = :nid AND uid = :uid AND is_evaluated = :is_evaluated', array(
    ':nid' => $quiz->nid,
    ':uid' => $user->uid,
    ':is_evaluated' => 1,
  ))
    ->fetchField();
  if ($answered) {
    return TRUE;
  }
}