Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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