Exemplo n.º 1
0
        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 topicId;
                LStoreHelper.CastNonNull(dataRow[Schema.AllAttemptsResults.ThemeId], out topicId);
                Topic topic = DisciplineService.GetTopic(topicId);
                if (topic == null)
                {
                    throw new NoNullAllowedException("Error while getting topic with id = " + topicId);
                }

                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);

                DateTime?finishTime;
                LStoreHelper.Cast(dataRow[Schema.AllAttemptsResults.FinishedTimestamp], out finishTime);


                float?scaledScore;
                LStoreHelper.Cast <float>(dataRow[Schema.AllAttemptsResults.Score], out scaledScore);

                // Create AttemptResult object
                AttemptResult attemptResult = new AttemptResult(attemptId, user, topic, iudicoCompletionStatus, iudicoAttemptStatus, iudicoSuccessStatus, startTime, finishTime, scaledScore);
                result.Add(attemptResult);
            }
            return(result);
        }
Exemplo n.º 2
0
        public IEnumerable <AttemptResult> GetResults(User user, Topic topic)
        {
            List <AttemptResult> result = new List <AttemptResult>();
            LearningStoreJob     job    = LStore.CreateJob();

            RequestAttemptsByTopicAndUser(job, user.Id.ToString(), topic.Id);
            DataTable dataTable = job.Execute <DataTable>();

            foreach (DataRow dataRow in dataTable.AsEnumerable())
            {
                AttemptItemIdentifier attemptItemId;
                LStoreHelper.CastNonNull(dataRow[Schema.AttemptsResultsByThemeAndUser.AttemptId], out attemptItemId);
                long attemptId = attemptItemId.GetKey();

                Microsoft.LearningComponents.CompletionStatus completionStatus;
                LStoreHelper.CastNonNull(dataRow[Schema.AttemptsResultsByThemeAndUser.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.AttemptsResultsByThemeAndUser.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.AttemptsResultsByThemeAndUser.SuccessStatus], out successStatus);
                IUDICO.Common.Models.Shared.Statistics.SuccessStatus iudicoSuccessStatus = (IUDICO.Common.Models.Shared.Statistics.SuccessStatus)successStatus;

                DateTime?startTime;
                LStoreHelper.Cast(dataRow[Schema.AttemptsResultsByThemeAndUser.StartedTimestamp], out startTime);

                DateTime?finishTime;
                LStoreHelper.Cast(dataRow[Schema.AllAttemptsResults.FinishedTimestamp], out finishTime);

                float?score;
                LStoreHelper.Cast <float>(dataRow[Schema.AttemptsResultsByThemeAndUser.Score], out score);
                float?scaledScore = null;

                if (score != null)
                {
                    scaledScore = score / 100;
                }

                // Create AttemptResult object
                AttemptResult attemptResult = new AttemptResult(attemptId, user, topic, iudicoCompletionStatus, iudicoAttemptStatus, iudicoSuccessStatus, startTime, finishTime, scaledScore);

                result.Add(attemptResult);
            }

            return(result);
        }
Exemplo n.º 3
0
        public IEnumerable <AnswerResult> GetAnswers(AttemptResult attemptResult)
        {
            List <AnswerResult>   result    = new List <AnswerResult>();
            LearningStoreJob      job       = LStore.CreateJob();
            AttemptItemIdentifier attemptId = new AttemptItemIdentifier(attemptResult.AttemptId);

            RequestInteractionResultsByAttempt(job, attemptId);
            DataTable dataTable = job.Execute <DataTable>();

            foreach (DataRow dataRow in dataTable.AsEnumerable())
            {
                ActivityAttemptItemIdentifier activityAttemptItemId;
                LStoreHelper.CastNonNull(dataRow[Schema.InteractionResultsByAttempt.ActivityAttemptId], out activityAttemptItemId);
                long activityAttemptId = activityAttemptItemId.GetKey();

                ActivityPackageItemIdentifier activityPackageItemId;
                LStoreHelper.CastNonNull(dataRow[Schema.InteractionResultsByAttempt.ActivityPackageId], out activityPackageItemId);
                long activityPackageId = activityPackageItemId.GetKey();

                String activityTitle;
                LStoreHelper.CastNonNull(dataRow[Schema.InteractionResultsByAttempt.ActivityTitle], out activityTitle);

                InteractionItemIdentifier interactionItemId;
                LStoreHelper.Cast(dataRow[Schema.InteractionResultsByAttempt.InteractionId], out interactionItemId);
                long?interactionId = null;
                if (interactionItemId != null)
                {
                    interactionId = interactionItemId.GetKey();
                }

                Microsoft.LearningComponents.CompletionStatus completionStatus;
                LStoreHelper.CastNonNull(dataRow[Schema.InteractionResultsByAttempt.CompletionStatus], out completionStatus);
                IUDICO.Common.Models.Shared.Statistics.CompletionStatus iudicoCompletionStatus = (IUDICO.Common.Models.Shared.Statistics.CompletionStatus)completionStatus;

                Microsoft.LearningComponents.SuccessStatus?successStatus;
                LStoreHelper.Cast(dataRow[Schema.InteractionResultsByAttempt.SuccessStatus], out successStatus);
                IUDICO.Common.Models.Shared.Statistics.SuccessStatus?iudicoSuccessStatus = (IUDICO.Common.Models.Shared.Statistics.SuccessStatus?)successStatus;

                bool?learnerResponseBool = null;
                LStoreHelper.Cast(dataRow[Schema.InteractionResultsByAttempt.LearnerResponseBool], out learnerResponseBool);

                string learnerResponseString = null;
                LStoreHelper.Cast(dataRow[Schema.InteractionResultsByAttempt.LearnerResponseString], out learnerResponseString);

                double?learnerResponseNumeric = null;
                LStoreHelper.Cast(dataRow[Schema.InteractionResultsByAttempt.LearnerResponseNumeric], out learnerResponseNumeric);

                object learnerResponse = null;
                if (learnerResponseBool != null)
                {
                    learnerResponse = learnerResponseBool;
                }
                if (learnerResponseString != null)
                {
                    learnerResponse = learnerResponseString;
                }
                if (learnerResponseNumeric != null)
                {
                    learnerResponse = learnerResponseNumeric;
                }

                string correctResponse;
                LStoreHelper.Cast(dataRow[Schema.InteractionResultsByAttempt.CorrectResponse], out correctResponse);

                Microsoft.LearningComponents.InteractionType?interactionType = null;
                LStoreHelper.Cast(dataRow[Schema.InteractionResultsByAttempt.InteractionType], out interactionType);
                IUDICO.Common.Models.Shared.Statistics.InteractionType?learnerResponseType = null;
                if (interactionType != null)
                {
                    learnerResponseType = (IUDICO.Common.Models.Shared.Statistics.InteractionType)interactionType;
                }

                float?scaledScore;
                LStoreHelper.Cast <float>(dataRow[Schema.InteractionResultsByAttempt.ScaledScore], out scaledScore);

                // Create AnswerResult object
                AnswerResult answerResult = new AnswerResult(activityAttemptId, activityPackageId, activityTitle, interactionId, iudicoCompletionStatus, iudicoSuccessStatus, attemptResult, learnerResponse, correctResponse, learnerResponseType, scaledScore);
                result.Add(answerResult);
            }

            return(result);
        }