Getting last_name and first_name from KTHIDs (used as SIS user IDs)

When first introducing Canvas as an LMS at KTH the integration process use one scheme for user names: First_name Last_name (e-mail). Subsequently this was changed twice more, until the format of names is Last_name, First_name. This final form is the name order used in Ladok 3 Links to an external site. (the national academic records system). Unfortunately, the existing users names were not changed (yet). This means that one gets a list of students with a mix of name orders, making entering data into Ladok 3 painful and time consuming.

The solution is to inject each student's Last_name and First_name entries as custom columns into the gradebook. But how can one get this data? The answer is LDAP! Fortunately, the SIS user ID for each student is their KTHID and one can use this to systematically lookup the user's First_name (givenname) and Last_name (surname).

How can one get a list of the SIS user ID/KTHIDs for all students in a course? Using the program  Download list_students_in_course.py

 course_number and then create a new CSV file from the column "sis_user_id". (Note that you cannot have a column heading.)

For example, if the file k1.csv has the entry:

u1d13i2c

Run the program Download KTHID-to-last-firstname-list.py

 giving it the CSV file:

./KTHID-to-last-firstname-list.py k1.csv 
'Tue Dec 27 08:38:47 2016'
('list_of_KTHIDs_file_name: ', 'k1.csv')
('augmented_list_of_names_file: ', 'k1-augmented.csv') 
'Tue Dec 27 08:38:47 2016' 
'\n--DONE--\n\n'

The resulting file (k1-augmented.csv) has the form:

KTHID,Last_name,First_name
u1d13i2c,Maguire Jr,Gerald Q

Note that the above program deals with base64 encoded user names and output UTF-8 versions of these names.

Now one can augment the list of students in the course spreadsheet by running Download augument_list_students_in_course.py

:

 ./augument_list_students_in_course.py 190 kthids-190a-augmented.csv
'Tue Dec 27 11:46:39 2016'
'Tue Dec 27 11:46:39 2016'
'\n--DONE--\n\n'

You will now find two new columns: Last_name and First_name in the file: students-in-190-augmented.xlsx