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
ae09598d
Commit
ae09598d
authored
12 years ago
by
Matthew Mongeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display textbooks in course navigation, handle in urls and views.
parent
884f33c9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
11 deletions
+43
-11
common/lib/xmodule/setup.py
+1
-0
common/lib/xmodule/xmodule/course_module.py
+5
-0
common/lib/xmodule/xmodule/textbook_module.py
+27
-0
lms/djangoapps/staticbook/views.py
+3
-5
lms/templates/course_navigation.html
+5
-4
lms/urls.py
+2
-2
No files found.
common/lib/xmodule/setup.py
View file @
ae09598d
...
...
@@ -31,6 +31,7 @@ setup(
"section = xmodule.backcompat_module:SemanticSectionDescriptor"
,
"sequential = xmodule.seq_module:SequenceDescriptor"
,
"slides = xmodule.backcompat_module:TranslateCustomTagDescriptor"
,
"textbook = xmodule.textbook_module:TextbookDescriptor"
,
"vertical = xmodule.vertical_module:VerticalDescriptor"
,
"video = xmodule.video_module:VideoDescriptor"
,
"videodev = xmodule.backcompat_module:TranslateCustomTagDescriptor"
,
...
...
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/course_module.py
View file @
ae09598d
...
...
@@ -7,6 +7,7 @@ from xmodule.graders import load_grading_policy
from
xmodule.modulestore
import
Location
from
xmodule.seq_module
import
SequenceDescriptor
,
SequenceModule
from
xmodule.timeparse
import
parse_time
,
stringify_time
from
xmodule.textbook_module
import
TextbookDescriptor
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -53,6 +54,10 @@ class CourseDescriptor(SequenceDescriptor):
return
grading_policy
@property
def
textbooks
(
self
):
return
[
child
for
child
in
self
.
get_children
()
if
type
(
child
)
==
TextbookDescriptor
]
@lazyproperty
def
grading_context
(
self
):
...
...
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/textbook_module.py
0 → 100644
View file @
ae09598d
from
xmodule.x_module
import
XModule
from
xmodule.xml_module
import
XmlDescriptor
from
lxml
import
etree
class
TextbookModule
(
XModule
):
def
__init__
(
self
,
system
,
location
,
definition
,
instance_state
=
None
,
shared_state
=
None
,
**
kwargs
):
XModule
.
__init__
(
self
,
system
,
location
,
definition
,
instance_state
,
shared_state
,
**
kwargs
)
class
TextbookDescriptor
(
XmlDescriptor
):
module_class
=
TextbookModule
def
__init__
(
self
,
system
,
definition
=
None
,
**
kwargs
):
super
(
TextbookDescriptor
,
self
)
.
__init__
(
system
,
definition
,
**
kwargs
)
self
.
title
=
self
.
metadata
[
"title"
]
@classmethod
def
definition_from_xml
(
cls
,
xml_object
,
system
):
return
{
'children'
:
[]
}
@property
def
table_of_contents
(
self
):
raw_table_of_contents
=
open
(
self
.
metadata
[
'table_of_contents_url'
],
'r'
)
# TODO: This will need to come from S3
table_of_contents
=
etree
.
parse
(
raw_table_of_contents
)
.
getroot
()
return
table_of_contents
This diff is collapsed.
Click to expand it.
lms/djangoapps/staticbook/views.py
View file @
ae09598d
...
...
@@ -6,19 +6,17 @@ from courseware.courses import get_course_with_access
from
lxml
import
etree
@login_required
def
index
(
request
,
course_id
,
page
=
0
):
def
index
(
request
,
course_id
,
book_index
,
page
=
0
):
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
staff_access
=
has_access
(
request
.
user
,
course
,
'staff'
)
# TODO: This will need to come from S3
raw_table_of_contents
=
open
(
'lms/templates/book_toc.xml'
,
'r'
)
table_of_contents
=
etree
.
parse
(
raw_table_of_contents
)
.
getroot
()
textbook
=
course
.
textbooks
[
int
(
book_index
)]
table_of_contents
=
textbook
.
table_of_contents
return
render_to_response
(
'staticbook.html'
,
{
'page'
:
int
(
page
),
'course'
:
course
,
'table_of_contents'
:
table_of_contents
,
'staff_access'
:
staff_access
})
def
index_shifted
(
request
,
course_id
,
page
):
return
index
(
request
,
course_id
=
course_id
,
page
=
int
(
page
)
+
24
)
This diff is collapsed.
Click to expand it.
lms/templates/course_navigation.html
View file @
ae09598d
...
...
@@ -16,8 +16,10 @@ def url_class(url):
<li
class=
"info"
><a
href=
"${reverse('info', args=[course.id])}"
class=
"${url_class('info')}"
>
Course Info
</a></li>
% if user.is_authenticated():
% if settings.MITX_FEATURES.get('ENABLE_TEXTBOOK'):
<li
class=
"book"
><a
href=
"${reverse('book', args=[course.id])}"
class=
"${url_class('book')}"
>
Textbook
</a></li>
% endif
% for index, textbook in enumerate(course.textbooks):
<li
class=
"book"
><a
href=
"${reverse('book', args=[course.id, index])}"
class=
"${url_class('book')}"
>
${textbook.title}
</a></li>
% endfor
% endif
% if settings.MITX_FEATURES.get('ENABLE_DISCUSSION'):
<li
class=
"discussion"
><a
href=
"${reverse('questions')}"
>
Discussion
</a></li>
% endif
...
...
@@ -34,4 +36,4 @@ def url_class(url):
</ol>
</div>
</nav>
\ No newline at end of file
</nav>
This diff is collapsed.
Click to expand it.
lms/urls.py
View file @
ae09598d
...
...
@@ -126,9 +126,9 @@ if settings.COURSEWARE_ENABLED:
#Inside the course
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/info$'
,
'courseware.views.course_info'
,
name
=
"info"
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/book$'
,
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/book
/(?P<book_index>[^/]*)/
$'
,
'staticbook.views.index'
,
name
=
"book"
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/book/(?P<page>[^/]*)$'
,
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/book/(?P<
book_index>[^/]*)/(?P<
page>[^/]*)$'
,
'staticbook.views.index'
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/book-shifted/(?P<page>[^/]*)$'
,
'staticbook.views.index_shifted'
),
...
...
This diff is collapsed.
Click to expand it.
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