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

drewbe121212’s picture

Finally 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.

codevoice’s picture

Hi 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.

chertzog’s picture

Version: 6.x-4.x-dev » 7.x-4.x-dev

could we possibly get this for Drupal 7?

chertzog’s picture

i was able to get what i needed using context to place blocks, but i would rather have some tpl flies of the question output.

drewbe121212’s picture

Status: Active » Closed (works as designed)
zuernbernhard’s picture

Status: Closed (works as designed) » Needs work

same problem here, doesn't work as expected ! quiz-single-question-node.tpl.php in theme directory has no effect

drewbe121212’s picture

zuern,

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

zuernbernhard’s picture

Status: Needs work » Closed (works as designed)

drewbe121212,

thank you ! it works, now. i really forgot the theme registry :( my stupid mistake ...

qwerty1988’s picture

hi 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................

danny englander’s picture

Status: Closed (works as designed) » Needs work

Sorry to reopen this but I have been struggling with this too. I got my theme to recognize quiz-single-question-node.tpl.php but 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:

<?php print $body; ?>
<?php print render($fields['body']); ?>
<?php print $question_number; ?>
<?php print render($question_number); ?>

... 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.

michaelk’s picture

Status: Needs work » Needs review
StatusFileSize
new5.42 KB

We 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!

okday’s picture

Hi,

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

michaelk’s picture

@okday

You should be able to just add custom CSS in your theme to make that sort of modification.

okday’s picture

OK thanks.

Thank you for your patch. it is working very well.

michaelk’s picture

Here is an updated version of the patch that fixes a bug in the first patch that broke the Quiz feedback after each question setting.

mikran’s picture

Issue summary: View changes
Status: Needs review » Needs work

I can see the patch from comment #15 is now committed. Is that intentional? It seemed to break many things.

mikran’s picture

Category: Support request » Feature request
mikran’s picture

Status: Needs work » Needs review
StatusFileSize
new1.21 KB

Okay 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.

  • Commit ed73c83 on 7.x-4.x, 7.x-5.x authored by michaelk, committed by paalj:
    Issue #1120016: Customizing look and feel of take page
    

  • Commit ed73c83 on 7.x-4.x, 7.x-5.x, quiz-pages authored by michaelk, committed by paalj:
    Issue #1120016: Customizing look and feel of take page
    

  • Commit ed73c83 on 7.x-4.x, 7.x-5.x, quiz-pages, 2269219 authored by michaelk, committed by paalj:
    Issue #1120016: Customizing look and feel of take page
    

  • Commit ed73c83 on 7.x-4.x, 7.x-5.x, 2269219 authored by michaelk, committed by paalj:
    Issue #1120016: Customizing look and feel of take page
    
rairupin’s picture

Hi, 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)

  • paalj committed ed73c83 on 7.x-6.x authored by michaelk
    Issue #1120016: Customizing look and feel of take page
    
zuernbernhard’s picture

Cannot 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 ?

djdevin’s picture

falcon’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.