public void RemoveAllAttempts() { foreach (var att in AttemptsControl.Get(Type).Where(q => q.IdQuestion == Id)) { AttemptsControl.Remove(att); } }
public static Button Chal_remove_att(ChalLine line) { var btn = Get(line.Chal.Remove_att, 0, 0, line.Chal.Row_4, "Remove attempt"); line.Chal.Remove_att.Width = 125; line.Chal.Remove_att.Click += (source, e) => { AttemptsControl.RemoveLast(line.Quest.Type); line.Chal.Remove_att.IsEnabled = false; line.Chal.Disable_quest.IsEnabled = true; line.Chal.Grid_chal.Background = UtilWPF.Vocour_row_off; line.Quest.LoadCrossData(); var updated = QuestControl.Get(line.Quest.Type).First(x => x.Id == line.Quest.Id); line.Chal.Avg_w.Content = updated.Avg_week + "% (w)"; line.Chal.Avg_m.Content = updated.Avg_month + "% (m)"; line.Chal.Avg_all.Content = updated.Avg_all + "% (all)"; line.Chal.Tries.Content = updated.Tries.Count + " tries"; line.Chal.Chance.Content = updated.Chance + " (" + Math.Round(updated.Chance_real, 2) + ")"; }; return(btn); }
private void GetAttempts() { var att = AttemptsControl.Get(Type); var attempts = att.Where(x => x.IdQuestion == Id); foreach (var item in attempts) { Tries.Add(new DateTry(item.Score, item.When)); } }
public static void Verify(ChalLine line, Button btn_verify, Button btn_next) { line.Chal.Cb_Answer.IsEnabled = false; int score = 0; bool isCorrect = false; if (line.Quest.Type == Model.Voc) { isCorrect = line.Chal.Cb_Answer.IsCorrect(); } else if (line.Quest.Type == Model.Spell) { isCorrect = line.Chal.Txt_Spell.Text.ContainsInsensitive(line.Quest.Text); } if (isCorrect) { line.Chal.Grid_chal.Background = UtilWPF.Colour_Correct; score = 10; } else { line.Chal.Grid_chal.Background = UtilWPF.Colour_Incorrect; } var att = new AttemptVM(line.Quest.Id, score, DateTime.Now, line.Quest.Type); AttemptsControl.Insert(att); var updated_quest = QuestControl.Get(line.Quest.Type).First(x => x.Id == line.Quest.Id); line.Chal.Avg_w.Content = updated_quest.Avg_week + "% (w)"; line.Chal.Avg_m.Content = updated_quest.Avg_month + "% (m)"; line.Chal.Avg_all.Content = updated_quest.Avg_all + "% (all)"; line.Chal.Tries.Content = updated_quest.Tries.Count + " tries"; foreach (var lbl in line.Chal.Quest_words) { if (line.Quest.Text.SplitSentence().Contains(lbl.Content.ToString())) { lbl.FontWeight = FontWeights.Bold; } } TurnElemsVisible(line); btn_next.IsEnabled = true; btn_verify.IsEnabled = false; }
public static (string, int) CheckAnswers(List <CellTemplate> cellList) { var total = 0; var corrects = 0; foreach (var item in cellList) { if (item.Txt != null) { item.Txt.IsReadOnly = true; var answer = string.Empty; if (!item.Txt.IsEmpty()) { answer = item.Txt.Text; } var isCorrect = answer.Equals(item.Quest.Text, StringComparison.OrdinalIgnoreCase); var score = 0; if (isCorrect) { score = 10; item.Txt.Background = Brushes.LightGreen; corrects = corrects + 1; } else { item.Txt.Background = Brushes.LightSalmon; item.Txt.ToolTip = item.Quest.Text; } var vm = new AttemptVM(item.Quest.Id, score, DateTime.Now, item.Quest.Type); AttemptsControl.Insert(vm); total = total + 1; } } var percent_corrects = 0; if (corrects != 0) { percent_corrects = (int)Math.Round((double)(100 * corrects) / total); } return(percent_corrects + "% (" + corrects + " corrects)", percent_corrects); }