MOBILE-3426 scorm: Avoid using relative sizes
parent
da93462af1
commit
18f4153c01
|
@ -13,7 +13,7 @@
|
||||||
<ion-content>
|
<ion-content>
|
||||||
<core-loading [hideUntil]="loaded">
|
<core-loading [hideUntil]="loaded">
|
||||||
<core-navigation-bar [previous]="previousSco" [next]="nextSco" (action)="loadSco($event)"></core-navigation-bar>
|
<core-navigation-bar [previous]="previousSco" [next]="nextSco" (action)="loadSco($event)"></core-navigation-bar>
|
||||||
<core-iframe *ngIf="loaded && src" [src]="src" [iframeWidth]="scorm.popup ? scorm.width : undefined" [iframeHeight]="scorm.popup ? scorm.height : undefined"></core-iframe>
|
<core-iframe *ngIf="loaded && src" [src]="src" [iframeWidth]="scormWidth" [iframeHeight]="scormHeight"></core-iframe>
|
||||||
<p *ngIf="!src && errorMessage">{{ errorMessage | translate }}</p>
|
<p *ngIf="!src && errorMessage">{{ errorMessage | translate }}</p>
|
||||||
</core-loading>
|
</core-loading>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { IonicPage, NavParams, ModalController } from 'ionic-angular';
|
||||||
import { CoreEventsProvider } from '@providers/events';
|
import { CoreEventsProvider } from '@providers/events';
|
||||||
import { CoreSitesProvider } from '@providers/sites';
|
import { CoreSitesProvider } from '@providers/sites';
|
||||||
import { CoreSyncProvider } from '@providers/sync';
|
import { CoreSyncProvider } from '@providers/sync';
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
import { CoreDomUtils } from '@providers/utils/dom';
|
||||||
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
import { CoreTimeUtilsProvider } from '@providers/utils/time';
|
||||||
import { CoreIonTabsComponent } from '@components/ion-tabs/ion-tabs';
|
import { CoreIonTabsComponent } from '@components/ion-tabs/ion-tabs';
|
||||||
import { AddonModScormProvider, AddonModScormAttemptCountResult } from '../../providers/scorm';
|
import { AddonModScormProvider, AddonModScormAttemptCountResult } from '../../providers/scorm';
|
||||||
|
@ -46,6 +46,8 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
|
||||||
src: string; // Iframe src.
|
src: string; // Iframe src.
|
||||||
errorMessage: string; // Error message.
|
errorMessage: string; // Error message.
|
||||||
accessInfo: any; // Access information.
|
accessInfo: any; // Access information.
|
||||||
|
scormWidth: null; // Width applied to scorm iframe.
|
||||||
|
scormHeight: null; // Height applied to scorm iframe.
|
||||||
|
|
||||||
protected siteId: string;
|
protected siteId: string;
|
||||||
protected mode: string; // Mode to play the SCORM.
|
protected mode: string; // Mode to play the SCORM.
|
||||||
|
@ -65,11 +67,18 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
|
||||||
protected launchPrevObserver: any;
|
protected launchPrevObserver: any;
|
||||||
protected goOfflineObserver: any;
|
protected goOfflineObserver: any;
|
||||||
|
|
||||||
constructor(navParams: NavParams, protected modalCtrl: ModalController, protected eventsProvider: CoreEventsProvider,
|
constructor(
|
||||||
protected sitesProvider: CoreSitesProvider, protected syncProvider: CoreSyncProvider,
|
navParams: NavParams,
|
||||||
protected domUtils: CoreDomUtilsProvider, protected timeUtils: CoreTimeUtilsProvider,
|
protected modalCtrl: ModalController,
|
||||||
protected scormProvider: AddonModScormProvider, protected scormHelper: AddonModScormHelperProvider,
|
protected eventsProvider: CoreEventsProvider,
|
||||||
protected scormSyncProvider: AddonModScormSyncProvider, protected tabs: CoreIonTabsComponent) {
|
protected sitesProvider: CoreSitesProvider,
|
||||||
|
protected syncProvider: CoreSyncProvider,
|
||||||
|
protected timeUtils: CoreTimeUtilsProvider,
|
||||||
|
protected scormProvider: AddonModScormProvider,
|
||||||
|
protected scormHelper: AddonModScormHelperProvider,
|
||||||
|
protected scormSyncProvider: AddonModScormSyncProvider,
|
||||||
|
protected tabs: CoreIonTabsComponent
|
||||||
|
) {
|
||||||
|
|
||||||
this.scorm = navParams.get('scorm') || {};
|
this.scorm = navParams.get('scorm') || {};
|
||||||
this.mode = navParams.get('mode') || AddonModScormProvider.MODENORMAL;
|
this.mode = navParams.get('mode') || AddonModScormProvider.MODENORMAL;
|
||||||
|
@ -95,12 +104,14 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
|
||||||
if (this.scorm.popup) {
|
if (this.scorm.popup) {
|
||||||
this.tabs.changeVisibility(false);
|
this.tabs.changeVisibility(false);
|
||||||
|
|
||||||
// If we receive a value <= 100 we need to assume it's a percentage.
|
// If we receive a value > 100 we assume it's a fixed pixel size.
|
||||||
if (this.scorm.width <= 100) {
|
if (this.scorm.width > 100) {
|
||||||
this.scorm.width = this.scorm.width + '%';
|
this.scormWidth = this.scorm.width;
|
||||||
}
|
|
||||||
if (this.scorm.height <= 100) {
|
// Only get fixed size on height if width is also fixed.
|
||||||
this.scorm.height = this.scorm.height + '%';
|
if (this.scorm.height > 100) {
|
||||||
|
this.scormHeight = this.scorm.height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +122,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
|
||||||
const promise = this.newAttempt ? this.setStartTime(this.currentSco.id) : Promise.resolve();
|
const promise = this.newAttempt ? this.setStartTime(this.currentSco.id) : Promise.resolve();
|
||||||
|
|
||||||
return promise.catch((error) => {
|
return promise.catch((error) => {
|
||||||
this.domUtils.showErrorModalDefault(error, 'addon.mod_scorm.errorgetscorm', true);
|
CoreDomUtils.instance.showErrorModalDefault(error, 'addon.mod_scorm.errorgetscorm', true);
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
// Load SCO.
|
// Load SCO.
|
||||||
this.loadSco(this.currentSco);
|
this.loadSco(this.currentSco);
|
||||||
|
@ -152,7 +163,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
|
||||||
// Wait a bit to prevent collisions between this store and SCORM API's store.
|
// Wait a bit to prevent collisions between this store and SCORM API's store.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.scormHelper.convertAttemptToOffline(this.scorm, this.attempt).catch((error) => {
|
this.scormHelper.convertAttemptToOffline(this.scorm, this.attempt).catch((error) => {
|
||||||
this.domUtils.showErrorModalDefault(error, 'core.error', true);
|
CoreDomUtils.instance.showErrorModalDefault(error, 'core.error', true);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.refreshToc();
|
this.refreshToc();
|
||||||
});
|
});
|
||||||
|
@ -248,7 +259,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
|
||||||
return Promise.all(promises);
|
return Promise.all(promises);
|
||||||
});
|
});
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.domUtils.showErrorModalDefault(error, 'addon.mod_scorm.errorgetscorm', true);
|
CoreDomUtils.instance.showErrorModalDefault(error, 'addon.mod_scorm.errorgetscorm', true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -372,7 +383,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
return this.scormProvider.saveTracks(sco.id, this.attempt, tracks, this.scorm, true);
|
return this.scormProvider.saveTracks(sco.id, this.attempt, tracks, this.scorm, true);
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.domUtils.showErrorModalDefault(error, 'core.error', true);
|
CoreDomUtils.instance.showErrorModalDefault(error, 'core.error', true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -432,7 +443,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return this.fetchToc();
|
return this.fetchToc();
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
this.domUtils.showErrorModalDefault(error, 'addon.mod_scorm.errorgetscorm', true);
|
CoreDomUtils.instance.showErrorModalDefault(error, 'addon.mod_scorm.errorgetscorm', true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue