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
d5b70d7b
Commit
d5b70d7b
authored
Feb 05, 2013
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inline cohorting working
parent
837f54c0
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
56 additions
and
32 deletions
+56
-32
common/lib/capa/capa/tests/test_files/js/test_problem_display.js
+1
-1
common/lib/capa/capa/tests/test_files/js/test_problem_generator.js
+1
-1
common/lib/capa/capa/tests/test_files/js/test_problem_grader.js
+1
-1
common/lib/capa/capa/tests/test_files/js/xproblem.js
+1
-1
common/static/coffee/src/discussion/discussion_module_view.coffee
+8
-4
common/static/coffee/src/discussion/views/new_post_inline_vew.coffee
+2
-0
lms/djangoapps/django_comment_client/forum/views.py
+34
-17
lms/djangoapps/django_comment_client/utils.py
+1
-1
lms/templates/discussion/_new_post.html
+3
-3
lms/templates/discussion/_single_thread.html
+1
-0
lms/templates/discussion/_underscore_templates.html
+1
-1
lms/templates/discussion/mustache/_content.mustache
+1
-0
lms/templates/discussion/mustache/_inline_discussion.mustache
+1
-2
No files found.
common/lib/capa/capa/tests/test_files/js/test_problem_display.js
View file @
d5b70d7b
// Generated by CoffeeScript 1.
3.3
// Generated by CoffeeScript 1.
4.0
(
function
()
{
var
MinimaxProblemDisplay
,
root
,
__hasProp
=
{}.
hasOwnProperty
,
...
...
common/lib/capa/capa/tests/test_files/js/test_problem_generator.js
View file @
d5b70d7b
// Generated by CoffeeScript 1.
3.3
// Generated by CoffeeScript 1.
4.0
(
function
()
{
var
TestProblemGenerator
,
root
,
__hasProp
=
{}.
hasOwnProperty
,
...
...
common/lib/capa/capa/tests/test_files/js/test_problem_grader.js
View file @
d5b70d7b
// Generated by CoffeeScript 1.
3.3
// Generated by CoffeeScript 1.
4.0
(
function
()
{
var
TestProblemGrader
,
root
,
__hasProp
=
{}.
hasOwnProperty
,
...
...
common/lib/capa/capa/tests/test_files/js/xproblem.js
View file @
d5b70d7b
// Generated by CoffeeScript 1.
3.3
// Generated by CoffeeScript 1.
4.0
(
function
()
{
var
XProblemDisplay
,
XProblemGenerator
,
XProblemGrader
,
root
;
...
...
common/static/coffee/src/discussion/discussion_module_view.coffee
View file @
d5b70d7b
...
...
@@ -73,10 +73,14 @@ if Backbone?
# $elem.html("Hide Discussion")
@
discussion
=
new
Discussion
()
@
discussion
.
reset
(
response
.
discussion_data
,
{
silent
:
false
})
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
})
#rather than have two different templates to get around (or take advantage of?)
#mustache's logic free templates, we added a 'group string' to each thread for inline
#discussions for the use case where a commentable is cohorted, but a global
#thread is posted by a TA
$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
...
...
common/static/coffee/src/discussion/views/new_post_inline_vew.coffee
View file @
d5b70d7b
...
...
@@ -25,6 +25,7 @@ if Backbone?
event
.
preventDefault
()
title
=
@
$
(
".new-post-title"
).
val
()
body
=
@
$
(
".new-post-body"
).
find
(
".wmd-input"
).
val
()
group
=
@
$
(
".new-post-group option:selected"
).
attr
(
"value"
)
# TODO tags: commenting out til we know what to do with them
#tags = @$(".new-post-tags").val()
...
...
@@ -45,6 +46,7 @@ if Backbone?
data
:
title
:
title
body
:
body
group_id
:
group
# TODO tags: commenting out til we know what to do with them
#tags: tags
...
...
lms/djangoapps/django_comment_client/forum/views.py
View file @
d5b70d7b
...
...
@@ -75,9 +75,12 @@ def get_threads(request, course_id, discussion_id=None, per_page=THREADS_PER_PAG
#now add the group name if the thread has a group id
for
thread
in
threads
:
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
thread
.
get
(
'group_id'
):
thread
[
'group_name'
]
=
get_cohort_by_id
(
course_id
,
thread
.
get
(
'group_id'
))
.
name
thread
[
'group_string'
]
=
"This post visible only to Group ${group_name}."
else
:
thread
[
'group_name'
]
=
""
thread
[
'group_string'
]
=
"This post visible to everyone."
query_params
[
'page'
]
=
page
query_params
[
'num_pages'
]
=
num_pages
...
...
@@ -85,6 +88,7 @@ def get_threads(request, course_id, discussion_id=None, per_page=THREADS_PER_PAG
return
threads
,
query_params
def
inline_discussion
(
request
,
course_id
,
discussion_id
):
"""
Renders JSON for DiscussionModules
"""
...
...
@@ -107,24 +111,26 @@ 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
)
cohorts_list
=
list
()
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
):
if
cached_has_permission
(
request
.
user
,
"see_all_cohorts"
,
course_id
)
or
True
:
cohorts
=
get_course_cohorts
(
course_id
)
for
c
in
cohorts
:
cohorts_dict
[
c
.
name
]
=
c
.
id
cohorts_list
.
append
({
'name'
:
c
.
name
,
'id'
:
c
.
id
})
else
:
#otherwise, just make a dictionary of two
user_cohort
=
get_cohort_id
(
user
,
course_id
)
cohorts_
dict
[
"All Groups"
]
=
None
cohorts_
list
.
append
({
'name'
:
'All Groups'
,
'id'
:
None
})
if
user_cohort
:
cohorts_
dict
[
user_cohort
.
name
]
=
user_cohort
.
id
else
:
cohorts_dic
t
=
None
cohorts_
list
.
append
({
'name'
:
user_cohort
.
name
,
'id'
:
user_cohort
.
id
})
else
:
cohorts_lis
t
=
None
return
utils
.
JsonResponse
({
...
...
@@ -136,12 +142,13 @@ 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_
dic
t
,
'cohorts'
:
cohorts_
lis
t
,
'is_cohorted'
:
is_cohorted
})
@login_required
def
forum_form_discussion
(
request
,
course_id
):
"""
Renders the main Discussion page, potentially filtered by a search query
"""
...
...
@@ -181,8 +188,10 @@ def forum_form_discussion(request, course_id):
#trending_tags = cc.search_trending_tags(
# course_id,
#)
cohorts
=
get_course_cohorts
(
course_id
)
cohorted_commentables
=
get_cohorted_commentables
(
course_id
)
user_cohort_id
=
get_cohort_id
(
request
.
user
,
course_id
)
context
=
{
'csrf'
:
csrf
(
request
)[
'csrf_token'
],
...
...
@@ -199,8 +208,8 @@ def forum_form_discussion(request, course_id):
'roles'
:
saxutils
.
escape
(
json
.
dumps
(
utils
.
get_role_ids
(
course_id
)),
escapedict
),
'is_moderator'
:
cached_has_permission
(
request
.
user
,
"see_all_cohorts"
,
course_id
),
'cohorts'
:
cohorts
,
'user_cohort'
:
get_cohort_id
(
user
,
course_id
)
,
'cohorted_commentables'
:
get_cohorted_commentables
(
course_id
)
,
'user_cohort'
:
user_cohort_id
,
'cohorted_commentables'
:
cohorted_commentables
,
'is_course_cohorted'
:
is_course_cohorted
(
course_id
)
}
# print "start rendering.."
...
...
@@ -208,7 +217,6 @@ def forum_form_discussion(request, course_id):
@login_required
def
single_thread
(
request
,
course_id
,
discussion_id
,
thread_id
):
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
cc_user
=
cc
.
User
.
from_django_user
(
request
.
user
)
user_info
=
cc_user
.
to_dict
()
...
...
@@ -222,7 +230,7 @@ def single_thread(request, course_id, discussion_id, thread_id):
if
request
.
is_ajax
():
courseware_context
=
get_courseware_context
(
thread
,
course
)
annotated_content_info
=
utils
.
get_annotated_content_infos
(
course_id
,
thread
,
request
.
user
,
user_info
=
user_info
)
context
=
{
'thread'
:
thread
.
to_dict
(),
'course_id'
:
course_id
}
# TODO: Remove completely or switch back to server side rendering
...
...
@@ -268,6 +276,10 @@ def single_thread(request, course_id, discussion_id, thread_id):
#)
annotated_content_info
=
utils
.
get_metadata_for_threads
(
course_id
,
threads
,
request
.
user
,
user_info
)
cohorts
=
get_course_cohorts
(
course_id
)
cohorted_commentables
=
get_cohorted_commentables
(
course_id
)
user_cohort
=
get_cohort_id
(
request
.
user
,
course_id
)
context
=
{
'discussion_id'
:
discussion_id
,
...
...
@@ -284,6 +296,11 @@ def single_thread(request, course_id, discussion_id, thread_id):
'category_map'
:
category_map
,
'roles'
:
saxutils
.
escape
(
json
.
dumps
(
utils
.
get_role_ids
(
course_id
)),
escapedict
),
'thread_pages'
:
query_params
[
'num_pages'
],
'is_course_cohorted'
:
is_course_cohorted
(
course_id
),
'is_moderator'
:
cached_has_permission
(
request
.
user
,
"see_all_cohorts"
,
course_id
)
or
True
,
'cohorts'
:
cohorts
,
'user_cohort'
:
get_cohort_id
(
request
.
user
,
course_id
),
'cohorted_commentables'
:
cohorted_commentables
}
return
render_to_response
(
'discussion/single_thread.html'
,
context
)
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
d5b70d7b
...
...
@@ -374,7 +374,7 @@ def safe_content(content):
'updated_at'
,
'depth'
,
'type'
,
'commentable_id'
,
'comments_count'
,
'at_position_list'
,
'children'
,
'highlighted_title'
,
'highlighted_body'
,
'courseware_title'
,
'courseware_url'
,
'tags'
,
'unread_comments_count'
,
'read'
,
'group_id'
,
'group_name'
'read'
,
'group_id'
,
'group_name'
,
'group_string'
]
if
(
content
.
get
(
'anonymous'
)
is
False
)
and
(
content
.
get
(
'anonymous_to_peers'
)
is
False
):
...
...
lms/templates/discussion/_new_post.html
View file @
d5b70d7b
...
...
@@ -22,8 +22,6 @@
</
%
def>
<article
class=
"new-post-article"
>
<div
class=
"inner-wrapper"
>
<form
class=
"new-post-form"
>
...
...
@@ -58,7 +56,9 @@
<option
value=
"${c.id}"
>
${c.name}
</option>
%endfor
%else:
<option
value=
"${user_cohort}"
>
My Cohort
</option>
%if user_cohort:
<option
value=
"${user_cohort}"
>
My Cohort
</option>
%endif
%endif
</select>
...
...
lms/templates/discussion/_single_thread.html
View file @
d5b70d7b
...
...
@@ -4,6 +4,7 @@
<article
class=
"discussion-article"
data-id=
"${discussion_id| h}"
>
<a
href=
"#"
class=
"dogear"
></a>
<div
class=
"discussion-post"
>
<header>
%if thread['group_id']
<div
class=
"group-visibility-label"
>
This post visible only to group ${cohort_dictionary[thread['group_id']]}.
</div>
...
...
lms/templates/discussion/_underscore_templates.html
View file @
d5b70d7b
...
...
@@ -28,7 +28,7 @@
<
header
>
$
{
"<% if (obj.group_id) { %>"
}
<
div
class
=
"group-visibility-label"
>
This
post
visible
only
to
Group
$
{
"<%- obj.group_name
%>"
}.
<
/div
>
<
div
class
=
"group-visibility-label"
>
$
{
"<%- obj.group_string
%>"
}.
<
/div
>
$
{
"<% } %>"
}
<
a
href
=
"#"
class
=
"vote-btn discussion-vote discussion-vote-up"
data
-
role
=
"discussion-vote"
data
-
tooltip
=
"vote"
><
span
class
=
"plus-icon"
>+<
/span> <span class='votes-count-number'>${'<%- votes
[
"up_count"
]
%>'}</
span
><
/a
>
...
...
lms/templates/discussion/mustache/_content.mustache
View file @
d5b70d7b
<div
class=
"discussion-content local
{{#
content
.
roles
}}
role-
{{
name
}}{{/
content
.
roles
}}
"
>
CONTENT MUSTACHE
<div
class=
"discussion-content-wrapper"
>
<div
class=
"discussion-votes"
>
<a
class=
"discussion-vote discussion-vote-up"
href=
"javascript:void(0)"
value=
"up"
>
▲
</a>
...
...
lms/templates/discussion/mustache/_inline_discussion.mustache
View file @
d5b70d7b
<section
class=
"discussion"
data-discussion-id=
"
{{
discussionId
}}
"
>
<article
class=
"new-post-article"
>
<span
class=
"topic"
data-discussion-id=
"
{{
discussionId
}}
"
/>
<div
class=
"inner-wrapper"
>
...
...
@@ -36,6 +34,7 @@
<section
class=
"threads"
>
{{#
threads
}}
<div
class=
"group-visibility-label"
>
{{
group_string
}}
</div>
<article
class=
"discussion-thread"
id=
"thread_
{{
id
}}
"
>
</article>
{{/
threads
}}
...
...
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