예제 #1
0
        //Questoes//

        //public static CQuestao GetQuiz(object nivel) {
        //    CQuestao ret = null;
        //    using (SQLiteConnection conn = new SQLiteConnection(path)) {
        //        using (SQLiteCommand comm = new SQLiteCommand("SELECT * FROM Questoes WHERE nivel = @nivel ORDER BY Random() LIMIT 1", conn)) {
        //            comm.Parameters.AddWithValue("@nivel", nivel);
        //            conn.Open();
        //            using (SQLiteDataReader reader = comm.ExecuteReader()) {
        //                while (reader.Read()) {
        //                    ret = new CQuestao(int.Parse(reader["Id"].ToString())) {
        //                        Pergunta = reader["pergunta"].ToString(),
        //                        Nivel = reader["Nivel"].ToString(),
        //                        listaRespostas = new List<CResposta> {
        //                            new CResposta() {
        //                                resposta = reader["resposta"].ToString(),
        //                                certa = true
        //                            },
        //                            new CResposta() {
        //                                resposta = reader["posivel1"].ToString(),
        //                                certa = false
        //                            },
        //                            new CResposta() {
        //                                resposta = reader["posivel2"].ToString(),
        //                                certa = false
        //                            }
        //                        }
        //                    };
        //                }
        //            }
        //        }
        //    }
        //    return ret;
        //}

        public static CQuestao GetPergunta(int id)
        {
            CQuestao         ret = null;
            List <CResposta> respTemp;

            using (SQLiteConnection conn = new SQLiteConnection(path)) {
                using (SQLiteCommand comm = new SQLiteCommand("SELECT * FROM Questoes WHERE Id_Questao = @Id_Questao", conn)) {
                    comm.Parameters.AddWithValue("@Id_Questao", id);
                    conn.Open();
                    using (SQLiteDataReader reader = comm.ExecuteReader()) {
                        while (reader.Read())
                        {
                            respTemp = GetRespostas(int.Parse(reader["Id_Questao"].ToString()));

                            ret = new CQuestao()
                            {
                                Id             = int.Parse(reader["Id_Questao"].ToString()),
                                Pergunta       = reader["pergunta"].ToString(),
                                Nivel          = reader["Nivel_Questao"].ToString(),
                                listaRespostas = respTemp
                            };
                        }
                    }
                }
            }
            return(ret);
        }
예제 #2
0
        private void GetInfo(object sender, EventArgs e)
        {
            editando      = ((JogoAddItemControl)sender).questao;
            rtbTexto.Text = editando.Pergunta;
            listaControlesRespostas.Clear();
            pRespostas.Controls.Clear();
            if (editando.Nivel == "BASICO")
            {
                rbBasico.Checked = true;
            }
            else if (editando.Nivel == "INTERMEDIARIO")
            {
                rbIntermediario.Checked = true;
            }
            else
            {
                rbAvancado.Checked = true;
            }

            foreach (CResposta item in editando.listaRespostas)
            {
                JogoAddResposta temp = new JogoAddResposta()
                {
                    resposta = item, Dock = DockStyle.Top
                };
                temp.cbCheck.CheckedChanged += RbVerdadeiraCheck_CheckedChanged;

                listaControlesRespostas.Add(temp);
                pRespostas.Controls.Add(temp);
            }

            btnConfirmar.Enabled = btnAdicionarResposta.Enabled = rtbTexto.Enabled = true;
        }
예제 #3
0
 public static int SetPergunta(CQuestao pergunta)
 {
     using (SQLiteConnection conn = new SQLiteConnection(path)) {
         using (SQLiteCommand comm = new SQLiteCommand("INSERT INTO Questoes(Pergunta, Nivel_Questao) VALUES(@Pergunta, @Nivel_Questao)", conn)) {
             comm.Parameters.AddWithValue("@Pergunta", pergunta.Pergunta);
             comm.Parameters.AddWithValue("@Nivel_Questao", pergunta.Nivel);
             conn.Open();
             if (comm.ExecuteNonQuery() != 0)
             {
                 return(int.Parse(conn.LastInsertRowId.ToString()));
             }
             return(-1);
         }
     }
 }
예제 #4
0
        private void btnNovo_Click(object sender, EventArgs e)
        {
            listaControlesRespostas.Clear();
            pRespostas.Controls.Clear();

            editando = new CQuestao()
            {
                listaRespostas = new List <CResposta>(),
                Nivel          = "BASICO"
            };

            rbBasico.Checked = true;

            btnAdicionarResposta.Enabled = btnConfirmar.Enabled = rtbTexto.Enabled = true;
        }
예제 #5
0
 public static bool UpdatePergunta(CQuestao questao)
 {
     using (SQLiteConnection conn = new SQLiteConnection(path)) {
         using (SQLiteCommand comm = new SQLiteCommand("UPDATE Questoes SET Pergunta = @Pergunta, Nivel_Questao = @Nivel_Questao WHERE Id_Questao = @Id_Questao", conn)) {
             comm.Parameters.AddWithValue("@Id_Questao", questao.Id);
             comm.Parameters.AddWithValue("@Pergunta", questao.Pergunta);
             comm.Parameters.AddWithValue("@Nivel_Questao", questao.Nivel);
             conn.Open();
             if (comm.ExecuteNonQuery() != 0)
             {
                 return(true);
             }
             return(false);
         }
     }
 }
예제 #6
0
        private void btnConfirmar_Click(object sender, EventArgs e)
        {
            foreach (JogoAddResposta item in listaControlesRespostas)
            {
                item.ConfirmarAlteracoes();

                MessageBox.Show(item.resposta.resposta + " ::: " + item.resposta.certa);
                editando.listaRespostas.Find(x => x.id_Resposta == item.resposta.id_Resposta).resposta = item.resposta.resposta;
            }

            editando.Pergunta = rtbTexto.Text;
            editando.GravarAlteracao();

            listaQuestoes = CQuestao.GetQuestoes();
            pQuestoesItem.Controls.Clear();
            foreach (CQuestao item in listaQuestoes)
            {
                JogoAddItemControl temp = new JogoAddItemControl()
                {
                    questao = item,
                    Dock    = DockStyle.Top
                };
                temp.EventHandler += GetInfo;
                pQuestoesItem.Controls.Add(temp);
            }

            editando = listaQuestoes.Find(x => x.Id == editando.Id);

            rtbTexto.Text = editando.Pergunta;
            listaControlesRespostas.Clear();
            pRespostas.Controls.Clear();

            foreach (CResposta item in editando.listaRespostas)
            {
                JogoAddResposta temp = new JogoAddResposta()
                {
                    resposta = item, Dock = DockStyle.Top
                };
                temp.cbCheck.CheckedChanged += RbVerdadeiraCheck_CheckedChanged;

                listaControlesRespostas.Add(temp);
                pRespostas.Controls.Add(temp);
            }
        }
예제 #7
0
        private void btnIniciar_Click(object sender, EventArgs e)
        {
            temp        = 90;
            resposta    = false;
            pontoSomado = true;

            if (aux > 0)
            {
                questao = questoes[rand.Next(aux)];
            }

            rtbTexto.Text = questao.Pergunta;
            richTextBox1  = null;
            questao.listaRespostas.OrderBy(x => rand.Next());
            pRespostas.Controls.Clear();

            foreach (CResposta item in questao.listaRespostas)
            {
                RadioButton rad = new RadioButton()
                {
                    Dock     = DockStyle.Top,
                    Text     = item.resposta,
                    Tag      = item.certa,
                    Padding  = new Padding(15, 10, 10, 10),
                    AutoSize = true
                };

                rad.CheckedChanged += rbCheck_CheckedChanged;
                pRespostas.Controls.Add(rad);
            }

            btnIniciar.Enabled   = false;
            btnIniciar.Text      = "Próxima";
            btnVerificar.Enabled = true;
            tContador.Start();
        }
예제 #8
0
 private void JogoControl_Load(object sender, EventArgs e)
 {
     questoes = CQuestao.GetQuestoes(CGlobalStatica.usuarioGlobal.NivelJogo);
     aux      = questoes.Count();
 }