Commit 91fb2874 by muzaffaryousaf

Minor code refactoring after PR review.

TNL-836
parent e3fe2cbf
...@@ -224,7 +224,7 @@ class OpenAssessmentBlock( ...@@ -224,7 +224,7 @@ class OpenAssessmentBlock(
See also: submissions.api for details. See also: submissions.api for details.
Args: Args:
anonymous_user_id(str): anonymous_user_id(str): A unique anonymous_user_id for (user, course) pair.
Returns: Returns:
(dict): The student item associated with this XBlock instance. This (dict): The student item associated with this XBlock instance. This
includes the student id, item id, and course id. includes the student id, item id, and course id.
......
...@@ -234,33 +234,36 @@ class StaffInfoMixin(object): ...@@ -234,33 +234,36 @@ class StaffInfoMixin(object):
submission_uuid = None submission_uuid = None
submission = None submission = None
assessment_steps = self.assessment_steps assessment_steps = self.assessment_steps
anonymous_user_id = None
submissions = None
student_item = None
if student_username: if student_username:
anonymous_user_id = self.get_anonymous_user_id(student_username, self.course_id) anonymous_user_id = self.get_anonymous_user_id(student_username, self.course_id)
student_item = self.get_student_item_dict(anonymous_user_id=anonymous_user_id) student_item = self.get_student_item_dict(anonymous_user_id=anonymous_user_id)
if anonymous_user_id: if anonymous_user_id:
# If there is a submission available for the requested student, present # If there is a submission available for the requested student, present
# it. If not, there will be no other information to collect. # it. If not, there will be no other information to collect.
submissions = submission_api.get_submissions(student_item, 1) submissions = submission_api.get_submissions(student_item, 1)
if submissions: if submissions:
submission_uuid = submissions[0]['uuid'] submission_uuid = submissions[0]['uuid']
submission = submissions[0] submission = submissions[0]
if 'file_key' in submission.get('answer', {}): if 'file_key' in submission.get('answer', {}):
file_key = submission['answer']['file_key'] file_key = submission['answer']['file_key']
try: try:
submission['image_url'] = file_api.get_download_url(file_key) submission['image_url'] = file_api.get_download_url(file_key)
except file_api.FileUploadError: except file_api.FileUploadError:
# Log the error, but do not prevent the rest of the student info # Log the error, but do not prevent the rest of the student info
# from being displayed. # from being displayed.
msg = ( msg = (
u"Could not retrieve image URL for staff debug page. " u"Could not retrieve image URL for staff debug page. "
u"The student username is '{student_username}', and the file key is {file_key}" u"The student username is '{student_username}', and the file key is {file_key}"
).format(student_username=student_username, file_key=file_key) ).format(student_username=student_username, file_key=file_key)
logger.exception(msg) logger.exception(msg)
example_based_assessment = None example_based_assessment = None
self_assessment = None self_assessment = None
......
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