MOBILE-2609 assign: Add file support in feedback comments
parent
01eaffa3de
commit
04e55e3695
|
@ -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 || []);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue