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
165c0aae
Commit
165c0aae
authored
Jul 11, 2017
by
Diana Huang
Committed by
GitHub
Jul 11, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15465 from edx/andya/ccx-redirect
Implement course home redirect if user cannot enroll
parents
1d04f60b
13854fb8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
10 deletions
+41
-10
common/test/acceptance/tests/lms/test_progress_page.py
+3
-0
lms/djangoapps/courseware/courses.py
+13
-0
lms/djangoapps/courseware/views/views.py
+9
-9
openedx/features/course_experience/views/course_home.py
+16
-1
No files found.
common/test/acceptance/tests/lms/test_progress_page.py
View file @
165c0aae
...
@@ -326,6 +326,9 @@ class SubsectionGradingPolicyTest(ProgressPageBaseTest):
...
@@ -326,6 +326,9 @@ class SubsectionGradingPolicyTest(ProgressPageBaseTest):
self
.
_answer_problem_correctly
()
self
.
_answer_problem_correctly
()
self
.
progress_page
.
visit
()
self
.
progress_page
.
visit
()
# Verify the basic a11y of the progress page
self
.
progress_page
.
a11y_audit
.
check_for_accessibility_errors
()
# Verify that y-Axis labels are aria-hidden
# Verify that y-Axis labels are aria-hidden
self
.
assertEqual
([
'100
%
'
,
'true'
],
self
.
progress_page
.
y_tick_label
(
0
))
self
.
assertEqual
([
'100
%
'
,
'true'
],
self
.
progress_page
.
y_tick_label
(
0
))
self
.
assertEqual
([
'0
%
'
,
'true'
],
self
.
progress_page
.
y_tick_label
(
1
))
self
.
assertEqual
([
'0
%
'
,
'true'
],
self
.
progress_page
.
y_tick_label
(
1
))
...
...
lms/djangoapps/courseware/courses.py
View file @
165c0aae
...
@@ -131,6 +131,19 @@ def check_course_access(course, user, action, check_if_enrolled=False):
...
@@ -131,6 +131,19 @@ def check_course_access(course, user, action, check_if_enrolled=False):
raise
CourseAccessRedirect
(
reverse
(
'about_course'
,
args
=
[
unicode
(
course
.
id
)]))
raise
CourseAccessRedirect
(
reverse
(
'about_course'
,
args
=
[
unicode
(
course
.
id
)]))
def
can_self_enroll_in_course
(
course_key
):
"""
Returns True if the user can enroll themselves in a course.
Note: an example of a course that a user cannot enroll in directly
is a CCX course. For such courses, a user can only be enrolled by
a CCX coach.
"""
if
hasattr
(
course_key
,
'ccx'
):
return
False
return
True
def
find_file
(
filesystem
,
dirs
,
filename
):
def
find_file
(
filesystem
,
dirs
,
filename
):
"""
"""
Looks for a filename in a list of dirs on a filesystem, in the specified order.
Looks for a filename in a list of dirs on a filesystem, in the specified order.
...
...
lms/djangoapps/courseware/views/views.py
View file @
165c0aae
...
@@ -46,6 +46,7 @@ from courseware.access import has_access, has_ccx_coach_role
...
@@ -46,6 +46,7 @@ from courseware.access import has_access, has_ccx_coach_role
from
courseware.access_response
import
StartDateError
from
courseware.access_response
import
StartDateError
from
courseware.access_utils
import
in_preview_mode
,
is_course_open_for_learner
from
courseware.access_utils
import
in_preview_mode
,
is_course_open_for_learner
from
courseware.courses
import
(
from
courseware.courses
import
(
can_self_enroll_in_course
,
get_course
,
get_course
,
get_course_by_id
,
get_course_by_id
,
get_course_overview_with_access
,
get_course_overview_with_access
,
...
@@ -287,10 +288,10 @@ def course_info(request, course_id):
...
@@ -287,10 +288,10 @@ def course_info(request, course_id):
# if user is not enrolled in a course then app will show enroll/get register link inside course info page.
# if user is not enrolled in a course then app will show enroll/get register link inside course info page.
user_is_enrolled
=
CourseEnrollment
.
is_enrolled
(
user
,
course
.
id
)
user_is_enrolled
=
CourseEnrollment
.
is_enrolled
(
user
,
course
.
id
)
show_enroll_banner
=
request
.
user
.
is_authenticated
()
and
not
user_is_enrolled
show_enroll_banner
=
request
.
user
.
is_authenticated
()
and
not
user_is_enrolled
if
show_enroll_banner
and
hasattr
(
course_key
,
'ccx'
):
# if course is CCX and user is not enrolled/registered then do not let him open course direct via link for
# If the user is not enrolled but this is a course that does not support
# self registration. Because only CCX coach can register/enroll a student. If un-enrolled user try
# direct enrollment then redirect them to the dashboard.
# to access CCX redirect him to dashboard.
if
not
user_is_enrolled
and
not
can_self_enroll_in_course
(
course_key
):
return
redirect
(
reverse
(
'dashboard'
))
return
redirect
(
reverse
(
'dashboard'
))
# Redirect the user if they are not yet allowed to view this course
# Redirect the user if they are not yet allowed to view this course
...
@@ -351,6 +352,7 @@ def course_info(request, course_id):
...
@@ -351,6 +352,7 @@ def course_info(request, course_id):
# TODO: (Experimental Code). See https://openedx.atlassian.net/wiki/display/RET/2.+In-course+Verification+Prompts
# TODO: (Experimental Code). See https://openedx.atlassian.net/wiki/display/RET/2.+In-course+Verification+Prompts
'upgrade_link'
:
check_and_get_upgrade_link
(
request
,
user
,
course
.
id
),
'upgrade_link'
:
check_and_get_upgrade_link
(
request
,
user
,
course
.
id
),
'upgrade_price'
:
get_cosmetic_verified_display_price
(
course
),
'upgrade_price'
:
get_cosmetic_verified_display_price
(
course
),
'course_tools'
:
course_tools
,
# ENDTODO
# ENDTODO
}
}
...
@@ -681,11 +683,9 @@ def course_about(request, course_id):
...
@@ -681,11 +683,9 @@ def course_about(request, course_id):
"""
"""
course_key
=
CourseKey
.
from_string
(
course_id
)
course_key
=
CourseKey
.
from_string
(
course_id
)
if
hasattr
(
course_key
,
'ccx'
):
# If a user is not able to enroll in a course then redirect
# if un-enrolled/non-registered user try to access CCX (direct for registration)
# them away from the about page to the dashboard.
# then do not show him about page to avoid self registration.
if
not
can_self_enroll_in_course
(
course_key
):
# Note: About page will only be shown to user who is not register. So that he can register. But for
# CCX only CCX coach can enroll students.
return
redirect
(
reverse
(
'dashboard'
))
return
redirect
(
reverse
(
'dashboard'
))
with
modulestore
()
.
bulk_operations
(
course_key
):
with
modulestore
()
.
bulk_operations
(
course_key
):
...
...
openedx/features/course_experience/views/course_home.py
View file @
165c0aae
...
@@ -3,13 +3,19 @@ Views for the course home page.
...
@@ -3,13 +3,19 @@ Views for the course home page.
"""
"""
from
django.core.context_processors
import
csrf
from
django.core.context_processors
import
csrf
from
django.core.urlresolvers
import
reverse
from
django.template.loader
import
render_to_string
from
django.template.loader
import
render_to_string
from
django.utils.decorators
import
method_decorator
from
django.utils.decorators
import
method_decorator
from
django.views.decorators.cache
import
cache_control
from
django.views.decorators.cache
import
cache_control
from
django.views.decorators.csrf
import
ensure_csrf_cookie
from
django.views.decorators.csrf
import
ensure_csrf_cookie
from
courseware.access
import
has_access
from
courseware.access
import
has_access
from
courseware.courses
import
get_course_info_section
,
get_course_with_access
from
courseware.courses
import
(
can_self_enroll_in_course
,
get_course_info_section
,
get_course_with_access
,
)
from
lms.djangoapps.courseware.exceptions
import
CourseAccessRedirect
from
lms.djangoapps.courseware.views.views
import
CourseTabView
from
lms.djangoapps.courseware.views.views
import
CourseTabView
from
opaque_keys.edx.keys
import
CourseKey
from
opaque_keys.edx.keys
import
CourseKey
from
openedx.core.djangoapps.plugin_api.views
import
EdxFragmentView
from
openedx.core.djangoapps.plugin_api.views
import
EdxFragmentView
...
@@ -117,6 +123,12 @@ class CourseHomeFragmentView(EdxFragmentView):
...
@@ -117,6 +123,12 @@ class CourseHomeFragmentView(EdxFragmentView):
course_sock_fragment
=
CourseSockFragmentView
()
.
render_to_fragment
(
request
,
course
=
course
,
**
kwargs
)
course_sock_fragment
=
CourseSockFragmentView
()
.
render_to_fragment
(
request
,
course
=
course
,
**
kwargs
)
has_visited_course
,
resume_course_url
=
self
.
_get_resume_course_info
(
request
,
course_id
)
has_visited_course
,
resume_course_url
=
self
.
_get_resume_course_info
(
request
,
course_id
)
else
:
else
:
# Redirect the user to the dashboard if they are not enrolled and
# this is a course that does not support direct enrollment.
if
not
can_self_enroll_in_course
(
course_key
):
raise
CourseAccessRedirect
(
reverse
(
'dashboard'
))
# Set all the fragments
outline_fragment
=
None
outline_fragment
=
None
welcome_message_fragment
=
None
welcome_message_fragment
=
None
course_sock_fragment
=
None
course_sock_fragment
=
None
...
@@ -129,6 +141,9 @@ class CourseHomeFragmentView(EdxFragmentView):
...
@@ -129,6 +141,9 @@ class CourseHomeFragmentView(EdxFragmentView):
# Get the course tools enabled for this user and course
# Get the course tools enabled for this user and course
course_tools
=
CourseToolsPluginManager
.
get_enabled_course_tools
(
request
,
course_key
)
course_tools
=
CourseToolsPluginManager
.
get_enabled_course_tools
(
request
,
course_key
)
# Get the course tools enabled for this user and course
course_tools
=
CourseToolsPluginManager
.
get_enabled_course_tools
(
request
,
course_key
)
# Render the course home fragment
# Render the course home fragment
context
=
{
context
=
{
'request'
:
request
,
'request'
:
request
,
...
...
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