Exemplo n.º 1
0
        internal static Reponse Save(Reponse reponse)
        {
            string connStr = Utils.GetConn;

            using (MySqlConnection conn = new MySqlConnection(connStr))
            {
                string sql = "INSERT INTO Reponse VALUES (@id, @texte, @niveau)";
                if (reponse.Id != 0)
                {
                    sql = "UPDATE Reponse SET r_texte = @texte, r_niveau = @niveau WHERE r_id = @id";
                }

                conn.Open();
                using (MySqlCommand cmd = new MySqlCommand(sql, conn))
                {
                    cmd.Parameters.Add(new MySqlParameter("@id", reponse.Id));
                    cmd.Parameters.Add(new MySqlParameter("@texte", reponse.Label));
                    cmd.Parameters.Add(new MySqlParameter("@niveau", reponse.NiveauId));
                    using (MySqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            fill(reponse, dr);
                        }
                    }
                }
            }
            return(reponse);
        }
Exemplo n.º 2
0
        private void BtnCommencer_Click(object sender, EventArgs e)
        {
            List <Quiz> quiz = QuizDAO.FindAll();
            //Quiz quizz;
            Quiz quizz = comboBox1.SelectedItem as Quiz;//il faut caster selectedItem retourne un objet dc il faut  que cet objet devin un quiz


            List <Question> questions = QuestionDAO.FindAll(quizz.QuizId);

            Question q = questions[0];

            groupBox1.Text = q.Enonce;

            List <Reponse> Reponses      = ReponseDAO.FindAll(quizz.QuizId);
            Reponse        reponse       = Reponses[0];
            RadioButton    nouveauBouton = new RadioButton
            {
                Name     = "radioButton1",
                Location = new Point((MARGE + SIZE) * nbNouveauBouton + MARGE, 365),
                // Name = "RadioButtonNew" + ++nbNouveauBouton,
                Size     = new Size(SIZE, 23),
                TabIndex = dernierTabIndex++,
                Text     = reponse.Texte,



                // Location = new Point(409, 315);


                //TabStop = true;

                // UseVisualStyleBackColor = true;
                // CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
            };
        }
Exemplo n.º 3
0
        public void Load_Reponse()
        {
            idTest = 1;
            Reponse reponse = new Reponse();

            using (MySqlConnection conn = new MySqlConnection(connStr))
            {
                string sql = "SELECT * FROM Reponse WHERE r_id = @id";
                conn.Open();
                using (MySqlCommand cmd = new MySqlCommand(sql, conn))
                {
                    cmd.Parameters.Add(new MySqlParameter("@id", idTest));
                    using (MySqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            reponse.Id    = (int)dr["r_id"];
                            reponse.Label = (string)dr["r_texte"];
                        }
                    }
                }
            }
            Assert.AreEqual(reponse.Id, 1);
            Assert.AreEqual(reponse.Label, "300");
            Trace.WriteLine("id: " + reponse.Id + " URL: " + reponse.Label);
        }
Exemplo n.º 4
0
        public async Task <ActionResult <Reponse> > PutReponse(int id, Reponse reponse)
        {
            if (id != reponse.id)
            {
                return(BadRequest());
            }

            _context.Entry(reponse).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (await _context.Reponses.FindAsync(id) == null)
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(await _context.Reponses.FindAsync(id));
        }
Exemplo n.º 5
0
        internal static List <Reponse> ListMauvaiseReponse(int id, NiveauIds niveau)
        {
            List <Reponse> listReponse = new List <Reponse>();
            string         connStr     = Utils.GetConn;

            using (MySqlConnection conn = new MySqlConnection(connStr))
            {
                string sql = "SELECT * FROM Reponse WHERE r_id != @id and r_niveau = @niveau";
                conn.Open();
                using (MySqlCommand cmd = new MySqlCommand(sql, conn))
                {
                    cmd.Parameters.Add(new MySqlParameter("@id", id));
                    cmd.Parameters.Add(new MySqlParameter("@niveau", niveau));
                    using (MySqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            Reponse reponse = new Reponse();
                            fill(reponse, dr);
                            listReponse.Add(reponse);
                        }
                    }
                }
            }
            return(listReponse);
        }
        /// <summary>
        ///       Permet l'ajout d'une réponse dans la base de données.
        /// </summary>
        /// <param name="reponse">Réponse à ajouter.</param>
        /// <returns>L'identifiant de la réponse ajoutée.</returns>
        public async Task <int> AddAsync(Reponse reponse)
        {
            this.context.Reponses.Add(reponse);
            await this.context.SaveChangesAsync().ConfigureAwait(false);

            return(reponse.ReponseId);
        }
Exemplo n.º 7
0
        public void Initialise(int numeroDuParagraphe)
        {
            using (SqlConnection connection = new SqlConnection())
            {
                connection.ConnectionString = Properties.Settings.Default.chaineConnexion;
                connection.Open();
                using (SqlCommand commande = connection.CreateCommand())
                {
                    commande.CommandText = " SELECT Paragraphe.Contenu as contenuParagrahe, " +
                                           " Question.Texte as contenuQuestion, " +
                                           " Reponse.Texte as contenuReponse " +
                                           " FROM Paragraphe " +
                                           " JOIN Question on Paragraphe.Id = question.ParagrapheId " +
                                           " JOIN Reponse on Question.Id = Reponse.QuestionId " +
                                           " WHERE Paragraphe.Numero = " + numeroDuParagraphe + "; ";

                    using (SqlDataReader reader = commande.ExecuteReader())
                    {
                        this.MaQuestion             = new Question();
                        this.MaQuestion.MesReponses = new List <Reponse>();
                        while (reader.Read())
                        {
                            this.Contenu = reader["contenuParagrahe"].ToString();

                            this.MaQuestion.Contenu = reader["contenuQuestion"].ToString();

                            Reponse reponse = new Reponse();
                            reponse.Contenu = reader["contenuReponse"].ToString();
                            this.MaQuestion.MesReponses.Add(reponse);
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        // GESTION POUR LE CHOIX UNIQUE
        public ActionResult VoteSimple(string onechoose, int idSondage)
        {
            //////////////////////////////////////////////////////////////////////////
            if (TestSondagevote(Request.Cookies, idSondage))
            {
                return(RedirectToAction("DejaVoter", new { idSondage = idSondage }));
            }
            ////////////////////////////////////////////////////////////////////
            Reponse model = new Reponse(idSondage);

            switch (onechoose)
            {
            case "Choix1":
                model.NombreVoteC1 = 1;
                break;

            case "Choix2":
                model.NombreVoteC2 = 1;
                break;

            case "Choix3":
                model.NombreVoteC3 = 1;
                break;

            case "Choix4":
                model.NombreVoteC4 = 1;
                break;
            }
            DataAccess.InsertionVoteBDD(idSondage, model.NombreVoteC1, model.NombreVoteC2, model.NombreVoteC3, model.NombreVoteC4);
            SaveCookie(idSondage);
            return(RedirectToAction("Resultat", new { IDSondage = idSondage }));
        }
Exemplo n.º 9
0
        public void MauvaisMessage()
        {
            const string p = "Snort";

            byte[] hash;
            using (HMACSHA256 sha = new HMACSHA256(Key))
            {
                hash = sha.ComputeHash(Encoding.UTF8.GetBytes(p));
            }

            using (RdvController rc = new RdvController())
            {
                rc.Request       = new HttpRequestMessage();
                rc.Configuration = new HttpConfiguration();
                rc.Request.Headers.Add(LapinSignature, BitConverter.ToString(hash).Replace("-", "").ToUpperInvariant());
                rc.Request.Method  = HttpMethod.Post;
                rc.Request.Content = new StringContent(p);

                HttpResponseMessage hrm = rc.NewCalendarEvent();
                string s = hrm.Content.ReadAsStringAsync().Result;

                Reponse r = JsonConvert.DeserializeObject <Reponse>(s);

                Assert.IsTrue(r.Signature);
                Assert.IsTrue("Unexpected character encountered while parsing value: S. Path '', line 0, position 0.".Equals(r.Erreur, StringComparison.Ordinal));
            }
        }
Exemplo n.º 10
0
 public HttpResponseMessage PostReponse(Reponse reponse)
 {
     if (userReponses.Add(reponse))
     {
         return(new HttpResponseMessage(HttpStatusCode.Created));
     }
     return(new HttpResponseMessage(HttpStatusCode.BadRequest));
 }
        public float RetournerValeurReponseCorrecte(string questionID, string optionID)
        {
            IEnumerable <Reponse> LstRep = GetAllResponseForQuestionID(int.Parse(questionID));
            OptionReponse         OpRep  = _db.OptionReponses.FirstOrDefault(x => x.OptionReponseID.ToString() == optionID);
            Reponse rep = LstRep.First(x => x.Libelle == OpRep.Libelle);

            return(rep.NbrePoints);
        }
Exemplo n.º 12
0
        public ActionResult DeleteConfirmed(int id)
        {
            Reponse reponse = db.Reponses.Find(id);

            db.Reponses.Remove(reponse);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 13
0
 public ActionResult AddReponse(Reponse reponse)
 {
     if (ModelState.IsValid)
     {
         reponseService.ajouterReponse(reponse);
     }
     return(View());
 }
Exemplo n.º 14
0
        public ActionResult Resultat(int idSondage)
        {
            Reponse sondage = DataAccess.AfficherQuestionReponse(idSondage);

            sondage.PourcentageDesVotes();

            return(View(sondage));
        }
Exemplo n.º 15
0
        public ActionResult CreateQuestion(QuestionViewModel model)
        {
            if (ModelState.IsValid)
            {
                CategorieQuest cat = categorieService.getCategorieById(model.CategorieID);
                Question       q   = new Question()
                {
                    DescriptionQuest  = model.DescriptionQuest,
                    ReferenceQuest    = model.ReferenceQuest,
                    StatusQuest       = model.StatusQuest,
                    TypeQuest         = model.TypeQuest,
                    categorieId       = model.CategorieID,
                    categorieQuestion = cat
                };
                switch (model.TypeQuest)
                {
                case TypeQuestion.DdlQuestion:
                    List <string> listReponses = model.reponse.Split(',').ToList <string>();
                    for (int i = 0; i < listReponses.Count; i++)
                    {
                        List <string> reponseAnalyses = listReponses[i].Split(':').ToList <string>();
                        Reponse       r = new Reponse
                        {
                            TextReponse = reponseAnalyses[0],
                            AnalyseReponsePointsForts = reponseAnalyses[1],
                            ValeurReponse             = i
                        };
                        q.Reponses.Add(r);
                    }
                    break;

                case TypeQuestion.NoteQuestion:

                    break;

                case TypeQuestion.TextAreaQUestion:

                    break;
                }
                //if(model.TypeQuest == TypeQuestion.QCM_Question)
                //{
                //    List<string> listReponses = model.reponse.Split(',').ToList<string>();
                //    for (int i = 0; i < listReponses.Count; i++)
                //    {
                //        List<string> reponseAnalyses = listReponses[i].Split(':').ToList<string>();
                //        Reponse r = new Reponse
                //        {
                //            TextReponse = reponseAnalyses[0],
                //            AnalyseReponse = reponseAnalyses[1],
                //            ValeurReponse = i
                //        };
                //        q.Reponses.Add(r);
                //    }
                //}
                questionService.ajouterQuestion(q);
            }
            return(View());
        }
Exemplo n.º 16
0
        public IHttpActionResult Create([FromBody] Reponse reponse)
        {
            var reponseToAdd = new FR_DataAccessLayer.Models.Reponse
            {
                Libelle = reponse.Libelle
            };

            reponseAccessLayer.Add(reponseToAdd);
            return(this.Ok("created"));
        }
Exemplo n.º 17
0
 public IActionResult Add(Reponse reponse)
 {
     if (this.ModelState.IsValid)
     {
         this._context.Reponses.Add(reponse);
         this._context.SaveChanges();
     }
     this.ViewBag.QuestionList = this._context.Questions.ToList();
     return(View(reponse));
 }
    public static IApplicationBuilder UseRabbitListener(this IApplicationBuilder app)
    {
        Listener = app.ApplicationServices.GetService <Reponse>();
        var life = app.ApplicationServices.GetService <IApplicationLifetime>();

        life.ApplicationStarted.Register(OnStarted);
        //press Ctrl+C to reproduce if your app runs in Kestrel as a console app
        life.ApplicationStopping.Register(OnStopping);
        return(app);
    }
Exemplo n.º 19
0
 public ActionResult Edit([Bind(Include = "IdReponse,LibelleReponse,IdQuestion")] Reponse reponse)
 {
     if (ModelState.IsValid)
     {
         db.Entry(reponse).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IdQuestion = new SelectList(db.Questions, "IdQuestion", "LibelleQuestion", reponse.IdQuestion);
     return(View(reponse));
 }
Exemplo n.º 20
0
        public Reponse GetReponse(string idReponse)
        {
            Reponse uneReponse = new Reponse();

            if (_mesReponses.ContainsKey(idReponse))
            {
                uneReponse = _mesReponses[idReponse];
            }

            return(uneReponse);
        }
Exemplo n.º 21
0
 public bool ajouterReponse(Reponse reponse)
 {
     if (reponse != null)
     {
         repoRepository.Create(reponse);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 22
0
        public IHttpActionResult Update(int id, [FromBody] Reponse reponse)
        {
            var reponseToUpdate = new FR_DataAccessLayer.Models.Reponse
            {
                Libelle   = reponse.Libelle,
                ReponseId = reponse.ReponseId
            };

            reponseAccessLayer.Update(reponseToUpdate);

            return(this.Ok("updated"));
        }
Exemplo n.º 23
0
        public async Task <IHttpActionResult> Create([FromBody] Reponse reponse)
        {
            var reponseToAdd = new AccessLayer.Models.Reponse
            {
                ReponseLib = reponse.ReponseLib,
                IsOk       = reponse.IsOk
            };

            await reponseAccessLayer.AddAsync(reponseToAdd);

            return(this.Ok("created"));
        }
Exemplo n.º 24
0
        public void TestAnswer2()
        {
            var array = new byte[]
            {
                0x32, 0x45, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x77, 0x77, 0x77,
                0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01,
                0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x04, 0xac, 0xd9, 0x14, 0x04
            };

            var a = new Reponse(array);
            //Assert.Equal(expected, actual);
        }
Exemplo n.º 25
0
    /// <summary>
    /// Ajouts the reponse sujet.
    /// </summary>
    /// <param name="reponse">The reponse.</param>
    /// <returns></returns>
    public Boolean ajoutReponseSujet(Reponse reponse)
    {
        Boolean fait            = false;
        int     longListReponse = listReponse.Count;

        listReponse.Add(reponse);
        if (longListReponse < listReponse.Count)
        {
            fait = true;
        }
        return(fait);
    }
Exemplo n.º 26
0
    public Boolean suppressionReponseSujet(Reponse reponse)
    {
        Boolean fait            = false;
        int     longListReponse = listReponse.Count;

        listReponse.Remove(reponse);
        if (longListReponse > listReponse.Count)
        {
            fait = true;
        }
        return(fait);
    }
Exemplo n.º 27
0
        public ActionResult Create([Bind(Include = "IdReponse,LibelleReponse,IdQuestion")] Reponse reponse)
        {
            if (ModelState.IsValid)
            {
                db.Reponses.Add(reponse);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.IdQuestion = new SelectList(db.Questions, "IdQuestion", "LibelleQuestion", reponse.IdQuestion);
            return(View(reponse));
        }
Exemplo n.º 28
0
        public ActionResult PageVote(int idSondage)
        {
            Reponse model = DataAccess.AfficherQuestionReponse(idSondage);

            if (model.ModelSondage.IsDisabled == true)
            {
                return(RedirectToAction("ImpossibleDevoter", new { idSondage = idSondage }));
            }
            else
            {
                return(View(model));
            }
        }
Exemplo n.º 29
0
        public async Task <IHttpActionResult> UpdateAsync([FromBody] Reponse reponse)
        {
            var reponseToUpdate = new AccessLayer.Models.Reponse
            {
                ReponseId  = reponse.ReponseId,
                ReponseLib = reponse.ReponseLib,
                IsOk       = reponse.IsOk
            };

            await reponseAccessLayer.UpdateAsync(reponseToUpdate);

            return(this.Ok("updated"));
        }
Exemplo n.º 30
0
        public IActionResult Add(Reponse reponse)
        {
            if (ModelState.IsValid)
            {
                if (_daoReponse.AddReponse(reponse).IsCompleted)
                {
                    return(RedirectToAction("Index"));
                }
            }

            ViewBag.MesQuestions = _questions;
            return(View(reponse));
        }