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
837f54c0
Commit
837f54c0
authored
Feb 04, 2013
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inline cohorting almost done
parent
a8a99759
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
6 deletions
+30
-6
common/static/coffee/src/discussion/discussion_module_view.coffee
+4
-1
lms/djangoapps/django_comment_client/forum/views.py
+26
-5
No files found.
common/static/coffee/src/discussion/discussion_module_view.coffee
View file @
837f54c0
...
...
@@ -73,7 +73,10 @@ if Backbone?
# $elem.html("Hide Discussion")
@
discussion
=
new
Discussion
()
@
discussion
.
reset
(
response
.
discussion_data
,
{
silent
:
false
})
$discussion
=
$
(
Mustache
.
render
$
(
"script#_inline_discussion"
).
html
(),
{
'threads'
:
response
.
discussion_data
,
'discussionId'
:
discussionId
,
'allow_anonymous_to_peers'
:
allow_anonymous_to_peers
,
'allow_anonymous'
:
allow_anonymous
})
if
response
.
is_cohorted
$discussion
=
$
(
Mustache
.
render
$
(
"script#_inline_discussion_cohorted"
).
html
(),
{
'threads'
:
response
.
discussion_data
,
'discussionId'
:
discussionId
,
'allow_anonymous_to_peers'
:
allow_anonymous_to_peers
,
'allow_anonymous'
:
allow_anonymous
})
else
$discussion
=
$
(
Mustache
.
render
$
(
"script#_inline_discussion"
).
html
(),
{
'threads'
:
response
.
discussion_data
,
'discussionId'
:
discussionId
,
'allow_anonymous_to_peers'
:
allow_anonymous_to_peers
,
'allow_anonymous'
:
allow_anonymous
})
if
@
$
(
'section.discussion'
).
length
@
$
(
'section.discussion'
).
replaceWith
(
$discussion
)
else
...
...
lms/djangoapps/django_comment_client/forum/views.py
View file @
837f54c0
...
...
@@ -11,7 +11,7 @@ from django.contrib.auth.models import User
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
from
courseware.courses
import
get_course_with_access
from
course_groups.cohorts
import
get_cohort_id
,
get_course_cohorts
,
get_cohorted_commentables
,
is_course_cohorted
,
get_cohort_by_id
from
course_groups.cohorts
import
*
from
courseware.access
import
has_access
from
urllib
import
urlencode
...
...
@@ -93,7 +93,8 @@ def inline_discussion(request, course_id, discussion_id):
try
:
threads
,
query_params
=
get_threads
(
request
,
course_id
,
discussion_id
,
per_page
=
INLINE_THREADS_PER_PAGE
)
user_info
=
cc
.
User
.
from_django_user
(
request
.
user
)
.
to_dict
()
user
=
cc
.
User
.
from_django_user
(
request
.
user
)
user_info
=
user
.
to_dict
()
except
(
cc
.
utils
.
CommentClientError
,
cc
.
utils
.
CommentClientUnknownError
)
as
err
:
# TODO (vshnayder): since none of this code seems to be aware of the fact that
# sometimes things go wrong, I suspect that the js client is also not
...
...
@@ -105,7 +106,27 @@ def inline_discussion(request, course_id, discussion_id):
allow_anonymous
=
course
.
metadata
.
get
(
"allow_anonymous"
,
True
)
allow_anonymous_to_peers
=
course
.
metadata
.
get
(
"allow_anonymous_to_peers"
,
False
)
#if we can't get the user's cohort, default to visible to all, treat as if the discussion is not cohoroted
is_cohorted
=
is_course_cohorted
(
course_id
)
and
is_commentable_cohorted
(
course_id
,
discussion_id
)
if
is_cohorted
:
cohorts_dict
=
dict
()
#if you're a mod, send all cohorts and let you pick
if
cached_has_permission
(
request
.
user
,
"see_all_cohorts"
,
course_id
):
cohorts
=
get_course_cohorts
(
course_id
)
for
c
in
cohorts
:
cohorts_dict
[
c
.
name
]
=
c
.
id
else
:
#otherwise, just make a dictionary of two
user_cohort
=
get_cohort_id
(
user
,
course_id
)
cohorts_dict
[
"All Groups"
]
=
None
if
user_cohort
:
cohorts_dict
[
user_cohort
.
name
]
=
user_cohort
.
id
else
:
cohorts_dict
=
None
return
utils
.
JsonResponse
({
'discussion_data'
:
map
(
utils
.
safe_content
,
threads
),
'user_info'
:
user_info
,
...
...
@@ -115,6 +136,8 @@ def inline_discussion(request, course_id, discussion_id):
'roles'
:
utils
.
get_role_ids
(
course_id
),
'allow_anonymous_to_peers'
:
allow_anonymous_to_peers
,
'allow_anonymous'
:
allow_anonymous
,
'cohorts'
:
cohorts_dict
,
'is_cohorted'
:
is_cohorted
})
@login_required
...
...
@@ -139,8 +162,6 @@ def forum_form_discussion(request, course_id):
for
thread
in
threads
:
courseware_context
=
get_courseware_context
(
thread
,
course
)
if
thread
.
get
(
'group_id'
)
and
not
thread
.
get
(
'group_name'
):
thread
[
'group_name'
]
=
get_cohort_by_id
(
course_id
,
thread
.
get
(
'group_id'
))
.
name
if
courseware_context
:
thread
.
update
(
courseware_context
)
if
request
.
is_ajax
():
...
...
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