Merge pull request #1713 from crazyserver/MOBILE-2795
MOBILE-2795 qtype: Adapt ddmarker to changes on 3.6main
commit
67b8e94aaa
|
@ -645,7 +645,7 @@ export class AddonQtypeDdMarkerQuestion {
|
||||||
|
|
||||||
// Wait the DOM to be rendered.
|
// Wait the DOM to be rendered.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.pollForImageLoad();
|
this.pollForImageLoad(question.scriptsCode, question.slot);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.resizeFunction = this.redrawDragsAndDrops.bind(this);
|
this.resizeFunction = this.redrawDragsAndDrops.bind(this);
|
||||||
|
@ -706,15 +706,27 @@ export class AddonQtypeDdMarkerQuestion {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait for the background image to be loaded.
|
* Wait for the background image to be loaded.
|
||||||
|
*
|
||||||
|
* @param {string} scriptsCode Scripts code to fetch background image.
|
||||||
|
* @param {number} slot Question number also named slot.
|
||||||
*/
|
*/
|
||||||
pollForImageLoad(): void {
|
pollForImageLoad(scriptsCode?: string, slot?: number): void {
|
||||||
if (this.afterImageLoadDone) {
|
if (this.afterImageLoadDone) {
|
||||||
// Already treated.
|
// Already treated.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bgImg = this.doc.bgImg(),
|
const bgImg = this.doc.bgImg();
|
||||||
imgLoaded = (): void => {
|
|
||||||
|
if (scriptsCode && !bgImg.src) {
|
||||||
|
const regExp = RegExp('amd\\.init\\("q' + slot + '",[ ]*"([^"]*)"', 'g'),
|
||||||
|
match = regExp.exec(scriptsCode);
|
||||||
|
if (match && match.length > 1) {
|
||||||
|
bgImg.src = match[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const imgLoaded = (): void => {
|
||||||
bgImg.removeEventListener('load', imgLoaded);
|
bgImg.removeEventListener('load', imgLoaded);
|
||||||
|
|
||||||
this.makeImageDropable();
|
this.makeImageDropable();
|
||||||
|
@ -787,7 +799,7 @@ export class AddonQtypeDdMarkerQuestion {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-draw drop zones.
|
// Re-draw drop zones.
|
||||||
if (this.dropZones.length !== 0) {
|
if (this.dropZones && this.dropZones.length !== 0) {
|
||||||
this.graphics.clear();
|
this.graphics.clear();
|
||||||
this.restartColours();
|
this.restartColours();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
// Style ddmarker content a bit. Almost all these styles are copied from Moodle.
|
// Style ddmarker content a bit. Almost all these styles are copied from Moodle.
|
||||||
addon-qtype-ddmarker {
|
addon-qtype-ddmarker {
|
||||||
|
.ddarea, .ddform {
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
.qtext {
|
.qtext {
|
||||||
margin-bottom: 0.5em;
|
margin-bottom: 0.5em;
|
||||||
display: block;
|
display: block;
|
||||||
|
|
Loading…
Reference in New Issue