I've got a quiz. There is a content type to create a question. I've added a textfield to it (which will show a link to where the user can find the answer).

When I look at the question itself the textfield has been added and is being displayed on the screen. But when the question is part of the quiz, the textfield isn't there anymore (not on the screen, nor in the code).

Who can help me?

Maybe I need to add some kind of hook to the Quiz module but I don't know how hooks/custom modules work.

Thanks in advance.


There are probably many ways doing this. I'm still new as well, so go easy on me.

I would suggest you to create a taxonomy quiz. Each list item of quiz would be your question. Then for the content type answer, have a field named question and select term reference, choose select list as the widget type. That way, when a user create a new content answer and refer to one of the question from taxonomy quiz, you can just click on the question and it will give you a list of answer.

Other ways would be using Node Reference, but I couldn't get my mind around how to refer back to the question itself, maybe Relation would do the trick.

But try my first suggestion first.


I think your custom field is not appeared in the question form of the Quiz. The path is, for example, node/8/take. It is a custom form/page created by the Quiz module.

You would need to alter the form using hook_form_alter() from your custom module. Then you would need to load the node (question) to get the field value using node_load() and add it to the form using #markup attribute.

function MYMODULE_form_alter(&$form, &$form_state, &$form_id){
    if($form_id == 'quiz_question_answering_form'){
        $qnode = node_load($form['question_nid']['#value']);
        $form['link2answer'] = array(
            '#markup' => l('See answer', $qnode->field_link2answer['und'][0]['safe_value']),

If you don't know how to create a custom module, check the documentation.


With quiz 7.x-5.0-alpha4+72-dev the array structure has changed somewhat. You will want to use this code:

 * Implements hook_form_FORM_ID_alter()
function my_module_form_quiz_question_answering_form_alter(&$form, &$form_state, $form_id) {
  // Print custom fields on the question page during the quiz.
  foreach ($form['questions'] as $node_key => $node_value) {
    $qnode = node_load($form['questions'][$node_key]['header']['body']['#object']->nid);

  $field_source_url = !empty($qnode->field_source[LANGUAGE_NONE][0]['url']) ? $qnode->field_source[LANGUAGE_NONE][0]['url'] : '';
  $field_source_title = !empty($qnode->field_source[LANGUAGE_NONE][0]['title']) ? $qnode->field_source[LANGUAGE_NONE][0]['title'] : $field_source_url;
  $field_source = l($field_source_title, $field_source_url);

  $form['navigation']['#prefix'] = theme('question_link', array(
    'field_source' => $field_source,

 * Implements hook_theme()
 * @return array
function my_module_theme() {
  $items = array();
  $theme_path = drupal_get_path('theme', 'my_theme') . '/templates';

  $items['question_link'] = array(
    'path' => $theme_path,
    'template' => 'question-link',
    'variables' => array(
      'field_source' => NULL,

  return $items;

Then in sites/all/themes/my_theme/templates/question-link.tpl.php

<?php if($field_source): ?>
  <strong>Source field</strong>
  <div class="question-field-source"><?php print $field_source; ?></div>
<?php endif; ?>

Clear the cache to alert Drupal of the new template file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.