forked from EVOgeek/Vmeda.Online
		
	MOBILE-2795 qtype: Adapt ddmarker to changes on 3.6
This commit is contained in:
		
							parent
							
								
									b55ca46c4c
								
							
						
					
					
						commit
						108d0cb3be
					
				@ -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,26 +706,38 @@ 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 => {
 | 
					 | 
				
			||||||
                bgImg.removeEventListener('load', imgLoaded);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                this.makeImageDropable();
 | 
					        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];
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                setTimeout(() => {
 | 
					        const imgLoaded = (): void => {
 | 
				
			||||||
                    this.redrawDragsAndDrops();
 | 
					            bgImg.removeEventListener('load', imgLoaded);
 | 
				
			||||||
                });
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                this.afterImageLoadDone = true;
 | 
					            this.makeImageDropable();
 | 
				
			||||||
                this.question.loaded = true;
 | 
					
 | 
				
			||||||
            };
 | 
					            setTimeout(() => {
 | 
				
			||||||
 | 
					                this.redrawDragsAndDrops();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            this.afterImageLoadDone = true;
 | 
				
			||||||
 | 
					            this.question.loaded = true;
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        bgImg.addEventListener('load', imgLoaded);
 | 
					        bgImg.addEventListener('load', imgLoaded);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user