diff --git a/src/addon/mod/assign/feedback/comments/component/comments.ts b/src/addon/mod/assign/feedback/comments/component/comments.ts index 9e28120e3..910eec587 100644 --- a/src/addon/mod/assign/feedback/comments/component/comments.ts +++ b/src/addon/mod/assign/feedback/comments/component/comments.ts @@ -85,7 +85,7 @@ export class AddonModAssignFeedbackCommentsComponent extends AddonModAssignFeedb // Update the text and save it as draft. this.isSent = false; - this.text = text; + this.text = this.replacePluginfileUrls(text); this.feedbackDelegate.saveFeedbackDraft(this.assign.id, this.userId, this.plugin, { text: text, format: 1 @@ -106,7 +106,7 @@ export class AddonModAssignFeedbackCommentsComponent extends AddonModAssignFeedb if (draft) { this.isSent = false; - return draft.text; + return this.replacePluginfileUrls(draft.text); } else { // There is no draft saved. Check if we have anything offline. 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, 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. @@ -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 || []); + } } diff --git a/src/addon/mod/assign/feedback/comments/providers/handler.ts b/src/addon/mod/assign/feedback/comments/providers/handler.ts index 108fef23a..55c003d9a 100644 --- a/src/addon/mod/assign/feedback/comments/providers/handler.ts +++ b/src/addon/mod/assign/feedback/comments/providers/handler.ts @@ -91,6 +91,20 @@ export class AddonModAssignFeedbackCommentsHandler implements AddonModAssignFeed 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} The files (or promise resolved with the files). + */ + getPluginFiles(assign: any, submission: any, plugin: any, siteId?: string): any[] | Promise { + return this.assignProvider.getSubmissionPluginAttachments(plugin); + } + /** * Get the text to submit. *