diff --git a/src/addon/mod/scorm/pages/player/player.html b/src/addon/mod/scorm/pages/player/player.html index 6d7874bad..e26b99e1d 100644 --- a/src/addon/mod/scorm/pages/player/player.html +++ b/src/addon/mod/scorm/pages/player/player.html @@ -13,7 +13,7 @@ - +

{{ errorMessage | translate }}

diff --git a/src/addon/mod/scorm/pages/player/player.ts b/src/addon/mod/scorm/pages/player/player.ts index 2b689387d..a21bd9e58 100644 --- a/src/addon/mod/scorm/pages/player/player.ts +++ b/src/addon/mod/scorm/pages/player/player.ts @@ -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 (this.scorm.height <= 100) { - this.scorm.height = this.scorm.height + '%'; + // 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; + } } } @@ -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); }); }