Ejemplo n.º 1
0
        private static string exportReponsesAppariement(QuestionAppariement qmt)
        {
            String res = "{\n";

            foreach (Reponse r in qmt.getReponses())
            {
                ReponseMatching rm = (ReponseMatching)r;
                res += "=" + rm.texte1 + " => " + rm.texte2;
                res += "\n";
            }
            if (!qmt.feedbackQ.Equals(""))
            {
                res += "####" + qmt.feedbackQ + "\n";
            }
            res += "}\n\n";
            return(res);
        }
Ejemplo n.º 2
0
        private static void cleanReponse(Reponse r)
        {
            if (r is ReponseSimple)
            {
                ReponseSimple rm    = (ReponseSimple)r;
                String        texte = rm.texte;
                texte = Regex.Replace(texte, @"%-?[0-9]+(\.[0-9]+)?%", "");
                texte = texte.Replace("\n", "");
                texte = Regex.Replace(texte, @"####.*", "");
                int index = texte.IndexOf("#");
                if (index != -1)
                {
                    String[] split = texte.Split("#");
                    texte        = split[0];
                    rm.feedbackR = split[1];
                }
                rm.texte = texte;
            }
            if (r is ReponseMatching)
            {
                ReponseMatching rm     = (ReponseMatching)r;
                String          texte1 = rm.texte1;
                texte1 = texte1.Replace("\n", "");
                String texte2 = rm.texte2;
                texte2 = texte2.Replace("\n", "");

                texte2 = Regex.Replace(texte2, @"####.*", "");
                int index = texte2.IndexOf("#");
                if (index != -1)
                {
                    String[] split = texte2.Split("#");
                    texte2       = split[0];
                    rm.feedbackR = split[1];
                }
                rm.texte1 = texte1;
                rm.texte2 = texte2;
            }
        }
Ejemplo n.º 3
0
        internal static void exportQuestions(List <Groupe> gquestions, string destpath, int verbose)
        {
            XmlTextWriter writer = new XmlTextWriter(destpath, System.Text.Encoding.UTF8);

            writer.WriteStartDocument(true);
            writer.Formatting  = Formatting.Indented;
            writer.Indentation = 2;
            writer.WriteStartElement("quiz");
            int nbquestions = 0;

            foreach (Groupe g in gquestions)
            {
                int i = 1;
                foreach (Question q in g.getQuestions())
                {
                    logExport(q);
                    nbquestions++;
                    writer.WriteStartElement("question");
                    switch (q)
                    {
                    case QuestionDescription qd:
                        writer.WriteAttributeString("type", "description");
                        break;

                    case QuestionVF qvf:
                        writer.WriteAttributeString("type", "truefalse");
                        break;

                    case QuestionSimple qs:
                        writer.WriteAttributeString("type", "multichoice");
                        writer.WriteStartElement("single");
                        writer.WriteString("true");
                        writer.WriteEndElement();
                        break;

                    case QuestionMultiple qm:
                        writer.WriteAttributeString("type", "multichoice");
                        writer.WriteStartElement("single");
                        writer.WriteString("false");
                        writer.WriteEndElement();
                        break;

                    case QuestionAppariement qmt:
                        writer.WriteAttributeString("type", "matching");
                        break;

                    case QuestionNumerical qn:
                        writer.WriteAttributeString("type", "numerical");
                        break;

                    case QuestionShort qs:
                        writer.WriteAttributeString("type", "shortanswer");
                        break;

                    default:
                        writer.WriteAttributeString("type", "essay");
                        break;
                    }
                    if (q.nomq.Equals(""))
                    {
                        q.nomq = "Question " + i;
                    }
                    writer.WriteStartElement("name");
                    writer.WriteStartElement("text");
                    writer.WriteString(q.nomq);
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                    if (q.getTitre().Equals(""))
                    {
                        q.titre[0] = "No title";
                    }

                    writer.WriteStartElement("questiontext");
                    writer.WriteStartElement("text");
                    writer.WriteString(q.getTitre());
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                    if (!q.feedbackQ.Equals(""))
                    {
                        writer.WriteStartElement("generalfeedback");
                        writer.WriteStartElement("text");
                        writer.WriteString(q.feedbackQ);
                        writer.WriteEndElement();
                        writer.WriteEndElement();
                    }
                    if (q is QuestionOuverteAMC)
                    {
                        q.getReponses().Clear();
                    }
                    foreach (Reponse r in q.getReponses())
                    {
                        if (r is ReponseSimple)
                        {
                            String        fraction;
                            ReponseSimple rs = (ReponseSimple)r;
                            if (rs.isTrue())
                            {
                                fraction = "100";
                            }
                            else
                            {
                                fraction = "0";
                            }
                            writer.WriteStartElement("answer");
                            writer.WriteAttributeString("fraction", fraction);
                            writer.WriteStartElement("text");
                            writer.WriteString(rs.texte);
                            writer.WriteEndElement();
                            if (!rs.feedbackR.Equals(""))
                            {
                                writer.WriteStartElement("feedback");
                                writer.WriteStartElement("text");
                                writer.WriteString(rs.feedbackR);
                                writer.WriteEndElement();
                                writer.WriteEndElement();
                            }
                            writer.WriteEndElement();
                        }
                        if (r is ReponseMatching)
                        {
                            ReponseMatching rm = (ReponseMatching)r;
                            writer.WriteStartElement("subquestion");
                            writer.WriteStartElement("text");
                            writer.WriteString(rm.texte1);
                            writer.WriteEndElement();
                            writer.WriteStartElement("answer");
                            writer.WriteStartElement("text");
                            writer.WriteString(rm.texte2);
                            writer.WriteEndElement();
                            writer.WriteEndElement();
                            writer.WriteEndElement();
                        }
                    }
                    writer.WriteEndElement();
                    i++;
                }
            }
            writer.WriteEndElement();
            writer.WriteEndDocument();
            Console.WriteLine(nbquestions + " questions converties");
            writer.Close();
        }