Migrate user data from our platform to Open edX

Hi, We already have an ed-tech platform with 40K users. We are migrating to Open edX for our lms and cms. We are planning to run Open edX on a subdomain and use SSO for cross platform authentication. We want to migrate(perhaps copy) our user data from our platform to Open edX before launching our lms. I searched the internet for answers but was not able to find a solution. How can we migrate user data from our platform to Open edX?
Any guidance or support is appreciated. Thanks.

Hi @Sam_Joel ! Open edX does´t store too much user information by default in the user tables, only the user id, full name, email and user email.
If you can trust the IdP, it is possible to configure the third party authentication to import all the user information to the local db and skip the registration form. This way, in the first login the user would be created almost seamlessly.
Another option would be to use a manage.py function to bulk create users. However, this will not create the link between the internal user record and the sso account.

Hi @andres thank you for replying.
→ So your option 1 means that instead of pre creating users we should create users on the fly as they login using our IdP,
→ And your second option means to create a manage.py function to bulk create users.

  • So the problem we have with option 1 is that we are moving the course content and certificates as well from our existing lms so if we are creating users on the fly we wont be able to create this mappings before hand.

We want to pre- create the users and their mappings to respective courses and freeze their certificate statuses before we go for launch so ideally we want to bulk create users before launch and create the mappings between the internal account and sso on the fly as the user logins on our platform.

And if we are going with option 2 (bulk creating users) how should we do it. We are new to Open edX and we don’t have any idea on how to migrate data. It would be really helpful if you can point any references, documentation or code snippets that can help us do this.

Any guidance or support is appreciated. Thanks.

We have a script that can create accounts and enroll to a course from a csv file:

#!/bin/bash

while IFS="," read username password email name course
do
    echo "Creating user '$username' ($name), password '$password', email: $email and enrolling into $course"
    echo "sudo -u www-data /edx/bin/python.edxapp /edx/app/edxapp/edx-platform/manage.py lms --settings production create_user -u $username -p $password -e $email -n '$name'  -c $course"

    sudo -u www-data /edx/bin/python.edxapp /edx/app/edxapp/edx-platform/manage.py lms --settings production create_user -u $username -p $password -e $email -n "$name" -c $course
done < $1

Just create a CSV file with the fields username,password,email,name,course (in this order, without a row with field names) and pipe to the script.

The usage of this command is:

usage: manage.py create_user [-h] [--version] [-v {0,1,2,3}]
                             [--settings SETTINGS] [--pythonpath PYTHONPATH]
                             [--traceback] [--no-color] [-m ENROLLMENT_MODE]
                             [-u USERNAME] [-n NAME] -p PASSWORD -e EMAIL
                             [-c COURSE_ID] [-s]

This command creates and registers a user in a given course as "audit",
"verified" or "honor". example: # Enroll a user test@example.com into the demo
course # The username and name will default to "test" manage.py ...
create_user -e test@example.com -p insecure -c edX/Open_DemoX/edx_demo_course
-m verified

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  -v {0,1,2,3}, --verbosity {0,1,2,3}
                        Verbosity level; 0=minimal output, 1=normal output,
                        2=verbose output, 3=very verbose output
  --settings SETTINGS   The Python path to a settings module, e.g.
                        "myproject.settings.main". If this isn't provided, the
                        DJANGO_SETTINGS_MODULE environment variable will be
                        used.
  --pythonpath PYTHONPATH
                        A directory to add to the Python path, e.g.
                        "/home/djangoprojects/myproject".
  --traceback           Raise on CommandError exceptions
  --no-color            Don't colorize the command output.
  -m ENROLLMENT_MODE, --mode ENROLLMENT_MODE
                        Enrollment type for user for a specific course,
                        defaults to "honor"
  -u USERNAME, --username USERNAME
                        Username, defaults to "user" in the email
  -n NAME, --proper_name NAME
                        Name, defaults to "user" in the email
  -p PASSWORD, --password PASSWORD
                        Password for user
  -e EMAIL, --email EMAIL
                        Email for user
  -c COURSE_ID, --course COURSE_ID
                        Course to enroll the user in (optional)
  -s, --staff           Give user the staff bit, defaults to off

Hope it helps!

2 Likes

Thank you so much @andres for your support.