Exemplo n.º 1
0
 /// <summary>
 /// If we're currently training, check to see whether our time requires a notification, shift to next, etc.
 /// </summary>
 public void CheckTimes()
 {
     if (TrainingMode == enumTrainingMode.QuestionAsked && TimeSincePresentation > CurrentLevel.QuestionTimeout)
     {
         QuestionsWrong       += 1;
         AnswerText            = "Timed out! ";
         TimeQuestionPresented = DateTime.Now;
         UserAnswer            = PointF.Empty;
         TrainingMode          = enumTrainingMode.AnswerWrong;
     }
     else if ((TrainingMode == enumTrainingMode.AnswerCorrect || TrainingMode == enumTrainingMode.AnswerWrong) && (TimeSincePresentation > CurrentLevel.WaitBetweenQuestions))
     {
         NextQuestion();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Handle the user's response
        /// </summary>
        /// <param name="LngLat"></param>
        public void HandleResponse(PointF LngLat)
        {
            //If we're a substation, find our position relative to the sub
            Double Dist;

            UserAnswer = LngLat;
            if (TargetElement is MM_Substation)
            {
                Dist          = (TargetElement as MM_Substation).DistanceTo(LngLat);
                CorrectAnswer = (TargetElement as MM_Substation).LngLat;
            }
            else
            {
                MM_Line TargetLine = (MM_Line)TargetElement;
                Dist = MM_Substation.ComputeDistance(LngLat, CorrectAnswer = new PointF((TargetLine.Substation1.Longitude + TargetLine.Substation2.Longitude) / 2f, (TargetLine.Substation1.Latitude + TargetLine.Substation2.Latitude) / 2f));
            }

            //Now, check through our list of reponses, and see if we made it
            QuestionsAnswered++;

            if (Dist > CurrentLevel.NoScoreThreshold)
            {
                AnswerText            = "Sorry! You were " + Dist.ToString("#,##0.0") + " miles away.";
                TimeQuestionPresented = DateTime.Now;
                TrainingMode          = enumTrainingMode.AnswerWrong;
                QuestionsWrong++;
            }
            else
            {
                double TotalScore;
                if (Dist <= CurrentLevel.BullsEyeThresholdDistance)
                {
                    TotalScore = CurrentLevel.UpperScoreValue;
                }
                else
                {
                    double XPercentile = (Dist - CurrentLevel.BullsEyeThresholdDistance) / (CurrentLevel.NoScoreThreshold - CurrentLevel.BullsEyeThresholdDistance);
                    TotalScore = ((CurrentLevel.LowerScoreValue - CurrentLevel.UpperScoreValue) * XPercentile) + CurrentLevel.UpperScoreValue;
                }
                double TimeScore = CurrentLevel.MaximumTimeScore * ((CurrentLevel.QuestionTimeout - TimeSincePresentation) / CurrentLevel.QuestionTimeout);
                Score                += TimeScore + TotalScore;
                LevelScore           += TimeScore + TotalScore;
                QuestionsRight       += 1;
                AnswerText            = "Correct! You were " + Dist.ToString("#,##0.0") + " miles away (" + TotalScore.ToString("0") + " pts; bonus " + TimeScore.ToString("0") + " pts)";
                TimeQuestionPresented = DateTime.Now;
                TrainingMode          = enumTrainingMode.AnswerCorrect;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Determine our next question
        /// </summary>
        public void NextQuestion()
        {
            //First, determine what our current level should be, and by threshold move to the next level if needed
            MM_Training_Level FoundLevel;

            if (CurrentLevel == null)
            {
                PriorLevel = null;
                if (!Levels.TryGetValue(0, out FoundLevel))
                {
                    TrainingMode = enumTrainingMode.NotTraning;
                    return;
                }
                else
                {
                    CurrentLevel = FoundLevel;
                }
            }
            else if (LevelScore >= CurrentLevel.ExitThresholdScore && QuestionsRight >= CurrentLevel.NumberOfQuestions)
            {
                if (!Levels.TryGetValue(CurrentLevel.ID + 1, out FoundLevel))
                {
                    MessageTime  = DateTime.Now;
                    TrainingMode = enumTrainingMode.UserWon;
                    return;
                }
                else
                {
                    CurrentLevel = FoundLevel;
                }
            }

            else if (QuestionsWrong >= CurrentLevel.FailureThreshold)
            {
                MessageTime  = DateTime.Now;
                TrainingMode = enumTrainingMode.UserFailed;
                return;
            }



            //Based on our question, determine our next
            if (PriorLevel != CurrentLevel)
            {
                PrepareLevel();
            }

            //If we have no elements, assume we won
            if (AvailableElements.Length == 0)
            {
                TrainingMode = enumTrainingMode.UserWon;
                return;
            }

            //Pick random elements based on our needs
            TargetElement = AvailableElements[rnd.Next(0, AvailableElements.Length)];
            if (TargetElement is MM_Line || TargetElement is MM_Substation)
            {
            }
            else
            {
                TargetElement = TargetElement.Substation;
            }

            //Now, handle our target element
            if (TargetElement is MM_Substation)
            {
                MM_Substation TargetSub = (MM_Substation)TargetElement;
                QuestionText = "Where is substation " + TargetSub.LongName + (String.Equals(TargetSub.LongName, TargetSub.Name, StringComparison.CurrentCultureIgnoreCase) ? "?" : " (" + TargetSub.Name + ")?");
            }
            else if (TargetElement is MM_Line)
            {
                MM_Line TargetLine = (MM_Line)TargetElement;
                QuestionText = "Where is line " + TargetLine.Name + " (from " + TargetLine.Substation1.LongName + " to " + TargetLine.Substation2.LongName + ")?";
            }
            else
            {
                QuestionText = "Where is " + TargetElement.ElemType.Name + " " + TargetElement.Name + "?";
            }
            Data_Integration.ReportSystemLevelData(QuestionText);
            TrainingMode          = enumTrainingMode.QuestionAsked;
            TimeQuestionPresented = DateTime.Now;
        }