Skip to content

Commit cb4125e

Browse files
MCKIN-12600 key error on filtering username (#326)
1 parent dfc9136 commit cb4125e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

problem_builder/tasks.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,17 @@ def _extract_data(course_key_str, block, user_id, match_string):
116116
# - Get all of the most recent student submissions for this block:
117117
submissions = tuple(_get_submissions(course_key_str, block, user_id))
118118

119-
student_ids = [submission['student_id'] for submission in submissions]
119+
# If the student ID key doesn't exist, we're dealing with a single student and know the ID already.
120+
student_ids = [submission.get('student_id', user_id) for submission in submissions]
120121
users = get_users_by_anonymous_ids(student_ids)
121122

122123
# - For each submission, look up student's username, email and answer:
123124
answer_cache = {}
124125
for submission in submissions:
126+
student_id = submission.get('student_id', user_id)
125127
username, _user_id, user_email = users.get(
126-
submission['student_id'],
127-
(submission['student_id'], 'N/A', 'N/A')
128+
student_id,
129+
(student_id, 'N/A', 'N/A')
128130
)
129131
answer = _get_answer(block, submission, answer_cache)
130132

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
# Constants #########################################################
3030

31-
VERSION = '4.1.11'
31+
VERSION = '4.1.12'
3232

3333
# Functions #########################################################
3434

0 commit comments

Comments
 (0)