Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

True/False Quiz: how to show incorrect answers at the end of quiz

$
0
0

I am working on a True/False Quiz. Here is part of my code for setting the questions in the quiz and also the "ResultsPage". The ResultsPage, however, only indicates the score (i.e. "5 out of 14"), and I'd like it to indicate which questions were the "errors". How best to go about this? Thanks.

QuizPageModel.cs
questions = new List()
{
new Question() { QuestionText="1=2", Answer=false } ,

            new Question() { QuestionText="2=5", Answer=false },
            new Question() { QuestionText="5=2+3", Answer=true},

            new Question() { 4*4=8", Answer=false },

        };

//True/False

        AnsweredTrue = new Command(async () =>
        {
        Debug.WriteLine("True button pressed");

            // check if answer is correct
            if (_currentAnswerValue == true)

                score++;
            AnsweredFalse = new Command(async () =>
        {
        Debug.WriteLine("False button pressed");



        // check if answer is correct
        if (_currentAnswerValue == false)
                score++;

        else
            {


            }

ResultsPage.xaml

ResultsPage.xaml.cs
public ResultsPage(int score, int total)
{
InitializeComponent();

    ScoreText.Text = $"{score} out of {total}";
}

Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>