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
b1f3b7d1
Commit
b1f3b7d1
authored
Mar 29, 2016
by
Renzo Lucioni
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11971 from edx/renzo/bypass-home
Add option to bypass course home
parents
5ccb1ea0
6f495791
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
0 deletions
+63
-0
common/lib/xmodule/xmodule/course_module.py
+11
-0
common/lib/xmodule/xmodule/tests/test_course_module.py
+10
-0
lms/djangoapps/courseware/tests/test_views.py
+38
-0
lms/djangoapps/courseware/views.py
+4
-0
No files found.
common/lib/xmodule/xmodule/course_module.py
View file @
b1f3b7d1
...
@@ -752,6 +752,17 @@ class CourseFields(object):
...
@@ -752,6 +752,17 @@ class CourseFields(object):
scope
=
Scope
.
settings
scope
=
Scope
.
settings
)
)
bypass_home
=
Boolean
(
display_name
=
_
(
"Bypass Course Home"
),
help
=
_
(
"Bypass the course home tab when students arrive from the dashboard, "
"sending them directly to course content."
),
default
=
False
,
scope
=
Scope
.
settings
,
deprecated
=
True
)
enable_subsection_gating
=
Boolean
(
enable_subsection_gating
=
Boolean
(
display_name
=
_
(
"Enable Subsection Prerequisites"
),
display_name
=
_
(
"Enable Subsection Prerequisites"
),
help
=
_
(
help
=
_
(
...
...
common/lib/xmodule/xmodule/tests/test_course_module.py
View file @
b1f3b7d1
...
@@ -365,6 +365,16 @@ class SelfPacedTestCase(unittest.TestCase):
...
@@ -365,6 +365,16 @@ class SelfPacedTestCase(unittest.TestCase):
self
.
assertFalse
(
self
.
course
.
self_paced
)
self
.
assertFalse
(
self
.
course
.
self_paced
)
class
BypassHomeTestCase
(
unittest
.
TestCase
):
"""Tests for setting which allows course home to be bypassed."""
def
setUp
(
self
):
super
(
BypassHomeTestCase
,
self
)
.
setUp
()
self
.
course
=
get_dummy_course
(
'2012-12-02T12:00'
)
def
test_default
(
self
):
self
.
assertFalse
(
self
.
course
.
bypass_home
)
class
CourseDescriptorTestCase
(
unittest
.
TestCase
):
class
CourseDescriptorTestCase
(
unittest
.
TestCase
):
"""
"""
Tests for a select few functions from CourseDescriptor.
Tests for a select few functions from CourseDescriptor.
...
...
lms/djangoapps/courseware/tests/test_views.py
View file @
b1f3b7d1
...
@@ -652,6 +652,44 @@ class ViewsTestCase(ModuleStoreTestCase):
...
@@ -652,6 +652,44 @@ class ViewsTestCase(ModuleStoreTestCase):
response
=
self
.
client
.
get
(
url
)
response
=
self
.
client
.
get
(
url
)
self
.
assertRedirects
(
response
,
reverse
(
'signin_user'
)
+
'?next='
+
url
)
self
.
assertRedirects
(
response
,
reverse
(
'signin_user'
)
+
'?next='
+
url
)
def
test_bypass_course_info
(
self
):
course_id
=
unicode
(
self
.
course_key
)
request
=
self
.
request_factory
.
get
(
reverse
(
'info'
,
args
=
[
course_id
])
)
# Middleware is not supported by the request factory. Simulate a
# logged-in user by setting request.user manually.
request
.
user
=
self
.
user
mako_middleware_process_request
(
request
)
self
.
assertFalse
(
self
.
course
.
bypass_home
)
self
.
assertIsNone
(
request
.
META
.
get
(
'HTTP_REFERER'
))
# pylint: disable=no-member
response
=
views
.
course_info
(
request
,
course_id
)
self
.
assertEqual
(
response
.
status_code
,
200
)
request
.
META
[
'HTTP_REFERER'
]
=
reverse
(
'dashboard'
)
# pylint: disable=no-member
response
=
views
.
course_info
(
request
,
course_id
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
course
.
bypass_home
=
True
self
.
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
# pylint: disable=no-member
self
.
assertTrue
(
self
.
course
.
bypass_home
)
response
=
views
.
course_info
(
request
,
course_id
)
# assertRedirects would be great here, but it forces redirections to be absolute URLs.
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
response
.
url
,
reverse
(
'courseware'
,
args
=
[
course_id
])
)
request
.
META
[
'HTTP_REFERER'
]
=
'foo'
# pylint: disable=no-member
response
=
views
.
course_info
(
request
,
course_id
)
self
.
assertEqual
(
response
.
status_code
,
200
)
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
# setting TIME_ZONE_DISPLAYED_FOR_DEADLINES explicitly
# setting TIME_ZONE_DISPLAYED_FOR_DEADLINES explicitly
...
...
lms/djangoapps/courseware/views.py
View file @
b1f3b7d1
...
@@ -694,6 +694,10 @@ def course_info(request, course_id):
...
@@ -694,6 +694,10 @@ def course_info(request, course_id):
if
request
.
user
.
is_authenticated
()
and
survey
.
utils
.
must_answer_survey
(
course
,
user
):
if
request
.
user
.
is_authenticated
()
and
survey
.
utils
.
must_answer_survey
(
course
,
user
):
return
redirect
(
reverse
(
'course_survey'
,
args
=
[
unicode
(
course
.
id
)]))
return
redirect
(
reverse
(
'course_survey'
,
args
=
[
unicode
(
course
.
id
)]))
is_from_dashboard
=
reverse
(
'dashboard'
)
in
request
.
META
.
get
(
'HTTP_REFERER'
,
[])
if
course
.
bypass_home
and
is_from_dashboard
:
return
redirect
(
reverse
(
'courseware'
,
args
=
[
course_id
]))
studio_url
=
get_studio_url
(
course
,
'course_info'
)
studio_url
=
get_studio_url
(
course
,
'course_info'
)
# link to where the student should go to enroll in the course:
# link to where the student should go to enroll in the course:
...
...
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