Skip to content

Add clone statement util #132

Open
Open
@garemoko

Description

@garemoko

I created a clone statement function as part of a tool which takes statements from one LRS, modifies them and then sends them to another (with a new id). I figured it might be useful to include in this library.

function cloneStatement (inStatement){
    var outStatement = JSON.parse(JSON.stringify(inStatement));
    delete outStatement.authority;
    delete outStatement.stored;
    delete outStatement.id;
    for (var property in outStatement) {
        if (outStatement.hasOwnProperty(property)) {
            if (outStatement[property] == null){
                delete outStatement[property];
            }
        }
    }
    return new TinCan.Statement(outStatement);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions