From 2057f316a07d03ae304c028347c756c386d91340 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 12 Jul 2021 12:46:23 +0200 Subject: [PATCH] MOBILE-3320 workshop: Fix error when synchronizing assessment data --- .../mod/workshop/services/workshop-sync.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/addons/mod/workshop/services/workshop-sync.ts b/src/addons/mod/workshop/services/workshop-sync.ts index aef9e01ce..f156c3e36 100644 --- a/src/addons/mod/workshop/services/workshop-sync.ts +++ b/src/addons/mod/workshop/services/workshop-sync.ts @@ -205,14 +205,23 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider = {}; const promises: Promise[] = []; - promises.push(this.syncSubmission(workshop, submissionsActions, result, siteId).then(() => { - result.updated = true; + submissionsActions.forEach((action) => { + offlineSubmissions[action.submissionid] = offlineSubmissions[action.submissionid] || []; + offlineSubmissions[action.submissionid].push(action); + }); - return; - })); + Object.keys(offlineSubmissions).forEach((submissionId) => { + const submissionActions = offlineSubmissions[submissionId]; + promises.push(this.syncSubmission(workshop, submissionActions, result, siteId).then(() => { + result.updated = true; + + return; + })); + }); assessments.forEach((assessment) => { promises.push(this.syncAssessment(workshop, assessment, result, siteId).then(() => { @@ -444,7 +453,7 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProviderinputData.feedbackauthorattachmentsid, workshop.id,