Пример #1
0
 def transform(self, usage_info, block_structure):
     """
     loads override data into blocks
     """
     provider_type = DiscussionsConfiguration.get(
         usage_info.course_key).provider_type
     topic_links = DiscussionTopicLink.objects.filter(
         context_key=usage_info.course_key,
         provider_id=provider_type,
         enabled_in_context=True,
     )
     for topic_link in topic_links:
         block_structure.override_xblock_field(
             topic_link.usage_key,
             DiscussionsTopicLinkTransformer.EXTERNAL_ID,
             topic_link.external_id,
         )
         mfe_embed_link = get_discussions_mfe_topic_url(
             usage_info.course_key, topic_link.external_id)
         if mfe_embed_link:
             block_structure.override_xblock_field(
                 topic_link.usage_key,
                 DiscussionsTopicLinkTransformer.EMBED_URL,
                 mfe_embed_link,
             )
Пример #2
0
 def _link_func(course, reverse_func):
     config = DiscussionsConfiguration.get(course.id)
     if config.provider_type == Provider.OPEN_EDX:
         return get_learning_mfe_home_url(course_key=course.id,
                                          url_fragment=self.type)
     else:
         return legacy_link_func(course, reverse_func)
Пример #3
0
 def is_enabled(cls, course, user=None):
     if super().is_enabled(course, user):
         config = DiscussionsConfiguration.get(course.id)
         return (
             config.enabled and
             config.lti_configuration is not None
         )
     else:
         return False
Пример #4
0
def _filter_discussion_for_non_legacy_provider(all_components, course_key):
    """
    Filter out Discussion component if non-legacy discussion provider is configured for course key
    """
    discussion_provider = DiscussionsConfiguration.get(context_key=course_key).provider_type

    if discussion_provider != 'legacy':
        filtered_components = [component for component in all_components if component != 'discussion']
    else:
        filtered_components = all_components

    return filtered_components
Пример #5
0
 def test_tabs_enrolled_or_staff(self, provider):
     config = DiscussionsConfiguration.get(self.course.id)
     config.provider_type = provider
     config.save()
     for is_enrolled, is_staff in [(True, False), (False, True)]:
         if provider == Provider.OPEN_EDX:
             expected_link = get_learning_mfe_home_url(
                 course_key=self.course.id, url_fragment="discussion")
         else:
             expected_link = "default_discussion_link"
         self.check_discussion(tab_list=self.tabs_with_discussion,
                               expected_discussion_link=expected_link,
                               expected_can_display_value=True,
                               is_enrolled=is_enrolled,
                               is_staff=is_staff)
Пример #6
0
 def test_tabs_with_discussion(self, provider):
     """Test a course with a discussion tab configured"""
     config = DiscussionsConfiguration.get(self.course.id)
     config.provider_type = provider
     config.save()
     if provider == Provider.OPEN_EDX:
         expected_link = get_learning_mfe_home_url(
             course_key=self.course.id, url_fragment="discussion")
     else:
         expected_link = "default_discussion_link"
     self.check_discussion(
         tab_list=self.tabs_with_discussion,
         expected_discussion_link=expected_link,
         expected_can_display_value=True,
     )
Пример #7
0
 def _get_lti_config(self, course: CourseBlock) -> LtiConfiguration:
     config = DiscussionsConfiguration.get(course.id)
     return config.lti_configuration