mirror of
https://github.com/moodle/moodle.git
synced 2025-04-19 15:32:32 +02:00
MDL-69930 qtype_ddimageortext: Duplication items in drag-onto-image question
This commit is contained in:
parent
aed0ee06f9
commit
dc293a2eb6
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -375,7 +375,7 @@ define(['jquery', 'core/dragdrop', 'core/key_codes'], function($, dragDrop, keys
|
||||
});
|
||||
this.getRoot().find('.draghome.placed.group' + this.getGroup(drag)).not('.beingdragged').each(function(i, dropNode) {
|
||||
var drop = $(dropNode);
|
||||
if (thisQ.isPointInDrop(pageX, pageY, drop)) {
|
||||
if (thisQ.isPointInDrop(pageX, pageY, drop) && !thisQ.isDragSameAsDrop(drag, drop)) {
|
||||
drop.addClass('valid-drag-over-drop');
|
||||
} else {
|
||||
drop.removeClass('valid-drag-over-drop');
|
||||
@ -410,7 +410,7 @@ define(['jquery', 'core/dragdrop', 'core/key_codes'], function($, dragDrop, keys
|
||||
|
||||
root.find('.draghome.placed.group' + this.getGroup(drag)).not('.beingdragged').each(function(i, placedNode) {
|
||||
var placedDrag = $(placedNode);
|
||||
if (!thisQ.isPointInDrop(pageX, pageY, placedDrag)) {
|
||||
if (!thisQ.isPointInDrop(pageX, pageY, placedDrag) || thisQ.isDragSameAsDrop(drag, placedDrag)) {
|
||||
// Not this placed drag.
|
||||
return true;
|
||||
}
|
||||
@ -917,6 +917,17 @@ define(['jquery', 'core/dragdrop', 'core/key_codes'], function($, dragDrop, keys
|
||||
return zIndex;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check that the drag is drop to it's clone.
|
||||
*
|
||||
* @param {jQuery} drag The drag.
|
||||
* @param {jQuery} drop The drop.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
DragDropOntoImageQuestion.prototype.isDragSameAsDrop = function(drag, drop) {
|
||||
return this.getChoice(drag) === this.getChoice(drop) && this.getGroup(drag) === this.getGroup(drop);
|
||||
};
|
||||
|
||||
/**
|
||||
* Singleton object that handles all the DragDropOntoImageQuestions
|
||||
* on the page, and deals with event dispatching.
|
||||
@ -996,6 +1007,8 @@ define(['jquery', 'core/dragdrop', 'core/key_codes'], function($, dragDrop, keys
|
||||
* @param {jQuery} element Element to bind the event
|
||||
*/
|
||||
addEventHandlersToDrag: function(element) {
|
||||
// Unbind all the mousedown and touchstart events to prevent double binding.
|
||||
element.unbind('mousedown touchstart');
|
||||
element.on('mousedown touchstart', questionManager.handleDragStart);
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user