diff --git a/lms/djangoapps/django_comment_client/utils.py b/lms/djangoapps/django_comment_client/utils.py index 2811b0a029..fd3458bfd0 100644 --- a/lms/djangoapps/django_comment_client/utils.py +++ b/lms/djangoapps/django_comment_client/utils.py @@ -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(): diff --git a/lms/static/coffee/src/discussion/views/new_post_view.coffee b/lms/static/coffee/src/discussion/views/new_post_view.coffee index bc30548f9f..24210f13ab 100644 --- a/lms/static/coffee/src/discussion/views/new_post_view.coffee +++ b/lms/static/coffee/src/discussion/views/new_post_view.coffee @@ -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) + ' ') + @dropdownButton.html(@fitName(@topicText) + ' ') 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() diff --git a/lms/templates/discussion/_new_post.html b/lms/templates/discussion/_new_post.html index b008c2d162..c5e4b41b0d 100644 --- a/lms/templates/discussion/_new_post.html +++ b/lms/templates/discussion/_new_post.html @@ -42,7 +42,7 @@

- +