From f34a1c9d11bee4e546bde5491ee14ee5be2ed275 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Mon, 22 Sep 2014 11:53:49 -0400 Subject: [PATCH] Add the 'meta' column from the UserProfile table to the CSV download add special case logic to get the 'meta' field into the downloaded CSV wip wip --- lms/djangoapps/instructor/views/api.py | 15 ++++++++++----- lms/djangoapps/instructor_analytics/basic.py | 3 ++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py index 0e31886073..a28219b5c9 100644 --- a/lms/djangoapps/instructor/views/api.py +++ b/lms/djangoapps/instructor/views/api.py @@ -692,11 +692,16 @@ def get_students_features(request, course_id, csv=False): # pylint: disable=W06 course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id) available_features = instructor_analytics.basic.AVAILABLE_FEATURES - query_features = [ - 'id', 'username', 'name', 'email', 'language', 'location', - 'year_of_birth', 'gender', 'level_of_education', 'mailing_address', - 'goals', - ] + + # Allow for microsites to be able to define additional columns (e.g. ) + query_features = microsite.get_value('student_profile_download_fields') + + if not query_features: + query_features = [ + 'id', 'username', 'name', 'email', 'language', 'location', + 'year_of_birth', 'gender', 'level_of_education', 'mailing_address', + 'goals' + ] student_data = instructor_analytics.basic.enrolled_students_features(course_id, query_features) diff --git a/lms/djangoapps/instructor_analytics/basic.py b/lms/djangoapps/instructor_analytics/basic.py index 4091db27a8..3b394a6001 100644 --- a/lms/djangoapps/instructor_analytics/basic.py +++ b/lms/djangoapps/instructor_analytics/basic.py @@ -11,7 +11,7 @@ from django.core.exceptions import ObjectDoesNotExist STUDENT_FEATURES = ('id', 'username', 'first_name', 'last_name', 'is_staff', 'email') PROFILE_FEATURES = ('name', 'language', 'location', 'year_of_birth', 'gender', - 'level_of_education', 'mailing_address', 'goals') + 'level_of_education', 'mailing_address', 'goals', 'meta') ORDER_ITEM_FEATURES = ('list_price', 'unit_cost', 'order_id') ORDER_FEATURES = ('purchase_time',) @@ -150,6 +150,7 @@ def enrolled_students_features(course_id, features): profile_dict = dict((feature, getattr(profile, feature)) for feature in profile_features) student_dict.update(profile_dict) + return student_dict return [extract_student(student, features) for student in students]