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
85c7258e
Commit
85c7258e
authored
Oct 30, 2015
by
Amir Qayyum Khan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed display name ccx course on coach dashboard
parent
e0ef89ed
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
7 deletions
+38
-7
lms/djangoapps/ccx/tests/test_views.py
+4
-0
lms/djangoapps/ccx/views.py
+28
-1
lms/djangoapps/instructor/access.py
+6
-6
No files found.
lms/djangoapps/ccx/tests/test_views.py
View file @
85c7258e
...
...
@@ -286,6 +286,10 @@ class TestCoachDashboard(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
course_enrollments
=
get_override_for_ccx
(
ccx
,
self
.
course
,
'max_student_enrollments_allowed'
)
self
.
assertEqual
(
course_enrollments
,
settings
.
CCX_MAX_STUDENTS_ALLOWED
)
# assert ccx creator has role=ccx_coach
role
=
CourseCcxCoachRole
(
course_key
)
self
.
assertTrue
(
role
.
has_user
(
self
.
coach
))
@SharedModuleStoreTestCase.modifies_courseware
@patch
(
'ccx.views.render_to_response'
,
intercept_renderer
)
@patch
(
'ccx.views.TODAY'
)
...
...
lms/djangoapps/ccx/views.py
View file @
85c7258e
...
...
@@ -42,6 +42,7 @@ from ccx_keys.locator import CCXLocator
from
student.roles
import
CourseCcxCoachRole
from
student.models
import
CourseEnrollment
from
instructor.access
import
allow_access
from
instructor.views.api
import
_split_input_list
from
instructor.views.gradebook_api
import
get_grade_book_page
from
instructor.views.tools
import
get_student_from_identifier
...
...
@@ -132,7 +133,10 @@ def dashboard(request, course, ccx=None):
}
if
ccx
:
ccx_locator
=
CCXLocator
.
from_course_locator
(
course
.
id
,
ccx
.
id
)
ccx_locator
=
CCXLocator
.
from_course_locator
(
course
.
id
,
unicode
(
ccx
.
id
))
# At this point we are done with verification that current user is ccx coach.
assign_coach_role_to_ccx
(
ccx_locator
,
request
.
user
,
course
.
id
)
schedule
=
get_ccx_schedule
(
course
,
ccx
)
grading_policy
=
get_override_for_ccx
(
ccx
,
course
,
'grading_policy'
,
course
.
grading_policy
)
...
...
@@ -147,6 +151,7 @@ def dashboard(request, course, ccx=None):
context
[
'grading_policy'
]
=
json
.
dumps
(
grading_policy
,
indent
=
4
)
context
[
'grading_policy_url'
]
=
reverse
(
'ccx_set_grading_policy'
,
kwargs
=
{
'course_id'
:
ccx_locator
})
else
:
context
[
'create_ccx_url'
]
=
reverse
(
'create_ccx'
,
kwargs
=
{
'course_id'
:
course
.
id
})
...
...
@@ -208,9 +213,31 @@ def create_ccx(request, course, ccx=None):
email_params
=
email_params
,
)
assign_coach_role_to_ccx
(
ccx_id
,
request
.
user
,
course
.
id
)
return
redirect
(
url
)
def
assign_coach_role_to_ccx
(
ccx_locator
,
user
,
master_course_id
):
"""
Check if user has ccx_coach role on master course then assign him coach role on ccx only
if role is not already assigned. Because of this coach can open dashboard from master course
as well as ccx.
:param ccx_locator: CCX key
:param user: User to whom we want to assign role.
:param master_course_id: Master course key
"""
coach_role_on_master_course
=
CourseCcxCoachRole
(
master_course_id
)
# check if user has coach role on master course
if
coach_role_on_master_course
.
has_user
(
user
):
# Check if user has coach role on ccx.
role
=
CourseCcxCoachRole
(
ccx_locator
)
if
not
role
.
has_user
(
user
):
# assign user role coach on ccx
with
ccx_course
(
ccx_locator
)
as
course
:
allow_access
(
course
,
user
,
"ccx_coach"
,
send_email
=
False
)
@ensure_csrf_cookie
@cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
)
@coach_dashboard
...
...
lms/djangoapps/instructor/access.py
View file @
85c7258e
...
...
@@ -45,25 +45,25 @@ def list_with_level(course, level):
return
ROLES
[
level
](
course
.
id
)
.
users_with_role
()
def
allow_access
(
course
,
user
,
level
):
def
allow_access
(
course
,
user
,
level
,
send_email
=
True
):
"""
Allow user access to course modification.
`level` is one of ['instructor', 'staff', 'beta']
"""
_change_access
(
course
,
user
,
level
,
'allow'
)
_change_access
(
course
,
user
,
level
,
'allow'
,
send_email
)
def
revoke_access
(
course
,
user
,
level
):
def
revoke_access
(
course
,
user
,
level
,
send_email
=
True
):
"""
Revoke access from user to course modification.
`level` is one of ['instructor', 'staff', 'beta']
"""
_change_access
(
course
,
user
,
level
,
'revoke'
)
_change_access
(
course
,
user
,
level
,
'revoke'
,
send_email
)
def
_change_access
(
course
,
user
,
level
,
action
):
def
_change_access
(
course
,
user
,
level
,
action
,
send_email
=
True
):
"""
Change access of user.
...
...
@@ -85,7 +85,7 @@ def _change_access(course, user, level, action):
course_id
=
course
.
id
,
student_email
=
user
.
email
,
auto_enroll
=
True
,
email_students
=
True
,
email_students
=
send_email
,
email_params
=
email_params
,
)
role
.
add_users
(
user
)
...
...
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