MOBILE-3039 workshop: Prefetch files from submissions to assess

main
Dani Palou 2019-06-07 11:13:24 +02:00
parent e6f982ec93
commit 79d3f02f72
1 changed files with 11 additions and 3 deletions

View File

@ -319,17 +319,25 @@ export class AddonModWorkshopPrefetchHandler extends CoreCourseActivityPrefetchH
reportPromise = reportPromise.finally(() => { reportPromise = reportPromise.finally(() => {
return this.workshopHelper.getReviewerAssessments(workshop.id, currentUserId, undefined, return this.workshopHelper.getReviewerAssessments(workshop.id, currentUserId, undefined,
undefined, siteId).then((revAssessments) => { undefined, siteId).then((revAssessments) => {
let p = Promise.resolve();
const promises = [];
let files = []; // Files in each submission.
revAssessments.forEach((assessment) => { revAssessments.forEach((assessment) => {
if (assessment.submission.authorid == currentUserId) { if (assessment.submission.authorid == currentUserId) {
p = this.workshopProvider.getAssessment(workshop.id, assessment.id); promises.push(this.workshopProvider.getAssessment(workshop.id, assessment.id));
} }
userIds.push(assessment.reviewerid); userIds.push(assessment.reviewerid);
userIds.push(assessment.gradinggradeoverby); userIds.push(assessment.gradinggradeoverby);
assessments[assessment.id] = assessment; assessments[assessment.id] = assessment;
files = files.concat(assessment.submission.attachmentfiles || [])
.concat(assessment.submission.contentfiles || []);
}); });
return p; promises.push(this.filepoolProvider.addFilesToQueue(siteId, files, this.component, module.id));
return Promise.all(promises);
}); });
}); });
} }