private void LoadChanceToAppear() { // peso 2 var daysSince = LastTry != null?DateTime.Now.Subtract(LastTry.When).Days : 100; var lastTry_score = 0; if (daysSince < 20 && daysSince >= 1) { lastTry_score = daysSince / 2; } else if (daysSince == 0) { Chance = 1; Chance_toolTip = "Question already completed today."; return; } else { lastTry_score = 20; } // peso 4 var inv_avg = 40.0; if (daysSince <= 7) { inv_avg -= ((20 * Avg_week) / 100) + ((15 * Avg_month) / 100) + ((05 * Avg_all) / 100); } else if (daysSince <= 30) { inv_avg -= ((30 * Avg_month) / 100) + ((10 * Avg_all) / 100); } else if (daysSince <= 7) { inv_avg -= ((40 * Avg_all) / 100); } // peso 1 var lastWasWrong = Tries != null && Tries.Any() ? (LastTry.Score == 100 ? 0 : 10) : 10; // peso 3 var imp_score = ScoreHelper.GetScoreFromImportance(Importance) * 3; Chance = Math.Round(lastTry_score + inv_avg + lastWasWrong + imp_score, 2); Chance_toolTip = inv_avg + " (inv_avg) -> " + (daysSince <= 7 ? "avg_week (20%) + avg_month (15%) + avg_all (5%)" : (daysSince <= 30 ? "avg_month (30%) + avg_all (10%)" : "avg_all (40%) + ")) + "\n"; Chance_toolTip += lastTry_score + " (lastTry) + " + lastWasWrong + " (lastWrong) + " + imp_score + " (imp)"; }
public double GetAverageScoreByTime(int lastDays) { if (!Tries.Any()) { return(0); } else { var filtered = Tries.Where(x => x.When >= (DateTime.Now.AddDays(-lastDays))); if (filtered.Any()) { return(filtered.Average(x => x.Score) * 10); } else { return(0); } } }