You are here

function quiz_add_question_to_quiz in Quiz 7.5

Same name and namespace in other branches
  1. 7.6 quiz.module \quiz_add_question_to_quiz()

VBO action to add questions to the current quiz.

File

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

Code

function quiz_add_question_to_quiz($question) {
  $quiz = node_load(arg(1));
  $efq = new EntityFieldQuery();
  $result = $efq
    ->entityCondition('entity_type', 'quiz_question_relationship')
    ->propertyCondition('parent_nid', $quiz->nid)
    ->propertyCondition('parent_vid', $quiz->vid)
    ->propertyCondition('child_nid', $question->nid)
    ->execute();
  if ($result) {
    return FALSE;
  }
  _quiz_question_get_instance($question)
    ->saveRelationships($quiz->nid, $quiz->vid);
  quiz_update_max_score_properties(array(
    $quiz->vid,
  ));
}