Example #1
0
        public string ToCollectionName(CalculType calculType)
        {
            Enum.TryParse(this.DeviceType, out DeviceTypes type);
            var DataType = DeviceTypeToDataType(type);

            if (DataType != null)
            {
                return(DataType + calculType + this.Delay);
            }
            return(null);
        }
 public void SaveReport(string flightName, CalculType calculType, double result)
 {
     using (var connection = new SQLiteConnection(_connectionString))
         using (var command = connection.CreateCommand())
         {
             connection.Open();
             command.CommandText = "INSERT INTO report (flight_name, calculType, calculDate, result)" +
                                   $" VALUES ('{flightName}', '{calculType.ToString()}', '{DateTime.Now.ToShortDateString()}', {result})";
             command.ExecuteNonQuery();
         }
 }
Example #3
0
 public ComplexData(Delay delay, CalculType calculType, DeviceTypes deviceType)
     : base(delay, deviceType)
 {
     this.CalculType = calculType.ToString();
 }
Example #4
0
        public EmbedBuilder GenerateMathContent(Question q, CalculType t = CalculType.Multiplication)
        {
            var eb = new EmbedBuilder();

            if (t == CalculType.Multiplication)
            {
                int a = n.Next(3, 20);
                int b = n.Next(3, 20);
                result = a * b;
                eb.WithTitle("QCM de mathématiques\n" + a + " * " + b + " = ? ");
            }
            else if (t == CalculType.Addition)
            {
                int a = n.Next(100, 2000);
                int b = n.Next(100, 2000);
                result = a + b;
                eb.WithTitle("QCM de mathématiques\n" + a + " + " + b + " = ? ");
            }
            else if (t == CalculType.Soustraction)
            {
                int a = n.Next(500, 2000);
                int b = n.Next(50, 300);
                result = a - b;
                eb.WithTitle("QCM de mathématiques\n" + a + " - " + b + " = ? ");
            }
            else
            {
                eb.WithTitle("Type de calcul inconnu :" + t);
            }
            Console.WriteLine("Reach 1.5");
            q.answer = result.ToString();
            List <int> listToRandomizeAnswers = new List <int>();

            Console.WriteLine("Reach2");
            listToRandomizeAnswers.Add(result);
            listToRandomizeAnswers.Add(result - 1);
            listToRandomizeAnswers.Add(result + 1);
            listToRandomizeAnswers.Add(result + 3);
            var listMel = listToRandomizeAnswers.OrderBy(a => Guid.NewGuid()).ToList();

            Console.WriteLine("Reach3   ");
            eb.AddField("a) ", listMel[0]);
            eb.AddField("b) ", listMel[1]);
            eb.AddField("c) ", listMel[2]);
            eb.AddField("d) ", listMel[3]);
            if (listMel[0] == result)
            {
                q.answerLetter = "🇦";
            }
            else if (listMel[1] == result)
            {
                q.answerLetter = "🇧";
            }
            else if (listMel[2] == result)
            {
                q.answerLetter = "🇨";
            }
            else if (listMel[3] == result)
            {
                q.answerLetter = "🇩";
            }
            Console.WriteLine("Reach4");

            Console.WriteLine("Bonne réponse : " + q.answerLetter + ":" + q.answer);

            // On Enleve avec RemoveAt() l'élément pour ne pas pouvoir le reprendre

            eb.WithColor(Color.DarkGreen);
            return(eb);
        }
Example #5
0
        public Question AddQuestion(int type, bool SingleImage = false, TextQuestion tq = TextQuestion.MathContent, int pos = -1)
        {
            Question qToAdd = null;

            if (type == QType.text)
            {
                if (tq == TextQuestion.MathContent)
                {
                    CalculType[] valeurs             = { CalculType.Addition, CalculType.Multiplication, CalculType.Soustraction };
                    CalculType   CalculTypeAleatoire = valeurs[r.Next(valeurs.Length)];
                    qToAdd         = new Question(null, type, "Question texte Maths");
                    qToAdd.content = GenerateMathContent(qToAdd, CalculTypeAleatoire);
                }
                else if (tq == TextQuestion.DefaultContent)
                {
                    List <int> IDAll = new List <int>();

                    qToAdd = new Question(null, type, null, "Question Texte");
                    // On ajoute les questions dans l'ordre
                    int newRandom = n.Next(0, qCount);
                    while (uniqueList.Contains(newRandom))
                    {
                        newRandom = n.Next(0, qCount);
                        // On cherche au hasard tant que l'on a pas un bon random
                    }
                    uniqueList.Add(newRandom);
                    qToAdd.content = GenerateDefaultContent(qToAdd, uniqueList[textQuestionNumber]);
                    textQuestionNumber++;
                }
            }
            else if (type == QType.image)
            {
                qToAdd = new Question(null, type, "Question visuelle");
                if (SingleImage)
                {
                    qToAdd.content = GeneratePictureContent(qToAdd);
                }
                else
                {
                    qToAdd.content = GeneratePictureContent(qToAdd, ImageQuestion.CorrespondingImageMultiple);
                }
            }
            else if (type == QType.audio)
            {
                Console.WriteLine("Gen");
                qToAdd         = new Question(null, type, "Question audio");
                qToAdd.content = GenerateAudioContent(qToAdd);
                Console.WriteLine("Gen à priori ok");
            }
            else
            {
                qToAdd = new Question(null, type, "Autre");
            }

            if (pos < 0)
            {
                questions.Add(qToAdd);
                // Console.WriteLine(qToAdd.name + "|" + qToAdd.type + "|" + qToAdd.content);
            }
            else
            {
                questions.Insert(pos, qToAdd);
            }
            return(qToAdd);
        }
 public ComplexDataRequest(Delay delay, CalculType calculType, DeviceTypes deviceType, string from, string to)
     : base(delay, calculType, deviceType)
 {
     this.From = from;
     this.To   = to;
 }