Public Method Author API

duplicateActivity()

Duplicates the Activity currently being edited, navigates to the newly duplicated Activity, and saves.

You would want to use this method so that you can create your own duplicate Activity button in your application, for example.

Examples

var canDuplicate = authorApp.duplicateActivity({
    reference: 'MyNewActivityReference',
    deepCopy: true,
    duplicateSharedPassages: true,
    showConfirmationScreen: true
});
console.log(canDuplicate);

Arguments

  • duplicateActivitySettings object

    Further options for Activity duplication.

    • reference string

      The Activity reference used to identify the Activity.

      If no value is passed, the new Activity that will be created will have a UUID as the reference. If you specify a custom reference, it must not match the reference of an existing Activity in the Item bank; otherwise, the operation will fail with an error.

      Maximum length is 150 characters.

    • deepCopy boolean

      If set to true, then the Items and content of the Activity will be duplicated.

      Default: false

    • duplicateSharedPassages boolean

      If deepCopy is set to true, then setting this value to true will duplicate all shared passages within all Items.

      If set to false, shared passages will not be copied and will instead load the original instance of the shared passages for all Items.

      Note If deepCopy is set to false, this setting will be ignored.

      Default: false

    • showConfirmationScreen boolean

      If set to true, the author will be taken to the confirmation screen before the duplication begins. In addition, the deepCopy and duplicateSharedPassages settings will have no effect when this is set to true.

      If set to false, no confirmation screen is shown, the duplication happens immediately, and the deepCopy and duplicateSharedPassages settings are respected.

      The deep_copy and duplicate_shared_passages initialization options determine which options are displayed on the confirmation screen.

      Default: false

Return value

boolean

Returns true if possible to attempt duplication, or false if unable to attempt duplication. For example, the following cases will return false:

  • When the author is not currently in the Activity editor view,
  • The specified new Activity reference is not valid, or
  • The current Activity is empty.

Caveats

This method may throw an error after it has been executed, despite returning true. An asynchronous check is performed to see if an existing Activity exists and this may take some time. An error may occur if the new Activity reference is used by an existing Activity, or the Activity that will be duplicated has missing Items.

Related articles

Was this article helpful?