예제 #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
        public async Task <IActionResult> AnswerQuestion(Answered answered, int id)
        {
            var questionRepo = await _repo.GetQuestion(id);

            if (questionRepo == null)
            {
                return(BadRequest("There is no questions left,or there is no such a question"));
            }
            answered.QuestionName  = questionRepo.Name;
            answered.CorrectAnswer = questionRepo.CorrectAnswer;

            questionRepo.isAnswered = true;

            if (questionRepo.CorrectAnswer == answered.YourAnswer)
            {
                answered.PointEarned = questionRepo.Points;
            }


            await _context.Answereds.AddAsync(answered);

            await _context.SaveChangesAsync();

            return(Ok(answered));
        }
 public void SaveAnswer(Answered answer)
 {
     _realm.Write(() =>
     {
         _realm.Add(answer);
     });
 }
예제 #4
0
        private void HandleCallAnswered(Answered answered)
        {
            var eventToStore = new CallAnswered()
            {
                ConversationId = Guid.Parse(FormatUuid(answered.ConversationUuid))
            };

            this._session.Events.Append(eventToStore.ConversationId, eventToStore);
        }
예제 #5
0
        protected virtual void OnAnswered(AnswerEventArgs e)
        {
            Answered?.Invoke(this, e);

            if (e.invalid)
            {
                Console.WriteLine("Invalid Answer");
                Execute();
            }
        }
예제 #6
0
 /// <summary>
 ///     Tries to answer specified question with given answer
 /// </summary>
 /// <param name="question">Question to answer</param>
 /// <param name="answer">Answer to question</param>
 /// <returns>
 ///     True when answer is correct, false otherwise.
 /// </returns>
 /// <exception cref="System.ArgumentException">
 ///     Thrown when question is not part of exercise.
 /// </exception>
 public bool Answer(Question question, string answer)
 {
     if (!Unanswered.Contains(question))
     {
         throw new ArgumentException(
                   string.Format("Question {0} is not part of exercise", question.Content));
     }
     if (!question.IsCorrect(answer))
     {
         Question head = Unanswered.First();
         Unanswered.RemoveAt(0);
         Unanswered.Add(head);
         return(false);
     }
     Answered.Add(question);
     Unanswered.Remove(question);
     return(true);
 }
        public async void OnNavigatedTo(NavigationParameters parameters)
        {
            if (parameters.ContainsKey(Constants.Answer))
            {
                _answered = (Answered)parameters[Constants.Answer];
            }

            if (parameters.ContainsKey(Constants.Title))
            {
                Title = (string)parameters[Constants.Title];
            }

            if (parameters.ContainsKey(Constants.GoBack))
            {
                if ((bool)parameters[Constants.GoBack])
                {
                    await _navigationService.GoBackAsync();
                }
            }
        }
예제 #8
0
        public async Task UpdateAnswered()
        {
            Answered ans = new Answered();

            ans.Answer     = UserBuzzedText;
            ans.Correct    = Question.Answer;
            ans.AnswerID   = Question.AnswerID;
            ans.QuestionID = Question.ID;
            ans.Category   = Question.Category;
            ans.Clue       = CurrentClue;

            var Ans = UserProfile.Answers.FirstOrDefault(x => x.ID == Answer.ID);

            ans.Difficulty = Ans.Difficulty;
            ans.Negs       = Ans.Negs;
            ans.Rating     = Ans.Rating;
            ans.Score      = Ans.Score;

            AnsweredRest ansRest = new AnsweredRest();

            ansRest.answerid   = ans.AnswerID;
            ansRest.buzzed     = ans.Answer;
            ansRest.clue       = CurrentClue;
            ansRest.questionid = ans.QuestionID;
            ansRest.rating     = ans.Rating;
            ansRest.score      = ans.Score;
            ansRest.userid     = Xamarin.Essentials.Preferences.Get("userid", 243);

            var current = Connectivity.NetworkAccess;

            if (current == NetworkAccess.Internet)
            {
                RestService r = new RestService();
                await r.Get("/wake");

                await r.PostAnswer("/postdata", ansRest);
            }

            DatabaseManager dbM = new DatabaseManager();
            await dbM.InsertAnsweredRead(ans);
        }
예제 #9
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
        }
        private async void EmotionTapped(string obj)
        {
            var answer = new Answered();

            answer.Emotion     = obj;
            answer.UpdatedTime = DateTimeOffset.UtcNow;
            Debug.WriteLine($"Emotion Tapped : {obj}");
            var moreDetailsEntered = await _pageDialogService.DisplayAlertAsync($"Feeling {obj}", "Would you like to add more details?", "Yes", "No");

            answer.MoreDetailsEntered = moreDetailsEntered;
            if (moreDetailsEntered)
            {
                var parameters = new NavigationParameters {
                    { Constants.Answer, answer }, { Constants.Title, $"Feeling {obj}. Because..." }
                };
                await _navigationService.NavigateAsync(Constants.CommentsPage, parameters);
            }
            else
            {
                _realmService.SaveAnswer(answer);
                await _navigationService.NavigateAsync(Constants.QuotePage);
            }
        }
예제 #11
0
 protected void OnAnswered(string str)
 {
     Answered?.Invoke(this, str);
 }
예제 #12
0
 protected internal virtual void OnAnswered(EventArgs <T> e)
 {
     Answered?.Invoke(this, e);
 }
예제 #13
0
 private void SendAnswer(IMolfarAnswer answer)
 {
     Answered?.Invoke(this, answer);
 }
예제 #14
0
 private void SendAnswer(string message)
 {
     Answered?.Invoke(this, new MolfarAnswer(message));
 }
 public async Task <int> InsertAnsweredRead(Answered answered)
 {
     return(await dbConnection.ExecuteAsync("INSERT INTO Answered (AnswerId, Answer, Category, Difficulty, Rating, Negs, Score, Correct, Clue) VALUES (?,?,?,?,?,?,?,?,?)", answered.AnswerID, answered.Answer, answered.Category, answered.Difficulty, answered.Rating, answered.Negs, answered.Score, answered.Correct, answered.Clue));
 }
예제 #16
0
 protected virtual void OnAnswered()
 {
     Answered?.Invoke(this, EventArgs.Empty);
 }
예제 #17
0
 protected virtual void OnAnswered(iFruitContact sender)
 {
     Answered?.Invoke(this);
 }