Closed (fixed)
Project:
Quiz
Version:
7.x-5.x-dev
Component:
Code - Quiz core
Priority:
Critical
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
28 Jul 2008 at 08:37 UTC
Updated:
1 Oct 2019 at 09:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
westwesterson commentedi would welcome any such contributions to do this. In terms of how this would be done technically however, I suspect it is a little bit more complex then that. I haven't tried this, but it might be possible to add a cck field to a question. let me know if this works.
Comment #2
summit commentedSubscribing, interested in getting open/survey questions into a questionnaire.
CCK is biggest favourite for this.
greetings,
Martijn
Comment #3
digitalfreak commentedI am almost there, I got stuck in the part of don't know which function did the Quiz module print those question and are those question in teaser form or full node form?
Moreover, I would like to know $node->body contain everything of the node or just things of the body field? Is there a way I could return all the field available in a custom node so that I can decide what to show and what to not show
My current setup is to use "media field" + "media field display" to get an audio type of question, and the question node work just fine on its own, however, when it is in a quiz, only things in the body field got shown. If I could know which function quiz is printing the question and all the available fields I can print within a node, showing the media field will be trivial.
Comment #4
mbutcher commentedEach question type is responsible for generating its own content during the actual quiz. The quiz module calls hook_render_question() and then displays what is returned.
So mulltichoice_render_question() is the place to start (IIRC, it just calls something like multichoice_render_question_form() or something like that).
To get a really detailed view of how things happen with CCK, you might have to look at CCK itself... maybe in hook_view() or something like that.
I'm very interested in this as well, so please keep updating this ticket. It is officially high priority for Quiz 3 -- I even broke my own rule and marked it as critical to remind myself of this.
Matt
Comment #5
digitalfreak commentedif you want to just add audio and video to the question, you might want to try this http://drupal.org/node/199575#comment-1095603
Comment #6
mbutcher commentedI have just checked in CCK support for Quiz questions. This should be available in the dev snapshots of 6.x-3.x.
THIS IS EXPERIMENTAL -- PLEASE TEST AND REPORT BUGS.
You should now be able to attach CCK fields to a quiz question type (e.g. multichoice or long_answer) and have these fields show up during the quiz.
Doing this required rewriting the question rendering system, so it is likely that my changes have introduced some bugs.
So far, I have only tested with a couple of basic CCK field types (the ones that come with CCK and the ImageField). If you test with others and they break, please report what CCK field type you are using.
(Since this required significant re-coding, the changes will not be backported to 6.x-2.x. However, the upgrade path from 2.x to 3.x should be smooth.)
Comment #7
mbutcher commentedMarking this as fixed. Any bugs should be filed as new issues in the queue.
Comment #9
zet commentedmbutcher , this (You should now be able to attach CCK fields to a quiz question type (e.g. multichoice or long_answer) and have these fields show up during the quiz.) should work in the 7.x-4.x-dev version too ? Cause it's not.
I attached an imagefield in a multichoice question that don't show up during the quiz taking. It does only on the multichoice question own page.
Comment #10
Addiction2Code-1 commentedI'm having the same issue. I've doen all I could with configuration, hopefully someone can provide a fix. Thanks!
Comment #11
aurelien1402 commentedHi,
Exactly the same here, with drupal 7.8 and the last developpement of Quiz (19 september 2011). The question is individually shown with the image (shadowbox and jquery work well), but included in a Quiz, only the question is shown, no more image field. Any idea? By the way, thanks a lot for your amazing project!
Comment #12
falcon commentedComment #13
djroshi commentedI don't really know if this is the same issue as it's a very old thread and apparently this was fixed in 6.x at some point.
Anyway, I found that content fields are not displaying when a user takes a quiz. They appear on the node page, but not on the question answering form. I am using D7 and the latest quiz alpha release, so I have no idea if this is still a missing feature from the dev branch. This is a bit of a deal-breaker for the project I am working on, luckily I was able to quickly find a reasonable approach for implementing this functionality via hook_form_alter.
The code solution below currently needs to be added to a custom module. It is quite a simple solution, rendering all content fields in a single #markup form element. It could easily be extended to put each field in it's own #markup element and use #weight alter the order of the form elements.
Comment #14
michael.eden commentedI can confirm I am also having issues displaying CCK fields in Quiz for Drupal 7. Fields present in node but absent in Quiz.
Comment #15
bmango commented@djroshi - many thanks for posting your code in #13. That is working for me. I had added a Video Embed Field and it is now showing the video on the quiz. However, I'm getting the following error:
Strict warning: Only variables should be passed by reference in template_preprocess_video_embed_field_embed_code() (line 355 of .../sites/all/modules/video_embed_field/video_embed_field.module).
Can you make any suggestions for this or can I ignore it?
Comment #16
mudddy commentedThank you for the code in #13. Worked perfectly for me.
Comment #17
okday commentedHi,
Someone can create a sub-module for this functionality?
thanks
Comment #18
Jimarick commentedHi
I'm having the same problem. I add an image field to a quiz question, and although it shows up if I open the question directly, when the quiz is running and it brings up the question, the image field is missing. I cant believe this function isnt part of the module iteslf? Am I missing something obvious here?
I tried this code above, and pasted it into a new module I created. I then enabled this module, but nothing has changed on the site. (The module is definately loading, as if I mess with the code then the site displays an error!)
Am i doing somehting wrong? The code of my module is:
<?php
/**
* @see
* field_attach_prepare_view
* field_attach_view
* field_view_field
* field_view_value
*/
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
// Alter the quiz question answering form
if ($form_id == 'quiz_question_answering_form') {
if (isset($form['question_nid'])) {
// Load the node object
$node = node_load($form['question_nid']['#value']);
// Remove the node body as this is rendered later anyway
if (isset($node->body)) {
unset($node->body);
}
// Get a renderable array for ALL node fields
$view = field_attach_view('node', $node, 'full');
// Alternatively we could get an individual field or field value
//$view = field_view_field('node', $node, 'field_name');
//$view = field_view_value('node', $node, 'field_name');
// Attach the rendered node to the form as a markup field
$markup = array(
'#markup' => render($view),
);
// In this case we attach the markup at the start of the form array so it is rendered first
// Adding a #weight value to $markup would be more precise
$form = array('field_question_image' => $markup) + $form;
// That's it...
}
}
}
Am I supposed to change the MYMODULE text to something different?
I hope you can help,
James
Comment #19
djroshi commentedYou will need to rename the function above (unless your module is actually called MYMODULE)
Comment #20
djroshi commentedFor convenience I have created a sandbox module here:
http://drupal.org/sandbox/djroshi/1942292
The code therein is an updated version of #13. You will need to click the 'version control' tab and have git installed to download.
Comment #21
leonardo.drupal commented@djroshi Thanks a lot for your module. It works great but I'd like to bring it to your notice that while it works fine with most question types, it breaks the "Cloze" type question , as it displays the actual question and answers, which gives away the answer as shown below
Maybe a small check to see if the question type is cloze and then exclude it might work. Since I am just beginning module development,I've been struggling to find out how to do it.
Nevertheless thanks a lot for your module once again.
Comment #22
nstillblue commentedAny idea how the problem with the Cloze Question-type could be solved?
It's a great module for the other question types, but I need it specifically for a Cloze question.
Comment #23
djroshi commentedI have slightly modified the sandbox module to address the issue with cloze questions, let me know if it works?
http://drupal.org/sandbox/djroshi/1942292
Comment #24
vincent rommelaars commentedHi djroshi,
I've tried your sandbox project and it worked fine for an image field attached to a "Quiz Direction" type.
I also added a media field using Media, Media_field, Media internet sources and Media YouTube to add a YouTube video to the "Quiz Direction" type.
This one isn't showing up with your code.
Have you got any clue on how to solve this one...?
Thanks in advance.
Greetz Vincent
Comment #25
djroshi commentedThere are many potential reasons why this isn't working for you. I would suggest first checking your field display settings. If you are capable of debugging the output of line 22 of the sandbox module
$view = field_attach_view('node', $node, 'full');you could try that. Failing that, you could try embedding the youtube video in the body of the quiz direction.Remember this feature was working in 6.x - sandbox module is a temporary fix until this feature is brought back into 7.x.
Changing status back to active - there is no patch to review here.
Comment #26
vincent rommelaars commentedWhen using print print_r($view); I get the results attached to this reply.
It's all about displaying 'field_video' but I can't seem to get it working...
Any ideas?
Thanks in advance...
Comment #27
seanenroute commentedThe submodule by djroshi worke3d great for images and video but I didn't have any luck putting in a Views Field.
Comment #28
djdevinFixed over in #2268045: How to add image in the question?
There are a lot of sub issues in this issue, but I believe they were all addressed by converting a lot of Quiz things to entities, and also exposing everything to Entity API and the default views controller.