/// <summary> /// Function checking if given answer was correct. /// </summary> /// <returns><c>true</c>, if answer correct was ised, <c>false</c> otherwise.</returns> /// <param name="answer">Answer.</param> /// <param name="isStepped">If set to <c>true</c> is stepped answer.</param> virtual protected bool IsAnswerCorrect(IAnswerVO answer, bool isStepped = false, int stepNr = -1) { var result = false; if (answer == null) { return(result); } // Handling "multiple-step-round" exercises if (isStepped) { // if stepNr = -1, use the stepnr from the currentround or 0 (first step), if not we force it to be a stepnr use that var fallbackStep = _currentRoundResult?.CurrentStep ?? 0; var step = stepNr == -1 ? fallbackStep : stepNr; var solution = _currentRound.Solutions[step]; result = answer.Solution.Equals(solution); } else { result = _currentRound.Solutions.Contains(answer.Solution); } // Handling "one-step-round" exercises return(result); }
protected override bool IsAnswerCorrect(IAnswerVO answer, bool isStepped = false, int stepNr = -1) { bool isCorrect = base.IsAnswerCorrect(answer, false, stepNr); if (answer == null || !isCorrect) { _allItems.Remove(_solutionChain[_currentSolutionIndex]); _currentSolutionIndex++; } else if (isCorrect) { var givenAnswer = answer.Solution as FlashGlanceRoundItemVO; _allItems.Remove(givenAnswer); _currentSolutionIndex++; } return(isCorrect); }
public RoundEvaluationResultVO( bool answerCorrect, IAnswerVO givenAnswer, List <IRoundItem> solutions, List <IModelPropertyUpdateVO> updates, bool isTimeOut, DateTime startReactionDateTime, int currentStep = 1, bool roundCompleted = true) : base(updates) { IsTimeOut = isTimeOut; RoundCompleted = roundCompleted; CurrentStep = currentStep; Solutions = solutions; GivenAnswer = givenAnswer; AnswerCorrect = answerCorrect; ReactionTime = DateTime.Now - startReactionDateTime; TimeStampUTC = DateTime.UtcNow; }
protected override bool IsAnswerCorrect(IAnswerVO answer, bool isStepped = false, int stepNr = -1) { return(!((MemoflowSolution)_currentRound.Solutions[0]).MatchTypes.Contains(MemoflowMatchType.NO)); }
override protected void EvaluateNormalAnswer(Action <IRoundEvaluationResultVO> callback, IAnswerVO answer, bool isTutorial = false) { bool wasCorrect; bool isTimeout; if (answer == null) { isTimeout = true; wasCorrect = false; } else { isTimeout = false; wasCorrect = ((MemoFlowAnswerVO)answer.Solution).Correct ? IsAnswerCorrect(answer) : !IsAnswerCorrect(answer); } if (wasCorrect && (_warmUpState != WarmUpState.Enabled)) { UpdateScore(); } CompleteRound(wasCorrect, isTutorial); _currentRoundResult = new RoundEvaluationResultVO( wasCorrect, answer, _currentRound.Solutions, GetAllPropertiesUpdates(), isTimeout, _startReactionDateTime, 1, true ); _roundHistory.First(x => x.RoundDataVO == _currentRound).RoundResult.Add(_currentRoundResult); callback(_currentRoundResult); }
/// <summary> /// Evaluates the stepped answer. /// </summary> /// <returns>The stepped answer.</returns> /// <param name="answer">Answer.</param> /// <param name="isTutorial">If set to <c>true</c> is tutorial.</param> protected virtual void EvaluateSteppedAnswer(Action <IRoundEvaluationResultVO> callback, IAnswerVO answer, bool isTutorial = false, int stepNr = -1) { int oldPoints = Score; bool wasCorrect = IsAnswerCorrect(answer, true, stepNr); int finishedStepsNr = CalculateFinishedStepsNr(); bool roundCompleted = RoundCompleted(wasCorrect, finishedStepsNr); if (wasCorrect && (_warmUpState != WarmUpState.Enabled)) { UpdateScore(); UpdateStepGoodrunPercent(finishedStepsNr); } if (roundCompleted) { // adjust whole round result if needed CompleteRound(IsWholeRoundCorrect(wasCorrect), isTutorial); } _currentRoundResult = new RoundEvaluationResultVO( wasCorrect, answer, _currentRound.Solutions, GetAllPropertiesUpdates(), answer == null, _startReactionDateTime, finishedStepsNr, roundCompleted ); // reset _startReactionDateTime so we have a correct reaction time in between step answers if the round is not completed if (!roundCompleted) { StartMonitorReactionTime(DateTime.Now); } _roundHistory.First(x => x.RoundDataVO == _currentRound).RoundResult.Add(_currentRoundResult); callback(_currentRoundResult); }
/// <summary> /// Evaluates the normal answer. /// </summary> /// <returns>The normal answer.</returns> /// <param name="answer">Answer.</param> /// <param name="isTutorial">If set to <c>true</c> is tutorial.</param> protected virtual void EvaluateNormalAnswer(Action <IRoundEvaluationResultVO> callback, IAnswerVO answer, bool isTutorial = false) { int oldPoints = Score; bool wasCorrect = IsAnswerCorrect(answer); if (wasCorrect && (_warmUpState != WarmUpState.Enabled)) { UpdateScore(); } CompleteRound(wasCorrect, isTutorial); _currentRoundResult = new RoundEvaluationResultVO( wasCorrect, answer, _currentRound.Solutions, GetAllPropertiesUpdates(), answer == null, _startReactionDateTime, 1, true ); _roundHistory.First(x => x.RoundDataVO == _currentRound).RoundResult.Add(_currentRoundResult); callback(_currentRoundResult); }
public IRoundEvaluationResultVO EvaluateNormalAnswer(IAnswerVO answer, bool isTutorial) { throw new NotImplementedException(); }
/// <inheritdoc /> public virtual void EvaluateAnswer(Action <IRoundEvaluationResultVO> callback, IAnswerVO answer, bool isTutorial = false) { // In specific exercise make here a decision what kind of answer to evaluate. EvaluateNormalAnswer(callback, answer, isTutorial); }