コード例 #1
0
        /// <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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 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;
 }
コード例 #4
0
 protected override bool IsAnswerCorrect(IAnswerVO answer, bool isStepped = false, int stepNr = -1)
 {
     return(!((MemoflowSolution)_currentRound.Solutions[0]).MatchTypes.Contains(MemoflowMatchType.NO));
 }
コード例 #5
0
        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);
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
 public IRoundEvaluationResultVO EvaluateNormalAnswer(IAnswerVO answer, bool isTutorial)
 {
     throw new NotImplementedException();
 }
コード例 #9
0
 /// <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);
 }