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
3a9542eb
Commit
3a9542eb
authored
Aug 31, 2012
by
Arjun Singh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move function; stop shadowing map; add todo about caching for _DISCUSSIONINFO
parent
3f58e1dd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
lms/djangoapps/django_comment_client/utils.py
+11
-10
No files found.
lms/djangoapps/django_comment_client/utils.py
View file @
3a9542eb
...
...
@@ -19,11 +19,11 @@ import urllib
import
pystache_custom
as
pystache
# TODO these should be cached via django's caching rather than in-memory globals
_FULLMODULES
=
None
_DISCUSSIONINFO
=
None
def
extract
(
dic
,
keys
):
return
{
k
:
dic
.
get
(
k
)
for
k
in
keys
}
...
...
@@ -67,6 +67,16 @@ def get_discussion_category_map(course):
initialize_discussion_info
(
course
)
return
_DISCUSSIONINFO
[
'category_map'
]
def
sort_map_entries
(
category_map
):
things
=
[]
for
title
,
entry
in
category_map
[
"entries"
]
.
items
():
things
.
append
((
title
,
entry
))
for
title
,
category
in
category_map
[
"subcategories"
]
.
items
():
things
.
append
((
title
,
category
))
sort_map_entries
(
category_map
[
"subcategories"
][
title
])
category_map
[
"children"
]
=
[
x
[
0
]
for
x
in
sorted
(
things
,
key
=
lambda
x
:
x
[
1
][
"sort_key"
])]
def
initialize_discussion_info
(
course
):
global
_DISCUSSIONINFO
...
...
@@ -111,15 +121,6 @@ def initialize_discussion_info(course):
node
[
level
][
"entries"
][
entry
[
"title"
]]
=
{
"id"
:
entry
[
"id"
],
"sort_key"
:
entry
[
"sort_key"
]}
def
sort_map_entries
(
map
):
things
=
[]
for
title
,
entry
in
map
[
"entries"
]
.
items
():
things
.
append
((
title
,
entry
))
for
title
,
category
in
map
[
"subcategories"
]
.
items
():
things
.
append
((
title
,
category
))
sort_map_entries
(
map
[
"subcategories"
][
title
])
map
[
"children"
]
=
[
x
[
0
]
for
x
in
sorted
(
things
,
key
=
lambda
x
:
x
[
1
][
"sort_key"
])]
sort_map_entries
(
category_map
)
_DISCUSSIONINFO
=
{}
...
...
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