MOBILE-3919 assign: Display activity instructions
parent
1da073eefa
commit
b793a9dbe9
|
@ -11,7 +11,7 @@
|
|||
<!-- Activity info. -->
|
||||
<core-course-module-info [module]="module" [description]="description" [component]="component" [componentId]="componentId"
|
||||
[courseId]="courseId" [hasDataToSync]="hasOffline" (completionChanged)="onCompletionChange()">
|
||||
<ion-list inset="true" description *ngIf="assign && assign.introattachments && assign.introattachments.length">
|
||||
<ion-list inset="true" description *ngIf="assign && assign.introattachments?.length && !assign.submissionattachments">
|
||||
<core-file *ngFor="let file of assign.introattachments" [file]="file" [component]="component" [componentId]="componentId">
|
||||
</core-file>
|
||||
</ion-list>
|
||||
|
|
|
@ -25,6 +25,20 @@
|
|||
[underTimeClassThresholds]="[300, 900]" class="ion-margin-horizontal">
|
||||
</core-timer>
|
||||
|
||||
<!-- Assign activity instructions and attachments if needed. -->
|
||||
<ion-item class="ion-text-wrap" *ngIf="activityInstructions">
|
||||
<ion-label>
|
||||
<core-format-text [text]="activityInstructions" [component]="component" [componentId]="moduleId" contextLevel="module"
|
||||
[contextInstanceId]="moduleId" [courseId]="courseId" [maxHeight]="120">
|
||||
</core-format-text>
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ng-container *ngIf="assign?.submissionattachments">
|
||||
<core-file *ngFor="let file of introAttachments" [file]="file" [component]="component" [componentId]="moduleId">
|
||||
</core-file>
|
||||
</ng-container>
|
||||
|
||||
<form name="addon-mod_assign-edit-form" #editSubmissionForm>
|
||||
<!-- Submission statement. -->
|
||||
<ion-item class="ion-text-wrap" *ngIf="submissionStatement">
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<CoreWSFile[]> {
|
||||
|
||||
|
@ -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<CoreWSFile[]>[] = [];
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue