public async Task BlindTest(string name = "blindtest") { try { ISocketMessageChannel channel = Context.Channel; await ReplyAsync("Génération du BlindTests! :fire: "); Qcm bigQcm = new Qcm(); qcmList.Add(bigQcm); bigQcm.name = name; bigQcm.AddQuestion(QType.audio); bigQcm.AddQuestion(QType.audio); bigQcm.AddQuestion(QType.audio); bigQcm.AddQuestion(QType.audio); bigQcm.AddQuestion(QType.audio); bigQcm.AddQuestion(QType.audio); bigQcm.AddQuestion(QType.audio); await ReplyAsync("Questions ajoutées avec succès"); } catch { await ReplyAsync("Erreur lors de la création du QCM"); } //await Context.Guild.CreateTextChannelAsync(bigQcm.name); //await bigQcm.Preview(channel); await StartQCM(name); }
public async Task BasicSampleQcm(string name = "text") { ISocketMessageChannel channel = Context.Channel; await ReplyAsync("Lancement du méga QCM! :fire: "); Qcm bigQcm = new Qcm(); qcmList.Add(bigQcm); bigQcm.name = name; for (int i = 0; i < 10; i++) { bigQcm.AddQuestion(QType.text, false, Qcm.TextQuestion.DefaultContent); } await ReplyAsync("Questions ajoutées avec succès"); }
public async Task MathSampleQcm(string name = "maths") { ISocketMessageChannel channel = Context.Channel; await ReplyAsync("Lancement du méga QCM! :fire: "); Qcm bigQcm = new Qcm(); qcmList.Add(bigQcm); bigQcm.name = name; for (int i = 0; i < 3; i++) { bigQcm.AddQuestion(QType.text); } await ReplyAsync("Questions ajoutées avec succès"); }
public async Task QcmSampleSingleIMG(string name = "img") { ISocketMessageChannel channel = Context.Channel; await ReplyAsync("Lancement du QCM Image! :fire: "); Qcm bigQcm = new Qcm(); qcmList.Add(bigQcm); bigQcm.name = name; bigQcm.AddQuestion(QType.image, true); bigQcm.AddQuestion(QType.image, true); bigQcm.AddQuestion(QType.image, true); bigQcm.AddQuestion(QType.image, true); // Image simple try { await ReplyAsync("Questions ajoutées avec succès"); } catch { await ReplyAsync("Erreur lors de la création du QCM"); } //await Context.Guild.CreateTextChannelAsync(bigQcm.name); //await bigQcm.Preview(channel); }
public async Task BigQcm(string name = "a") { ISocketMessageChannel channel = Context.Channel; await ReplyAsync("Lancement du méga QCM! :fire: "); Qcm bigQcm = new Qcm(); qcmList.Add(bigQcm); bigQcm.name = name; // l'audio ne marche que si premiere question QUE bigQcm.AddQuestion(QType.text); bigQcm.AddQuestion(QType.text, false, Qcm.TextQuestion.DefaultContent); bigQcm.AddQuestion(QType.image); // Image multiple bigQcm.AddQuestion(QType.image, true); // Image simple try { await ReplyAsync("Questions ajoutées avec succès"); } catch { await ReplyAsync("Erreur lors de la création du QCM"); } //await Context.Guild.CreateTextChannelAsync(bigQcm.name); //await bigQcm.Preview(channel); }
public async Task StartQCM([Remainder] string qcmName) { Console.WriteLine(); Qcm qcm = await GetQcm(qcmName); AudioService audioService = (AudioService)Program._services.GetService(typeof(AudioService)); if (am == null) { am = new AudioModule(audioService, Context); } IMessage msg = null; if (!qcm.HasStarted) { stopwatch.Restart(); qcm.HasStarted = true; Console.WriteLine("Affichage Q1"); // Si ça buggue ç'est à cause du display Mode msg = await qcm.DisplayInDiscord(_client.GetChannel(414746672284041222) as ISocketMessageChannel, qcm.questions[0], Qcm.DisplayMode.QCM, am); qcm.questionsID.Add(msg.Id); } else //Problème réussir à bloquer l'affichage Q2 cad ignorer le dernier smiley { ISocketMessageChannel channel = _client.GetChannel(414746672284041222) as ISocketMessageChannel; if (i < qcm.questions.Count) { Console.WriteLine("On arrive à une question de type :" + qcm.questions[i].type); msg = await qcm.DisplayInDiscord(_client.GetChannel(414746672284041222) as ISocketMessageChannel, qcm.questions[i], Qcm.DisplayMode.QCM); qcm.questionsID.Add(msg.Id); Console.WriteLine(stopwatch.ElapsedMilliseconds); } // Tableau des réponses else { // Le tableau des réponses ne s'affiche que pour un affichage de type QCM if (qcm.displayMode == Qcm.DisplayMode.QCM) { await channel.SendMessageAsync("Vous êtes arrivé au bout de ce QCM"); await channel.SendMessageAsync("Réponses enregistrées : " + qcm.allAnswers.Count); EmbedBuilder embed = new EmbedBuilder(); int i = 0; int score = 0; int maxScore = qcm.allAnswers.Count; Console.OutputEncoding = System.Text.Encoding.UTF8; var usersIDThatAnswered = new List <ulong>(); var playerList = new List <QcmPlayer>(); foreach (var ans in qcm.allAnswers) { if (!usersIDThatAnswered.Contains(ans.User.Value.Id)) { usersIDThatAnswered.Add(ans.User.Value.Id); playerList.Add(new QcmPlayer(ans.User.Value)); } } foreach (var ans in qcm.allAnswers) { try { if (ans.Emote.Name != null) { embed.AddField("Votre Réponse n°" + (i + 1) + " : " + ans.Emote.Name, " par " + ans.User.Value.Username); foreach (var player in playerList) { if (ans.Emote.Name == qcm.questions[i].answerLetter && ans.User.Value == player.user) { player.score++; } if (ans.User.Value == player.user) { player.maxScore++; } } embed.AddField("Bonne réponse ", qcm.questions[i].answer + ":" + qcm.questions[i].answerLetter); if (ans.Emote.Name == qcm.questions[i].answerLetter) { score++; } else { Console.WriteLine(ans.Emote.Name + " : " + qcm.questions[i].answerLetter); } } i++; embed.AddField("", ""); } catch (Exception ex) { Console.WriteLine(ex); } } await channel.SendMessageAsync("", false, embed); await channel.SendMessageAsync(" Score Final " + score + " / " + maxScore + "\n Durée : " + (stopwatch.ElapsedMilliseconds / 1000) + "s"); foreach (var player in playerList) { await channel.SendMessageAsync(">> " + player.user.Username + " Score : " + player.score + " / " + player.maxScore); } } } } // return msg; }