Merge pull request #9541 from edx/afzaledx/extending_auto_auth_for_verified_users

Added the ability to change the enrollment mode in the auto_auth API
This commit is contained in:
Afzal Wali Naushahi
2015-09-02 23:27:36 +05:00
4 changed files with 17 additions and 29 deletions

View File

@@ -1046,9 +1046,10 @@ class CourseEnrollment(models.Model):
`course_key` is our usual course_id string (e.g. "edX/Test101/2013_Fall)
`mode` is a string specifying what kind of enrollment this is. The
default is "honor", meaning honor certificate. Future options
may include "audit", "verified_id", etc. Please don't use it
until we have these mapped out.
default is 'honor', meaning honor certificate. Other options
include 'professional', 'verified', 'audit',
'no-id-professional' and 'credit'.
See CourseMode in common/djangoapps/course_modes/models.py.
`check_access`: if True, we check that an accessible course actually
exists for the given course_key before we enroll the student.

View File

@@ -1769,6 +1769,10 @@ def auto_auth(request):
full_name = request.GET.get('full_name', username)
is_staff = request.GET.get('staff', None)
course_id = request.GET.get('course_id', None)
# mode has to be one of 'honor'/'professional'/'verified'/'audit'/'no-id-professional'/'credit'
enrollment_mode = request.GET.get('enrollment_mode', 'honor')
course_key = None
if course_id:
course_key = CourseLocator.from_string(course_id)
@@ -1816,7 +1820,7 @@ def auto_auth(request):
# Enroll the user in a course
if course_key is not None:
CourseEnrollment.enroll(user, course_key)
CourseEnrollment.enroll(user, course_key, mode=enrollment_mode)
# Apply the roles
for role_name in role_names: