Merge pull request #2887 from dpalou/MOBILE-3320

MOBILE-3320 workshop: Fix error when synchronizing assessment data
main
Pau Ferrer Ocaña 2021-07-12 13:16:35 +02:00 committed by GitHub
commit 4d50236c26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 5 deletions

View File

@ -205,14 +205,23 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider<AddonModW
const assessments: AddonModWorkshopOfflineAssessment[] = syncs[1]; const assessments: AddonModWorkshopOfflineAssessment[] = syncs[1];
const submissionEvaluations: AddonModWorkshopOfflineEvaluateSubmission[] = syncs[2]; const submissionEvaluations: AddonModWorkshopOfflineEvaluateSubmission[] = syncs[2];
const assessmentEvaluations: AddonModWorkshopOfflineEvaluateAssessment[] = syncs[3]; const assessmentEvaluations: AddonModWorkshopOfflineEvaluateAssessment[] = syncs[3];
const offlineSubmissions: Record<string, AddonModWorkshopOfflineSubmission[]> = {};
const promises: Promise<void>[] = []; const promises: Promise<void>[] = [];
promises.push(this.syncSubmission(workshop, submissionsActions, result, siteId).then(() => { submissionsActions.forEach((action) => {
offlineSubmissions[action.submissionid] = offlineSubmissions[action.submissionid] || [];
offlineSubmissions[action.submissionid].push(action);
});
Object.keys(offlineSubmissions).forEach((submissionId) => {
const submissionActions = offlineSubmissions[submissionId];
promises.push(this.syncSubmission(workshop, submissionActions, result, siteId).then(() => {
result.updated = true; result.updated = true;
return; return;
})); }));
});
assessments.forEach((assessment) => { assessments.forEach((assessment) => {
promises.push(this.syncAssessment(workshop, assessment, result, siteId).then(() => { promises.push(this.syncAssessment(workshop, assessment, result, siteId).then(() => {
@ -444,7 +453,7 @@ export class AddonModWorkshopSyncProvider extends CoreSyncBaseProvider<AddonModW
try { try {
let files: CoreFileEntry[] = []; let files: CoreFileEntry[] = [];
// Upload attachments first if any. // Upload attachments first if any.
if (inputData.feedbackauthorattachmentsid) { if (inputData.feedbackauthorattachmentsid && typeof inputData.feedbackauthorattachmentsid !== 'number') {
files = await AddonModWorkshopHelper.getAssessmentFilesFromOfflineFilesObject( files = await AddonModWorkshopHelper.getAssessmentFilesFromOfflineFilesObject(
<CoreFileUploaderStoreFilesResult>inputData.feedbackauthorattachmentsid, <CoreFileUploaderStoreFilesResult>inputData.feedbackauthorattachmentsid,
workshop.id, workshop.id,