當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。