コード例 #1
0
ファイル: test_models.py プロジェクト: chauhanhardik/populo
    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)
コード例 #2
0
    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)
コード例 #3
0
    def get_attempts(self, user_id, course_id, related_assessment_location):
        """Get re-verification attempts 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:
            Number of re-verification attempts of a user
        """
        course_key = CourseKey.from_string(course_id)
        return VerificationStatus.get_user_attempts(user_id, course_key, related_assessment_location)
コード例 #4
0
ファイル: test_models.py プロジェクト: echines/edx-platform
    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)
コード例 #5
0
ファイル: test_models.py プロジェクト: Shubhi01/edx-platform
    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)
コード例 #6
0
    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)
コード例 #7
0
    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
        )
コード例 #8
0
ファイル: views.py プロジェクト: mushtaqak/edx-platform
def _compose_message_reverification_email(
        course_key, user_id, related_assessment_location, status, request
):  # pylint: disable=invalid-name
    """
    Compose subject and message for photo reverification email.

    Args:
        course_key(CourseKey): CourseKey object
        user_id(str): User Id
        related_assessment_location(str): Location of reverification XBlock
        photo_verification(QuerySet): Queryset of SoftwareSecure objects
        status(str): Approval status
        is_secure(Bool): Is running on secure protocol or not

    Returns:
        None if any error occurred else Tuple of subject and message strings
    """
    try:
        usage_key = UsageKey.from_string(related_assessment_location)
        reverification_block = modulestore().get_item(usage_key)

        course = modulestore().get_course(course_key)
        redirect_url = get_redirect_url(course_key, usage_key.replace(course_key=course_key))

        subject = "Re-verification Status"
        context = {
            "status": status,
            "course_name": course.display_name_with_default,
            "assessment": reverification_block.related_assessment
        }

        # Allowed attempts is 1 if not set on verification block
        allowed_attempts = reverification_block.attempts + 1
        used_attempts = VerificationStatus.get_user_attempts(user_id, course_key, related_assessment_location)
        left_attempts = allowed_attempts - used_attempts
        is_attempt_allowed = left_attempts > 0
        verification_open = True
        if reverification_block.due:
            verification_open = timezone.now() <= reverification_block.due

        context["left_attempts"] = left_attempts
        context["is_attempt_allowed"] = is_attempt_allowed
        context["verification_open"] = verification_open
        context["due_date"] = get_default_time_display(reverification_block.due)

        context['platform_name'] = settings.PLATFORM_NAME
        context["used_attempts"] = used_attempts
        context["allowed_attempts"] = allowed_attempts
        context["support_link"] = microsite.get_value('email_from_address', settings.CONTACT_EMAIL)

        re_verification_link = reverse(
            'verify_student_incourse_reverify',
            args=(
                unicode(course_key),
                related_assessment_location
            )
        )

        context["course_link"] = request.build_absolute_uri(redirect_url)
        context["reverify_link"] = request.build_absolute_uri(re_verification_link)

        message = render_to_string('emails/reverification_processed.txt', context)
        log.info(
            "Sending email to User_Id=%s. Attempts left for this user are %s. "
            "Allowed attempts %s. "
            "Due Date %s",
            str(user_id), left_attempts, allowed_attempts, str(reverification_block.due)
        )
        return subject, message
    # Catch all exception to avoid raising back to view
    except:  # pylint: disable=bare-except
        log.exception("The email for re-verification sending failed for user_id %s", user_id)