/// <summary> /// Get a question and answers, with a list of possible incorrect answers. /// </summary> /// <param name="question"></param> /// <param name="correctAnswer"></param> /// <param name="wrongAnswers"></param> public void GetQuestion(out FlashCard questionCard, out Translation correctTranslation, out List <FlashCard> wrongQuestionCards, out List <Translation> wrongTranslations) { //grab a random flash card to be the question questionRand.MaxNum = Cards.Count - 1; var cardIndex = questionRand.Next(); questionCard = Cards[cardIndex]; //Get the correct answer var correctIndex = translationRand.Next(questionCard.Translations.Count); var correctAnswer = questionCard.Translations[correctIndex]; correctTranslation = correctAnswer; //add all the possible incorrect answers wrongQuestionCards = new List <FlashCard>(); wrongTranslations = new List <Translation>(); for (int i = 0; i < Cards.Count; i++) { if (cardIndex != i) { //Get the translation from this card that matches the correct answer var wrongCard = Cards[i]; var wrongAnswer = wrongCard.Translations.FirstOrDefault(x => x.Language == correctAnswer.Language); if (null != wrongAnswer) { wrongQuestionCards.Add(wrongCard); wrongTranslations.Add(wrongAnswer); } } } }
/// <summary> /// The user selected an answer. /// Set the flags, menu entry colors, and start timer. /// </summary> private void AnswerSelected(bool correctAnswer, FlashCard selectedAnswer) { QuestionStateMachine.Done(); if (!AnswerChosen) { //set flags AnswerChosen = true; AnsweredCorrect = correctAnswer; //Set all the colors of the answers to let the user know which was the correct answer foreach (var entry in Entries) { entry.QuestionAnswered = true; } if (null != QuestionAnswered) { QuestionAnswered(this, new QuestionEventArgs(AnsweredCorrect, correctQuestion, selectedAnswer)); } //start the timer to exit this screen AutoQuit.Start(1f); if (null != OverlayScreen) { OverlayScreen.ExitScreen(); } } }
protected virtual QuestionMenuEntry CreateQuestionMenuEntry(string text, FlashCard flashCard, bool correctAnswer, ContentManager content) { return(new QuestionMenuEntry(text, flashCard, correctAnswer, content) { TransitionObject = new WipeTransitionObject(TransitionWipeType.PopBottom), }); }
private void ParseCardXmlNodes(XmlNode xmlNode) { //create a new flash card var card = new FlashCard() { Language1 = this.Language1, Language2 = this.Language2 }; //read it in XmlFileBuddy.ReadChildNodes(xmlNode, card.ParseChildNode); //store the card Cards.Add(card); }
protected virtual QuestionMenuEntry CreateQuestionMenuEntry(string text, FlashCard flashCard, bool correctAnswer, IFontBuddy font) { try { return(new QuestionMenuEntry(text, flashCard, correctAnswer, font) { TransitionObject = new WipeTransitionObject(TransitionWipeType.PopBottom), }); } catch (Exception ex) { ScreenManager.ErrorScreen(ex); throw new Exception($"Error creating menu entry for {text}", ex); } }
private void Init(FlashCard flashCard, bool correctAnswer) { FlashCard = flashCard; CorrectAnswer = correctAnswer; Label.ShrinkToFit(Resolution.TitleSafeArea.Width); QuestionLabel.IsCorrectAnswer = correctAnswer; OnClick += QuestionLabel.OnAnswer; Highlightable = false; //Setting the resource name here will cause the correct sound effect to be loaded an played when this button is clicked ClickedSound = correctAnswer ? "CorrectAnswer" : "WrongAnswer"; if (Rect.Width < QuestionLabel.Rect.Width) { Size = new Microsoft.Xna.Framework.Vector2(QuestionLabel.Rect.Width, Size.Y); } }
public QuestionMenuEntry(string text, FlashCard flashCard, bool correctAnswer, ContentManager content) : base(text, content) { Init(flashCard, correctAnswer); }
public QuestionMenuEntry(string text, FlashCard flashCard, bool correctAnswer, IFontBuddy font) : base(text, font) { Init(flashCard, correctAnswer); }
public void LoadSoundEffect(string language, ContentManager content) { SoundEffect = FlashCard.LoadSoundEffect(language, content); }
public QuestionEventArgs(bool answeredCorrectly, FlashCard correctAnswer, FlashCard selectedAnswer) { AnsweredCorrectly = answeredCorrectly; CorrectAnswer = correctAnswer; SelectedAnswer = selectedAnswer; }