Exemple #1
0
    def test_activate_block_id(self):
        user = UserFactory()

        course = CourseFactory.create()
        chapter = ItemFactory.create(parent=course, category='chapter')
        section = ItemFactory.create(parent=chapter, category='sequential', display_name="Sequence")
        vertical = ItemFactory.create(parent=section, category='vertical', display_name="Vertical")
        ItemFactory.create(parent=vertical, category='id_checker', display_name="ID Checker")

        CourseEnrollmentFactory(user=user, course_id=course.id)

        request = RequestFactory().get(
            reverse(
                'courseware_section',
                kwargs={
                    'course_id': unicode(course.id),
                    'chapter': chapter.url_name,
                    'section': section.url_name,
                }
            ) + '?activate_block_id=test_block_id'
        )
        request.user = user
        mako_middleware_process_request(request)

        response = views.index(request, unicode(course.id), chapter=chapter.url_name, section=section.url_name)
        self.assertIn("Activate Block ID: test_block_id", response.content)
    def test_student_state(self, default_store):
        """
        Verify that saved student state is loaded for xblocks rendered in the index view.
        """
        user = UserFactory()

        with modulestore().default_store(default_store):
            course = CourseFactory.create()
            chapter = ItemFactory.create(parent=course, category="chapter")
            section = ItemFactory.create(parent=chapter, category="view_checker", display_name="Sequence Checker")
            vertical = ItemFactory.create(parent=section, category="view_checker", display_name="Vertical Checker")
            block = ItemFactory.create(parent=vertical, category="view_checker", display_name="Block Checker")

        for item in (section, vertical, block):
            StudentModuleFactory.create(
                student=user,
                course_id=course.id,
                module_state_key=item.scope_ids.usage_id,
                state=json.dumps({"state": unicode(item.scope_ids.usage_id)}),
            )

        CourseEnrollmentFactory(user=user, course_id=course.id)

        request = RequestFactory().get(
            reverse(
                "courseware_section",
                kwargs={"course_id": unicode(course.id), "chapter": chapter.url_name, "section": section.url_name},
            )
        )
        request.user = user
        mako_middleware_process_request(request)

        # Trigger the assertions embedded in the ViewCheckerBlocks
        response = views.index(request, unicode(course.id), chapter=chapter.url_name, section=section.url_name)
        self.assertEquals(response.content.count("ViewCheckerPassed"), 3)
Exemple #3
0
    def test_student_state(self, default_store):
        """
        Verify that saved student state is loaded for xblocks rendered in the index view.
        """
        user = UserFactory()

        with modulestore().default_store(default_store):
            course = CourseFactory.create()
            chapter = ItemFactory.create(parent=course, category='chapter')
            section = ItemFactory.create(parent=chapter,
                                         category='view_checker',
                                         display_name="Sequence Checker")
            vertical = ItemFactory.create(parent=section,
                                          category='view_checker',
                                          display_name="Vertical Checker")
            block = ItemFactory.create(parent=vertical,
                                       category='view_checker',
                                       display_name="Block Checker")

        for item in (section, vertical, block):
            StudentModuleFactory.create(
                student=user,
                course_id=course.id,
                module_state_key=item.scope_ids.usage_id,
                state=json.dumps({'state': unicode(item.scope_ids.usage_id)}))

        CourseEnrollmentFactory(user=user, course_id=course.id)

        request = RequestFactory().get(
            reverse('courseware_section',
                    kwargs={
                        'course_id': unicode(course.id),
                        'chapter': chapter.url_name,
                        'section': section.url_name,
                    }))
        request.user = user
        mako_middleware_process_request(request)

        # Trigger the assertions embedded in the ViewCheckerBlocks
        response = views.index(request,
                               unicode(course.id),
                               chapter=chapter.url_name,
                               section=section.url_name)
        self.assertEquals(response.content.count("ViewCheckerPassed"), 3)