Merge pull request #7775 from edx/will/verification-logging
Add logging for verification and reverification.
This commit is contained in:
@@ -806,6 +806,8 @@ def submit_photos_for_verification(request):
|
||||
attempt.mark_ready()
|
||||
attempt.submit()
|
||||
|
||||
log.info(u"Submitted initial verification attempt for user %s", request.user.id)
|
||||
|
||||
account_settings = get_account_settings(request.user)
|
||||
|
||||
# Send a confirmation email to the user
|
||||
@@ -1121,21 +1123,32 @@ class InCourseReverifyView(View):
|
||||
|
||||
incourse_reverify_enabled = InCourseReverificationConfiguration.current().enabled
|
||||
if not incourse_reverify_enabled:
|
||||
log.error(
|
||||
u"In-course reverification is not enabled. "
|
||||
u"You can enable it in Django admin by setting "
|
||||
u"InCourseReverificationConfiguration to enabled."
|
||||
)
|
||||
raise Http404
|
||||
|
||||
user = request.user
|
||||
course_key = CourseKey.from_string(course_id)
|
||||
course = modulestore().get_course(course_key)
|
||||
if course is None:
|
||||
log.error(u"Could not find course %s for in-course reverification.", course_key)
|
||||
raise Http404
|
||||
|
||||
checkpoint = VerificationCheckpoint.get_verification_checkpoint(course_key, checkpoint_name)
|
||||
if checkpoint is None:
|
||||
log.error(
|
||||
u"No verification checkpoint exists for the "
|
||||
u"course %s and checkpoint name %s.",
|
||||
course_key, checkpoint_name
|
||||
)
|
||||
raise Http404
|
||||
|
||||
init_verification = SoftwareSecurePhotoVerification.get_initial_verification(user)
|
||||
if not init_verification:
|
||||
return redirect(reverse('verify_student_verify_later', kwargs={'course_id': unicode(course_key)}))
|
||||
return self._redirect_no_initial_verification(user, course_key)
|
||||
|
||||
# emit the reverification event
|
||||
self._track_reverification_events(
|
||||
@@ -1176,6 +1189,7 @@ class InCourseReverifyView(View):
|
||||
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)
|
||||
checkpoint = VerificationCheckpoint.get_verification_checkpoint(course_key, checkpoint_name)
|
||||
if checkpoint is None:
|
||||
@@ -1191,10 +1205,10 @@ class InCourseReverifyView(View):
|
||||
'usage_id': usage_id
|
||||
}
|
||||
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)}))
|
||||
return self._redirect_no_initial_verification(user, course_key)
|
||||
|
||||
try:
|
||||
attempt = SoftwareSecurePhotoVerification.submit_faceimage(
|
||||
@@ -1211,6 +1225,10 @@ class InCourseReverifyView(View):
|
||||
try:
|
||||
redirect_url = get_redirect_url(course_key, usage_key)
|
||||
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),))
|
||||
|
||||
return JsonResponse({'url': redirect_url})
|
||||
@@ -1236,6 +1254,11 @@ class InCourseReverifyView(View):
|
||||
None
|
||||
|
||||
"""
|
||||
log.info(
|
||||
u"In-course reverification: event %s occurred for user %s in course %s at checkpoint %s",
|
||||
event_name, user_id, course_id, checkpoint
|
||||
)
|
||||
|
||||
if settings.FEATURES.get('SEGMENT_IO_LMS') and hasattr(settings, 'SEGMENT_IO_LMS_KEY'):
|
||||
tracking_context = tracker.get_tracker().resolve_context()
|
||||
analytics.track(
|
||||
@@ -1252,3 +1275,29 @@ class InCourseReverifyView(View):
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
def _redirect_no_initial_verification(self, user, course_key):
|
||||
"""Redirect because the user does not have an initial verification.
|
||||
|
||||
NOTE: currently, we assume that courses are configured such that
|
||||
the first re-verification always occurs AFTER the initial verification
|
||||
deadline. Later, we may want to allow users to upgrade to a verified
|
||||
track, then submit an initial verification that also counts
|
||||
as a verification for the checkpoint in the course.
|
||||
|
||||
Arguments:
|
||||
user (User): The user who made the request.
|
||||
course_key (CourseKey): The identifier for the course for which
|
||||
the user is attempting to re-verify.
|
||||
|
||||
Returns:
|
||||
HttpResponse
|
||||
|
||||
"""
|
||||
log.warning(
|
||||
u"User %s does not have an initial verification, so "
|
||||
u"he/she will be redirected to the \"verify later\" flow "
|
||||
u"for the course %s.",
|
||||
user.id, course_key
|
||||
)
|
||||
return redirect(reverse('verify_student_verify_later', kwargs={'course_id': unicode(course_key)}))
|
||||
|
||||
Reference in New Issue
Block a user