function quiz_node_prepare in Quiz 7.5
Same name and namespace in other branches
- 8.6 quiz.module \quiz_node_prepare()
- 8.5 quiz.module \quiz_node_prepare()
- 7.6 quiz.module \quiz_node_prepare()
- 7 quiz.module \quiz_node_prepare()
- 7.4 quiz.module \quiz_node_prepare()
Implements hook_node_prepare().
File
- ./
quiz.module, line 1641 - quiz.module Main file for the 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.
if (arg(0) == 'node') {
global $user;
if (!node_load_multiple(array(), array(
'uid' => $user->uid,
'type' => 'quiz',
))) {
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_get_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;
}
}
}