Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
a82dcc0e
Commit
a82dcc0e
authored
Dec 12, 2014
by
Adam Palay
Committed by
Zia Fazal
Apr 07, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix enrollment issue in instructor dash (ECOM-776)
parent
16d8df97
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
11 deletions
+47
-11
lms/djangoapps/instructor/enrollment.py
+8
-2
lms/djangoapps/instructor/tests/test_api.py
+39
-9
No files found.
lms/djangoapps/instructor/enrollment.py
View file @
a82dcc0e
...
@@ -35,7 +35,7 @@ class EmailEnrollmentState(object):
...
@@ -35,7 +35,7 @@ class EmailEnrollmentState(object):
exists_ce
=
False
exists_ce
=
False
full_name
=
None
full_name
=
None
ceas
=
CourseEnrollmentAllowed
.
objects
.
filter
(
course_id
=
course_id
,
email
=
email
)
.
all
()
ceas
=
CourseEnrollmentAllowed
.
objects
.
filter
(
course_id
=
course_id
,
email
=
email
)
.
all
()
exists_allowed
=
len
(
ceas
)
>
0
exists_allowed
=
ceas
.
exists
()
state_auto_enroll
=
exists_allowed
and
ceas
[
0
]
.
auto_enroll
state_auto_enroll
=
exists_allowed
and
ceas
[
0
]
.
auto_enroll
self
.
user
=
exists_user
self
.
user
=
exists_user
...
@@ -88,7 +88,13 @@ def enroll_email(course_id, student_email, auto_enroll=False, email_students=Fal
...
@@ -88,7 +88,13 @@ def enroll_email(course_id, student_email, auto_enroll=False, email_students=Fal
previous_state
=
EmailEnrollmentState
(
course_id
,
student_email
)
previous_state
=
EmailEnrollmentState
(
course_id
,
student_email
)
if
previous_state
.
user
:
if
previous_state
.
user
:
CourseEnrollment
.
enroll_by_email
(
student_email
,
course_id
,
previous_state
.
mode
)
# if the student is currently unenrolled, don't enroll them in their
# previous mode
course_mode
=
u"honor"
if
previous_state
.
enrollment
:
course_mode
=
previous_state
.
mode
CourseEnrollment
.
enroll_by_email
(
student_email
,
course_id
,
course_mode
)
if
email_students
:
if
email_students
:
email_params
[
'message'
]
=
'enrolled_enroll'
email_params
[
'message'
]
=
'enrolled_enroll'
email_params
[
'email_address'
]
=
student_email
email_params
[
'email_address'
]
=
student_email
...
...
lms/djangoapps/instructor/tests/test_api.py
View file @
a82dcc0e
...
@@ -1077,23 +1077,53 @@ class TestInstructorAPIEnrollment(ModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -1077,23 +1077,53 @@ class TestInstructorAPIEnrollment(ModuleStoreTestCase, LoginEnrollmentTestCase):
self
.
assertEqual
(
course_enrollment
.
mode
,
u'verified'
)
self
.
assertEqual
(
course_enrollment
.
mode
,
u'verified'
)
# now re-enroll the student through the instructor dash
# now re-enroll the student through the instructor dash
self
.
_change_student_enrollment
(
self
.
enrolled_student
,
self
.
course
,
'enroll'
)
# affirm that the student is still in "verified" mode
course_enrollment
=
CourseEnrollment
.
objects
.
get
(
user
=
self
.
enrolled_student
,
course_id
=
self
.
course
.
id
)
self
.
assertEqual
(
course_enrollment
.
mode
,
u"verified"
)
def
test_unenroll_and_enroll_verified
(
self
):
"""
Test that unenrolling and enrolling a student from a verified track
results in that student being in an honor track
"""
course_enrollment
=
CourseEnrollment
.
objects
.
get
(
user
=
self
.
enrolled_student
,
course_id
=
self
.
course
.
id
)
# upgrade enrollment
course_enrollment
.
mode
=
u'verified'
course_enrollment
.
save
()
self
.
assertEqual
(
course_enrollment
.
mode
,
u'verified'
)
self
.
_change_student_enrollment
(
self
.
enrolled_student
,
self
.
course
,
'unenroll'
)
self
.
_change_student_enrollment
(
self
.
enrolled_student
,
self
.
course
,
'enroll'
)
course_enrollment
=
CourseEnrollment
.
objects
.
get
(
user
=
self
.
enrolled_student
,
course_id
=
self
.
course
.
id
)
self
.
assertEqual
(
course_enrollment
.
mode
,
u'honor'
)
def
_change_student_enrollment
(
self
,
user
,
course
,
action
):
"""
Helper function that posts to 'students_update_enrollment' to change
a student's enrollment
"""
url
=
reverse
(
url
=
reverse
(
'students_update_enrollment'
,
'students_update_enrollment'
,
kwargs
=
{
'course_id'
:
self
.
course
.
id
.
to_deprecated_string
()},
kwargs
=
{
'course_id'
:
course
.
id
.
to_deprecated_string
()},
)
)
params
=
{
params
=
{
'identifiers'
:
self
.
enrolled_student
.
email
,
'identifiers'
:
user
.
email
,
'action'
:
'enroll'
,
'action'
:
action
,
'email_students'
:
True
,
'email_students'
:
True
,
}
}
response
=
self
.
client
.
post
(
url
,
params
)
response
=
self
.
client
.
post
(
url
,
params
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
return
response
# affirm that the student is still in "verified" mode
course_enrollment
=
CourseEnrollment
.
objects
.
get
(
user
=
self
.
enrolled_student
,
course_id
=
self
.
course
.
id
)
self
.
assertEqual
(
course_enrollment
.
mode
,
u"verified"
)
@ddt.ddt
@ddt.ddt
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment