Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
31fbde9c
Commit
31fbde9c
authored
Apr 26, 2017
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename cohort methods to divided.
parent
8fbf01cd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
163 additions
and
153 deletions
+163
-153
common/static/common/js/discussion/discussion.js
+2
-2
common/static/common/js/discussion/views/discussion_inline_view.js
+3
-3
common/static/common/js/discussion/views/discussion_thread_show_view.js
+2
-2
common/static/common/js/discussion/views/discussion_thread_view.js
+2
-2
common/static/common/js/discussion/views/discussion_topic_menu_view.js
+1
-1
common/static/common/js/discussion/views/new_post_view.js
+5
-5
common/static/common/js/spec/discussion/view/discussion_thread_edit_view_spec.js
+13
-13
common/static/common/js/spec/discussion/view/discussion_thread_show_view_spec.js
+5
-5
common/static/common/js/spec/discussion/view/discussion_topic_menu_view_spec.js
+29
-29
common/static/common/js/spec/discussion/view/new_post_view_spec.js
+25
-25
common/static/common/js/spec_helpers/discussion_spec_helper.js
+2
-2
common/static/common/templates/discussion/new-post-menu-entry.underscore
+1
-1
common/static/common/templates/discussion/new-post.underscore
+2
-2
common/static/common/templates/discussion/thread-show.underscore
+1
-1
lms/djangoapps/discussion/static/discussion/js/discussion_board_factory.js
+2
-2
lms/djangoapps/discussion/static/discussion/js/discussion_router.js
+1
-1
lms/djangoapps/discussion/templates/discussion/discussion_board_fragment.html
+1
-1
lms/djangoapps/discussion/templates/discussion/discussion_board_js.template
+1
-1
lms/djangoapps/discussion/templates/discussion/discussion_profile_page.html
+1
-1
lms/djangoapps/discussion/views.py
+11
-10
lms/djangoapps/discussion_api/api.py
+7
-8
lms/djangoapps/django_comment_client/base/views.py
+2
-2
lms/djangoapps/django_comment_client/tests/test_utils.py
+0
-0
lms/djangoapps/django_comment_client/utils.py
+28
-18
lms/static/js/groups/views/cohort_discussions_course_wide.js
+1
-1
lms/static/js/groups/views/cohort_discussions_inline.js
+1
-1
lms/static/js/spec/groups/views/cohorts_spec.js
+5
-5
lms/templates/discussion/_filter_dropdown.html
+1
-1
lms/templates/instructor/instructor_dashboard_2/cohort-discussions-subcategory.underscore
+2
-2
openedx/core/djangoapps/course_groups/tests/test_views.py
+2
-2
openedx/core/djangoapps/course_groups/views.py
+4
-4
No files found.
common/static/common/js/discussion/discussion.js
View file @
31fbde9c
...
...
@@ -36,7 +36,7 @@
this
.
pages
=
options
.
pages
||
1
;
this
.
current_page
=
1
;
this
.
sort_preference
=
options
.
sort
;
this
.
is_commentable_
cohorted
=
options
.
is_commentable_cohort
ed
;
this
.
is_commentable_
divided
=
options
.
is_commentable_divid
ed
;
this
.
bind
(
'add'
,
function
(
item
)
{
item
.
discussion
=
self
;
});
...
...
@@ -142,7 +142,7 @@
Content
.
loadContentInfos
(
response
.
annotated_content_info
);
self
.
pages
=
response
.
num_pages
;
self
.
current_page
=
response
.
page
;
self
.
is_commentable_
cohorted
=
response
.
is_commentable_cohort
ed
;
self
.
is_commentable_
divided
=
response
.
is_commentable_divid
ed
;
return
self
.
reset
(
new_collection
);
},
error
:
error
...
...
common/static/common/js/discussion/views/discussion_inline_view.js
View file @
31fbde9c
...
...
@@ -86,7 +86,7 @@
DiscussionUtil
.
loadRoles
(
response
.
roles
);
this
.
courseSettings
=
new
DiscussionCourseSettings
(
response
.
course_settings
);
this
.
is_commentable_
cohorted
=
response
.
is_commentable_cohort
ed
;
this
.
is_commentable_
divided
=
response
.
is_commentable_divid
ed
;
this
.
discussion
=
new
Discussion
(
undefined
,
{
pages
:
response
.
num_pages
});
this
.
discussion
.
reset
(
response
.
discussion_data
,
{
...
...
@@ -126,7 +126,7 @@
course_settings
:
this
.
courseSettings
,
topicId
:
discussionId
,
startHeader
:
this
.
startHeader
,
is_commentable_
cohorted
:
response
.
is_commentable_cohort
ed
is_commentable_
divided
:
response
.
is_commentable_divid
ed
});
this
.
newPostView
.
render
();
...
...
@@ -154,7 +154,7 @@
mode
:
'inline'
,
startHeader
:
this
.
startHeader
,
courseSettings
:
this
.
courseSettings
,
is_commentable_
cohorted
:
this
.
is_commentable_cohort
ed
is_commentable_
divided
:
this
.
is_commentable_divid
ed
});
this
.
threadView
.
render
();
this
.
listenTo
(
this
.
threadView
.
showView
,
'thread:_delete'
,
this
.
navigateToAllPosts
);
...
...
common/static/common/js/discussion/views/discussion_thread_show_view.js
View file @
31fbde9c
...
...
@@ -31,7 +31,7 @@
DiscussionThreadShowView
.
__super__
.
initialize
.
call
(
this
);
this
.
mode
=
options
.
mode
||
'inline'
;
this
.
startHeader
=
options
.
startHeader
;
this
.
is_commentable_
cohorted
=
options
.
is_commentable_cohort
ed
;
this
.
is_commentable_
divided
=
options
.
is_commentable_divid
ed
;
if
((
_ref
=
this
.
mode
)
!==
'tab'
&&
_ref
!==
'inline'
)
{
throw
new
Error
(
'invalid mode: '
+
this
.
mode
);
}
...
...
@@ -42,7 +42,7 @@
mode
:
this
.
mode
,
startHeader
:
this
.
startHeader
,
flagged
:
this
.
model
.
isFlagged
(),
is_commentable_
cohorted
:
this
.
is_commentable_cohort
ed
,
is_commentable_
divided
:
this
.
is_commentable_divid
ed
,
author_display
:
this
.
getAuthorDisplay
(),
cid
:
this
.
model
.
cid
,
readOnly
:
$
(
'.discussion-module'
).
data
(
'read-only'
)
...
...
common/static/common/js/discussion/views/discussion_thread_view.js
View file @
31fbde9c
...
...
@@ -92,7 +92,7 @@
self
.
model
=
collection
.
get
(
id
);
}
});
this
.
is_commentable_
cohorted
=
options
.
is_commentable_cohort
ed
;
this
.
is_commentable_
divided
=
options
.
is_commentable_divid
ed
;
this
.
createShowView
();
this
.
responses
=
new
Comments
();
this
.
loadedResponses
=
false
;
...
...
@@ -423,7 +423,7 @@
model
:
this
.
model
,
mode
:
this
.
mode
,
startHeader
:
this
.
startHeader
,
is_commentable_
cohorted
:
this
.
is_commentable_cohort
ed
is_commentable_
divided
:
this
.
is_commentable_divid
ed
});
this
.
showView
.
bind
(
'thread:_delete'
,
this
.
_delete
);
return
this
.
showView
.
bind
(
'thread:edit'
,
this
.
edit
);
...
...
common/static/common/js/discussion/views/discussion_topic_menu_view.js
View file @
31fbde9c
...
...
@@ -55,7 +55,7 @@
html
=
entryTemplate
({
text
:
name
,
id
:
entry
.
id
,
is_
cohorted
:
entry
.
is_cohort
ed
is_
divided
:
entry
.
is_divid
ed
});
}
else
{
// subcategory
html
=
categoryTemplate
({
...
...
common/static/common/js/discussion/views/new_post_view.js
View file @
31fbde9c
...
...
@@ -41,7 +41,7 @@
throw
new
Error
(
'invalid mode: '
+
this
.
mode
);
}
this
.
course_settings
=
options
.
course_settings
;
this
.
is_commentable_
cohorted
=
options
.
is_commentable_cohort
ed
;
this
.
is_commentable_
divided
=
options
.
is_commentable_divid
ed
;
this
.
topicId
=
options
.
topicId
;
this
.
discussionBoardView
=
options
.
discussionBoardView
;
};
...
...
@@ -52,7 +52,7 @@
context
=
_
.
clone
(
this
.
course_settings
.
attributes
);
_
.
extend
(
context
,
{
cohort_options
:
this
.
getCohortOptions
(),
is_commentable_
cohorted
:
this
.
is_commentable_cohort
ed
,
is_commentable_
divided
:
this
.
is_commentable_divid
ed
,
mode
:
this
.
mode
,
startHeader
:
this
.
startHeader
,
form_id
:
this
.
mode
+
(
this
.
topicId
?
'-'
+
this
.
topicId
:
''
)
...
...
@@ -85,14 +85,14 @@
};
NewPostView
.
prototype
.
getCohortOptions
=
function
()
{
var
user
Cohort
Id
;
var
user
Group
Id
;
if
(
this
.
course_settings
.
get
(
'is_cohorted'
)
&&
DiscussionUtil
.
isPrivilegedUser
())
{
user
CohortId
=
$
(
'#discussion-container'
).
data
(
'user-cohort
-id'
);
user
GroupId
=
$
(
'#discussion-container'
).
data
(
'user-group
-id'
);
return
_
.
map
(
this
.
course_settings
.
get
(
'cohorts'
),
function
(
cohort
)
{
return
{
value
:
cohort
.
id
,
text
:
cohort
.
name
,
selected
:
cohort
.
id
===
user
Cohort
Id
selected
:
cohort
.
id
===
user
Group
Id
};
});
}
else
{
...
...
common/static/common/js/spec/discussion/view/discussion_thread_edit_view_spec.js
View file @
31fbde9c
...
...
@@ -96,29 +96,29 @@
describe
(
'renderComments'
,
function
()
{
beforeEach
(
function
()
{
this
.
course_settings
=
new
DiscussionCourseSettings
({
'category_map'
:
{
'children'
:
[
// eslint-disable-line quote-props
category_map
:
{
children
:
[
[
'Topic'
,
'entry'
],
[
'General'
,
'entry'
],
[
'Basic Question'
,
'entry'
]
],
'entries'
:
{
'Topic'
:
{
'is_cohorted'
:
true
,
'id'
:
'topic'
entries
:
{
Topic
:
{
is_divided
:
true
,
id
:
'topic'
},
'General'
:
{
'sort_key'
:
'General'
,
'is_cohorted'
:
false
,
'id'
:
'6.00.1x_General'
General
:
{
sort_key
:
'General'
,
is_divided
:
false
,
id
:
'6.00.1x_General'
},
'Basic Question'
:
{
'is_cohorted'
:
false
,
'id'
:
"6>00'1x
\"
Basic_Question"
is_divided
:
false
,
id
:
"6>00'1x
\"
Basic_Question"
}
}
},
'is_cohorted'
:
true
is_cohorted
:
true
});
});
...
...
common/static/common/js/spec/discussion/view/discussion_thread_show_view_spec.js
View file @
31fbde9c
...
...
@@ -173,23 +173,23 @@
});
});
describe
(
'cohorting'
,
function
()
{
it
(
'renders correctly for a
n uncohort
ed thread'
,
function
()
{
it
(
'renders correctly for a
unifi
ed thread'
,
function
()
{
this
.
view
.
render
();
return
expect
(
this
.
view
.
$
(
'.group-visibility-label'
).
text
().
trim
())
.
toEqual
(
'This post is visible to everyone.'
);
});
it
(
'renders correctly for a
cohort
ed thread'
,
function
()
{
it
(
'renders correctly for a
divid
ed thread'
,
function
()
{
this
.
thread
.
set
(
'group_id'
,
'1'
);
this
.
thread
.
set
(
'group_name'
,
'Mock Cohort'
);
this
.
view
.
is_commentable_
cohort
ed
=
true
;
this
.
view
.
is_commentable_
divid
ed
=
true
;
this
.
view
.
render
();
return
expect
(
this
.
view
.
$
(
'.group-visibility-label'
).
text
().
trim
())
.
toEqual
(
'This post is visible only to Mock Cohort.'
);
});
it
(
'renders correctly for a grouped un
cohort
ed thread'
,
function
()
{
it
(
'renders correctly for a grouped un
ifi
ed thread'
,
function
()
{
this
.
thread
.
set
(
'group_id'
,
'1'
);
this
.
thread
.
set
(
'group_name'
,
'Mock Cohort'
);
this
.
view
.
is_commentable_
cohort
ed
=
false
;
this
.
view
.
is_commentable_
divid
ed
=
false
;
this
.
view
.
render
();
return
expect
(
this
.
view
.
$
(
'.group-visibility-label'
).
text
().
trim
())
.
toEqual
(
'This post is visible to everyone.'
);
...
...
common/static/common/js/spec/discussion/view/discussion_topic_menu_view_spec.js
View file @
31fbde9c
...
...
@@ -16,67 +16,67 @@
DiscussionSpecHelper
.
setUpGlobals
();
DiscussionSpecHelper
.
setUnderscoreFixtures
();
this
.
course_settings
=
new
DiscussionCourseSettings
({
'category_map'
:
{
'subcategories'
:
{
category_map
:
{
subcategories
:
{
'Basic Question Types'
:
{
'subcategories'
:
{},
'children'
:
[
subcategories
:
{},
children
:
[
[
'Selection From Options'
,
'entry'
],
[
'Numerical Input'
,
'entry'
],
[
'Very long category name'
,
'entry'
],
[
'Very very very very long category name'
,
'entry'
],
[
'Name with <em>HTML</em>'
,
'entry'
]
],
'entries'
:
{
entries
:
{
'Selection From Options'
:
{
'sort_key'
:
null
,
'is_cohorted'
:
true
,
'id'
:
'cba3e4cd91d0466b9ac50926e495b76f'
sort_key
:
null
,
is_divided
:
true
,
id
:
'cba3e4cd91d0466b9ac50926e495b76f'
},
'Numerical Input'
:
{
'sort_key'
:
null
,
'is_cohorted'
:
false
,
'id'
:
'c49f0dfb8fc94c9c8d9999cc95190c56'
sort_key
:
null
,
is_divided
:
false
,
id
:
'c49f0dfb8fc94c9c8d9999cc95190c56'
},
'Very long category name'
:
{
'sort_key'
:
null
,
'is_cohorted'
:
false
,
'id'
:
'c49f0dfb8fc94c9c8d9999cc95190c59'
sort_key
:
null
,
is_divided
:
false
,
id
:
'c49f0dfb8fc94c9c8d9999cc95190c59'
},
'Very very very very long category name'
:
{
'sort_key'
:
null
,
'is_cohorted'
:
false
,
'id'
:
'c49f0dfb8fc94c9c8d9999cc95190e32'
sort_key
:
null
,
is_divided
:
false
,
id
:
'c49f0dfb8fc94c9c8d9999cc95190e32'
},
'Name with <em>HTML</em>'
:
{
'sort_key'
:
null
,
'is_cohorted'
:
false
,
'id'
:
'c49f0dfb8fc94c9c8d9999cc95190363'
sort_key
:
null
,
is_divided
:
false
,
id
:
'c49f0dfb8fc94c9c8d9999cc95190363'
}
}
},
'Example Inline Discussion'
:
{
'subcategories'
:
{},
'children'
:
[
subcategories
:
{},
children
:
[
[
'What Are Your Goals for Creating a MOOC?'
,
'entry'
]
],
'entries'
:
{
entries
:
{
'What Are Your Goals for Creating a MOOC?'
:
{
'sort_key'
:
null
,
'is_cohorted'
:
true
,
'id'
:
'cba3e4cd91d0466b9ac50926e495b931'
sort_key
:
null
,
is_divided
:
true
,
id
:
'cba3e4cd91d0466b9ac50926e495b931'
}
}
}
},
'children'
:
[
// eslint-disable-line quote-props
children
:
[
[
'Basic Question Types'
,
'subcategory'
],
[
'Example Inline Discussion'
,
'subcategory'
]
],
'entries'
:
{}
entries
:
{}
},
'is_cohorted'
:
true
is_cohorted
:
true
});
});
...
...
common/static/common/js/spec/discussion/view/new_post_view_spec.js
View file @
31fbde9c
...
...
@@ -38,15 +38,15 @@
children
:
[[
'Topic'
,
'entry'
],
[
'General'
,
'entry'
],
[
'Not Cohorted'
,
'entry'
]],
entries
:
{
Topic
:
{
is_
cohort
ed
:
true
,
is_
divid
ed
:
true
,
id
:
'topic'
},
General
:
{
is_
cohort
ed
:
true
,
is_
divid
ed
:
true
,
id
:
'general'
},
'Not Cohorted'
:
{
is_
cohort
ed
:
false
,
is_
divid
ed
:
false
,
id
:
'not-cohorted'
}
}
...
...
@@ -145,20 +145,20 @@
});
it
(
'disables the cohort menu if it is set false'
,
function
()
{
DiscussionSpecHelper
.
makeModerator
();
this
.
view
.
is_commentable_
cohort
ed
=
false
;
this
.
view
.
is_commentable_
divid
ed
=
false
;
return
checkVisibility
(
this
.
view
,
true
,
true
,
true
);
});
it
(
'enables the cohort menu if it is set true'
,
function
()
{
DiscussionSpecHelper
.
makeModerator
();
this
.
view
.
is_commentable_
cohort
ed
=
true
;
this
.
view
.
is_commentable_
divid
ed
=
true
;
return
checkVisibility
(
this
.
view
,
true
,
false
,
true
);
});
it
(
'is not visible to students when set false'
,
function
()
{
this
.
view
.
is_commentable_
cohort
ed
=
false
;
this
.
view
.
is_commentable_
divid
ed
=
false
;
return
checkVisibility
(
this
.
view
,
false
,
false
,
true
);
});
it
(
'is not visible to students when set true'
,
function
()
{
this
.
view
.
is_commentable_
cohort
ed
=
true
;
this
.
view
.
is_commentable_
divid
ed
=
true
;
return
checkVisibility
(
this
.
view
,
false
,
false
,
true
);
});
});
...
...
@@ -166,33 +166,33 @@
var
checkPostCancelReset
;
beforeEach
(
function
()
{
this
.
course_settings
=
new
DiscussionCourseSettings
({
'allow_anonymous_to_peers'
:
true
,
'allow_anonymous'
:
true
,
'category_map'
:
{
'subcategories'
:
{
allow_anonymous_to_peers
:
true
,
allow_anonymous
:
true
,
category_map
:
{
subcategories
:
{
'Week 1'
:
{
'subcategories'
:
{},
'children'
:
[
// eslint-disable-line quote-props
subcategories
:
{},
children
:
[
[
'Topic-Level Student-Visible Label'
,
'entry'
]
],
'entries'
:
{
entries
:
{
'Topic-Level Student-Visible Label'
:
{
'sort_key'
:
null
,
'is_cohorted'
:
false
,
'id'
:
'2b3a858d0c884eb4b272dbbe3f2ffddd'
sort_key
:
null
,
is_divided
:
false
,
id
:
'2b3a858d0c884eb4b272dbbe3f2ffddd'
}
}
}
},
'children'
:
[
// eslint-disable-line quote-props
children
:
[
[
'General'
,
'entry'
],
[
'Week 1'
,
'subcategory'
]
],
'entries'
:
{
'General'
:
{
'sort_key'
:
'General'
,
'is_cohorted'
:
false
,
'id'
:
'i4x-waqastest-waqastest-course-waqastest'
entries
:
{
General
:
{
sort_key
:
'General'
,
is_divided
:
false
,
id
:
'i4x-waqastest-waqastest-course-waqastest'
}
}
}
...
...
@@ -255,7 +255,7 @@
entries
:
{
'Topic-Level Student-Visible Label'
:
{
sort_key
:
null
,
is_
cohort
ed
:
false
,
is_
divid
ed
:
false
,
id
:
'2b3a858d0c884eb4b272dbbe3f2ffddd'
}
}
...
...
@@ -268,7 +268,7 @@
entries
:
{
'First topic'
:
{
sort_key
:
'First topic'
,
is_
cohort
ed
:
false
,
is_
divid
ed
:
false
,
id
:
'i4x-waqastest-waqastest-course-waqastest'
}
}
...
...
common/static/common/js/spec_helpers/discussion_spec_helper.js
View file @
31fbde9c
...
...
@@ -58,11 +58,11 @@
children
:
[[
'Test Topic'
,
'entry'
],
[
'Other Topic'
,
'entry'
]],
entries
:
{
'Test Topic'
:
{
is_
cohort
ed
:
true
,
is_
divid
ed
:
true
,
id
:
'test_topic'
},
'Other Topic'
:
{
is_
cohort
ed
:
true
,
is_
divid
ed
:
true
,
id
:
'other_topic'
}
}
...
...
common/static/common/templates/discussion/new-post-menu-entry.underscore
View file @
31fbde9c
<option class="topic-title" data-discussion-id="<%- id %>" data-cohorted="<%- is_
cohort
ed %>"><%- text %></option>
<option class="topic-title" data-discussion-id="<%- id %>" data-cohorted="<%- is_
divid
ed %>"><%- text %></option>
common/static/common/templates/discussion/new-post.underscore
View file @
31fbde9c
...
...
@@ -10,7 +10,7 @@
<ul class="post-errors" style="display: none"></ul>
<div class="forum-new-post-form-wrapper"></div>
<% if (cohort_options) { %>
<div class="post-field group-selector-wrapper <% if (!is_commentable_
cohort
ed) { print('disabled'); } %>">
<div class="post-field group-selector-wrapper <% if (!is_commentable_
divid
ed) { print('disabled'); } %>">
<label class="field-label">
<span class="field-label-text">
<% //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.") %>
</div>
<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_
cohort
ed) { print("disabled"); } %>>
<select aria-describedby="field_help_visible_to" class="post-topic field-input js-group-select" name="group_id" <% if (!is_commentable_
divid
ed) { print("disabled"); } %>>
<option value=""><%- gettext("All Groups") %></option>
<% _.each(cohort_options, function(opt) { %>
<option value="<%- opt.value %>" <% if (opt.selected) { print("selected"); } %>><%- opt.text %></option>
...
...
common/static/common/templates/discussion/thread-show.underscore
View file @
31fbde9c
...
...
@@ -70,7 +70,7 @@
%>
<% } %>
<div class="group-visibility-label">
<% if (obj.group_name && is_commentable_
cohort
ed) { %>
<% if (obj.group_name && is_commentable_
divid
ed) { %>
<%-
interpolate(
gettext('This post is visible only to %(group_name)s.'),
...
...
lms/djangoapps/discussion/static/discussion/js/discussion_board_factory.js
View file @
31fbde9c
...
...
@@ -21,7 +21,7 @@
sortPreference
=
options
.
sortPreference
,
threads
=
options
.
threads
,
threadPages
=
options
.
threadPages
,
isCommentable
Cohorted
=
options
.
isCommentableCohort
ed
,
isCommentable
Divided
=
options
.
isCommentableDivid
ed
,
contentInfo
=
options
.
contentInfo
,
user
=
new
DiscussionUser
(
userInfo
),
discussion
,
...
...
@@ -41,7 +41,7 @@
// Create a discussion model
discussion
=
new
Discussion
(
threads
,
{
pages
:
threadPages
,
sort
:
sortPreference
,
is_commentable_
cohorted
:
isCommentableCohort
ed
});
is_commentable_
divided
:
isCommentableDivid
ed
});
courseSettings
=
new
DiscussionCourseSettings
(
options
.
courseSettings
);
// Create the discussion board view
...
...
lms/djangoapps/discussion/static/discussion/js/discussion_router.js
View file @
31fbde9c
...
...
@@ -103,7 +103,7 @@
mode
:
'tab'
,
startHeader
:
this
.
startHeader
,
courseSettings
:
this
.
courseSettings
,
is_commentable_
cohorted
:
this
.
discussion
.
is_commentable_cohort
ed
is_commentable_
divided
:
this
.
discussion
.
is_commentable_divid
ed
});
this
.
main
.
render
();
this
.
main
.
on
(
'thread:responses:rendered'
,
function
()
{
...
...
lms/djangoapps/discussion/templates/discussion/discussion_board_fragment.html
View file @
31fbde9c
...
...
@@ -22,7 +22,7 @@ from openedx.core.djangolib.markup import HTML
data-read-only=
"false"
data-sort-preference=
"${sort_preference}"
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"
>
## Breadcrumb navigation
<div
class=
"page-header-main"
>
...
...
lms/djangoapps/discussion/templates/discussion/discussion_board_js.template
View file @
31fbde9c
...
...
@@ -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},
courseName: '${course.display_name_with_default | n, js_escaped_string}',
courseSettings: ${course_settings | n, dump_js_escaped_json},
isCommentable
Cohorted: ${is_commentable_cohort
ed | n, dump_js_escaped_json}
isCommentable
Divided: ${is_commentable_divid
ed | n, dump_js_escaped_json}
});
});
});
...
...
lms/djangoapps/discussion/templates/discussion/discussion_profile_page.html
View file @
31fbde9c
...
...
@@ -84,7 +84,7 @@ from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_str
data-read-only=
"false"
data-sort-preference=
"${sort_preference}"
data-flag-moderator=
"${json.dumps(flag_moderator)}"
data-user-
cohort-id=
"${user_cohort
}"
>
data-user-
group-id=
"${user_group_id
}"
>
</div>
</main>
</div>
...
...
lms/djangoapps/discussion/views.py
View file @
31fbde9c
...
...
@@ -32,7 +32,6 @@ from courseware.courses import get_course_with_access
from
courseware.views.views
import
CourseTabView
from
openedx.core.djangoapps.course_groups.cohorts
import
(
is_course_cohorted
,
get_cohort_id
,
get_course_cohorts
,
)
from
openedx.core.djangoapps.plugin_api.views
import
EdxFragmentView
...
...
@@ -49,8 +48,10 @@ from django_comment_client.utils import (
strip_none
,
add_courseware_context
,
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
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
)
return
utils
.
JsonResponse
({
'is_commentable_
cohorted'
:
is_commentable_cohort
ed
(
course_key
,
discussion_id
),
'is_commentable_
divided'
:
is_commentable_divid
ed
(
course_key
,
discussion_id
),
'discussion_data'
:
threads
,
'user_info'
:
user_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
is_moderator
=
has_permission
(
request
.
user
,
"see_all_cohorts"
,
course
.
id
)
if
is_commentable_
cohort
ed
(
course
.
id
,
discussion_id
)
and
not
is_moderator
:
user_group_id
=
get_
cohort_id
(
request
.
user
,
course
.
id
)
if
is_commentable_
divid
ed
(
course
.
id
,
discussion_id
)
and
not
is_moderator
:
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
:
return
None
...
...
@@ -423,7 +424,7 @@ def _create_discussion_board_context(request, course_key, discussion_id=None, th
add_courseware_context
(
threads
,
course
,
user
)
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
({
'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
,
'is_moderator'
:
has_permission
(
user
,
"see_all_cohorts"
,
course_key
),
'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
,
'category_map'
:
course_settings
[
"category_map"
],
'course_settings'
:
course_settings
,
'is_commentable_
cohorted'
:
is_commentable_cohort
ed
(
course_key
,
discussion_id
)
'is_commentable_
divided'
:
is_commentable_divid
ed
(
course_key
,
discussion_id
)
})
return
context
...
...
@@ -500,7 +501,7 @@ def user_profile(request, course_key, user_id):
)
.
order_by
(
"name"
)
.
values_list
(
"name"
,
flat
=
True
)
.
distinct
()
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
.
update
({
...
...
@@ -508,7 +509,7 @@ def user_profile(request, course_key, user_id):
'django_user_roles'
:
user_roles
,
'profiled_user'
:
profiled_user
.
to_dict
(),
'threads'
:
threads
,
'user_
cohort'
:
user_cohort
_id
,
'user_
group_id'
:
user_group
_id
,
'annotated_content_info'
:
annotated_content_info
,
'page'
:
query_params
[
'page'
],
'num_pages'
:
query_params
[
'num_pages'
],
...
...
lms/djangoapps/discussion_api/api.py
View file @
31fbde9c
...
...
@@ -43,12 +43,11 @@ from django_comment_common.signals import (
comment_voted
,
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.lib.comment_client.comment
import
Comment
from
lms.lib.comment_client.thread
import
Thread
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
...
...
@@ -113,10 +112,10 @@ def _get_thread_and_context(request, thread_id, retrieve_kwargs=None):
if
(
not
context
[
"is_requester_privileged"
]
and
cc_thread
[
"group_id"
]
and
is_commentable_
cohort
ed
(
course
.
id
,
cc_thread
[
"commentable_id"
])
is_commentable_
divid
ed
(
course
.
id
,
cc_thread
[
"commentable_id"
])
):
requester_
cohort
=
get_cohort_id
(
request
.
user
,
course
.
id
)
if
requester_
cohort
is
not
None
and
cc_thread
[
"group_id"
]
!=
requester_cohort
:
requester_
group_id
=
get_group_id_for_user
(
request
.
user
,
course
.
id
)
if
requester_
group_id
is
not
None
and
cc_thread
[
"group_id"
]
!=
requester_group_id
:
raise
ThreadNotFoundError
(
"Thread not found."
)
return
cc_thread
,
context
except
CommentClientRequestError
:
...
...
@@ -547,7 +546,7 @@ def get_thread_list(
"user_id"
:
unicode
(
request
.
user
.
id
),
"group_id"
:
(
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
,
"per_page"
:
page_size
,
...
...
@@ -831,10 +830,10 @@ def create_thread(request, thread_data):
_check_initializable_thread_fields
(
thread_data
,
context
)
if
(
"group_id"
not
in
thread_data
and
is_commentable_
cohort
ed
(
course_key
,
thread_data
.
get
(
"topic_id"
))
is_commentable_
divid
ed
(
course_key
,
thread_data
.
get
(
"topic_id"
))
):
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
)
actions_form
=
ThreadActionsForm
(
thread_data
)
if
not
(
serializer
.
is_valid
()
and
actions_form
.
is_valid
()):
...
...
lms/djangoapps/django_comment_client/base/views.py
View file @
31fbde9c
...
...
@@ -241,11 +241,11 @@ def create_thread(request, course_id, commentable_id):
thread
=
cc
.
Thread
(
**
params
)
#
Cohort
the thread if required
#
Divide
the thread if required
try
:
group_id
=
get_group_id_for_comments_service
(
request
,
course_key
,
commentable_id
)
except
ValueError
:
return
HttpResponseServerError
(
"Invalid
cohort id
"
)
return
HttpResponseServerError
(
"Invalid
group id for commentable
"
)
if
group_id
is
not
None
:
thread
.
group_id
=
group_id
...
...
lms/djangoapps/django_comment_client/tests/test_utils.py
View file @
31fbde9c
This diff is collapsed.
Click to expand it.
lms/djangoapps/django_comment_client/utils.py
View file @
31fbde9c
...
...
@@ -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"
])]
def
get_discussion_category_map
(
course
,
user
,
cohorted_if_in_lis
t
=
False
,
exclude_unstarted
=
True
):
def
get_discussion_category_map
(
course
,
user
,
divided_only_if_explici
t
=
False
,
exclude_unstarted
=
True
):
"""
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.
...
...
@@ -266,15 +266,15 @@ def get_discussion_category_map(course, user, cohorted_if_in_list=False, exclude
Args:
course: Course for which to get the ids.
user: User to check for access.
cohorted_if_in_list (bool): If True, inline topics are marked is_cohort
ed only if they are
in course_cohort_settings.discussion_topics.
divided_only_if_explicit (bool): If True, inline topics are marked is_divid
ed only if they are
explicitly listed
in course_cohort_settings.discussion_topics.
Example:
>>> example = {
>>> "entries": {
>>> "General": {
>>> "sort_key": "General",
>>> "is_
cohort
ed": True,
>>> "is_
divid
ed": True,
>>> "id": "i4x-edx-eiorguegnru-course-foobarbaz"
>>> }
>>> },
...
...
@@ -292,12 +292,12 @@ def get_discussion_category_map(course, user, cohorted_if_in_list=False, exclude
>>> "entries": {
>>> "Working with Videos": {
>>> "sort_key": None,
>>> "is_
cohort
ed": False,
>>> "is_
divid
ed": False,
>>> "id": "d9f970a42067413cbb633f81cfb12604"
>>> },
>>> "Videos on edX": {
>>> "sort_key": None,
>>> "is_
cohort
ed": False,
>>> "is_
divid
ed": False,
>>> "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
:
node
[
level
][
"start_date"
]
=
category_start_date
always_cohort
_inline_discussions
=
(
# pylint: disable=invalid-name
not
cohorted_if_in_lis
t
and
course_cohort_settings
.
always_cohort_inline_discussions
divide_all
_inline_discussions
=
(
# pylint: disable=invalid-name
not
divided_only_if_explici
t
and
course_cohort_settings
.
always_cohort_inline_discussions
)
dupe_counters
=
defaultdict
(
lambda
:
0
)
# counts the number of times we see each title
for
entry
in
entries
:
is_entry_
cohort
ed
=
(
is_entry_
divid
ed
=
(
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"
],
"sort_key"
:
entry
[
"sort_key"
],
"start_date"
:
entry
[
"start_date"
],
"is_
cohorted"
:
is_entry_cohort
ed
}
"is_
divided"
:
is_entry_divid
ed
}
# 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
...
...
@@ -386,8 +386,9 @@ def get_discussion_category_map(course, user, cohorted_if_in_list=False, exclude
"id"
:
entry
[
"id"
],
"sort_key"
:
entry
.
get
(
"sort_key"
,
topic
),
"start_date"
:
datetime
.
now
(
UTC
()),
"is_cohorted"
:
(
course_cohort_settings
.
is_cohorted
and
entry
[
"id"
]
in
course_cohort_settings
.
cohorted_discussions
)
"is_divided"
:
(
course_cohort_settings
.
is_cohorted
and
entry
[
"id"
]
in
course_cohort_settings
.
cohorted_discussions
)
}
_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:
ValueError if the requested group_id is invalid
"""
if
commentable_id
is
None
or
is_commentable_
cohort
ed
(
course_key
,
commentable_id
):
if
commentable_id
is
None
or
is_commentable_
divid
ed
(
course_key
,
commentable_id
):
if
request
.
method
==
"GET"
:
requested_group_id
=
request
.
GET
.
get
(
'group_id'
)
elif
request
.
method
==
"POST"
:
...
...
@@ -755,7 +756,7 @@ def get_group_id_for_comments_service(request, course_key, commentable_id=None):
raise
ValueError
else
:
# 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
else
:
# 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
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
):
"""
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_
cohort
ed
(
course_key
,
commentable_id
):
def
is_commentable_
divid
ed
(
course_key
,
commentable_id
):
"""
Args:
course_key: CourseKey
commentable_id: string
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:
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
ans
=
True
log
.
debug
(
u"is_commentable_
cohort
ed(
%
s,
%
s) = {
%
s}"
,
course_key
,
commentable_id
,
ans
)
log
.
debug
(
u"is_commentable_
divid
ed(
%
s,
%
s) = {
%
s}"
,
course_key
,
commentable_id
,
ans
)
return
ans
...
...
lms/static/js/groups/views/cohort_discussions_course_wide.js
View file @
31fbde9c
...
...
@@ -41,7 +41,7 @@
return
subCategoryTemplate
({
name
:
name
,
id
:
entry
.
id
,
is_
cohorted
:
entry
.
is_cohort
ed
,
is_
divided
:
entry
.
is_divid
ed
,
type
:
'course-wide'
});
}));
...
...
lms/static/js/groups/views/cohort_discussions_inline.js
View file @
31fbde9c
...
...
@@ -58,7 +58,7 @@
htmlSnippet
=
entryTemplate
({
name
:
name
,
id
:
entry
.
id
,
is_
cohorted
:
entry
.
is_cohort
ed
,
is_
divided
:
entry
.
is_divid
ed
,
type
:
'inline'
});
}
else
{
// subcategory
...
...
lms/static/js/spec/groups/views/cohorts_spec.js
View file @
31fbde9c
...
...
@@ -93,12 +93,12 @@ define(['backbone', 'jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers
entries
:
{
Topic_C_1
:
{
sort_key
:
null
,
is_
cohort
ed
:
true
,
is_
divid
ed
:
true
,
id
:
'Topic_C_1'
},
Topic_C_2
:
{
sort_key
:
null
,
is_
cohort
ed
:
false
,
is_
divid
ed
:
false
,
id
:
'Topic_C_2'
}
}
...
...
@@ -111,12 +111,12 @@ define(['backbone', 'jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers
entries
:
{
Inline_Discussion_1
:
{
sort_key
:
null
,
is_
cohort
ed
:
true
,
is_
divid
ed
:
true
,
id
:
'Inline_Discussion_1'
},
Inline_Discussion_2
:
{
sort_key
:
null
,
is_
cohort
ed
:
allCohorted
||
false
,
is_
divid
ed
:
allCohorted
||
false
,
id
:
'Inline_Discussion_2'
}
}
...
...
@@ -1492,7 +1492,7 @@ define(['backbone', 'jquery', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers
entries
:
{
Topic_C_1
:
{
sort_key
:
null
,
is_
cohort
ed
:
true
,
is_
divid
ed
:
true
,
id
:
'Topic_C_1'
}
}
...
...
lms/templates/discussion/_filter_dropdown.html
View file @
31fbde9c
...
...
@@ -20,7 +20,7 @@ from openedx.core.djangolib.markup import HTML
class=
"forum-nav-browse-menu-item"
data-discussion-id=
'${entries[entry]["id"]}'
id=
'${entries[entry]["id"]}'
data-cohorted=
"${str(entries[entry]['is_
cohort
ed']).lower()}"
data-cohorted=
"${str(entries[entry]['is_
divid
ed']).lower()}"
role=
"option"
>
% if entry:
...
...
lms/templates/instructor/instructor_dashboard_2/cohort-discussions-subcategory.underscore
View file @
31fbde9c
<li class="discussion-subcategory-item">
<div class="subcategory-item">
<label>
<input data-id="<%- id %>" class="check-discussion-subcategory-<%- type %>" type="checkbox" <%- is_
cohort
ed ? 'checked="checked"' : '' %> />
<input data-id="<%- id %>" class="check-discussion-subcategory-<%- type %>" type="checkbox" <%- is_
divid
ed ? 'checked="checked"' : '' %> />
<span class="topic-name"><%- name %></span>
<span class="cohorted-text <%- is_
cohort
ed ? '' : 'hidden'%>">- <%- gettext('Cohorted') %></span>
<span class="cohorted-text <%- is_
divid
ed ? '' : 'hidden'%>">- <%- gettext('Cohorted') %></span>
</label>
</div>
</li>
openedx/core/djangoapps/course_groups/tests/test_views.py
View file @
31fbde9c
...
...
@@ -1255,7 +1255,7 @@ class CourseCohortDiscussionTopicsTestCase(CohortViewsTestCase):
'entries'
:
{
'Topic B'
:
{
'sort_key'
:
'A'
,
'is_
cohort
ed'
:
True
,
'is_
divid
ed'
:
True
,
'id'
:
topic_name_to_id
(
self
.
course
,
"Topic B"
),
'start_date'
:
response
[
'course_wide_discussions'
][
'entries'
][
'Topic B'
][
'start_date'
]
}
...
...
@@ -1269,7 +1269,7 @@ class CourseCohortDiscussionTopicsTestCase(CohortViewsTestCase):
'entries'
:
{
'Discussion'
:
{
'sort_key'
:
None
,
'is_
cohort
ed'
:
True
,
'is_
divid
ed'
:
True
,
'id'
:
topic_name_to_id
(
self
.
course
,
"Topic A"
),
'start_date'
:
start_date
}
...
...
openedx/core/djangoapps/course_groups/views.py
View file @
31fbde9c
...
...
@@ -435,7 +435,7 @@ def cohort_discussion_topics(request, course_key_string):
>>> "entries": {
>>> "General": {
>>> "sort_key": "General",
>>> "is_
cohort
ed": True,
>>> "is_
divid
ed": True,
>>> "id": "i4x-edx-eiorguegnru-course-foobarbaz"
>>> }
>>> }
...
...
@@ -452,12 +452,12 @@ def cohort_discussion_topics(request, course_key_string):
>>> "entries": {
>>> "Working with Videos": {
>>> "sort_key": None,
>>> "is_
cohort
ed": False,
>>> "is_
divid
ed": False,
>>> "id": "d9f970a42067413cbb633f81cfb12604"
>>> },
>>> "Videos on edX": {
>>> "sort_key": None,
>>> "is_
cohort
ed": False,
>>> "is_
divid
ed": False,
>>> "id": "98d8feb5971041a085512ae22b398613"
>>> }
>>> }
...
...
@@ -472,7 +472,7 @@ def cohort_discussion_topics(request, course_key_string):
discussion_topics
=
{}
discussion_category_map
=
get_discussion_category_map
(
course
,
request
.
user
,
cohorted_if_in_lis
t
=
True
,
exclude_unstarted
=
False
course
,
request
.
user
,
divided_only_if_explici
t
=
True
,
exclude_unstarted
=
False
)
# We extract the data for the course wide discussions from the category map.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment