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]); }
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]; }
private static TestDataViewModel GetTest(DataSource source) { if (TestViewModels.ContainsKey("average")) { return(TestViewModels["average"]); } TestViewModels.Add("average", new TestDataViewModel("average")); if (Tests.Count != AttemptRepository.GetTestCount(source)) { Tests.Clear(); foreach (var test in AttemptRepository.GetTests(source)) { Tests.Add(test.ID, test); } } var tests = Tests.Values.ToList(); var averageHitPercentagePerGesture = GetAverageHitPercentagePerTurn(tests); var averageTimePerTargetPerGesture = GetAverageTimePerTarget(tests); foreach (var gesture in AllGestures) { GestureInfo info = new GestureInfo(); info.HitData = GetJSPercentageArray(averageHitPercentagePerGesture[gesture], gesture); info.TimeData = GetJSTimeArray(averageTimePerTargetPerGesture[gesture], gesture); info.HitPercentage = averageHitPercentagePerGesture[gesture].Last() * 100f; List <Attempt> attempts = new List <Attempt>(); foreach (var test in tests) { attempts.AddRange(test.Attempts[gesture]); } TestViewModels["average"].GestureInformation[GetGestureTypeString(gesture)] = info; } return(TestViewModels["average"]); }
private static TestDataViewModel GetTest(DataSource source) { if (TestViewModels.ContainsKey("average")) { return TestViewModels["average"]; } TestViewModels.Add("average", new TestDataViewModel("average")); if (Tests.Count != AttemptRepository.GetTestCount(source)) { Tests.Clear(); foreach(var test in AttemptRepository.GetTests(source)) { Tests.Add(test.ID, test); } } var tests = Tests.Values.ToList(); var averageHitPercentagePerGesture = GetAverageHitPercentagePerTurn(tests); var averageTimePerTargetPerGesture = GetAverageTimePerTarget(tests); foreach (var gesture in AllGestures) { GestureInfo info = new GestureInfo(); info.HitData = GetJSPercentageArray(averageHitPercentagePerGesture[gesture], gesture); info.TimeData = GetJSTimeArray(averageTimePerTargetPerGesture[gesture], gesture); info.HitPercentage = averageHitPercentagePerGesture[gesture].Last() * 100f; List<Attempt> attempts = new List<Attempt>(); foreach(var test in tests) { attempts.AddRange(test.Attempts[gesture]); } TestViewModels["average"].GestureInformation[GetGestureTypeString(gesture)] = info; } return TestViewModels["average"]; }