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
75d89e81
Commit
75d89e81
authored
Jan 30, 2017
by
Andy Armstrong
Committed by
Brian Jacobel
Mar 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement a stub unified course tab
parent
4d1d709e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
165 additions
and
1 deletions
+165
-1
lms/djangoapps/courseware/tabs.py
+13
-1
lms/djangoapps/courseware/views/views.py
+53
-0
lms/templates/courseware/course-outline.html
+12
-0
lms/templates/courseware/unified-course-view.html
+72
-0
lms/urls.py
+15
-0
No files found.
lms/djangoapps/courseware/tabs.py
View file @
75d89e81
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
This module is essentially a broker to xmodule/tabs.py -- it was originally introduced to
This module is essentially a broker to xmodule/tabs.py -- it was originally introduced to
perform some LMS-specific tab display gymnastics for the Entrance Exams feature
perform some LMS-specific tab display gymnastics for the Entrance Exams feature
"""
"""
import
waffle
from
django.conf
import
settings
from
django.conf
import
settings
from
django.utils.translation
import
ugettext
as
_
,
ugettext_noop
from
django.utils.translation
import
ugettext
as
_
,
ugettext_noop
...
@@ -9,7 +11,7 @@ from courseware.access import has_access
...
@@ -9,7 +11,7 @@ from courseware.access import has_access
from
courseware.entrance_exams
import
user_can_skip_entrance_exam
from
courseware.entrance_exams
import
user_can_skip_entrance_exam
from
openedx.core.lib.course_tabs
import
CourseTabPluginManager
from
openedx.core.lib.course_tabs
import
CourseTabPluginManager
from
student.models
import
CourseEnrollment
from
student.models
import
CourseEnrollment
from
xmodule.tabs
import
CourseTab
,
CourseTabList
,
key_checker
from
xmodule.tabs
import
CourseTab
,
CourseTabList
,
key_checker
,
link_reverse_func
class
EnrolledTab
(
CourseTab
):
class
EnrolledTab
(
CourseTab
):
...
@@ -34,6 +36,16 @@ class CoursewareTab(EnrolledTab):
...
@@ -34,6 +36,16 @@ class CoursewareTab(EnrolledTab):
is_movable
=
False
is_movable
=
False
is_default
=
False
is_default
=
False
@property
def
link_func
(
self
):
"""
Returns a function that computes the URL for this tab.
"""
if
waffle
.
switch_is_active
(
'unified_course_view'
):
return
link_reverse_func
(
'unified_course_view'
)
else
:
return
link_reverse_func
(
'courseware'
)
class
CourseInfoTab
(
CourseTab
):
class
CourseInfoTab
(
CourseTab
):
"""
"""
...
...
lms/djangoapps/courseware/views/views.py
View file @
75d89e81
...
@@ -25,6 +25,7 @@ from django.http import (
...
@@ -25,6 +25,7 @@ from django.http import (
QueryDict
,
QueryDict
,
)
)
from
django.shortcuts
import
redirect
from
django.shortcuts
import
redirect
from
django.template.loader
import
render_to_string
from
django.utils.decorators
import
method_decorator
from
django.utils.decorators
import
method_decorator
from
django.utils.timezone
import
UTC
from
django.utils.timezone
import
UTC
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext
as
_
...
@@ -1623,3 +1624,55 @@ def financial_assistance_form(request):
...
@@ -1623,3 +1624,55 @@ def financial_assistance_form(request):
}
}
],
],
})
})
class
UnifiedCourseView
(
View
):
"""
Unified view for a course.
"""
@method_decorator
(
login_required
)
@method_decorator
(
ensure_csrf_cookie
)
@method_decorator
(
cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
))
@method_decorator
(
ensure_valid_course_key
)
def
get
(
self
,
request
,
course_id
):
"""
Displays the main view for the specified course.
Arguments:
request: HTTP request
course_id (unicode): course id
"""
course_key
=
CourseKey
.
from_string
(
course_id
)
course
=
get_course_with_access
(
request
.
user
,
'load'
,
course_key
,
check_if_enrolled
=
True
)
# Render the outline as a fragment
outline_fragment
=
CourseOutlineFragmentView
()
.
render_fragment
(
request
,
course_id
=
course_id
)
# Render the entire unified course view
context
=
{
'csrf'
:
csrf
(
request
)[
'csrf_token'
],
'course'
:
course
,
'outline_fragment'
:
outline_fragment
,
'disable_courseware_js'
:
True
,
'uses_pattern_library'
:
True
,
}
return
render_to_response
(
'courseware/unified-course-view.html'
,
context
)
class
CourseOutlineFragmentView
(
FragmentView
):
"""
Course outline fragment to be shown in the unified course view.
"""
def
render_fragment
(
self
,
request
,
course_id
=
None
):
"""
Renders the course outline as a fragment.
"""
course_key
=
CourseKey
.
from_string
(
course_id
)
course
=
get_course_with_access
(
request
.
user
,
'load'
,
course_key
,
check_if_enrolled
=
True
)
context
=
{
'csrf'
:
csrf
(
request
)[
'csrf_token'
],
'course'
:
course
,
}
html
=
render_to_string
(
'courseware/course-outline.html'
,
context
)
return
Fragment
(
html
)
lms/templates/courseware/course-outline.html
0 → 100644
View file @
75d89e81
## mako
<
%
namespace
name=
'static'
file=
'../static_content.html'
/>
<
%!
import
json
from
django
.
utils
.
translation
import
ugettext
as
_
%
>
<section
class=
"course-outline"
id=
"course-outline"
>
<p>
Hello, world!
</p>
</section>
lms/templates/courseware/unified-course-view.html
0 → 100644
View file @
75d89e81
## mako
<
%!
main_css =
"style-main-v2"
%
>
<
%
page
expression_filter=
"h"
/>
<
%
inherit
file=
"../main.html"
/>
<
%
namespace
name=
'static'
file=
'../static_content.html'
/>
<
%
def
name=
"online_help_token()"
><
%
return
"
courseware
"
%
></
%
def>
<
%
def
name=
"course_name()"
>
<
%
return
_
("{
course_number
}
Courseware
").
format
(
course_number=
course.display_number_with_default)
%
>
</
%
def>
<
%!
import
json
from
django
.
utils
.
translation
import
ugettext
as
_
from
django
.
template
.
defaultfilters
import
escapejs
from
django
.
core
.
urlresolvers
import
reverse
from
django_comment_client
.
permissions
import
has_permission
from
openedx
.
core
.
djangolib
.
js_utils
import
dump_js_escaped_json
,
js_escaped_string
from
openedx
.
core
.
djangolib
.
markup
import
HTML
%
>
<
%
block
name=
"bodyclass"
>
course
</
%
block>
<
%
block
name=
"pagetitle"
>
${course_name()}
</
%
block>
<
%
include
file=
"../courseware/course_navigation.html"
args=
"active_page='courseware'"
/>
<
%
block
name=
"headextra"
>
${HTML(outline_fragment.head_html())}
</
%
block>
<
%
block
name=
"js_extra"
>
${HTML(outline_fragment.foot_html())}
</
%
block>
<
%
block
name=
"content"
>
<section
class=
"course-view container"
id=
"course-container"
>
<header
class=
"page-header has-secondary"
>
## Breadcrumb navigation
<div
class=
"page-header-main"
>
<nav
aria-label=
"${_('Discussions')}"
class=
"sr-is-focusable"
tabindex=
"-1"
>
<div
class=
"has-breadcrumbs"
></div>
</nav>
</div>
<div
class=
"page-header-secondary"
>
<div
class=
"form-actions"
>
<a
class=
"btn btn-small"
href=
"${reverse('courseware', kwargs={'course_id': unicode(course.id.to_deprecated_string())})}"
>
${_("Resume Course")}
</a>
</div>
<div
class=
"page-header-search"
>
<form
class=
"search-form"
role=
"search"
>
<label
class=
"field-label sr-only"
for=
"search"
id=
"search-hint"
>
Search the course
</label>
<input
class=
"field-input input-text search-input"
type=
"search"
name=
"search"
id=
"search"
placeholder=
"Search the course"
/>
<button
class=
"btn btn-small search-btn"
type=
"button"
>
Search
</button>
</form>
</div>
</div>
</header>
<div
class=
"page-content"
>
${HTML(outline_fragment.body_html())}
</div>
</section>
</
%
block>
lms/urls.py
View file @
75d89e81
...
@@ -11,6 +11,7 @@ from django.conf.urls.static import static
...
@@ -11,6 +11,7 @@ from django.conf.urls.static import static
from
courseware.views.views
import
CourseTabView
,
EnrollStaffView
,
StaticCourseTabView
from
courseware.views.views
import
CourseTabView
,
EnrollStaffView
,
StaticCourseTabView
from
config_models.views
import
ConfigurationModelCurrentAPIView
from
config_models.views
import
ConfigurationModelCurrentAPIView
from
courseware.views.index
import
CoursewareIndex
from
courseware.views.index
import
CoursewareIndex
from
courseware.views.views
import
UnifiedCourseView
,
CourseOutlineFragmentView
from
openedx.core.djangoapps.auth_exchange.views
import
LoginWithAccessTokenView
from
openedx.core.djangoapps.auth_exchange.views
import
LoginWithAccessTokenView
from
openedx.core.djangoapps.catalog.models
import
CatalogIntegration
from
openedx.core.djangoapps.catalog.models
import
CatalogIntegration
from
openedx.core.djangoapps.programs.models
import
ProgramsApiConfig
from
openedx.core.djangoapps.programs.models
import
ProgramsApiConfig
...
@@ -380,6 +381,20 @@ urlpatterns += (
...
@@ -380,6 +381,20 @@ urlpatterns += (
),
),
url
(
url
(
r'^courses/{}/course/?$'
.
format
(
settings
.
COURSE_ID_PATTERN
,
),
UnifiedCourseView
.
as_view
(),
name
=
'unified_course_view'
,
),
url
(
r'^courses/{}/course/outline?$'
.
format
(
settings
.
COURSE_ID_PATTERN
,
),
CourseOutlineFragmentView
.
as_view
(),
name
=
'course_outline_fragment_view'
,
),
url
(
r'^courses/{}/courseware/?$'
.
format
(
r'^courses/{}/courseware/?$'
.
format
(
settings
.
COURSE_ID_PATTERN
,
settings
.
COURSE_ID_PATTERN
,
),
),
...
...
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