Commit 4c79a376 by Sven Marnach

Handle unresolvable anonymous ids gracefully.

parent efe6f231
...@@ -178,10 +178,16 @@ def _get_submissions(course_key_str, block, user_id): ...@@ -178,10 +178,16 @@ def _get_submissions(course_key_str, block, user_id):
def _get_username(submission, user_id): def _get_username(submission, user_id):
""" """
Return username of student who provided `submission`. Return username of student who provided `submission`.
If the anonymous id of the submission can't be resolved into a username, the anonymous
id is returned.
""" """
# If the student ID key doesn't exist, we're dealing with a single student and know the ID already. # If the student ID key doesn't exist, we're dealing with a single student and know the ID already.
student_id = submission.get('student_id', user_id) student_id = submission.get('student_id', user_id)
return user_by_anonymous_id(student_id).username user = user_by_anonymous_id(student_id)
if user is None:
return student_id
return user.username
def _get_answer(block, submission, answer_cache): def _get_answer(block, submission, answer_cache):
......
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