MOBILE-4538 assign: Inheritdocs from handlers

main
Pau Ferrer Ocaña 2024-03-08 13:51:45 +01:00
parent 4fd1276817
commit dc1b9e9575
9 changed files with 170 additions and 282 deletions

View File

@ -60,11 +60,7 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss
} }
/** /**
* Discard the draft data of the feedback plugin. * @inheritdoc
*
* @param assignId The assignment ID.
* @param userId User ID.
* @param siteId Site ID. If not defined, current site.
*/ */
discardDraft(assignId: number, userId: number, siteId?: string): void { discardDraft(assignId: number, userId: number, siteId?: string): void {
const id = this.getDraftId(assignId, userId, siteId); const id = this.getDraftId(assignId, userId, siteId);
@ -74,22 +70,14 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss
} }
/** /**
* Return the Component to use to display the plugin data. * @inheritdoc
* It's recommended to return the class of the component, but you can also return an instance of the component.
*
* @returns The component (or promise resolved with component) to use, undefined if not found.
*/ */
getComponent(): Type<IAddonModAssignFeedbackPluginComponent> { getComponent(): Type<IAddonModAssignFeedbackPluginComponent> {
return AddonModAssignFeedbackCommentsComponent; return AddonModAssignFeedbackCommentsComponent;
} }
/** /**
* Return the draft saved data of the feedback plugin. * @inheritdoc
*
* @param assignId The assignment ID.
* @param userId User ID.
* @param siteId Site ID. If not defined, current site.
* @returns Data (or promise resolved with the data).
*/ */
getDraft(assignId: number, userId: number, siteId?: string): AddonModAssignFeedbackCommentsDraftData | undefined { getDraft(assignId: number, userId: number, siteId?: string): AddonModAssignFeedbackCommentsDraftData | undefined {
const id = this.getDraftId(assignId, userId, siteId); const id = this.getDraftId(assignId, userId, siteId);
@ -114,13 +102,7 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss
} }
/** /**
* Get files used by this plugin. * @inheritdoc
* The files returned by this function will be prefetched when the user prefetches the assign.
*
* @param assign The assignment.
* @param submission The submission.
* @param plugin The plugin object.
* @returns The files (or promise resolved with the files).
*/ */
getPluginFiles( getPluginFiles(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,
@ -131,14 +113,7 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss
} }
/** /**
* Check if the feedback data has changed for this plugin. * @inheritdoc
*
* @param assign The assignment.
* @param submission The submission.
* @param plugin The plugin object.
* @param inputData Data entered by the user for the feedback.
* @param userId User ID of the submission.
* @returns Boolean (or promise resolved with boolean): whether the data has changed.
*/ */
async hasDataChanged( async hasDataChanged(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,
@ -172,12 +147,7 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss
} }
/** /**
* Check whether the plugin has draft data stored. * @inheritdoc
*
* @param assignId The assignment ID.
* @param userId User ID.
* @param siteId Site ID. If not defined, current site.
* @returns Boolean or promise resolved with boolean: whether the plugin has draft data.
*/ */
hasDraftData(assignId: number, userId: number, siteId?: string): boolean | Promise<boolean> { hasDraftData(assignId: number, userId: number, siteId?: string): boolean | Promise<boolean> {
const draft = this.getDraft(assignId, userId, siteId); const draft = this.getDraft(assignId, userId, siteId);
@ -186,9 +156,7 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss
} }
/** /**
* Whether or not the handler is enabled on a site level. * @inheritdoc
*
* @returns True or promise resolved with true if enabled.
*/ */
async isEnabled(): Promise<boolean> { async isEnabled(): Promise<boolean> {
// In here we should check if comments is not disabled in site. // In here we should check if comments is not disabled in site.
@ -198,13 +166,7 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss
} }
/** /**
* Prepare and add to pluginData the data to send to the server based on the draft data saved. * @inheritdoc
*
* @param assignId The assignment ID.
* @param userId User ID.
* @param plugin The plugin object.
* @param pluginData Object where to store the data to send.
* @param siteId Site ID. If not defined, current site.
*/ */
prepareFeedbackData( prepareFeedbackData(
assignId: number, assignId: number,
@ -225,13 +187,7 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss
} }
/** /**
* Save draft data of the feedback plugin. * @inheritdoc
*
* @param assignId The assignment ID.
* @param userId User ID.
* @param plugin The plugin object.
* @param data The data to save.
* @param siteId Site ID. If not defined, current site.
*/ */
saveDraft( saveDraft(
assignId: number, assignId: number,

View File

@ -35,23 +35,14 @@ export class AddonModAssignFeedbackEditPdfHandlerService implements AddonModAssi
type = 'editpdf'; type = 'editpdf';
/** /**
* Return the Component to use to display the plugin data. * @inheritdoc
* It's recommended to return the class of the component, but you can also return an instance of the component.
*
* @returns The component (or promise resolved with component) to use, undefined if not found.
*/ */
getComponent(): Type<IAddonModAssignFeedbackPluginComponent> { getComponent(): Type<IAddonModAssignFeedbackPluginComponent> {
return AddonModAssignFeedbackEditPdfComponent; return AddonModAssignFeedbackEditPdfComponent;
} }
/** /**
* Get files used by this plugin. * @inheritdoc
* The files returned by this function will be prefetched when the user prefetches the assign.
*
* @param assign The assignment.
* @param submission The submission.
* @param plugin The plugin object.
* @returns The files (or promise resolved with the files).
*/ */
getPluginFiles( getPluginFiles(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,
@ -62,9 +53,7 @@ export class AddonModAssignFeedbackEditPdfHandlerService implements AddonModAssi
} }
/** /**
* Whether or not the handler is enabled on a site level. * @inheritdoc
*
* @returns True or promise resolved with true if enabled.
*/ */
async isEnabled(): Promise<boolean> { async isEnabled(): Promise<boolean> {
return true; return true;

View File

@ -35,23 +35,14 @@ export class AddonModAssignFeedbackFileHandlerService implements AddonModAssignF
type = 'file'; type = 'file';
/** /**
* Return the Component to use to display the plugin data. * @inheritdoc
* It's recommended to return the class of the component, but you can also return an instance of the component.
*
* @returns The component (or promise resolved with component) to use, undefined if not found.
*/ */
getComponent(): Type<IAddonModAssignFeedbackPluginComponent> { getComponent(): Type<IAddonModAssignFeedbackPluginComponent> {
return AddonModAssignFeedbackFileComponent; return AddonModAssignFeedbackFileComponent;
} }
/** /**
* Get files used by this plugin. * @inheritdoc
* The files returned by this function will be prefetched when the user prefetches the assign.
*
* @param assign The assignment.
* @param submission The submission.
* @param plugin The plugin object.
* @returns The files (or promise resolved with the files).
*/ */
getPluginFiles( getPluginFiles(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,
@ -62,9 +53,7 @@ export class AddonModAssignFeedbackFileHandlerService implements AddonModAssignF
} }
/** /**
* Whether or not the handler is enabled on a site level. * @inheritdoc
*
* @returns True or promise resolved with true if enabled.
*/ */
async isEnabled(): Promise<boolean> { async isEnabled(): Promise<boolean> {
return true; return true;

View File

@ -15,8 +15,9 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreWSFile } from '@services/ws'; import { CoreWSFile } from '@services/ws';
import { Translate } from '@singletons'; import { Translate } from '@singletons';
import { AddonModAssignPlugin } from '../assign'; import { AddonModAssignAssign, AddonModAssignPlugin, AddonModAssignSavePluginData, AddonModAssignSubmission } from '../assign';
import { AddonModAssignFeedbackHandler } from '../feedback-delegate'; import { AddonModAssignFeedbackHandler } from '../feedback-delegate';
import { CoreFormFields } from '@singletons/form';
/** /**
* Default handler used when a feedback plugin doesn't have a specific implementation. * Default handler used when a feedback plugin doesn't have a specific implementation.
@ -30,14 +31,19 @@ export class AddonModAssignDefaultFeedbackHandler implements AddonModAssignFeedb
/** /**
* @inheritdoc * @inheritdoc
*/ */
discardDraft(): void { // eslint-disable-next-line @typescript-eslint/no-unused-vars
discardDraft(assignId: number, userId: number, siteId?: string): void | Promise<void> {
// Nothing to do. // Nothing to do.
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
getDraft(): undefined { getDraft(
assignId: number, // eslint-disable-line @typescript-eslint/no-unused-vars
userId: number, // eslint-disable-line @typescript-eslint/no-unused-vars
siteId?: string, // eslint-disable-line @typescript-eslint/no-unused-vars
): CoreFormFields | Promise<CoreFormFields | undefined> | undefined {
// Nothing to do. // Nothing to do.
return; return;
} }
@ -45,7 +51,12 @@ export class AddonModAssignDefaultFeedbackHandler implements AddonModAssignFeedb
/** /**
* @inheritdoc * @inheritdoc
*/ */
getPluginFiles(): CoreWSFile[] { getPluginFiles(
assign: AddonModAssignAssign, // eslint-disable-line @typescript-eslint/no-unused-vars
submission: AddonModAssignSubmission, // eslint-disable-line @typescript-eslint/no-unused-vars
plugin: AddonModAssignPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
siteId?: string, // eslint-disable-line @typescript-eslint/no-unused-vars
): CoreWSFile[] | Promise<CoreWSFile[]> {
return []; return [];
} }
@ -73,14 +84,21 @@ export class AddonModAssignDefaultFeedbackHandler implements AddonModAssignFeedb
/** /**
* @inheritdoc * @inheritdoc
*/ */
hasDataChanged(): boolean { async hasDataChanged(
assign: AddonModAssignAssign, // eslint-disable-line @typescript-eslint/no-unused-vars
submission: AddonModAssignSubmission, // eslint-disable-line @typescript-eslint/no-unused-vars
plugin: AddonModAssignPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
inputData: CoreFormFields, // eslint-disable-line @typescript-eslint/no-unused-vars
userId: number, // eslint-disable-line @typescript-eslint/no-unused-vars
): Promise<boolean> {
return false; return false;
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
hasDraftData(): boolean { // eslint-disable-next-line @typescript-eslint/no-unused-vars
hasDraftData(assignId: number, userId: number, siteId?: string): boolean | Promise<boolean> {
return false; return false;
} }
@ -94,21 +112,38 @@ export class AddonModAssignDefaultFeedbackHandler implements AddonModAssignFeedb
/** /**
* @inheritdoc * @inheritdoc
*/ */
async prefetch(): Promise<void> { async prefetch(
assign: AddonModAssignAssign, // eslint-disable-line @typescript-eslint/no-unused-vars
submission: AddonModAssignSubmission, // eslint-disable-line @typescript-eslint/no-unused-vars
plugin: AddonModAssignPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
siteId?: string, // eslint-disable-line @typescript-eslint/no-unused-vars
): Promise<void> {
return; return;
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
prepareFeedbackData(): void { prepareFeedbackData(
assignId: number, // eslint-disable-line @typescript-eslint/no-unused-vars
userId: number, // eslint-disable-line @typescript-eslint/no-unused-vars
plugin: AddonModAssignPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
pluginData: AddonModAssignSavePluginData, // eslint-disable-line @typescript-eslint/no-unused-vars
siteId?: string, // eslint-disable-line @typescript-eslint/no-unused-vars
): void | Promise<void> {
// Nothing to do. // Nothing to do.
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
saveDraft(): void { saveDraft(
assignId: number, // eslint-disable-line @typescript-eslint/no-unused-vars
userId: number, // eslint-disable-line @typescript-eslint/no-unused-vars
plugin: AddonModAssignPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
data: CoreFormFields, // eslint-disable-line @typescript-eslint/no-unused-vars
siteId?: string, // eslint-disable-line @typescript-eslint/no-unused-vars
): void | Promise<void> {
// Nothing to do. // Nothing to do.
} }

View File

@ -15,8 +15,10 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreWSFile } from '@services/ws'; import { CoreWSFile } from '@services/ws';
import { Translate } from '@singletons'; import { Translate } from '@singletons';
import { AddonModAssignPlugin } from '../assign'; import { AddonModAssignAssign, AddonModAssignPlugin, AddonModAssignSavePluginData, AddonModAssignSubmission } from '../assign';
import { AddonModAssignSubmissionHandler } from '../submission-delegate'; import { AddonModAssignSubmissionHandler } from '../submission-delegate';
import { CoreFormFields } from '@singletons/form';
import { AddonModAssignSubmissionsDBRecordFormatted } from '../assign-offline';
/** /**
* Default handler used when a submission plugin doesn't have a specific implementation. * Default handler used when a submission plugin doesn't have a specific implementation.
@ -30,42 +32,71 @@ export class AddonModAssignDefaultSubmissionHandler implements AddonModAssignSub
/** /**
* @inheritdoc * @inheritdoc
*/ */
canEditOffline(): boolean | Promise<boolean> { canEditOffline(
assign: AddonModAssignAssign, // eslint-disable-line @typescript-eslint/no-unused-vars
submission: AddonModAssignSubmission, // eslint-disable-line @typescript-eslint/no-unused-vars
plugin: AddonModAssignPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
): boolean | Promise<boolean> {
return false; return false;
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
isEmpty(): boolean { isEmpty(
assign: AddonModAssignAssign, // eslint-disable-line @typescript-eslint/no-unused-vars
plugin: AddonModAssignPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
): boolean {
return true; return true;
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
clearTmpData(): void { clearTmpData(
assign: AddonModAssignAssign, // eslint-disable-line @typescript-eslint/no-unused-vars
submission: AddonModAssignSubmission, // eslint-disable-line @typescript-eslint/no-unused-vars
plugin: AddonModAssignPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
inputData: CoreFormFields, // eslint-disable-line @typescript-eslint/no-unused-vars
): void {
// Nothing to do. // Nothing to do.
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
copySubmissionData(): void { copySubmissionData(
assign: AddonModAssignAssign, // eslint-disable-line @typescript-eslint/no-unused-vars
plugin: AddonModAssignPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
pluginData: AddonModAssignSavePluginData, // eslint-disable-line @typescript-eslint/no-unused-vars
userId?: number, // eslint-disable-line @typescript-eslint/no-unused-vars
siteId?: string, // eslint-disable-line @typescript-eslint/no-unused-vars
): void | Promise<void> {
// Nothing to do. // Nothing to do.
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
deleteOfflineData(): void { deleteOfflineData(
assign: AddonModAssignAssign, // eslint-disable-line @typescript-eslint/no-unused-vars
submission: AddonModAssignSubmission, // eslint-disable-line @typescript-eslint/no-unused-vars
plugin: AddonModAssignPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
offlineData: AddonModAssignSubmissionsDBRecordFormatted, // eslint-disable-line @typescript-eslint/no-unused-vars
siteId?: string, // eslint-disable-line @typescript-eslint/no-unused-vars
): void | Promise<void> {
// Nothing to do. // Nothing to do.
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
getPluginFiles(): CoreWSFile[] { getPluginFiles(
assign: AddonModAssignAssign, // eslint-disable-line @typescript-eslint/no-unused-vars
submission: AddonModAssignSubmission, // eslint-disable-line @typescript-eslint/no-unused-vars
plugin: AddonModAssignPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
siteId?: string, // eslint-disable-line @typescript-eslint/no-unused-vars
): CoreWSFile[] | Promise<CoreWSFile[]> {
return []; return [];
} }
@ -93,21 +124,34 @@ export class AddonModAssignDefaultSubmissionHandler implements AddonModAssignSub
/** /**
* @inheritdoc * @inheritdoc
*/ */
getSizeForCopy(): number { getSizeForCopy(
assign: AddonModAssignAssign, // eslint-disable-line @typescript-eslint/no-unused-vars
plugin: AddonModAssignPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
): number | Promise<number> {
return 0; return 0;
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
getSizeForEdit(): number { getSizeForEdit(
assign: AddonModAssignAssign, // eslint-disable-line @typescript-eslint/no-unused-vars
submission: AddonModAssignSubmission, // eslint-disable-line @typescript-eslint/no-unused-vars
plugin: AddonModAssignPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
inputData: CoreFormFields, // eslint-disable-line @typescript-eslint/no-unused-vars
): number | Promise<number> {
return 0; return 0;
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
hasDataChanged(): boolean { async hasDataChanged(
assign: AddonModAssignAssign, // eslint-disable-line @typescript-eslint/no-unused-vars
submission: AddonModAssignSubmission, // eslint-disable-line @typescript-eslint/no-unused-vars
plugin: AddonModAssignPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
inputData: CoreFormFields, // eslint-disable-line @typescript-eslint/no-unused-vars
): Promise<boolean> {
return false; return false;
} }
@ -121,28 +165,49 @@ export class AddonModAssignDefaultSubmissionHandler implements AddonModAssignSub
/** /**
* @inheritdoc * @inheritdoc
*/ */
isEnabledForEdit(): boolean { isEnabledForEdit(): boolean | Promise<boolean> {
return false; return false;
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
async prefetch(): Promise<void> { async prefetch(
assign: AddonModAssignAssign, // eslint-disable-line @typescript-eslint/no-unused-vars
submission: AddonModAssignSubmission, // eslint-disable-line @typescript-eslint/no-unused-vars
plugin: AddonModAssignPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
siteId?: string, // eslint-disable-line @typescript-eslint/no-unused-vars
): Promise<void> {
return; return;
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
prepareSubmissionData(): void { prepareSubmissionData(
assign: AddonModAssignAssign, // eslint-disable-line @typescript-eslint/no-unused-vars
submission: AddonModAssignSubmission, // eslint-disable-line @typescript-eslint/no-unused-vars
plugin: AddonModAssignPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
inputData: CoreFormFields, // eslint-disable-line @typescript-eslint/no-unused-vars
pluginData: AddonModAssignSavePluginData, // eslint-disable-line @typescript-eslint/no-unused-vars
offline?: boolean, // eslint-disable-line @typescript-eslint/no-unused-vars
userId?: number, // eslint-disable-line @typescript-eslint/no-unused-vars
siteId?: string, // eslint-disable-line @typescript-eslint/no-unused-vars
): void | Promise<void> {
// Nothing to do. // Nothing to do.
} }
/** /**
* @inheritdoc * @inheritdoc
*/ */
prepareSyncData(): void { prepareSyncData(
assign: AddonModAssignAssign, // eslint-disable-line @typescript-eslint/no-unused-vars
submission: AddonModAssignSubmission, // eslint-disable-line @typescript-eslint/no-unused-vars
plugin: AddonModAssignPlugin, // eslint-disable-line @typescript-eslint/no-unused-vars
offlineData: AddonModAssignSubmissionsDBRecordFormatted, // eslint-disable-line @typescript-eslint/no-unused-vars
pluginData: AddonModAssignSavePluginData, // eslint-disable-line @typescript-eslint/no-unused-vars
siteId?: string, // eslint-disable-line @typescript-eslint/no-unused-vars
): void | Promise<void> {
// Nothing to do. // Nothing to do.
} }

View File

@ -194,7 +194,7 @@ export interface AddonModAssignSubmissionHandler extends CoreDelegateHandler {
submission: AddonModAssignSubmission, submission: AddonModAssignSubmission,
plugin: AddonModAssignPlugin, plugin: AddonModAssignPlugin,
inputData: CoreFormFields, inputData: CoreFormFields,
): boolean | Promise<boolean>; ): Promise<boolean>;
/** /**
* Whether or not the handler is enabled for edit on a site level. * Whether or not the handler is enabled for edit on a site level.

View File

@ -30,11 +30,7 @@ export class AddonModAssignSubmissionCommentsHandlerService implements AddonModA
type = 'comments'; type = 'comments';
/** /**
* Whether the plugin can be edited in offline for existing submissions. In general, this should return false if the * @inheritdoc
* plugin uses Moodle filters. The reason is that the app only prefetches filtered data, and the user should edit
* unfiltered data.
*
* @returns Boolean or promise resolved with boolean: whether it can be edited in offline.
*/ */
canEditOffline(): boolean { canEditOffline(): boolean {
// This plugin is read only, but return true to prevent blocking the edition. // This plugin is read only, but return true to prevent blocking the edition.
@ -42,44 +38,28 @@ export class AddonModAssignSubmissionCommentsHandlerService implements AddonModA
} }
/** /**
* Return the Component to use to display the plugin data, either in read or in edit mode. * @inheritdoc
* It's recommended to return the class of the component, but you can also return an instance of the component.
*
* @param plugin The plugin object.
* @param edit Whether the user is editing.
* @returns The component (or promise resolved with component) to use, undefined if not found.
*/ */
getComponent(plugin: AddonModAssignPlugin, edit = false): Type<AddonModAssignSubmissionPluginBaseComponent> | undefined { getComponent(plugin: AddonModAssignPlugin, edit = false): Type<AddonModAssignSubmissionPluginBaseComponent> | undefined {
return edit ? undefined : AddonModAssignSubmissionCommentsComponent; return edit ? undefined : AddonModAssignSubmissionCommentsComponent;
} }
/** /**
* Whether or not the handler is enabled on a site level. * @inheritdoc
*
* @returns True or promise resolved with true if enabled.
*/ */
async isEnabled(): Promise<boolean> { async isEnabled(): Promise<boolean> {
return true; return true;
} }
/** /**
* Whether or not the handler is enabled for edit on a site level. * @inheritdoc
*
* @returns Whether or not the handler is enabled for edit on a site level.
*/ */
isEnabledForEdit(): boolean{ isEnabledForEdit(): boolean{
return true; return true;
} }
/** /**
* Prefetch any required data for the plugin. * @inheritdoc
* This should NOT prefetch files. Files to be prefetched should be returned by the getPluginFiles function.
*
* @param assign The assignment.
* @param submission The submission.
* @param plugin The plugin object.
* @param siteId Site ID. If not defined, current site.
* @returns Promise resolved when done.
*/ */
async prefetch( async prefetch(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,

View File

@ -45,11 +45,7 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
type = 'file'; type = 'file';
/** /**
* Whether the plugin can be edited in offline for existing submissions. In general, this should return false if the * @inheritdoc
* plugin uses Moodle filters. The reason is that the app only prefetches filtered data, and the user should edit
* unfiltered data.
*
* @returns Boolean or promise resolved with boolean: whether it can be edited in offline.
*/ */
canEditOffline(): boolean { canEditOffline(): boolean {
// This plugin doesn't use Moodle filters, it can be edited in offline. // This plugin doesn't use Moodle filters, it can be edited in offline.
@ -57,11 +53,7 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
} }
/** /**
* Check if a plugin has no data. * @inheritdoc
*
* @param assign The assignment.
* @param plugin The plugin object.
* @returns Whether the plugin is empty.
*/ */
isEmpty(assign: AddonModAssignAssign, plugin: AddonModAssignPlugin): boolean { isEmpty(assign: AddonModAssignAssign, plugin: AddonModAssignPlugin): boolean {
const files = AddonModAssign.getSubmissionPluginAttachments(plugin); const files = AddonModAssign.getSubmissionPluginAttachments(plugin);
@ -70,9 +62,7 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
} }
/** /**
* Should clear temporary data for a cancelled submission. * @inheritdoc
*
* @param assign The assignment.
*/ */
clearTmpData(assign: AddonModAssignAssign): void { clearTmpData(assign: AddonModAssignAssign): void {
const files = CoreFileSession.getFiles(AddonModAssignProvider.COMPONENT, assign.id); const files = CoreFileSession.getFiles(AddonModAssignProvider.COMPONENT, assign.id);
@ -85,13 +75,7 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
} }
/** /**
* This function will be called when the user wants to create a new submission based on the previous one. * @inheritdoc
* It should add to pluginData the data to send to server based in the data in plugin (previous attempt).
*
* @param assign The assignment.
* @param plugin The plugin object.
* @param pluginData Object where to store the data to send.
* @returns If the function is async, it should return a Promise resolved when done.
*/ */
async copySubmissionData( async copySubmissionData(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,
@ -106,24 +90,14 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
} }
/** /**
* Return the Component to use to display the plugin data, either in read or in edit mode. * @inheritdoc
* It's recommended to return the class of the component, but you can also return an instance of the component.
*
* @returns The component (or promise resolved with component) to use, undefined if not found.
*/ */
getComponent(): Type<AddonModAssignSubmissionPluginBaseComponent> { getComponent(): Type<AddonModAssignSubmissionPluginBaseComponent> {
return AddonModAssignSubmissionFileComponent; return AddonModAssignSubmissionFileComponent;
} }
/** /**
* Delete any stored data for the plugin and submission. * @inheritdoc
*
* @param assign The assignment.
* @param submission The submission.
* @param plugin The plugin object.
* @param offlineData Offline data stored.
* @param siteId Site ID. If not defined, current site.
* @returns If the function is async, it should return a Promise resolved when done.
*/ */
async deleteOfflineData( async deleteOfflineData(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,
@ -144,13 +118,7 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
} }
/** /**
* Get files used by this plugin. * @inheritdoc
* The files returned by this function will be prefetched when the user prefetches the assign.
*
* @param assign The assignment.
* @param submission The submission.
* @param plugin The plugin object.
* @returns The files (or promise resolved with the files).
*/ */
getPluginFiles( getPluginFiles(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,
@ -161,11 +129,7 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
} }
/** /**
* Get the size of data (in bytes) this plugin will send to copy a previous submission. * @inheritdoc
*
* @param assign The assignment.
* @param plugin The plugin object.
* @returns The size (or promise resolved with size).
*/ */
async getSizeForCopy(assign: AddonModAssignAssign, plugin: AddonModAssignPlugin): Promise<number> { async getSizeForCopy(assign: AddonModAssignAssign, plugin: AddonModAssignPlugin): Promise<number> {
const files = AddonModAssign.getSubmissionPluginAttachments(plugin); const files = AddonModAssign.getSubmissionPluginAttachments(plugin);
@ -174,12 +138,7 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
} }
/** /**
* Get the size of data (in bytes) this plugin will send to add or edit a submission. * @inheritdoc
*
* @param assign The assignment.
* @param submission The submission.
* @param plugin The plugin object.
* @returns The size (or promise resolved with size).
*/ */
async getSizeForEdit( async getSizeForEdit(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,
@ -199,12 +158,7 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
} }
/** /**
* Check if the submission data has changed for this plugin. * @inheritdoc
*
* @param assign The assignment.
* @param submission The submission.
* @param plugin The plugin object.
* @returns Boolean (or promise resolved with boolean): whether the data has changed.
*/ */
async hasDataChanged( async hasDataChanged(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,
@ -243,35 +197,21 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
} }
/** /**
* Whether or not the handler is enabled on a site level. * @inheritdoc
*
* @returns True or promise resolved with true if enabled.
*/ */
async isEnabled(): Promise<boolean> { async isEnabled(): Promise<boolean> {
return true; return true;
} }
/** /**
* Whether or not the handler is enabled for edit on a site level. * @inheritdoc
*
* @returns Whether or not the handler is enabled for edit on a site level.
*/ */
isEnabledForEdit(): boolean { isEnabledForEdit(): boolean {
return true; return true;
} }
/** /**
* Prepare and add to pluginData the data to send to the server based on the input data. * @inheritdoc
*
* @param assign The assignment.
* @param submission The submission.
* @param plugin The plugin object.
* @param inputData Data entered by the user for the submission.
* @param pluginData Object where to store the data to send.
* @param offline Whether the user is editing in offline.
* @param userId User ID. If not defined, site's current user.
* @param siteId Site ID. If not defined, current site.
* @returns If the function is async, it should return a Promise resolved when done.
*/ */
async prepareSubmissionData( async prepareSubmissionData(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,
@ -308,16 +248,7 @@ export class AddonModAssignSubmissionFileHandlerService implements AddonModAssig
} }
/** /**
* Prepare and add to pluginData the data to send to the server based on the offline data stored. * @inheritdoc
* This will be used when performing a synchronization.
*
* @param assign The assignment.
* @param submission The submission.
* @param plugin The plugin object.
* @param offlineData Offline data stored.
* @param pluginData Object where to store the data to send.
* @param siteId Site ID. If not defined, current site.
* @returns If the function is async, it should return a Promise resolved when done.
*/ */
async prepareSyncData( async prepareSyncData(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,

View File

@ -41,11 +41,7 @@ export class AddonModAssignSubmissionOnlineTextHandlerService implements AddonMo
type = 'onlinetext'; type = 'onlinetext';
/** /**
* Whether the plugin can be edited in offline for existing submissions. In general, this should return false if the * @inheritdoc
* plugin uses Moodle filters. The reason is that the app only prefetches filtered data, and the user should edit
* unfiltered data.
*
* @returns Boolean or promise resolved with boolean: whether it can be edited in offline.
*/ */
canEditOffline(): boolean { canEditOffline(): boolean {
// This plugin uses Moodle filters, it cannot be edited in offline. // This plugin uses Moodle filters, it cannot be edited in offline.
@ -53,11 +49,7 @@ export class AddonModAssignSubmissionOnlineTextHandlerService implements AddonMo
} }
/** /**
* Check if a plugin has no data. * @inheritdoc
*
* @param assign The assignment.
* @param plugin The plugin object.
* @returns Whether the plugin is empty.
*/ */
isEmpty(assign: AddonModAssignAssign, plugin: AddonModAssignPlugin): boolean { isEmpty(assign: AddonModAssignAssign, plugin: AddonModAssignPlugin): boolean {
const text = AddonModAssign.getSubmissionPluginText(plugin, true); const text = AddonModAssign.getSubmissionPluginText(plugin, true);
@ -67,15 +59,7 @@ export class AddonModAssignSubmissionOnlineTextHandlerService implements AddonMo
} }
/** /**
* This function will be called when the user wants to create a new submission based on the previous one. * @inheritdoc
* It should add to pluginData the data to send to server based in the data in plugin (previous attempt).
*
* @param assign The assignment.
* @param plugin The plugin object.
* @param pluginData Object where to store the data to send.
* @param userId User ID. If not defined, site's current user.
* @param siteId Site ID. If not defined, current site.
* @returns If the function is async, it should return a Promise resolved when done.
*/ */
async copySubmissionData( async copySubmissionData(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,
@ -102,23 +86,14 @@ export class AddonModAssignSubmissionOnlineTextHandlerService implements AddonMo
} }
/** /**
* Return the Component to use to display the plugin data, either in read or in edit mode. * @inheritdoc
* It's recommended to return the class of the component, but you can also return an instance of the component.
*
* @returns The component (or promise resolved with component) to use, undefined if not found.
*/ */
getComponent(): Type<AddonModAssignSubmissionPluginBaseComponent> { getComponent(): Type<AddonModAssignSubmissionPluginBaseComponent> {
return AddonModAssignSubmissionOnlineTextComponent; return AddonModAssignSubmissionOnlineTextComponent;
} }
/** /**
* Get files used by this plugin. * @inheritdoc
* The files returned by this function will be prefetched when the user prefetches the assign.
*
* @param assign The assignment.
* @param submission The submission.
* @param plugin The plugin object.
* @returns The files (or promise resolved with the files).
*/ */
getPluginFiles( getPluginFiles(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,
@ -129,11 +104,7 @@ export class AddonModAssignSubmissionOnlineTextHandlerService implements AddonMo
} }
/** /**
* Get the size of data (in bytes) this plugin will send to copy a previous submission. * @inheritdoc
*
* @param assign The assignment.
* @param plugin The plugin object.
* @returns The size (or promise resolved with size).
*/ */
async getSizeForCopy(assign: AddonModAssignAssign, plugin: AddonModAssignPlugin): Promise<number> { async getSizeForCopy(assign: AddonModAssignAssign, plugin: AddonModAssignPlugin): Promise<number> {
const text = AddonModAssign.getSubmissionPluginText(plugin, true); const text = AddonModAssign.getSubmissionPluginText(plugin, true);
@ -145,12 +116,7 @@ export class AddonModAssignSubmissionOnlineTextHandlerService implements AddonMo
} }
/** /**
* Get the size of data (in bytes) this plugin will send to add or edit a submission. * @inheritdoc
*
* @param assign The assignment.
* @param submission The submission.
* @param plugin The plugin object.
* @returns The size (or promise resolved with size).
*/ */
getSizeForEdit( getSizeForEdit(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,
@ -177,13 +143,7 @@ export class AddonModAssignSubmissionOnlineTextHandlerService implements AddonMo
} }
/** /**
* Check if the submission data has changed for this plugin. * @inheritdoc
*
* @param assign The assignment.
* @param submission The submission.
* @param plugin The plugin object.
* @param inputData Data entered by the user for the submission.
* @returns Boolean (or promise resolved with boolean): whether the data has changed.
*/ */
async hasDataChanged( async hasDataChanged(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,
@ -209,31 +169,21 @@ export class AddonModAssignSubmissionOnlineTextHandlerService implements AddonMo
} }
/** /**
* Whether or not the handler is enabled on a site level. * @inheritdoc
*
* @returns True or promise resolved with true if enabled.
*/ */
async isEnabled(): Promise<boolean> { async isEnabled(): Promise<boolean> {
return true; return true;
} }
/** /**
* Whether or not the handler is enabled for edit on a site level. * @inheritdoc
*
* @returns Whether or not the handler is enabled for edit on a site level.
*/ */
isEnabledForEdit(): boolean { isEnabledForEdit(): boolean {
return true; return true;
} }
/** /**
* Prepare and add to pluginData the data to send to the server based on the input data. * @inheritdoc
*
* @param assign The assignment.
* @param submission The submission.
* @param plugin The plugin object.
* @param inputData Data entered by the user for the submission.
* @param pluginData Object where to store the data to send.
*/ */
prepareSubmissionData( prepareSubmissionData(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,
@ -269,14 +219,7 @@ export class AddonModAssignSubmissionOnlineTextHandlerService implements AddonMo
} }
/** /**
* Prepare and add to pluginData the data to send to the server based on the offline data stored. * @inheritdoc
* This will be used when performing a synchronization.
*
* @param assign The assignment.
* @param submission The submission.
* @param plugin The plugin object.
* @param offlineData Offline data stored.
* @param pluginData Object where to store the data to send.
*/ */
prepareSyncData( prepareSyncData(
assign: AddonModAssignAssign, assign: AddonModAssignAssign,