def test_get_all_course_highlights(self):
        all_highlights = [["week1highlight1", "week1highlight2"], ["week1highlight1", "week1highlight2"], [], []]
        with self.store.bulk_operations(self.course_key):
            for week_highlights in all_highlights:
                self._create_chapter(highlights=week_highlights)

        assert get_all_course_highlights(self.course_key) == all_highlights
示例#2
0
def export_course_metadata(sender, course_key, **kwargs):  # pylint: disable=unused-argument
    """
    Export course metadata on course publish.

    File format
    '{"highlights": [["week1highlight1", "week1highlight2"], ["week1highlight1", "week1highlight2"], [], []]}'
    To retrieve highlights for week1, you would need to do
    course_metadata['highlights'][0]

    This data is initially being used by Braze Connected Content to include
    section highlights in emails, but may be used for other things in the future.
    """
    if EXPORT_COURSE_METADATA_FLAG.is_enabled():
        log.info('exportdebugginglog flag is enabled')
        highlights = get_all_course_highlights(course_key)
        log.info('exportdebugginglog highlights {}'.format(str(highlights)))
        highlights_content = ContentFile(json.dumps({'highlights':
                                                     highlights}))
        log.info('exportdebugginglog highlights_content {}'.format(
            str(highlights_content)))
        log.info(
            'exportdebugginglog path course_metadata_export/{}.json'.format(
                course_key))
        log.info('exportdebugginglog bucket {} storage {}'.format(
            settings.COURSE_METADATA_EXPORT_BUCKET,
            settings.COURSE_METADATA_EXPORT_STORAGE))
        course_metadata_export_storage.save(
            'course_metadata_export/{}.json'.format(course_key),
            highlights_content)
示例#3
0
def export_course_metadata_task(self, course_key_string):  # pylint: disable=unused-argument
    """
    Export course metadata

    File format
    '{"highlights": [["week1highlight1", "week1highlight2"], ["week1highlight1", "week1highlight2"], [], []]}'
    To retrieve highlights for week1, you would need to do
    course_metadata['highlights'][0]

    This data is initially being used by Braze Connected Content to include
    section highlights in emails, but may be used for other things in the future.
    """
    course_key = CourseKey.from_string(course_key_string)
    highlights = get_all_course_highlights(course_key)
    highlights_content = ContentFile(json.dumps({'highlights': highlights}))
    course_metadata_export_storage.save(f'course_metadata_export/{course_key}.json', highlights_content)