Exemplo n.º 1
0
        public ActionResult Index()
        {
            // Load data
            StudyReportContext ctx = new StudyReportContext();
            ctx.Database.Initialize(true);

            var answerVms = new AnswerViewModel().ListAnswerViewModel();
            return View(answerVms);
        }
Exemplo n.º 2
0
 public ViewResult Index(bool hideZeroProgress, bool hideNullDifficulty)
 {
     var answerVms = new AnswerViewModel()
         .ListAnswerViewModel()
         .Where(
             x => (!hideZeroProgress || x.Progress != 0)
                 && (!hideNullDifficulty || x.Difficulty.HasValue))
         .ToList();
     return View(answerVms);
 }
Exemplo n.º 3
0
        public ContentResult GetData()
        {
            var answerVms = new AnswerViewModel().ListAnswerViewModel();

            var result = answerVms
                .GroupBy(x => x.LearningObjective)
                .Select(x =>
                    new {
                        LearningObjective = x.Key,
                        Progress = x.Sum(y => y.Progress)
                    })
                .Distinct()
                .OrderBy(x => x.LearningObjective)
                .ToList();

            return Content(JsonConvert.SerializeObject(result), "application/json");
        }
Exemplo n.º 4
0
        public List<AnswerViewModel> ListAnswerViewModel()
        {
            // Build view model
            List<AnswerViewModel> answerVms = new List<AnswerViewModel>();

            using (var ctx = new DataAccess.StudyReportContext())
            {
                var answers = ctx.Answers.ToList();
                foreach (var answer in answers)
                {
                    if (DateTime.SpecifyKind(answer.SubmitDateTime.Value, DateTimeKind.Utc) >= new DateTime(2015, 3, 24, 0, 0, 0, DateTimeKind.Utc)
                        && DateTime.SpecifyKind(answer.SubmitDateTime.Value, DateTimeKind.Utc) <= new DateTime(2015, 3, 24, 11, 30, 0, DateTimeKind.Utc))
                    {
                        AnswerViewModel answerVm = new AnswerViewModel
                        {
                            SubmitDateTime = DateTime.SpecifyKind(answer.SubmitDateTime.Value, DateTimeKind.Utc),
                            Correct = answer.Correct,
                            Progress = answer.Progress,
                            UserId = answer.User.UserId.ToString(),
                            ExerciseId = answer.Exercise.Id.ToString(),
                            Difficulty = answer.Exercise.Difficulty,
                            Subject = answer.Exercise.LearningObjective.Domain != null ? answer.Exercise.LearningObjective.Domain.Subject.Name : string.Empty,
                            Domain = answer.Exercise.LearningObjective.Domain != null ? answer.Exercise.LearningObjective.Domain.Name : string.Empty,
                            LearningObjective = answer.Exercise.LearningObjective.Name
                        };
                        answerVms.Add(answerVm);
                    }
                }
            }

            return answerVms;
        }