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
6a1a9073
Commit
6a1a9073
authored
Apr 30, 2013
by
dcadams
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pep8 violations.
parent
7c7471d3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
14 deletions
+22
-14
lms/djangoapps/instructor/tests/test_enrollment.py
+16
-8
lms/djangoapps/instructor/views.py
+6
-6
No files found.
lms/djangoapps/instructor/tests/test_enrollment.py
View file @
6a1a9073
""" Unit tests for enrollment methods in views.py """
'''
Unit tests for enrollment methods in views.py
'''
from
django.test.utils
import
override_settings
from
django.contrib.auth.models
import
Group
,
User
...
...
@@ -12,9 +14,11 @@ from student.models import CourseEnrollment, CourseEnrollmentAllowed
@override_settings
(
MODULESTORE
=
TEST_DATA_XML_MODULESTORE
)
class
TestInstructorEnrollsStudent
(
LoginEnrollmentTestCase
):
'''
Check Enrollment/Unenrollment with/without auto-enrollment on activation
'''
def
setUp
(
self
):
xmodule
.
modulestore
.
django
.
_MODULESTORES
=
{}
self
.
full
=
modulestore
()
.
get_course
(
"edX/full/6.002_Spring_2012"
)
self
.
toy
=
modulestore
()
.
get_course
(
"edX/toy/2012_Fall"
)
...
...
@@ -52,9 +56,11 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase):
self
.
login
(
self
.
instructor
,
self
.
password
)
self
.
enroll
(
self
.
toy
)
def
test_unenrollment
(
self
):
#Do un-enrollment
'''
Do un-enrollment test
'''
course
=
self
.
toy
url
=
reverse
(
'instructor_dashboard'
,
kwargs
=
{
'course_id'
:
course
.
id
})
response
=
self
.
client
.
post
(
url
,
{
'action'
:
'Unenroll multiple students'
,
'multiple_students'
:
'student1@test.com, student2@test.com'
})
...
...
@@ -73,8 +79,10 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase):
ce
=
CourseEnrollment
.
objects
.
filter
(
course_id
=
course
.
id
,
user
=
user
)
self
.
assertEqual
(
0
,
len
(
ce
))
def
test_enrollmemt_new_student_autoenroll_on
(
self
):
'''
Do auto-enroll on test
'''
#Run the Enroll students command
course
=
self
.
toy
...
...
@@ -115,8 +123,10 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase):
ce
=
CourseEnrollment
.
objects
.
filter
(
course_id
=
course
.
id
,
user
=
user
)
self
.
assertEqual
(
1
,
len
(
ce
))
def
test_enrollmemt_new_student_autoenroll_off
(
self
):
'''
Do auto-enroll off test
'''
#Run the Enroll students command
course
=
self
.
toy
...
...
@@ -155,4 +165,3 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase):
user
=
User
.
objects
.
get
(
email
=
'test2_2@student.com'
)
ce
=
CourseEnrollment
.
objects
.
filter
(
course_id
=
course
.
id
,
user
=
user
)
self
.
assertEqual
(
0
,
len
(
ce
))
\ No newline at end of file
lms/djangoapps/instructor/views.py
View file @
6a1a9073
...
...
@@ -542,8 +542,8 @@ def instructor_dashboard(request, course_id):
elif
action
==
'Enroll multiple students'
:
students
=
request
.
POST
.
get
(
'multiple_students'
,
''
)
auto_enroll
=
request
.
POST
.
get
(
'auto_enroll'
,
False
)
!=
False
ret
=
_do_enroll_students
(
course_id
,
students
,
auto_enroll
=
auto_enroll
)
auto_enroll
=
request
.
POST
.
get
(
'auto_enroll'
,
False
)
is
not
False
ret
=
_do_enroll_students
(
course
,
course
_id
,
students
,
auto_enroll
=
auto_enroll
)
datatable
=
ret
[
'datatable'
]
elif
action
==
'Unenroll multiple students'
:
...
...
@@ -967,11 +967,11 @@ def grade_summary(request, course_id):
#-----------------------------------------------------------------------------
# enrollment
def
_do_enroll_students
(
course_id
,
students
,
overload
=
False
,
auto_enroll
=
False
):
def
_do_enroll_students
(
course
,
course
_id
,
students
,
overload
=
False
,
auto_enroll
=
False
):
"""Do the actual work of enrolling multiple students, presented as a string
of emails separated by commas or returns"""
new_students
=
get_and_clean_student_list
(
students
)
new_students
,
new_students_lc
=
get_and_clean_student_list
(
students
)
status
=
dict
([
x
,
'unprocessed'
]
for
x
in
new_students
)
if
overload
:
# delete all but staff
...
...
@@ -1035,7 +1035,7 @@ def _do_unenroll_students(course_id, students):
"""Do the actual work of un-enrolling multiple students, presented as a string
of emails separated by commas or returns"""
old_students
=
get_and_clean_student_list
(
students
)
old_students
,
old_students_lc
=
get_and_clean_student_list
(
students
)
status
=
dict
([
x
,
'unprocessed'
]
for
x
in
old_students
)
for
student
in
old_students
:
...
...
@@ -1079,7 +1079,7 @@ def get_and_clean_student_list(students):
if
''
in
students
:
students
.
remove
(
''
)
return
students
return
students
,
students_lc
#-----------------------------------------------------------------------------
# answer distribution
...
...
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