forked from CIT/Vmeda.Online
		
	
						commit
						711fe76c7d
					
				@ -85,7 +85,7 @@ export class AddonModAssignFeedbackCommentsComponent extends AddonModAssignFeedb
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            // Update the text and save it as draft.
 | 
					            // Update the text and save it as draft.
 | 
				
			||||||
            this.isSent = false;
 | 
					            this.isSent = false;
 | 
				
			||||||
            this.text = text;
 | 
					            this.text = this.replacePluginfileUrls(text);
 | 
				
			||||||
            this.feedbackDelegate.saveFeedbackDraft(this.assign.id, this.userId, this.plugin, {
 | 
					            this.feedbackDelegate.saveFeedbackDraft(this.assign.id, this.userId, this.plugin, {
 | 
				
			||||||
                text: text,
 | 
					                text: text,
 | 
				
			||||||
                format: 1
 | 
					                format: 1
 | 
				
			||||||
@ -106,7 +106,7 @@ export class AddonModAssignFeedbackCommentsComponent extends AddonModAssignFeedb
 | 
				
			|||||||
            if (draft) {
 | 
					            if (draft) {
 | 
				
			||||||
                this.isSent = false;
 | 
					                this.isSent = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                return draft.text;
 | 
					                return this.replacePluginfileUrls(draft.text);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                // There is no draft saved. Check if we have anything offline.
 | 
					                // There is no draft saved. Check if we have anything offline.
 | 
				
			||||||
                return this.assignOfflineProvider.getSubmissionGrade(this.assign.id, this.userId).catch(() => {
 | 
					                return this.assignOfflineProvider.getSubmissionGrade(this.assign.id, this.userId).catch(() => {
 | 
				
			||||||
@ -118,7 +118,7 @@ export class AddonModAssignFeedbackCommentsComponent extends AddonModAssignFeedb
 | 
				
			|||||||
                        this.feedbackDelegate.saveFeedbackDraft(this.assign.id, this.userId, this.plugin,
 | 
					                        this.feedbackDelegate.saveFeedbackDraft(this.assign.id, this.userId, this.plugin,
 | 
				
			||||||
                                offlineData.plugindata.assignfeedbackcomments_editor);
 | 
					                                offlineData.plugindata.assignfeedbackcomments_editor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        return offlineData.plugindata.assignfeedbackcomments_editor.text;
 | 
					                        return this.replacePluginfileUrls(offlineData.plugindata.assignfeedbackcomments_editor.text);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    // No offline data found, return online text.
 | 
					                    // No offline data found, return online text.
 | 
				
			||||||
@ -129,4 +129,16 @@ export class AddonModAssignFeedbackCommentsComponent extends AddonModAssignFeedb
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Replace @@PLUGINFILE@@ wildcards with the real URL of embedded files.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param {string} Text to treat.
 | 
				
			||||||
 | 
					     * @return {string} Treated text.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    replacePluginfileUrls(text: string): string {
 | 
				
			||||||
 | 
					        const files = this.plugin.fileareas && this.plugin.fileareas[0] && this.plugin.fileareas[0].files;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return this.textUtils.replacePluginfileUrls(text, files || []);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -91,6 +91,20 @@ export class AddonModAssignFeedbackCommentsHandler implements AddonModAssignFeed
 | 
				
			|||||||
        return siteId + '#' + assignId + '#' + userId;
 | 
					        return siteId + '#' + assignId + '#' + userId;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Get files used by this plugin.
 | 
				
			||||||
 | 
					     * The files returned by this function will be prefetched when the user prefetches the assign.
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param {any} assign The assignment.
 | 
				
			||||||
 | 
					     * @param {any} submission The submission.
 | 
				
			||||||
 | 
					     * @param {any} plugin The plugin object.
 | 
				
			||||||
 | 
					     * @param {string} [siteId] Site ID. If not defined, current site.
 | 
				
			||||||
 | 
					     * @return {any[]|Promise<any[]>} The files (or promise resolved with the files).
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    getPluginFiles(assign: any, submission: any, plugin: any, siteId?: string): any[] | Promise<any[]> {
 | 
				
			||||||
 | 
					        return this.assignProvider.getSubmissionPluginAttachments(plugin);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Get the text to submit.
 | 
					     * Get the text to submit.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -106,6 +106,13 @@ export class AddonModAssignPrefetchHandler extends CoreCourseActivityPrefetchHan
 | 
				
			|||||||
                            promises.push(this.getSubmissionFiles(assign, submission.submitid, !!submission.blindid, siteId)
 | 
					                            promises.push(this.getSubmissionFiles(assign, submission.submitid, !!submission.blindid, siteId)
 | 
				
			||||||
                                    .then((submissionFiles) => {
 | 
					                                    .then((submissionFiles) => {
 | 
				
			||||||
                                files = files.concat(submissionFiles);
 | 
					                                files = files.concat(submissionFiles);
 | 
				
			||||||
 | 
					                            }).catch((error) => {
 | 
				
			||||||
 | 
					                                if (error && error.errorcode == 'nopermission') {
 | 
				
			||||||
 | 
					                                    // The user does not have persmission to view this submission, ignore it.
 | 
				
			||||||
 | 
					                                    return Promise.resolve();
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                return Promise.reject(error);
 | 
				
			||||||
                            }));
 | 
					                            }));
 | 
				
			||||||
                        });
 | 
					                        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -257,11 +264,11 @@ export class AddonModAssignPrefetchHandler extends CoreCourseActivityPrefetchHan
 | 
				
			|||||||
     * @param {any} assign Assign.
 | 
					     * @param {any} assign Assign.
 | 
				
			||||||
     * @param {number} courseId Course ID.
 | 
					     * @param {number} courseId Course ID.
 | 
				
			||||||
     * @param {number} moduleId Module ID.
 | 
					     * @param {number} moduleId Module ID.
 | 
				
			||||||
     * @param {number} [userId] User ID. If not defined, site's current user.
 | 
					     * @param {number} userId User ID. If not defined, site's current user.
 | 
				
			||||||
     * @param {string} [siteId] Site ID. If not defined, current site.
 | 
					     * @param {string} siteId Site ID. If not defined, current site.
 | 
				
			||||||
     * @return {Promise<any>} Promise resolved when prefetched, rejected otherwise.
 | 
					     * @return {Promise<any>} Promise resolved when prefetched, rejected otherwise.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    protected prefetchSubmissions(assign: any, courseId: number, moduleId: number, userId?: number, siteId?: string): Promise<any> {
 | 
					    protected prefetchSubmissions(assign: any, courseId: number, moduleId: number, userId: number, siteId: string): Promise<any> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Get submissions.
 | 
					        // Get submissions.
 | 
				
			||||||
        return this.assignProvider.getSubmissions(assign.id, siteId).then((data) => {
 | 
					        return this.assignProvider.getSubmissions(assign.id, siteId).then((data) => {
 | 
				
			||||||
@ -279,9 +286,24 @@ export class AddonModAssignPrefetchHandler extends CoreCourseActivityPrefetchHan
 | 
				
			|||||||
                        subPromises.push(this.assignProvider.getSubmissionStatus(assign.id, submission.submitid,
 | 
					                        subPromises.push(this.assignProvider.getSubmissionStatus(assign.id, submission.submitid,
 | 
				
			||||||
                                !!submission.blindid, true, false, siteId).then((subm) => {
 | 
					                                !!submission.blindid, true, false, siteId).then((subm) => {
 | 
				
			||||||
                            return this.prefetchSubmission(assign, courseId, moduleId, subm, submission.submitid, siteId);
 | 
					                            return this.prefetchSubmission(assign, courseId, moduleId, subm, submission.submitid, siteId);
 | 
				
			||||||
 | 
					                        }).catch((error) => {
 | 
				
			||||||
 | 
					                            if (error && error.errorcode == 'nopermission') {
 | 
				
			||||||
 | 
					                                // The user does not have persmission to view this submission, ignore it.
 | 
				
			||||||
 | 
					                                return Promise.resolve();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            return Promise.reject(error);
 | 
				
			||||||
                        }));
 | 
					                        }));
 | 
				
			||||||
                    });
 | 
					                    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    // Prefetch the submission of the current user even if it does not exist, this will be create it.
 | 
				
			||||||
 | 
					                    if (!data.submissions || !data.submissions.find((subm) => subm.submitid == userId)) {
 | 
				
			||||||
 | 
					                        subPromises.push(this.assignProvider.getSubmissionStatus(assign.id, userId, false, true, false, siteId)
 | 
				
			||||||
 | 
					                                .then((subm) => {
 | 
				
			||||||
 | 
					                            return this.prefetchSubmission(assign, courseId, moduleId, subm, userId, siteId);
 | 
				
			||||||
 | 
					                        }));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    return Promise.all(subPromises);
 | 
					                    return Promise.all(subPromises);
 | 
				
			||||||
                }));
 | 
					                }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user