Someone asked me how to display the user name rather than just the UserID in the Survey module results export file.
When you create a Survey with the Survey module, you can go to Settings and click Export Data to create a .csv file with the Survey results (that you can open with Microsoft Excel).
However, the results contain the UserID of the user not the user’s name.
To show the name is easy, Open Settings.ascx.vb file and change the ExportData() method method to this:
Public Sub ExportData()
Response.Clear()
Response.AddHeader("content-disposition", "attachment; filename=Survey_Results_" _
+ ModuleId.ToString + "_" + _
DateTime.Now.ToShortDateString().Replace("/", "_") + ".csv")
Response.Charset = ""
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim stringWriter As System.IO.StringWriter = New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWriter)
stringWriter.Write("Question,Option,Option Type,Is Correct?,User" & vbCrLf)
Dim colSurveyResultInfo As List(Of SurveyResultInfo) = _
SurveyOptionController.GetSurveyResultData(ModuleId)
Dim objSurveyResultInfo As SurveyResultInfo
Dim objUserController As New UserController
For Each objSurveyResultInfo In colSurveyResultInfo
stringWriter.Write(objSurveyResultInfo.Question & "," & _
objSurveyResultInfo.OptionName & "," & _
objSurveyResultInfo.OptionType & "," & _
objSurveyResultInfo.IsCorrect & "," & _
objUserController.GetUser(PortalId, objSurveyResultInfo.UserId).DisplayName & _
vbCrLf)
Next
Response.Write(stringWriter.ToString())
Response.End()
End Sub