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


Python models.BaseStudentModuleHistory类代码示例

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


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

示例1: test_get_history_false_true

 def test_get_history_false_true(self):
     student_module = StudentModule.objects.all()
     history = BaseStudentModuleHistory.get_history(student_module)
     self.assertEquals(len(history), 3)
     self.assertEquals({'type': 'csmh', 'order': 3}, json.loads(history[0].state))
     self.assertEquals({'type': 'csmh', 'order': 2}, json.loads(history[1].state))
     self.assertEquals({'type': 'csmh', 'order': 1}, json.loads(history[2].state))
开发者ID:edx,项目名称:edx-platform,代码行数:7,代码来源:tests.py

示例2: test_get_history_true_false

 def test_get_history_true_false(self):
     student_module = StudentModule.objects.all()
     history = BaseStudentModuleHistory.get_history(student_module)
     self.assertEquals(len(history), 3)
     self.assertEquals({"type": "csmhe", "order": 3}, json.loads(history[0].state))
     self.assertEquals({"type": "csmhe", "order": 2}, json.loads(history[1].state))
     self.assertEquals({"type": "csmhe", "order": 1}, json.loads(history[2].state))
开发者ID:zhenzhai,项目名称:edx-platform,代码行数:7,代码来源:tests.py

示例3: test_show_answer_doesnt_write_to_csm

    def test_show_answer_doesnt_write_to_csm(self):
        self.basic_setup()
        self.submit_question_answer('p1', {'2_1': u'Correct'})

        # Now fetch the state entry for that problem.
        student_module = StudentModule.objects.filter(
            course_id=self.course.id,
            student=self.student_user
        )
        # count how many state history entries there are
        baseline = BaseStudentModuleHistory.get_history(student_module)
        self.assertEqual(len(baseline), 3)

        # now click "show answer"
        self.show_question_answer('p1')

        # check that we don't have more state history entries
        csmh = BaseStudentModuleHistory.get_history(student_module)
        self.assertEqual(len(csmh), 3)
开发者ID:cmscom,项目名称:edx-platform,代码行数:19,代码来源:test_submitting_problems.py

示例4: get_history

    def get_history(self, username, block_key, scope=Scope.user_state):
        """
        Retrieve history of state changes for a given block for a given
        student.  We don't guarantee that history for many blocks will be fast.

        If the specified block doesn't exist, raise :class:`~DoesNotExist`.

        Arguments:
            username: The name of the user whose history should be retrieved.
            block_key: The key identifying which xblock history to retrieve.
            scope (Scope): The scope to load data from.

        Yields:
            XBlockUserState entries for each modification to the specified XBlock, from latest
            to earliest.
        """

        if scope != Scope.user_state:
            raise ValueError("Only Scope.user_state is supported")
        student_modules = list(
            student_module
            for student_module, usage_id
            in self._get_student_modules(username, [block_key])
        )
        if len(student_modules) == 0:
            raise self.DoesNotExist()

        history_entries = BaseStudentModuleHistory.get_history(student_modules)

        # If no history records exist, raise an error
        if not history_entries:
            raise self.DoesNotExist()

        for history_entry in history_entries:
            state = history_entry.state

            # If the state is serialized json, then load it
            if state is not None:
                state = json.loads(state)

            # If the state is empty, then for the purposes of `get_history`, it has been
            # deleted, and so we list that entry as `None`.
            if state == {}:
                state = None

            block_key = history_entry.csm.module_state_key
            block_key = block_key.map_into_course(
                history_entry.csm.course_id
            )

            yield XBlockUserState(username, block_key, state, history_entry.created, scope)
开发者ID:chrisndodge,项目名称:edx-platform,代码行数:51,代码来源:user_state_client.py

示例5: test_get_history_false_false

 def test_get_history_false_false(self):
     student_module = StudentModule.objects.all()
     history = BaseStudentModuleHistory.get_history(student_module)
     self.assertEquals(len(history), 0)
开发者ID:edx,项目名称:edx-platform,代码行数:4,代码来源:tests.py


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