public void MultiChoiceNAnswers() { MultiChoiceQuestion q = new MultiChoiceQuestion("Multi Choice", "Texte du Multi Choice"); // q.AddAnswer("Answer 1", "aucune", 50); q.AddAnswer("Answer 2", "aucune", 50); q.AddAnswer("Answer 3", "aucune", 0); // Action act = () => q.AddAnswer("Answer 4", "aucune", 50); Assert.ThrowsException <OverflowException>(act); // Trace.WriteLine(q.MoodleXML.OuterXml); }
public void SaveAsMoodle(string filePath) { Quiz mQuiz = new Quiz(); // string push = E3CTest.NewLine; E3CTest.NewLine = "<br/>"; // foreach (Theme th in Themes) { Category cat = new Category(th.Titre); // foreach (Question q in th.Questions) { MultiChoiceQuestion mQuestion = new MultiChoiceQuestion(); mQuestion.Title = q.Titre; mQuestion.QuestionText = q.TexteQuestion; // String repJuste = q.Correction.Choix; repJuste = repJuste.Trim(); if (!String.IsNullOrWhiteSpace(repJuste)) { // Ok, on a une Correction (une Réponse Juste) foreach (Reponse rep in q.Reponses) { Answer ans = new Answer(); ans.Text = rep.Texte; if (String.Compare(repJuste, rep.Choix, true) == 0) { ans.Fraction = 100; } mQuestion.AddAnswer(ans); } mQuiz.AddQuestion(cat, mQuestion); } } } // mQuiz.Save(filePath); // E3CTest.NewLine = push; }