function quiz_question_form in Quiz 6.6
Same name and namespace in other branches
- 6.3 question_types/quiz_question/quiz_question.module \quiz_question_form()
- 6.4 question_types/quiz_question/quiz_question.module \quiz_question_form()
- 6.5 question_types/quiz_question/quiz_question.module \quiz_question_form()
- 7.6 question_types/quiz_question/quiz_question.module \quiz_question_form()
- 7 question_types/quiz_question/quiz_question.module \quiz_question_form()
- 7.5 question_types/quiz_question/quiz_question.module \quiz_question_form()
Implementation of hook_form().
File
- question_types/
quiz_question/ quiz_question.module, line 146 - Quiz Question module. This module provides the basic facilities for adding quiz question types to a quiz. While you can create standard Quiz question types simply by implementing the appropriate hooks, this module provides a framework that makes…
Code
function quiz_question_form(&$node, $form_state) {
$form = array();
$form['body'] = array(
'#type' => 'textarea',
'#title' => t('Question'),
'#description' => t('Enter the full text of the question that will be shown to the user. Include any special instructions on how to answer.'),
'#default_value' => $node->body,
'#required' => TRUE,
'#weight' => -15,
);
// process up the filter format
$form['format'] = filter_form($node->format);
// First we do the basic title and text fields.
// XXX: Should there be a way for question types to modify these (other than form alter hooks)?
// Allow user to set title?
if (user_access('allow user titles')) {
$form['helper']['#theme'] = 'quiz_question_creation_form';
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $node->title,
'#required' => FALSE,
'#description' => t('Add a title that will help distinguish this question from other questions. This will not be seen during the quiz.'),
);
}
else {
$form['title'] = array(
'#type' => 'value',
'#value' => $node->title,
);
}
// Collection ID used here to tie creation of a question to a specific quiz or qcollection
$collection_id = arg(3);
if (!empty($collection_id)) {
$collection = node_load((int) $collection_id);
$form['collection_nid'] = array(
'#type' => 'value',
'#value' => $collection->nid,
);
$form['collection_vid'] = array(
'#type' => 'value',
'#value' => $collection->vid,
);
// If coming from collection view, go back there on submit.
// TODO ask the node itself where to go after authoring a question
switch ($collection->type) {
case 'quiz':
$form['#redirect'] = 'node/' . $collection->nid . '/questions';
break;
case 'qcollection':
$form['#redirect'] = 'node/' . $collection->nid . '/items';
break;
}
}
$question = _quiz_question_get_instance($node);
$form = array_merge($form, $question
->getCreationForm($form_state));
return $form;
}