Hello,
I just updated to the V4 quiz module, and for the life of me I cannot customize the layout of the actual question taking page. Where do I need to look for this?
Basically, I have added some additional fields to the quiz multichoice pages. Namely, a video URL that on the answer question page, displays a video player and the video. It is basically a page where people come, watch a video, answer a question about the video them move to the next video/question.
I attempted to use the module contemplate (Content template) to handle the display of the page.
The page is suppose to be divided up into two columns, the video no the left hand side, and the question to the right side of the video.
When I visit the question node through the exact url it works completely fine.
But when accessing the question through the quiz node (/node/%/take), it falls back to the original basic layout.
What do I need to modify to modify the output of these individual fields so that it takes effect on the actual quiz taking page?
Comments
Comment #1
drewbe121212 commentedFinally figured out how to do this.
It turns out, Quiz registers a custom node tpl file in the theme registry.
Create a file quiz-single-question-node.tpl.php in your theme directory. This is the overall layout of the quiz question (all CCK if used, form for answering questions etc).
I really don't like how this does not fall back on the original node.tpl file. That would be the normal expectation out of a standard install.
Comment #2
codevoice commentedHi drewbe121212, this isn't working for me. What are the contents of your quiz-single-question-node.tpl.php file? I have that file (contents copied from node.tpl.php, but any changes have no effect), but it doesn't seem to be working for me. Thanks in advance.
Comment #3
chertzogcould we possibly get this for Drupal 7?
Comment #4
chertzogi was able to get what i needed using context to place blocks, but i would rather have some tpl flies of the question output.
Comment #5
drewbe121212 commentedComment #6
zuernbernhard commentedsame problem here, doesn't work as expected ! quiz-single-question-node.tpl.php in theme directory has no effect
Comment #7
drewbe121212 commentedzuern,
Make sure you clear out your site cache after you have applied the new template file. The theme registry has to be rebuilt and this takes care of it for you.
Also, try including the quiz-single-question-node.tpl.php in the templates directory.
/themes/theme_name/templates/quiz-single-question-node.tpl.php
Comment #8
zuernbernhard commenteddrewbe121212,
thank you ! it works, now. i really forgot the theme registry :( my stupid mistake ...
Comment #9
qwerty1988 commentedhi could you please tell me how to print the variables of the take page as the question number, time etc so that i can render them and use in the theming of the page................
Comment #10
danny englanderSorry to reopen this but I have been struggling with this too. I got my theme to recognize
quiz-single-question-node.tpl.phpbut then what? I printed out the variables as such:<pre><?php var_dump(get_defined_vars()); ?></pre>... and indeed I now see my quiz but with the variable dump. Looking at the variables, I am not sure which ones to use or how to render them with PHP in the normal drupal ways. For example. I tried various incarnations of:
... but none of those worked either after I cleared my cache. Any ideas? Once I figure this out, I'd be happy to add some documentation.
Comment #11
michaelk commentedWe were also running into this issue, and we wanted a better solution than writing a custom template file.
I have attached my patch. The patch is against 7.x-4.x-dev. Please test it out, so it can be committed into the module for the future.
The patch defines a custom "Question" view mode. Then on each question content type you can go to the "Manage Display" tab and edit the question view mode to define what fields should be displayed to the student when they are taking the test. This means that you can now easily display any field to the student as part of the question. This allows you to easily support video and audio questions and other cases where you might want to display extra fields (other than the question body) to the user.
Please note that the patch also includes an database update that makes it so that the default behavior is identical to the current module's implementation of only displaying the question body field when taking the quiz. You must modify the "Question" view mode in order to change the default display.
Thanks!
Comment #12
okday commentedHi,
It is working very well. Is it possible to add an empty line between each field that are displayed on the question page?
This patch must be added to the DEV branch
It’s a very cool feature
Comment #13
michaelk commented@okday
You should be able to just add custom CSS in your theme to make that sort of modification.
Comment #14
okday commentedOK thanks.
Thank you for your patch. it is working very well.
Comment #15
michaelk commentedHere is an updated version of the patch that fixes a bug in the first patch that broke the Quiz feedback after each question setting.
Comment #16
mikran commentedI can see the patch from comment #15 is now committed. Is that intentional? It seemed to break many things.
Comment #17
mikran commentedComment #18
mikran commentedOkay it was rather simple really. I had 'Question:' label displayed twice. Once from field and another one from template. Attached patch sets question label to 'above' and removes hard coded label from template.
The other thing that was broken after latest update was actually related to cloze and I've opened that as a separate issue #2216049: getReportForm() implementation in ClozeResponse is not compatible with latest changes in Quiz.
Comment #23
rairupin commentedHi, applied patch 22 and it works excellent. But I am getting two "Next" buttons in the quiz tab. Can you pls let me know how to correct it. (ref: http://www.edubase.co/node/903/take, uname-kamal, pwd-kamal123)
Comment #25
zuernbernhard commentedCannot find that in 7.x-5.x anymore ? What is the reason ? Forgot to merge or is there another way of heming single Quiz-Questions ?
Comment #26
djdevinSee https://www.drupal.org/node/2427715#comment-9645933
Comment #27
falcon commented