Commit cafc15cf by cahrens Committed by Matt Drayer

Move city and country fields to the very end.

OSPR-1155
parent 4bdeaf76
...@@ -2525,6 +2525,9 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment ...@@ -2525,6 +2525,9 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment
Test that some minimum of information is formatted Test that some minimum of information is formatted
correctly in the response to get_students_features. correctly in the response to get_students_features.
""" """
for student in self.students:
student.profile.city = "Mos Eisley {}".format(student.id)
student.profile.save()
url = reverse('get_students_features', kwargs={'course_id': self.course.id.to_deprecated_string()}) url = reverse('get_students_features', kwargs={'course_id': self.course.id.to_deprecated_string()})
response = self.client.get(url, {}) response = self.client.get(url, {})
res_json = json.loads(response.content) res_json = json.loads(response.content)
...@@ -2536,6 +2539,8 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment ...@@ -2536,6 +2539,8 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment
][0] ][0]
self.assertEqual(student_json['username'], student.username) self.assertEqual(student_json['username'], student.username)
self.assertEqual(student_json['email'], student.email) self.assertEqual(student_json['email'], student.email)
self.assertEqual(student_json['city'], student.profile.city)
self.assertEqual(student_json['country'], "")
@ddt.data(True, False) @ddt.data(True, False)
def test_get_students_features_cohorted(self, is_cohorted): def test_get_students_features_cohorted(self, is_cohorted):
......
...@@ -1245,7 +1245,7 @@ def get_students_features(request, course_id, csv=False): # pylint: disable=red ...@@ -1245,7 +1245,7 @@ def get_students_features(request, course_id, csv=False): # pylint: disable=red
query_features = [ query_features = [
'id', 'username', 'name', 'email', 'language', 'location', 'id', 'username', 'name', 'email', 'language', 'location',
'year_of_birth', 'gender', 'level_of_education', 'mailing_address', 'year_of_birth', 'gender', 'level_of_education', 'mailing_address',
'goals', 'city', 'country' 'goals',
] ]
# Provide human-friendly and translatable names for these features. These names # Provide human-friendly and translatable names for these features. These names
...@@ -1263,8 +1263,6 @@ def get_students_features(request, course_id, csv=False): # pylint: disable=red ...@@ -1263,8 +1263,6 @@ def get_students_features(request, course_id, csv=False): # pylint: disable=red
'level_of_education': _('Level of Education'), 'level_of_education': _('Level of Education'),
'mailing_address': _('Mailing Address'), 'mailing_address': _('Mailing Address'),
'goals': _('Goals'), 'goals': _('Goals'),
'city': _('City'),
'country': _('Country'),
} }
if is_course_cohorted(course.id): if is_course_cohorted(course.id):
...@@ -1276,6 +1274,12 @@ def get_students_features(request, course_id, csv=False): # pylint: disable=red ...@@ -1276,6 +1274,12 @@ def get_students_features(request, course_id, csv=False): # pylint: disable=red
query_features.append('team') query_features.append('team')
query_features_names['team'] = _('Team') query_features_names['team'] = _('Team')
# For compatibility reasons, city and country should always appear last.
query_features.append('city')
query_features_names['city'] = _('City')
query_features.append('country')
query_features_names['country'] = _('Country')
if not csv: if not csv:
student_data = instructor_analytics.basic.enrolled_students_features(course_key, query_features) student_data = instructor_analytics.basic.enrolled_students_features(course_key, query_features)
response_payload = { response_payload = {
......
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