You are here

function _quiz_redirect_if_empty in Quiz 7

Same name and namespace in other branches
  1. 6.4 quiz.module \_quiz_redirect_if_empty()

Redirects to the manage questions tab if the quiz has no questions.

Parameters

$node: Quiz node.

2 calls to _quiz_redirect_if_empty()
quiz_insert in ./quiz.module
Implements hook_insert().
quiz_update in ./quiz.module
Implements hook_update().

File

./quiz.module, line 4082
Quiz Module

Code

function _quiz_redirect_if_empty($node) {
  $res = db_query('SELECT child_vid FROM {quiz_node_relationship} WHERE parent_vid = :vid', array(
    ':vid' => $node->vid,
  ))
    ->fetchField();
  if (!is_numeric($res)) {
    $_GET['destination'] = 'node/' . $node->nid . '/questions';
  }
}