Example #1
0
    //returns an int (the _currentLevel) and takes input from AttemptEval as to whether the previous answer was correct or not
    public int ProcessAttempt(AttemptEval result)
    {
        if (result == AttemptEval.Incorrect)
        {
            _numberIncorrectAtThisLevel++;
            _totalIncorrect++;
        }
        else
        {
            _numberCorrectAtThisLevel++;
            _totalCorrect++;
        }

        if (_numberIncorrectAtThisLevel + _numberCorrectAtThisLevel >= 5)
        {
            float performance = ((float)_numberCorrectAtThisLevel / (float)(_numberCorrectAtThisLevel + _numberIncorrectAtThisLevel));
            if (performance < 0.7)
            {
                if (_currentLevel != _lowestLevel)
                {
                    _currentLevel--;
                }

                _numberCorrectAtThisLevel   = 0;
                _numberIncorrectAtThisLevel = 0;
            }
            else
            {
                if (performance > 0.9)
                {
                    _currentLevel++;
                    _numberCorrectAtThisLevel   = 0;
                    _numberIncorrectAtThisLevel = 0;
                }
            }
        }

        return(_currentLevel);
    }
Example #2
0
    IEnumerator CollectResponses()
    {
        // Enable the buttons
        Choices.SetActive(true);

        _responseTimer = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond);

        // Check for user responses or timeout
        int previousCount = 0;

        while (true)
        {
            // If we made it this far and our count has increased then we should show the thing they chose
            if (previousCount < _responseArray.Count)
            {
                // Grab the last response
                int itmIdx = _responseArray[_responseArray.Count - 1];

                // Set the glyph
                MainGO.GetComponent <SpriteRenderer>().sprite = _spriteArray[itmIdx];
                MainGO.SetActive(true);
                yield return(new WaitForSeconds(0.200f));

                MainGO.SetActive(false);
                yield return(new WaitForSeconds(0.100f));

                previousCount++;

                continue;
            }

            if (CurrentBlockType == BlockType.BaselineBlock)
            {
                // If we have processed all responses or hit our timeout then process and break loop
                if (((_randomIndexArray.Count <= _responseArray.Count)) || (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - _responseTimer) / 1000) >= _baselineResponseTimeLimit)
                {
                    //return of this is eval of answer
                    //_iterationCount++;
                    //_currentRespEval = CheckResponses();
                    //_spanLengths.Add(_currentSpanLength); //comtains all span lengths attempted

                    //calculating total trial duration
                    TrialEndTime  = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond);
                    TrialDuration = (TrialEndTime - TrialStartTime);
                    _trialCount++;

                    ////log response
                    //ResponseLogger();
                    ////set span length
                    //_currentSpanLength = _difficulty.ProcessAttempt(_currentRespEval);

                    //if we are in scanner...calculate the appropreate time to display feedback to make trial last x number of sec
                    FeedbackTimeout = (BaselineTimeLimit - TrialDuration);

                    MainGO.GetComponent <SpriteRenderer>().sprite = _feedbackSprite;
                    MainGO.SetActive(true);

                    yield return(new WaitForSeconds(FeedbackTimeout / 1000));

                    MainGO.SetActive(false);

                    if (_trialCount >= _baselineTrialLimit)
                    {
                        _trialCount      = 0;
                        CurrentBlockType = BlockType.RecallBlock;
                    }

                    break;
                }
            }

            if (CurrentBlockType == BlockType.RecallBlock)
            {
                // If we have processed all responses or hit our timeout then process and break loop
                if (((_randomIndexArray.Count <= _responseArray.Count)) || (((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - _responseTimer) / 1000) >= _responseTimeLimit)
                {
                    //return of this is eval of answer
                    _iterationCount++;
                    _currentRespEval = CheckResponses();
                    _spanLengths.Add(_currentSpanLength); //comtains all span lengths attempted

                    //calculating total trial duration
                    TrialEndTime  = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond);
                    TrialDuration = (TrialEndTime - TrialStartTime);
                    _trialCount++;

                    //log response
                    ResponseLogger();
                    //set span length
                    _currentSpanLength = _difficulty.ProcessAttempt(_currentRespEval);

                    //if we are in scanner...calculate the appropreate time to display feedback to make trial last x number of sec
                    if (CurrentTaskType == TaskType.Scanner)
                    {
                        FeedbackTimeout = (RecallTimeLimit - TrialDuration);
                    }

                    MainGO.GetComponent <SpriteRenderer>().sprite = _feedbackSprite;
                    MainGO.SetActive(true);

                    yield return(new WaitForSeconds(FeedbackTimeout / 1000));

                    MainGO.SetActive(false);

                    if (CurrentTaskType == TaskType.Scanner)
                    {
                        if (_trialCount >= _recallTrialLimit)
                        {
                            _trialCount      = 0;
                            CurrentBlockType = BlockType.BaselineBlock;
                        }
                    }

                    break;
                }
            }


            // Pause for 100 msec and check again for response
            yield return(new WaitForSeconds(0.1f));
        }

        yield return(new WaitForSeconds(0.5f));
    }