diff --git a/common/static/coffee/spec/discussion/view/discussion_thread_list_view_spec.coffee b/common/static/coffee/spec/discussion/view/discussion_thread_list_view_spec.coffee
index 11866c349c..c82ab2e406 100644
--- a/common/static/coffee/spec/discussion/view/discussion_thread_list_view_spec.coffee
+++ b/common/static/coffee/spec/discussion/view/discussion_thread_list_view_spec.coffee
@@ -75,6 +75,7 @@ describe "DiscussionThreadListView", ->
Flagged
+ <% if (isCohorted && isPrivilegedUser) { %>
Cohort:
@@ -83,6 +84,7 @@ describe "DiscussionThreadListView", ->
Cohort2
+ <% } %>
by recent activity
@@ -123,7 +125,11 @@ describe "DiscussionThreadListView", ->
spyOn($, "ajax")
@discussion = new Discussion([])
- @view = new DiscussionThreadListView({collection: @discussion, el: $("#fixture-element")})
+ @view = new DiscussionThreadListView(
+ collection: @discussion,
+ el: $("#fixture-element"),
+ courseSettings: new DiscussionCourseSettings({is_cohorted: true})
+ )
@view.render()
setupAjax = (callback) ->
@@ -141,7 +147,8 @@ describe "DiscussionThreadListView", ->
makeView = (discussion) ->
return new DiscussionThreadListView(
el: $("#fixture-element"),
- collection: discussion
+ collection: discussion,
+ courseSettings: new DiscussionCourseSettings({is_cohorted: true})
)
expectFilter = (filterVal) ->
@@ -164,7 +171,12 @@ describe "DiscussionThreadListView", ->
)
describe "cohort selector", ->
- it "should filter correctly", ->
+ it "should not be visible to students", ->
+ expect(@view.$(".forum-nav-filter-cohort-control:visible")).not.toExist()
+
+ it "should allow moderators to select visibility", ->
+ DiscussionSpecHelper.makeModerator()
+ @view.render()
expectedGroupId = null
setupAjax((params) => expect(params.data.group_id).toEqual(expectedGroupId))
_.each(
@@ -498,6 +510,8 @@ describe "DiscussionThreadListView", ->
expect($(".forum-nav-browse-current").text()).toEqual("Posts I'm Following")
it "should show/hide the cohort selector", ->
+ DiscussionSpecHelper.makeModerator()
+ @view.render()
setupAjax()
_.each(
[
diff --git a/common/static/coffee/src/discussion/discussion_router.coffee b/common/static/coffee/src/discussion/discussion_router.coffee
index 549c0ec830..5309602bba 100644
--- a/common/static/coffee/src/discussion/discussion_router.coffee
+++ b/common/static/coffee/src/discussion/discussion_router.coffee
@@ -8,7 +8,11 @@ if Backbone?
@discussion = options['discussion']
@course_settings = options['course_settings']
- @nav = new DiscussionThreadListView(collection: @discussion, el: $(".forum-nav"))
+ @nav = new DiscussionThreadListView(
+ collection: @discussion,
+ el: $(".forum-nav"),
+ courseSettings: @course_settings
+ )
@nav.on "thread:selected", @navigateToThread
@nav.on "thread:removed", @navigateToAllThreads
@nav.on "threads:rendered", @setActiveThread
diff --git a/common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee b/common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
index d1e2ad6136..9fb33c7952 100644
--- a/common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
+++ b/common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
@@ -13,7 +13,8 @@ if Backbone?
"change .forum-nav-filter-main-control": "chooseFilter"
"change .forum-nav-filter-cohort-control": "chooseCohort"
- initialize: ->
+ initialize: (options) ->
+ @courseSettings = options.courseSettings
@displayedCollection = new Discussion(@collection.models, pages: @collection.pages)
@collection.on "change", @reloadDisplayedCollection
@discussionIds=""
@@ -121,7 +122,12 @@ if Backbone?
render: ->
@timer = 0
- @$el.html(@template())
+ @$el.html(
+ @template({
+ isCohorted: @courseSettings.get("is_cohorted"),
+ isPrivilegedUser: DiscussionUtil.isPrivilegedUser()
+ })
+ )
@$(".forum-nav-sort-control").val(@collection.sort_preference)
$(window).bind "load", @updateSidebar
diff --git a/lms/templates/discussion/_thread_list_template.html b/lms/templates/discussion/_thread_list_template.html
index 48ef678d0c..7ba9afd8ed 100644
--- a/lms/templates/discussion/_thread_list_template.html
+++ b/lms/templates/discussion/_thread_list_template.html
@@ -37,10 +37,7 @@
${_("Flagged")}
%endif
- \
- %if is_course_cohorted and is_moderator:
-## Lack of indentation is intentional to avoid whitespace between this and siblings
-
+ ${"<% if (isCohorted && isPrivilegedUser) { %>"}
## Translators: This labels a cohort menu in forum navigation
${_("Cohort:")}
@@ -49,10 +46,7 @@
${c['name']}
%endfor
- \
- %endif
-## Lack of indentation is intentional to avoid whitespace between this and siblings
-
+ ${"<% } %>"}
## Translators: This labels a sort menu in forum navigation
${_("Sort:")}