MDL-70112 drag-drop qtypes: fix form preview
authorTim Hunt <T.J.Hunt@open.ac.uk>
Tue, 3 Nov 2020 21:25:51 +0000 (21:25 +0000)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Tue, 3 Nov 2020 21:36:00 +0000 (21:36 +0000)
question/type/ddimageortext/amd/build/form.min.js
question/type/ddimageortext/amd/build/form.min.js.map
question/type/ddimageortext/amd/src/form.js
question/type/ddmarker/amd/build/form.min.js
question/type/ddmarker/amd/build/form.min.js.map
question/type/ddmarker/amd/src/form.js
question/type/edit_question_form.php

index 1753414..f963ee6 100644 (file)
Binary files a/question/type/ddimageortext/amd/build/form.min.js and b/question/type/ddimageortext/amd/build/form.min.js differ
index 1e6304f..bced8d5 100644 (file)
Binary files a/question/type/ddimageortext/amd/build/form.min.js.map and b/question/type/ddimageortext/amd/build/form.min.js.map differ
index 6147e6b..1e0c80f 100644 (file)
@@ -82,7 +82,7 @@ define(['jquery', 'core/dragdrop'], function($, dragDrop) {
             // From now on, when a new file gets loaded into the filepicker, update the preview.
             // This is not in the setupEventHandlers section as it needs to be delayed until
             // after filepicker's javascript has finished.
-            $('form.mform').on('change', '.filepickerhidden', function() {
+            $('form.mform[data-qtype="ddimageortext"]').on('change', '.filepickerhidden', function() {
                 M.util.js_pending('dragDropToImageForm');
                 dragDropToImageForm.loadPreviewImage();
             });
@@ -428,7 +428,7 @@ define(['jquery', 'core/dragdrop'], function($, dragDrop) {
             },
 
             getEl: function(name, indexes) {
-                var form = $('form.mform')[0];
+                var form = $('form.mform[data-qtype="ddimageortext"]')[0];
                 return form.elements[this.toNameWithIndex(name, indexes)];
             },
 
@@ -479,7 +479,7 @@ define(['jquery', 'core/dragdrop'], function($, dragDrop) {
             if (draftItemIdsToName === undefined) {
                 draftItemIdsToName = {};
                 nameToParentNode = {};
-                var fp = $('form.mform input.filepickerhidden');
+                var fp = $('form.mform[data-qtype="ddimageortext"] input.filepickerhidden');
                 fp.each(function(index, filepicker) {
                     draftItemIdsToName[filepicker.value] = filepicker.name;
                     nameToParentNode[filepicker.name] = filepicker.parentNode;
index edf1402..ef09d2c 100644 (file)
Binary files a/question/type/ddmarker/amd/build/form.min.js and b/question/type/ddmarker/amd/build/form.min.js differ
index a8ed51d..8a99a09 100644 (file)
Binary files a/question/type/ddmarker/amd/build/form.min.js.map and b/question/type/ddmarker/amd/build/form.min.js.map differ
index d8f61b2..a06e0b8 100644 (file)
@@ -554,7 +554,7 @@ define(['jquery', 'core/dragdrop', 'qtype_ddmarker/shapes'], function($, dragDro
             // From now on, when a new file gets loaded into the filepicker, update the preview.
             // This is not in the setupEventHandlers section as it needs to be delayed until
             // after filepicker's javascript has finished.
-            $('form.mform').on('change', '#id_bgimage', dragDropForm.loadPreviewImage);
+            $('form.mform[data-qtype="ddmarker"]').on('change', '#id_bgimage', dragDropForm.loadPreviewImage);
 
             dragDropForm.loadPreviewImage();
         },
@@ -645,7 +645,7 @@ define(['jquery', 'core/dragdrop', 'qtype_ddmarker/shapes'], function($, dragDro
             },
 
             getEl: function(name, indexes) {
-                var form = $('form.mform')[0];
+                var form = $('form.mform[data-qtype="ddmarker"]')[0];
                 return form.elements[this.toNameWithIndex(name, indexes)];
             },
 
index 735615a..3bf44cb 100644 (file)
@@ -110,7 +110,7 @@ abstract class question_edit_form extends question_wizard_form {
         $this->category = $category;
         $this->categorycontext = context::instance_by_id($category->contextid);
 
-        parent::__construct($submiturl, null, 'post', '', null, $formeditable);
+        parent::__construct($submiturl, null, 'post', '', ['data-qtype' => $this->qtype()], $formeditable);
     }
 
     /**