From 997d6185fd12411cee62df663c1536e62d26bea5 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 26 May 2021 09:28:22 +0200 Subject: [PATCH] MOBILE-3320 scorm: Fix file downloaded when it shouldn't --- src/addons/mod/scorm/services/handlers/prefetch.ts | 11 ++++++++--- src/addons/mod/scorm/services/scorm-sync.ts | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/addons/mod/scorm/services/handlers/prefetch.ts b/src/addons/mod/scorm/services/handlers/prefetch.ts index 634082609..f25974718 100644 --- a/src/addons/mod/scorm/services/handlers/prefetch.ts +++ b/src/addons/mod/scorm/services/handlers/prefetch.ts @@ -15,7 +15,7 @@ import { Injectable } from '@angular/core'; import { CoreError } from '@classes/errors/error'; import { CoreCourseActivityPrefetchHandlerBase } from '@features/course/classes/activity-prefetch-handler'; -import { CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course'; +import { CoreCourse, CoreCourseAnyModuleData, CoreCourseCommonModWSOptions } from '@features/course/services/course'; import { CoreApp } from '@services/app'; import { CoreFile } from '@services/file'; import { CoreFilepool } from '@services/filepool'; @@ -316,8 +316,13 @@ export class AddonModScormPrefetchHandlerService extends CoreCourseActivityPrefe * @param siteId Site ID. * @returns Promise resolved with the SCORM. */ - protected getScorm(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise { - const moduleUrl = 'url' in module ? module.url : undefined; + protected async getScorm(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise { + let moduleUrl = 'url' in module ? module.url : undefined; + if (!moduleUrl) { + module = await CoreCourse.getModule(module.id, module.course, undefined, true, false, siteId); + + moduleUrl = module.url; + } return AddonModScorm.getScorm(courseId, module.id, { moduleUrl, siteId }); } diff --git a/src/addons/mod/scorm/services/scorm-sync.ts b/src/addons/mod/scorm/services/scorm-sync.ts index 43bdaeb38..44ba195cd 100644 --- a/src/addons/mod/scorm/services/scorm-sync.ts +++ b/src/addons/mod/scorm/services/scorm-sync.ts @@ -198,7 +198,7 @@ export class AddonModScormSyncProvider extends CoreCourseActivitySyncBaseProvide if (updated) { try { // Update downloaded data. - const module = await CoreCourse.getModuleBasicInfoByInstance(scorm.id, 'scorm', siteId); + const module = await CoreCourse.getModule(scorm.coursemodule, scorm.course, undefined, false, false, siteId); await this.prefetchAfterUpdate(AddonModScormPrefetchHandler.instance, module, scorm.course, undefined, siteId); } catch {