Top level discussions
This commit is contained in:
@@ -65,6 +65,15 @@ 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
|
||||
@@ -77,7 +86,9 @@ def initialize_discussion_info(course):
|
||||
all_modules = get_full_modules()[course_id]
|
||||
|
||||
discussion_id_map = {}
|
||||
|
||||
unexpanded_category_map = defaultdict(list)
|
||||
|
||||
for location, module in all_modules.items():
|
||||
if location.category == 'discussion':
|
||||
id = module.metadata['id']
|
||||
@@ -109,14 +120,10 @@ 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"])]
|
||||
for topic, entry in course.metadata['discussion_topics'].items():
|
||||
category_map['entries'][topic] = {"id": entry["id"],
|
||||
"sort_key": entry.get("sort_key", topic)}
|
||||
|
||||
|
||||
sort_map_entries(category_map)
|
||||
#for level in category_map["subcategories"].values():
|
||||
|
||||
@@ -9,6 +9,7 @@ class @NewPostView extends Backbone.View
|
||||
@topicId = @$(".topic").first().data("discussion_id")
|
||||
@topicText = @getFullTopicName(@$(".topic").first())
|
||||
|
||||
@maxNameWidth = 100
|
||||
@setSelectedTopic()
|
||||
|
||||
events:
|
||||
@@ -31,7 +32,6 @@ class @NewPostView extends Backbone.View
|
||||
@showTopicDropdown()
|
||||
|
||||
showTopicDropdown: () ->
|
||||
console.log "showing"
|
||||
@menuOpen = true
|
||||
@dropdownButton.addClass('dropped')
|
||||
@topicMenu.show()
|
||||
@@ -58,13 +58,9 @@ class @NewPostView extends Backbone.View
|
||||
@topicText = @getFullTopicName($target)
|
||||
@topicId = $target.data('discussion_id')
|
||||
@setSelectedTopic()
|
||||
else
|
||||
console.log "NOTHING IN "
|
||||
console.log $target
|
||||
|
||||
setSelectedTopic: ->
|
||||
if @topicText
|
||||
@dropdownButton.html(@fitName(@topicText) + ' <span class="drop-arrow">▾</span>')
|
||||
@dropdownButton.html(@fitName(@topicText) + ' <span class="drop-arrow">▾</span>')
|
||||
|
||||
getFullTopicName: (topicElement) ->
|
||||
name = topicElement.html()
|
||||
@@ -87,7 +83,6 @@ class @NewPostView extends Backbone.View
|
||||
return width
|
||||
|
||||
fitName: (name) ->
|
||||
console.log name
|
||||
width = @getNameWidth(name)
|
||||
if width < @maxNameWidth
|
||||
return name
|
||||
@@ -138,7 +133,6 @@ class @NewPostView extends Backbone.View
|
||||
auto_subscribe: follow
|
||||
error: DiscussionUtil.formErrorHandler(@$(".new-post-form-errors"))
|
||||
success: (response, textStatus) =>
|
||||
console.log response
|
||||
thread = new Thread response['content']
|
||||
DiscussionUtil.clearFormErrors(@$(".new-post-form-errors"))
|
||||
@$el.hide()
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<div class="options">
|
||||
<input type="checkbox" name="follow" class="discussion-follow" class="discussion-follow" id="new-post-follow" checked><label for="new-post-follow">follow this post</label>
|
||||
<br>
|
||||
<input type="checkbox" name="anonymous" class="discussion-anonymous" id="new-post-anonymous" checked><label for="new-post-anonymous">post anonymously</label>
|
||||
<input type="checkbox" name="anonymous" class="discussion-anonymous" id="new-post-anonymous"><label for="new-post-anonymous">post anonymously</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right-column">
|
||||
|
||||
Reference in New Issue
Block a user