Add student email to the results spreadsheet   #2582

Fixes for adding student email next to student name in CSV file generation
Move variable declaration closer to where it is used.