Skip to content
LRS
Learning Locker.en

LearningLocker

Migration from LearningLocker to Ralph

Exporting from LearningLocker

Coming from LearningLocker v7.1.1, the statements are located in the statements collection.

We provide a utility script for this purpose. It works by connecting to the underlying MongoDB database of LearningLocker.

It is written in bash, so either need to run it on Linux, MacOS (not tested), or from WSL2 on Windows. It relies on Docker, which should be installed using the official method for your platform. You also need to be part of the docker group, so that you can run docker without sudo.

Two MongoDB sources are supported:

  • A local or remote MongoDB database that is currently running.

Important

It currently does not support authentication

  • The whole source tree of an offline MongoDB installation.

In the first case, you can run:

./scripts/export_learning-locker_statements_collection.sh \
    --mongodb_version 3.4 \
    --mongodb_host my.mongodb.host \
    --mongodb_port 27017 \
    --out /where/to/put/the/collection.json \
    --overwrite

In the second case, you have:

./scripts/export_learning-locker_statements_collection.sh \
    --mongodb_version 3.4 \
    --mongo_path /path/to/the/mongodb/data \
    --out /where/to/put/the/collection.json \
    --overwrite

Formatting the data for Ralph

Ralph expects statements in a JSON Array format:

[
  {
    "verb": { ...  },
    "context": { ...  },
    "result": { ...  },
    "id": "9dc99b37-e920-4a68-a066-917faca28949",
    "actor": { ...  },
    "object": { ...  },
    "timestamp": "2021-11-29T23:09:00.867219+00:00"
  }, ...
]

If you followed the previous section, you exported the statements data as a succession of json objects, which look like:

// Formatted for lisibility
// In practice aach object is in a single line
{
  "_id": { ...  },
  "hasGeneratedId": ...,
  "organisation": { ...  },
  "lrs_id": { ...  },
  "client": { ...  },
  "person": ...,
  "active": ...,
  "voided": ...,
  "timestamp": { ...  },
  "stored": { ...  },
  "hash": ...,
  "agents": [ ...  ],
  "relatedAgents": [ ...  ],
  "registrations": [],
  "verbs": [ ...  ],
  "activities": [ ...  ],
  "relatedActivities": [ ...  ],
  "statement": { ...  /* xAPIstatement */ },
  "metadata": {}
}
{ ... /* another document */ }
{ ... /* and another */ }
...

In this case, we use jq to:

  • get only the actual xAPI statements,
  • convert it to a proper json array,

it looks like this:

cat ./learning_locker.collection.json | jq -s '[.[].statement]' > ./ralph.statements.json

Which you can then send to Ralph.

Caution

TODO