You are here

function quiz_node_prepare in Quiz 7.4

Same name and namespace in other branches
  1. 8.6 quiz.module \quiz_node_prepare()
  2. 8.5 quiz.module \quiz_node_prepare()
  3. 7.6 quiz.module \quiz_node_prepare()
  4. 7 quiz.module \quiz_node_prepare()
  5. 7.5 quiz.module \quiz_node_prepare()

Implementation of hook_node_prepare().

File

./quiz.module, line 1660
Quiz Module

Code

function quiz_node_prepare($node) {
  if ($node->type == 'quiz' && !isset($node->nid)) {

    // If this is a new node we apply the user defaults for the quiz settings.
    $settings = _quiz_load_user_settings();
    if (!$settings) {
      if (arg(0) == 'node') {
        drupal_set_message(t('You are making your first @quiz. On this page you set the attributes, most of which you may tell the system to remember as defaults for the future. On the next screen you can add questions.', array(
          '@quiz' => QUIZ_NAME,
        )));
      }
      $settings = _quiz_load_user_settings(variable_get('quiz_def_uid', 1));
    }
    $settings += _quiz_get_node_defaults();
    foreach ($settings as $key => $value) {
      if (!isset($node->{$key})) {
        $node->{$key} = $value;
      }
    }
  }
  if (isset($node->is_quiz_question)) {
    if (variable_get('quiz_auto_revisioning', 1)) {
      $node->revision = quiz_question_has_been_answered($node) ? 1 : 0;
    }
  }
}