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
0251e8e1
Commit
0251e8e1
authored
Feb 24, 2016
by
Brian Beggs
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11545 from mitocw/feature/aq/support_mutiple_instances_ccx_mitocw#175
Allow multiple instances of ccx
parents
71e0ce7a
2ee91050
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
4 deletions
+33
-4
lms/djangoapps/ccx/tests/test_views.py
+6
-2
lms/djangoapps/ccx/utils.py
+24
-0
lms/djangoapps/ccx/views.py
+3
-2
No files found.
lms/djangoapps/ccx/tests/test_views.py
View file @
0251e8e1
...
...
@@ -185,7 +185,7 @@ class TestCoachDashboard(CcxTestCase, LoginEnrollmentTestCase):
'<form action=".+create_ccx"'
,
response
.
content
))
def
test_create_ccx
(
self
):
def
test_create_ccx
(
self
,
ccx_name
=
'New CCX'
):
"""
Create CCX. Follow redirect to coach dashboard, confirm we see
the coach dashboard for the new CCX.
...
...
@@ -196,7 +196,7 @@ class TestCoachDashboard(CcxTestCase, LoginEnrollmentTestCase):
'create_ccx'
,
kwargs
=
{
'course_id'
:
unicode
(
self
.
course
.
id
)})
response
=
self
.
client
.
post
(
url
,
{
'name'
:
'New CCX'
})
response
=
self
.
client
.
post
(
url
,
{
'name'
:
ccx_name
})
self
.
assertEqual
(
response
.
status_code
,
302
)
url
=
response
.
get
(
'location'
)
# pylint: disable=no-member
response
=
self
.
client
.
get
(
url
)
...
...
@@ -221,6 +221,10 @@ class TestCoachDashboard(CcxTestCase, LoginEnrollmentTestCase):
role
=
CourseCcxCoachRole
(
course_key
)
self
.
assertTrue
(
role
.
has_user
(
self
.
coach
,
refresh
=
True
))
@ddt.data
(
"CCX demo 1"
,
"CCX demo 2"
,
"CCX demo 3"
)
def
test_create_multiple_ccx
(
self
,
ccx_name
):
self
.
test_create_ccx
(
ccx_name
)
def
test_get_date
(
self
):
"""
Assert that get_date returns valid date.
...
...
lms/djangoapps/ccx/utils.py
View file @
0251e8e1
...
...
@@ -127,6 +127,30 @@ def get_ccx_for_coach(course, coach):
return
None
def
get_ccx_by_ccx_id
(
course
,
coach
,
ccx_id
):
"""
Finds a CCX of given coach on given master course.
Arguments:
course (CourseDescriptor): Master course
coach (User): Coach to ccx
ccx_id (long): Id of ccx
Returns:
ccx (CustomCourseForEdX): Instance of CCX.
"""
try
:
ccx
=
CustomCourseForEdX
.
objects
.
get
(
id
=
ccx_id
,
course_id
=
course
.
id
,
coach
=
coach
)
except
CustomCourseForEdX
.
DoesNotExist
:
return
None
return
ccx
def
get_valid_student_email
(
identifier
):
"""
Helper function to get an user email from an identifier and validate it.
...
...
lms/djangoapps/ccx/views.py
View file @
0251e8e1
...
...
@@ -56,6 +56,7 @@ from lms.djangoapps.ccx.utils import (
ccx_course
,
ccx_students_enrolling_center
,
get_ccx_for_coach
,
get_ccx_by_ccx_id
,
get_date
,
parse_date
,
prep_course_for_grading
,
...
...
@@ -93,8 +94,8 @@ def coach_dashboard(view):
# if there is a ccx, we must validate that it is the ccx for this coach
if
ccx
is
not
None
:
coach_ccx
=
get_ccx_
for_coach
(
course
,
request
.
user
)
if
coach_ccx
is
None
or
coach_ccx
.
id
!=
ccx
.
id
:
coach_ccx
=
get_ccx_
by_ccx_id
(
course
,
request
.
user
,
ccx
.
id
)
if
coach_ccx
is
None
:
return
HttpResponseForbidden
(
_
(
'You must be the coach for this ccx to access this view'
)
)
...
...
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