Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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-...
Comment | File | Size | Author |
---|---|---|---|
#13 | quiz-fixed_settings_merge-2212789-13.patch | 1.3 KB | amermod |
#12 | quiz-fixed_settings_merge-2212789-12.patch | 1.31 KB | alx_benjamin |
#11 | quiz-fixed_settings_merge-2212789-11.patch | 1.44 KB | Da_Cloud |
#9 | Screenshot.png | 116.16 KB | Da_Cloud |
#9 | quiz-fixed_settings_merge-2212789-9.patch | 811 bytes | Da_Cloud |
Comments
Comment #1
Jamesap CreditAttribution: Jamesap commentedComment #2
Jamesap CreditAttribution: Jamesap commentedComment #3
Jamesap CreditAttribution: Jamesap commentedAdding patch
Comment #4
Jamesap CreditAttribution: Jamesap commentedPushed to opigno_lms
http://drupalcode.org/project/opigno_lms.git/commit/de26cd3
Comment #5
Jamesap CreditAttribution: Jamesap commentedWrong patch correct one added
Comment #6
Jamesap CreditAttribution: Jamesap commentedReleased in opigno 1.10
Comment #7
Jamesap CreditAttribution: Jamesap commentedAdded patch for h5p quiz branch
Comment #8
falcon CreditAttribution: falcon commentedI think we need to go through this one again and make sure that it also works when the creation form doesn't validate.
Comment #9
Da_Cloud CreditAttribution: Da_Cloud at INDICIA commentedThe 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.
Comment #10
Da_Cloud CreditAttribution: Da_Cloud at INDICIA commentedComment #11
Da_Cloud CreditAttribution: Da_Cloud at INDICIA commentedSeems 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.
Comment #12
alx_benjamin CreditAttribution: alx_benjamin commentedRecreated patch #11 to be run from within quiz module's directory.
Thank you for the patch.
Comment #13
amermod CreditAttribution: amermod at Connect-i commentedUpdated 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.