public void OnAttemptsExhausted(FreeResponseMinigameDriver driver) { if (AttemptsExhausted != null) { AttemptsExhausted.Invoke(); } }
public void SubmitAnswer(string _attempt, FreeResponseMinigameDriver driver, Action <string> onIncorrect = null) { var isCorrect = false; var attempt = _attempt; driver.AttemptsTried++; if (string.IsNullOrEmpty(_attempt)) { attempt = ""; } attempt = attempt.Trim(); if (driver.Quiz == null || driver.Quiz.Answer.AnswerText == null || driver.Quiz.Answer.AnswerText.Count() <= 0) { throw new MissingFieldException("Quiz has no answer text attached."); } if (driver.Quiz.Answer is StrictMatchAnswer) { var answerObj = driver.Quiz.Answer as StrictMatchAnswer; isCorrect = CheckStrictMatch(attempt, answerObj); } else if (driver.Quiz.Answer is LooseMatchAnswer) { // not implemented //var answerObj = driver.Quiz.Answer as LooseMatchAnswer; //isCorrect = CheckLooseMatch(attempt, answerObj); } else if (driver.Quiz.Answer is TextMustContainAnswer) { var answerObj = driver.Quiz.Answer as TextMustContainAnswer; isCorrect = CheckMustContainMatch(attempt, answerObj); } else { throw new Exception("Unable to cast Quiz answer."); } if (isCorrect) { OnAttemptCorrect(attempt, driver); } else { if (driver.Quiz.MaximumAttempts > 0 && driver.AttemptsTried >= driver.Quiz.MaximumAttempts) { OnAttemptsExhausted(driver); } if (onIncorrect != null) { onIncorrect.Invoke(attempt); } } }
////////////////////////////////////////////////////////////// // FREE RESPONSE QUIZ ////////////////////////////////////////////////////////////// public void Action(FreeResponseMinigameDriver quizDriver) { if (OnAction != null) { OnAction.Invoke(); } ThreadHelper.Instance.CallOnMainThread(() => { PushQuizPanel <FreeResponseMinigameDriver, FreeResponseQuizPanel>(quizDriver); }); }
////////////////////////////////////////////////////////////// // FREE RESPONSE QUIZ ////////////////////////////////////////////////////////////// public void Action(FreeResponseMinigameDriver quizDriver) { if (OnAction != null) { OnAction.Invoke(); } ThreadHelper.Instance.CallOnMainThread(() => { var panel = PanelManager.Instance.GetPanel <FreeResponseQuizPanel>(); if (panel == null) { m_logger.Error(typeof(FreeResponseQuizPanel).ToString() + " not found."); return; } PanelManager.Instance.Push(k_quizStack, panel, quizDriver); }); }
public void OnAttemptCorrect(string _attempt, FreeResponseMinigameDriver driver) { PushSuccessPanel(driver.TaskDriver); }