From 86939ff82e0ea43374eace393dd41db250d39a14 Mon Sep 17 00:00:00 2001 From: Matheus Zych Date: Wed, 14 Jan 2026 11:37:09 +0100 Subject: [PATCH] =?UTF-8?q?Fixes=20weird=20behavior=20when=20multi?= =?UTF-8?q?=E2=80=91selecting=20in=20matching=20questions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ILIAS/TestQuestionPool/resources/js/dist/matching.js | 2 +- .../ILIAS/TestQuestionPool/resources/js/src/makeDraggable.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/ILIAS/TestQuestionPool/resources/js/dist/matching.js b/components/ILIAS/TestQuestionPool/resources/js/dist/matching.js index cb03bf4bc3ec..45bf74caa79c 100644 --- a/components/ILIAS/TestQuestionPool/resources/js/dist/matching.js +++ b/components/ILIAS/TestQuestionPool/resources/js/dist/matching.js @@ -12,4 +12,4 @@ * https://www.ilias.de * https://github.com/ILIAS-eLearning */ -!function(e){"use strict";const t="1:1",n="n:n",o="source_area",s="ilMatchingQuestionTerm",c="c-test__definition",l="c-test__term",i="c-test__dropzone";function r(e,t,c,l){l===n&&function(e,t,n){n.parentNode.classList.contains(s)&&n.remove(),t.parentNode.classList.contains(o)&&e.remove()}(e,t,c)}function a(e,n,o){e.querySelectorAll(`.${s}`).forEach((e=>{n!==t?function(e,t){null!==e.firstElementChild&&e.lastElementChild.classList.contains(i)||e.append(t.cloneNode())}(e,o):function(e,t){const n=e.firstElementChild;null!==n?n.classList.contains(l)&&null!==n.nextElementSibling&&n.nextElementSibling.remove():e.prepend(t.cloneNode())}(e,o)}))}function d(e,t,n,l,i){!function(e,t,n){const l=e.dataset;if(!n.classList.contains(o)){const e=n.closest(`.${c}`).querySelector("input"),t=JSON.parse(e.value),o=t.indexOf(l.id);o>-1&&t.splice(o,1),e.value=JSON.stringify(t)}if(t.parentNode.classList.contains(s)){const e=t.closest(`.${c}`),n=JSON.parse(e.querySelector("input").value);n.push(l.id),e.querySelector("input").value=JSON.stringify(n)}}(e,t,l),r(e,t,n,i)}function u(e,c,r){const u=function(e){const t=e.querySelectorAll(`.${l}`);let n=0;return t.forEach((e=>{e.offsetHeight{e.style.height=`${t.item(0).offsetHeight}px`})),e.querySelector(`.${i}`)}(e);c(r===t?"move":"copy",e,l,i,((e,t,n,o)=>{d(e,t,n,o,r)}),(t=>{!function(e,t,c,l){a(t,c,l);const r=t.querySelector(`.${o}`);null!==r.firstElementChild&&r.firstElementChild.classList.contains(i)||r.prepend(l.cloneNode()),e.parentNode.querySelectorAll(`.${i}`).forEach((e=>{e.remove()})),c===n&&t.querySelectorAll(`.${s}`).forEach((t=>{null!==t.lastElementChild&&t.lastElementChild.classList.contains(i)||t.append(l.cloneNode()),null!==t.querySelector(`[data-id='${e.dataset.id}']`)&&t.querySelector(`.${i}`)?.remove()}))}(t,e,r,u)}))}const f="c-test__dropzone--active",h="c-test__dropzone--hover";function v(e,t,n,o,s,c){let l,i,r;function a(t){setTimeout((()=>{u(t.target),t.dataTransfer.dropEffect=e,t.dataTransfer.effectAllowed=e,t.dataTransfer.setDragImage(r,0,0)}),0)}function d(e){e.preventDefault(),e.stopPropagation(),u(e.target.closest(`.${n}`));const t=r.offsetWidth,o=r.offsetHeight;l=r.cloneNode(!0),r.parentNode.insertBefore(l,r),r.style.position="fixed",r.style.left=e.touches[0].clientX-t/2+"px",r.style.top=e.touches[0].clientY-o/2+"px",r.style.width=`${t}px`,r.style.height=`${o}px`,r.addEventListener("touchmove",v),r.addEventListener("touchend",L)}function u(e){r=e,r.style.opacity=.5,c(r),t.querySelectorAll(`.${o}`).forEach((e=>{q(e),e.classList.add(f)})),r.querySelectorAll(`.${o}`).forEach((e=>{e.classList.remove(f)}))}function v(e){e.preventDefault(),r.style.left=e.touches[0].clientX-r.offsetWidth/2+"px",r.style.top=e.touches[0].clientY-r.offsetHeight/2+"px";const{documentElement:n}=t.ownerDocument;e.touches[0].clientY>.8*n.clientHeight&&n.scroll({left:0,top:.8*e.touches[0].pageY,behavior:"smooth"}),e.touches[0].clientY<.2*n.clientHeight&&n.scroll({left:0,top:.8*e.touches[0].pageY,behavior:"smooth"});const s=t.ownerDocument.elementsFromPoint(e.changedTouches[0].clientX,e.changedTouches[0].clientY).filter((e=>e.classList.contains(o)));0===s.length&&void 0!==i&&(i.classList.remove(h),i=void 0),1===s.length&&i!==s[0]&&(void 0!==i&&i.classList.remove(h),[i]=s,i.classList.add(h))}function p(e){e.preventDefault()}function m(e){e.target.classList.add(h)}function g(e){e.target.classList.remove(h)}function E(){r.removeAttribute("style"),t.querySelectorAll(`.${o}`).forEach((e=>{e.classList.remove(f),e.classList.remove(h)}))}function y(e){e.preventDefault(),S(e.target)}function L(e){e.preventDefault();const n=t.ownerDocument.elementsFromPoint(e.changedTouches[0].clientX,e.changedTouches[0].clientY).filter((e=>e.classList.contains(o)));E(),l.remove(),1===n.length&&S(n[0])}function S(t){const n=r.parentNode;let o=r;"move"!==e&&(o=r.cloneNode(!0),o.style.opacity=null,$(o)),t.parentNode.insertBefore(o,t),s(o,t,r,n)}function $(e){e.addEventListener("dragstart",a),e.addEventListener("dragend",E),e.addEventListener("touchstart",d)}function q(e){e.removeEventListener("dragover",p),e.removeEventListener("dragenter",m),e.removeEventListener("dragleave",g),e.removeEventListener("drop",y),e.addEventListener("dragover",p),e.addEventListener("dragenter",m),e.addEventListener("dragleave",g),e.addEventListener("drop",y)}t.querySelectorAll(`.${n}`).forEach($),t.querySelectorAll(`.${o}`).forEach(q)}e.test=e.test||{},e.test.matching=e.test.matching||{},e.test.matching.init=(e,t)=>u(e,v,t)}(il); +!function(e){"use strict";const t="1:1",n="n:n",o="source_area",s="ilMatchingQuestionTerm",c="c-test__definition",l="c-test__term",i="c-test__dropzone";function r(e,t,c,l){l===n&&function(e,t,n){n.parentNode.classList.contains(s)&&n.remove(),t.parentNode.classList.contains(o)&&e.remove()}(e,t,c)}function a(e,n,o){e.querySelectorAll(`.${s}`).forEach((e=>{n!==t?function(e,t){null!==e.firstElementChild&&e.lastElementChild.classList.contains(i)||e.append(t.cloneNode())}(e,o):function(e,t){const n=e.firstElementChild;null!==n?n.classList.contains(l)&&null!==n.nextElementSibling&&n.nextElementSibling.remove():e.prepend(t.cloneNode())}(e,o)}))}function d(e,t,n,l,i){!function(e,t,n){const l=e.dataset;if(!n.classList.contains(o)){const e=n.closest(`.${c}`).querySelector("input"),t=JSON.parse(e.value),o=t.indexOf(l.id);o>-1&&t.splice(o,1),e.value=JSON.stringify(t)}if(t.parentNode.classList.contains(s)){const e=t.closest(`.${c}`),n=JSON.parse(e.querySelector("input").value);n.push(l.id),e.querySelector("input").value=JSON.stringify(n)}}(e,t,l),r(e,t,n,i)}function u(e,c,r){const u=function(e){const t=e.querySelectorAll(`.${l}`);let n=0;return t.forEach((e=>{e.offsetHeight{e.style.height=`${t.item(0).offsetHeight}px`})),e.querySelector(`.${i}`)}(e);c(r===t?"move":"copy",e,l,i,((e,t,n,o)=>{d(e,t,n,o,r)}),(t=>{!function(e,t,c,l){a(t,c,l);const r=t.querySelector(`.${o}`);null!==r.firstElementChild&&r.firstElementChild.classList.contains(i)||r.prepend(l.cloneNode()),e.parentNode.querySelectorAll(`.${i}`).forEach((e=>{e.remove()})),c===n&&t.querySelectorAll(`.${s}`).forEach((t=>{null!==t.lastElementChild&&t.lastElementChild.classList.contains(i)||t.append(l.cloneNode()),null!==t.querySelector(`[data-id='${e.dataset.id}']`)&&t.querySelector(`.${i}`)?.remove()}))}(t,e,r,u)}))}const f="c-test__dropzone--active",h="c-test__dropzone--hover";function v(e,t,n,o,s,c){let l,i,r;function a(t){setTimeout((()=>{u(t.target),t.dataTransfer.dropEffect=e,t.dataTransfer.effectAllowed=e,t.dataTransfer.setDragImage(r,0,0)}),0)}function d(e){e.preventDefault(),e.stopPropagation(),u(e.target.closest(`.${n}`));const t=r.offsetWidth,o=r.offsetHeight;l=r.cloneNode(!0),r.parentNode.insertBefore(l,r),r.style.position="fixed",r.style.left=e.touches[0].clientX-t/2+"px",r.style.top=e.touches[0].clientY-o/2+"px",r.style.width=`${t}px`,r.style.height=`${o}px`,r.addEventListener("touchmove",v),r.addEventListener("touchend",L)}function u(e){e.draggable&&(r=e,r.style.opacity=.5,c(r),t.querySelectorAll(`.${o}`).forEach((e=>{q(e),e.classList.add(f)})),r.querySelectorAll(`.${o}`).forEach((e=>{e.classList.remove(f)})))}function v(e){e.preventDefault(),r.style.left=e.touches[0].clientX-r.offsetWidth/2+"px",r.style.top=e.touches[0].clientY-r.offsetHeight/2+"px";const{documentElement:n}=t.ownerDocument;e.touches[0].clientY>.8*n.clientHeight&&n.scroll({left:0,top:.8*e.touches[0].pageY,behavior:"smooth"}),e.touches[0].clientY<.2*n.clientHeight&&n.scroll({left:0,top:.8*e.touches[0].pageY,behavior:"smooth"});const s=t.ownerDocument.elementsFromPoint(e.changedTouches[0].clientX,e.changedTouches[0].clientY).filter((e=>e.classList.contains(o)));0===s.length&&void 0!==i&&(i.classList.remove(h),i=void 0),1===s.length&&i!==s[0]&&(void 0!==i&&i.classList.remove(h),[i]=s,i.classList.add(h))}function p(e){e.preventDefault()}function m(e){e.target.classList.add(h)}function g(e){e.target.classList.remove(h)}function E(){r.removeAttribute("style"),t.querySelectorAll(`.${o}`).forEach((e=>{e.classList.remove(f),e.classList.remove(h)}))}function y(e){e.preventDefault(),S(e.target)}function L(e){e.preventDefault();const n=t.ownerDocument.elementsFromPoint(e.changedTouches[0].clientX,e.changedTouches[0].clientY).filter((e=>e.classList.contains(o)));E(),l.remove(),1===n.length&&S(n[0])}function S(t){const n=r.parentNode;let o=r;"move"!==e&&(o=r.cloneNode(!0),o.style.opacity=null,$(o)),t.parentNode.insertBefore(o,t),s(o,t,r,n)}function $(e){e.addEventListener("dragstart",a),e.addEventListener("dragend",E),e.addEventListener("touchstart",d)}function q(e){e.removeEventListener("dragover",p),e.removeEventListener("dragenter",m),e.removeEventListener("dragleave",g),e.removeEventListener("drop",y),e.addEventListener("dragover",p),e.addEventListener("dragenter",m),e.addEventListener("dragleave",g),e.addEventListener("drop",y)}t.querySelectorAll(`.${n}`).forEach($),t.querySelectorAll(`.${o}`).forEach(q)}e.test=e.test||{},e.test.matching=e.test.matching||{},e.test.matching.init=(e,t)=>u(e,v,t)}(il); diff --git a/components/ILIAS/TestQuestionPool/resources/js/src/makeDraggable.js b/components/ILIAS/TestQuestionPool/resources/js/src/makeDraggable.js index 994d8106347f..59de6bb799ec 100644 --- a/components/ILIAS/TestQuestionPool/resources/js/src/makeDraggable.js +++ b/components/ILIAS/TestQuestionPool/resources/js/src/makeDraggable.js @@ -91,6 +91,10 @@ export default function makeDraggable( * @returns {void} */ function startMoving(target) { + if (!target.draggable) { + return; + } + draggedElement = target; draggedElement.style.opacity = 0.5;