fix: updated discussion enabled label (#31572)

Co-authored-by: adeel.tajamul <adeel.tajamul@arbisoft.com>
This commit is contained in:
Muhammad Adeel Tajamul
2023-01-24 14:42:22 +05:00
committed by GitHub
parent 536fe66362
commit a8535ffaea
4 changed files with 10 additions and 49 deletions

View File

@@ -20,7 +20,6 @@ from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.student.roles import CourseInstructorRole, CourseStaffRole
from openedx.core.djangoapps.course_apps.toggles import proctoring_settings_modal_view_enabled
from openedx.core.djangoapps.discussions.config.waffle import ENABLE_PAGES_AND_RESOURCES_MICROFRONTEND
from openedx.core.djangoapps.discussions.models import DiscussionTopicLink, Provider
from openedx.core.djangoapps.django_comment_common.models import assign_default_role
from openedx.core.djangoapps.django_comment_common.utils import seed_permissions_roles
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
@@ -732,38 +731,3 @@ def translation_language(language):
translation.activate(previous)
else:
yield
def mark_verticals_discussion_enabled(course_structure, course_key):
"""
Adds has_discussion attribute on verticals of course_structure
"""
topics = []
topics_query = DiscussionTopicLink.objects.filter(
context_key=course_key,
provider_id=Provider.OPEN_EDX,
)
for topic in topics_query:
topics.append({
"usage_key": str(topic.usage_key)
})
sub_sections_reference = []
if course_structure.get('has_children'):
chapters = course_structure['child_info'].get('children')
for section in chapters:
if section.get('has_children'):
sub_sections = section.get('child_info').get('children')
for sub_section in sub_sections:
sub_sections_reference.append(sub_section)
for sub_section in sub_sections_reference:
if sub_section.get('has_children'):
verticals = sub_section.get('child_info').get('children')
for vertical in verticals:
vertical_id = vertical.get('id')
vertical['has_discussion'] = False
for topic in topics:
if topic.get('usage_key') == vertical_id:
vertical['has_discussion'] = True
return course_structure