You are here

public function QuizQuestion::hasBeenAnswered in Quiz 7.6

Same name and namespace in other branches
  1. 6.4 question_types/quiz_question/quiz_question.core.inc \QuizQuestion::hasBeenAnswered()
  2. 7 question_types/quiz_question/quiz_question.core.inc \QuizQuestion::hasBeenAnswered()
  3. 7.4 question_types/quiz_question/quiz_question.core.inc \QuizQuestion::hasBeenAnswered()
  4. 7.5 question_types/quiz_question/quiz_question.core.inc \QuizQuestion::hasBeenAnswered()

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 question_types/quiz_question/quiz_question.core.inc
Returns a node form to quiz_question_form

File

question_types/quiz_question/quiz_question.core.inc, line 382
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;
}