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
3fa67c14
Commit
3fa67c14
authored
Jan 31, 2013
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow moderators and students to select cohort on post creation
parent
1fc26de9
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
15 deletions
+61
-15
common/djangoapps/course_groups/cohorts.py
+19
-0
common/static/coffee/src/discussion/views/new_post_view.coffee
+8
-0
lms/djangoapps/django_comment_client/base/views.py
+14
-3
lms/djangoapps/django_comment_client/forum/views.py
+8
-7
lms/templates/discussion/_new_post.html
+12
-5
No files found.
common/djangoapps/course_groups/cohorts.py
View file @
3fa67c14
...
...
@@ -30,6 +30,9 @@ def get_cohort_id(user, course_id):
Given a course id and a user, return the id of the cohort that user is
assigned to in that course. If they don't have a cohort, return None.
"""
print
"
\n\n\n\n\n
*********************************"
print
user
print
course_id
cohort
=
get_cohort
(
user
,
course_id
)
return
None
if
cohort
is
None
else
cohort
.
id
...
...
@@ -65,6 +68,22 @@ def is_commentable_cohorted(course_id, commentable_id):
return
ans
def
get_cohorted_commentables
(
course_id
):
"""
Given a course_id return a list of strings representing cohorted commentables
"""
course
=
courses
.
get_course_by_id
(
course_id
)
if
not
course
.
is_cohorted
:
# this is the easy case :)
ans
=
[]
else
:
ans
=
course
.
top_level_discussion_topic_ids
return
ans
def
get_cohort
(
user
,
course_id
):
"""
Given a django User and a course_id, return the user's cohort in that
...
...
common/static/coffee/src/discussion/views/new_post_view.coffee
View file @
3fa67c14
...
...
@@ -14,6 +14,7 @@ if Backbone?
@
setSelectedTopic
()
DiscussionUtil
.
makeWmdEditor
@
$el
,
$
.
proxy
(
@
$
,
@
),
"new-post-body"
@
$
(
".new-post-tags"
).
tagsInput
DiscussionUtil
.
tagsInputOptions
()
events
:
...
...
@@ -65,6 +66,11 @@ if Backbone?
@
topicText
=
@
getFullTopicName
(
$target
)
@
topicId
=
$target
.
data
(
'discussion_id'
)
@
setSelectedTopic
()
if
$target
.
attr
(
'cohorted'
)
==
"True"
$
(
'.choose-cohort'
).
show
();
else
$
(
'.choose-cohort'
).
hide
();
setSelectedTopic
:
->
@
dropdownButton
.
html
(
@
fitName
(
@
topicText
)
+
' <span class="drop-arrow">▾</span>'
)
...
...
@@ -116,6 +122,7 @@ if Backbone?
title
=
@
$
(
".new-post-title"
).
val
()
body
=
@
$
(
".new-post-body"
).
find
(
".wmd-input"
).
val
()
tags
=
@
$
(
".new-post-tags"
).
val
()
group
=
@
$
(
".new-post-group option:selected"
).
attr
(
"value"
)
anonymous
=
false
||
@
$
(
"input.discussion-anonymous"
).
is
(
":checked"
)
anonymous_to_peers
=
false
||
@
$
(
"input.discussion-anonymous-to-peers"
).
is
(
":checked"
)
...
...
@@ -137,6 +144,7 @@ if Backbone?
anonymous
:
anonymous
anonymous_to_peers
:
anonymous_to_peers
auto_subscribe
:
follow
group_id
:
group
error
:
DiscussionUtil
.
formErrorHandler
(
@
$
(
".new-post-form-errors"
))
success
:
(
response
,
textStatus
)
=>
# TODO: Move this out of the callback, this makes it feel sluggish
...
...
lms/djangoapps/django_comment_client/base/views.py
View file @
3fa67c14
...
...
@@ -90,19 +90,30 @@ def create_thread(request, course_id, commentable_id):
})
user
=
cc
.
User
.
from_django_user
(
request
.
user
)
# Cohort the thread if the commentable is cohorted.
if
is_commentable_cohorted
(
course_id
,
commentable_id
):
user_group_id
=
get_cohort_id
(
request
.
user
,
course_id
)
print
"********************** IS COHORTED"
user_group_id
=
get_cohort_id
(
user
,
course_id
)
print
"********************** USER GOUP ID IS"
print
user_group_id
# TODO (vshnayder): once we have more than just cohorts, we'll want to
# change this to a single get_group_for_user_and_commentable function
# that can do different things depending on the commentable_id
if
cached_has_permission
(
request
.
user
,
"see_all_cohorts"
,
course_id
):
if
cached_has_permission
(
request
.
user
,
"see_all_cohorts"
,
course_id
)
or
True
:
# admins can optionally choose what group to post as
print
"********************** CACHED HAS PERMISSIONS TRUE"
group_id
=
post
.
get
(
'group_id'
,
user_group_id
)
else
:
# regular users always post with their own id.
print
"********************** CACHED HAS PERMISSIONS FALSE"
group_id
=
user_group_id
print
"
\n\n\n\n\n
********************************* group is "
print
group_id
print
"
\n\n\n\n\n
********************************* and post is"
print
post
thread
.
update_attributes
(
group_id
=
group_id
)
thread
.
save
()
...
...
lms/djangoapps/django_comment_client/forum/views.py
View file @
3fa67c14
...
...
@@ -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
from
course_groups.cohorts
import
get_cohort_id
,
get_course_cohorts
,
get_cohorted_commentables
,
is_course_cohorted
from
courseware.access
import
has_access
from
urllib
import
urlencode
...
...
@@ -128,7 +128,8 @@ def forum_form_discussion(request, course_id):
log
.
error
(
"Error loading forum discussion threads:
%
s"
%
str
(
err
))
raise
Http404
user_info
=
cc
.
User
.
from_django_user
(
request
.
user
)
.
to_dict
()
user
=
cc
.
User
.
from_django_user
(
request
.
user
)
user_info
=
user
.
to_dict
()
annotated_content_info
=
utils
.
get_metadata_for_threads
(
course_id
,
threads
,
request
.
user
,
user_info
)
...
...
@@ -167,13 +168,13 @@ def forum_form_discussion(request, course_id):
'course_id'
:
course
.
id
,
'category_map'
:
category_map
,
'roles'
:
saxutils
.
escape
(
json
.
dumps
(
utils
.
get_role_ids
(
course_id
)),
escapedict
),
#'is_moderator': cached_has_permission(request.user, "see_all_cohorts", course_id),
'is_moderator'
:
True
,
'cohorts'
:
get_course_cohorts
(
course_id
)
'is_moderator'
:
cached_has_permission
(
request
.
user
,
"see_all_cohorts"
,
course_id
),
'cohorts'
:
get_course_cohorts
(
course_id
),
'cohort'
:
get_cohort_id
(
user
,
course_id
),
'cohorted_commentables'
:
get_cohorted_commentables
(
course_id
),
'is_course_cohorted'
:
is_course_cohorted
(
course_id
)
}
# print "start rendering.."
print
"
\n\n\n\n\n\n
*************************************"
print
context
return
render_to_response
(
'discussion/index.html'
,
context
)
@login_required
...
...
lms/templates/discussion/_new_post.html
View file @
3fa67c14
...
...
@@ -9,7 +9,7 @@
</
%
def>
<
%
def
name=
"render_entry(entries, entry)"
>
<li><a
href=
"#"
class=
"topic"
data-discussion_id=
"${entries[entry]['id']}"
>
${entry}
</a></li>
<li><a
href=
"#"
class=
"topic"
data-discussion_id=
"${entries[entry]['id']}"
cohorted =
"${entries[entry]['id'] in cohorted_commentables}"
>
${entry}
</a></li>
</
%
def>
<
%
def
name=
"render_category(categories, category)"
>
...
...
@@ -21,6 +21,9 @@
</li>
</
%
def>
<article
class=
"new-post-article"
>
<div
class=
"inner-wrapper"
>
<form
class=
"new-post-form"
>
...
...
@@ -45,14 +48,18 @@
%elif course.metadata.get("allow_anonymous_to_peers", False):
<input
type=
"checkbox"
name=
"anonymous_to_peers"
class=
"discussion-anonymous-to-peers"
id=
"new-post-anonymous-to-peers"
><label
for=
"new-post-anonymous-to-peers"
>
post anonymously to classmates
</label>
%endif
%if is_
moderator
:
<div
class=
"form-group-label"
>
%if is_
course_cohorted
:
<div
class=
"form-group-label
choose-cohort
"
>
Make visible to:
<select
class=
"group-filter-select"
>
<select
class=
"group-filter-select
new-post-group"
name =
"group_id
"
>
<option
>
All Groups
</option>
%if is_moderator:
%for c in cohorts:
<option
value=
"g1"
>
Group 1
</option>
<option
value=
"${c.id}"
>
${c.name}
</option>
%endfor
%else:
<option
value=
"${cohort}"
>
My Cohort
</option>
%endif
</select>
</div>
...
...
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