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


Python models.GradedAssignment类代码示例

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


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

示例1: BaseOutcomeTest

class BaseOutcomeTest(TestCase):
    """
    Super type for tests of both the leaf and composite outcome celery tasks.
    """
    def setUp(self):
        super(BaseOutcomeTest, self).setUp()
        self.course_key = CourseLocator(
            org='some_org',
            course='some_course',
            run='some_run'
        )
        self.usage_key = BlockUsageLocator(
            course_key=self.course_key,
            block_type='problem',
            block_id='block_id'
        )
        self.user = UserFactory.create()
        self.consumer = LtiConsumer(
            consumer_name='Lti Consumer Name',
            consumer_key='consumer_key',
            consumer_secret='consumer_secret',
            instance_guid='tool_instance_guid'
        )
        self.consumer.save()
        outcome = OutcomeService(
            lis_outcome_service_url='http://example.com/service_url',
            lti_consumer=self.consumer
        )
        outcome.save()
        self.assignment = GradedAssignment(
            user=self.user,
            course_key=self.course_key,
            usage_key=self.usage_key,
            outcome_service=outcome,
            lis_result_sourcedid='sourcedid',
            version_number=1,
        )
        self.assignment.save()

        self.send_score_update_mock = self.setup_patch(
            'lti_provider.outcomes.send_score_update', None
        )

    def setup_patch(self, function_name, return_value):
        """
        Patch a method with a given return value, and return the mock
        """
        mock = MagicMock(return_value=return_value)
        new_patch = patch(function_name, new=mock)
        new_patch.start()
        self.addCleanup(new_patch.stop)
        return mock
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:52,代码来源:test_tasks.py

示例2: create_graded_assignment

 def create_graded_assignment(self, desc, result_id, outcome_service):
     """
     Create and save a new GradedAssignment model in the test database.
     """
     assignment = GradedAssignment(
         user=self.user,
         course_key=self.course.id,
         usage_key=desc.location,
         outcome_service=outcome_service,
         lis_result_sourcedid=result_id,
         version_number=0
     )
     assignment.save()
     return assignment
开发者ID:Kalyzee,项目名称:edx-platform,代码行数:14,代码来源:test_outcomes.py

示例3: SignAndSendReplaceResultTest

class SignAndSendReplaceResultTest(TestCase):
    """
    Tests for the sign_and_send_replace_result method in outcomes.py
    """
    shard = 4

    def setUp(self):
        super(SignAndSendReplaceResultTest, self).setUp()
        self.course_key = CourseLocator(
            org='some_org',
            course='some_course',
            run='some_run'
        )
        self.usage_key = BlockUsageLocator(
            course_key=self.course_key,
            block_type='problem',
            block_id='block_id'
        )
        self.user = UserFactory.create()
        consumer = LtiConsumer(
            consumer_name='consumer',
            consumer_key='consumer_key',
            consumer_secret='secret'
        )
        consumer.save()
        outcome = OutcomeService(
            lis_outcome_service_url='http://example.com/service_url',
            lti_consumer=consumer,
        )
        outcome.save()
        self.assignment = GradedAssignment(
            user=self.user,
            course_key=self.course_key,
            usage_key=self.usage_key,
            outcome_service=outcome,
            lis_result_sourcedid='sourcedid',
        )
        self.assignment.save()

    @patch('requests.post', return_value='response')
    def test_sign_and_send_replace_result(self, post_mock):
        response = outcomes.sign_and_send_replace_result(self.assignment, 'xml')
        post_mock.assert_called_with(
            'http://example.com/service_url',
            data='xml',
            auth=ANY,
            headers={'content-type': 'application/xml'}
        )
        self.assertEqual(response, 'response')
开发者ID:cmscom,项目名称:edx-platform,代码行数:49,代码来源:test_outcomes.py

示例4: setUp

 def setUp(self):
     super(SignAndSendReplaceResultTest, self).setUp()
     self.course_key = CourseLocator(
         org='some_org',
         course='some_course',
         run='some_run'
     )
     self.usage_key = BlockUsageLocator(
         course_key=self.course_key,
         block_type='problem',
         block_id='block_id'
     )
     self.user = UserFactory.create()
     consumer = LtiConsumer(
         consumer_name='consumer',
         consumer_key='consumer_key',
         consumer_secret='secret'
     )
     consumer.save()
     outcome = OutcomeService(
         lis_outcome_service_url='http://example.com/service_url',
         lti_consumer=consumer,
     )
     outcome.save()
     self.assignment = GradedAssignment(
         user=self.user,
         course_key=self.course_key,
         usage_key=self.usage_key,
         outcome_service=outcome,
         lis_result_sourcedid='sourcedid',
     )
     self.assignment.save()
开发者ID:Kalyzee,项目名称:edx-platform,代码行数:32,代码来源:test_outcomes.py

示例5: setUp

    def setUp(self):
        super(BaseOutcomeTest, self).setUp()
        self.course_key = CourseLocator(org="some_org", course="some_course", run="some_run")
        self.usage_key = BlockUsageLocator(course_key=self.course_key, block_type="problem", block_id="block_id")
        self.user = UserFactory.create()
        self.consumer = LtiConsumer(
            consumer_name="Lti Consumer Name",
            consumer_key="consumer_key",
            consumer_secret="consumer_secret",
            instance_guid="tool_instance_guid",
        )
        self.consumer.save()
        outcome = OutcomeService(lis_outcome_service_url="http://example.com/service_url", lti_consumer=self.consumer)
        outcome.save()
        self.assignment = GradedAssignment(
            user=self.user,
            course_key=self.course_key,
            usage_key=self.usage_key,
            outcome_service=outcome,
            lis_result_sourcedid="sourcedid",
            version_number=1,
        )
        self.assignment.save()

        self.send_score_update_mock = self.setup_patch("lti_provider.outcomes.send_score_update", None)
开发者ID:johnny-nan,项目名称:edx-platform,代码行数:25,代码来源:test_tasks.py

示例6: setUp

 def setUp(self):
     super(SendOutcomeTest, self).setUp()
     self.course_key = CourseLocator(
         org='some_org',
         course='some_course',
         run='some_run'
     )
     self.usage_key = BlockUsageLocator(
         course_key=self.course_key,
         block_type='problem',
         block_id='block_id'
     )
     self.user = UserFactory.create()
     self.points_possible = 10
     self.points_earned = 3
     self.generate_xml_mock = self.setup_patch(
         'lti_provider.outcomes.generate_replace_result_xml',
         'replace result XML'
     )
     self.replace_result_mock = self.setup_patch(
         'lti_provider.outcomes.sign_and_send_replace_result',
         'replace result response'
     )
     self.check_result_mock = self.setup_patch(
         'lti_provider.outcomes.check_replace_result_response',
         True
     )
     consumer = LtiConsumer(
         consumer_name='Lti Consumer Name',
         consumer_key='consumer_key',
         consumer_secret='consumer_secret',
         instance_guid='tool_instance_guid'
     )
     consumer.save()
     outcome = OutcomeService(
         lis_outcome_service_url='http://example.com/service_url',
         lti_consumer=consumer
     )
     outcome.save()
     self.assignment = GradedAssignment(
         user=self.user,
         course_key=self.course_key,
         usage_key=self.usage_key,
         outcome_service=outcome,
         lis_result_sourcedid='sourcedid',
     )
     self.assignment.save()
开发者ID:189140879,项目名称:edx-platform,代码行数:47,代码来源:test_outcomes.py

示例7: setUp

    def setUp(self):
        super(BaseOutcomeTest, self).setUp()
        self.course_key = CourseLocator(
            org='some_org',
            course='some_course',
            run='some_run'
        )
        self.usage_key = BlockUsageLocator(
            course_key=self.course_key,
            block_type='problem',
            block_id='block_id'
        )
        self.user = UserFactory.create()
        self.consumer = LtiConsumer(
            consumer_name='Lti Consumer Name',
            consumer_key='consumer_key',
            consumer_secret='consumer_secret',
            instance_guid='tool_instance_guid'
        )
        self.consumer.save()
        outcome = OutcomeService(
            lis_outcome_service_url='http://example.com/service_url',
            lti_consumer=self.consumer
        )
        outcome.save()
        self.assignment = GradedAssignment(
            user=self.user,
            course_key=self.course_key,
            usage_key=self.usage_key,
            outcome_service=outcome,
            lis_result_sourcedid='sourcedid',
            version_number=1,
        )
        self.assignment.save()

        self.send_score_update_mock = self.setup_patch(
            'lti_provider.outcomes.send_score_update', None
        )
开发者ID:digitalsatori,项目名称:edx-platform,代码行数:38,代码来源:test_tasks.py

示例8: SendOutcomeTest

class SendOutcomeTest(TestCase):
    """
    Tests for the send_outcome method in tasks.py
    """

    def setUp(self):
        super(SendOutcomeTest, self).setUp()
        self.course_key = CourseLocator(
            org='some_org',
            course='some_course',
            run='some_run'
        )
        self.usage_key = BlockUsageLocator(
            course_key=self.course_key,
            block_type='problem',
            block_id='block_id'
        )
        self.user = UserFactory.create()
        self.points_possible = 10
        self.points_earned = 3
        self.generate_xml_mock = self.setup_patch(
            'lti_provider.outcomes.generate_replace_result_xml',
            'replace result XML'
        )
        self.replace_result_mock = self.setup_patch(
            'lti_provider.outcomes.sign_and_send_replace_result',
            'replace result response'
        )
        self.check_result_mock = self.setup_patch(
            'lti_provider.outcomes.check_replace_result_response',
            True
        )
        consumer = LtiConsumer(
            consumer_name='Lti Consumer Name',
            consumer_key='consumer_key',
            consumer_secret='consumer_secret',
            instance_guid='tool_instance_guid'
        )
        consumer.save()
        outcome = OutcomeService(
            lis_outcome_service_url='http://example.com/service_url',
            lti_consumer=consumer
        )
        outcome.save()
        self.assignment = GradedAssignment(
            user=self.user,
            course_key=self.course_key,
            usage_key=self.usage_key,
            outcome_service=outcome,
            lis_result_sourcedid='sourcedid',
        )
        self.assignment.save()

    def setup_patch(self, function_name, return_value):
        """
        Patch a method with a given return value, and return the mock
        """
        mock = MagicMock(return_value=return_value)
        new_patch = patch(function_name, new=mock)
        new_patch.start()
        self.addCleanup(new_patch.stop)
        return mock

    def test_send_outcome(self):
        tasks.send_outcome(
            self.points_possible,
            self.points_earned,
            self.user.id,
            unicode(self.course_key),
            unicode(self.usage_key)
        )
        self.generate_xml_mock.assert_called_once_with('sourcedid', 0.3)
        self.replace_result_mock.assert_called_once_with(self.assignment, 'replace result XML')
开发者ID:189140879,项目名称:edx-platform,代码行数:73,代码来源:test_outcomes.py


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