Ejemplo n.º 1
0
 private void LoadPergunta(Pergunta p, int i)
 {
     if (p.Dissertativa)
     {
         label.Text        = $"{i}- {p.Texto}";
         txtRespostaA.Text = "";
         txtRespostaB.Text = "";
         txtRespostaC.Text = "";
         txtRespostaD.Text = "";
     }
     else
     {
         label.Text        = $"{i}- {p.Texto}";
         txtRespostaA.Text = $"A) {p.Respostas[0]}";
         txtRespostaB.Text = $"B) {p.Respostas[1]}";
         txtRespostaC.Text = $"C) {p.Respostas[2]}";
         txtRespostaD.Text = $"D) {p.Respostas[3]}";
     }
     if (p.TemImagem)
     {
         img.Visibility = Visibility.Visible;
         img.Source     = Serializa.GetImageSourceFromImage(p.Imagem);
         Grid.SetColumn(stpRespostas, 1);
     }
     else
     {
         img.Visibility = Visibility.Collapsed;
         Grid.SetColumn(stpRespostas, 0);
     }
 }
Ejemplo n.º 2
0
        public PerguntaExpander(Pergunta pergunta)
        {
            InitializeComponent();
            this.pergunta         = pergunta;
            txtTextoPergunta.Text = pergunta.Texto;
            if (pergunta.Dissertativa)
            {
                txtRespostaA.Visibility = Visibility.Hidden;
                txtRespostaB.Visibility = Visibility.Hidden;
                txtRespostaC.Visibility = Visibility.Hidden;
                txtRespostaD.Visibility = Visibility.Hidden;

                rdbRespostaA.Visibility = Visibility.Hidden;
                rdbRespostaB.Visibility = Visibility.Hidden;
                rdbRespostaC.Visibility = Visibility.Hidden;
                rdbRespostaD.Visibility = Visibility.Hidden;

                txtRespostaDissertativa.Visibility = Visibility.Visible;

                txtRespostaDissertativa.Text = pergunta.Respostas[0];
            }
            else
            {
                txtRespostaA.Text = pergunta.Respostas[0];
                txtRespostaB.Text = pergunta.Respostas[1];
                txtRespostaC.Text = pergunta.Respostas[2];
                txtRespostaD.Text = pergunta.Respostas[3];

                rdbRespostaA.IsChecked = pergunta.Correta == pergunta.Respostas[0];
                rdbRespostaB.IsChecked = pergunta.Correta == pergunta.Respostas[1];
                rdbRespostaC.IsChecked = pergunta.Correta == pergunta.Respostas[2];
                rdbRespostaD.IsChecked = pergunta.Correta == pergunta.Respostas[3];
            }

            rdbRespostaA.GroupName    = pergunta.Texto;
            rdbRespostaB.GroupName    = pergunta.Texto;
            rdbRespostaC.GroupName    = pergunta.Texto;
            rdbRespostaD.GroupName    = pergunta.Texto;
            tgbDissertativa.IsChecked = pergunta.Dissertativa;
            tgbTopQuiz.IsChecked      = pergunta.TopQuiz;

            tgbImagem.IsChecked = pergunta.TemImagem;

            if (pergunta.TemImagem)
            {
                img1.Source = Serializa.GetImageSourceFromImage(pergunta.Imagem);
            }
        }
Ejemplo n.º 3
0
        private void btnSalvar_Click(object sender, RoutedEventArgs e)
        {
            string correta = "";

            if (rdbRespostaA.IsChecked == true)
            {
                correta = txtRespostaA.Text;
            }

            if (rdbRespostaB.IsChecked == true)
            {
                correta = txtRespostaB.Text;
            }

            if (rdbRespostaC.IsChecked == true)
            {
                correta = txtRespostaC.Text;
            }

            if (rdbRespostaD.IsChecked == true)
            {
                correta = txtRespostaD.Text;
            }

            if (tgbDissertativa.IsChecked == true)
            {
                correta = txtRespostaDissertativa.Text;
            }

            Pergunta newPergunta = new Pergunta
            {
                Imagem                                 = tgbImagem.IsChecked == true?Serializa.GetImageFromImageSource(img1.Source) : null,
                                             Texto     = expPergunta.Header.ToString(),
                                             TopQuiz   = tgbTopQuiz.IsChecked == true,
                                             Correta   = correta,
                                             Respostas = tgbDissertativa.IsChecked == true ? new[] { txtRespostaDissertativa.Text } : new[] { txtRespostaA.Text, txtRespostaB.Text, txtRespostaC.Text, txtRespostaD.Text },
            };

            Data.DataManager.UpdatePergunta(pergunta.Id, newPergunta);
            MainWindow.Notificar("Pergunta editada com sucesso!");
        }
Ejemplo n.º 4
0
        private void btnConfirmarAdicionarPergunta_Click(object sender, RoutedEventArgs e)
        {
            if (tgbDissertativa.IsChecked == true)
            {
                if (string.IsNullOrWhiteSpace(txtRespostaDissertativa.Text))
                {
                    txtRespostaDissertativa.Focus();
                    return;
                }


                var pergunta = new Pergunta
                {
                    Texto     = txtTextoPergunta.Text,
                    Imagem    = Serializa.GetImageFromImageSource(img1.Source),
                    TopQuiz   = tgbTopQuiz.IsChecked ?? false,
                    Correta   = txtRespostaDissertativa.Text,
                    Respostas = new[] { txtRespostaDissertativa.Text }
                };

                Data.DataManager.AddPergunta(pergunta);
                dlgAddPergunta.IsOpen = false;
            }
            else
            {
                if (string.IsNullOrWhiteSpace(txtRespostaA.Text))
                {
                    txtRespostaA.Focus();
                    return;
                }
                if (string.IsNullOrWhiteSpace(txtRespostaB.Text))
                {
                    txtRespostaB.Focus();
                    return;
                }
                if (string.IsNullOrWhiteSpace(txtRespostaC.Text))
                {
                    txtRespostaC.Focus();
                    return;
                }
                if (string.IsNullOrWhiteSpace(txtRespostaD.Text))
                {
                    txtRespostaD.Focus();
                    return;
                }


                var correta = "";
                if (rdbRespostaA.IsChecked ?? false)
                {
                    correta = txtRespostaA.Text;
                }
                if (rdbRespostaB.IsChecked ?? false)
                {
                    correta = txtRespostaB.Text;
                }
                if (rdbRespostaC.IsChecked ?? false)
                {
                    correta = txtRespostaC.Text;
                }
                if (rdbRespostaD.IsChecked ?? false)
                {
                    correta = txtRespostaD.Text;
                }

                var pergunta = new Pergunta
                {
                    Texto     = txtTextoPergunta.Text,
                    Imagem    = Serializa.GetImageFromImageSource(img1.Source),
                    TopQuiz   = tgbTopQuiz.IsChecked ?? false,
                    Correta   = correta,
                    Respostas = new [] { txtRespostaA.Text, txtRespostaB.Text, txtRespostaC.Text, txtRespostaD.Text },
                };

                Data.DataManager.AddPergunta(pergunta);
                dlgAddPergunta.IsOpen = false;
            }
            txtTextoPergunta.Text        = "";
            txtRespostaA.Text            = "";
            txtRespostaB.Text            = "";
            txtRespostaC.Text            = "";
            txtRespostaD.Text            = "";
            txtRespostaDissertativa.Text = "";


            Notificar("Pergunta adicionada com sucesso!");
            AtualizarPerguntas();
        }