You are here

function quiz_certificate_access_certificate in Certificate 3.x

Same name and namespace in other branches
  1. 8.3 modules/quiz_certificate/quiz_certificate.module \quiz_certificate_access_certificate()
  2. 6.2 modules/quiz_certificate/quiz_certificate.module \quiz_certificate_access_certificate()
  3. 6 modules/quiz_certificate/quiz_certificate.module \quiz_certificate_access_certificate()
  4. 7.3 modules/quiz_certificate/quiz_certificate.module \quiz_certificate_access_certificate()
  5. 7.2 modules/quiz_certificate/quiz_certificate.module \quiz_certificate_access_certificate()
  6. 4.x modules/quiz_certificate/quiz_certificate.module \quiz_certificate_access_certificate()

Implements hook_access_certificate().

File

modules/quiz_certificate/quiz_certificate.module, line 6

Code

function quiz_certificate_access_certificate($node, $user) {
  if ($node->type == 'quiz') {
    $results = entity_load('quiz_result', FALSE, array(
      'nid' => $node->nid,
      'uid' => $user->uid,
    ));
    foreach ($results as $result) {
      if ($result->score >= $node->pass_rate) {
        return TRUE;
      }
    }
  }
}