You are here

function _quiz_check_num_random in Quiz 7.6

Same name and namespace in other branches
  1. 8.4 quiz.module \_quiz_check_num_random()
  2. 6.4 quiz.module \_quiz_check_num_random()
  3. 7 quiz.module \_quiz_check_num_random()
  4. 7.4 quiz.module \_quiz_check_num_random()
  5. 7.5 quiz.module \_quiz_check_num_random()

Convert all question statuses back to "always" when the Quiz is no longer set to random.

Parameters

$node: Quiz node.

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

File

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

Code

function _quiz_check_num_random($node) {
  if ($node->randomization != 2) {
    $efq = new EntityFieldQuery();
    $results = $efq
      ->entityCondition('entity_type', 'quiz_question_relationship')
      ->propertyCondition('question_status', QUIZ_QUESTION_RANDOM)
      ->propertyCondition('parent_vid', $node->vid)
      ->execute();
    if (isset($results['quiz_question_relationship'])) {
      $questions = entity_load('quiz_question_relationship', array_keys($results['quiz_question_relationship']));
      foreach ($questions as $question) {
        $question->question_status = QUIZ_QUESTION_ALWAYS;
        $question
          ->save();
      }
    }
  }
}