Exemplo n.º 1
0
    def get_status(self, user_id, course_id, related_assessment):
        """ Check if the user has any verification attempt or has skipped the verification

        Args:
            user_id(str): User Id string
            course_id(str): A string of course_id
            related_assessment(str): Verification checkpoint name

        Returns:
            "skipped" if has skip the re-verification or Verification Status string if
            any attempt submitted by user else None
        """
        course_key = CourseKey.from_string(course_id)
        has_skipped = SkippedReverification.check_user_skipped_reverification_exists(user_id, course_key)
        if has_skipped:
            return "skipped"
        try:
            checkpoint_status = VerificationStatus.objects.filter(
                user_id=user_id,
                checkpoint__course_id=course_key,
                checkpoint__checkpoint_name=related_assessment
            ).latest()
            return checkpoint_status.status
        except ObjectDoesNotExist:
            return None
Exemplo n.º 2
0
    def get_status(self, user_id, course_id, related_assessment_location):
        """Get verification attempt status against a user for a given
        'checkpoint' and 'course_id'.

        Args:
            user_id (str): User Id string
            course_id (str): A string of course id
            related_assessment_location (str): Location of Reverification XBlock

        Returns: str or None
        """
        user = User.objects.get(id=user_id)
        course_key = CourseKey.from_string(course_id)

        if not CourseEnrollment.is_enrolled_as_verified(user, course_key):
            return self.NON_VERIFIED_TRACK
        elif SkippedReverification.check_user_skipped_reverification_exists(user_id, course_key):
            return self.SKIPPED_STATUS

        try:
            checkpoint_status = VerificationStatus.objects.filter(
                user_id=user_id,
                checkpoint__course_id=course_key,
                checkpoint__checkpoint_location=related_assessment_location
            ).latest()
            return checkpoint_status.status
        except ObjectDoesNotExist:
            return None
Exemplo n.º 3
0
    def test_check_user_skipped_reverification_exists(self):
        """Checking check_user_skipped_reverification_exists method returns boolean status"""

        # adding verification status
        SkippedReverification.add_skipped_reverification_attempt(
            checkpoint=self.checkpoint, user_id=self.user.id, course_id=unicode(self.course.id)
        )

        self.assertTrue(
            SkippedReverification.check_user_skipped_reverification_exists(course_id=self.course.id, user=self.user)
        )

        user2 = UserFactory.create()
        self.assertFalse(
            SkippedReverification.check_user_skipped_reverification_exists(course_id=self.course.id, user=user2)
        )
Exemplo n.º 4
0
    def test_check_user_skipped_reverification_exists(self):
        """
        Test the 'check_user_skipped_reverification_exists' method's response.
        """
        # add verification status
        SkippedReverification.add_skipped_reverification_attempt(
            checkpoint=self.checkpoint, user_id=self.user.id, course_id=unicode(self.course.id)
        )
        self.assertTrue(
            SkippedReverification.check_user_skipped_reverification_exists(course_id=self.course.id, user=self.user)
        )

        user2 = UserFactory.create()
        self.assertFalse(
            SkippedReverification.check_user_skipped_reverification_exists(course_id=self.course.id, user=user2)
        )
Exemplo n.º 5
0
    def get_status(self, user_id, course_id, related_assessment_location):
        """Get verification attempt status against a user for a given
        'checkpoint' and 'course_id'.

        Args:
            user_id(str): User Id string
            course_id(str): A string of course id
            related_assessment_location(str): Location of Reverification XBlock

        Returns:
            "skipped" if the user has skipped the re-verification or
            Verification Status string if the user has submitted photo
            verification attempt else None
        """
        course_key = CourseKey.from_string(course_id)
        has_skipped = SkippedReverification.check_user_skipped_reverification_exists(user_id, course_key)
        if has_skipped:
            return "skipped"
        try:
            checkpoint_status = VerificationStatus.objects.filter(
                user_id=user_id,
                checkpoint__course_id=course_key,
                checkpoint__checkpoint_location=related_assessment_location
            ).latest()
            return checkpoint_status.status
        except ObjectDoesNotExist:
            return None
Exemplo n.º 6
0
    def test_check_user_skipped_reverification_exists(self):
        """Checking check_user_skipped_reverification_exists method returns boolean status"""

        # adding verification status
        SkippedReverification.add_skipped_reverification_attempt(
            checkpoint=self.checkpoint, user_id=self.user.id, course_id=unicode(self.course.id)
        )

        self.assertTrue(
            SkippedReverification.check_user_skipped_reverification_exists(course_id=self.course.id, user=self.user)
        )

        user2 = UserFactory.create()
        self.assertFalse(
            SkippedReverification.check_user_skipped_reverification_exists(course_id=self.course.id, user=user2)
        )