refactor: refactoring feature list for providers

This commit is contained in:
SaadYousaf
2021-10-15 14:39:57 +05:00
committed by Saad Yousaf
parent b3b3ef98b2
commit 22d106daf4
2 changed files with 98 additions and 88 deletions

View File

@@ -33,8 +33,6 @@ ProviderExternalLinks = namedtuple(
['learn_more', 'configuration', 'general', 'accessibility', 'contact_email']
)
ProviderFeature = namedtuple('ProviderFeature', ['id', 'feature_support_type'])
class Features(Enum):
"""
@@ -42,34 +40,46 @@ class Features(Enum):
"""
# Basic Supported Features
PRIMARY_DISCUSSION_APP_EXPERIENCE = ProviderFeature('primary-discussion-app-experience', 'basic')
LTI_BASIC_CONFIGURATION = ProviderFeature('lti-basic-configuration', 'basic')
# DISCUSSION_PAGE = ProviderFeature('discussion-page', 'basic')
PRIMARY_DISCUSSION_APP_EXPERIENCE = ('primary-discussion-app-experience', 'basic')
LTI_BASIC_CONFIGURATION = ('lti-basic-configuration', 'basic')
# DISCUSSION_PAGE = ('discussion-page', 'basic')
# Partially Supported Features
QUESTION_DISCUSSION_SUPPORT = ProviderFeature('question-discussion-support', 'partial')
COMMUNITY_TA_SUPPORT = ProviderFeature('community-ta-support', 'partial')
REPORT_FLAG_CONTENT_TO_MODERATORS = ProviderFeature('report/flag-content-to-moderators', 'partial')
LTI_ADVANCED_SHARING_MODE = ProviderFeature('lti-advanced-sharing-mode', 'partial')
AUTOMATIC_LEARNER_ENROLLMENT = ProviderFeature('automatic-learner-enrollment', 'partial')
ANONYMOUS_POSTING = ProviderFeature('anonymous-posting', 'partial')
INTERNATIONALIZATION_SUPPORT = ProviderFeature('internationalization-support', 'partial')
EMAIL_NOTIFICATIONS = ProviderFeature('email-notifications', 'partial')
WCAG_2_0_SUPPORT = ProviderFeature('wcag-2.0-support', 'partial')
BLACKOUT_DISCUSSION_DATES = ProviderFeature('blackout-discussion-dates', 'partial')
# WCAG_2_1 = ProviderFeature('wcag-2.1', 'partial')
# EMBEDDED_COURSE_SECTIONS = ProviderFeature('embedded-course-sections', 'basic')
QUESTION_DISCUSSION_SUPPORT = ('question-discussion-support', 'partial')
COMMUNITY_TA_SUPPORT = ('community-ta-support', 'partial')
REPORT_FLAG_CONTENT_TO_MODERATORS = ('report/flag-content-to-moderators', 'partial')
LTI_ADVANCED_SHARING_MODE = ('lti-advanced-sharing-mode', 'partial')
AUTOMATIC_LEARNER_ENROLLMENT = ('automatic-learner-enrollment', 'partial')
ANONYMOUS_POSTING = ('anonymous-posting', 'partial')
INTERNATIONALIZATION_SUPPORT = ('internationalization-support', 'partial')
EMAIL_NOTIFICATIONS = ('email-notifications', 'partial')
WCAG_2_0_SUPPORT = ('wcag-2.0-support', 'partial')
BLACKOUT_DISCUSSION_DATES = ('blackout-discussion-dates', 'partial')
# WCAG_2_1 = ('wcag-2.1', 'partial')
# EMBEDDED_COURSE_SECTIONS = ('embedded-course-sections', 'basic')
# Fully Supported Features
COURSE_COHORT_SUPPORT = ProviderFeature('course-cohort-support', 'full')
RESEARCH_DATA_EVENTS = ProviderFeature('research-data-events', 'full')
COURSE_COHORT_SUPPORT = ('course-cohort-support', 'full')
RESEARCH_DATA_EVENTS = ('research-data-events', 'full')
# Commonly Requested Features
IN_PLATFORM_NOTIFICATIONS = ProviderFeature('in-platform-notifications', 'common')
DISCUSSION_CONTENT_PROMPTS = ProviderFeature('discussion-content-prompts', 'common')
GRADED_DISCUSSIONS = ProviderFeature('graded-discussions', 'common')
DIRECT_MESSAGES_FROM_INSTRUCTORS = ProviderFeature('direct-messages-from-instructors', 'common')
USER_MENTIONS = ProviderFeature('user-mentions', 'common')
IN_PLATFORM_NOTIFICATIONS = ('in-platform-notifications', 'common')
DISCUSSION_CONTENT_PROMPTS = ('discussion-content-prompts', 'common')
GRADED_DISCUSSIONS = ('graded-discussions', 'common')
DIRECT_MESSAGES_FROM_INSTRUCTORS = ('direct-messages-from-instructors', 'common')
USER_MENTIONS = ('user-mentions', 'common')
def __init__(self, feature_id, feature_support_type):
self.feature_id = feature_id
self.feature_support_type = feature_support_type
@property
def value(self):
return self.feature_id
@property
def support(self):
return self.feature_support_type
def pii_sharing_required_message(provider_name):
@@ -94,18 +104,18 @@ def pii_sharing_required_message(provider_name):
AVAILABLE_PROVIDER_MAP = {
'legacy': {
'features': [
Features.LTI_BASIC_CONFIGURATION.value.id,
Features.PRIMARY_DISCUSSION_APP_EXPERIENCE.value.id,
Features.QUESTION_DISCUSSION_SUPPORT.value.id,
Features.COMMUNITY_TA_SUPPORT.value.id,
Features.REPORT_FLAG_CONTENT_TO_MODERATORS.value.id,
Features.AUTOMATIC_LEARNER_ENROLLMENT.value.id,
Features.ANONYMOUS_POSTING.value.id,
Features.INTERNATIONALIZATION_SUPPORT.value.id,
Features.WCAG_2_0_SUPPORT.value.id,
Features.BLACKOUT_DISCUSSION_DATES.value.id,
Features.COURSE_COHORT_SUPPORT.value.id,
Features.RESEARCH_DATA_EVENTS.value.id,
Features.LTI_BASIC_CONFIGURATION.value,
Features.PRIMARY_DISCUSSION_APP_EXPERIENCE.value,
Features.QUESTION_DISCUSSION_SUPPORT.value,
Features.COMMUNITY_TA_SUPPORT.value,
Features.REPORT_FLAG_CONTENT_TO_MODERATORS.value,
Features.AUTOMATIC_LEARNER_ENROLLMENT.value,
Features.ANONYMOUS_POSTING.value,
Features.INTERNATIONALIZATION_SUPPORT.value,
Features.WCAG_2_0_SUPPORT.value,
Features.BLACKOUT_DISCUSSION_DATES.value,
Features.COURSE_COHORT_SUPPORT.value,
Features.RESEARCH_DATA_EVENTS.value,
],
'external_links': ProviderExternalLinks(
learn_more='',
@@ -119,19 +129,19 @@ AVAILABLE_PROVIDER_MAP = {
},
'ed-discuss': {
'features': [
Features.PRIMARY_DISCUSSION_APP_EXPERIENCE.value.id,
Features.LTI_BASIC_CONFIGURATION.value.id,
Features.QUESTION_DISCUSSION_SUPPORT.value.id,
Features.REPORT_FLAG_CONTENT_TO_MODERATORS.value.id,
Features.LTI_ADVANCED_SHARING_MODE.value.id,
Features.AUTOMATIC_LEARNER_ENROLLMENT.value.id,
Features.ANONYMOUS_POSTING.value.id,
Features.INTERNATIONALIZATION_SUPPORT.value.id,
Features.EMAIL_NOTIFICATIONS.value.id,
Features.WCAG_2_0_SUPPORT.value.id,
Features.BLACKOUT_DISCUSSION_DATES.value.id,
Features.IN_PLATFORM_NOTIFICATIONS.value.id,
Features.USER_MENTIONS.value.id,
Features.PRIMARY_DISCUSSION_APP_EXPERIENCE.value,
Features.LTI_BASIC_CONFIGURATION.value,
Features.QUESTION_DISCUSSION_SUPPORT.value,
Features.REPORT_FLAG_CONTENT_TO_MODERATORS.value,
Features.LTI_ADVANCED_SHARING_MODE.value,
Features.AUTOMATIC_LEARNER_ENROLLMENT.value,
Features.ANONYMOUS_POSTING.value,
Features.INTERNATIONALIZATION_SUPPORT.value,
Features.EMAIL_NOTIFICATIONS.value,
Features.WCAG_2_0_SUPPORT.value,
Features.BLACKOUT_DISCUSSION_DATES.value,
Features.IN_PLATFORM_NOTIFICATIONS.value,
Features.USER_MENTIONS.value,
],
'external_links': ProviderExternalLinks(
learn_more='',
@@ -145,20 +155,20 @@ AVAILABLE_PROVIDER_MAP = {
},
'inscribe': {
'features': [
Features.PRIMARY_DISCUSSION_APP_EXPERIENCE.value.id,
Features.LTI_BASIC_CONFIGURATION.value.id,
Features.QUESTION_DISCUSSION_SUPPORT.value.id,
Features.COMMUNITY_TA_SUPPORT.value.id,
Features.REPORT_FLAG_CONTENT_TO_MODERATORS.value.id,
Features.LTI_ADVANCED_SHARING_MODE.value.id,
Features.AUTOMATIC_LEARNER_ENROLLMENT.value.id,
Features.ANONYMOUS_POSTING.value.id,
Features.INTERNATIONALIZATION_SUPPORT.value.id,
Features.EMAIL_NOTIFICATIONS.value.id,
Features.WCAG_2_0_SUPPORT.value.id,
Features.RESEARCH_DATA_EVENTS.value.id,
Features.IN_PLATFORM_NOTIFICATIONS.value.id,
Features.DISCUSSION_CONTENT_PROMPTS.value.id,
Features.PRIMARY_DISCUSSION_APP_EXPERIENCE.value,
Features.LTI_BASIC_CONFIGURATION.value,
Features.QUESTION_DISCUSSION_SUPPORT.value,
Features.COMMUNITY_TA_SUPPORT.value,
Features.REPORT_FLAG_CONTENT_TO_MODERATORS.value,
Features.LTI_ADVANCED_SHARING_MODE.value,
Features.AUTOMATIC_LEARNER_ENROLLMENT.value,
Features.ANONYMOUS_POSTING.value,
Features.INTERNATIONALIZATION_SUPPORT.value,
Features.EMAIL_NOTIFICATIONS.value,
Features.WCAG_2_0_SUPPORT.value,
Features.RESEARCH_DATA_EVENTS.value,
Features.IN_PLATFORM_NOTIFICATIONS.value,
Features.DISCUSSION_CONTENT_PROMPTS.value,
],
'external_links': ProviderExternalLinks(
learn_more='',
@@ -172,16 +182,16 @@ AVAILABLE_PROVIDER_MAP = {
},
'piazza': {
'features': [
Features.PRIMARY_DISCUSSION_APP_EXPERIENCE.value.id,
Features.LTI_BASIC_CONFIGURATION.value.id,
Features.QUESTION_DISCUSSION_SUPPORT.value.id,
Features.COMMUNITY_TA_SUPPORT.value.id,
Features.REPORT_FLAG_CONTENT_TO_MODERATORS.value.id,
Features.LTI_ADVANCED_SHARING_MODE.value.id,
Features.ANONYMOUS_POSTING.value.id,
Features.EMAIL_NOTIFICATIONS.value.id,
Features.WCAG_2_0_SUPPORT.value.id,
Features.BLACKOUT_DISCUSSION_DATES.value.id,
Features.PRIMARY_DISCUSSION_APP_EXPERIENCE.value,
Features.LTI_BASIC_CONFIGURATION.value,
Features.QUESTION_DISCUSSION_SUPPORT.value,
Features.COMMUNITY_TA_SUPPORT.value,
Features.REPORT_FLAG_CONTENT_TO_MODERATORS.value,
Features.LTI_ADVANCED_SHARING_MODE.value,
Features.ANONYMOUS_POSTING.value,
Features.EMAIL_NOTIFICATIONS.value,
Features.WCAG_2_0_SUPPORT.value,
Features.BLACKOUT_DISCUSSION_DATES.value,
],
'external_links': ProviderExternalLinks(
learn_more='https://piazza.com/product/overview',
@@ -195,18 +205,18 @@ AVAILABLE_PROVIDER_MAP = {
},
'yellowdig': {
'features': [
Features.PRIMARY_DISCUSSION_APP_EXPERIENCE.value.id,
Features.LTI_BASIC_CONFIGURATION.value.id,
Features.QUESTION_DISCUSSION_SUPPORT.value.id,
Features.COMMUNITY_TA_SUPPORT.value.id,
Features.REPORT_FLAG_CONTENT_TO_MODERATORS.value.id,
Features.EMAIL_NOTIFICATIONS.value.id,
Features.WCAG_2_0_SUPPORT.value.id,
Features.RESEARCH_DATA_EVENTS.value.id,
Features.IN_PLATFORM_NOTIFICATIONS.value.id,
Features.GRADED_DISCUSSIONS.value.id,
Features.DIRECT_MESSAGES_FROM_INSTRUCTORS.value.id,
Features.USER_MENTIONS.value.id,
Features.PRIMARY_DISCUSSION_APP_EXPERIENCE.value,
Features.LTI_BASIC_CONFIGURATION.value,
Features.QUESTION_DISCUSSION_SUPPORT.value,
Features.COMMUNITY_TA_SUPPORT.value,
Features.REPORT_FLAG_CONTENT_TO_MODERATORS.value,
Features.EMAIL_NOTIFICATIONS.value,
Features.WCAG_2_0_SUPPORT.value,
Features.RESEARCH_DATA_EVENTS.value,
Features.IN_PLATFORM_NOTIFICATIONS.value,
Features.GRADED_DISCUSSIONS.value,
Features.DIRECT_MESSAGES_FROM_INSTRUCTORS.value,
Features.USER_MENTIONS.value,
],
'external_links': ProviderExternalLinks(
learn_more='https://www.youtube.com/watch?v=ZACief-qMwY',

View File

@@ -203,7 +203,7 @@ class DiscussionsConfigurationSerializer(serializers.ModelSerializer):
course_key = instance.context_key
payload = super().to_representation(instance)
lti_configuration_data = {}
supports_lti = instance.supports(Features.LTI_BASIC_CONFIGURATION.value.id)
supports_lti = instance.supports(Features.LTI_BASIC_CONFIGURATION.value)
if supports_lti:
lti_configuration = LtiSerializer(instance.lti_configuration, context={
'pii_sharing_allowed': get_lti_pii_sharing_state_for_course(course_key),
@@ -220,7 +220,7 @@ class DiscussionsConfigurationSerializer(serializers.ModelSerializer):
if legacy_settings.is_valid(raise_exception=True):
plugin_configuration = legacy_settings.data
features_list = [
{'id': feature.value.id, 'feature_support_type': feature.value.feature_support_type}
{'id': feature.value, 'feature_support_type': feature.feature_support_type}
for feature in Features
]
payload.update({
@@ -259,7 +259,7 @@ class DiscussionsConfigurationSerializer(serializers.ModelSerializer):
Update LtiConfiguration
"""
lti_configuration_data = validated_data.get('lti_configuration')
supports_lti = instance.supports(Features.LTI_BASIC_CONFIGURATION.value.id)
supports_lti = instance.supports(Features.LTI_BASIC_CONFIGURATION.value)
if not supports_lti:
instance.lti_configuration = None
elif lti_configuration_data: