Added master's track
Added mode option to course enrollment management command
This commit is contained in:
@@ -12,9 +12,10 @@ class Command(BaseCommand):
|
||||
Enroll a user into a course
|
||||
"""
|
||||
help = """
|
||||
This enrolls a user into a given course with the default mode (e.g., 'honor', 'audit', etc).
|
||||
This enrolls a user into a given course
|
||||
|
||||
User email and course ID are required.
|
||||
Mode is optional. It defaults to the default mode (e.g., 'honor', 'audit', etc).
|
||||
|
||||
example:
|
||||
# Enroll a user test@example.com into the demo course
|
||||
@@ -35,7 +36,14 @@ class Command(BaseCommand):
|
||||
'-c', '--course',
|
||||
nargs=1,
|
||||
required=True,
|
||||
help='course ID to enroll the user in')
|
||||
help='course ID to enroll the user in'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-m', '--mode',
|
||||
required=False,
|
||||
default=None,
|
||||
help='course mode to enroll the user in'
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
"""
|
||||
@@ -43,10 +51,11 @@ class Command(BaseCommand):
|
||||
"""
|
||||
email = options['email'][0]
|
||||
course = options['course'][0]
|
||||
mode = options['mode']
|
||||
|
||||
user = User.objects.get(email=email)
|
||||
try:
|
||||
add_enrollment(user.username, course)
|
||||
add_enrollment(user.username, course, mode=mode)
|
||||
except CourseEnrollmentExistsError:
|
||||
# If the user is already enrolled in the course, do nothing.
|
||||
pass
|
||||
|
||||
@@ -3383,6 +3383,12 @@ COURSE_ENROLLMENT_MODES = {
|
||||
"display_name": _("Honor"),
|
||||
"min_price": 0
|
||||
},
|
||||
"masters": {
|
||||
"id": 7,
|
||||
"slug": "masters",
|
||||
"display_name": _("Master's"),
|
||||
"min_price": 0
|
||||
},
|
||||
}
|
||||
|
||||
CONTENT_TYPE_GATE_GROUP_IDS = {
|
||||
|
||||
Reference in New Issue
Block a user