Пример #1
0
 public ReponseOrientation(int id_question, string reponseText, Metier metier)
 {
     this.id = -1;
     this.id_question = id_question;
     this.reponseText = reponseText;
     this.metier = metier;
 }
Пример #2
0
 public ReponseOrientation(SerializationInfo info, StreamingContext ctxt)
 {
     this.id = (int)info.GetValue("id", typeof(int));
     this.id_question = (int)info.GetValue("id_question", typeof(int));
     this.reponseText = (string)info.GetValue("reponseText", typeof(string));
     this.metier = (Metier)info.GetValue("metier", typeof(Metier));
 }
        public Message Exec(Message msg)
        {
            List<QuestionOrientation> questionsOrientation = new List<QuestionOrientation>();

            msg.Data[0] = Mpg_Questions_Orientation.Rq_GetAllQuestions();
            Message reponse = CAD.GetInstance().Execute_StockedProcedure(msg);
            System.Data.DataSet results = (System.Data.DataSet)reponse.Data[0];

            msg.Data[0] = Mpg_Reponses_Orientation.Rq_GetAllReponses();
            Message reponseRep = CAD.GetInstance().Execute_StockedProcedure(msg);
            System.Data.DataSet resultsRep = (System.Data.DataSet)reponseRep.Data[0];

            msg.Data[0] = Mpg_Metiers.Rq_GetAllMetiers();
            Message reponseMetier = CAD.GetInstance().Execute_StockedProcedure(msg);
            System.Data.DataSet resultsMetier = (System.Data.DataSet)reponseRep.Data[0];

            foreach (System.Data.DataRow row in results.Tables[0].Rows)
            {
                List<ReponseOrientation> reponsesQuestion = new List<ReponseOrientation>();

                int id = Convert.ToInt32(row[Mpg_Questions_Orientation.CH_ID].ToString());
                string intitule = row[Mpg_Questions_Orientation.CH_INTITULE].ToString();
                int ordre = Convert.ToInt32(row[Mpg_Questions_Orientation.CH_ORDRE].ToString());

                foreach (System.Data.DataRow rowRep in resultsRep.Tables[0].Rows)
                {
                    Metier metier = new Metier("Aucun metier","Aucune description");

                    int idRep = Convert.ToInt32(rowRep[Mpg_Reponses_Orientation.CH_ID].ToString());
                    int idQues = Convert.ToInt32(rowRep[Mpg_Reponses_Orientation.CH_ID_QUESTION].ToString());
                    string intituleRep = rowRep[Mpg_Reponses_Orientation.CH_INTITULE].ToString();
                    int idMetier = Convert.ToInt32(rowRep[Mpg_Reponses_Orientation.CH_ID_METIER].ToString());

                    foreach (System.Data.DataRow rowMet in resultsMetier.Tables[0].Rows)
                    {
                        int idMet = Convert.ToInt32(rowMet[Mpg_Metiers.CH_ID].ToString());
                        string intituleMet = rowMet[Mpg_Metiers.CH_INTITULE].ToString();
                        string descMet = rowMet[Mpg_Metiers.CH_DESCRIPTION].ToString();

                        if (idMet == idMetier)
                            metier = new Metier(idMet, intituleMet, descMet);
                    }

                    ReponseOrientation reponseQues = new ReponseOrientation(idRep, idQues, intituleRep, metier);

                    if (reponseQues.ID_Question == id)
                        reponsesQuestion.Add(reponseQues);
                }

                questionsOrientation.Add(new QuestionOrientation(id, intitule, reponsesQuestion.Cast<ReponseOrientation>().ToArray(), ordre));
            }

            msg.Data[0] = questionsOrientation.Cast<QuestionOrientation>().ToArray();
            return msg;
        }
        private void DoCorrection()
        {
            Metier[] metiers = new Metier[this.reponses.Length];

            for(int i = 0; i<this.reponses.Length; i++)
            {
                ReponseOrientation rep = this.reponses[i];
                metiers[i] = rep.Metier;
                Projet_Client.Composant_de_communication.MessageManager.Debug(rep.ReponseText + " --> " + rep.Metier.Intitule);
            }

            List<Metier> metierList = metiers.Cast<Metier>().ToList<Metier>();

            var groupsWithCounts = from s in metierList
                                   group s by s into g
                                   select new
                                   {
                                       Item = g.Key,
                                       Count = g.Count()
                                   };

            var groupsSorted = groupsWithCounts.OrderByDescending(g => g.Count);
            string mostFrequest = groupsSorted.First().Item.Intitule;

            MessageBox.Show("Resultat: " + mostFrequest);
            this.Close();
        }
Пример #5
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            switch (this.type)
            {
                case CT_Get_Questionnaire.QuestionnaireType.Jeu:
                    QuestionJeu questionJ = ((QuestionJeu)this.QuestionListBox.SelectedItem);

                    questionJ.QuestionText = this.QuestionIntituleLabel.Text;

                    for(int i = 0; i < questionJ.Reponses.Length; i++)
                    {
                        bool correct = (this.ReponseIsCorrectChkBox[i].IsChecked.HasValue) ? this.ReponseIsCorrectChkBox[i].IsChecked.Value : false;
                        questionJ.Reponses[i] = new ReponseJeu(
                            questionJ.Reponses[i].ID, 
                            questionJ.ID, 
                            this.ReponsesTxtBox[i].Text,
                            Convert.ToInt32(this.ReponsesPointsTxtBox[i].Text),
                            correct);
                    }

                    Message msgJ = new Message();

                    msgJ.Data[0] = CT_Get_Questionnaire.QuestionnaireType.Jeu;
                    msgJ.Data[1] = questionJ;

                    new CT_Upd_Question().Exec(msgJ);

                    break;
                case CT_Get_Questionnaire.QuestionnaireType.Orientation:
                    QuestionOrientation questionO = ((QuestionOrientation)this.QuestionListBox.SelectedItem);

                    questionO.QuestionText = this.QuestionIntituleLabel.Text;

                    for (int i = 0; i < questionO.Reponses.Length; i++)
                    {
                        Metier m = new Metier("Aucun Metier", "Aucune descrition");

                        foreach(Metier metier in this.RecupListMetierOfQuestionOrientation(questionO))
                        {
                            if(metier.Intitule == this.ReponseMMetierComboBox[i].Text)
                                m = metier;
                        }

                        questionO.Reponses[i] = new ReponseOrientation(
                            questionO.Reponses[i].ID,
                            questionO.ID,
                            this.ReponsesTxtBox[i].Text,
                            m);
                    }

                    Message msgO = new Message();

                    msgO.Data[0] = CT_Get_Questionnaire.QuestionnaireType.Orientation;
                    msgO.Data[1] = questionO;

                    new CT_Upd_Question().Exec(msgO);

                    break;
            }

            this.refreshQuestionList();
        }