How can I fetch usernames and their corresponding userid?

Hi OppiaMobile-Team

The question is: How can I fetch usernames and their corresponding userid?

Thank you for your help and have a nice weekend
Sirofjelly

Hi @sirofjelly
Probably the easiest way is directly from the database, the auth_user has “id” and “username”. The userid is basically only an internal reference, so it’s not really displayed in the Oppia dashboard, only really as part of urls,
Cheers,
Alex

Hi Alex,

Can you show me where to find the auth_user download mention above? I am having similar problem as OP: when I down load quiz results (Course>course data exports>course quiz responses) I get user ID but no name. Is there a way to add user names to the quiz response report? My workaround has been to download the Time tracking report which does contain both and move that list into the quiz results.

Best
Steve

Hi @Steve
Sure we can get this added easily enough to the report by default, should be done in the release for end of this month.
For now, for getting the username/userid match up, the auth_user table is a core Django table, so you can see the data in the Oppia admin pages. But for actually exporting these, it’ll best be done directly in mysql… eg. you can use

SELECT * FROM auth_user
INTO OUTFILE '\tmp\myExportFile.csv'
FIELDS ENCLOSED BY '"'
TERMINATED BY ';'
ESCAPED BY '"'
LINES TERMINATED BY '\r\n';

(from MySQL Export a MySQL Table to CSV File), though there are likely several other similar ways to do this in MySQL.
I realise that exporting like this is just a point in time snapshot of the current users, but we’ll get the username added to the report soon,
Cheers,
Alex