diff --git a/src/addons/mod/assign/components/index/addon-mod-assign-index.html b/src/addons/mod/assign/components/index/addon-mod-assign-index.html index ff974dd33..2b39744af 100644 --- a/src/addons/mod/assign/components/index/addon-mod-assign-index.html +++ b/src/addons/mod/assign/components/index/addon-mod-assign-index.html @@ -11,7 +11,7 @@ - + diff --git a/src/addons/mod/assign/pages/edit/edit.html b/src/addons/mod/assign/pages/edit/edit.html index e661cbd84..c1675bdb5 100644 --- a/src/addons/mod/assign/pages/edit/edit.html +++ b/src/addons/mod/assign/pages/edit/edit.html @@ -25,6 +25,20 @@ [underTimeClassThresholds]="[300, 900]" class="ion-margin-horizontal"> + + + + + + + + + + + + +
diff --git a/src/addons/mod/assign/pages/edit/edit.ts b/src/addons/mod/assign/pages/edit/edit.ts index 7f76ca8f4..4a5e59cfa 100644 --- a/src/addons/mod/assign/pages/edit/edit.ts +++ b/src/addons/mod/assign/pages/edit/edit.ts @@ -38,6 +38,7 @@ import { AddonModAssignHelper } from '../../services/assign-helper'; import { AddonModAssignOffline } from '../../services/assign-offline'; import { AddonModAssignSync } from '../../services/assign-sync'; import { CoreUtils } from '@services/utils/utils'; +import { CoreWSExternalFile } from '@services/ws'; /** * Page that allows adding or editing an assigment submission. @@ -61,6 +62,9 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave { submissionStatementAccepted = false; // Whether submission statement is accepted. loaded = false; // Whether data has been loaded. timeLimitEndTime = 0; // If time limit is enabled, the end time for the timer. + activityInstructions?: string; // Activity instructions. + introAttachments?: CoreWSExternalFile[]; // Intro attachments. + component = AddonModAssignProvider.COMPONENT; protected userId: number; // User doing the submission. protected isBlind = false; // Whether blind is used. @@ -184,6 +188,20 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave { submissionStatus = await this.startSubmissionIfNeeded(submissionStatus, options); + if (submissionStatus.assignmentdata?.activity) { + // There are activity instructions. Make sure to display it with filters applied. + const filteredSubmissionStatus = options.filter ? + submissionStatus : + await AddonModAssign.getSubmissionStatus(this.assign.id, { + ...options, + filter: true, + }); + + this.activityInstructions = filteredSubmissionStatus.assignmentdata?.activity; + } + + this.introAttachments = submissionStatus.assignmentdata?.attachments?.intro ?? this.assign.introattachments; + this.allowOffline = true; // If offline isn't allowed we shouldn't have reached this point. // Only show submission statement if we are editing our own submission. if (this.assign.requiresubmissionstatement && !this.assign.submissiondrafts && this.userId == currentUserId) { diff --git a/src/addons/mod/assign/services/handlers/prefetch.ts b/src/addons/mod/assign/services/handlers/prefetch.ts index bb344e147..d44a3648a 100644 --- a/src/addons/mod/assign/services/handlers/prefetch.ts +++ b/src/addons/mod/assign/services/handlers/prefetch.ts @@ -101,19 +101,26 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref await AddonModAssignHelper.getSubmissionsUserData(assign, submissionData.submissions, 0, { siteId }); // Get all the files in the submissions. - const promises = submissions.map((submission) => - this.getSubmissionFiles(assign, submission.submitid!, !!submission.blindid, siteId).then((submissionFiles) => { - files = files.concat(submissionFiles); + const promises = submissions.map(async (submission) => { + try { + const submissionFiles = await this.getSubmissionFiles( + assign, + submission.submitid!, + !!submission.blindid, + true, + siteId, + ); - return; - }).catch((error) => { + files = files.concat(submissionFiles); + } catch (error) { if (error && error.errorcode == 'nopermission') { // The user does not have persmission to view this submission, ignore it. return; } throw error; - })); + } + }); await Promise.all(promises); } else { @@ -121,7 +128,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref const userId = CoreSites.getCurrentSiteUserId(); const blindMarking = !!assign.blindmarking && !assign.revealidentities; - const submissionFiles = await this.getSubmissionFiles(assign, userId, blindMarking, siteId); + const submissionFiles = await this.getSubmissionFiles(assign, userId, blindMarking, false, siteId); files = files.concat(submissionFiles); } @@ -138,6 +145,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref * @param assign Assign. * @param submitId User ID of the submission to get. * @param blindMarking True if blind marking, false otherwise. + * @param canViewAllSubmissions Whether the user can view all submissions. * @param siteId Site ID. If not defined, current site. * @return Promise resolved with array of files. */ @@ -145,6 +153,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref assign: AddonModAssignAssign, submitId: number, blindMarking: boolean, + canViewAllSubmissions: boolean, siteId?: string, ): Promise { @@ -155,8 +164,15 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref }); const userSubmission = AddonModAssign.getSubmissionObjectFromAttempt(assign, submissionStatus.lastattempt); + // Get intro and activity files from the submission status if it's a student. + // It's ok if they were already obtained from the assignment instance, they won't be downloaded twice. + const files = canViewAllSubmissions ? + [] : + (submissionStatus.assignmentdata?.attachments?.intro || []) + .concat(submissionStatus.assignmentdata?.attachments?.activity || []); + if (!submissionStatus.lastattempt || !userSubmission) { - return []; + return files; } const promises: Promise[] = []; @@ -177,7 +193,7 @@ export class AddonModAssignPrefetchHandlerService extends CoreCourseActivityPref const filesLists = await Promise.all(promises); - return [].concat.apply([], filesLists); + return files.concat.apply(files, filesLists); } /**