Merge pull request #14972 from edx/christina/ed11
Renaming prep for allow discussions to be divided by enrollment tracks
This commit is contained in:
@@ -36,7 +36,7 @@
|
|||||||
this.pages = options.pages || 1;
|
this.pages = options.pages || 1;
|
||||||
this.current_page = 1;
|
this.current_page = 1;
|
||||||
this.sort_preference = options.sort;
|
this.sort_preference = options.sort;
|
||||||
this.is_commentable_cohorted = options.is_commentable_cohorted;
|
this.is_commentable_divided = options.is_commentable_divided;
|
||||||
this.bind('add', function(item) {
|
this.bind('add', function(item) {
|
||||||
item.discussion = self;
|
item.discussion = self;
|
||||||
});
|
});
|
||||||
@@ -142,7 +142,7 @@
|
|||||||
Content.loadContentInfos(response.annotated_content_info);
|
Content.loadContentInfos(response.annotated_content_info);
|
||||||
self.pages = response.num_pages;
|
self.pages = response.num_pages;
|
||||||
self.current_page = response.page;
|
self.current_page = response.page;
|
||||||
self.is_commentable_cohorted = response.is_commentable_cohorted;
|
self.is_commentable_divided = response.is_commentable_divided;
|
||||||
return self.reset(new_collection);
|
return self.reset(new_collection);
|
||||||
},
|
},
|
||||||
error: error
|
error: error
|
||||||
|
|||||||
@@ -86,7 +86,7 @@
|
|||||||
DiscussionUtil.loadRoles(response.roles);
|
DiscussionUtil.loadRoles(response.roles);
|
||||||
|
|
||||||
this.courseSettings = new DiscussionCourseSettings(response.course_settings);
|
this.courseSettings = new DiscussionCourseSettings(response.course_settings);
|
||||||
this.is_commentable_cohorted = response.is_commentable_cohorted;
|
this.is_commentable_divided = response.is_commentable_divided;
|
||||||
|
|
||||||
this.discussion = new Discussion(undefined, {pages: response.num_pages});
|
this.discussion = new Discussion(undefined, {pages: response.num_pages});
|
||||||
this.discussion.reset(response.discussion_data, {
|
this.discussion.reset(response.discussion_data, {
|
||||||
@@ -126,7 +126,7 @@
|
|||||||
course_settings: this.courseSettings,
|
course_settings: this.courseSettings,
|
||||||
topicId: discussionId,
|
topicId: discussionId,
|
||||||
startHeader: this.startHeader,
|
startHeader: this.startHeader,
|
||||||
is_commentable_cohorted: response.is_commentable_cohorted
|
is_commentable_divided: response.is_commentable_divided
|
||||||
});
|
});
|
||||||
|
|
||||||
this.newPostView.render();
|
this.newPostView.render();
|
||||||
@@ -154,7 +154,7 @@
|
|||||||
mode: 'inline',
|
mode: 'inline',
|
||||||
startHeader: this.startHeader,
|
startHeader: this.startHeader,
|
||||||
courseSettings: this.courseSettings,
|
courseSettings: this.courseSettings,
|
||||||
is_commentable_cohorted: this.is_commentable_cohorted
|
is_commentable_divided: this.is_commentable_divided
|
||||||
});
|
});
|
||||||
this.threadView.render();
|
this.threadView.render();
|
||||||
this.listenTo(this.threadView.showView, 'thread:_delete', this.navigateToAllPosts);
|
this.listenTo(this.threadView.showView, 'thread:_delete', this.navigateToAllPosts);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
DiscussionThreadShowView.__super__.initialize.call(this);
|
DiscussionThreadShowView.__super__.initialize.call(this);
|
||||||
this.mode = options.mode || 'inline';
|
this.mode = options.mode || 'inline';
|
||||||
this.startHeader = options.startHeader;
|
this.startHeader = options.startHeader;
|
||||||
this.is_commentable_cohorted = options.is_commentable_cohorted;
|
this.is_commentable_divided = options.is_commentable_divided;
|
||||||
if ((_ref = this.mode) !== 'tab' && _ref !== 'inline') {
|
if ((_ref = this.mode) !== 'tab' && _ref !== 'inline') {
|
||||||
throw new Error('invalid mode: ' + this.mode);
|
throw new Error('invalid mode: ' + this.mode);
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
mode: this.mode,
|
mode: this.mode,
|
||||||
startHeader: this.startHeader,
|
startHeader: this.startHeader,
|
||||||
flagged: this.model.isFlagged(),
|
flagged: this.model.isFlagged(),
|
||||||
is_commentable_cohorted: this.is_commentable_cohorted,
|
is_commentable_divided: this.is_commentable_divided,
|
||||||
author_display: this.getAuthorDisplay(),
|
author_display: this.getAuthorDisplay(),
|
||||||
cid: this.model.cid,
|
cid: this.model.cid,
|
||||||
readOnly: $('.discussion-module').data('read-only')
|
readOnly: $('.discussion-module').data('read-only')
|
||||||
|
|||||||
@@ -92,7 +92,7 @@
|
|||||||
self.model = collection.get(id);
|
self.model = collection.get(id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.is_commentable_cohorted = options.is_commentable_cohorted;
|
this.is_commentable_divided = options.is_commentable_divided;
|
||||||
this.createShowView();
|
this.createShowView();
|
||||||
this.responses = new Comments();
|
this.responses = new Comments();
|
||||||
this.loadedResponses = false;
|
this.loadedResponses = false;
|
||||||
@@ -423,7 +423,7 @@
|
|||||||
model: this.model,
|
model: this.model,
|
||||||
mode: this.mode,
|
mode: this.mode,
|
||||||
startHeader: this.startHeader,
|
startHeader: this.startHeader,
|
||||||
is_commentable_cohorted: this.is_commentable_cohorted
|
is_commentable_divided: this.is_commentable_divided
|
||||||
});
|
});
|
||||||
this.showView.bind('thread:_delete', this._delete);
|
this.showView.bind('thread:_delete', this._delete);
|
||||||
return this.showView.bind('thread:edit', this.edit);
|
return this.showView.bind('thread:edit', this.edit);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
html = entryTemplate({
|
html = entryTemplate({
|
||||||
text: name,
|
text: name,
|
||||||
id: entry.id,
|
id: entry.id,
|
||||||
is_cohorted: entry.is_cohorted
|
is_divided: entry.is_divided
|
||||||
});
|
});
|
||||||
} else { // subcategory
|
} else { // subcategory
|
||||||
html = categoryTemplate({
|
html = categoryTemplate({
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
throw new Error('invalid mode: ' + this.mode);
|
throw new Error('invalid mode: ' + this.mode);
|
||||||
}
|
}
|
||||||
this.course_settings = options.course_settings;
|
this.course_settings = options.course_settings;
|
||||||
this.is_commentable_cohorted = options.is_commentable_cohorted;
|
this.is_commentable_divided = options.is_commentable_divided;
|
||||||
this.topicId = options.topicId;
|
this.topicId = options.topicId;
|
||||||
this.discussionBoardView = options.discussionBoardView;
|
this.discussionBoardView = options.discussionBoardView;
|
||||||
};
|
};
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
context = _.clone(this.course_settings.attributes);
|
context = _.clone(this.course_settings.attributes);
|
||||||
_.extend(context, {
|
_.extend(context, {
|
||||||
cohort_options: this.getCohortOptions(),
|
cohort_options: this.getCohortOptions(),
|
||||||
is_commentable_cohorted: this.is_commentable_cohorted,
|
is_commentable_divided: this.is_commentable_divided,
|
||||||
mode: this.mode,
|
mode: this.mode,
|
||||||
startHeader: this.startHeader,
|
startHeader: this.startHeader,
|
||||||
form_id: this.mode + (this.topicId ? '-' + this.topicId : '')
|
form_id: this.mode + (this.topicId ? '-' + this.topicId : '')
|
||||||
@@ -85,14 +85,14 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
NewPostView.prototype.getCohortOptions = function() {
|
NewPostView.prototype.getCohortOptions = function() {
|
||||||
var userCohortId;
|
var userGroupId;
|
||||||
if (this.course_settings.get('is_cohorted') && DiscussionUtil.isPrivilegedUser()) {
|
if (this.course_settings.get('is_cohorted') && DiscussionUtil.isPrivilegedUser()) {
|
||||||
userCohortId = $('#discussion-container').data('user-cohort-id');
|
userGroupId = $('#discussion-container').data('user-group-id');
|
||||||
return _.map(this.course_settings.get('cohorts'), function(cohort) {
|
return _.map(this.course_settings.get('cohorts'), function(cohort) {
|
||||||
return {
|
return {
|
||||||
value: cohort.id,
|
value: cohort.id,
|
||||||
text: cohort.name,
|
text: cohort.name,
|
||||||
selected: cohort.id === userCohortId
|
selected: cohort.id === userGroupId
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -96,29 +96,29 @@
|
|||||||
describe('renderComments', function() {
|
describe('renderComments', function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
this.course_settings = new DiscussionCourseSettings({
|
this.course_settings = new DiscussionCourseSettings({
|
||||||
'category_map': {
|
category_map: {
|
||||||
'children': [ // eslint-disable-line quote-props
|
children: [
|
||||||
['Topic', 'entry'],
|
['Topic', 'entry'],
|
||||||
['General', 'entry'],
|
['General', 'entry'],
|
||||||
['Basic Question', 'entry']
|
['Basic Question', 'entry']
|
||||||
],
|
],
|
||||||
'entries': {
|
entries: {
|
||||||
'Topic': {
|
Topic: {
|
||||||
'is_cohorted': true,
|
is_divided: true,
|
||||||
'id': 'topic'
|
id: 'topic'
|
||||||
},
|
},
|
||||||
'General': {
|
General: {
|
||||||
'sort_key': 'General',
|
sort_key: 'General',
|
||||||
'is_cohorted': false,
|
is_divided: false,
|
||||||
'id': '6.00.1x_General'
|
id: '6.00.1x_General'
|
||||||
},
|
},
|
||||||
'Basic Question': {
|
'Basic Question': {
|
||||||
'is_cohorted': false,
|
is_divided: false,
|
||||||
'id': "6>00'1x\"Basic_Question"
|
id: "6>00'1x\"Basic_Question"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'is_cohorted': true
|
is_cohorted: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -173,23 +173,23 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('cohorting', function() {
|
describe('cohorting', function() {
|
||||||
it('renders correctly for an uncohorted thread', function() {
|
it('renders correctly for a unified thread', function() {
|
||||||
this.view.render();
|
this.view.render();
|
||||||
return expect(this.view.$('.group-visibility-label').text().trim())
|
return expect(this.view.$('.group-visibility-label').text().trim())
|
||||||
.toEqual('This post is visible to everyone.');
|
.toEqual('This post is visible to everyone.');
|
||||||
});
|
});
|
||||||
it('renders correctly for a cohorted thread', function() {
|
it('renders correctly for a divided thread', function() {
|
||||||
this.thread.set('group_id', '1');
|
this.thread.set('group_id', '1');
|
||||||
this.thread.set('group_name', 'Mock Cohort');
|
this.thread.set('group_name', 'Mock Cohort');
|
||||||
this.view.is_commentable_cohorted = true;
|
this.view.is_commentable_divided = true;
|
||||||
this.view.render();
|
this.view.render();
|
||||||
return expect(this.view.$('.group-visibility-label').text().trim())
|
return expect(this.view.$('.group-visibility-label').text().trim())
|
||||||
.toEqual('This post is visible only to Mock Cohort.');
|
.toEqual('This post is visible only to Mock Cohort.');
|
||||||
});
|
});
|
||||||
it('renders correctly for a grouped uncohorted thread', function() {
|
it('renders correctly for a grouped unified thread', function() {
|
||||||
this.thread.set('group_id', '1');
|
this.thread.set('group_id', '1');
|
||||||
this.thread.set('group_name', 'Mock Cohort');
|
this.thread.set('group_name', 'Mock Cohort');
|
||||||
this.view.is_commentable_cohorted = false;
|
this.view.is_commentable_divided = false;
|
||||||
this.view.render();
|
this.view.render();
|
||||||
return expect(this.view.$('.group-visibility-label').text().trim())
|
return expect(this.view.$('.group-visibility-label').text().trim())
|
||||||
.toEqual('This post is visible to everyone.');
|
.toEqual('This post is visible to everyone.');
|
||||||
|
|||||||
@@ -16,67 +16,67 @@
|
|||||||
DiscussionSpecHelper.setUpGlobals();
|
DiscussionSpecHelper.setUpGlobals();
|
||||||
DiscussionSpecHelper.setUnderscoreFixtures();
|
DiscussionSpecHelper.setUnderscoreFixtures();
|
||||||
this.course_settings = new DiscussionCourseSettings({
|
this.course_settings = new DiscussionCourseSettings({
|
||||||
'category_map': {
|
category_map: {
|
||||||
'subcategories': {
|
subcategories: {
|
||||||
'Basic Question Types': {
|
'Basic Question Types': {
|
||||||
'subcategories': {},
|
subcategories: {},
|
||||||
'children': [
|
children: [
|
||||||
['Selection From Options', 'entry'],
|
['Selection From Options', 'entry'],
|
||||||
['Numerical Input', 'entry'],
|
['Numerical Input', 'entry'],
|
||||||
['Very long category name', 'entry'],
|
['Very long category name', 'entry'],
|
||||||
['Very very very very long category name', 'entry'],
|
['Very very very very long category name', 'entry'],
|
||||||
['Name with <em>HTML</em>', 'entry']
|
['Name with <em>HTML</em>', 'entry']
|
||||||
],
|
],
|
||||||
'entries': {
|
entries: {
|
||||||
'Selection From Options': {
|
'Selection From Options': {
|
||||||
'sort_key': null,
|
sort_key: null,
|
||||||
'is_cohorted': true,
|
is_divided: true,
|
||||||
'id': 'cba3e4cd91d0466b9ac50926e495b76f'
|
id: 'cba3e4cd91d0466b9ac50926e495b76f'
|
||||||
},
|
},
|
||||||
'Numerical Input': {
|
'Numerical Input': {
|
||||||
'sort_key': null,
|
sort_key: null,
|
||||||
'is_cohorted': false,
|
is_divided: false,
|
||||||
'id': 'c49f0dfb8fc94c9c8d9999cc95190c56'
|
id: 'c49f0dfb8fc94c9c8d9999cc95190c56'
|
||||||
},
|
},
|
||||||
'Very long category name': {
|
'Very long category name': {
|
||||||
'sort_key': null,
|
sort_key: null,
|
||||||
'is_cohorted': false,
|
is_divided: false,
|
||||||
'id': 'c49f0dfb8fc94c9c8d9999cc95190c59'
|
id: 'c49f0dfb8fc94c9c8d9999cc95190c59'
|
||||||
},
|
},
|
||||||
'Very very very very long category name': {
|
'Very very very very long category name': {
|
||||||
'sort_key': null,
|
sort_key: null,
|
||||||
'is_cohorted': false,
|
is_divided: false,
|
||||||
'id': 'c49f0dfb8fc94c9c8d9999cc95190e32'
|
id: 'c49f0dfb8fc94c9c8d9999cc95190e32'
|
||||||
},
|
},
|
||||||
'Name with <em>HTML</em>': {
|
'Name with <em>HTML</em>': {
|
||||||
'sort_key': null,
|
sort_key: null,
|
||||||
'is_cohorted': false,
|
is_divided: false,
|
||||||
'id': 'c49f0dfb8fc94c9c8d9999cc95190363'
|
id: 'c49f0dfb8fc94c9c8d9999cc95190363'
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'Example Inline Discussion': {
|
'Example Inline Discussion': {
|
||||||
'subcategories': {},
|
subcategories: {},
|
||||||
'children': [
|
children: [
|
||||||
['What Are Your Goals for Creating a MOOC?', 'entry']
|
['What Are Your Goals for Creating a MOOC?', 'entry']
|
||||||
],
|
],
|
||||||
'entries': {
|
entries: {
|
||||||
'What Are Your Goals for Creating a MOOC?': {
|
'What Are Your Goals for Creating a MOOC?': {
|
||||||
'sort_key': null,
|
sort_key: null,
|
||||||
'is_cohorted': true,
|
is_divided: true,
|
||||||
'id': 'cba3e4cd91d0466b9ac50926e495b931'
|
id: 'cba3e4cd91d0466b9ac50926e495b931'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'children': [ // eslint-disable-line quote-props
|
children: [
|
||||||
['Basic Question Types', 'subcategory'],
|
['Basic Question Types', 'subcategory'],
|
||||||
['Example Inline Discussion', 'subcategory']
|
['Example Inline Discussion', 'subcategory']
|
||||||
],
|
],
|
||||||
'entries': {}
|
entries: {}
|
||||||
},
|
},
|
||||||
'is_cohorted': true
|
is_cohorted: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -38,15 +38,15 @@
|
|||||||
children: [['Topic', 'entry'], ['General', 'entry'], ['Not Cohorted', 'entry']],
|
children: [['Topic', 'entry'], ['General', 'entry'], ['Not Cohorted', 'entry']],
|
||||||
entries: {
|
entries: {
|
||||||
Topic: {
|
Topic: {
|
||||||
is_cohorted: true,
|
is_divided: true,
|
||||||
id: 'topic'
|
id: 'topic'
|
||||||
},
|
},
|
||||||
General: {
|
General: {
|
||||||
is_cohorted: true,
|
is_divided: true,
|
||||||
id: 'general'
|
id: 'general'
|
||||||
},
|
},
|
||||||
'Not Cohorted': {
|
'Not Cohorted': {
|
||||||
is_cohorted: false,
|
is_divided: false,
|
||||||
id: 'not-cohorted'
|
id: 'not-cohorted'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,20 +145,20 @@
|
|||||||
});
|
});
|
||||||
it('disables the cohort menu if it is set false', function() {
|
it('disables the cohort menu if it is set false', function() {
|
||||||
DiscussionSpecHelper.makeModerator();
|
DiscussionSpecHelper.makeModerator();
|
||||||
this.view.is_commentable_cohorted = false;
|
this.view.is_commentable_divided = false;
|
||||||
return checkVisibility(this.view, true, true, true);
|
return checkVisibility(this.view, true, true, true);
|
||||||
});
|
});
|
||||||
it('enables the cohort menu if it is set true', function() {
|
it('enables the cohort menu if it is set true', function() {
|
||||||
DiscussionSpecHelper.makeModerator();
|
DiscussionSpecHelper.makeModerator();
|
||||||
this.view.is_commentable_cohorted = true;
|
this.view.is_commentable_divided = true;
|
||||||
return checkVisibility(this.view, true, false, true);
|
return checkVisibility(this.view, true, false, true);
|
||||||
});
|
});
|
||||||
it('is not visible to students when set false', function() {
|
it('is not visible to students when set false', function() {
|
||||||
this.view.is_commentable_cohorted = false;
|
this.view.is_commentable_divided = false;
|
||||||
return checkVisibility(this.view, false, false, true);
|
return checkVisibility(this.view, false, false, true);
|
||||||
});
|
});
|
||||||
it('is not visible to students when set true', function() {
|
it('is not visible to students when set true', function() {
|
||||||
this.view.is_commentable_cohorted = true;
|
this.view.is_commentable_divided = true;
|
||||||
return checkVisibility(this.view, false, false, true);
|
return checkVisibility(this.view, false, false, true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -166,33 +166,33 @@
|
|||||||
var checkPostCancelReset;
|
var checkPostCancelReset;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
this.course_settings = new DiscussionCourseSettings({
|
this.course_settings = new DiscussionCourseSettings({
|
||||||
'allow_anonymous_to_peers': true,
|
allow_anonymous_to_peers: true,
|
||||||
'allow_anonymous': true,
|
allow_anonymous: true,
|
||||||
'category_map': {
|
category_map: {
|
||||||
'subcategories': {
|
subcategories: {
|
||||||
'Week 1': {
|
'Week 1': {
|
||||||
'subcategories': {},
|
subcategories: {},
|
||||||
'children': [ // eslint-disable-line quote-props
|
children: [
|
||||||
['Topic-Level Student-Visible Label', 'entry']
|
['Topic-Level Student-Visible Label', 'entry']
|
||||||
],
|
],
|
||||||
'entries': {
|
entries: {
|
||||||
'Topic-Level Student-Visible Label': {
|
'Topic-Level Student-Visible Label': {
|
||||||
'sort_key': null,
|
sort_key: null,
|
||||||
'is_cohorted': false,
|
is_divided: false,
|
||||||
'id': '2b3a858d0c884eb4b272dbbe3f2ffddd'
|
id: '2b3a858d0c884eb4b272dbbe3f2ffddd'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'children': [ // eslint-disable-line quote-props
|
children: [
|
||||||
['General', 'entry'],
|
['General', 'entry'],
|
||||||
['Week 1', 'subcategory']
|
['Week 1', 'subcategory']
|
||||||
],
|
],
|
||||||
'entries': {
|
entries: {
|
||||||
'General': {
|
General: {
|
||||||
'sort_key': 'General',
|
sort_key: 'General',
|
||||||
'is_cohorted': false,
|
is_divided: false,
|
||||||
'id': 'i4x-waqastest-waqastest-course-waqastest'
|
id: 'i4x-waqastest-waqastest-course-waqastest'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,7 +255,7 @@
|
|||||||
entries: {
|
entries: {
|
||||||
'Topic-Level Student-Visible Label': {
|
'Topic-Level Student-Visible Label': {
|
||||||
sort_key: null,
|
sort_key: null,
|
||||||
is_cohorted: false,
|
is_divided: false,
|
||||||
id: '2b3a858d0c884eb4b272dbbe3f2ffddd'
|
id: '2b3a858d0c884eb4b272dbbe3f2ffddd'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,7 @@
|
|||||||
entries: {
|
entries: {
|
||||||
'First topic': {
|
'First topic': {
|
||||||
sort_key: 'First topic',
|
sort_key: 'First topic',
|
||||||
is_cohorted: false,
|
is_divided: false,
|
||||||
id: 'i4x-waqastest-waqastest-course-waqastest'
|
id: 'i4x-waqastest-waqastest-course-waqastest'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,11 +58,11 @@
|
|||||||
children: [['Test Topic', 'entry'], ['Other Topic', 'entry']],
|
children: [['Test Topic', 'entry'], ['Other Topic', 'entry']],
|
||||||
entries: {
|
entries: {
|
||||||
'Test Topic': {
|
'Test Topic': {
|
||||||
is_cohorted: true,
|
is_divided: true,
|
||||||
id: 'test_topic'
|
id: 'test_topic'
|
||||||
},
|
},
|
||||||
'Other Topic': {
|
'Other Topic': {
|
||||||
is_cohorted: true,
|
is_divided: true,
|
||||||
id: 'other_topic'
|
id: 'other_topic'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
<option class="topic-title" data-discussion-id="<%- id %>" data-cohorted="<%- is_cohorted %>"><%- text %></option>
|
<option class="topic-title" data-discussion-id="<%- id %>" data-cohorted="<%- is_divided %>"><%- text %></option>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<ul class="post-errors" style="display: none"></ul>
|
<ul class="post-errors" style="display: none"></ul>
|
||||||
<div class="forum-new-post-form-wrapper"></div>
|
<div class="forum-new-post-form-wrapper"></div>
|
||||||
<% if (cohort_options) { %>
|
<% if (cohort_options) { %>
|
||||||
<div class="post-field group-selector-wrapper <% if (!is_commentable_cohorted) { print('disabled'); } %>">
|
<div class="post-field group-selector-wrapper <% if (!is_commentable_divided) { print('disabled'); } %>">
|
||||||
<label class="field-label">
|
<label class="field-label">
|
||||||
<span class="field-label-text">
|
<span class="field-label-text">
|
||||||
<% //Translators: This labels the selector for which group of students can view a post %>
|
<% //Translators: This labels the selector for which group of students can view a post %>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<%- gettext("Discussion admins, moderators, and TAs can make their posts visible to all students or specify a single cohort.") %>
|
<%- gettext("Discussion admins, moderators, and TAs can make their posts visible to all students or specify a single cohort.") %>
|
||||||
</div>
|
</div>
|
||||||
<div class="field-input">
|
<div class="field-input">
|
||||||
<select aria-describedby="field_help_visible_to" class="post-topic field-input js-group-select" name="group_id" <% if (!is_commentable_cohorted) { print("disabled"); } %>>
|
<select aria-describedby="field_help_visible_to" class="post-topic field-input js-group-select" name="group_id" <% if (!is_commentable_divided) { print("disabled"); } %>>
|
||||||
<option value=""><%- gettext("All Groups") %></option>
|
<option value=""><%- gettext("All Groups") %></option>
|
||||||
<% _.each(cohort_options, function(opt) { %>
|
<% _.each(cohort_options, function(opt) { %>
|
||||||
<option value="<%- opt.value %>" <% if (opt.selected) { print("selected"); } %>><%- opt.text %></option>
|
<option value="<%- opt.value %>" <% if (opt.selected) { print("selected"); } %>><%- opt.text %></option>
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
%>
|
%>
|
||||||
<% } %>
|
<% } %>
|
||||||
<div class="group-visibility-label">
|
<div class="group-visibility-label">
|
||||||
<% if (obj.group_name && is_commentable_cohorted) { %>
|
<% if (obj.group_name && is_commentable_divided) { %>
|
||||||
<%-
|
<%-
|
||||||
interpolate(
|
interpolate(
|
||||||
gettext('This post is visible only to %(group_name)s.'),
|
gettext('This post is visible only to %(group_name)s.'),
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
sortPreference = options.sortPreference,
|
sortPreference = options.sortPreference,
|
||||||
threads = options.threads,
|
threads = options.threads,
|
||||||
threadPages = options.threadPages,
|
threadPages = options.threadPages,
|
||||||
isCommentableCohorted = options.isCommentableCohorted,
|
isCommentableDivided = options.isCommentableDivided,
|
||||||
contentInfo = options.contentInfo,
|
contentInfo = options.contentInfo,
|
||||||
user = new DiscussionUser(userInfo),
|
user = new DiscussionUser(userInfo),
|
||||||
discussion,
|
discussion,
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
// Create a discussion model
|
// Create a discussion model
|
||||||
discussion = new Discussion(threads, {pages: threadPages, sort: sortPreference,
|
discussion = new Discussion(threads, {pages: threadPages, sort: sortPreference,
|
||||||
is_commentable_cohorted: isCommentableCohorted});
|
is_commentable_divided: isCommentableDivided});
|
||||||
courseSettings = new DiscussionCourseSettings(options.courseSettings);
|
courseSettings = new DiscussionCourseSettings(options.courseSettings);
|
||||||
|
|
||||||
// Create the discussion board view
|
// Create the discussion board view
|
||||||
|
|||||||
@@ -103,7 +103,7 @@
|
|||||||
mode: 'tab',
|
mode: 'tab',
|
||||||
startHeader: this.startHeader,
|
startHeader: this.startHeader,
|
||||||
courseSettings: this.courseSettings,
|
courseSettings: this.courseSettings,
|
||||||
is_commentable_cohorted: this.discussion.is_commentable_cohorted
|
is_commentable_divided: this.discussion.is_commentable_divided
|
||||||
});
|
});
|
||||||
this.main.render();
|
this.main.render();
|
||||||
this.main.on('thread:responses:rendered', function() {
|
this.main.on('thread:responses:rendered', function() {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ from openedx.core.djangolib.markup import HTML
|
|||||||
data-read-only="false"
|
data-read-only="false"
|
||||||
data-sort-preference="${sort_preference}"
|
data-sort-preference="${sort_preference}"
|
||||||
data-flag-moderator="${json.dumps(flag_moderator)}"
|
data-flag-moderator="${json.dumps(flag_moderator)}"
|
||||||
data-user-cohort-id="${user_cohort}">
|
data-user-group-id="${user_group_id}">
|
||||||
<header class="page-header has-secondary">
|
<header class="page-header has-secondary">
|
||||||
## Breadcrumb navigation
|
## Breadcrumb navigation
|
||||||
<div class="page-header-main">
|
<div class="page-header-main">
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_str
|
|||||||
contentInfo: ${annotated_content_info | n, dump_js_escaped_json},
|
contentInfo: ${annotated_content_info | n, dump_js_escaped_json},
|
||||||
courseName: '${course.display_name_with_default | n, js_escaped_string}',
|
courseName: '${course.display_name_with_default | n, js_escaped_string}',
|
||||||
courseSettings: ${course_settings | n, dump_js_escaped_json},
|
courseSettings: ${course_settings | n, dump_js_escaped_json},
|
||||||
isCommentableCohorted: ${is_commentable_cohorted | n, dump_js_escaped_json}
|
isCommentableDivided: ${is_commentable_divided | n, dump_js_escaped_json}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_str
|
|||||||
data-read-only="false"
|
data-read-only="false"
|
||||||
data-sort-preference="${sort_preference}"
|
data-sort-preference="${sort_preference}"
|
||||||
data-flag-moderator="${json.dumps(flag_moderator)}"
|
data-flag-moderator="${json.dumps(flag_moderator)}"
|
||||||
data-user-cohort-id="${user_cohort}">
|
data-user-group-id="${user_group_id}">
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ from courseware.courses import get_course_with_access
|
|||||||
from courseware.views.views import CourseTabView
|
from courseware.views.views import CourseTabView
|
||||||
from openedx.core.djangoapps.course_groups.cohorts import (
|
from openedx.core.djangoapps.course_groups.cohorts import (
|
||||||
is_course_cohorted,
|
is_course_cohorted,
|
||||||
get_cohort_id,
|
|
||||||
get_course_cohorts,
|
get_course_cohorts,
|
||||||
)
|
)
|
||||||
from openedx.core.djangoapps.plugin_api.views import EdxFragmentView
|
from openedx.core.djangoapps.plugin_api.views import EdxFragmentView
|
||||||
@@ -49,8 +48,10 @@ from django_comment_client.utils import (
|
|||||||
strip_none,
|
strip_none,
|
||||||
add_courseware_context,
|
add_courseware_context,
|
||||||
get_group_id_for_comments_service,
|
get_group_id_for_comments_service,
|
||||||
is_commentable_cohorted
|
is_commentable_divided,
|
||||||
|
get_group_id_for_user,
|
||||||
)
|
)
|
||||||
|
|
||||||
import django_comment_client.utils as utils
|
import django_comment_client.utils as utils
|
||||||
import lms.lib.comment_client as cc
|
import lms.lib.comment_client as cc
|
||||||
|
|
||||||
@@ -222,7 +223,7 @@ def inline_discussion(request, course_key, discussion_id):
|
|||||||
add_courseware_context(threads, course, request.user)
|
add_courseware_context(threads, course, request.user)
|
||||||
|
|
||||||
return utils.JsonResponse({
|
return utils.JsonResponse({
|
||||||
'is_commentable_cohorted': is_commentable_cohorted(course_key, discussion_id),
|
'is_commentable_divided': is_commentable_divided(course_key, discussion_id),
|
||||||
'discussion_data': threads,
|
'discussion_data': threads,
|
||||||
'user_info': user_info,
|
'user_info': user_info,
|
||||||
'annotated_content_info': annotated_content_info,
|
'annotated_content_info': annotated_content_info,
|
||||||
@@ -347,8 +348,8 @@ def _find_thread(request, course, discussion_id, thread_id):
|
|||||||
|
|
||||||
# verify that the thread belongs to the requesting student's cohort
|
# verify that the thread belongs to the requesting student's cohort
|
||||||
is_moderator = has_permission(request.user, "see_all_cohorts", course.id)
|
is_moderator = has_permission(request.user, "see_all_cohorts", course.id)
|
||||||
if is_commentable_cohorted(course.id, discussion_id) and not is_moderator:
|
if is_commentable_divided(course.id, discussion_id) and not is_moderator:
|
||||||
user_group_id = get_cohort_id(request.user, course.id)
|
user_group_id = get_group_id_for_user(request.user, course.id)
|
||||||
if getattr(thread, "group_id", None) is not None and user_group_id != thread.group_id:
|
if getattr(thread, "group_id", None) is not None and user_group_id != thread.group_id:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -423,7 +424,7 @@ def _create_discussion_board_context(request, course_key, discussion_id=None, th
|
|||||||
add_courseware_context(threads, course, user)
|
add_courseware_context(threads, course, user)
|
||||||
|
|
||||||
with newrelic_function_trace("get_cohort_info"):
|
with newrelic_function_trace("get_cohort_info"):
|
||||||
user_cohort_id = get_cohort_id(user, course_key)
|
user_group_id = get_group_id_for_user(user, course_key)
|
||||||
|
|
||||||
context.update({
|
context.update({
|
||||||
'root_url': root_url,
|
'root_url': root_url,
|
||||||
@@ -434,11 +435,11 @@ def _create_discussion_board_context(request, course_key, discussion_id=None, th
|
|||||||
'annotated_content_info': annotated_content_info,
|
'annotated_content_info': annotated_content_info,
|
||||||
'is_moderator': has_permission(user, "see_all_cohorts", course_key),
|
'is_moderator': has_permission(user, "see_all_cohorts", course_key),
|
||||||
'cohorts': course_settings["cohorts"], # still needed to render _thread_list_template
|
'cohorts': course_settings["cohorts"], # still needed to render _thread_list_template
|
||||||
'user_cohort': user_cohort_id, # read from container in NewPostView
|
'user_group_id': user_group_id, # read from container in NewPostView
|
||||||
'sort_preference': cc_user.default_sort_key,
|
'sort_preference': cc_user.default_sort_key,
|
||||||
'category_map': course_settings["category_map"],
|
'category_map': course_settings["category_map"],
|
||||||
'course_settings': course_settings,
|
'course_settings': course_settings,
|
||||||
'is_commentable_cohorted': is_commentable_cohorted(course_key, discussion_id)
|
'is_commentable_divided': is_commentable_divided(course_key, discussion_id)
|
||||||
})
|
})
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@@ -500,7 +501,7 @@ def user_profile(request, course_key, user_id):
|
|||||||
).order_by("name").values_list("name", flat=True).distinct()
|
).order_by("name").values_list("name", flat=True).distinct()
|
||||||
|
|
||||||
with newrelic_function_trace("get_cohort_info"):
|
with newrelic_function_trace("get_cohort_info"):
|
||||||
user_cohort_id = get_cohort_id(request.user, course_key)
|
user_group_id = get_group_id_for_user(request.user, course_key)
|
||||||
|
|
||||||
context = _create_base_discussion_view_context(request, course_key)
|
context = _create_base_discussion_view_context(request, course_key)
|
||||||
context.update({
|
context.update({
|
||||||
@@ -508,7 +509,7 @@ def user_profile(request, course_key, user_id):
|
|||||||
'django_user_roles': user_roles,
|
'django_user_roles': user_roles,
|
||||||
'profiled_user': profiled_user.to_dict(),
|
'profiled_user': profiled_user.to_dict(),
|
||||||
'threads': threads,
|
'threads': threads,
|
||||||
'user_cohort': user_cohort_id,
|
'user_group_id': user_group_id,
|
||||||
'annotated_content_info': annotated_content_info,
|
'annotated_content_info': annotated_content_info,
|
||||||
'page': query_params['page'],
|
'page': query_params['page'],
|
||||||
'num_pages': query_params['num_pages'],
|
'num_pages': query_params['num_pages'],
|
||||||
|
|||||||
@@ -43,12 +43,11 @@ from django_comment_common.signals import (
|
|||||||
comment_voted,
|
comment_voted,
|
||||||
comment_deleted,
|
comment_deleted,
|
||||||
)
|
)
|
||||||
from django_comment_client.utils import get_accessible_discussion_xblocks, is_commentable_cohorted
|
from django_comment_client.utils import get_accessible_discussion_xblocks, is_commentable_divided, get_group_id_for_user
|
||||||
from lms.djangoapps.discussion_api.pagination import DiscussionAPIPagination
|
from lms.djangoapps.discussion_api.pagination import DiscussionAPIPagination
|
||||||
from lms.lib.comment_client.comment import Comment
|
from lms.lib.comment_client.comment import Comment
|
||||||
from lms.lib.comment_client.thread import Thread
|
from lms.lib.comment_client.thread import Thread
|
||||||
from lms.lib.comment_client.utils import CommentClientRequestError
|
from lms.lib.comment_client.utils import CommentClientRequestError
|
||||||
from openedx.core.djangoapps.course_groups.cohorts import get_cohort_id
|
|
||||||
from openedx.core.lib.exceptions import CourseNotFoundError, PageNotFoundError, DiscussionNotFoundError
|
from openedx.core.lib.exceptions import CourseNotFoundError, PageNotFoundError, DiscussionNotFoundError
|
||||||
|
|
||||||
|
|
||||||
@@ -113,10 +112,10 @@ def _get_thread_and_context(request, thread_id, retrieve_kwargs=None):
|
|||||||
if (
|
if (
|
||||||
not context["is_requester_privileged"] and
|
not context["is_requester_privileged"] and
|
||||||
cc_thread["group_id"] and
|
cc_thread["group_id"] and
|
||||||
is_commentable_cohorted(course.id, cc_thread["commentable_id"])
|
is_commentable_divided(course.id, cc_thread["commentable_id"])
|
||||||
):
|
):
|
||||||
requester_cohort = get_cohort_id(request.user, course.id)
|
requester_group_id = get_group_id_for_user(request.user, course.id)
|
||||||
if requester_cohort is not None and cc_thread["group_id"] != requester_cohort:
|
if requester_group_id is not None and cc_thread["group_id"] != requester_group_id:
|
||||||
raise ThreadNotFoundError("Thread not found.")
|
raise ThreadNotFoundError("Thread not found.")
|
||||||
return cc_thread, context
|
return cc_thread, context
|
||||||
except CommentClientRequestError:
|
except CommentClientRequestError:
|
||||||
@@ -547,7 +546,7 @@ def get_thread_list(
|
|||||||
"user_id": unicode(request.user.id),
|
"user_id": unicode(request.user.id),
|
||||||
"group_id": (
|
"group_id": (
|
||||||
None if context["is_requester_privileged"] else
|
None if context["is_requester_privileged"] else
|
||||||
get_cohort_id(request.user, course.id)
|
get_group_id_for_user(request.user, course.id)
|
||||||
),
|
),
|
||||||
"page": page,
|
"page": page,
|
||||||
"per_page": page_size,
|
"per_page": page_size,
|
||||||
@@ -831,10 +830,10 @@ def create_thread(request, thread_data):
|
|||||||
_check_initializable_thread_fields(thread_data, context)
|
_check_initializable_thread_fields(thread_data, context)
|
||||||
if (
|
if (
|
||||||
"group_id" not in thread_data and
|
"group_id" not in thread_data and
|
||||||
is_commentable_cohorted(course_key, thread_data.get("topic_id"))
|
is_commentable_divided(course_key, thread_data.get("topic_id"))
|
||||||
):
|
):
|
||||||
thread_data = thread_data.copy()
|
thread_data = thread_data.copy()
|
||||||
thread_data["group_id"] = get_cohort_id(user, course_key)
|
thread_data["group_id"] = get_group_id_for_user(user, course_key)
|
||||||
serializer = ThreadSerializer(data=thread_data, context=context)
|
serializer = ThreadSerializer(data=thread_data, context=context)
|
||||||
actions_form = ThreadActionsForm(thread_data)
|
actions_form = ThreadActionsForm(thread_data)
|
||||||
if not (serializer.is_valid() and actions_form.is_valid()):
|
if not (serializer.is_valid() and actions_form.is_valid()):
|
||||||
|
|||||||
@@ -241,11 +241,11 @@ def create_thread(request, course_id, commentable_id):
|
|||||||
|
|
||||||
thread = cc.Thread(**params)
|
thread = cc.Thread(**params)
|
||||||
|
|
||||||
# Cohort the thread if required
|
# Divide the thread if required
|
||||||
try:
|
try:
|
||||||
group_id = get_group_id_for_comments_service(request, course_key, commentable_id)
|
group_id = get_group_id_for_comments_service(request, course_key, commentable_id)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return HttpResponseServerError("Invalid cohort id")
|
return HttpResponseServerError("Invalid group id for commentable")
|
||||||
if group_id is not None:
|
if group_id is not None:
|
||||||
thread.group_id = group_id
|
thread.group_id = group_id
|
||||||
|
|
||||||
|
|||||||
@@ -390,12 +390,14 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
def assert_category_map_equals(self, expected, cohorted_if_in_list=False, exclude_unstarted=True): # pylint: disable=arguments-differ
|
def assert_category_map_equals(self, expected, divided_only_if_explicit=False, exclude_unstarted=True): # pylint: disable=arguments-differ
|
||||||
"""
|
"""
|
||||||
Asserts the expected map with the map returned by get_discussion_category_map method.
|
Asserts the expected map with the map returned by get_discussion_category_map method.
|
||||||
"""
|
"""
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
utils.get_discussion_category_map(self.course, self.instructor, cohorted_if_in_list, exclude_unstarted),
|
utils.get_discussion_category_map(
|
||||||
|
self.course, self.instructor, divided_only_if_explicit, exclude_unstarted
|
||||||
|
),
|
||||||
expected
|
expected
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -413,9 +415,9 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
self.assert_category_map_equals(
|
self.assert_category_map_equals(
|
||||||
{
|
{
|
||||||
"entries": {
|
"entries": {
|
||||||
"Topic A": {"id": "Topic_A", "sort_key": "Topic A", "is_cohorted": "Topic_A" in expected_ids},
|
"Topic A": {"id": "Topic_A", "sort_key": "Topic A", "is_divided": "Topic_A" in expected_ids},
|
||||||
"Topic B": {"id": "Topic_B", "sort_key": "Topic B", "is_cohorted": "Topic_B" in expected_ids},
|
"Topic B": {"id": "Topic_B", "sort_key": "Topic B", "is_divided": "Topic_B" in expected_ids},
|
||||||
"Topic C": {"id": "Topic_C", "sort_key": "Topic C", "is_cohorted": "Topic_C" in expected_ids},
|
"Topic C": {"id": "Topic_C", "sort_key": "Topic C", "is_divided": "Topic_C" in expected_ids},
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
"children": [("Topic A", TYPE_ENTRY), ("Topic B", TYPE_ENTRY), ("Topic C", TYPE_ENTRY)]
|
"children": [("Topic A", TYPE_ENTRY), ("Topic B", TYPE_ENTRY), ("Topic C", TYPE_ENTRY)]
|
||||||
@@ -466,7 +468,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion": {
|
"Discussion": {
|
||||||
"id": "discussion1",
|
"id": "discussion1",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -490,7 +492,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion": {
|
"Discussion": {
|
||||||
"id": "discussion1",
|
"id": "discussion1",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": True,
|
"is_divided": True,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -514,7 +516,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion": {
|
"Discussion": {
|
||||||
"id": "discussion1",
|
"id": "discussion1",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -523,7 +525,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
},
|
},
|
||||||
"children": [("Chapter", TYPE_SUBCATEGORY)]
|
"children": [("Chapter", TYPE_SUBCATEGORY)]
|
||||||
},
|
},
|
||||||
cohorted_if_in_list=True
|
divided_only_if_explicit=True
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_get_unstarted_discussion_xblocks(self):
|
def test_get_unstarted_discussion_xblocks(self):
|
||||||
@@ -540,7 +542,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion 1": {
|
"Discussion 1": {
|
||||||
"id": "discussion1",
|
"id": "discussion1",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
"start_date": later
|
"start_date": later
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -552,7 +554,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
},
|
},
|
||||||
"children": [("Chapter 1", TYPE_SUBCATEGORY)]
|
"children": [("Chapter 1", TYPE_SUBCATEGORY)]
|
||||||
},
|
},
|
||||||
cohorted_if_in_list=True,
|
divided_only_if_explicit=True,
|
||||||
exclude_unstarted=False
|
exclude_unstarted=False
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -564,7 +566,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
self.create_discussion("Chapter 2 / Section 1 / Subsection 2", "Discussion")
|
self.create_discussion("Chapter 2 / Section 1 / Subsection 2", "Discussion")
|
||||||
self.create_discussion("Chapter 3 / Section 1", "Discussion")
|
self.create_discussion("Chapter 3 / Section 1", "Discussion")
|
||||||
|
|
||||||
def check_cohorted(is_cohorted):
|
def check_cohorted(is_divided):
|
||||||
|
|
||||||
self.assert_category_map_equals(
|
self.assert_category_map_equals(
|
||||||
{
|
{
|
||||||
@@ -575,12 +577,12 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion 1": {
|
"Discussion 1": {
|
||||||
"id": "discussion1",
|
"id": "discussion1",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": is_cohorted,
|
"is_divided": is_divided,
|
||||||
},
|
},
|
||||||
"Discussion 2": {
|
"Discussion 2": {
|
||||||
"id": "discussion2",
|
"id": "discussion2",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": is_cohorted,
|
"is_divided": is_divided,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -591,7 +593,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion": {
|
"Discussion": {
|
||||||
"id": "discussion3",
|
"id": "discussion3",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": is_cohorted,
|
"is_divided": is_divided,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {
|
"subcategories": {
|
||||||
@@ -603,7 +605,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion": {
|
"Discussion": {
|
||||||
"id": "discussion4",
|
"id": "discussion4",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": is_cohorted,
|
"is_divided": is_divided,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -614,7 +616,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion": {
|
"Discussion": {
|
||||||
"id": "discussion5",
|
"id": "discussion5",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": is_cohorted,
|
"is_divided": is_divided,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -634,7 +636,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion": {
|
"Discussion": {
|
||||||
"id": "discussion6",
|
"id": "discussion6",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": is_cohorted,
|
"is_divided": is_divided,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -704,7 +706,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion 1": {
|
"Discussion 1": {
|
||||||
"id": "discussion1",
|
"id": "discussion1",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -715,7 +717,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion": {
|
"Discussion": {
|
||||||
"id": "discussion3",
|
"id": "discussion3",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -749,12 +751,12 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion 1": {
|
"Discussion 1": {
|
||||||
"id": "discussion1",
|
"id": "discussion1",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
},
|
},
|
||||||
"Discussion 2": {
|
"Discussion 2": {
|
||||||
"id": "discussion2",
|
"id": "discussion2",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -765,7 +767,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion": {
|
"Discussion": {
|
||||||
"id": "discussion3",
|
"id": "discussion3",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {
|
"subcategories": {
|
||||||
@@ -777,7 +779,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion": {
|
"Discussion": {
|
||||||
"id": "discussion4",
|
"id": "discussion4",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -788,7 +790,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion": {
|
"Discussion": {
|
||||||
"id": "discussion5",
|
"id": "discussion5",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -808,7 +810,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion": {
|
"Discussion": {
|
||||||
"id": "discussion6",
|
"id": "discussion6",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -839,27 +841,27 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion 1": {
|
"Discussion 1": {
|
||||||
"id": "discussion1",
|
"id": "discussion1",
|
||||||
"sort_key": "D",
|
"sort_key": "D",
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
},
|
},
|
||||||
"Discussion 2": {
|
"Discussion 2": {
|
||||||
"id": "discussion2",
|
"id": "discussion2",
|
||||||
"sort_key": "A",
|
"sort_key": "A",
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
},
|
},
|
||||||
"Discussion 3": {
|
"Discussion 3": {
|
||||||
"id": "discussion3",
|
"id": "discussion3",
|
||||||
"sort_key": "E",
|
"sort_key": "E",
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
},
|
},
|
||||||
"Discussion 4": {
|
"Discussion 4": {
|
||||||
"id": "discussion4",
|
"id": "discussion4",
|
||||||
"sort_key": "C",
|
"sort_key": "C",
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
},
|
},
|
||||||
"Discussion 5": {
|
"Discussion 5": {
|
||||||
"id": "discussion5",
|
"id": "discussion5",
|
||||||
"sort_key": "B",
|
"sort_key": "B",
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -885,9 +887,9 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
self.assert_category_map_equals(
|
self.assert_category_map_equals(
|
||||||
{
|
{
|
||||||
"entries": {
|
"entries": {
|
||||||
"Topic A": {"id": "Topic_A", "sort_key": "B", "is_cohorted": False},
|
"Topic A": {"id": "Topic_A", "sort_key": "B", "is_divided": False},
|
||||||
"Topic B": {"id": "Topic_B", "sort_key": "C", "is_cohorted": False},
|
"Topic B": {"id": "Topic_B", "sort_key": "C", "is_divided": False},
|
||||||
"Topic C": {"id": "Topic_C", "sort_key": "A", "is_cohorted": False},
|
"Topic C": {"id": "Topic_C", "sort_key": "A", "is_divided": False},
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
"children": [("Topic C", TYPE_ENTRY), ("Topic A", TYPE_ENTRY), ("Topic B", TYPE_ENTRY)]
|
"children": [("Topic C", TYPE_ENTRY), ("Topic A", TYPE_ENTRY), ("Topic B", TYPE_ENTRY)]
|
||||||
@@ -912,27 +914,27 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion D": {
|
"Discussion D": {
|
||||||
"id": "discussion1",
|
"id": "discussion1",
|
||||||
"sort_key": "Discussion D",
|
"sort_key": "Discussion D",
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
},
|
},
|
||||||
"Discussion A": {
|
"Discussion A": {
|
||||||
"id": "discussion2",
|
"id": "discussion2",
|
||||||
"sort_key": "Discussion A",
|
"sort_key": "Discussion A",
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
},
|
},
|
||||||
"Discussion E": {
|
"Discussion E": {
|
||||||
"id": "discussion3",
|
"id": "discussion3",
|
||||||
"sort_key": "Discussion E",
|
"sort_key": "Discussion E",
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
},
|
},
|
||||||
"Discussion C": {
|
"Discussion C": {
|
||||||
"id": "discussion4",
|
"id": "discussion4",
|
||||||
"sort_key": "Discussion C",
|
"sort_key": "Discussion C",
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
},
|
},
|
||||||
"Discussion B": {
|
"Discussion B": {
|
||||||
"id": "discussion5",
|
"id": "discussion5",
|
||||||
"sort_key": "Discussion B",
|
"sort_key": "Discussion B",
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -965,12 +967,12 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion 1": {
|
"Discussion 1": {
|
||||||
"id": "discussion3",
|
"id": "discussion3",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
},
|
},
|
||||||
"Discussion 2": {
|
"Discussion 2": {
|
||||||
"id": "discussion5",
|
"id": "discussion5",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -981,12 +983,12 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion 1": {
|
"Discussion 1": {
|
||||||
"id": "discussion4",
|
"id": "discussion4",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
},
|
},
|
||||||
"Discussion 2": {
|
"Discussion 2": {
|
||||||
"id": "discussion1",
|
"id": "discussion1",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -997,7 +999,7 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
|
|||||||
"Discussion": {
|
"Discussion": {
|
||||||
"id": "discussion2",
|
"id": "discussion2",
|
||||||
"sort_key": None,
|
"sort_key": None,
|
||||||
"is_cohorted": False,
|
"is_divided": False,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"subcategories": {},
|
"subcategories": {},
|
||||||
@@ -1074,17 +1076,17 @@ class ContentGroupCategoryMapTestCase(CategoryMapTestMixin, ContentGroupTestCase
|
|||||||
'entries': {
|
'entries': {
|
||||||
'Visible to Alpha': {
|
'Visible to Alpha': {
|
||||||
'sort_key': None,
|
'sort_key': None,
|
||||||
'is_cohorted': False,
|
'is_divided': False,
|
||||||
'id': 'alpha_group_discussion'
|
'id': 'alpha_group_discussion'
|
||||||
},
|
},
|
||||||
'Visible to Beta': {
|
'Visible to Beta': {
|
||||||
'sort_key': None,
|
'sort_key': None,
|
||||||
'is_cohorted': False,
|
'is_divided': False,
|
||||||
'id': 'beta_group_discussion'
|
'id': 'beta_group_discussion'
|
||||||
},
|
},
|
||||||
'Visible to Everyone': {
|
'Visible to Everyone': {
|
||||||
'sort_key': None,
|
'sort_key': None,
|
||||||
'is_cohorted': False,
|
'is_divided': False,
|
||||||
'id': 'global_group_discussion'
|
'id': 'global_group_discussion'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1094,7 +1096,7 @@ class ContentGroupCategoryMapTestCase(CategoryMapTestMixin, ContentGroupTestCase
|
|||||||
'entries': {
|
'entries': {
|
||||||
'General': {
|
'General': {
|
||||||
'sort_key': 'General',
|
'sort_key': 'General',
|
||||||
'is_cohorted': False,
|
'is_divided': False,
|
||||||
'id': 'i4x-org-number-course-run'
|
'id': 'i4x-org-number-course-run'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1119,12 +1121,12 @@ class ContentGroupCategoryMapTestCase(CategoryMapTestMixin, ContentGroupTestCase
|
|||||||
'entries': {
|
'entries': {
|
||||||
'Visible to Alpha': {
|
'Visible to Alpha': {
|
||||||
'sort_key': None,
|
'sort_key': None,
|
||||||
'is_cohorted': False,
|
'is_divided': False,
|
||||||
'id': 'alpha_group_discussion'
|
'id': 'alpha_group_discussion'
|
||||||
},
|
},
|
||||||
'Visible to Everyone': {
|
'Visible to Everyone': {
|
||||||
'sort_key': None,
|
'sort_key': None,
|
||||||
'is_cohorted': False,
|
'is_divided': False,
|
||||||
'id': 'global_group_discussion'
|
'id': 'global_group_discussion'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1134,7 +1136,7 @@ class ContentGroupCategoryMapTestCase(CategoryMapTestMixin, ContentGroupTestCase
|
|||||||
'entries': {
|
'entries': {
|
||||||
'General': {
|
'General': {
|
||||||
'sort_key': 'General',
|
'sort_key': 'General',
|
||||||
'is_cohorted': False,
|
'is_divided': False,
|
||||||
'id': 'i4x-org-number-course-run'
|
'id': 'i4x-org-number-course-run'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1159,12 +1161,12 @@ class ContentGroupCategoryMapTestCase(CategoryMapTestMixin, ContentGroupTestCase
|
|||||||
'entries': {
|
'entries': {
|
||||||
'Visible to Beta': {
|
'Visible to Beta': {
|
||||||
'sort_key': None,
|
'sort_key': None,
|
||||||
'is_cohorted': False,
|
'is_divided': False,
|
||||||
'id': 'beta_group_discussion'
|
'id': 'beta_group_discussion'
|
||||||
},
|
},
|
||||||
'Visible to Everyone': {
|
'Visible to Everyone': {
|
||||||
'sort_key': None,
|
'sort_key': None,
|
||||||
'is_cohorted': False,
|
'is_divided': False,
|
||||||
'id': 'global_group_discussion'
|
'id': 'global_group_discussion'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1174,7 +1176,7 @@ class ContentGroupCategoryMapTestCase(CategoryMapTestMixin, ContentGroupTestCase
|
|||||||
'entries': {
|
'entries': {
|
||||||
'General': {
|
'General': {
|
||||||
'sort_key': 'General',
|
'sort_key': 'General',
|
||||||
'is_cohorted': False,
|
'is_divided': False,
|
||||||
'id': 'i4x-org-number-course-run'
|
'id': 'i4x-org-number-course-run'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1198,7 +1200,7 @@ class ContentGroupCategoryMapTestCase(CategoryMapTestMixin, ContentGroupTestCase
|
|||||||
'entries': {
|
'entries': {
|
||||||
'Visible to Everyone': {
|
'Visible to Everyone': {
|
||||||
'sort_key': None,
|
'sort_key': None,
|
||||||
'is_cohorted': False,
|
'is_divided': False,
|
||||||
'id': 'global_group_discussion'
|
'id': 'global_group_discussion'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1208,7 +1210,7 @@ class ContentGroupCategoryMapTestCase(CategoryMapTestMixin, ContentGroupTestCase
|
|||||||
'entries': {
|
'entries': {
|
||||||
'General': {
|
'General': {
|
||||||
'sort_key': 'General',
|
'sort_key': 'General',
|
||||||
'is_cohorted': False,
|
'is_divided': False,
|
||||||
'id': 'i4x-org-number-course-run'
|
'id': 'i4x-org-number-course-run'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1273,9 +1275,9 @@ class DiscussionTabTestCase(ModuleStoreTestCase):
|
|||||||
self.assertFalse(self.discussion_tab_present(self.enrolled_user))
|
self.assertFalse(self.discussion_tab_present(self.enrolled_user))
|
||||||
|
|
||||||
|
|
||||||
class IsCommentableCohortedTestCase(ModuleStoreTestCase):
|
class IsCommentableDividedTestCase(ModuleStoreTestCase):
|
||||||
"""
|
"""
|
||||||
Test the is_commentable_cohorted function.
|
Test the is_commentable_divided function.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
MODULESTORE = TEST_DATA_MIXED_MODULESTORE
|
MODULESTORE = TEST_DATA_MIXED_MODULESTORE
|
||||||
@@ -1284,10 +1286,10 @@ class IsCommentableCohortedTestCase(ModuleStoreTestCase):
|
|||||||
"""
|
"""
|
||||||
Make sure that course is reloaded every time--clear out the modulestore.
|
Make sure that course is reloaded every time--clear out the modulestore.
|
||||||
"""
|
"""
|
||||||
super(IsCommentableCohortedTestCase, self).setUp()
|
super(IsCommentableDividedTestCase, self).setUp()
|
||||||
self.toy_course_key = ToyCourseFactory.create().id
|
self.toy_course_key = ToyCourseFactory.create().id
|
||||||
|
|
||||||
def test_is_commentable_cohorted(self):
|
def test_is_commentable_divided(self):
|
||||||
course = modulestore().get_course(self.toy_course_key)
|
course = modulestore().get_course(self.toy_course_key)
|
||||||
self.assertFalse(cohorts.is_course_cohorted(course.id))
|
self.assertFalse(cohorts.is_course_cohorted(course.id))
|
||||||
|
|
||||||
@@ -1297,7 +1299,7 @@ class IsCommentableCohortedTestCase(ModuleStoreTestCase):
|
|||||||
|
|
||||||
# no topics
|
# no topics
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
utils.is_commentable_cohorted(course.id, to_id("General")),
|
utils.is_commentable_divided(course.id, to_id("General")),
|
||||||
"Course doesn't even have a 'General' topic"
|
"Course doesn't even have a 'General' topic"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1305,7 +1307,7 @@ class IsCommentableCohortedTestCase(ModuleStoreTestCase):
|
|||||||
config_course_cohorts(course, is_cohorted=False, discussion_topics=["General", "Feedback"])
|
config_course_cohorts(course, is_cohorted=False, discussion_topics=["General", "Feedback"])
|
||||||
|
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
utils.is_commentable_cohorted(course.id, to_id("General")),
|
utils.is_commentable_divided(course.id, to_id("General")),
|
||||||
"Course isn't cohorted"
|
"Course isn't cohorted"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1314,7 +1316,7 @@ class IsCommentableCohortedTestCase(ModuleStoreTestCase):
|
|||||||
|
|
||||||
self.assertTrue(cohorts.is_course_cohorted(course.id))
|
self.assertTrue(cohorts.is_course_cohorted(course.id))
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
utils.is_commentable_cohorted(course.id, to_id("General")),
|
utils.is_commentable_divided(course.id, to_id("General")),
|
||||||
"Course is cohorted, but 'General' isn't."
|
"Course is cohorted, but 'General' isn't."
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1328,15 +1330,15 @@ class IsCommentableCohortedTestCase(ModuleStoreTestCase):
|
|||||||
|
|
||||||
self.assertTrue(cohorts.is_course_cohorted(course.id))
|
self.assertTrue(cohorts.is_course_cohorted(course.id))
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
utils.is_commentable_cohorted(course.id, to_id("General")),
|
utils.is_commentable_divided(course.id, to_id("General")),
|
||||||
"Course is cohorted, but 'General' isn't."
|
"Course is cohorted, but 'General' isn't."
|
||||||
)
|
)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
utils.is_commentable_cohorted(course.id, to_id("Feedback")),
|
utils.is_commentable_divided(course.id, to_id("Feedback")),
|
||||||
"Feedback was listed as cohorted. Should be."
|
"Feedback was listed as cohorted. Should be."
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_is_commentable_cohorted_inline_discussion(self):
|
def test_is_commentable_divided_inline_discussion(self):
|
||||||
course = modulestore().get_course(self.toy_course_key)
|
course = modulestore().get_course(self.toy_course_key)
|
||||||
self.assertFalse(cohorts.is_course_cohorted(course.id))
|
self.assertFalse(cohorts.is_course_cohorted(course.id))
|
||||||
|
|
||||||
@@ -1350,7 +1352,7 @@ class IsCommentableCohortedTestCase(ModuleStoreTestCase):
|
|||||||
cohorted_discussions=["Feedback", "random_inline"]
|
cohorted_discussions=["Feedback", "random_inline"]
|
||||||
)
|
)
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
utils.is_commentable_cohorted(course.id, to_id("random")),
|
utils.is_commentable_divided(course.id, to_id("random")),
|
||||||
"By default, Non-top-level discussions are not cohorted in a cohorted courses."
|
"By default, Non-top-level discussions are not cohorted in a cohorted courses."
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1364,20 +1366,20 @@ class IsCommentableCohortedTestCase(ModuleStoreTestCase):
|
|||||||
always_cohort_inline_discussions=False
|
always_cohort_inline_discussions=False
|
||||||
)
|
)
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
utils.is_commentable_cohorted(course.id, to_id("random")),
|
utils.is_commentable_divided(course.id, to_id("random")),
|
||||||
"Non-top-level discussion is not cohorted if always_cohort_inline_discussions is False."
|
"Non-top-level discussion is not cohorted if always_cohort_inline_discussions is False."
|
||||||
)
|
)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
utils.is_commentable_cohorted(course.id, to_id("random_inline")),
|
utils.is_commentable_divided(course.id, to_id("random_inline")),
|
||||||
"If always_cohort_inline_discussions set to False, Non-top-level discussion is "
|
"If always_cohort_inline_discussions set to False, Non-top-level discussion is "
|
||||||
"cohorted if explicitly set in cohorted_discussions."
|
"cohorted if explicitly set in cohorted_discussions."
|
||||||
)
|
)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
utils.is_commentable_cohorted(course.id, to_id("Feedback")),
|
utils.is_commentable_divided(course.id, to_id("Feedback")),
|
||||||
"If always_cohort_inline_discussions set to False, top-level discussion are not affected."
|
"If always_cohort_inline_discussions set to False, top-level discussion are not affected."
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_is_commentable_cohorted_team(self):
|
def test_is_commentable_divided_team(self):
|
||||||
course = modulestore().get_course(self.toy_course_key)
|
course = modulestore().get_course(self.toy_course_key)
|
||||||
self.assertFalse(cohorts.is_course_cohorted(course.id))
|
self.assertFalse(cohorts.is_course_cohorted(course.id))
|
||||||
|
|
||||||
@@ -1386,8 +1388,8 @@ class IsCommentableCohortedTestCase(ModuleStoreTestCase):
|
|||||||
|
|
||||||
# Verify that team discussions are not cohorted, but other discussions are
|
# Verify that team discussions are not cohorted, but other discussions are
|
||||||
# if "always cohort inline discussions" is set to true.
|
# if "always cohort inline discussions" is set to true.
|
||||||
self.assertFalse(utils.is_commentable_cohorted(course.id, team.discussion_topic_id))
|
self.assertFalse(utils.is_commentable_divided(course.id, team.discussion_topic_id))
|
||||||
self.assertTrue(utils.is_commentable_cohorted(course.id, "random"))
|
self.assertTrue(utils.is_commentable_divided(course.id, "random"))
|
||||||
|
|
||||||
|
|
||||||
class PermissionsTestCase(ModuleStoreTestCase):
|
class PermissionsTestCase(ModuleStoreTestCase):
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ def _sort_map_entries(category_map, sort_alpha):
|
|||||||
category_map["children"] = [(x[0], x[2]) for x in sorted(things, key=lambda x: x[1]["sort_key"])]
|
category_map["children"] = [(x[0], x[2]) for x in sorted(things, key=lambda x: x[1]["sort_key"])]
|
||||||
|
|
||||||
|
|
||||||
def get_discussion_category_map(course, user, cohorted_if_in_list=False, exclude_unstarted=True):
|
def get_discussion_category_map(course, user, divided_only_if_explicit=False, exclude_unstarted=True):
|
||||||
"""
|
"""
|
||||||
Transform the list of this course's discussion xblocks into a recursive dictionary structure. This is used
|
Transform the list of this course's discussion xblocks into a recursive dictionary structure. This is used
|
||||||
to render the discussion category map in the discussion tab sidebar for a given user.
|
to render the discussion category map in the discussion tab sidebar for a given user.
|
||||||
@@ -266,15 +266,15 @@ def get_discussion_category_map(course, user, cohorted_if_in_list=False, exclude
|
|||||||
Args:
|
Args:
|
||||||
course: Course for which to get the ids.
|
course: Course for which to get the ids.
|
||||||
user: User to check for access.
|
user: User to check for access.
|
||||||
cohorted_if_in_list (bool): If True, inline topics are marked is_cohorted only if they are
|
divided_only_if_explicit (bool): If True, inline topics are marked is_divided only if they are
|
||||||
in course_cohort_settings.discussion_topics.
|
explicitly listed in course_cohort_settings.discussion_topics.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
>>> example = {
|
>>> example = {
|
||||||
>>> "entries": {
|
>>> "entries": {
|
||||||
>>> "General": {
|
>>> "General": {
|
||||||
>>> "sort_key": "General",
|
>>> "sort_key": "General",
|
||||||
>>> "is_cohorted": True,
|
>>> "is_divided": True,
|
||||||
>>> "id": "i4x-edx-eiorguegnru-course-foobarbaz"
|
>>> "id": "i4x-edx-eiorguegnru-course-foobarbaz"
|
||||||
>>> }
|
>>> }
|
||||||
>>> },
|
>>> },
|
||||||
@@ -292,12 +292,12 @@ def get_discussion_category_map(course, user, cohorted_if_in_list=False, exclude
|
|||||||
>>> "entries": {
|
>>> "entries": {
|
||||||
>>> "Working with Videos": {
|
>>> "Working with Videos": {
|
||||||
>>> "sort_key": None,
|
>>> "sort_key": None,
|
||||||
>>> "is_cohorted": False,
|
>>> "is_divided": False,
|
||||||
>>> "id": "d9f970a42067413cbb633f81cfb12604"
|
>>> "id": "d9f970a42067413cbb633f81cfb12604"
|
||||||
>>> },
|
>>> },
|
||||||
>>> "Videos on edX": {
|
>>> "Videos on edX": {
|
||||||
>>> "sort_key": None,
|
>>> "sort_key": None,
|
||||||
>>> "is_cohorted": False,
|
>>> "is_divided": False,
|
||||||
>>> "id": "98d8feb5971041a085512ae22b398613"
|
>>> "id": "98d8feb5971041a085512ae22b398613"
|
||||||
>>> }
|
>>> }
|
||||||
>>> }
|
>>> }
|
||||||
@@ -356,14 +356,14 @@ def get_discussion_category_map(course, user, cohorted_if_in_list=False, exclude
|
|||||||
if node[level]["start_date"] > category_start_date:
|
if node[level]["start_date"] > category_start_date:
|
||||||
node[level]["start_date"] = category_start_date
|
node[level]["start_date"] = category_start_date
|
||||||
|
|
||||||
always_cohort_inline_discussions = ( # pylint: disable=invalid-name
|
divide_all_inline_discussions = ( # pylint: disable=invalid-name
|
||||||
not cohorted_if_in_list and course_cohort_settings.always_cohort_inline_discussions
|
not divided_only_if_explicit and course_cohort_settings.always_cohort_inline_discussions
|
||||||
)
|
)
|
||||||
dupe_counters = defaultdict(lambda: 0) # counts the number of times we see each title
|
dupe_counters = defaultdict(lambda: 0) # counts the number of times we see each title
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
is_entry_cohorted = (
|
is_entry_divided = (
|
||||||
course_cohort_settings.is_cohorted and (
|
course_cohort_settings.is_cohorted and (
|
||||||
always_cohort_inline_discussions or entry["id"] in course_cohort_settings.cohorted_discussions
|
divide_all_inline_discussions or entry["id"] in course_cohort_settings.cohorted_discussions
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -376,7 +376,7 @@ def get_discussion_category_map(course, user, cohorted_if_in_list=False, exclude
|
|||||||
node[level]["entries"][title] = {"id": entry["id"],
|
node[level]["entries"][title] = {"id": entry["id"],
|
||||||
"sort_key": entry["sort_key"],
|
"sort_key": entry["sort_key"],
|
||||||
"start_date": entry["start_date"],
|
"start_date": entry["start_date"],
|
||||||
"is_cohorted": is_entry_cohorted}
|
"is_divided": is_entry_divided}
|
||||||
|
|
||||||
# TODO. BUG! : course location is not unique across multiple course runs!
|
# TODO. BUG! : course location is not unique across multiple course runs!
|
||||||
# (I think Kevin already noticed this) Need to send course_id with requests, store it
|
# (I think Kevin already noticed this) Need to send course_id with requests, store it
|
||||||
@@ -386,8 +386,9 @@ def get_discussion_category_map(course, user, cohorted_if_in_list=False, exclude
|
|||||||
"id": entry["id"],
|
"id": entry["id"],
|
||||||
"sort_key": entry.get("sort_key", topic),
|
"sort_key": entry.get("sort_key", topic),
|
||||||
"start_date": datetime.now(UTC()),
|
"start_date": datetime.now(UTC()),
|
||||||
"is_cohorted": (course_cohort_settings.is_cohorted and
|
"is_divided": (
|
||||||
entry["id"] in course_cohort_settings.cohorted_discussions)
|
course_cohort_settings.is_cohorted and entry["id"] in course_cohort_settings.cohorted_discussions
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
_sort_map_entries(category_map, course.discussion_sort_alpha)
|
_sort_map_entries(category_map, course.discussion_sort_alpha)
|
||||||
@@ -740,7 +741,7 @@ def get_group_id_for_comments_service(request, course_key, commentable_id=None):
|
|||||||
Raises:
|
Raises:
|
||||||
ValueError if the requested group_id is invalid
|
ValueError if the requested group_id is invalid
|
||||||
"""
|
"""
|
||||||
if commentable_id is None or is_commentable_cohorted(course_key, commentable_id):
|
if commentable_id is None or is_commentable_divided(course_key, commentable_id):
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
requested_group_id = request.GET.get('group_id')
|
requested_group_id = request.GET.get('group_id')
|
||||||
elif request.method == "POST":
|
elif request.method == "POST":
|
||||||
@@ -755,7 +756,7 @@ def get_group_id_for_comments_service(request, course_key, commentable_id=None):
|
|||||||
raise ValueError
|
raise ValueError
|
||||||
else:
|
else:
|
||||||
# regular users always query with their own id.
|
# regular users always query with their own id.
|
||||||
group_id = get_cohort_id(request.user, course_key)
|
group_id = get_group_id_for_user(request.user, course_key)
|
||||||
return group_id
|
return group_id
|
||||||
else:
|
else:
|
||||||
# Never pass a group_id to the comments service for a non-cohorted
|
# Never pass a group_id to the comments service for a non-cohorted
|
||||||
@@ -763,6 +764,14 @@ def get_group_id_for_comments_service(request, course_key, commentable_id=None):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def get_group_id_for_user(user, course_key):
|
||||||
|
"""
|
||||||
|
This method will be modified to consider Enrollment Tracks.
|
||||||
|
Currently pass-through to get_cohort_id.
|
||||||
|
"""
|
||||||
|
return get_cohort_id(user, course_key)
|
||||||
|
|
||||||
|
|
||||||
def is_comment_too_deep(parent):
|
def is_comment_too_deep(parent):
|
||||||
"""
|
"""
|
||||||
Determine whether a comment with the given parent violates MAX_COMMENT_DEPTH
|
Determine whether a comment with the given parent violates MAX_COMMENT_DEPTH
|
||||||
@@ -777,14 +786,15 @@ def is_comment_too_deep(parent):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def is_commentable_cohorted(course_key, commentable_id):
|
def is_commentable_divided(course_key, commentable_id):
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
course_key: CourseKey
|
course_key: CourseKey
|
||||||
commentable_id: string
|
commentable_id: string
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Bool: is this commentable cohorted?
|
Bool: is this commentable divided, meaning that learners are divided into
|
||||||
|
groups (either Cohorts or Enrollment Tracks) and only see posts within their group?
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
Http404 if the course doesn't exist.
|
Http404 if the course doesn't exist.
|
||||||
@@ -807,7 +817,7 @@ def is_commentable_cohorted(course_key, commentable_id):
|
|||||||
# inline discussions are cohorted by default
|
# inline discussions are cohorted by default
|
||||||
ans = True
|
ans = True
|
||||||
|
|
||||||
log.debug(u"is_commentable_cohorted(%s, %s) = {%s}", course_key, commentable_id, ans)
|
log.debug(u"is_commentable_divided(%s, %s) = {%s}", course_key, commentable_id, ans)
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
return subCategoryTemplate({
|
return subCategoryTemplate({
|
||||||
name: name,
|
name: name,
|
||||||
id: entry.id,
|
id: entry.id,
|
||||||
is_cohorted: entry.is_cohorted,
|
is_divided: entry.is_divided,
|
||||||
type: 'course-wide'
|
type: 'course-wide'
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
htmlSnippet = entryTemplate({
|
htmlSnippet = entryTemplate({
|
||||||
name: name,
|
name: name,
|
||||||
id: entry.id,
|
id: entry.id,
|
||||||
is_cohorted: entry.is_cohorted,
|
is_divided: entry.is_divided,
|
||||||
type: 'inline'
|
type: 'inline'
|
||||||
});
|
});
|
||||||
} else { // subcategory
|
} else { // subcategory
|
||||||
|
|||||||
@@ -93,12 +93,12 @@ define(['backbone', 'jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers
|
|||||||
entries: {
|
entries: {
|
||||||
Topic_C_1: {
|
Topic_C_1: {
|
||||||
sort_key: null,
|
sort_key: null,
|
||||||
is_cohorted: true,
|
is_divided: true,
|
||||||
id: 'Topic_C_1'
|
id: 'Topic_C_1'
|
||||||
},
|
},
|
||||||
Topic_C_2: {
|
Topic_C_2: {
|
||||||
sort_key: null,
|
sort_key: null,
|
||||||
is_cohorted: false,
|
is_divided: false,
|
||||||
id: 'Topic_C_2'
|
id: 'Topic_C_2'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,12 +111,12 @@ define(['backbone', 'jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers
|
|||||||
entries: {
|
entries: {
|
||||||
Inline_Discussion_1: {
|
Inline_Discussion_1: {
|
||||||
sort_key: null,
|
sort_key: null,
|
||||||
is_cohorted: true,
|
is_divided: true,
|
||||||
id: 'Inline_Discussion_1'
|
id: 'Inline_Discussion_1'
|
||||||
},
|
},
|
||||||
Inline_Discussion_2: {
|
Inline_Discussion_2: {
|
||||||
sort_key: null,
|
sort_key: null,
|
||||||
is_cohorted: allCohorted || false,
|
is_divided: allCohorted || false,
|
||||||
id: 'Inline_Discussion_2'
|
id: 'Inline_Discussion_2'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1492,7 +1492,7 @@ define(['backbone', 'jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers
|
|||||||
entries: {
|
entries: {
|
||||||
Topic_C_1: {
|
Topic_C_1: {
|
||||||
sort_key: null,
|
sort_key: null,
|
||||||
is_cohorted: true,
|
is_divided: true,
|
||||||
id: 'Topic_C_1'
|
id: 'Topic_C_1'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ from openedx.core.djangolib.markup import HTML
|
|||||||
class="forum-nav-browse-menu-item"
|
class="forum-nav-browse-menu-item"
|
||||||
data-discussion-id='${entries[entry]["id"]}'
|
data-discussion-id='${entries[entry]["id"]}'
|
||||||
id='${entries[entry]["id"]}'
|
id='${entries[entry]["id"]}'
|
||||||
data-cohorted="${str(entries[entry]['is_cohorted']).lower()}"
|
data-cohorted="${str(entries[entry]['is_divided']).lower()}"
|
||||||
role="option"
|
role="option"
|
||||||
>
|
>
|
||||||
% if entry:
|
% if entry:
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<li class="discussion-subcategory-item">
|
<li class="discussion-subcategory-item">
|
||||||
<div class="subcategory-item">
|
<div class="subcategory-item">
|
||||||
<label>
|
<label>
|
||||||
<input data-id="<%- id %>" class="check-discussion-subcategory-<%- type %>" type="checkbox" <%- is_cohorted ? 'checked="checked"' : '' %> />
|
<input data-id="<%- id %>" class="check-discussion-subcategory-<%- type %>" type="checkbox" <%- is_divided ? 'checked="checked"' : '' %> />
|
||||||
<span class="topic-name"><%- name %></span>
|
<span class="topic-name"><%- name %></span>
|
||||||
<span class="cohorted-text <%- is_cohorted ? '' : 'hidden'%>">- <%- gettext('Cohorted') %></span>
|
<span class="cohorted-text <%- is_divided ? '' : 'hidden'%>">- <%- gettext('Cohorted') %></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -1255,7 +1255,7 @@ class CourseCohortDiscussionTopicsTestCase(CohortViewsTestCase):
|
|||||||
'entries': {
|
'entries': {
|
||||||
'Topic B': {
|
'Topic B': {
|
||||||
'sort_key': 'A',
|
'sort_key': 'A',
|
||||||
'is_cohorted': True,
|
'is_divided': True,
|
||||||
'id': topic_name_to_id(self.course, "Topic B"),
|
'id': topic_name_to_id(self.course, "Topic B"),
|
||||||
'start_date': response['course_wide_discussions']['entries']['Topic B']['start_date']
|
'start_date': response['course_wide_discussions']['entries']['Topic B']['start_date']
|
||||||
}
|
}
|
||||||
@@ -1269,7 +1269,7 @@ class CourseCohortDiscussionTopicsTestCase(CohortViewsTestCase):
|
|||||||
'entries': {
|
'entries': {
|
||||||
'Discussion': {
|
'Discussion': {
|
||||||
'sort_key': None,
|
'sort_key': None,
|
||||||
'is_cohorted': True,
|
'is_divided': True,
|
||||||
'id': topic_name_to_id(self.course, "Topic A"),
|
'id': topic_name_to_id(self.course, "Topic A"),
|
||||||
'start_date': start_date
|
'start_date': start_date
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -435,7 +435,7 @@ def cohort_discussion_topics(request, course_key_string):
|
|||||||
>>> "entries": {
|
>>> "entries": {
|
||||||
>>> "General": {
|
>>> "General": {
|
||||||
>>> "sort_key": "General",
|
>>> "sort_key": "General",
|
||||||
>>> "is_cohorted": True,
|
>>> "is_divided": True,
|
||||||
>>> "id": "i4x-edx-eiorguegnru-course-foobarbaz"
|
>>> "id": "i4x-edx-eiorguegnru-course-foobarbaz"
|
||||||
>>> }
|
>>> }
|
||||||
>>> }
|
>>> }
|
||||||
@@ -452,12 +452,12 @@ def cohort_discussion_topics(request, course_key_string):
|
|||||||
>>> "entries": {
|
>>> "entries": {
|
||||||
>>> "Working with Videos": {
|
>>> "Working with Videos": {
|
||||||
>>> "sort_key": None,
|
>>> "sort_key": None,
|
||||||
>>> "is_cohorted": False,
|
>>> "is_divided": False,
|
||||||
>>> "id": "d9f970a42067413cbb633f81cfb12604"
|
>>> "id": "d9f970a42067413cbb633f81cfb12604"
|
||||||
>>> },
|
>>> },
|
||||||
>>> "Videos on edX": {
|
>>> "Videos on edX": {
|
||||||
>>> "sort_key": None,
|
>>> "sort_key": None,
|
||||||
>>> "is_cohorted": False,
|
>>> "is_divided": False,
|
||||||
>>> "id": "98d8feb5971041a085512ae22b398613"
|
>>> "id": "98d8feb5971041a085512ae22b398613"
|
||||||
>>> }
|
>>> }
|
||||||
>>> }
|
>>> }
|
||||||
@@ -472,7 +472,7 @@ def cohort_discussion_topics(request, course_key_string):
|
|||||||
|
|
||||||
discussion_topics = {}
|
discussion_topics = {}
|
||||||
discussion_category_map = get_discussion_category_map(
|
discussion_category_map = get_discussion_category_map(
|
||||||
course, request.user, cohorted_if_in_list=True, exclude_unstarted=False
|
course, request.user, divided_only_if_explicit=True, exclude_unstarted=False
|
||||||
)
|
)
|
||||||
|
|
||||||
# We extract the data for the course wide discussions from the category map.
|
# We extract the data for the course wide discussions from the category map.
|
||||||
|
|||||||
Reference in New Issue
Block a user