With your help I managed to get the player to be displayed inline. (http://drupal.org/node/1812626)

However I have a difficulty placing the inline player in a multiple choice question in a quizz.

Basically the quiz module works by creating an multiple choice question as a node, and then agregating this questions into quizzes in another node.

Therefore when I view the multiple choice question the player appears ok, but when I view it in a quiz I get an error:
"Notice: Undefined property: stdClass::$field_audio_mcq in eval() (line 2 of /public_html/modules/php/php.module(80) : eval()'d code)."

I believe that this is just because the audiofile is linked with the node of the mcq and not with the node of quiz.

Do you see a way to make it work?

Thank you in advance

Comments

tamerzg’s picture

You could use node_load to load multiple choice question nodes. I am not sure about exact code but something like this:

foreach($nids as $nid) {
  $mcq_node = node_load($nid);
  $audiofile = file_create_url($mcq_node->field_audio_mcq['und'][0]['value']);
  ...
}

Where $nids would be array of multiple choice node nids belonging to this quiz. You could maybe obtain it by looking at Quiz API and their functions or do the mysql query.

tbom’s picture

I tried the following:

I removed from the interface the mcq from the quizz and then I placed the following code in the quizz:

$mcq_node = node_load(36); 
 $audiofile = file_create_url($mcq_node->field_audio_mcq['und'][0]['value']);

36 is the nid of the mcq node (the nid column in the dr_node table).

In the mcq I kept the previous code:
$node=menu_get_object(); $audiofile = file_create_url($node->field_audio_mcq['und'][0]['uri']); $info = pathinfo($audiofile); $op = $info['extension']; print audiofield_get_player($audiofile, $op);

But now when I try to view the quizz I get an error:
Undefined index: value in eval() (line 5 of /public_html/modules/php/php.module(80) : eval()'d code).

Can you please help me find a solution
Thank you

tamerzg’s picture

Sorry my mistake, should be :
$audiofile = file_create_url($mcq_node->field_audio_mcq['und'][0]['uri']);
instead of:
$audiofile = file_create_url($mcq_node->field_audio_mcq['und'][0]['value']);

tbom’s picture

Hi,

I tried the following:

In the quiz page I added:

$mcq_node = node_load(36);
$audiofile = file_create_url($mcq_node->field_audio_mcq['und'][0]['uri']);

and in the mcq page I added

  $node=menu_get_object();
   $info = pathinfo($audiofile);
  $op = $info['extension'];
  print audiofield_get_player($audiofile, $op);

meaning that I removed the file_create_url from the mcq and I added it in the quiz. Is this a mistake? I find it quite strange, that you would create a variable in the main node, and then in the subnode you use the variable... even if it has the same name...

but now I get
Notice: Undefined property: stdClass::$field_audio_mcq in eval() (line 2 of /public_html/modules/php/php.module(80) : eval()'d code).

I guess this is because I haven;t added the field_audio to the quiz in the structure>content types>manage fields

but I'm not sure if this would work.

Thanks