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


Python VerificationStatus.add_verification_status方法代码示例

本文整理汇总了Python中verify_student.models.VerificationStatus.add_verification_status方法的典型用法代码示例。如果您正苦于以下问题:Python VerificationStatus.add_verification_status方法的具体用法?Python VerificationStatus.add_verification_status怎么用?Python VerificationStatus.add_verification_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在verify_student.models.VerificationStatus的用法示例。


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

示例1: test_add_status_from_checkpoints

# 需要导入模块: from verify_student.models import VerificationStatus [as 别名]
# 或者: from verify_student.models.VerificationStatus import add_verification_status [as 别名]
    def test_add_status_from_checkpoints(self, status):
        """Test verification status for reverification checkpoints after
        submitting software secure photo verification.
        """

        # add initial verification status for checkpoints
        initial_status = "submitted"
        VerificationStatus.add_verification_status(
            checkpoint=self.first_checkpoint, user=self.user, status=initial_status
        )
        VerificationStatus.add_verification_status(
            checkpoint=self.second_checkpoint, user=self.user, status=initial_status
        )

        # now add verification status for multiple checkpoint points
        VerificationStatus.add_status_from_checkpoints(
            checkpoints=[self.first_checkpoint, self.second_checkpoint], user=self.user, status=status
        )

        # test that verification status entries with new status have been added
        # for both checkpoints
        result = VerificationStatus.objects.filter(user=self.user, checkpoint=self.first_checkpoint)
        self.assertEqual(len(result), len(self.first_checkpoint.checkpoint_status.all()))
        self.assertEqual(
            list(result.values_list("checkpoint__checkpoint_location", flat=True)),
            list(self.first_checkpoint.checkpoint_status.values_list("checkpoint__checkpoint_location", flat=True)),
        )

        result = VerificationStatus.objects.filter(user=self.user, checkpoint=self.second_checkpoint)
        self.assertEqual(len(result), len(self.second_checkpoint.checkpoint_status.all()))
        self.assertEqual(
            list(result.values_list("checkpoint__checkpoint_location", flat=True)),
            list(self.second_checkpoint.checkpoint_status.values_list("checkpoint__checkpoint_location", flat=True)),
        )
开发者ID:chauhanhardik,项目名称:populo,代码行数:36,代码来源:test_models.py

示例2: post

# 需要导入模块: from verify_student.models import VerificationStatus [as 别名]
# 或者: from verify_student.models.VerificationStatus import add_verification_status [as 别名]
    def post(self, request, course_id, checkpoint_name):
        """Submits the re-verification attempt to SoftwareSecure

        Args:
            request(HttpRequest): HttpRequest object
            course_id(str): Course Id
            checkpoint_name(str): Checkpoint name

        Returns:
            HttpResponse with status_code 400 if photo is missing or any error
            or redirect to verify_student_verify_later url if initial verification doesn't exist otherwise
            HttpsResponse with status code 200
        """
        # Check the in-course re-verification is enabled or not
        incourse_reverify_enabled = InCourseReverificationConfiguration.current().enabled
        if not incourse_reverify_enabled:
            raise Http404

        user = request.user
        course_key = CourseKey.from_string(course_id)
        course = modulestore().get_course(course_key)
        checkpoint = VerificationCheckpoint.get_verification_checkpoint(course_key, checkpoint_name)
        if checkpoint is None:
            log.error("Checkpoint is not defined. Could not submit verification attempt for user %s",
                      request.user.id)
            context = {
                'course_key': unicode(course_key),
                'course_name': course.display_name_with_default,
                'checkpoint_name': checkpoint_name,
                'error': True,
                'errorMsg': _("No checkpoint found"),
                'platform_name': settings.PLATFORM_NAME,
            }
            return render_to_response("verify_student/incourse_reverify.html", context)
        init_verification = SoftwareSecurePhotoVerification.get_initial_verification(user)
        if not init_verification:
            log.error("Could not submit verification attempt for user %s", request.user.id)
            return redirect(reverse('verify_student_verify_later', kwargs={'course_id': unicode(course_key)}))

        try:
            attempt = SoftwareSecurePhotoVerification.submit_faceimage(
                request.user, request.POST['face_image'], init_verification.photo_id_key
            )
            checkpoint.add_verification_attempt(attempt)
            VerificationStatus.add_verification_status(checkpoint, user, "submitted")

            # emit the reverification event
            self._track_reverification_events(
                EVENT_NAME_USER_SUBMITTED_INCOURSE_REVERIFY, user.id, course_id, checkpoint_name
            )

            return HttpResponse()
        except IndexError:
            log.exception("Invalid image data during photo verification.")
            return HttpResponseBadRequest(_("Invalid image data during photo verification."))
        except Exception:  # pylint: disable=broad-except
            log.exception("Could not submit verification attempt for user {}.").format(request.user.id)
            msg = _("Could not submit photos")
            return HttpResponseBadRequest(msg)
开发者ID:MSOpenTech,项目名称:edx-platform,代码行数:61,代码来源:views.py

示例3: test_get_user_attempts

# 需要导入模块: from verify_student.models import VerificationStatus [as 别名]
# 或者: from verify_student.models.VerificationStatus import add_verification_status [as 别名]
    def test_get_user_attempts(self):
        """
        Test adding verification status.
        """
        VerificationStatus.add_verification_status(checkpoint=self.first_checkpoint, user=self.user, status="submitted")

        actual_attempts = VerificationStatus.get_user_attempts(
            self.user.id, self.course.id, self.first_checkpoint_location
        )
        self.assertEqual(actual_attempts, 1)
开发者ID:chauhanhardik,项目名称:populo,代码行数:12,代码来源:test_models.py

示例4: test_add_verification_status

# 需要导入模块: from verify_student.models import VerificationStatus [as 别名]
# 或者: from verify_student.models.VerificationStatus import add_verification_status [as 别名]
    def test_add_verification_status(self, status):
        """ Adding verification status using the class method. """

        # adding verification status
        VerificationStatus.add_verification_status(checkpoint=self.first_checkpoint, user=self.user, status=status)

        # test the status from database
        result = VerificationStatus.objects.filter(checkpoint=self.first_checkpoint)[0]
        self.assertEqual(result.status, status)
        self.assertEqual(result.user, self.user)
开发者ID:chauhanhardik,项目名称:populo,代码行数:12,代码来源:test_models.py

示例5: test_add_verification_status

# 需要导入模块: from verify_student.models import VerificationStatus [as 别名]
# 或者: from verify_student.models.VerificationStatus import add_verification_status [as 别名]
    def test_add_verification_status(self, status):
        """adding verfication status using the class method."""

        # adding verification status
        VerificationStatus.add_verification_status(checkpoint=self.check_point1, user=self.user, status=status)

        # getting the status from db
        result = VerificationStatus.objects.filter(checkpoint=self.check_point1)[0]
        self.assertEqual(result.status, status)
        self.assertEqual(result.user, self.user)
开发者ID:Cgruppo,项目名称:edx-platform,代码行数:12,代码来源:test_models.py

示例6: test_get_user_attempts

# 需要导入模块: from verify_student.models import VerificationStatus [as 别名]
# 或者: from verify_student.models.VerificationStatus import add_verification_status [as 别名]
    def test_get_user_attempts(self):

        # adding verification status
        VerificationStatus.add_verification_status(
            checkpoint=self.check_point1,
            user=self.user,
            status='submitted',
            location_id=self.dummy_reverification_item_id_1
        )

        self.assertEqual(VerificationStatus.get_user_attempts(
            course_key=self.course.id,
            user_id=self.user.id,
            related_assessment='midterm', location_id=self.dummy_reverification_item_id_1), 1)
开发者ID:Shubhi01,项目名称:edx-platform,代码行数:16,代码来源:test_models.py

示例7: test_get_location_id

# 需要导入模块: from verify_student.models import VerificationStatus [as 别名]
# 或者: from verify_student.models.VerificationStatus import add_verification_status [as 别名]
    def test_get_location_id(self):
        """
        Getting location id for a specific checkpoint.
        """

        # creating software secure attempt against checkpoint
        self.first_checkpoint.add_verification_attempt(SoftwareSecurePhotoVerification.objects.create(user=self.user))

        # add initial verification status for checkpoint
        VerificationStatus.add_verification_status(checkpoint=self.first_checkpoint, user=self.user, status="submitted")
        attempt = SoftwareSecurePhotoVerification.objects.filter(user=self.user)

        self.assertIsNotNone(VerificationStatus.get_location_id(attempt))
        self.assertEqual(VerificationStatus.get_location_id(None), "")
开发者ID:chauhanhardik,项目名称:populo,代码行数:16,代码来源:test_models.py

示例8: test_get_user_attempts

# 需要导入模块: from verify_student.models import VerificationStatus [as 别名]
# 或者: from verify_student.models.VerificationStatus import add_verification_status [as 别名]
    def test_get_user_attempts(self):
        """
        Test adding verification status.
        """
        VerificationStatus.add_verification_status(
            checkpoint=self.first_checkpoint,
            user=self.user,
            status='submitted'
        )

        self.assertEqual(
            VerificationStatus.get_user_attempts(
                user_id=self.user.id,
                course_key=self.course.id,
                related_assessment_location=self.first_checkpoint_location
            ),
            1
        )
开发者ID:benpatterson,项目名称:edx-platform,代码行数:20,代码来源:test_models.py

示例9: test_get_location_id

# 需要导入模块: from verify_student.models import VerificationStatus [as 别名]
# 或者: from verify_student.models.VerificationStatus import add_verification_status [as 别名]
    def test_get_location_id(self):
        """ Getting location id for a specific checkpoint  """

        # creating software secure attempt against checkpoint
        self.check_point1.add_verification_attempt(SoftwareSecurePhotoVerification.objects.create(user=self.user))

        # add initial verification status for checkpoint
        VerificationStatus.add_verification_status(
            checkpoint=self.check_point1,
            user=self.user,
            status='submitted',
            location_id=self.dummy_reverification_item_id_1
        )

        attempt = SoftwareSecurePhotoVerification.objects.filter(user=self.user)

        self.assertIsNotNone(VerificationStatus.get_location_id(attempt))
        self.assertEqual(VerificationStatus.get_location_id(None), '')
开发者ID:Shubhi01,项目名称:edx-platform,代码行数:20,代码来源:test_models.py

示例10: test_add_status_from_checkpoints

# 需要导入模块: from verify_student.models import VerificationStatus [as 别名]
# 或者: from verify_student.models.VerificationStatus import add_verification_status [as 别名]
    def test_add_status_from_checkpoints(self, status):
        """ Adding verification status for checkpoints list after submitting sspv. """

        # add initial verification status for checkpoints
        initial_status = "submitted"
        VerificationStatus.add_verification_status(
            checkpoint=self.check_point1,
            user=self.user,
            status=initial_status,
            location_id=self.dummy_reverification_item_id_1
        )
        VerificationStatus.add_verification_status(
            checkpoint=self.check_point2,
            user=self.user,
            status=initial_status,
            location_id=self.dummy_reverification_item_id_2
        )

        # now add verification status for multiple checkpoint points
        VerificationStatus.add_status_from_checkpoints(
            checkpoints=[self.check_point1, self.check_point2], user=self.user, status=status
        )

        # test that verification status entries with new status have been added
        # for both checkpoints and all entries have related 'location_id'.
        result = VerificationStatus.objects.filter(user=self.user, checkpoint=self.check_point1)
        self.assertEqual(len(result), len(self.check_point1.checkpoint_status.all()))
        self.assertEqual(
            list(result.values_list('location_id', flat=True)),
            list(self.check_point1.checkpoint_status.all().values_list('location_id', flat=True))
        )
        result = VerificationStatus.objects.filter(user=self.user, checkpoint=self.check_point2)
        self.assertEqual(len(result), len(self.check_point2.checkpoint_status.all()))
        self.assertEqual(
            list(result.values_list('location_id', flat=True)),
            list(self.check_point2.checkpoint_status.all().values_list('location_id', flat=True))
        )
开发者ID:escolaglobal,项目名称:edx-platform,代码行数:39,代码来源:test_models.py

示例11: post

# 需要导入模块: from verify_student.models import VerificationStatus [as 别名]
# 或者: from verify_student.models.VerificationStatus import add_verification_status [as 别名]
    def post(self, request, course_id, usage_id):
        """Submits the re-verification attempt to SoftwareSecure.

        Args:
            request(HttpRequest): HttpRequest object
            course_id(str): Course Id
            usage_id(str): Location of Reverification XBlock in courseware

        Returns:
            HttpResponse with status_code 400 if photo is missing or any error
            or redirect to the verification flow if initial verification
            doesn't exist otherwise HttpResponse with status code 200
        """
        # Check the in-course re-verification is enabled or not
        incourse_reverify_enabled = InCourseReverificationConfiguration.current().enabled
        if not incourse_reverify_enabled:
            raise Http404

        user = request.user
        try:
            course_key = CourseKey.from_string(course_id)
            usage_key = UsageKey.from_string(usage_id).replace(course_key=course_key)
        except InvalidKeyError:
            raise Http404(u"Invalid course_key or usage_key")

        course = modulestore().get_course(course_key)
        if course is None:
            log.error(u"Invalid course id '%s'", course_id)
            return HttpResponseBadRequest(_("Invalid course location."))

        checkpoint = VerificationCheckpoint.get_verification_checkpoint(course_key, usage_id)
        if checkpoint is None:
            log.error(
                u"Checkpoint is not defined. Could not submit verification attempt"
                u" for user '%s', course '%s' and checkpoint location '%s'.",
                request.user.id, course_key, usage_id
            )
            return HttpResponseBadRequest(_("Invalid checkpoint location."))

        init_verification = SoftwareSecurePhotoVerification.get_initial_verification(user)
        if not init_verification:
            return self._redirect_no_initial_verification(user, course_key)

        try:
            attempt = SoftwareSecurePhotoVerification.submit_faceimage(
                request.user, request.POST['face_image'], init_verification.photo_id_key
            )
            checkpoint.add_verification_attempt(attempt)
            VerificationStatus.add_verification_status(checkpoint, user, "submitted")

            # emit the reverification event
            self._track_reverification_events(
                'edx.bi.reverify.submitted',
                user.id, course_id, checkpoint.checkpoint_name
            )

            redirect_url = get_redirect_url(course_key, usage_key)
            response = JsonResponse({'url': redirect_url})

        except (ItemNotFoundError, NoPathToItem):
            log.warning(u"Could not find redirect URL for location %s in course %s", course_key, usage_key)
            redirect_url = reverse("courseware", args=(unicode(course_key),))
            response = JsonResponse({'url': redirect_url})

        except Http404 as expt:
            log.exception("Invalid location during photo verification.")
            response = HttpResponseBadRequest(expt.message)

        except IndexError:
            log.exception("Invalid image data during photo verification.")
            response = HttpResponseBadRequest(_("Invalid image data during photo verification."))

        except Exception:  # pylint: disable=broad-except
            log.exception("Could not submit verification attempt for user %s.", request.user.id)
            msg = _("Could not submit photos")
            response = HttpResponseBadRequest(msg)

        return response
开发者ID:mushtaqak,项目名称:edx-platform,代码行数:80,代码来源:views.py


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