Skip to content

Commit

Permalink
fix: unhide discussion tab when enabling it
Browse files Browse the repository at this point in the history
  • Loading branch information
viadanna committed Sep 2, 2024
1 parent 10aec43 commit ccfeede
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions openedx/core/djangoapps/discussions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,16 @@ def get_course_division_scheme(course_discussion_settings: CourseDiscussionSetti
):
division_scheme = CourseDiscussionSettings.NONE
return division_scheme


def show_discussion_tab(course_key, user_id: int) -> None:
"""
Toggle the visibility of the discussion tab in the course.
"""
store = modulestore()
course = store.get_course(course_key)
for tab in course.tabs:
if tab.tab_id == 'discussion':
tab.is_hidden = False
store.update_item(course, user_id)
break
4 changes: 3 additions & 1 deletion openedx/core/djangoapps/discussions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
DiscussionsConfigurationSerializer,
DiscussionsProvidersSerializer,
)
from .utils import show_discussion_tab


class DiscussionsConfigurationSettingsView(APIView):
Expand Down Expand Up @@ -120,8 +121,9 @@ def update_configuration_data(request, course_key_string):
new_provider_type = serializer.validated_data.get('provider_type', None)
if new_provider_type is not None and new_provider_type != configuration.provider_type:
check_course_permissions(course, request.user, 'change_provider')

serializer.save()
if configuration.is_enabled(course_key):
show_discussion_tab(course_key, request.user.id)
return serializer.data


Expand Down

0 comments on commit ccfeede

Please sign in to comment.