def _create_response_row(self): user_profile = UserProfile.objects.get(user__username=self.username) response_row = [unicode(x) for x in [anonymize_username(user_profile.user.username), anonymous_id_for_user(user_profile.user, self.course.id), user_profile.gender, user_profile.year_of_birth, user_profile.level_of_education]] + [OPTION_1, OPTION_2] return response_row
def fetch_user_profile_data(student_module): """ Return a list of user profile information. """ user = student_module.student user_profile = UserProfile.objects.get(user=user) data_row = [anonymize_username(user.username), unicode(user_profile.gender), unicode(user_profile.year_of_birth), unicode(user_profile.level_of_education)] return data_row
def test_user_with_no_profile(self): self._create_student_module_entry() user = User.objects.get(username=self.username) UserProfile.objects.filter(user__username=self.username).delete() self._launch_task() rows = self._read_report_file(get_path(self.running_report_name, self.problem_module.location)) expected_row = [unicode(x) for x in [ anonymize_username(self.username), anonymous_id_for_user(user, self.course.id), '', '', '' ]] + [OPTION_1, OPTION_2] self.assertEqual(rows[2], expected_row)
def test_generate_answers_distribution_report(self): self._create_student_module_entry() self._launch_task() rows = self._read_report_file(get_path(self.running_report_name, self.problem_module.location)) user_profile = UserProfile.objects.get(user__username=self.username) expected_row = [unicode(x) for x in [ anonymize_username(self.username), anonymous_id_for_user(user_profile.user, self.course.id), user_profile.gender, user_profile.year_of_birth, user_profile.level_of_education ]] + [OPTION_1, OPTION_2] self.assertEqual(rows[1], ['id', 'course_specific_id', 'gender', 'year_of_birth', 'level_of_education', 'q1', 'q2']) self.assertEqual(rows[2], expected_row)
def fetch_user_profile_data(student_module): """ Return a list of user profile information. If the user profile is not available, the relevant pieces of information are skipped. """ user = student_module.student try: user_profile = UserProfile.objects.get(user=user) except UserProfile.DoesNotExist: user_profile = None return [ anonymize_username(user.username), anonymous_id_for_user(user, student_module.course_id), unicode(user_profile.gender if user_profile else ''), unicode(user_profile.year_of_birth if user_profile else ''), unicode(user_profile.level_of_education if user_profile else '') ]
def fetch_user_profile_data(student_module): """ Return a list of user profile information. If the user profile is not available, the relevant pieces of information are skipped. """ user = student_module.student try: user_profile = UserProfile.objects.get(user=user) except UserProfile.DoesNotExist: user_profile = None return [ anonymize_username(user.username), anonymous_id_for_user(user, student_module.course_id), unicode(user_profile.gender if user_profile else ''), unicode(user_profile.year_of_birth if user_profile else ''), unicode(user_profile.level_of_education if user_profile else '') ]