public IEnumerable <AttemptResult> GetAllAttempts() { List <AttemptResult> result = new List <AttemptResult>(); LearningStoreJob job = LStore.CreateJob(); RequestAllAttempts(job); DataTable dataTable = job.Execute <DataTable>(); foreach (DataRow dataRow in dataTable.AsEnumerable()) { AttemptItemIdentifier attemptItemId; LStoreHelper.CastNonNull(dataRow[Schema.AllAttemptsResults.AttemptId], out attemptItemId); long attemptId = attemptItemId.GetKey(); String userKey; LStoreHelper.CastNonNull(dataRow[Schema.AllAttemptsResults.UserItemKey], out userKey); User user = UserService.GetUsers().Single(curr => curr.Id.ToString() == userKey); if (user == null) { throw new NoNullAllowedException("Error while getting user with id = " + userKey); } Int32 themeId; LStoreHelper.CastNonNull(dataRow[Schema.AllAttemptsResults.ThemeId], out themeId); Theme theme = CurriculumService.GetTheme(themeId); if (theme == null) { throw new NoNullAllowedException("Error while getting theme with id = " + themeId); } Microsoft.LearningComponents.CompletionStatus completionStatus; LStoreHelper.CastNonNull(dataRow[Schema.AllAttemptsResults.CompletionStatus], out completionStatus); IUDICO.Common.Models.Shared.Statistics.CompletionStatus iudicoCompletionStatus = (IUDICO.Common.Models.Shared.Statistics.CompletionStatus)completionStatus; Microsoft.LearningComponents.AttemptStatus attemptStatus; LStoreHelper.CastNonNull(dataRow[Schema.AllAttemptsResults.AttemptStatus], out attemptStatus); IUDICO.Common.Models.Shared.Statistics.AttemptStatus iudicoAttemptStatus = (IUDICO.Common.Models.Shared.Statistics.AttemptStatus)attemptStatus; Microsoft.LearningComponents.SuccessStatus successStatus; LStoreHelper.CastNonNull(dataRow[Schema.AllAttemptsResults.SuccessStatus], out successStatus); IUDICO.Common.Models.Shared.Statistics.SuccessStatus iudicoSuccessStatus = (IUDICO.Common.Models.Shared.Statistics.SuccessStatus)successStatus; DateTime?startTime; LStoreHelper.Cast(dataRow[Schema.AllAttemptsResults.StartedTimestamp], out startTime); float?scaledScore; LStoreHelper.Cast <float>(dataRow[Schema.AllAttemptsResults.Score], out scaledScore); // Create AttemptResult object AttemptResult attemptResult = new AttemptResult(attemptId, user, theme, iudicoCompletionStatus, iudicoAttemptStatus, iudicoSuccessStatus, startTime, scaledScore); result.Add(attemptResult); } return(result); }
public int GetCurriculumIdByThemeId(int themeId) { var theme = CurriculumService.GetTheme(themeId); if (theme == null) { throw new NullReferenceException("Can't find theme by specified themeId"); } if (theme.Stage == null) { throw new NullReferenceException("Can't find stage by specified themeId"); } if (theme.Stage.Curriculum == null) { throw new NullReferenceException("Can't find curriculum by specified themeId"); } return(theme.Stage.Curriculum.Id); }