When taking a quiz, the question type dd_lines does not show the drag and drop question.
There is a javascript error because Drupal.settings.quiz_ddlines does not exist.
Replacing

$form['#attached']['js'][] = array(
'data' => array(
'quiz_ddlines' => $default_settings
),
'type' => 'setting'
);

with

drupal_add_js(array('quiz_ddlines' => $default_settings), 'setting');

Fixed it. Why is the form not setting the js settings?

https://www.opigno.org/en/forum/support/picture-not-displayed-questions-...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jamesap’s picture

Issue summary: View changes
Jamesap’s picture

Title: [1.8] Quiz dd_lines question type render bug » [1.10] Quiz dd_lines question type render bug
Jamesap’s picture

FileSize
936 bytes

Adding patch

Jamesap’s picture

Status: Active » Patch (to be ported)
Jamesap’s picture

FileSize
714 bytes

Wrong patch correct one added

Jamesap’s picture

Status: Patch (to be ported) » Closed (fixed)

Released in opigno 1.10

Jamesap’s picture

Added patch for h5p quiz branch

falcon’s picture

Project: Opigno LMS » Quiz
Version: 7.x-1.x-dev » 7.x-4.x-dev
Component: Code » Code - Quiz core
Status: Closed (fixed) » Active

I think we need to go through this one again and make sure that it also works when the creation form doesn't validate.

Da_Cloud’s picture

The patch from #8 probably has the same result, but it the reason why the form doesn't apply the settings seems to be because the settings get overwritten later on in the flow.

If you look in the quiz_question.module file on line 125 you see the following line
$form = array_merge($quiz_question_form, $form);

The issue here is that the $form also has an #attached key to attach some CSS (see screenshot). The way array_merge works is that if both arrays have the same key the later value will overwrite the previous value. In this case the attached js will be overwritten by the attached css.

There are multiple ways to fix the way these array's are merged together, but I assume that simply using the recursive array_merge function would do the trick without messing up the rest of the code.

Da_Cloud’s picture

Status: Active » Needs review
Da_Cloud’s picture

Seems I was to quick with uploading the above patch as I've forgotten to add one other line to the patch where roughly the same thing happens.

alx_benjamin’s picture

Recreated patch #11 to be run from within quiz module's directory.

Thank you for the patch.

amermod’s picture

Updated the patch. The part that attache the JS file was adding an array inside another array. It's not necessary and creates notices in the log.