"generate a CSV file of all students enrolled in this course", NOT WORKING

I am using TUTOR verison 11.07.

Hello, i got mulitple courses where i am not able to download information on enrolled learnes.
I am howewer able to download csv of UNENROLLED. which is like 4 users .

*The courses have under 40 USERS enrolled, so it should not take long to generate either.

*also when i try the “simpler” option og “List enrolled students profile information” button, the respose in the request header is 400 "User has no profile."
image

I see in the logs metnion USER 4, but i am not able to understand how i am supposed to find that user.

It do not want to unenroll and enroll all users, as then everyone would loose hteir progress?
and the already enrolled users would get spammed again with “enrolled” notfication ( because i would add new users also, and as long as i am not able to get current users, i can not differenciate between the)

Errorlog under includes things like “User has no profile.”

ERRORLOG: 

    lms_1            | 2021-01-25 15: 46: 45,
741 WARNING 6 [lms.djangoapps.instructor_task.api_helper
] [user 4
] [ip 81.166.83.112
] api_helper.py: 90 - No duplicate tasks found: task_type profile_info_csv, task_key , and most recent task_i
d = 18
lms-worker_1     | 2021-01-25 15: 46: 45,
771 INFO 1 [celery.worker.strategy
] [user None
] [ip None
] strategy.py: 157 - Received task: lms.djangoapps.instructor_task.tasks.calculate_students_features_csv[d5d2d6c9-cc3d-4488-960c-0a15b235
626b
]  
nginx_1          | 172.18.0.7 - - [
    25/Jan/2021: 15: 46: 45 +0000
] http: //himoldeonline.no "POST /courses/course-v1:HiMolde+MOR100+2020_T1/instructor/api/get_students_features/csv HTTP/1.1" 200 130 "https://himoldeonline.no/courses/cou
rse-v1:HiMolde+MOR100+2020_T1/instructor" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" "81.166.83.112"
lms_1            | [pid: 6|app: 0|req: 8647/32054
] 172.18.0.13 () {
    60 vars in 2084 bytes
} [Mon Jan 25 15: 46: 45 2021
] POST /courses/course-v1:HiMolde+MOR100+2020_T1/instructor/api/get_students_features/csv => generated 130 bytes in 
112 msecs (HTTP/1.0 200) 9 headers in 589 bytes (1 switches on core 0)
lms-worker_1     | 2021-01-25 15: 46: 45,
807 INFO 38 [edx.celery.task
] [user None
] [ip None
] runner.py: 108 - Task: d5d2d6c9-cc3d-4488-960c-0a15b235626b, InstructorTask ID: 19, Course: course-v1:HiMolde+MOR100+2020_T1, Input: ['id', '
username', 'name', 'email', 'language', 'location', 'year_of_birth', 'gender', 'level_of_education', 'mailing_address', 'goals', 'enrollment_mode', 'verification_status', 'last_login', 'date_joined', 'cohort', 'city', 'country'
], S
tarting update (nothing generated yet)
lms-worker_1     | 2021-01-25 15: 46: 45,
919 WARNING 38 [edx.celery.task
] [user None
] [ip None
] tasks_base.py: 96 - Task (d5d2d6c9-cc3d-4488-960c-0a15b235626b) failed
lms-worker_1     | Traceback (most recent call last):
lms-worker_1     |   File "/openedx/venv/lib/python3.8/site-packages/celery/app/trace.py", line 412, in trace_task
lms-worker_1     |     R = retval = fun(*args, **kwargs)
lms-worker_1     |   File "/openedx/venv/lib/python3.8/site-packages/celery/app/trace.py", line 704, in __protected_call__
lms-worker_1     |     return self.run(*args, **kwargs)
lms-worker_1     |   File "/openedx/edx-platform/lms/djangoapps/instructor_task/tasks.py", line 220, in calculate_students_features_csv
lms-worker_1     |     return run_main_task(entry_id, task_fn, action_name)
lms-worker_1     |   File "/openedx/edx-platform/lms/djangoapps/instructor_task/tasks_helper/runner.py", line 120, in run_main_task
lms-worker_1     |     task_progress = task_fcn(entry_id, course_id, task_input, action_name)
lms-worker_1     |   File "/openedx/edx-platform/lms/djangoapps/instructor_task/tasks_helper/enrollments.py", line 78, in upload_students_csv
lms-worker_1     |     student_data = enrolled_students_features(course_id, query_features)
lms-worker_1     |   File "/openedx/edx-platform/lms/djangoapps/instructor_analytics/basic.py", line 176, in enrolled_students_features
lms-worker_1     |     return [extract_student(student, features) for student in students
]
lms-worker_1     |   File "/openedx/edx-platform/lms/djangoapps/instructor_analytics/basic.py", line 176, in <listcomp>
lms-worker_1     |     return [extract_student(student, features) for student in students
]
lms-worker_1     |   File "/openedx/edx-platform/lms/djangoapps/instructor_analytics/basic.py", line 138, in extract_student
lms-worker_1     |     profile = student.profile
lms-worker_1     |   File "/openedx/venv/lib/python3.8/site-packages/django/db/models/fields/related_descriptors.py", line 412, in __get__
lms-worker_1     |     raise self.RelatedObjectDoesNotExist(
lms-worker_1     | django.contrib.auth.models.User.profile.RelatedObjectDoesNotExist: User has no profile.
lms-worker_1     | 2021-01-25 15: 46: 45,
929 ERROR 38 [celery.app.trace
] [user None
] [ip None
] trace.py: 255 - Task lms.djangoapps.instructor_task.tasks.calculate_students_features_csv[d5d2d6c9-cc3d-4488-960c-0a15b235626b
] raised unex
pected: RelatedObjectDoesNotExist('User has no profile.')
lms-worker_1     | Traceback (most recent call last):
lms-worker_1     |   File "/openedx/venv/lib/python3.8/site-packages/celery/app/trace.py", line 412, in trace_task
lms-worker_1     |     R = retval = fun(*args, **kwargs)
lms-worker_1     |   File "/openedx/venv/lib/python3.8/site-packages/celery/app/trace.py", line 704, in __protected_call__
lms-worker_1     |     return self.run(*args, **kwargs)
lms-worker_1     |   File "/openedx/edx-platform/lms/djangoapps/instructor_task/tasks.py", line 220, in calculate_students_features_csv
lms-worker_1     |     return run_main_task(entry_id, task_fn, action_name)
lms-worker_1     |   File "/openedx/edx-platform/lms/djangoapps/instructor_task/tasks_helper/runner.py", line 120, in run_main_task
lms-worker_1     |     task_progress = task_fcn(entry_id, course_id, task_input, action_name)
lms-worker_1     |   File "/openedx/edx-platform/lms/djangoapps/instructor_task/tasks_helper/enrollments.py", line 78, in upload_students_csv
lms-worker_1     |     student_data = enrolled_students_features(course_id, query_features)
lms-worker_1     |   File "/openedx/edx-platform/lms/djangoapps/instructor_analytics/basic.py", line 176, in enrolled_students_features
lms-worker_1     |     return [extract_student(student, features) for student in students
]
lms-worker_1     |   File "/openedx/edx-platform/lms/djangoapps/instructor_analytics/basic.py", line 176, in <listcomp>
lms-worker_1     |     return [extract_student(student, features) for student in students
]
lms-worker_1     |   File "/openedx/edx-platform/lms/djangoapps/instructor_analytics/basic.py", line 138, in extract_student
lms-worker_1     |     profile = student.profile
lms-worker_1     |   File "/openedx/venv/lib/python3.8/site-packages/django/db/models/fields/related_descriptors.py", line 412, in __get__
lms-worker_1     |     raise self.RelatedObjectDoesNotExist(
lms-worker_1     | django.contrib.auth.models.User.profile.RelatedObjectDoesNotExist: User has no profile.

elasticsearch_1  | [
    2021-01-15 15: 07: 16,
    016
][INFO
][cluster.metadata
] [B
1 Like

I’ve seen this (or a similar) error in the past, based on what I recall, the cause was that a user was created from the admin, which doesn’t create the profile. Or created with another mechanism different that the registration form.

One possible thing to try, is to go to the admin site, get the user and edit the profile fields (I think that this will define the profile related with the user).

Again, I’m not sure if this may resolve the issue, its just an idea to explore.

Hello.

thanks for the tip, to makes things harder, the user ID of the user in the admin panel is not the same as user ID in the course.
This means that the user Id mention when i get error is actuallye the “order” of enrollment in the course . so i was able to export some ohter data, that showed me the id of the users enrolled.

so as you suggested it had something to do with user created outside the registration form.
it was actually my own user that was the problem, the profile was active, but i had to set Country and Language to make it work.

it appears to be part of the solution, as it works for one course , but not the others.

i will test som more later.

Thanks for the help.

1 Like