public FileContentResult DownloadResultsDataToCSV() { TestAttempts = ApTestData.GetTestAttempts(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("AppUserID,TestName,WrittenAndVerbalReasoningScore,DiagrammaticReasoningScore,SymbolicManipulationScore,Pass\n"); foreach (var testAttempt in TestAttempts) { stringBuilder.Append(testAttempt.AppUserID + ","); stringBuilder.Append(GetTestName(testAttempt.TestID) + ","); stringBuilder.Append(testAttempt.Section1Result.ToString() + ","); stringBuilder.Append(testAttempt.Section2Result.ToString() + ","); stringBuilder.Append(testAttempt.Section3Result.ToString() + ","); stringBuilder.Append(testAttempt.IsPass.ToString() + "\n"); } return(File(Encoding.UTF8.GetBytes(stringBuilder.ToString()), "text/csv", "UserResults.csv")); }
public void OnGet() { AppUsers = ApTestData.GetAllAppUsers(); Tests = ApTestData.GetTests(); TestAttempts = ApTestData.GetTestAttempts(); }