当前位置: 首页>>代码示例>>Python>>正文


Python factories.StudentModuleFactory类代码示例

本文整理汇总了Python中courseware.tests.factories.StudentModuleFactory的典型用法代码示例。如果您正苦于以下问题:Python StudentModuleFactory类的具体用法?Python StudentModuleFactory怎么用?Python StudentModuleFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了StudentModuleFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

    def setUp(self):
        super(TestGetProblemGradeDistribution, self).setUp()

        self.request_factory = RequestFactory()
        self.instructor = AdminFactory.create()
        self.client.login(username=self.instructor.username, password='test')
        self.attempts = 3
        self.users = [
            UserFactory.create(username="metric" + str(__))
            for __ in xrange(USER_COUNT)
        ]

        for user in self.users:
            CourseEnrollmentFactory.create(user=user, course_id=self.course.id)

        for i, item in enumerate(self.items):
            for j, user in enumerate(self.users):
                StudentModuleFactory.create(
                    grade=1 if i < j else 0,
                    max_grade=1 if i < j else 0.5,
                    student=user,
                    course_id=self.course.id,
                    module_state_key=item.location,
                    state=json.dumps({'attempts': self.attempts}),
                )
            for j, user in enumerate(self.users):
                StudentModuleFactory.create(
                    course_id=self.course.id,
                    module_type='sequential',
                    module_state_key=item.location,
                )
开发者ID:AlexxNica,项目名称:edx-platform,代码行数:31,代码来源:test_dashboard_data.py

示例2: test_student_state

    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)
开发者ID:escolaglobal,项目名称:edx-platform,代码行数:35,代码来源:test_views.py

示例3: setUp

    def setUp(self):
        super(TestGetProblemGradeDistribution, self).setUp()

        self.request_factory = RequestFactory()
        self.instructor = AdminFactory.create()
        self.client.login(username=self.instructor.username, password='test')
        self.attempts = 3
        self.course = CourseFactory.create(
            display_name=u"test course omega \u03a9",
        )

        section = ItemFactory.create(
            parent_location=self.course.location,
            category="chapter",
            display_name=u"test factory section omega \u03a9",
        )
        self.sub_section = ItemFactory.create(
            parent_location=section.location,
            category="sequential",
            display_name=u"test subsection omega \u03a9",
        )

        unit = ItemFactory.create(
            parent_location=self.sub_section.location,
            category="vertical",
            metadata={'graded': True, 'format': 'Homework'},
            display_name=u"test unit omega \u03a9",
        )

        self.users = [UserFactory.create(username="metric" + str(__)) for __ in xrange(USER_COUNT)]

        for user in self.users:
            CourseEnrollmentFactory.create(user=user, course_id=self.course.id)

        for i in xrange(USER_COUNT - 1):
            category = "problem"
            self.item = ItemFactory.create(
                parent_location=unit.location,
                category=category,
                data=StringResponseXMLFactory().build_xml(answer='foo'),
                metadata={'rerandomize': 'always'},
                display_name=u"test problem omega \u03a9 " + str(i)
            )

            for j, user in enumerate(self.users):
                StudentModuleFactory.create(
                    grade=1 if i < j else 0,
                    max_grade=1 if i < j else 0.5,
                    student=user,
                    course_id=self.course.id,
                    module_state_key=self.item.location,
                    state=json.dumps({'attempts': self.attempts}),
                )

            for j, user in enumerate(self.users):
                StudentModuleFactory.create(
                    course_id=self.course.id,
                    module_type='sequential',
                    module_state_key=self.item.location,
                )
开发者ID:Cgruppo,项目名称:edx-platform,代码行数:60,代码来源:test_dashboard_data.py

示例4: setup_students_and_grades

def setup_students_and_grades(context):
    """
    Create students and set their grades.
    :param context:  class reference
    """
    if context.course:
        context.student = student = UserFactory.create()
        CourseEnrollmentFactory.create(user=student, course_id=context.course.id)

        context.student2 = student2 = UserFactory.create()
        CourseEnrollmentFactory.create(user=student2, course_id=context.course.id)

        # create grades for self.student as if they'd submitted the ccx
        for chapter in context.course.get_children():
            for i, section in enumerate(chapter.get_children()):
                for j, problem in enumerate(section.get_children()):
                    # if not problem.visible_to_staff_only:
                    StudentModuleFactory.create(
                        grade=1 if i < j else 0,
                        max_grade=1,
                        student=context.student,
                        course_id=context.course.id,
                        module_state_key=problem.location
                    )

                    StudentModuleFactory.create(
                        grade=1 if i > j else 0,
                        max_grade=1,
                        student=context.student2,
                        course_id=context.course.id,
                        module_state_key=problem.location
                    )
开发者ID:Akif-Vohra,项目名称:edx-platform,代码行数:32,代码来源:test_views.py

示例5: setUp

    def setUp(self):
        super(TestGradebook, self).setUp()

        instructor = AdminFactory.create()
        self.client.login(username=instructor.username, password='test')
        self.users = [UserFactory.create() for _ in xrange(USER_COUNT)]

        for user in self.users:
            CourseEnrollmentFactory.create(user=user, course_id=self.course.id)

        for i, item in enumerate(self.items):
            for j, user in enumerate(self.users):
                StudentModuleFactory.create(
                    grade=1 if i < j else 0,
                    max_grade=1,
                    student=user,
                    course_id=self.course.id,
                    module_state_key=item.location
                )

        self.response = self.client.get(reverse(
            'spoc_gradebook',
            args=(self.course.id.to_deprecated_string(),)
        ))

        self.assertEquals(self.response.status_code, 200)
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:26,代码来源:test_spoc_gradebook.py

示例6: setUp

    def setUp(self):
        super(TestGradebookVertical, self).setUp()

        instructor = AdminFactory.create()
        self.client.login(username=instructor.username, password='test')

        # remove the caches
        modulestore().request_cache = None
        modulestore().metadata_inheritance_cache_subsystem = None

        kwargs = {}
        if self.grading_policy is not None:
            kwargs['grading_policy'] = self.grading_policy

        self.course = CourseFactory.create(**kwargs)
        chapter = ItemFactory.create(
            parent_location=self.course.location,
            category="sequential",
        )
        section = ItemFactory.create(
            parent_location=chapter.location,
            category="vertical",
            metadata={'graded': True, 'format': 'Homework', 'weight': 0.8}
        )

        ItemFactory.create(
            parent_location=chapter.location,
            category="vertical",
            metadata={'graded': True, 'format': 'Homework', 'weight': 0.2}
        )

        self.users = [UserFactory.create() for _ in xrange(USER_COUNT)]

        for user in self.users:
            CourseEnrollmentFactory.create(user=user, course_id=self.course.id)

        for i in xrange(USER_COUNT - 1):
            category = "problem"
            item = ItemFactory.create(
                parent_location=section.location,
                category=category,
                data=StringResponseXMLFactory().build_xml(answer='foo'),
                metadata={'rerandomize': 'always'}
            )

            for j, user in enumerate(self.users):
                StudentModuleFactory.create(
                    grade=1 if i < j else 0,
                    max_grade=1,
                    student=user,
                    course_id=self.course.id,
                    module_state_key=item.location
                )

        self.response = self.client.get(reverse(
            'spoc_gradebook',
            args=(self.course.id.to_deprecated_string(),)
        ))
开发者ID:ariestiyansyah,项目名称:edx-platformX,代码行数:58,代码来源:test_spoc_gradebook.py

示例7: setUp

    def setUp(self):
        """
        Set up tests
        """
        super(TestCCXGrades, self).setUp()

        # Create instructor account
        self.coach = coach = AdminFactory.create()
        self.client.login(username=coach.username, password="test")

        # Create CCX
        role = CourseCcxCoachRole(self._course.id)
        role.add_users(coach)
        ccx = CcxFactory(course_id=self._course.id, coach=self.coach)

        # override course grading policy and make last section invisible to students
        override_field_for_ccx(ccx, self._course, 'grading_policy', {
            'GRADER': [
                {'drop_count': 0,
                 'min_count': 2,
                 'short_label': 'HW',
                 'type': 'Homework',
                 'weight': 1}
            ],
            'GRADE_CUTOFFS': {'Pass': 0.75},
        })
        override_field_for_ccx(
            ccx, self.sections[-1], 'visible_to_staff_only', True
        )

        # create a ccx locator and retrieve the course structure using that key
        # which emulates how a student would get access.
        self.ccx_key = CCXLocator.from_course_locator(self._course.id, ccx.id)
        self.course = get_course_by_id(self.ccx_key, depth=None)

        self.student = student = UserFactory.create()
        CourseEnrollmentFactory.create(user=student, course_id=self.course.id)

        # create grades for self.student as if they'd submitted the ccx
        for chapter in self.course.get_children():
            for i, section in enumerate(chapter.get_children()):
                for j, problem in enumerate(section.get_children()):
                    # if not problem.visible_to_staff_only:
                    StudentModuleFactory.create(
                        grade=1 if i < j else 0,
                        max_grade=1,
                        student=self.student,
                        course_id=self.course.id,
                        module_state_key=problem.location
                    )

        self.client.login(username=coach.username, password="test")

        self.addCleanup(RequestCache.clear_request_cache)
开发者ID:chauhanhardik,项目名称:populo,代码行数:54,代码来源:test_views.py

示例8: _create_students_with_state

 def _create_students_with_state(self, num_students, state=None):
     """Create students, a problem, and StudentModule objects for testing"""
     self.define_option_problem(PROBLEM_URL_NAME)
     students = [
         UserFactory.create(username='robot%d' % i, email='robot+test+%[email protected]' % i)
         for i in xrange(num_students)
     ]
     for student in students:
         StudentModuleFactory.create(course_id=self.course.id,
                                     module_state_key=self.problem_url,
                                     student=student,
                                     state=state)
     return students
开发者ID:AzizYosofi,项目名称:edx-platform,代码行数:13,代码来源:test_tasks.py

示例9: test_edx_grade_with_no_score_but_problem_loaded

    def test_edx_grade_with_no_score_but_problem_loaded(self):
        """Test grading with an already loaded problem but without score.

        This can happen when the student calls the progress page from the courseware (djangoapps.courseware.views.progress).
        The progress view grades the activity only to get the current score but staff may have not given the problem a score yet.
        """
        request = RequestFactory().get('/')
        user = UserFactory(username='Joe')
        CourseEnrollmentFactory.create(course_id=self.course.id,
                                       user=user)
        StudentModuleFactory.create(student=user, course_id=self.course.id, module_state_key=str(self.gea_xblock.location))
        grade = _grade(user, request, self.course, None)
        self.assertEqual(grade['percent'], 0.0)
开发者ID:openfun,项目名称:edx-gea,代码行数:13,代码来源:tests.py

示例10: test_problem_with_no_answer

 def test_problem_with_no_answer(self):
     section, sub_section, unit, problem = self.create_course_structure()
     self.create_student()
     StudentModuleFactory.create(
         course_id=self.course.id,
         module_state_key=problem.location,
         student=self.student,
         grade=0,
         state=u'{"answer": {"problem_id": "123"}}',
     )
     course_with_children = modulestore().get_course(self.course.id, depth=4)
     datarows = list(student_responses(course_with_children))
     self.assertEqual(datarows[0][-1], None)
开发者ID:caesar2164,项目名称:edx-platform,代码行数:13,代码来源:test_basic.py

示例11: setUp

    def setUp(self):

        self.instructor = AdminFactory.create()
        self.client.login(username=self.instructor.username, password="test")
        self.attempts = 3
        self.course = CourseFactory.create(display_name=u"test course omega \u03a9")

        section = ItemFactory.create(
            parent_location=self.course.location, category="chapter", display_name=u"test factory section omega \u03a9"
        )
        sub_section = ItemFactory.create(
            parent_location=section.location, category="sequential", display_name=u"test subsection omega \u03a9"
        )

        unit = ItemFactory.create(
            parent_location=sub_section.location,
            category="vertical",
            metadata={"graded": True, "format": "Homework"},
            display_name=u"test unit omega \u03a9",
        )

        self.users = [UserFactory.create() for _ in xrange(USER_COUNT)]

        for user in self.users:
            CourseEnrollmentFactory.create(user=user, course_id=self.course.id)

        for i in xrange(USER_COUNT - 1):
            category = "problem"
            item = ItemFactory.create(
                parent_location=unit.location,
                category=category,
                data=StringResponseXMLFactory().build_xml(answer="foo"),
                metadata={"rerandomize": "always"},
                display_name=u"test problem omega \u03a9 " + str(i),
            )

            for j, user in enumerate(self.users):
                StudentModuleFactory.create(
                    grade=1 if i < j else 0,
                    max_grade=1 if i < j else 0.5,
                    student=user,
                    course_id=self.course.id,
                    module_state_key=Location(item.location).url(),
                    state=json.dumps({"attempts": self.attempts}),
                )

            for j, user in enumerate(self.users):
                StudentModuleFactory.create(
                    course_id=self.course.id, module_type="sequential", module_state_key=Location(item.location).url()
                )
开发者ID:XiaodunServerGroup,项目名称:medicalmooc,代码行数:50,代码来源:test_dashboard_data.py

示例12: test_invalid_module_state

 def test_invalid_module_state(self):
     section, sub_section, unit, problem = self.create_course_structure()
     self.create_student()
     StudentModuleFactory.create(
         course_id=self.course.id,
         module_state_key=problem.location,
         student=self.student,
         grade=0,
         state=u'{"student_answers":{"fake-problem":"No idea"}}}',
     )
     course_with_children = modulestore().get_course(self.course.id, depth=4)
     datarows = list(student_responses(course_with_children))
     # Invalid module state response will be skipped, so datarows should be empty
     self.assertEqual(len(datarows), 0)
开发者ID:caesar2164,项目名称:edx-platform,代码行数:14,代码来源:test_basic.py

示例13: test_unicode

 def test_unicode(self):
     self.course = CourseFactory.create()
     course_key = self.course.id
     self.problem_location = Location('edX', 'unicode_graded', '2012_Fall', 'problem', 'H1P1')
     self.student = UserFactory(username=u'student\xec')
     CourseEnrollmentFactory.create(user=self.student, course_id=self.course.id)
     StudentModuleFactory.create(
         course_id=self.course.id,
         module_state_key=self.problem_location,
         student=self.student,
         grade=0,
         state=u'{"student_answers":{"fake-problem":"caf\xe9"}}',
     )
     result = push_student_responses_to_s3(None, None, self.course.id, None, 'generated')
     self.assertEqual(result, 'succeeded')
开发者ID:stvstnfrd,项目名称:edx-platform,代码行数:15,代码来源:test_tasks_helper.py

示例14: test_problem_with_no_answer

    def test_problem_with_no_answer(self):
        self.course = get_course(CourseKey.from_string('edX/graded/2012_Fall'))
        problem_location = Location('edX', 'graded', '2012_Fall', 'problem', 'H1P2')

        self.create_student()
        StudentModuleFactory.create(
            course_id=self.course.id,
            module_state_key=problem_location,
            student=self.student,
            grade=0,
            state=u'{"answer": {"problem_id": "123"}}',
        )

        datarows = list(student_responses(self.course))
        self.assertEqual(datarows[0][-1], None)
开发者ID:sigberto,项目名称:edx-platform,代码行数:15,代码来源:test_basic.py

示例15: _create_students_with_state

    def _create_students_with_state(self, num_students, state=None, grade=0, max_grade=1):
        """Create students, a problem, and StudentModule objects for testing"""
        self.define_option_problem(PROBLEM_URL_NAME)
        enrolled_students = self._create_and_enroll_students(num_students)

        for student in enrolled_students:
            StudentModuleFactory.create(
                course_id=self.course.id,
                module_state_key=self.location,
                student=student,
                grade=grade,
                max_grade=max_grade,
                state=state
            )
        return enrolled_students
开发者ID:TeachAtTUM,项目名称:edx-platform,代码行数:15,代码来源:test_tasks.py


注:本文中的courseware.tests.factories.StudentModuleFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。