function quiz_make_new in Quiz 7.4
Same name and namespace in other branches
- 8.4 quiz.module \quiz_make_new()
- 6.4 quiz.module \quiz_make_new()
- 7 quiz.module \quiz_make_new()
Makes, saves and returns a new quiz node.
Parameters
$title: The title of the new node.
Return value
New quiz node object.
1 call to quiz_make_new()
- QuizQuestion::saveRelationships in question_types/
quiz_question/ quiz_question.core.inc - Handle the add to quiz part of the quiz_question_form
File
- ./
quiz.module, line 4039 - Quiz Module
Code
function quiz_make_new($title) {
global $user;
$new_node = new stdClass();
$new_node->title = $title;
$new_node->type = 'quiz';
$new_node->status = 1;
// Get default user settings.
$settings = _quiz_load_user_settings();
if (!$settings) {
$settings = _quiz_load_user_settings(variable_get('quiz_def_uid', 1));
}
$settings += _quiz_get_node_defaults();
foreach ($settings as $key => $value) {
$new_node->{$key} = $value;
}
$new_node->auto_created = TRUE;
$new_node->uid = $user->uid;
node_save($new_node);
if (is_numeric($new_node->nid)) {
drupal_set_message(t('Quiz %title has been created.', array(
'%title' => $title,
)));
}
return $new_node;
}