Пример #1
0
        public static TestDataViewModel GetTest(string id, DataSource source)
        {
            if (id == "average")
            {
                return(GetTest(source));
            }

            if (TestViewModels.ContainsKey(id))
            {
                return(TestViewModels[id]);
            }
            TestViewModels.Add(id, new TestDataViewModel(id));
            TestViewModels[id].GestureInformation = new Dictionary <string, GestureInfo>();


            if (!Tests.ContainsKey(id))
            {
                Tests[id] = AttemptRepository.GetTest(id, source);
            }

            foreach (var gesture in AllGestures)
            {
                GestureInfo info       = new GestureInfo();
                var         hitsPerTry = MathHelper.GetHitsPerTry(Tests[id].Attempts[gesture]);
                info.HitData       = GetJSPercentageArray(hitsPerTry, gesture);
                info.TimeData      = GetJSTimeArray(MathHelper.GetTimePerTarget(Tests[id].Attempts[gesture]), gesture);
                info.HitPercentage = hitsPerTry.Last() * 100f;

                TestViewModels[id].GestureInformation[GetGestureTypeString(gesture)] = info;
            }


            return(TestViewModels[id]);
        }
Пример #2
0
        public ActionResult GetImage(string testId, GestureType type, DataSource source = DataSource.Old)
        {
            List <Attempt> attempts = new List <Attempt>();

            if (testId != "average")
            {
                attempts = AttemptRepository.GetTest(testId, source).Attempts[type];
            }
            else
            {
                var tests = AttemptRepository.GetTests(source);
                foreach (var test in tests)
                {
                    attempts.AddRange(test.Attempts[type]);
                }
            }
            MemoryStream ms;

            DataVisualizer.DrawHitBox(attempts, out ms);
            return(File(ms, "image/png"));
        }