diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index cf61f2e101..02b476750f 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -184,7 +184,7 @@ def get_module(user, request, location, student_module_cache, position=None): ) if settings.MITX_FEATURES.get('DISPLAY_HISTOGRAMS_TO_STAFF') and user.is_staff: - module.get_html = add_histogram(module.get_html) + module.get_html = add_histogram(module.get_html, module) # If StudentModule for this instance wasn't already in the database, # and this isn't a guest user, create it. diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index ef5a75e360..ecb7e7fd6f 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -23,8 +23,11 @@ from django.views.decorators.cache import cache_control from module_render import toc_for_course, get_module, get_section from models import StudentModuleCache from student.models import UserProfile +<<<<<<< HEAD from multicourse import multicourse_settings +======= +>>>>>>> 38dd8f18984df3ab14f5715891af7f984c7f14a7 from django_comment_client.utils import get_discussion_title from xmodule.modulestore import Location diff --git a/lms/djangoapps/django_comment_client/base/views.py b/lms/djangoapps/django_comment_client/base/views.py index f995829b79..ef86fb3b19 100644 --- a/lms/djangoapps/django_comment_client/base/views.py +++ b/lms/djangoapps/django_comment_client/base/views.py @@ -38,7 +38,12 @@ def comment_author_only(fn): return verified_fn def instructor_only(fn): #TODO add instructor verification - return fn + def verified_fn(request, *args, **kwargs): + if not request.user.is_staff: + return JsonError("unauthorized") + else: + return fn(request, *args, **kwargs) + return verified_fn def extract(dic, keys): return {k: dic[k] for k in keys} @@ -70,7 +75,6 @@ def create_comment(request, course_id, thread_id): attributes = extract(request.POST, ['body']) attributes['user_id'] = request.user.id attributes['course_id'] = course_id - print request.POST if request.POST.get('anonymous', 'false').lower() == 'true': attributes['anonymous'] = True if request.POST.get('autowatch', 'false').lower() == 'true': diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index b980db3963..16bee537d3 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -27,9 +27,9 @@ def render_accordion(request, course, discussion_id): 'csrf': csrf(request)['csrf_token'], } - return render_to_string('discussion/accordion.html', context) + return render_to_string('discussion/_accordion.html', context) -def render_discussion(request, course_id, threads, discussion_id=None, with_search_bar=True, search_text=''): +def render_discussion(request, course_id, threads, discussion_id=None, with_search_bar=True, search_text='', template='discussion/_inline.html'): context = { 'threads': threads, 'discussion_id': discussion_id, @@ -38,12 +38,19 @@ def render_discussion(request, course_id, threads, discussion_id=None, with_sear 'user_info': comment_client.get_user_info(request.user.id, raw=True), 'tags': comment_client.get_threads_tags(raw=True), 'course_id': course_id, + 'request': request, } - return render_to_string('discussion/inline.html', context) + return render_to_string(template, context) + +def render_inline_discussion(*args, **kwargs): + return render_discussion(template='discussion/_inline.html', *args, **kwargs) + +def render_forum_discussion(*args, **kwargs): + return render_discussion(template='discussion/_forum.html', *args, **kwargs) def inline_discussion(request, course_id, discussion_id): threads = comment_client.get_threads(discussion_id, recursive=False) - html = render_discussion(request, course_id, threads, discussion_id=discussion_id) + html = render_inline_discussion(request, course_id, threads, discussion_id=discussion_id) return HttpResponse(html, content_type="text/plain") def render_search_bar(request, course_id, discussion_id=None, text=''): @@ -54,7 +61,7 @@ def render_search_bar(request, course_id, discussion_id=None, text=''): 'text': text, 'course_id': course_id, } - return render_to_string('discussion/search_bar.html', context) + return render_to_string('discussion/_search_bar.html', context) def forum_form_discussion(request, course_id, discussion_id): @@ -70,7 +77,7 @@ def forum_form_discussion(request, course_id, discussion_id): context = { 'csrf': csrf(request)['csrf_token'], 'course': course, - 'content': render_discussion(request, course_id, threads, discussion_id=discussion_id, search_text=search_text), + 'content': render_forum_discussion(request, course_id, threads, discussion_id=discussion_id, search_text=search_text), 'accordion': render_accordion(request, course, discussion_id), } @@ -97,8 +104,9 @@ def render_single_thread(request, course_id, thread_id): 'annotated_content_info': json.dumps(get_annotated_content_info(thread=thread, user_id=request.user.id)), 'tags': comment_client.get_threads_tags(raw=True), 'course_id': course_id, + 'request': request, } - return render_to_string('discussion/single_thread.html', context) + return render_to_string('discussion/_single_thread.html', context) def single_thread(request, course_id, discussion_id, thread_id): @@ -131,7 +139,7 @@ def search(request, course_id): context = { 'csrf': csrf(request)['csrf_token'], 'init': '', - 'content': render_discussion(request, course_id, threads, search_text=text), + 'content': render_forum_discussion(request, course_id, threads, search_text=text), 'accordion': '', 'course': course, } diff --git a/lms/static/coffee/src/discussion.coffee b/lms/static/coffee/src/discussion.coffee index f7cece2e6a..cbb31fa3af 100644 --- a/lms/static/coffee/src/discussion.coffee +++ b/lms/static/coffee/src/discussion.coffee @@ -373,6 +373,15 @@ Discussion = Discussion.handleAnchorAndReload(response) , 'json' + handleEndorse = (elem) -> + url = Discussion.urlFor('endorse_comment', id) + endorsed = $local(".discussion-endorse").is(":checked") + $.post url, {endorsed: endorsed}, (response, textStatus) -> + # TODO error handling + Discussion.handleAnchorAndReload(response) + , 'json' + + $local(".discussion-reply").click -> handleReply(this) @@ -385,6 +394,9 @@ Discussion = $local(".discussion-vote-down").click -> handleVote(this, "down") + $local(".discussion-endorse").click -> + handleEndorse(this) + $local(".discussion-edit").click -> if $content.hasClass("thread") handleEditThread(this) diff --git a/lms/static/sass/_discussion.scss b/lms/static/sass/_discussion.scss index 4e2765228f..f7dae9bc89 100644 --- a/lms/static/sass/_discussion.scss +++ b/lms/static/sass/_discussion.scss @@ -267,6 +267,12 @@ $discussion_input_width: 90%; display: block; color: black; } + + &.endorsed { + > .discussion-content { + background-color: lightyellow; + } + } } } } diff --git a/lms/templates/discussion/accordion.html b/lms/templates/discussion/_accordion.html similarity index 100% rename from lms/templates/discussion/accordion.html rename to lms/templates/discussion/_accordion.html diff --git a/lms/templates/discussion/_show_discussion.html b/lms/templates/discussion/_discussion_module.html similarity index 100% rename from lms/templates/discussion/_show_discussion.html rename to lms/templates/discussion/_discussion_module.html diff --git a/lms/templates/discussion/inline.html b/lms/templates/discussion/_forum.html similarity index 93% rename from lms/templates/discussion/inline.html rename to lms/templates/discussion/_forum.html index 074c956cbd..967ebb9994 100644 --- a/lms/templates/discussion/inline.html +++ b/lms/templates/discussion/_forum.html @@ -1,4 +1,4 @@ -<%namespace name="renderer" file="thread.html"/> +<%namespace name="renderer" file="_thread.html"/>
diff --git a/lms/templates/discussion/_inline.html b/lms/templates/discussion/_inline.html new file mode 100644 index 0000000000..967ebb9994 --- /dev/null +++ b/lms/templates/discussion/_inline.html @@ -0,0 +1,25 @@ +<%namespace name="renderer" file="_thread.html"/> + +
+
+ + ${search_bar} +
New Post
+
+ % for thread in threads: + ${renderer.render_thread(course_id, thread, edit_thread=False, show_comments=False)} + % endfor +
+ +<%! + def escape_quotes(text): + return text.replace('\"', '\\\"').replace("\'", "\\\'") +%> + + diff --git a/lms/templates/discussion/search_bar.html b/lms/templates/discussion/_search_bar.html similarity index 100% rename from lms/templates/discussion/search_bar.html rename to lms/templates/discussion/_search_bar.html diff --git a/lms/templates/discussion/single_thread.html b/lms/templates/discussion/_single_thread.html similarity index 92% rename from lms/templates/discussion/single_thread.html rename to lms/templates/discussion/_single_thread.html index 7157bd2296..c66b39bfac 100644 --- a/lms/templates/discussion/single_thread.html +++ b/lms/templates/discussion/_single_thread.html @@ -1,4 +1,4 @@ -<%namespace name="renderer" file="thread.html"/> +<%namespace name="renderer" file="_thread.html"/>
Discussion diff --git a/lms/templates/discussion/thread.html b/lms/templates/discussion/_thread.html similarity index 85% rename from lms/templates/discussion/thread.html rename to lms/templates/discussion/_thread.html index e49d555d59..5896927b44 100644 --- a/lms/templates/discussion/thread.html +++ b/lms/templates/discussion/_thread.html @@ -15,7 +15,11 @@ <%def name="render_comments(comments)">
% for comment in comments: + % if comment['endorsed']: +
+ % else:
+ % endif ${render_content(comment, "comment")}
${render_comments(comment['children'])} @@ -76,6 +80,14 @@ % if type == "thread" and kwargs['edit_thread'] or type == "comment": ${render_link("discussion-link discussion-reply", "Reply")} ${render_link("discussion-link discussion-edit", "Edit")} + % if type == "comment" and request.user.is_staff: + % if content['endorsed']: + + % else: + + % endif + + % endif % endif
diff --git a/lms/templates/profile.html b/lms/templates/profile.html index 6c5a0a5ccf..93731fcd8d 100644 --- a/lms/templates/profile.html +++ b/lms/templates/profile.html @@ -137,8 +137,9 @@ $(function() { total = section['section_total'].possible percentageString = "{0:.0%}".format( float(earned)/total) if earned > 0 and total > 0 else "" %> +

->>>>>>> 7f2f47597fd50acbab49be5173b76b026ff4378d + ${ section['section'] } ${"({0:.3n}/{1:.3n}) {2}".format( float(earned), float(total), percentageString )}

${section['format']} %if 'due' in section and section['due']!="":