Exemplo n.º 1
0
    def test_hide_learning_sequences(self):
        """
        Check that Learning Sequences filters out sequences.
        """
        CourseEnrollment.enroll(self.user, self.course.id, CourseMode.VERIFIED)

        # Normal behavior: the sequence exists
        response = self.client.get(self.url)
        assert response.status_code == 200
        blocks = response.data['course_blocks']['blocks']
        seq_block_id = next(
            block_id
            for block_id, block in blocks.items()
            if block['type'] == 'sequential'
        )

        # With Learning Sequences active and a course outline loaded, the same
        # sequence is removed.
        with override_waffle_flag(USE_FOR_OUTLINES, active=True):
            new_learning_seq_outline = CourseOutlineData(
                course_key=self.course.id,
                title="Test Course Outline!",
                published_at=datetime(2021, 6, 14, tzinfo=timezone.utc),
                published_version="5ebece4b69dd593d82fe2022",
                entrance_exam_id=None,
                days_early_for_beta=None,
                sections=[],
                self_paced=False,
                course_visibility=CourseVisibility.PRIVATE  # pylint: disable=protected-access
            )
            replace_course_outline(new_learning_seq_outline)
            response = self.client.get(self.url)
            blocks = response.data['course_blocks']['blocks']
            assert seq_block_id not in blocks
Exemplo n.º 2
0
def update_outline_from_modulestore(course_key):
    """
    Update the CourseOutlineData for course_key in the learning_sequences with
    ModuleStore data (i.e. what was most recently published in Studio).
    """
    # Set the course_id attribute first so that if getting the information
    # from the modulestore errors out, we still have the course_key reported in
    # New Relic for easier trace debugging.
    set_custom_attribute('course_id', str(course_key))

    course_outline_data = get_outline_from_modulestore(course_key)
    set_custom_attribute('num_sequences', len(course_outline_data.sequences))
    replace_course_outline(course_outline_data)