From e641cf7569d1ff52d876d6ee63a4b1fc7a9fa591 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 22 Jan 2016 13:36:40 +0100 Subject: [PATCH] MOBILE-1389 scorm: Fix size in % and logout bug --- www/addons/mod_scorm/controllers/player.js | 10 ++++++++++ www/addons/mod_scorm/services/scorm.js | 8 ++++++++ www/addons/mod_scorm/services/scorm_online.js | 12 ++++++++++++ 3 files changed, 30 insertions(+) diff --git a/www/addons/mod_scorm/controllers/player.js b/www/addons/mod_scorm/controllers/player.js index 7fcc302dbe9..64d440aa32a 100644 --- a/www/addons/mod_scorm/controllers/player.js +++ b/www/addons/mod_scorm/controllers/player.js @@ -39,6 +39,16 @@ angular.module('mm.addons.mod_scorm') $scope.scorm = scorm; $scope.loadingToc = true; + if (scorm.popup) { + // Fix for bug in WS not returning %. If we receive a value <= 100 we'll assume it's a percentage. + if (scorm.width <= 100) { + scorm.width = scorm.width + '%'; + } + if (scorm.height <= 100) { + scorm.height = scorm.height + '%'; + } + } + // Fetch data needed to play the SCORM. function fetchData() { // Wait for any ongoing sync to finish. We won't sync a SCORM while it's being played. diff --git a/www/addons/mod_scorm/services/scorm.js b/www/addons/mod_scorm/services/scorm.js index 9a0d404b5d9..c3f25567f50 100644 --- a/www/addons/mod_scorm/services/scorm.js +++ b/www/addons/mod_scorm/services/scorm.js @@ -728,6 +728,10 @@ angular.module('mm.addons.mod_scorm') self.getScos = function(scormid, organization, ignoreCache) { organization = organization || ''; + if (!$mmSite.isLoggedIn()) { + return $q.reject(); + } + // Don't send the organization to the WS, we'll filter them locally. var params = { scormid: scormid @@ -945,6 +949,10 @@ angular.module('mm.addons.mod_scorm') cacheKey: getScormDataCacheKey(courseid) }; + if (!$mmSite.isLoggedIn()) { + return $q.reject(); + } + return $mmSite.read('mod_scorm_get_scorms_by_courses', params, preSets).then(function(response) { if (response && response.scorms) { var currentScorm; diff --git a/www/addons/mod_scorm/services/scorm_online.js b/www/addons/mod_scorm/services/scorm_online.js index ab99e9d6eda..9d1ab52c869 100644 --- a/www/addons/mod_scorm/services/scorm_online.js +++ b/www/addons/mod_scorm/services/scorm_online.js @@ -67,6 +67,10 @@ angular.module('mm.addons.mod_scorm') self.getAttemptCount = function(scormId, userId, ignoreMissing, ignoreCache) { userId = userId || $mmSite.getUserId(); + if (!$mmSite.isLoggedIn()) { + return $q.reject(); + } + var params = { scormid: scormId, userid: userId, @@ -135,6 +139,10 @@ angular.module('mm.addons.mod_scorm') preSets.emergencyCache = 0; } + if (!$mmSite.isLoggedIn()) { + return $q.reject(); + } + return $mmSite.read('mod_scorm_get_scorm_user_data', params, preSets).then(function(response) { if (response && response.data) { // Format the response. @@ -224,6 +232,10 @@ angular.module('mm.addons.mod_scorm') return $q.when(); // Nothing to save. } + if (!$mmSite.isLoggedIn()) { + return $q.reject(); + } + blockedScorms[scormId] = true; return $mmSite.write('mod_scorm_insert_scorm_tracks', params).then(function(response) {