From 07eead234939ea433a8c05cdb6f9523970469059 Mon Sep 17 00:00:00 2001 From: Bridger Maxwell Date: Thu, 23 Aug 2012 10:11:31 -0400 Subject: [PATCH 1/6] Updated django-wiki to better handle relative wiki links. --- lms/envs/common.py | 2 ++ repo-requirements.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lms/envs/common.py b/lms/envs/common.py index d2397c166d..49921a8626 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -322,6 +322,8 @@ WIKI_CAN_CHANGE_PERMISSIONS = lambda article, user: user.is_staff or user.is_sup WIKI_CAN_ASSIGN = lambda article, user: user.is_staff or user.is_superuser WIKI_USE_BOOTSTRAP_SELECT_WIDGET = False +WIKI_LINK_LIVE_LOOKUPS = False +WIKI_LINK_DEFAULT_LEVEL = 2 ################################# Jasmine ################################### JASMINE_TEST_DIRECTORY = PROJECT_ROOT + '/static/coffee' diff --git a/repo-requirements.txt b/repo-requirements.txt index b93dc2837f..fc6ae1b301 100644 --- a/repo-requirements.txt +++ b/repo-requirements.txt @@ -1,6 +1,6 @@ -e git://github.com/MITx/django-staticfiles.git@6d2504e5c8#egg=django-staticfiles -e git://github.com/MITx/django-pipeline.git#egg=django-pipeline --e git://github.com/benjaoming/django-wiki.git@533c7fc#egg=django-wiki +-e git://github.com/benjaoming/django-wiki.git@7e42bce#egg=django-wiki -e git://github.com/dementrock/pystache_custom.git@776973740bdaad83a3b029f96e415a7d1e8bec2f#egg=pystache_custom-dev -e common/lib/capa -e common/lib/xmodule From 2feda8467e589ccea08f626d58371de634c6c8e3 Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Thu, 23 Aug 2012 10:32:27 -0400 Subject: [PATCH 2/6] fix unicode error on forum profile view page --- 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 1bc6addffc..98d7ddedfd 100644 --- a/lms/templates/discussion/user_profile.html +++ b/lms/templates/discussion/user_profile.html @@ -30,7 +30,7 @@
- ${content} + ${content.decode('utf-8')}
From 0b309ea40af0561256c769db0c45d950f9d4ac9f Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Thu, 23 Aug 2012 11:27:54 -0400 Subject: [PATCH 3/6] Can't return Http404, have to raise it. --- lms/djangoapps/courseware/module_render.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 7967452647..51fc5f46c3 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -346,10 +346,10 @@ def xqueue_callback(request, course_id, userid, id, dispatch): get = request.POST.copy() for key in ['xqueue_header', 'xqueue_body']: if not get.has_key(key): - return Http404 + raise Http404 header = json.loads(get['xqueue_header']) if not isinstance(header, dict) or not header.has_key('lms_key'): - return Http404 + raise Http404 # Retrieve target StudentModule user = User.objects.get(id=userid) From f2c5a064aa230b7b39134191fe0d359a39b87ee5 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 23 Aug 2012 11:49:23 -0400 Subject: [PATCH 4/6] Pull the http or https from the forwarded proto for the xqueue callback url --- lms/djangoapps/courseware/module_render.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 51fc5f46c3..da9828fb12 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -199,7 +199,10 @@ def _get_module(user, request, location, student_module_cache, course_id, positi ) # Fully qualified callback URL for external queueing system - xqueue_callback_url = request.build_absolute_uri('/')[:-1] # Trailing slash provided by reverse + xqueue_callback_url = '{proto}://{host}'.format( + host=request.get_host(), + proto=request.META.get('HTTP_X_FORWARDED_PROTO', 'https' if request.is_secure() else 'http') + ) xqueue_callback_url += reverse('xqueue_callback', kwargs=dict(course_id=course_id, userid=str(user.id), From 48e7966ef2a2b5ff184d3a37a3037142e0c33c22 Mon Sep 17 00:00:00 2001 From: Arjun Singh Date: Thu, 23 Aug 2012 09:11:13 -0700 Subject: [PATCH 5/6] partial credit for an inputfield --- common/lib/capa/capa/correctmap.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/lib/capa/capa/correctmap.py b/common/lib/capa/capa/correctmap.py index c727626a33..eb6ef2d00c 100644 --- a/common/lib/capa/capa/correctmap.py +++ b/common/lib/capa/capa/correctmap.py @@ -73,10 +73,12 @@ class CorrectMap(object): return answer_id in self.cmap and self.cmap[answer_id]['queuekey'] == test_key def get_npoints(self, answer_id): - if self.is_correct(answer_id): - npoints = self.cmap[answer_id].get('npoints', 1) # default to 1 point if correct - return npoints or 1 - return 0 # if not correct, return 0 + npoints = self.get_property(answer_id, 'npoints') + if npoints is not None: + return npoints + elif self.is_correct(answer_id): + return 1 + return 0 # if not correct and no points have been assigned, return 0 def set_property(self, answer_id, property, value): if answer_id in self.cmap: self.cmap[answer_id][property] = value From ed6317f37c9b0e09006cf51680e0ca087b4ea6a4 Mon Sep 17 00:00:00 2001 From: Arjun Singh Date: Thu, 23 Aug 2012 10:03:36 -0700 Subject: [PATCH 6/6] getting rid of terrible hack in favor of re enabling the dispatcher to sync w/ the comment service --- common/djangoapps/student/models.py | 2 +- lms/djangoapps/django_comment_client/base/views.py | 2 +- lms/djangoapps/django_comment_client/forum/views.py | 6 +++--- lms/lib/comment_client/user.py | 10 ---------- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index 55204f19f6..9cde878d21 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -273,7 +273,7 @@ def add_user_to_default_group(user, group): utg.users.add(User.objects.get(username=user)) utg.save() -# @receiver(post_save, sender=User) +@receiver(post_save, sender=User) def update_user_information(sender, instance, created, **kwargs): try: cc_user = cc.User.from_django_user(instance) diff --git a/lms/djangoapps/django_comment_client/base/views.py b/lms/djangoapps/django_comment_client/base/views.py index 280e6d2780..dd9da857c6 100644 --- a/lms/djangoapps/django_comment_client/base/views.py +++ b/lms/djangoapps/django_comment_client/base/views.py @@ -51,7 +51,7 @@ def ajax_content_response(request, course_id, content, template_name): 'content': content, } html = render_to_string(template_name, context) - user_info = cc.User.from_django_user(request.user).safe_attributes() + user_info = cc.User.from_django_user(request.user).to_dict() annotated_content_info = utils.get_annotated_content_info(course_id, content, request.user, user_info) return JsonResponse({ 'html': html, diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index 38f8fa985d..eda574cb6e 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -64,7 +64,7 @@ def render_discussion(request, course_id, threads, *args, **kwargs): 'user': (lambda: reverse('django_comment_client.forum.views.user_profile', args=[course_id, user_id])), }[discussion_type]() - user_info = cc.User.from_django_user(request.user).safe_attributes() + user_info = cc.User.from_django_user(request.user).to_dict() def infogetter(thread): return utils.get_annotated_content_infos(course_id, thread, request.user, user_info) @@ -176,7 +176,7 @@ def render_single_thread(request, discussion_id, course_id, thread_id): thread = cc.Thread.find(thread_id).retrieve(recursive=True).to_dict() - user_info = cc.User.from_django_user(request.user).safe_attributes() + user_info = cc.User.from_django_user(request.user).to_dict() annotated_content_info = utils.get_annotated_content_infos(course_id, thread=thread, user=request.user, user_info=user_info) @@ -194,7 +194,7 @@ def single_thread(request, course_id, discussion_id, thread_id): if request.is_ajax(): - user_info = cc.User.from_django_user(request.user).safe_attributes() + user_info = cc.User.from_django_user(request.user).to_dict() thread = cc.Thread.find(thread_id).retrieve(recursive=True) 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} diff --git a/lms/lib/comment_client/user.py b/lms/lib/comment_client/user.py index 1f61e9d625..ae4abf91b7 100644 --- a/lms/lib/comment_client/user.py +++ b/lms/lib/comment_client/user.py @@ -33,16 +33,6 @@ class User(models.Model): params = {'source_type': source.type, 'source_id': source.id} response = perform_request('delete', _url_for_subscription(self.id), params) - # TODO this is a hack to compensate for the fact that synchronization isn't - # happening properly. - def safe_attributes(self): - try: - return self.to_dict() - except: - self.save() - self._retrieve() - return self.to_dict() - def vote(self, voteable, value): if voteable.type == 'thread': url = _url_for_vote_thread(voteable.id)