-
Notifications
You must be signed in to change notification settings - Fork 92
Open
Description
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 = NoneLocation 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-proctoringviaOPENEDX_EXTRA_PIP_REQUIREMENTS - Enable timed exams with the
nullproctoring backend - Do NOT enable
ENABLE_CREDIT_ELIGIBILITYor 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.
Metadata
Metadata
Assignees
Labels
No labels