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
b5ab7660
Commit
b5ab7660
authored
Mar 06, 2013
by
Brian Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial framework for htmlbook
parent
cde4cdf8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
3 deletions
+60
-3
common/lib/xmodule/xmodule/course_module.py
+7
-0
lms/djangoapps/courseware/tabs.py
+11
-0
lms/djangoapps/staticbook/views.py
+37
-3
lms/urls.py
+5
-0
No files found.
common/lib/xmodule/xmodule/course_module.py
View file @
b5ab7660
...
...
@@ -358,6 +358,13 @@ class CourseDescriptor(SequenceDescriptor):
"""
return
self
.
metadata
.
get
(
'pdf_textbooks'
)
@property
def
html_textbooks
(
self
):
"""
Return the html_textbooks config, as a python object, or None if not specified.
"""
return
self
.
metadata
.
get
(
'html_textbooks'
)
@tabs.setter
def
tabs
(
self
,
value
):
self
.
metadata
[
'tabs'
]
=
value
...
...
lms/djangoapps/courseware/tabs.py
View file @
b5ab7660
...
...
@@ -130,6 +130,17 @@ def _pdf_textbooks(tab, user, course, active_page):
for
index
,
textbook
in
enumerate
(
course
.
pdf_textbooks
)]
return
[]
def
_html_textbooks
(
tab
,
user
,
course
,
active_page
):
"""
Generates one tab per textbook. Only displays if user is authenticated.
"""
if
user
.
is_authenticated
():
# since there can be more than one textbook, active_page is e.g. "book/0".
return
[
CourseTab
(
textbook
[
'tab_title'
],
reverse
(
'html_book'
,
args
=
[
course
.
id
,
index
]),
active_page
==
"htmltextbook/{0}"
.
format
(
index
))
for
index
,
textbook
in
enumerate
(
course
.
html_textbooks
)]
return
[]
def
_staff_grading
(
tab
,
user
,
course
,
active_page
):
if
has_access
(
user
,
course
,
'staff'
):
link
=
reverse
(
'staff_grading'
,
args
=
[
course
.
id
])
...
...
lms/djangoapps/staticbook/views.py
View file @
b5ab7660
...
...
@@ -57,12 +57,46 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
# then remap all the chapter URLs as well, if they are provided.
if
'chapters'
in
textbook
:
for
entry
in
textbook
[
'chapters'
]:
entry
[
'url'
]
=
remap_static_url
(
entry
[
'url'
],
course
)
entry
[
'url'
]
=
remap_static_url
(
entry
[
'url'
],
course
)
return
render_to_response
(
'static_pdfbook.html'
,
{
'book_index'
:
book_index
,
'course'
:
course
,
{
'book_index'
:
book_index
,
'course'
:
course
,
'textbook'
:
textbook
,
'chapter'
:
chapter
,
'page'
:
page
,
'staff_access'
:
staff_access
})
@login_required
def
html_index
(
request
,
course_id
,
book_index
,
chapter
=
None
,
page
=
None
):
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
staff_access
=
has_access
(
request
.
user
,
course
,
'staff'
)
book_index
=
int
(
book_index
)
textbook
=
course
.
html_textbooks
[
book_index
]
def
remap_static_url
(
original_url
,
course
):
input_url
=
"'"
+
original_url
+
"'"
output_url
=
replace_static_urls
(
input_url
,
course
.
metadata
[
'data_dir'
],
course_namespace
=
course
.
location
)
# strip off the quotes again...
return
output_url
[
1
:
-
1
]
if
'url'
in
textbook
:
textbook
[
'url'
]
=
remap_static_url
(
textbook
[
'url'
],
course
)
# then remap all the chapter URLs as well, if they are provided.
if
'chapters'
in
textbook
:
for
entry
in
textbook
[
'chapters'
]:
entry
[
'url'
]
=
remap_static_url
(
entry
[
'url'
],
course
)
return
render_to_response
(
'static_htmlbook.html'
,
{
'book_index'
:
book_index
,
'course'
:
course
,
'textbook'
:
textbook
,
'chapter'
:
chapter
,
'page'
:
page
,
...
...
lms/urls.py
View file @
b5ab7660
...
...
@@ -285,6 +285,11 @@ if settings.COURSEWARE_ENABLED:
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/chapter/(?P<chapter>[^/]*)/(?P<page>[^/]*)$'
,
'staticbook.views.pdf_index'
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/htmlbook/(?P<book_index>[^/]*)/$'
,
'staticbook.views.html_index'
,
name
=
"html_book"
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/htmlbook/(?P<book_index>[^/]*)/(?P<page>[^/]*)$'
,
'staticbook.views.html_index'
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/courseware/?$'
,
'courseware.views.index'
,
name
=
"courseware"
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/courseware/(?P<chapter>[^/]*)/$'
,
...
...
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