TNL-5621 Fix discussion topics in MIT course.
This commit is contained in:
@@ -21,6 +21,7 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
from opaque_keys.edx.locations import SlashSeparatedCourseKey
|
||||
from xmodule.modulestore.tests.factories import ItemFactory
|
||||
from lms.djangoapps.django_comment_client.constants import TYPE_ENTRY, TYPE_SUBCATEGORY
|
||||
|
||||
from ..models import CourseUserGroup, CourseCohort
|
||||
from ..views import (
|
||||
@@ -1229,7 +1230,7 @@ class CourseCohortDiscussionTopicsTestCase(CohortViewsTestCase):
|
||||
start_date = response['inline_discussions']['subcategories']['Chapter']['start_date']
|
||||
expected_response = {
|
||||
"course_wide_discussions": {
|
||||
'children': ['Topic B'],
|
||||
'children': [['Topic B', TYPE_ENTRY]],
|
||||
'entries': {
|
||||
'Topic B': {
|
||||
'sort_key': 'A',
|
||||
@@ -1243,7 +1244,7 @@ class CourseCohortDiscussionTopicsTestCase(CohortViewsTestCase):
|
||||
'subcategories': {
|
||||
'Chapter': {
|
||||
'subcategories': {},
|
||||
'children': ['Discussion'],
|
||||
'children': [['Discussion', TYPE_ENTRY]],
|
||||
'entries': {
|
||||
'Discussion': {
|
||||
'sort_key': None,
|
||||
@@ -1256,7 +1257,7 @@ class CourseCohortDiscussionTopicsTestCase(CohortViewsTestCase):
|
||||
'start_date': start_date
|
||||
}
|
||||
},
|
||||
'children': ['Chapter']
|
||||
'children': [['Chapter', TYPE_SUBCATEGORY]]
|
||||
}
|
||||
}
|
||||
self.assertEqual(response, expected_response)
|
||||
|
||||
@@ -24,6 +24,7 @@ from edxmako.shortcuts import render_to_response
|
||||
|
||||
from . import cohorts
|
||||
from lms.djangoapps.django_comment_client.utils import get_discussion_category_map, get_discussion_categories_ids
|
||||
from lms.djangoapps.django_comment_client.constants import TYPE_ENTRY
|
||||
from .models import CourseUserGroup, CourseUserGroupPartitionGroup, CohortMembership
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -437,15 +438,15 @@ def cohort_discussion_topics(request, course_key_string):
|
||||
>>> "id": "i4x-edx-eiorguegnru-course-foobarbaz"
|
||||
>>> }
|
||||
>>> }
|
||||
>>> "children": ["General"]
|
||||
>>> "children": ["General", "entry"]
|
||||
>>> },
|
||||
>>> "inline_discussions" : {
|
||||
>>> "subcategories": {
|
||||
>>> "Getting Started": {
|
||||
>>> "subcategories": {},
|
||||
>>> "children": [
|
||||
>>> "Working with Videos",
|
||||
>>> "Videos on edX"
|
||||
>>> ["Working with Videos", "entry"],
|
||||
>>> ["Videos on edX", "entry"]
|
||||
>>> ],
|
||||
>>> "entries": {
|
||||
>>> "Working with Videos": {
|
||||
@@ -460,7 +461,7 @@ def cohort_discussion_topics(request, course_key_string):
|
||||
>>> }
|
||||
>>> }
|
||||
>>> },
|
||||
>>> "children": ["Getting Started"]
|
||||
>>> "children": ["Getting Started", "subcategory"]
|
||||
>>> },
|
||||
>>> }
|
||||
>>> }
|
||||
@@ -479,11 +480,11 @@ def cohort_discussion_topics(request, course_key_string):
|
||||
course_wide_children = []
|
||||
inline_children = []
|
||||
|
||||
for name in discussion_category_map['children']:
|
||||
if name in course_wide_entries:
|
||||
course_wide_children.append(name)
|
||||
for name, c_type in discussion_category_map['children']:
|
||||
if name in course_wide_entries and c_type == TYPE_ENTRY:
|
||||
course_wide_children.append([name, c_type])
|
||||
else:
|
||||
inline_children.append(name)
|
||||
inline_children.append([name, c_type])
|
||||
|
||||
discussion_topics['course_wide_discussions'] = {
|
||||
'entries': course_wide_entries,
|
||||
|
||||
Reference in New Issue
Block a user