There are many commands available in Tutor and Open edX. View the Tutor documentation to learn about these commands and how to use them.
For example, Tutor has a command to import the demo course:
tutor local importdemocourse
You can list all available
Tutor commands by running:
tutor local -h
For example, Tutor uses the Open edX commands (
manage.py) to delete a course. This command shows how to execute the Open edX command
./manage.py cms delete_course.
tutor local run cms ./manage.py cms delete_course course-v1:edX+DemoX+Demo_Course
You can list all available Open edX CMS commands by running:
tutor local run cms ./manage.py cms
You can list all available production commands by running:
tutor local run lms ./manage.py lms --settings production help
Here are some common commands that we use
Create a course
# tutor local run cms ./manage.py cms create_course split email ORG CODE DATE tutor local run cms ./manage.py cms create_course split firstname.lastname@example.org ENG CS_01 2021_2022
Delete a course
# Requires a prompt to confirm tutor local run cms ./manage.py cms delete_course course_ID # Delete without a prompt (no undo) yes | tutor local run cms ./manage.py cms delete_course course_ID
tutor local run lms ./manage.py lms manage_user username email_address
Change user password
tutor local run lms ./manage.py lms changepassword username
tutor local run lms ./manage.py lms manage_user --remove username email_address
Bulk commands can be run inside of the docker stack to speed up the process. Otherwise, each iteration requires starting the required containers. We use methods like this to import and export courses. This example shows how to create a user and set their password without user interaction.
First, start the stack. This example mounts a volume in
/tmp/volume to share data (course imports, exports, user accounts, etc.) between the container and host.
docker-compose -f /home/$USER/.local/share/tutor/env/local/docker-compose.yml \ -f /home/$USER/.local/share/tutor/env/local/docker-compose.prod.yml \ --project-name tutor_local run \ --volume /tmp/volume:/tmp/volume \ --rm lms /bin/bash
You can then execute commands in a shell script using
./manage.py to create and modify user accounts.
An example script to create users programmatically might look like something like:
USER=jim EMAILemail@example.com PASS=8QkbL4QDT1 # Create the user account using 'manage_user' /openedx/edx-platform/manage.py lms manage_user jim firstname.lastname@example.org # Call the script in the volume directory to change the password without user interation /tmp/volume/changepass.sh $USER $PASS
#!/usr/bin/expect -f # Changes a user's pasword without interaction. # - Must install expect first # - apt install expect set user [lindex $argv 0] set pass [lindex $argv 1] spawn python /openedx/edx-platform/manage.py lms changepassword $user expect "Password:" send "$pass\r" expect "Password (again):" send "$pass\r" expect eof