| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 
 | public void addQuestion(Question q)
        {
                doc=new Document();
                Element question = new Element("question");
                question.setAttribute("id",String.valueOf(q.getIdentifiant())); // <-- écriture de l'identifiant unique de la question
                question.setAttribute("group",q.getGroup());
                Element title = new Element("title"); // <-- mise à jour du titre
                question=question.addContent(title);
                title.setText(q.getTitle());
                Element choice = new Element("choice"); // <-- écriture des choix possibles
                question = question.addContent(choice);
                choice.setAttribute("type",q.getChoiceType());
                for(int i=0;i<q.getPossibilities().size();i++) 
                {
                        Element poss = new Element("option");
                        poss.setText((String) q.getPossibilities().get(i));
                        choice = choice.addContent(poss);
                }
                XMLOutputter out = new XMLOutputter();
                try
                {
                        out.output(doc, new FileWriter(this.file));
                }
                catch(IOException e2)
                {
                        System.out.println("Fichier non trouvé");
                }
 
        } | 
Partager