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
1f1a87d9
Commit
1f1a87d9
authored
Aug 10, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #379 from MITx/feature/victor/keep-accordion-state
Make accordion remember state
parents
b9459ace
1c3038ff
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
14 deletions
+20
-14
lms/djangoapps/courseware/module_render.py
+5
-4
lms/djangoapps/courseware/views.py
+3
-8
lms/static/coffee/src/navigation.coffee
+8
-1
lms/templates/accordion.html
+2
-1
lms/urls.py
+2
-0
No files found.
lms/djangoapps/courseware/module_render.py
View file @
1f1a87d9
...
...
@@ -46,7 +46,8 @@ def toc_for_course(user, request, course, active_chapter, active_section):
'format': format, 'due': due, 'active' : bool}, ...]
active is set for the section and chapter corresponding to the passed
parameters. Everything else comes from the xml, or defaults to "".
parameters, which are expected to be url_names of the chapter+section.
Everything else comes from the xml, or defaults to "".
chapters with name 'hidden' are skipped.
'''
...
...
@@ -59,8 +60,8 @@ def toc_for_course(user, request, course, active_chapter, active_section):
sections
=
list
()
for
section
in
chapter
.
get_display_items
():
active
=
(
chapter
.
display
_name
==
active_chapter
and
section
.
display
_name
==
active_section
)
active
=
(
chapter
.
url
_name
==
active_chapter
and
section
.
url
_name
==
active_section
)
hide_from_toc
=
section
.
metadata
.
get
(
'hide_from_toc'
,
'false'
)
.
lower
()
==
'true'
if
not
hide_from_toc
:
...
...
@@ -73,7 +74,7 @@ def toc_for_course(user, request, course, active_chapter, active_section):
chapters
.
append
({
'display_name'
:
chapter
.
display_name
,
'url_name'
:
chapter
.
url_name
,
'sections'
:
sections
,
'active'
:
chapter
.
display
_name
==
active_chapter
})
'active'
:
chapter
.
url
_name
==
active_chapter
})
return
chapters
...
...
lms/djangoapps/courseware/views.py
View file @
1f1a87d9
...
...
@@ -129,19 +129,14 @@ def render_accordion(request, course, chapter, section):
If chapter and section are '' or None, renders a default accordion.
course, chapter, and section are the url_names.
Returns the html string'''
# grab the table of contents
toc
=
toc_for_course
(
request
.
user
,
request
,
course
,
chapter
,
section
)
active_chapter
=
1
for
i
in
range
(
len
(
toc
)):
if
toc
[
i
][
'active'
]:
active_chapter
=
i
context
=
dict
([(
'active_chapter'
,
active_chapter
),
(
'toc'
,
toc
),
(
'course_name'
,
course
.
title
),
context
=
dict
([(
'toc'
,
toc
),
(
'course_id'
,
course
.
id
),
(
'csrf'
,
csrf
(
request
)[
'csrf_token'
])]
+
template_imports
.
items
())
return
render_to_string
(
'accordion.html'
,
context
)
...
...
lms/static/coffee/src/navigation.coffee
View file @
1f1a87d9
class
@
Navigation
constructor
:
->
if
$
(
'#accordion'
).
length
# First look for an active section
active
=
$
(
'#accordion ul:has(li.active)'
).
index
(
'#accordion ul'
)
# if we didn't find one, look for an active chapter
if
active
<
0
active
=
$
(
'#accordion h3.active'
).
index
(
'#accordion h3'
)
# if that didn't work either, default to 0
if
active
<
0
active
=
0
$
(
'#accordion'
).
bind
(
'accordionchange'
,
@
log
).
accordion
active
:
if
active
>=
0
then
active
else
1
active
:
active
header
:
'h3'
autoHeight
:
false
$
(
'#open_close_accordion a'
).
click
@
toggle
...
...
lms/templates/accordion.html
View file @
1f1a87d9
<
%!
from
django
.
core
.
urlresolvers
import
reverse
%
>
<
%
def
name=
"make_chapter(chapter)"
>
<h3><a
href=
"#"
>
${chapter['display_name']}
</a></h3>
<h3
${'
class=
"active"
'
if
'
active
'
in
chapter
and
chapter
['
active
']
else
''}
><a
href=
"#"
>
${chapter['display_name']}
</a>
</h3>
<ul>
% for section in chapter['sections']:
...
...
lms/urls.py
View file @
1f1a87d9
...
...
@@ -130,6 +130,8 @@ if settings.COURSEWARE_ENABLED:
'staticbook.views.index_shifted'
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/courseware/?$'
,
'courseware.views.index'
,
name
=
"courseware"
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/courseware/(?P<chapter>[^/]*)/$'
,
'courseware.views.index'
,
name
=
"courseware_chapter"
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/courseware/(?P<chapter>[^/]*)/(?P<section>[^/]*)/$'
,
'courseware.views.index'
,
name
=
"courseware_section"
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/profile$'
,
...
...
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