Merge pull request #2887 from dpalou/MOBILE-3320
MOBILE-3320 workshop: Fix error when synchronizing assessment datamain
commit
4d50236c26
|
@ -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) => {
|
||||||
result.updated = true;
|
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) => {
|
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,
|
||||||
|
|
Loading…
Reference in New Issue