示例#1
0
        public void OnParticipantKeyDown(object sender, ParticipantKey key)
        {
            if (_answers.ContainsKey(key.ParticipantNo) && _answers[key.ParticipantNo].QuestionChoice == null)
            {
                if (_question.Choices.Count >= key.AnswerNo)
                {
                    var answer = _answers[key.ParticipantNo];
                    var choice = _question.Choices[key.AnswerNo - 1];
                    answer.QuestionChoice = choice;
                    answer.CompetitionParticipant.Unanswered -= 1;
                    if (choice.IsAnswer)
                    {
                        answer.Score = choice.Question.Score;
                        answer.CompetitionParticipant.Score           += answer.Score;
                        answer.CompetitionParticipant.AnsweredCorrect += 1;
                    }
                    else
                    {
                        answer.CompetitionParticipant.AnsweredIncorrect += 1;
                    }
                    answer.TimeTaken = (DateTime.Now - _startTime).TotalSeconds;

                    Answered?.Invoke(answer);

                    ParticipantAnswer.Text += _answers.Values.Count(t => t.QuestionChoice != null) > 1
                        ? $"  {key.ParticipantNo}号选手已回答"
                        : $"{key.ParticipantNo}号选手已抢答";
                }
            }
        }
示例#2
0
        protected virtual void OnAnswered(AnswerEventArgs e)
        {
            Answered?.Invoke(this, e);

            if (e.invalid)
            {
                Console.WriteLine("Invalid Answer");
                Execute();
            }
        }
示例#3
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            RadioButton checkedButton;

            //Checks to see if the user has selected an answer
            if (AnswerRadioButton1.Checked == true)
            {
                checkedButton = AnswerRadioButton1;
            }
            else if (AnswerRadioButton2.Checked == true)
            {
                checkedButton = AnswerRadioButton2;
            }
            else if (AnswerRadioButton3.Checked == true)
            {
                checkedButton = AnswerRadioButton3;
            }
            else if (AnswerRadioButton4.Checked == true)
            {
                checkedButton = AnswerRadioButton4;
            }
            else
            {
                return;
            }

            //Answer selected is compared against the correct answer
            //A message is displayed telling the user their result and their result is returned
            if (checkedButton.Text == CurrentQuestion.CorrectAns)
            {
                MessageBox.Show("Correct", "Well Done", MessageBoxButtons.OK);
                Answered?.Invoke(this, true);
            }
            else
            {
                MessageBox.Show("Incorrect", "Try Again", MessageBoxButtons.OK);
                Answered?.Invoke(this, false);
            }

            this.Close(); //Form is closed
        }
示例#4
0
 protected void OnAnswered(string str)
 {
     Answered?.Invoke(this, str);
 }
示例#5
0
 protected virtual void OnAnswered()
 {
     Answered?.Invoke(this, EventArgs.Empty);
 }
示例#6
0
 protected internal virtual void OnAnswered(EventArgs <T> e)
 {
     Answered?.Invoke(this, e);
 }
示例#7
0
 private void SendAnswer(IMolfarAnswer answer)
 {
     Answered?.Invoke(this, answer);
 }
示例#8
0
 private void SendAnswer(string message)
 {
     Answered?.Invoke(this, new MolfarAnswer(message));
 }
示例#9
0
 protected virtual void OnAnswered(iFruitContact sender)
 {
     Answered?.Invoke(this);
 }