本文整理匯總了Python中verify_student.models.VerificationStatus.get_user_attempts方法的典型用法代碼示例。如果您正苦於以下問題:Python VerificationStatus.get_user_attempts方法的具體用法?Python VerificationStatus.get_user_attempts怎麽用?Python VerificationStatus.get_user_attempts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類verify_student.models.VerificationStatus
的用法示例。
在下文中一共展示了VerificationStatus.get_user_attempts方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_get_user_attempts
# 需要導入模塊: from verify_student.models import VerificationStatus [as 別名]
# 或者: from verify_student.models.VerificationStatus import get_user_attempts [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)
示例2: get_attempts
# 需要導入模塊: from verify_student.models import VerificationStatus [as 別名]
# 或者: from verify_student.models.VerificationStatus import get_user_attempts [as 別名]
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)
示例3: test_get_user_attempts
# 需要導入模塊: from verify_student.models import VerificationStatus [as 別名]
# 或者: from verify_student.models.VerificationStatus import get_user_attempts [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)
示例4: test_get_user_attempts
# 需要導入模塊: from verify_student.models import VerificationStatus [as 別名]
# 或者: from verify_student.models.VerificationStatus import get_user_attempts [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
)
示例5: _compose_message_reverification_email
# 需要導入模塊: from verify_student.models import VerificationStatus [as 別名]
# 或者: from verify_student.models.VerificationStatus import get_user_attempts [as 別名]
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)