Summary
Two locations in edx_proctoring/api.py call methods on credit_service without checking if it's None, causing crashes when the credit service is
not available. This is common in Tutor deployments that don't have credit eligibility enabled.
Affected Code
Location 1: Line ~1648 in update_attempt_status()
# call service to get course name.
credit_service = get_runtime_service('credit')
credit_state = credit_service.get_credit_state( # <-- crashes if credit_service is None
exam_attempt_obj.user_id,
exam_attempt_obj.proctored_exam.course_id,
return_course_info=True
)
Error:
AttributeError: 'NoneType' object has no attribute 'get_credit_state'
Location 2: Line ~1517 in update_attempt_status()
credit_service = get_runtime_service('credit')
# ... status logic ...
credit_service.set_credit_requirement_status( # <-- crashes if credit_service is None
user_id=exam_attempt_obj.user_id,
course_key_or_id=exam['course_id'],
req_namespace='proctored_exam',
req_name=exam_attempt_obj.proctored_exam.content_id,
status=credit_requirement_status
)
Error:
AttributeError: 'NoneType' object has no attribute 'set_credit_requirement_status'
Suggested Fix
Location 1:
credit_service = get_runtime_service('credit')
if credit_service:
credit_state = credit_service.get_credit_state(
exam_attempt_obj.user_id,
exam_attempt_obj.proctored_exam.course_id,
return_course_info=True
)
else:
credit_state = None
Location 2:
if credit_service:
credit_service.set_credit_requirement_status(
user_id=exam_attempt_obj.user_id,
course_key_or_id=exam['course_id'],
req_namespace='proctored_exam',
req_name=exam_attempt_obj.proctored_exam.content_id,
status=credit_requirement_status
)
Environment
- Tutor version: 21.0.0
- Open edX release: Sumac
- edx-proctoring: Installed via
OPENEDX_EXTRA_PIP_REQUIREMENTS
- Exam type: Timed exams (non-proctored)
- Proctoring backend:
null
Steps to Reproduce
- Deploy Open edX using Tutor 21
- Install
edx-proctoring via OPENEDX_EXTRA_PIP_REQUIREMENTS
- Enable timed exams with the
null proctoring backend
- Do NOT enable
ENABLE_CREDIT_ELIGIBILITY or configure the credit service
- Create a timed exam in Studio
- As a student, attempt to start or submit the timed exam
- Observe the 500 error
Impact
Students cannot start or submit timed exams when the credit service is not configured, even though credit functionality is not needed for basic timed
exams.
Notes
Other parts of the codebase already follow the pattern of checking if credit_service: before calling methods. These two locations appear to have bee
n missed.
Summary
Two locations in
edx_proctoring/api.pycall methods oncredit_servicewithout checking if it'sNone, causing crashes when the credit service isnot available. This is common in Tutor deployments that don't have credit eligibility enabled.
Affected Code
Location 1: Line ~1648 in
update_attempt_status()Error:
Location 2: Line ~1517 in
update_attempt_status()Error:
Suggested Fix
Location 1:
Location 2:
Environment
OPENEDX_EXTRA_PIP_REQUIREMENTSnullSteps to Reproduce
edx-proctoringviaOPENEDX_EXTRA_PIP_REQUIREMENTSnullproctoring backendENABLE_CREDIT_ELIGIBILITYor configure the credit serviceImpact
Students cannot start or submit timed exams when the credit service is not configured, even though credit functionality is not needed for basic timed
exams.
Notes
Other parts of the codebase already follow the pattern of checking
if credit_service:before calling methods. These two locations appear to have been missed.