From 8680be38a76891a42d33b28b0000769ec40c91e5 Mon Sep 17 00:00:00 2001 From: Arjun Singh Date: Tue, 4 Sep 2012 09:53:54 -0700 Subject: [PATCH 01/12] Including courseware context in _ template --- lms/templates/discussion/_underscore_templates.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lms/templates/discussion/_underscore_templates.html b/lms/templates/discussion/_underscore_templates.html index 1a5fe6158d..bf76ef7537 100644 --- a/lms/templates/discussion/_underscore_templates.html +++ b/lms/templates/discussion/_underscore_templates.html @@ -13,6 +13,11 @@
${'<%- body %>'}
+ ${'<% if (courseware_location) { %>'} +
+ (this post is about <% courseware_title %>) +
+ ${'<% } %>'}
${'<% if (closed) { %>'} This thread is closed. From 91aec6d38f5bd2d4c4950fa1d3e7c950a65c241d Mon Sep 17 00:00:00 2001 From: Arjun Singh Date: Tue, 4 Sep 2012 09:55:18 -0700 Subject: [PATCH 02/12] Including courseware context in threads for non inline discussion --- lms/djangoapps/django_comment_client/forum/views.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index 4607cc10c5..03ee5a999a 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -71,6 +71,15 @@ def render_discussion(request, course_id, threads, *args, **kwargs): annotated_content_info = reduce(merge_dict, map(infogetter, threads), {}) + if discussion_type != 'inline': + course = get_course_with_access(request.user, course_id, 'load') + + for thread in threads: + courseware_context = get_courseware_context(thread, course) + if courseware_context: + thread['courseware_location'] = courseware_context['courseware_location'] + thread['courseware_title'] = courseware_context['courseware_title'] + context = { 'threads': threads, 'discussion_id': discussion_id, From 0e1b247a7be5559340f4dd79e0a378ebb398549d Mon Sep 17 00:00:00 2001 From: Arjun Singh Date: Tue, 4 Sep 2012 10:38:28 -0700 Subject: [PATCH 03/12] courseware context links in discussion --- .../django_comment_client/forum/views.py | 30 ++++++++++++------- lms/djangoapps/django_comment_client/utils.py | 18 +++++------ lms/static/sass/_discussion.scss | 6 ++++ .../discussion/_underscore_templates.html | 4 +-- 4 files changed, 36 insertions(+), 22 deletions(-) diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index 03ee5a999a..af896f6f80 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -13,7 +13,7 @@ from courseware.access import has_access from urllib import urlencode from operator import methodcaller from django_comment_client.permissions import check_permissions_by_view -from django_comment_client.utils import merge_dict, extract, strip_none, strip_blank +from django_comment_client.utils import merge_dict, extract, strip_none, strip_blank, get_courseware_context import json import django_comment_client.utils as utils @@ -240,15 +240,23 @@ def single_thread(request, course_id, discussion_id, thread_id): category_map = utils.get_discussion_category_map(course) threads, query_params = get_threads(request, course_id) - recent_active_threads = cc.search_recent_active_threads( - course_id, - recursive=False, - query_params={'follower_id': request.user.id}, - ) + course = get_course_with_access(request.user, course_id, 'load') - trending_tags = cc.search_trending_tags( - course_id, - ) + for thread in threads: + courseware_context = get_courseware_context(thread, course) + if courseware_context: + thread['courseware_location'] = courseware_context['courseware_location'] + thread['courseware_title'] = courseware_context['courseware_title'] + + #recent_active_threads = cc.search_recent_active_threads( + # course_id, + # recursive=False, + # query_params={'follower_id': request.user.id}, + #) + + #trending_tags = cc.search_trending_tags( + # course_id, + #) user_info = cc.User.from_django_user(request.user).to_dict() escapedict = {'"': '"'} @@ -265,8 +273,8 @@ def single_thread(request, course_id, discussion_id, thread_id): 'user_info': saxutils.escape(json.dumps(user_info),escapedict), 'annotated_content_info': saxutils.escape(json.dumps(annotated_content_info), escapedict), 'course': course, - 'recent_active_threads': recent_active_threads, - 'trending_tags': trending_tags, + #'recent_active_threads': recent_active_threads, + #'trending_tags': trending_tags, 'course_id': course.id, 'thread_id': thread_id, 'threads': saxutils.escape(json.dumps(threads), escapedict), diff --git a/lms/djangoapps/django_comment_client/utils.py b/lms/djangoapps/django_comment_client/utils.py index 373611380d..b0a570caad 100644 --- a/lms/djangoapps/django_comment_client/utils.py +++ b/lms/djangoapps/django_comment_client/utils.py @@ -124,10 +124,7 @@ def initialize_discussion_info(course): category_map['entries'][topic] = {"id": entry["id"], "sort_key": entry.get("sort_key", topic)} - sort_map_entries(category_map) - #for level in category_map["subcategories"].values(): - # sort_map_entries(level) _DISCUSSIONINFO = {} @@ -135,12 +132,15 @@ def initialize_discussion_info(course): _DISCUSSIONINFO['category_map'] = category_map - # TODO delete me when you've used me - #_DISCUSSIONINFO['categorized']['General'] = [{ - # 'title': 'General', - # 'discussion_id': url_course_id, - # 'category': 'General', - #}] +def get_courseware_context(content, course): + id_map = get_discussion_id_map(course) + id = content['commentable_id'] + content_info = None + if id in id_map: + location = id_map[id]["location"].url() + title = id_map[id]["title"] + content_info = { "courseware_location": location, "courseware_title": title} + return content_info class JsonResponse(HttpResponse): def __init__(self, data=None): diff --git a/lms/static/sass/_discussion.scss b/lms/static/sass/_discussion.scss index 9a0fddbcc8..c6cebe9517 100644 --- a/lms/static/sass/_discussion.scss +++ b/lms/static/sass/_discussion.scss @@ -1056,6 +1056,12 @@ body.discussion { color: #888; } + .post-context{ + margin-top: 20px; + font-size: 12px; + color: #888; + } + p + p { margin-top: 20px; } diff --git a/lms/templates/discussion/_underscore_templates.html b/lms/templates/discussion/_underscore_templates.html index bf76ef7537..a86644de9f 100644 --- a/lms/templates/discussion/_underscore_templates.html +++ b/lms/templates/discussion/_underscore_templates.html @@ -13,9 +13,9 @@
${'<%- body %>'}
- ${'<% if (courseware_location) { %>'} + ${'<% if (obj.courseware_location) { %>'}
- (this post is about <% courseware_title %>) + (this post is about ${'<%- courseware_title %>'})
${'<% } %>'}
From 398e79dc8cf742c1d931e3b42ab2536abf2cdfd2 Mon Sep 17 00:00:00 2001 From: Tom Giannattasio Date: Tue, 4 Sep 2012 13:40:21 -0400 Subject: [PATCH 04/12] simple blank slate view --- lms/static/coffee/src/discussion/discussion_router.coffee | 2 +- lms/static/sass/_discussion.scss | 8 ++++++++ lms/templates/discussion/_underscore_templates.html | 2 +- lms/templates/discussion/index.html | 7 ++++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lms/static/coffee/src/discussion/discussion_router.coffee b/lms/static/coffee/src/discussion/discussion_router.coffee index 4dc599898a..824ef896fb 100644 --- a/lms/static/coffee/src/discussion/discussion_router.coffee +++ b/lms/static/coffee/src/discussion/discussion_router.coffee @@ -15,7 +15,7 @@ class @DiscussionRouter extends Backbone.Router allThreads: -> # TODO: Do something reasonable here - $(".discussion-column").html("No thread selected.") + # $(".discussion-column").html($('#blank-slate-template').html()) setActiveThread: => if @thread diff --git a/lms/static/sass/_discussion.scss b/lms/static/sass/_discussion.scss index a00639792e..3c0ba1fee0 100644 --- a/lms/static/sass/_discussion.scss +++ b/lms/static/sass/_discussion.scss @@ -1038,9 +1038,17 @@ body.discussion { } } + .blank-slate h1 { + margin-top: 195px; + text-align: center; + color: #ccc; + } + + .blank-slate, .discussion-article { position: relative; padding: 40px; + min-height: 468px; h1 { margin-bottom: 10px; diff --git a/lms/templates/discussion/_underscore_templates.html b/lms/templates/discussion/_underscore_templates.html index 1a5fe6158d..3d86c92796 100644 --- a/lms/templates/discussion/_underscore_templates.html +++ b/lms/templates/discussion/_underscore_templates.html @@ -60,4 +60,4 @@ + \ No newline at end of file diff --git a/lms/templates/discussion/index.html b/lms/templates/discussion/index.html index 48ed88fdfb..545b218e54 100644 --- a/lms/templates/discussion/index.html +++ b/lms/templates/discussion/index.html @@ -26,7 +26,12 @@
-
+
+
+

${course.title} discussion forum

+ +
+
From 4a3f85b41723b29651a404db4c4ef88bd677d4e4 Mon Sep 17 00:00:00 2001 From: Tom Giannattasio Date: Tue, 4 Sep 2012 14:05:09 -0400 Subject: [PATCH 05/12] styled closed post notice --- lms/static/sass/_discussion.scss | 10 ++++++++++ lms/templates/discussion/_underscore_templates.html | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lms/static/sass/_discussion.scss b/lms/static/sass/_discussion.scss index 3c0ba1fee0..e970c2d6d0 100644 --- a/lms/static/sass/_discussion.scss +++ b/lms/static/sass/_discussion.scss @@ -1022,6 +1022,16 @@ body.discussion { + .bottom-post-status { + padding: 30px; + font-size: 20px; + font-weight: 700; + color: #ccc; + text-align: center; + } + + + .discussion-column { float: right; diff --git a/lms/templates/discussion/_underscore_templates.html b/lms/templates/discussion/_underscore_templates.html index b005c4567c..3959b336e4 100644 --- a/lms/templates/discussion/_underscore_templates.html +++ b/lms/templates/discussion/_underscore_templates.html @@ -13,9 +13,6 @@
${'<%- body %>'}
-
  • Edit
  • Delete
  • @@ -25,6 +22,9 @@
    +

    Post a response:

      From ffab52be36b221d202f7a90620db88508ebbd2df Mon Sep 17 00:00:00 2001 From: Tom Giannattasio Date: Tue, 4 Sep 2012 14:11:24 -0400 Subject: [PATCH 06/12] fixed typo on profile page and reworded button text --- lms/templates/discussion/_user_profile.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/templates/discussion/_user_profile.html b/lms/templates/discussion/_user_profile.html index 8660d8035f..7bf58a256a 100644 --- a/lms/templates/discussion/_user_profile.html +++ b/lms/templates/discussion/_user_profile.html @@ -15,7 +15,7 @@ % if check_permissions_by_view(user, course.id, content=None, name='update_moderator_status'): % if "Moderator" in role_names: - Revoke Moderator provileges + Revoke Moderator rights % else: Promote to Moderator % endif From 0129be36c92aaaec664cca34e8753b6b0e6ec1b7 Mon Sep 17 00:00:00 2001 From: Matthew Mongeau Date: Tue, 4 Sep 2012 14:26:37 -0400 Subject: [PATCH 07/12] Get highlighting working. --- .../src/discussion/views/discussion_thread_view.coffee | 5 +++++ .../coffee/src/discussion/views/thread_list_item_view.coffee | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/lms/static/coffee/src/discussion/views/discussion_thread_view.coffee b/lms/static/coffee/src/discussion/views/discussion_thread_view.coffee index 3dddb7d901..37483e49d8 100644 --- a/lms/static/coffee/src/discussion/views/discussion_thread_view.coffee +++ b/lms/static/coffee/src/discussion/views/discussion_thread_view.coffee @@ -23,6 +23,8 @@ class @DiscussionThreadView extends DiscussionContentView Markdown.makeWmdEditor @$(".reply-body"), "", DiscussionUtil.urlFor("upload"), (text) -> DiscussionUtil.postMathJaxProcessor(text) @convertMath() @renderResponses() + @highlight @$(".post-body") + @highlight @$("h1") @ renderDogear: -> @@ -151,3 +153,6 @@ class @DiscussionThreadView extends DiscussionContentView type: "POST" success: (response, textStatus) => @model.set('endorsed', not endorsed) + + highlight: (el) -> + el.html(el.html().replace(/<mark>/g, "").replace(/<\/mark>/g, "")) diff --git a/lms/static/coffee/src/discussion/views/thread_list_item_view.coffee b/lms/static/coffee/src/discussion/views/thread_list_item_view.coffee index 5cf2954357..6f04924dc6 100644 --- a/lms/static/coffee/src/discussion/views/thread_list_item_view.coffee +++ b/lms/static/coffee/src/discussion/views/thread_list_item_view.coffee @@ -12,6 +12,7 @@ class @ThreadListItemView extends Backbone.View @$el.html(@template(@model.toJSON())) if window.user.following(@model) @follow() + @highlight @$(".title") @ threadSelected: (event) -> event.preventDefault() @@ -25,3 +26,6 @@ class @ThreadListItemView extends Backbone.View addComment: => @$(".comments-count").html(parseInt(@$(".comments-count").html()) + 1) + + highlight: (el) -> + el.html(el.html().replace(/<mark>/g, "").replace(/<\/mark>/g, "")) From 2380e7fff46be16d9d952ddf034c520e72b2bed9 Mon Sep 17 00:00:00 2001 From: Matthew Mongeau Date: Tue, 4 Sep 2012 14:35:46 -0400 Subject: [PATCH 08/12] Change default text to All. --- lms/templates/discussion/_new_post.html | 2 +- lms/templates/discussion/_thread_list_template.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lms/templates/discussion/_new_post.html b/lms/templates/discussion/_new_post.html index dde21c5a95..8081829ec1 100644 --- a/lms/templates/discussion/_new_post.html +++ b/lms/templates/discussion/_new_post.html @@ -29,7 +29,7 @@
      - Homework / Week 1 + All