Merge pull request #4786 from aboudreault/inline-discusssion-cohorting
Add always_cohort_inline_discussions in course settings
This commit is contained in:
@@ -321,7 +321,7 @@ browser and pasting the output. When that file changes, this one should be rege
|
||||
<label class="field-label">
|
||||
<span class="field-label-text">
|
||||
Visible To:
|
||||
</span><select class="field-input js-group-select" name="group_id">
|
||||
</span><select class="field-input js-group-select" name="group_id" <% if (!is_commentable_cohorted) { %>disabled<% } %>>
|
||||
<option value="">All Groups</option>
|
||||
<% _.each(cohort_options, function(opt) { %>
|
||||
<option value="<%= opt.value %>" <% if (opt.selected) { %>selected<% } %>><%- opt.text %></option>
|
||||
|
||||
@@ -10,6 +10,15 @@ describe "NewPostView", ->
|
||||
)
|
||||
@discussion = new Discussion([], {pages: 1})
|
||||
|
||||
checkVisibility = (view, expectedVisible, expectedDisabled) =>
|
||||
view.render()
|
||||
expect(view.$(".js-group-select").is(":visible")).toEqual(expectedVisible)
|
||||
disabled = view.$(".js-group-select").prop("disabled")
|
||||
if expectedVisible and ! expectedDisabled
|
||||
expect(disabled).toEqual(false)
|
||||
else if expectedDisabled
|
||||
expect(disabled).toEqual(true)
|
||||
|
||||
describe "cohort selector", ->
|
||||
beforeEach ->
|
||||
@course_settings = new DiscussionCourseSettings({
|
||||
@@ -32,12 +41,6 @@ describe "NewPostView", ->
|
||||
mode: "tab"
|
||||
)
|
||||
|
||||
checkVisibility = (view, expectedVisible) =>
|
||||
view.render()
|
||||
expect(view.$(".js-group-select").is(":visible")).toEqual(expectedVisible)
|
||||
if expectedVisible
|
||||
expect(view.$(".js-group-select").prop("disabled")).toEqual(false)
|
||||
|
||||
it "is not visible to students", ->
|
||||
checkVisibility(@view, false)
|
||||
|
||||
@@ -69,6 +72,46 @@ describe "NewPostView", ->
|
||||
$.ajax.reset()
|
||||
)
|
||||
|
||||
describe "always cohort inline discussions ", ->
|
||||
beforeEach ->
|
||||
@course_settings = new DiscussionCourseSettings({
|
||||
"category_map": {
|
||||
"children": [],
|
||||
"entries": {}
|
||||
},
|
||||
"allow_anonymous": false,
|
||||
"allow_anonymous_to_peers": false,
|
||||
"is_cohorted": true,
|
||||
"cohorts": [
|
||||
{"id": 1, "name": "Cohort1"},
|
||||
{"id": 2, "name": "Cohort2"}
|
||||
]
|
||||
})
|
||||
@view = new NewPostView(
|
||||
el: $("#fixture-element"),
|
||||
collection: @discussion,
|
||||
course_settings: @course_settings,
|
||||
mode: "tab"
|
||||
)
|
||||
|
||||
it "disables the cohort menu if it is set false", ->
|
||||
DiscussionSpecHelper.makeModerator()
|
||||
@view.is_commentable_cohorted = false
|
||||
checkVisibility(@view, true, true)
|
||||
|
||||
it "enables the cohort menu if it is set true", ->
|
||||
DiscussionSpecHelper.makeModerator()
|
||||
@view.is_commentable_cohorted = true
|
||||
checkVisibility(@view, true)
|
||||
|
||||
it "is not visible to students when set false", ->
|
||||
@view.is_commentable_cohorted = false
|
||||
checkVisibility(@view, false)
|
||||
|
||||
it "is not visible to students when set true", ->
|
||||
@view.is_commentable_cohorted = true
|
||||
checkVisibility(@view, false)
|
||||
|
||||
describe "cancel post resets form ", ->
|
||||
beforeEach ->
|
||||
@course_settings = new DiscussionCourseSettings({
|
||||
|
||||
@@ -116,7 +116,8 @@ if Backbone?
|
||||
el: @newPostForm,
|
||||
collection: @discussion,
|
||||
course_settings: @course_settings,
|
||||
topicId: discussionId
|
||||
topicId: discussionId,
|
||||
is_commentable_cohorted: response.is_commentable_cohorted
|
||||
)
|
||||
@newPostView.render()
|
||||
@listenTo( @newPostView, 'newPost:cancel', @hideNewPost )
|
||||
|
||||
@@ -6,12 +6,14 @@ if Backbone?
|
||||
if @mode not in ["tab", "inline"]
|
||||
throw new Error("invalid mode: " + @mode)
|
||||
@course_settings = options.course_settings
|
||||
@is_commentable_cohorted = options.is_commentable_cohorted
|
||||
@topicId = options.topicId
|
||||
|
||||
render: () ->
|
||||
context = _.clone(@course_settings.attributes)
|
||||
_.extend(context, {
|
||||
cohort_options: @getCohortOptions(),
|
||||
is_commentable_cohorted: @is_commentable_cohorted,
|
||||
mode: @mode,
|
||||
form_id: @mode + (if @topicId then "-" + @topicId else "")
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user