From eab3a622baea128f9787d164effd2ac6450f997d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 27 Nov 2020 12:25:06 +0100 Subject: [PATCH] MOBILE-3523 workshop: Prefetch assessments forms --- .../mod/workshop/components/assessment/assessment.ts | 2 +- src/addon/mod/workshop/providers/helper.ts | 10 +++++++--- src/addon/mod/workshop/providers/prefetch-handler.ts | 5 +++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/addon/mod/workshop/components/assessment/assessment.ts b/src/addon/mod/workshop/components/assessment/assessment.ts index 4aafdd625..b7a13569f 100644 --- a/src/addon/mod/workshop/components/assessment/assessment.ts +++ b/src/addon/mod/workshop/components/assessment/assessment.ts @@ -113,7 +113,7 @@ export class AddonModWorkshopAssessmentComponent implements OnInit { }; if (!this.submission) { - const modal = this.domUtils.showModalLoading('core.sending', true); + const modal = this.domUtils.showModalLoading(); this.workshopHelper.getSubmissionById(this.workshop.id, this.assessment.submissionid, {cmId: this.workshop.coursemodule}).then((submissionData) => { diff --git a/src/addon/mod/workshop/providers/helper.ts b/src/addon/mod/workshop/providers/helper.ts index 7adf38209..5ef4d8f8f 100644 --- a/src/addon/mod/workshop/providers/helper.ts +++ b/src/addon/mod/workshop/providers/helper.ts @@ -189,10 +189,14 @@ export class AddonModWorkshopHelperProvider { options.siteId = options.siteId || this.sitesProvider.getCurrentSiteId(); return this.workshopProvider.getReviewerAssessments(workshopId, options).then((assessments) => { - const promises = assessments.map((assessment) => { - return this.getSubmissionById(workshopId, assessment.submissionid, options).then((submission) => { + const promises = []; + assessments.forEach((assessment) => { + promises.push(this.getSubmissionById(workshopId, assessment.submissionid, options).then((submission) => { assessment.submission = submission; - }); + })); + promises.push(this.workshopProvider.getAssessmentForm(workshopId, assessment.id, options).then((assessmentForm) => { + assessment.form = assessmentForm; + })); }); return Promise.all(promises).then(() => { diff --git a/src/addon/mod/workshop/providers/prefetch-handler.ts b/src/addon/mod/workshop/providers/prefetch-handler.ts index 9f69bb7d0..c189a9f60 100644 --- a/src/addon/mod/workshop/providers/prefetch-handler.ts +++ b/src/addon/mod/workshop/providers/prefetch-handler.ts @@ -142,6 +142,11 @@ export class AddonModWorkshopPrefetchHandler extends CoreCourseActivityPrefetchH files = files.concat(assessment.feedbackattachmentfiles) .concat(assessment.feedbackcontentfiles); }); + if (workshop.phase >= AddonModWorkshopProvider.PHASE_ASSESSMENT && canAssess) { + return Promise.all(assessments.map((assessment) => { + return this.workshopHelper.getReviewerAssessmentById(workshop.id, assessment.id); + })); + } })); });