Author API Methods
duplicateItem()
Duplicates the current Item being edited. If the operation is successful, the duplicate Item is automatically loaded and saved.
All Questions and Features in the Item are fully cloned with new internal UUID references (except for passages, see caveats).
Note The duplicate Item is not persisted in the Item bank if config.item_edit.item.save.persist option is false. Item duplication using this method is not supported when editing an Item within an Activity.
Alternatively, this method can be called by passing in an object as the first argument with additional settings.
Examples
// Duplicate an Item with a new generated reference and duplicated passages
authorApp.duplicateItem('', true);
// Duplicate an Item with additional settings
authorApp.duplicateItem({
reference: 'NewReference',
showConfirmationScreen: true,
duplicateSharedPassages: true
});
Arguments
-
reference string object
Maximum length is 150 characters. It must not match the reference of an existing Item in the Item bank; otherwise, the operation will fail with an error. If an empty string or no value is passed, the duplicate Item that will be created will have a UUID as the reference.
-
duplicatePassages boolean
If set to to
true, passages are duplicated among Items. If set tofalse, passages are shared.Default:
false
Return value
Type boolean
Returns true if it's possible to attempt duplication, or false if unable to attempt duplication, for example, when not editing an Item, the passed reference is not valid, Item is empty.
Caveats
Passages are not duplicated and will be shared between the original "master" Item and the newly duplicated Item.
Note This method may throw an error later despite returning true (boolean) if something goes wrong, for example, if the passed reference is used by an existing Item in the Item bank.