def _check_split_test(self, user_tag):
        """Checks that the right compentents are rendered for user with ``user_tag``"""
        # This explicitly sets the user_tag for self.student to ``user_tag``
        UserCourseTagFactory(
            user=self.student,
            course_id=self.course.id,
            key='xblock.partition_service.partition_{0}'.format(
                self.partition.id),
            value=str(user_tag))

        resp = self.client.get(
            reverse('courseware_section',
                    kwargs={
                        'course_id': self.course.id,
                        'chapter': self.chapter.url_name,
                        'section': self.sequential.url_name
                    }))

        content = resp.content

        # Assert we see the proper icon in the top display
        self.assertIn(
            '<a class="{} inactive progress-0"'.format(
                self.ICON_CLASSES[user_tag]), content)
        # And proper tooltips
        for tooltip in self.TOOLTIPS[user_tag]:
            self.assertIn(tooltip, content)

        for hidden in self.HIDDEN_CONTENT[user_tag]:
            self.assertNotIn(hidden, content)

        # Assert that we can see the data from the appropriate test condition
        for visible in self.VISIBLE_CONTENT[user_tag]:
            self.assertIn(visible, content)
Beispiel #2
0
 def test_create_user_course_tags(self):
     """Create user preference tags and confirm properties are set accordingly. """
     user = UserFactory.create()
     course = CourseFactory.create()
     tag = UserCourseTagFactory.create(user=user, course_id=course.id, key="testkey", value="foobar")
     self.assertEquals(tag.user, user)
     self.assertEquals(tag.course_id, course.id)
     self.assertEquals(tag.key, "testkey")
     self.assertEquals(tag.value, "foobar")
Beispiel #3
0
 def test_create_user_course_tags(self):
     """Create user preference tags and confirm properties are set accordingly. """
     user = UserFactory.create()
     course = CourseFactory.create()
     tag = UserCourseTagFactory.create(user=user,
                                       course_id=course.id,
                                       key="testkey",
                                       value="foobar")
     self.assertEquals(tag.user, user)
     self.assertEquals(tag.course_id, course.id)
     self.assertEquals(tag.key, "testkey")
     self.assertEquals(tag.value, "foobar")
    def test_tag_context(self):
        for key, value in (('int_value', 1), ('str_value', "two")):
            UserCourseTagFactory.create(
                course_id=self.course_id,
                user=self.user,
                key=key,
                value=value,
            )

        UserCourseTagFactory.create(
            course_id=self.course_id,
            user=self.other_user,
            key="other_user",
            value="other_user_value"
        )

        UserCourseTagFactory.create(
            course_id='other/course/id',
            user=self.user,
            key="other_course",
            value="other_course_value"
        )

        self.process_request()
        self.assertContextSetTo({
            'course_id': self.course_id,
            'course_user_tags': {
                'int_value': '1',
                'str_value': 'two',
            }
        })
    def test_tag_context(self):
        for key, value in (('int_value', 1), ('str_value', "two")):
            UserCourseTagFactory.create(
                course_id=self.course_id,
                user=self.user,
                key=key,
                value=value,
            )

        UserCourseTagFactory.create(course_id=self.course_id,
                                    user=self.other_user,
                                    key="other_user",
                                    value="other_user_value")

        UserCourseTagFactory.create(course_id='other/course/id',
                                    user=self.user,
                                    key="other_course",
                                    value="other_course_value")

        self.process_request()
        self.assertContextSetTo({
            'course_id': self.course_id,
            'course_user_tags': {
                'int_value': '1',
                'str_value': 'two',
            }
        })
Beispiel #6
0
    def split_setup(self, user_partition_group):
        """
        Setup for tests using split_test module. Creates a split_test instance as a child of self.homework_conditional
        with 2 verticals in it, and assigns self.student_user to the specified user_partition_group.

        The verticals are returned.
        """
        vertical_0_url = self.course.id.make_usage_key("vertical", "split_test_vertical_0")
        vertical_1_url = self.course.id.make_usage_key("vertical", "split_test_vertical_1")

        group_id_to_child = {}
        for index, url in enumerate([vertical_0_url, vertical_1_url]):
            group_id_to_child[str(index)] = url

        split_test = ItemFactory.create(
            parent_location=self.homework_conditional.location,
            category="split_test",
            display_name="Split test",
            user_partition_id='0',
            group_id_to_child=group_id_to_child,
        )

        vertical_0 = ItemFactory.create(
            parent_location=split_test.location,
            category="vertical",
            display_name="Condition 0 vertical",
            location=vertical_0_url,
        )

        vertical_1 = ItemFactory.create(
            parent_location=split_test.location,
            category="vertical",
            display_name="Condition 1 vertical",
            location=vertical_1_url,
        )

        # Now add the student to the specified group.
        UserCourseTagFactory(
            user=self.student_user,
            course_id=self.course.id,
            key='xblock.partition_service.partition_{0}'.format(self.partition.id),  # pylint: disable=no-member
            value=str(user_partition_group)
        )

        return vertical_0, vertical_1
    def test_tag_context(self):
        for key, value in (("int_value", 1), ("str_value", "two")):
            UserCourseTagFactory.create(course_id=self.course_id, user=self.user, key=key, value=value)

        UserCourseTagFactory.create(
            course_id=self.course_id, user=self.other_user, key="other_user", value="other_user_value"
        )

        UserCourseTagFactory.create(
            course_id="other/course/id", user=self.user, key="other_course", value="other_course_value"
        )

        self.process_request()
        self.assertContextSetTo(
            {"course_id": self.course_id, "course_user_tags": {"int_value": "1", "str_value": "two"}}
        )
    def setUp(self):
        """
        Set up a course with graded problems within a split test.

        Course hierarchy is as follows (modeled after how split tests
        are created in studio):
        -> course
            -> chapter
                -> sequential (graded)
                    -> vertical
                        -> split_test
                            -> vertical (Group A)
                                -> problem
                            -> vertical (Group B)
                                -> problem
        """
        super(TestGradeReportConditionalContent, self).setUp()

        # Create user partitions
        self.user_partition_group_a = 0
        self.user_partition_group_b = 1
        self.partition = UserPartition(
            0, 'first_partition', 'First Partition', [
                Group(self.user_partition_group_a, 'Group A'),
                Group(self.user_partition_group_b, 'Group B')
            ])

        # Create course with group configurations and grading policy
        self.initialize_course(
            course_factory_kwargs={
                'user_partitions': [self.partition],
                'grading_policy': {
                    "GRADER": [{
                        "type": "Homework",
                        "min_count": 1,
                        "drop_count": 0,
                        "short_label": "HW",
                        "weight": 1.0
                    }]
                }
            })

        # Create users and partition them
        self.student_a = self.create_student('student_a')
        self.student_b = self.create_student('student_b')
        UserCourseTagFactory(
            user=self.student_a,
            course_id=self.course.id,
            key='xblock.partition_service.partition_{0}'.format(
                self.partition.id),  # pylint: disable=no-member
            value=str(self.user_partition_group_a))
        UserCourseTagFactory(
            user=self.student_b,
            course_id=self.course.id,
            key='xblock.partition_service.partition_{0}'.format(
                self.partition.id),  # pylint: disable=no-member
            value=str(self.user_partition_group_b))

        # Create a vertical to contain our split test
        problem_vertical = ItemFactory.create(
            parent_location=self.problem_section.location,
            category='vertical',
            display_name='Problem Unit')

        # Create the split test and child vertical containers
        vertical_a_url = self.course.id.make_usage_key(
            'vertical', 'split_test_vertical_a')
        vertical_b_url = self.course.id.make_usage_key(
            'vertical', 'split_test_vertical_b')
        self.split_test = ItemFactory.create(
            parent_location=problem_vertical.location,
            category='split_test',
            display_name='Split Test',
            user_partition_id=self.partition.id,  # pylint: disable=no-member
            group_id_to_child={
                str(index): url
                for index, url in enumerate([vertical_a_url, vertical_b_url])
            })
        self.vertical_a = ItemFactory.create(
            parent_location=self.split_test.location,
            category='vertical',
            display_name='Group A problem container',
            location=vertical_a_url)
        self.vertical_b = ItemFactory.create(
            parent_location=self.split_test.location,
            category='vertical',
            display_name='Group B problem container',
            location=vertical_b_url)