Commit 59b3dc61 by Kevin Chugh

lms producing grouped content

parent b26c59bd
......@@ -72,6 +72,7 @@ def get_cohort_id(user, course_id):
and if the course is not cohorted or the user is an instructor, return None
"""
return 101
def is_commentable_cohorted(course_id,commentable_id):
"""
......
......@@ -21,6 +21,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 courseware.courses import get_cohort_id
from django_comment_client.utils import JsonResponse, JsonError, extract, get_courseware_context
......@@ -83,6 +84,24 @@ def create_thread(request, course_id, commentable_id):
'course_id' : course_id,
'user_id' : request.user.id,
})
#now cohort id
#if the group id came in from the form, set it there, otherwise,
#see if the user and the commentable are cohorted
print post
group_id = None
if 'group_id' in post:
group_id = post['group_id']
if group_id is None:
group_id = get_cohort_id(request.user, course_id)
if group_id is not None:
thread.update_attributes(**{'group_id' :group_id})
thread.save()
if post.get('auto_subscribe', 'false').lower() == 'true':
user = cc.User.from_django_user(request.user)
......
......@@ -11,6 +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 courseware.courses import get_cohort_id
from courseware.access import has_access
from urllib import urlencode
......@@ -58,6 +59,12 @@ def get_threads(request, course_id, discussion_id=None, per_page=THREADS_PER_PAG
user.default_sort_key = request.GET.get('sort_key')
user.save()
#if the course-user is cohorted, then add the group id
group_id = get_cohort_id(user,course_id);
if group_id:
default_query_params["group_id"] = group_id;
query_params = merge_dict(default_query_params,
strip_none(extract(request.GET, ['page', 'sort_key', 'sort_order', 'text', 'tags', 'commentable_ids'])))
......
......@@ -10,12 +10,12 @@ class Thread(models.Model):
'closed', 'tags', 'votes', 'commentable_id', 'username', 'user_id',
'created_at', 'updated_at', 'comments_count', 'unread_comments_count',
'at_position_list', 'children', 'type', 'highlighted_title',
'highlighted_body', 'endorsed', 'read'
'highlighted_body', 'endorsed', 'read', 'group_id'
]
updatable_fields = [
'title', 'body', 'anonymous', 'anonymous_to_peers', 'course_id',
'closed', 'tags', 'user_id', 'commentable_id',
'closed', 'tags', 'user_id', 'commentable_id', 'group_id'
]
initializable_fields = updatable_fields
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment