private void GetCorrectAnswersFromQuestions() { uint numberQuestion = 1; foreach (Question question in Questions) { List <string> answers = new List <string>() { question.Answer1, question.Answer2, question.Answer3, question.Answer4, question.Answer5, question.Answer6, question.Answer7, question.Answer8 }; List <bool> answersBool = new List <bool>() { question.Answer1Bool == true?true:false, question.Answer2Bool == true?true:false, question.Answer3Bool == true?true:false, question.Answer4Bool == true?true:false, question.Answer5Bool == true?true:false, question.Answer6Bool == true?true:false, question.Answer7Bool == true?true:false, question.Answer8Bool == true?true:false }; List <string> ansCor = new List <string>(); for (int i = 0; i < answersBool.Count; i++) { if (answersBool[i]) { ansCor.Add(answers[i]); } } AllAnswers.Add(numberQuestion, answers); CorrectAnswers.Add(numberQuestion, answersBool); AnswersCorrect.Add(numberQuestion, ansCor); numberQuestion++; } }
public void PrintResults() { Console.WriteLine("----------------------------------"); Console.WriteLine(CorrectAnswers.ToString() + "/" + TotalAnswers.ToString() + " (" + 100 * CorrectAnswers / TotalAnswers + "%)"); Console.WriteLine("----------------------------------"); Console.ReadKey(true); }
public IActionResult QuizResult() { CorrectAnswers answers = CorrectAnswers.Instance; ViewBag.Result = answers.Answers; ViewData["Correct"] = "" + answers.Correct; ViewData["Total"] = "" + answers.Total; return(View()); }
public override bool GradeQuestion() { bool complete = false; Console.WriteLine("Your answers(one per line, press enter when done: "); do { string input = Console.ReadLine(); if (input == "") { complete = true; } else { UserResponse.Add(input); } } while (complete == false); int numCorrect = 0; foreach (string answer in UserResponse) { if (CorrectAnswers.Contains(answer)) { numCorrect++; } else { numCorrect--; } } if (numCorrect == CorrectAnswers.Count) { return(true); } else { return(false); } }
public IActionResult Quiz(Operations operation, string action) { if (ModelState.IsValid) { CorrectAnswers answers = CorrectAnswers.Instance; answers.Total += 1; if (operation.Check()) { answers.Correct += 1; } (answers.Answers).Add(operation); } else { ModelState.AddModelError("YourAnswer", "недопустимый формат ответа"); return(View(operation)); } if (action == "Next") { return(View(new Operations())); } return(RedirectToAction("QuizResult")); }
private void ClearScore() { CorrectAnswers.Clear(); TotalJumps = 0; }
public bool IsAnswerCorrect(string answer) { return(CorrectAnswers.Any(correctAnswer => correctAnswer.Equals(answer.Trim(), StringComparison.OrdinalIgnoreCase))); }
/// <summary> /// Get correct answers in string format. /// </summary> public string GetCorrectAnswers() { return(string.Join(", ", CorrectAnswers.Select(answer => answer.Answer))); }