4

I´m trying to theme my quizzes, but even when I did manage to theme the quiz nodetype (node--quiz.tpl), that template is gone after the "take the quiz" button is clicked.

I´ve tried theming the multichoice-answering-form.tpl (as my questions are all of the multichoice type), but nothing happens.

I´ve checked the quiz module and haven´t found a default template according to this need. Or maybe I´m missing something?

I´ve tried creating the template quiz-single-question-node.tpl, it seems that even when it is "taken" the content isn´t correct, because I get an undefined variable error.

This is what I´ve try into that template, and didn´t worked out:

print drupal_render($form);
print render($form);
print render($content);

Whith any of the three options I get the same undefined variable error.

Any help will be very much appreciated. Thanks!!

2
  • Have you looked into using CSS and/or jQuery?
    – user785179
    Commented Jan 18, 2013 at 21:21
  • 1
    jaypan.com/tutorial/… <-- This is a tutorial for theming of forms. Quizzes are a special case of forms, so this may help you.
    – beth
    Commented Jan 18, 2013 at 21:37

1 Answer 1

4

There are different templates that you could use to theme the quiz.

1) page--node--take.tpl.php this would take care of the basic page level template for all the nodes with the url of the form node/nid/take

2) node--quiz.tpl.php this would be used for the quiz page.

3) quiz-single-question-node.tpl as you guessed this is the one for the single page quiz node. there is one variable in that $question_node

<?php print drupal_render($question_node->content['body']);?> 

that would render the quiz form on each of the quiz node. so this could be used to add additional things to the quiz node like a footer with instruction or things like that.

4) theme_quiz_question_navigation_form function is the place were the navigation buttons are rendered so you could either over ride it in your theme or create a template file. the variable would be $form.

5) multichoice-answering-form.tpl.php this tpl contains the part of the form other than the buttons in the multichoice question type. this has got a variable called $form. you can make the required changes and then render the same in the tpl with something like print drupal_render($form);

Or the above can also be done using the form_alter function with in a module or theme. the form ID to use would be quiz_question_answering_form

There are many other template and theme functions with in the quiz module to change the look and feel of quiz for example to change the design of the result page you have quiz-report-form.tpl.php

If you go through the files and functions of the quiz module you would see many other templates and theme functions.

1
  • Thank you Mohammed! Your very detailed explanation should be at the quiz docs!
    – Rosamunda
    Commented Jan 19, 2013 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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