Commit 2e0945a5 by Ibrahim

send student email conditionally to software secure

parent d5d52a3e
......@@ -557,11 +557,13 @@ def create_exam_attempt(exam_id, user_id, taking_as_proctored=False):
# get the name of the user, if the service is available
full_name = None
email = None
credit_service = get_runtime_service('credit')
if credit_service:
credit_state = credit_service.get_credit_state(user_id, exam['course_id'])
full_name = credit_state['profile_fullname']
email = credit_state['student_email']
context = {
'time_limit_mins': allowed_time_limit_mins,
......@@ -569,6 +571,7 @@ def create_exam_attempt(exam_id, user_id, taking_as_proctored=False):
'is_sample_attempt': exam['is_practice_exam'],
'callback_url': callback_url,
'full_name': full_name,
'email': email
}
# see if there is an exam review policy for this exam
......
......@@ -47,7 +47,8 @@ class SoftwareSecureBackendProvider(ProctoringBackendProvider):
"""
def __init__(self, organization, exam_sponsor, exam_register_endpoint,
secret_key_id, secret_key, crypto_key, software_download_url):
secret_key_id, secret_key, crypto_key, software_download_url,
send_email=False):
"""
Class initializer
"""
......@@ -60,6 +61,7 @@ class SoftwareSecureBackendProvider(ProctoringBackendProvider):
self.crypto_key = crypto_key
self.timeout = 10
self.software_download_url = software_download_url
self.send_email = send_email
self.passing_review_status = ['Clean', 'Rules Violation']
self.failing_review_status = ['Not Reviewed', 'Suspicious']
......@@ -392,6 +394,18 @@ class SoftwareSecureBackendProvider(ProctoringBackendProvider):
if not exam_name:
exam_name = 'Proctored Exam'
org_extra = {
"examStartDate": start_time_str,
"examEndDate": end_time_str,
"noOfStudents": 1,
"examID": exam['id'],
"courseID": exam['course_id'],
"firstName": first_name,
"lastName": last_name
}
if self.send_email:
org_extra["email"] = context['email']
return {
"examCode": attempt_code,
"organization": self.organization,
......@@ -406,15 +420,7 @@ class SoftwareSecureBackendProvider(ProctoringBackendProvider):
"ssiProduct": 'rp-now',
# need to pass in a URL to the LMS?
"examUrl": callback_url,
"orgExtra": {
"examStartDate": start_time_str,
"examEndDate": end_time_str,
"noOfStudents": 1,
"examID": exam['id'],
"courseID": exam['course_id'],
"firstName": first_name,
"lastName": last_name,
}
"orgExtra": org_extra
}
def _header_string(self, headers, date):
......
......@@ -84,7 +84,8 @@ def mock_response_error(url, request): # pylint: disable=unused-argument
"exam_register_endpoint": "http://test",
"organization": "edx",
"exam_sponsor": "edX LMS",
"software_download_url": "http://example.com"
"software_download_url": "http://example.com",
"send_email": True
}
}
)
......
......@@ -18,7 +18,7 @@ class MockCreditService(object):
"""
def __init__(self, enrollment_mode='verified', profile_fullname='Wolfgang von Strucker',
course_name='edx demo'):
course_name='edx demo', student_email='foo@bar'):
"""
Initializer
"""
......@@ -27,6 +27,7 @@ class MockCreditService(object):
'course_name': course_name,
'enrollment_mode': enrollment_mode,
'profile_fullname': profile_fullname,
'student_email': student_email,
'credit_requirement_status': []
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment