refactor: updated provider map structure and test cases
This commit is contained in:
@@ -76,7 +76,7 @@ The payload is expected to be shaped like this (key names subject to change):
|
||||
'active': configuration.provider_type or '',
|
||||
'available': {
|
||||
provider: {
|
||||
'features': PROVIDER_FEATURE_MAP.get(provider) or [],
|
||||
'features': AVAILABLE_PROVIDER_MAP.get(provider).get('features') or [],
|
||||
}
|
||||
for provider in configuration.available_providers
|
||||
},
|
||||
|
||||
@@ -16,6 +16,7 @@ from model_utils.models import TimeStampedModel
|
||||
from opaque_keys.edx.django.models import LearningContextKeyField
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from simple_history.models import HistoricalRecords
|
||||
from collections import namedtuple
|
||||
|
||||
from openedx.core.djangoapps.config_model_utils.models import StackedConfigurationModel
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
@@ -25,6 +26,9 @@ log = logging.getLogger(__name__)
|
||||
DEFAULT_PROVIDER_TYPE = 'legacy'
|
||||
|
||||
|
||||
DocumentLinks = namedtuple('DocumentLinks', ['learn_more', 'configuration_documentation', 'documentation', 'accessibility_documentation', 'email_id'])
|
||||
|
||||
|
||||
class Features(Enum):
|
||||
"""
|
||||
Features to be used/mapped in discussion providers
|
||||
@@ -55,17 +59,7 @@ class Features(Enum):
|
||||
WCAG_2_1 = 'wcag-2.1'
|
||||
WCAG_2_0_SUPPORT = 'wcag-2.0-support'
|
||||
|
||||
class LINKS(Enum):
|
||||
"""
|
||||
Links to be used in discussion providers for documentation
|
||||
"""
|
||||
PIAZZA_DOCUMENTATION: ''
|
||||
PIAZZA_ACCESSIBILITY_DOCUMENTATION: ''
|
||||
PIAZZA_EMAIL: ''
|
||||
PIAZZA_CONFIGURATION_DOCUMENTATION: ''
|
||||
PIAZZA_LEARN_MORE: ''
|
||||
|
||||
PROVIDER_FEATURE_MAP = {
|
||||
AVAILABLE_PROVIDER_MAP = {
|
||||
'legacy': {
|
||||
'features': [
|
||||
Features.DISCUSSION_PAGE.value,
|
||||
@@ -81,16 +75,16 @@ PROVIDER_FEATURE_MAP = {
|
||||
Features.COURSE_COHORT_SUPPORT.value,
|
||||
Features.RESEARCH_DATA_EVENTS.value,
|
||||
],
|
||||
'documentation_urls': {
|
||||
'learnMore': '',
|
||||
'configurationDocumentation': '',
|
||||
'documentation': '',
|
||||
'accessibilityDocumentation': '',
|
||||
'emailId': '',
|
||||
}
|
||||
'documentation_urls': DocumentLinks(
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
)._asdict(),
|
||||
},
|
||||
'piazza': {
|
||||
'features':[
|
||||
'features': [
|
||||
Features.DISCUSSION_PAGE.value,
|
||||
Features.LTI.value,
|
||||
Features.WCAG_2_0_SUPPORT.value,
|
||||
@@ -104,13 +98,13 @@ PROVIDER_FEATURE_MAP = {
|
||||
Features.DIRECT_MESSAGES_FROM_INSTRUCTORS.value,
|
||||
Features.USER_MENTIONS.value,
|
||||
],
|
||||
'documentation_urls': {
|
||||
'learnMore': 'https://piazza.com/product/overview',
|
||||
'configurationDocumentation': 'https://support.piazza.com/support/solutions/articles/48001065447-configure-piazza-within-edx',
|
||||
'documentation': 'https://support.piazza.com/',
|
||||
'accessibilityDocumentation': 'https://piazza.com/product/accessibility',
|
||||
'emailId': 'team@piazza.com',
|
||||
}
|
||||
'documentation_urls': DocumentLinks(
|
||||
'https://piazza.com/product/overview',
|
||||
'https://support.piazza.com/support/solutions/articles/48001065447-configure-piazza-within-edx',
|
||||
'https://support.piazza.com/',
|
||||
'https://piazza.com/product/accessibility',
|
||||
'team@piazza.com',
|
||||
)._asdict()
|
||||
},
|
||||
'edx-next': {
|
||||
'features': [
|
||||
@@ -130,13 +124,13 @@ PROVIDER_FEATURE_MAP = {
|
||||
Features.DISCUSSION_CONTENT_PROMPTS.value,
|
||||
Features.GRADED_DISCUSSIONS.value,
|
||||
],
|
||||
'documentation_urls': {
|
||||
'learnMore': '',
|
||||
'configurationDocumentation': '',
|
||||
'documentation': '',
|
||||
'accessibilityDocumentation': '',
|
||||
'emailId': '',
|
||||
}
|
||||
'documentation_urls': DocumentLinks(
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
)._asdict(),
|
||||
},
|
||||
'yellowdig': {
|
||||
'features': [
|
||||
@@ -152,26 +146,26 @@ PROVIDER_FEATURE_MAP = {
|
||||
Features.DIRECT_MESSAGES_FROM_INSTRUCTORS.value,
|
||||
Features.USER_MENTIONS.value,
|
||||
],
|
||||
'documentation_urls': {
|
||||
'learnMore': 'https://www.youtube.com/watch?v=ZACief-qMwY',
|
||||
'configurationDocumentation': '',
|
||||
'documentation': 'https://hubs.ly/H0J5Bn70',
|
||||
'accessibilityDocumentation': 'https://drive.google.com/file/d/1FT6E2ajMabFQI3NqgInPgGsQnLH7e2Mb/view?usp=sharing',
|
||||
'emailId': 'learnmore@yellowdig.com',
|
||||
}
|
||||
'documentation_urls': DocumentLinks(
|
||||
'https://www.youtube.com/watch?v=ZACief-qMwY',
|
||||
'',
|
||||
'https://hubs.ly/H0J5Bn7',
|
||||
'https://drive.google.com/file/d/1FT6E2ajMabFQI3NqgInPgGsQnLH7e2Mb/view?usp=sharing',
|
||||
'learnmore@yellowdig.com',
|
||||
)._asdict(),
|
||||
},
|
||||
'inscribe': {
|
||||
'features': [
|
||||
Features.PRIMARY_DISCUSSION_APP_EXPERIENCE.value,
|
||||
Features.LTI_BASIC_CONFIGURATION.value,
|
||||
],
|
||||
'documentation_urls': {
|
||||
'learnMore': '',
|
||||
'configurationDocumentation': '',
|
||||
'documentation': 'https://www.inscribeapp.com/',
|
||||
'accessibilityDocumentation': '',
|
||||
'emailId': '',
|
||||
}
|
||||
'documentation_urls': DocumentLinks(
|
||||
'',
|
||||
'',
|
||||
'https://www.inscribeapp.com/',
|
||||
'',
|
||||
'',
|
||||
)._asdict(),
|
||||
},
|
||||
'discourse': {
|
||||
'features': [
|
||||
@@ -179,13 +173,13 @@ PROVIDER_FEATURE_MAP = {
|
||||
Features.LTI_BASIC_CONFIGURATION.value,
|
||||
Features.LTI_ADVANCED_SHARING_MODE.value,
|
||||
],
|
||||
'documentation_urls': {
|
||||
'learnMore': '',
|
||||
'configurationDocumentation': '',
|
||||
'documentation': 'http://discourse.org/',
|
||||
'accessibilityDocumentation': '',
|
||||
'emailId': '',
|
||||
}
|
||||
'documentation_urls': DocumentLinks(
|
||||
'',
|
||||
'',
|
||||
'http://discourse.org/',
|
||||
'',
|
||||
'',
|
||||
)._asdict(),
|
||||
},
|
||||
'ed-discuss': {
|
||||
'features': [
|
||||
@@ -199,13 +193,13 @@ PROVIDER_FEATURE_MAP = {
|
||||
Features.COMMUNITY_TA_SUPPORT.value,
|
||||
Features.EMAIL_NOTIFICATIONS.value,
|
||||
],
|
||||
'documentation_urls': {
|
||||
'learnMore': '',
|
||||
'configurationDocumentation': '',
|
||||
'documentation': 'https://edstem.org/us/',
|
||||
'accessibilityDocumentation': '',
|
||||
'emailId': '',
|
||||
}
|
||||
'documentation_urls': DocumentLinks(
|
||||
'',
|
||||
'',
|
||||
'https://edstem.org/us/',
|
||||
'',
|
||||
'',
|
||||
)._asdict(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,7 +362,7 @@ class DiscussionsConfiguration(TimeStampedModel):
|
||||
"""
|
||||
Check if the provider supports some feature
|
||||
"""
|
||||
features = PROVIDER_FEATURE_MAP.get(self.provider_type) or []
|
||||
features = AVAILABLE_PROVIDER_MAP.get(self.provider_type).get('features') or []
|
||||
has_support = bool(feature in features)
|
||||
return has_support
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from openedx.core.djangoapps.django_comment_common.models import CourseDiscussio
|
||||
from openedx.core.lib.courses import get_course_by_id
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
from .models import DEFAULT_PROVIDER_TYPE, PROVIDER_FEATURE_MAP, DiscussionsConfiguration, Features
|
||||
from .models import DEFAULT_PROVIDER_TYPE, AVAILABLE_PROVIDER_MAP, DiscussionsConfiguration, Features
|
||||
|
||||
|
||||
class LtiSerializer(serializers.ModelSerializer):
|
||||
@@ -209,7 +209,7 @@ class DiscussionsConfigurationSerializer(serializers.ModelSerializer):
|
||||
'plugin_configuration': plugin_configuration,
|
||||
'providers': {
|
||||
'active': provider_type or DEFAULT_PROVIDER_TYPE,
|
||||
'available': PROVIDER_FEATURE_MAP,
|
||||
'available': AVAILABLE_PROVIDER_MAP,
|
||||
},
|
||||
})
|
||||
return payload
|
||||
|
||||
@@ -16,7 +16,7 @@ from common.lib.xmodule.xmodule.modulestore.tests.django_utils import ModuleStor
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
|
||||
from ..models import PROVIDER_FEATURE_MAP
|
||||
from ..models import AVAILABLE_PROVIDER_MAP
|
||||
|
||||
|
||||
DATA_LEGACY_COHORTS = {
|
||||
@@ -143,7 +143,7 @@ class DataTest(AuthorizedApiTest):
|
||||
assert response.status_code == self.expected_response_code
|
||||
assert not data['enabled']
|
||||
assert data['provider_type'] == 'legacy'
|
||||
assert data['providers']['available']['legacy'] == PROVIDER_FEATURE_MAP['legacy']
|
||||
assert data['providers']['available']['legacy'] == AVAILABLE_PROVIDER_MAP['legacy']
|
||||
assert data['lti_configuration'] == {}
|
||||
assert data['plugin_configuration'] == {
|
||||
'allow_anonymous': True,
|
||||
@@ -188,7 +188,7 @@ class DataTest(AuthorizedApiTest):
|
||||
data = self._setup_lti()
|
||||
assert data['enabled']
|
||||
assert data['provider_type'] == 'piazza'
|
||||
assert data['providers']['available']['piazza'] == PROVIDER_FEATURE_MAP['piazza']
|
||||
assert data['providers']['available']['piazza'] == AVAILABLE_PROVIDER_MAP['piazza']
|
||||
assert data['lti_configuration'] == DATA_LTI_CONFIGURATION
|
||||
assert len(data['plugin_configuration']) == 0
|
||||
assert len(data['lti_configuration']) > 0
|
||||
|
||||
Reference in New Issue
Block a user