예제 #1
0
 /// <summary>
 /// Ajoute une réponse à la question
 /// </summary>
 /// <param name="idReponse">Id de la réponse</param>
 /// <param name="reponse">réponse</param>
 public void AddReponse(int idReponse, ReponseDatas reponse)
 {
     if (!DictReponseModele.Keys.Contains(idReponse))
     {
         DictReponseModele.Add(idReponse, reponse);
     }
 }
예제 #2
0
        /// <summary>
        /// Insère une réponse dans une question par l'id donnée et avec les informations données
        /// </summary>
        /// <param name="idQuestion">Id de la question</param>
        /// <param name="reponseText">Texte de la réponse</param>
        /// <param name="bonneReponse">Bonne réponse ou non</param>
        /// <returns></returns>
        public string InsertReponse(int idQuestion, string reponseText, bool bonneReponse)
        {
            QuestionDatas qm = null;

            foreach (KeyValuePair <int, QuestionDatas> item in Qcm.DictQuestionModele)
            {
                if (item.Key == idQuestion)
                {
                    qm = item.Value;
                }
            }
            if (qm != null)
            {
                if (qm.DictReponseModele.Count >= 6)
                {
                    return("Il a trop de réponses !");
                }
                else
                {
                    ReponseDatas rm = new ReponseDatas(reponseText, bonneReponse, Modes.Create);
                    qm.AddReponse(Qcm.NextIdReponse, rm);
                    Qcm.NextIdReponse++;
                    return("");
                }
            }
            return("Cette question est introuvable !");
        }
예제 #3
0
        /// <summary>
        /// Ajoute une reponse à une question du modèle
        /// </summary>
        /// <param name="idQuestion">Id de la question</param>
        /// <param name="idReponse">Id de la réponse</param>
        /// <param name="reponse">Réponse</param>
        public void AddReponseToQuestion(int idQuestion, int idReponse, ReponseDatas reponse)
        {
            QuestionDatas qm;

            if (DictQuestionModele.TryGetValue(idQuestion, out qm))
            {
                qm.AddReponse(idReponse, reponse);
            }
        }
예제 #4
0
 /// <summary>
 /// Modifie une réponse par les informations fournies
 /// </summary>
 /// <param name="idQuestion">Id de la question</param>
 /// <param name="idReponse">Id de la réponse</param>
 /// <param name="reponseModele">Réponse</param>
 /// <returns>Message</returns>
 public KeyValuePair <bool, string> UpdateReponseByIdQuestionAndIdReponse(int idQuestion, int idReponse, ReponseDatas reponseModele)
 {
     return(QcmModele.UpdateReponseByIdQuestionAndIdReponse(idQuestion, idReponse, reponseModele));
 }
예제 #5
0
        /// <summary>
        /// Mets à jour les réponses par l'id de la question et l'id de la réponse
        /// </summary>
        /// <param name="idQuestion">Id de la question</param>
        /// <param name="idReponse">Id de la réponse</param>
        /// <param name="reponseModele">Réponse</param>
        /// <returns></returns>
        public KeyValuePair <bool, string> UpdateReponseByIdQuestionAndIdReponse(int idQuestion, int idReponse, ReponseDatas reponseModele)
        {
            QuestionDatas qm;

            if (Qcm.DictQuestionModele.TryGetValue(idQuestion, out qm))
            {
                ReponseDatas rm;
                if (qm.DictReponseModele.TryGetValue(idReponse, out rm))
                {
                    if (rm.Reponse != reponseModele.Reponse || rm.BonneReponse != reponseModele.BonneReponse)
                    {
                        rm.Reponse      = reponseModele.Reponse;
                        rm.BonneReponse = reponseModele.BonneReponse;
                        if (rm.ModeDatabase == Modes.AddedInBase)
                        {
                            rm.ModeDatabase = Modes.Update;
                        }
                        return(new KeyValuePair <bool, string>(false, "Réponse modifiée avec succès !"));
                    }
                    else
                    {
                        return(new KeyValuePair <bool, string>(false, null));
                    }
                }
                else
                {
                    return(new KeyValuePair <bool, string>(true, "Echec lors de la récupération de la réponse pour la modification !"));
                }
            }
            else
            {
                return(new KeyValuePair <bool, string>(true, "Echec lors de la récupération de la question contenant la réponse pour la modification !"));
            }
        }