Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lms/djangoapps/instructor_analytics/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def enrolled_students_features(course_key, features):
"""
include_cohort_column = 'cohort' in features
include_team_column = 'team' in features
include_city_column = 'city' in features
include_enrollment_mode = 'enrollment_mode' in features
include_verification_status = 'verification_status' in features
include_program_enrollments = 'external_user_key' in features
Expand Down Expand Up @@ -152,6 +153,13 @@ def extract_student(student, features):
for meta_feature, meta_key in meta_features:
student_dict[meta_feature] = meta_dict.get(meta_key)

# There are two separate places where the city value can be stored,
# one used by account settings and the other used by the registration form.
# If the account settings value (meta.city) is set, it takes precedence.
meta_city = meta_dict.get('city')
if include_city_column and meta_city:
student_dict['city'] = meta_city

Comment on lines +159 to +162
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaizoku, with this change, wouldn't we have the same value in student_dict['meta.city'] (populated in the for loop above) and student_dict['city']?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lgp171188 , only if we include meta.city and city in the query features. Only "city" is configured by default, if both are manually configured, this might be an issue, but should we be handling that scenario? As it stands, end users won't have to configure any options to get the city, it will always be there. So adding meta.city to the student_profile_download_fields would in a way be a misconfiguration.

if include_cohort_column:
# Note that we use student.course_groups.all() here instead of
# student.course_groups.filter(). The latter creates a fresh query,
Expand Down