Ejemplo n.º 1
0
        public async void CheckAnswer(SocketMessage rawMessage)
        {
            // If we arn't running, don't bother checking
            if (!IsRunning)
            {
                return;
            }

            // If we've gotten this far, our message is almost definitely an attempt at a 1-4 answer.
            // Figure out if the user has already tried to answer this question
            if (hasAnsweredCurrentQuestion.ContainsKey(rawMessage.Author.Id))
            {
                return;
            }
            else
            {
                hasAnsweredCurrentQuestion.Add(rawMessage.Author.Id, true);
            }

            // Figure out if they answered correctly.
            // Since our answer indexes are 0-3, just add 1 to get the corrisponding answer attempt
            if (rawMessage.Content == (questionSetManager.CurrentQuestion.AnswerNumber + 1).ToString())
            {
                hasAnsweredCurrentQuestion.Clear();
                QuestionAnswered?.Invoke(this, new QuestionAnsweredEventArgs(questionSetManager.CurrentQuestion, rawMessage.Author));
                // Give them a point
                scoreKeeper.AddScore(rawMessage.Author, 1);
                // And ask the next question
                GetNextQuestion();
            }
        }
Ejemplo n.º 2
0
 public Tasks()
 {
     InitializeComponent();
     checkBtn.Click  += delegate { QuestionAnswered?.Invoke(this, EventArgs.Empty); };
     Load            += delegate { TestOpen?.Invoke(this, EventArgs.Empty); };
     checkBtn.Enabled = false;
 }
Ejemplo n.º 3
0
 protected void OnQuestionAnswered(string playerName, bool correctAnswer)
 {
     QuestionAnswered?.Invoke(this, new QuestionAnsweredEventArgs
     {
         PlayerName    = playerName,
         CorrectAnswer = correctAnswer,
     });
 }
Ejemplo n.º 4
0
        /// <summary>
        /// This will move the current question index by 1
        /// </summary>
        public virtual QuestionAnswered AnswerCurrentQuestion(int alternativeIndex)
        {
            if (isQuestionsAllAnswered)
            {
                return(null);
            }

            var curQuestion = GetCurrentQuestion();

            if (curQuestion == null)
            {
                Debug.LogWarning("No question found for index: " + mCurQuestionIndex);
                return(null);
            }

            int    correctAltIndex = -1;
            string correctAltId    = curQuestion.correctAlternativeId;

            for (int i = 0; i < curQuestion.alternatives.Length; i++)
            {
                if (curQuestion.alternatives[i].alternativeId == correctAltId)
                {
                    correctAltIndex = i;
                    break;
                }
            }

            var newAnswered = new QuestionAnswered(mCurQuestionIndex, curQuestion.questionId, alternativeIndex, curQuestion.alternatives[alternativeIndex].alternativeId, correctAltIndex);

            //don't submit if it's already answered
            int questionInd = -1;

            for (int i = 0; i < mQuestionsAnsweredList.Count; i++)
            {
                if (mQuestionsAnsweredList[i].answer.questionId == newAnswered.answer.questionId)
                {
                    questionInd = i;
                    break;
                }
            }

            if (questionInd == -1)
            {
                newAnswered.Submit();

                mQuestionsAnsweredList.Add(newAnswered);
            }

            mCurQuestionIndex++;

            return(newAnswered);
        }
Ejemplo n.º 5
0
 private void _view_QuestionAnswered(object sender, EventArgs e)
 {
     QuestionAnswered.Invoke(this, null);
 }
Ejemplo n.º 6
0
 public void HandleAnswer(Response answer, Action callback, string lastQuestionKey)
 {
     QuestionAnswered?.Invoke(this, new QuestionAnsweredEventArgs(answer, callback, lastQuestionKey));
 }