MOBILE-3320 scorm: Fix file downloaded when it shouldn't

main
Dani Palou 2021-05-26 09:28:22 +02:00
parent 1ac0b7a0f4
commit 997d6185fd
2 changed files with 9 additions and 4 deletions

View File

@ -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<AddonModScormScorm> {
const moduleUrl = 'url' in module ? module.url : undefined;
protected async getScorm(module: CoreCourseAnyModuleData, courseId: number, siteId?: string): Promise<AddonModScormScorm> {
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 });
}

View File

@ -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 {