You are here

public function QuizQuestion::hasBeenAnswered in OG Quiz 7

Finds out if a question has been answered or not

This function also returns TRUE if a quiz that this question belongs to have been answered. Even if the question itself haven't been answered. This is because the question might have been rendered and a user is about to answer it...

Return value

true if question has been answered or is about to be answered...

1 call to QuizQuestion::hasBeenAnswered()
QuizQuestion::getNodeForm in includes/og_quiz_question.php
Returns a node form to quiz_question_form

File

includes/og_quiz_question.php, line 692
Classes used in the Quiz Question module.

Class

QuizQuestion
A base implementation of a quiz_question, adding a layer of abstraction between the node API, quiz API and the question types.

Code

public function hasBeenAnswered() {
  if (!isset($this->node->vid)) {
    return FALSE;
  }
  $answered = db_query_range('SELECT 1 FROM {quiz_node_results} qnres
            JOIN {quiz_node_relationship} qnrel ON (qnres.vid = qnrel.parent_vid)
            WHERE qnrel.child_vid = :child_vid', 0, 1, array(
    ':child_vid' => $this->node->vid,
  ))
    ->fetch();
  return $answered ? TRUE : FALSE;
}