MOBILE-3426 scorm: Avoid using relative sizes

main
Pau Ferrer Ocaña 2020-07-14 12:35:43 +02:00
parent da93462af1
commit 18f4153c01
2 changed files with 29 additions and 18 deletions

View File

@ -13,7 +13,7 @@
<ion-content>
<core-loading [hideUntil]="loaded">
<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>
</core-loading>
</ion-content>

View File

@ -17,7 +17,7 @@ import { IonicPage, NavParams, ModalController } from 'ionic-angular';
import { CoreEventsProvider } from '@providers/events';
import { CoreSitesProvider } from '@providers/sites';
import { CoreSyncProvider } from '@providers/sync';
import { CoreDomUtilsProvider } from '@providers/utils/dom';
import { CoreDomUtils } from '@providers/utils/dom';
import { CoreTimeUtilsProvider } from '@providers/utils/time';
import { CoreIonTabsComponent } from '@components/ion-tabs/ion-tabs';
import { AddonModScormProvider, AddonModScormAttemptCountResult } from '../../providers/scorm';
@ -46,6 +46,8 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
src: string; // Iframe src.
errorMessage: string; // Error message.
accessInfo: any; // Access information.
scormWidth: null; // Width applied to scorm iframe.
scormHeight: null; // Height applied to scorm iframe.
protected siteId: string;
protected mode: string; // Mode to play the SCORM.
@ -65,11 +67,18 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
protected launchPrevObserver: any;
protected goOfflineObserver: any;
constructor(navParams: NavParams, protected modalCtrl: ModalController, protected eventsProvider: CoreEventsProvider,
protected sitesProvider: CoreSitesProvider, protected syncProvider: CoreSyncProvider,
protected domUtils: CoreDomUtilsProvider, protected timeUtils: CoreTimeUtilsProvider,
protected scormProvider: AddonModScormProvider, protected scormHelper: AddonModScormHelperProvider,
protected scormSyncProvider: AddonModScormSyncProvider, protected tabs: CoreIonTabsComponent) {
constructor(
navParams: NavParams,
protected modalCtrl: ModalController,
protected eventsProvider: CoreEventsProvider,
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.mode = navParams.get('mode') || AddonModScormProvider.MODENORMAL;
@ -95,12 +104,14 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
if (this.scorm.popup) {
this.tabs.changeVisibility(false);
// If we receive a value <= 100 we need to assume it's a percentage.
if (this.scorm.width <= 100) {
this.scorm.width = this.scorm.width + '%';
// If we receive a value > 100 we assume it's a fixed pixel size.
if (this.scorm.width > 100) {
this.scormWidth = this.scorm.width;
// Only get fixed size on height if width is also fixed.
if (this.scorm.height > 100) {
this.scormHeight = this.scorm.height;
}
if (this.scorm.height <= 100) {
this.scorm.height = this.scorm.height + '%';
}
}
@ -111,7 +122,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
const promise = this.newAttempt ? this.setStartTime(this.currentSco.id) : Promise.resolve();
return promise.catch((error) => {
this.domUtils.showErrorModalDefault(error, 'addon.mod_scorm.errorgetscorm', true);
CoreDomUtils.instance.showErrorModalDefault(error, 'addon.mod_scorm.errorgetscorm', true);
}).finally(() => {
// Load SCO.
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.
setTimeout(() => {
this.scormHelper.convertAttemptToOffline(this.scorm, this.attempt).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'core.error', true);
CoreDomUtils.instance.showErrorModalDefault(error, 'core.error', true);
}).then(() => {
this.refreshToc();
});
@ -248,7 +259,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
return Promise.all(promises);
});
}).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);
}).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(() => {
return this.fetchToc();
}).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'addon.mod_scorm.errorgetscorm', true);
CoreDomUtils.instance.showErrorModalDefault(error, 'addon.mod_scorm.errorgetscorm', true);
});
}