feat: add provider info to the discussion configuration API (#29864)

The new discusions MFE needs to know which provider is in use (legacy or new) to deliver the expected experience. This adds the provider name and other relevant configuration to the discussion configuraiton API.
This commit is contained in:
Kshitij Sobti
2022-02-28 11:53:28 +05:30
committed by GitHub
parent 781183ce6b
commit f7df694c5f
4 changed files with 23 additions and 3 deletions

View File

@@ -278,6 +278,8 @@ def get_course(request, course_key):
course = _get_course(course_key, request.user)
user_roles = get_user_role_names(request.user, course_key)
course_config = DiscussionsConfiguration.get(course_key)
return {
"id": str(course_key),
"blackouts": [
@@ -299,7 +301,10 @@ def get_course(request, course_key):
FORUM_ROLE_ADMINISTRATOR,
FORUM_ROLE_MODERATOR,
FORUM_ROLE_COMMUNITY_TA,
})
}),
"provider": course_config.provider_type,
"enable_in_context": course_config.enable_in_context,
"group_at_subsection": course_config.plugin_configuration.get("group_at_subsection", False),
}

View File

@@ -739,10 +739,10 @@ class CourseMetadataSerailizer(serializers.Serializer):
)
topics_url = serializers.URLField(help_text="The URL of the topic listing for the course.")
allow_anonymous = serializers.BooleanField(
help_text="A boolean which indicating whether anonymous posts are allowed or not.",
help_text="A boolean indicating whether anonymous posts are allowed or not.",
)
allow_anonymous_to_peers = serializers.BooleanField(
help_text="A boolean which indicating whether posts anonymous to peers are allowed or not.",
help_text="A boolean indicating whether posts anonymous to peers are allowed or not.",
)
user_roles = serializers.ListField(
child=serializers.CharField(),
@@ -751,3 +751,12 @@ class CourseMetadataSerailizer(serializers.Serializer):
user_is_privileged = serializers.BooleanField(
help_text="A boolean indicating if the current user has a privileged role",
)
provider = serializers.CharField(
help_text="The discussion provider used by this course",
)
enable_in_context = serializers.BooleanField(
help_text="A boolean indicating whether in-context discussion is enabled for the course",
)
group_at_subsection = serializers.BooleanField(
help_text="A boolean indicating whether discussions should be grouped at subsection",
)

View File

@@ -191,6 +191,9 @@ class GetCourseTest(ForumsEnableMixin, UrlResetMixin, SharedModuleStoreTestCase)
'topics_url': 'http://testserver/api/discussion/v1/course_topics/course-v1:x+y+z',
'allow_anonymous': True,
'allow_anonymous_to_peers': False,
'enable_in_context': True,
'group_at_subsection': False,
'provider': 'legacy',
'user_is_privileged': False,
'user_roles': {'Student'},
}

View File

@@ -512,6 +512,9 @@ class CourseViewTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
"http://testserver/api/discussion/v1/threads/?course_id=course-v1%3Ax%2By%2Bz&following=True"
),
"topics_url": "http://testserver/api/discussion/v1/course_topics/course-v1:x+y+z",
'enable_in_context': True,
'group_at_subsection': False,
'provider': 'legacy',
"allow_anonymous": True,
"allow_anonymous_to_peers": False,
'user_is_privileged': False,