Author API Methods
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.
The following properties are supported.
-
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
deepCopyis set totrue, then setting this value totruewill 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
deepCopyis set tofalse, 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, thedeepCopyandduplicateSharedPassagessettings will have no effect when this is set totrue.If set to
false, no confirmation screen is shown, the duplication happens immediately, and thedeepCopyandduplicateSharedPassagessettings are respected.The
deep_copyandduplicate_shared_passagesinitialization options determine which options are displayed on the confirmation screen.Default: false
-
Return value
Type 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
referenceis 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
- Duplicating Activities
- The
activity_edit.duplicateinitialization option, which contains the global configuration options for Activity duplication behavior.