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
526bc963
Commit
526bc963
authored
Dec 19, 2014
by
Adam
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6231 from edx/adam/fix-unenroll-enroll-inst-dash
fix enrollment issue in instructor dash (ECOM-776)
parents
84a2eeb8
c1dd64c0
Hide 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 @
526bc963
...
...
@@ -35,7 +35,7 @@ class EmailEnrollmentState(object):
exists_ce
=
False
full_name
=
None
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
self
.
user
=
exists_user
...
...
@@ -88,7 +88,13 @@ def enroll_email(course_id, student_email, auto_enroll=False, email_students=Fal
previous_state
=
EmailEnrollmentState
(
course_id
,
student_email
)
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
:
email_params
[
'message'
]
=
'enrolled_enroll'
email_params
[
'email_address'
]
=
student_email
...
...
lms/djangoapps/instructor/tests/test_api.py
View file @
526bc963
...
...
@@ -1077,23 +1077,53 @@ class TestInstructorAPIEnrollment(ModuleStoreTestCase, LoginEnrollmentTestCase):
self
.
assertEqual
(
course_enrollment
.
mode
,
u'verified'
)
# 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
(
'students_update_enrollment'
,
kwargs
=
{
'course_id'
:
self
.
course
.
id
.
to_deprecated_string
()},
kwargs
=
{
'course_id'
:
course
.
id
.
to_deprecated_string
()},
)
params
=
{
'identifiers'
:
self
.
enrolled_student
.
email
,
'action'
:
'enroll'
,
'identifiers'
:
user
.
email
,
'action'
:
action
,
'email_students'
:
True
,
}
response
=
self
.
client
.
post
(
url
,
params
)
self
.
assertEqual
(
response
.
status_code
,
200
)
# 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"
)
return
response
@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