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
cda95d7a
Commit
cda95d7a
authored
Oct 27, 2015
by
Peter Pinch
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10251 from mitocw/fix/jf/enroll-coach-on-create-ccx
Enroll the coach in the CCX on creation
parents
d39d0cf5
a3a7ff24
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
5 deletions
+28
-5
lms/djangoapps/ccx/tests/test_views.py
+16
-3
lms/djangoapps/ccx/views.py
+12
-2
No files found.
lms/djangoapps/ccx/tests/test_views.py
View file @
cda95d7a
...
@@ -6,6 +6,7 @@ import json
...
@@ -6,6 +6,7 @@ import json
import
re
import
re
import
pytz
import
pytz
import
ddt
import
ddt
import
urlparse
from
mock
import
patch
,
MagicMock
from
mock
import
patch
,
MagicMock
from
nose.plugins.attrib
import
attr
from
nose.plugins.attrib
import
attr
...
@@ -14,12 +15,13 @@ from courseware.courses import get_course_by_id
...
@@ -14,12 +15,13 @@ from courseware.courses import get_course_by_id
from
courseware.tests.factories
import
StudentModuleFactory
from
courseware.tests.factories
import
StudentModuleFactory
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
courseware.tabs
import
get_course_tab_list
from
courseware.tabs
import
get_course_tab_list
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
,
resolve
from
django.utils.timezone
import
UTC
from
django.utils.timezone
import
UTC
from
django.test.utils
import
override_settings
from
django.test.utils
import
override_settings
from
django.test
import
RequestFactory
from
django.test
import
RequestFactory
from
edxmako.shortcuts
import
render_to_response
from
edxmako.shortcuts
import
render_to_response
from
request_cache.middleware
import
RequestCache
from
request_cache.middleware
import
RequestCache
from
opaque_keys.edx.keys
import
CourseKey
from
student.roles
import
CourseCcxCoachRole
from
student.roles
import
CourseCcxCoachRole
from
student.models
import
(
from
student.models
import
(
CourseEnrollment
,
CourseEnrollment
,
...
@@ -200,7 +202,7 @@ class TestCoachDashboard(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -200,7 +202,7 @@ class TestCoachDashboard(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
self
.
make_coach
()
self
.
make_coach
()
url
=
reverse
(
url
=
reverse
(
'ccx_coach_dashboard'
,
'ccx_coach_dashboard'
,
kwargs
=
{
'course_id'
:
self
.
course
.
id
.
to_deprecated_string
(
)})
kwargs
=
{
'course_id'
:
unicode
(
self
.
course
.
id
)})
response
=
self
.
client
.
get
(
url
)
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
re
.
search
(
self
.
assertTrue
(
re
.
search
(
...
@@ -212,15 +214,26 @@ class TestCoachDashboard(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -212,15 +214,26 @@ class TestCoachDashboard(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
Create CCX. Follow redirect to coach dashboard, confirm we see
Create CCX. Follow redirect to coach dashboard, confirm we see
the coach dashboard for the new CCX.
the coach dashboard for the new CCX.
"""
"""
self
.
make_coach
()
self
.
make_coach
()
url
=
reverse
(
url
=
reverse
(
'create_ccx'
,
'create_ccx'
,
kwargs
=
{
'course_id'
:
self
.
course
.
id
.
to_deprecated_string
()})
kwargs
=
{
'course_id'
:
unicode
(
self
.
course
.
id
)})
response
=
self
.
client
.
post
(
url
,
{
'name'
:
'New CCX'
})
response
=
self
.
client
.
post
(
url
,
{
'name'
:
'New CCX'
})
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
response
.
status_code
,
302
)
url
=
response
.
get
(
'location'
)
# pylint: disable=no-member
url
=
response
.
get
(
'location'
)
# pylint: disable=no-member
response
=
self
.
client
.
get
(
url
)
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
# Get the ccx_key
path
=
urlparse
.
urlparse
(
url
)
.
path
resolver
=
resolve
(
path
)
ccx_key
=
resolver
.
kwargs
[
'course_id'
]
course_key
=
CourseKey
.
from_string
(
ccx_key
)
self
.
assertTrue
(
CourseEnrollment
.
is_enrolled
(
self
.
coach
,
course_key
))
self
.
assertTrue
(
re
.
search
(
'id="ccx-schedule"'
,
response
.
content
))
self
.
assertTrue
(
re
.
search
(
'id="ccx-schedule"'
,
response
.
content
))
@SharedModuleStoreTestCase.modifies_courseware
@SharedModuleStoreTestCase.modifies_courseware
...
...
lms/djangoapps/ccx/views.py
View file @
cda95d7a
...
@@ -47,7 +47,6 @@ from instructor.enrollment import (
...
@@ -47,7 +47,6 @@ from instructor.enrollment import (
unenroll_email
,
unenroll_email
,
get_email_params
,
get_email_params
,
)
)
from
.models
import
CustomCourseForEdX
from
.models
import
CustomCourseForEdX
from
.overrides
import
(
from
.overrides
import
(
get_override_for_ccx
,
get_override_for_ccx
,
...
@@ -56,7 +55,6 @@ from .overrides import (
...
@@ -56,7 +55,6 @@ from .overrides import (
bulk_delete_ccx_override_fields
,
bulk_delete_ccx_override_fields
,
)
)
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
TODAY
=
datetime
.
datetime
.
today
# for patching in tests
TODAY
=
datetime
.
datetime
.
today
# for patching in tests
...
@@ -183,7 +181,19 @@ def create_ccx(request, course, ccx=None):
...
@@ -183,7 +181,19 @@ def create_ccx(request, course, ccx=None):
override_field_for_ccx
(
ccx
,
vertical
,
hidden
,
True
)
override_field_for_ccx
(
ccx
,
vertical
,
hidden
,
True
)
ccx_id
=
CCXLocator
.
from_course_locator
(
course
.
id
,
ccx
.
id
)
# pylint: disable=no-member
ccx_id
=
CCXLocator
.
from_course_locator
(
course
.
id
,
ccx
.
id
)
# pylint: disable=no-member
url
=
reverse
(
'ccx_coach_dashboard'
,
kwargs
=
{
'course_id'
:
ccx_id
})
url
=
reverse
(
'ccx_coach_dashboard'
,
kwargs
=
{
'course_id'
:
ccx_id
})
# Enroll the coach in the course
email_params
=
get_email_params
(
course
,
auto_enroll
=
True
,
course_key
=
ccx_id
,
display_name
=
ccx
.
display_name
)
enroll_email
(
course_id
=
ccx_id
,
student_email
=
request
.
user
.
email
,
auto_enroll
=
True
,
email_students
=
True
,
email_params
=
email_params
,
)
return
redirect
(
url
)
return
redirect
(
url
)
...
...
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