From 4f93f244ad1df1185925fd96929269f0a5e51b6f Mon Sep 17 00:00:00 2001 From: pablo rodriguez <58742538+1-pablo-rodriguez@users.noreply.github.com> Date: Mon, 25 Apr 2022 13:25:20 +0200 Subject: [PATCH] MAJ --- bin/.gitignore | 1 - src/MEPTL/HTML.java | 5812 +++++++++++++++++++++ src/MEPTL/StringSimilarity.java | 54 + src/MEPTL/commandes.java | 586 +++ src/MEPTL/meptl.java | 5265 +++++++++++++++++++ src/MEPTL/outils.java | 1049 ++++ src/MEPTL/verificationFichierAnalyse.java | 462 ++ src/resources/licence.txt | 674 +++ 8 files changed, 13902 insertions(+), 1 deletion(-) delete mode 100644 bin/.gitignore create mode 100644 src/MEPTL/HTML.java create mode 100644 src/MEPTL/StringSimilarity.java create mode 100644 src/MEPTL/commandes.java create mode 100644 src/MEPTL/meptl.java create mode 100644 src/MEPTL/outils.java create mode 100644 src/MEPTL/verificationFichierAnalyse.java create mode 100644 src/resources/licence.txt diff --git a/bin/.gitignore b/bin/.gitignore deleted file mode 100644 index 16f90ab..0000000 --- a/bin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/MEPTL/ diff --git a/src/MEPTL/HTML.java b/src/MEPTL/HTML.java new file mode 100644 index 0000000..29103af --- /dev/null +++ b/src/MEPTL/HTML.java @@ -0,0 +1,5812 @@ +package MEPTL; + +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Date; + +import cXML.node; + +/** + * + * @author pablo rodriguez + * + */ +public class HTML { + + // Titre principaux des analyses avec identifiant pour lien + public static String H1(String txt, String id) { + txt = "





\r\n" + + ""+ txt +"


\r"; + return txt; + } + + // Titre principaux des analyse + public static String H1(String txt) { + txt = "

\r\n" + + ""+ txt +"


\r"; + return txt; + } + + // Titre 2 + public static String H2(String txt) { + txt="

"+ txt +"

"; + return txt; + } + + // Titre 2 + public static String H2(String txt, String id) { + txt="

"+ txt +"

"; + return txt; + } + + // Titre 3 + public static String H3(String txt) { + txt="

"+ txt +"

"; + return txt; + } + + // paragraphe class pablo + public static String Ppablo(String txt) { + return "

" + txt +"

"; + } + + /** + * Style HTML pour paragraphe style class p1 + * @param txt + * @return + */ + public static String Paragraph_classp1(String txt) { + return("

" + txt + "

"); + } + + /** + * Style HTML pour paragraphe style class p11 + * @param txt + * @return + */ + public static String Paragraph_classCommentaire(String txt) { + return("

" + txt + "

"); + } + + /** + * Style HTML pour paragraphe style class p1 + * @param txt + * @return + */ + public static String Paragraph_classp1(String txt, String id) { + return("

" + txt + "

"); + } + + // paragraphe avec la class p5 fond ROUGE pour erreur + public static String Paragraph_classp5(String txt) { + return("

" + txt + "

"); + } + + // paragraphe avec la class p5 fond ROUGE pour erreur + public static String Paragraph_classp6(String txt) { + return("

" + txt + "

"); + } + + // style avec la class p7 fond VERT pour correct + public static String Paragraph_classp7(String txt) { + return("

" + txt + "

"); + } + + //Saut de page puis tritre + public static String SautLigneOnduleBleu(String titre) { + return "

" + titre+"

\r"; + } + + //Saut de page puis tritre + public static String SautP8(String titre) { + return "

" + titre+"

\r"; + } + + /** + * Un saut de ligne + * @return + */ + public static String SautLigne() { + return "
\r"; + } + + /** + * Un saut de ligne puis un trait horizontal sans style + * @return + */ + public static String SautLigneEtBordure() { + return "

\r"; + } + + // Entête des tables pour les styles de paragraphe, styles de page, etc... + public static String TableEnteteTableurSynthese() { + return "\r\n" + + " "+ + " " + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "

\r\n" + + "Sous partie

\r\n" + + "Proportion (%)

\r\n" + + "Nombre de points

\r\n" + + "Points gagnés

\r\n" + + "Coef.

"; + } + + // Table pour la synthèse au début du FeedBack : Style de paragraphe, Style de page + public static String TablePointsSyntheseStyle(String nomstyle,double prop, String pointstotal, String pointsgagnes, String coef, String id ) { + String propRed = Integer.toHexString(255 - (int) Math.round(Math.pow(prop,3)*255)); + String propGreen = Integer.toHexString((int) Math.round(Math.pow(prop,3)*255)); + if(propRed.length()==1) propRed= "0"+propRed; + if(propGreen.length()==1) propGreen= "0"+propGreen; + + String color="#" + propRed + propGreen + "40"; + DecimalFormat df = new DecimalFormat("###.##"); + return "\r\n" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "\r\n" + + "

" + + "" + nomstyle +"

" + + "" + df.format(prop*100) +"%

"+ + pointstotal + "

"+ + pointsgagnes + "

"+ + coef + "

"; + } + + // Entête des tables pour les styles de paragraphe, styles de page, etc... + public static String TableEntete() { + return "\r\n" + + ""+ + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " \r\n" + + "

\r\n" + + "" + "Correct/Erreur" + "

\r\n" + + "" + "Propriété" +"

\r\n" + + "Valeur fichier

\r\n" + + "Consigne" +"

"; + } + + // Entête des tables pour ordre structure + public static String TableEnteteOrdreStructure() { + return "\r\n" + + ""+ + "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " \r\n" + + "

\r\n" + + "" + "Correct/Erreur" + "

\r\n" + + "" + "Propriété" +"

\r\n" + + "Ordre fichier

\r\n" + + "Ordre consigne" +"

"; + } + + + // Table pour les corrects dans les styles de paragraphe, styles de page + public static String Table(String txt1, String txt2, String txt3, String txt4,int niveau) { + String color = "#AAAAAA"; //# + if(niveau==2) color =" #dc143c"; + if(niveau==1) color = "#32cd32"; + + return "\r\n" + + " "+ + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "

\r\n" + + "" + txt1 + "

\r\n" + + txt2 +"

\r\n" + + txt3 +"

\r\n" + + txt4 +"

"; + } + + // table d'un node + public static String Table(node nod) { + + String code = HTML.SautLigne(); + if(nod.getAttributs().get("titre")!=null) if(!nod.getAttributs().get("titre").isEmpty()) { + code = code + HTML.H1(nod.getAttributs().get("titre"),nod.getAttributs().get("id"))+ HTML.SautLigne() ; + }else { + code = code + HTML.H1("",nod.getAttributs().get("id"))+ HTML.SautLigne() ; + } + + //ajoute le commentaire + if(!nod.getContenu().isEmpty()) if(nod.getNodes().size()==1) code = code + HTML.Paragraph_classp6(nod.getContenu()) + HTML.SautLigne(); + + code = code + HTML.TableEntete(); //ajoute l'entête + + + for(int k = 0 ; k < nod.getNodes().size();k++) { + if(nod.getNodes().get(k).getAttributs().get("niveau")!=null) { + + String Tst = nod.getNodes().get(k).getAttributs().get("resultat"); + // String Key = outils.Traduction(nod.getNodes().get(k).getAttributs().get("elt") + " " + outils.withoutCodeAndPoint(nod.getNodes().get(k).getAttributs().get("attribut"))); + String Key = outils.traduction.get(nod.getNodes().get(k).getAttributs().get("elt") + " " + outils.withoutCodeAndPoint(nod.getNodes().get(k).getAttributs().get("attribut"))); + if(Key==null) Key = nod.getNodes().get(k).getAttributs().get("elt") + " " + outils.withoutCodeAndPoint(nod.getNodes().get(k).getAttributs().get("attribut")); + + String valueStudent = nod.getNodes().get(k).getAttributs().get("valueStudent"); + String valueSujet = outils.withoutCodeAndPoint(nod.getNodes().get(k).getAttributs().get("valueSujet")); + int niveau = Integer.valueOf(nod.getNodes().get(k).getAttributs().get("niveau")); + + code = code + HTML.Table(Tst, Key, valueStudent, valueSujet, niveau); + }else { + + if(nod.getNodes().get(k).getAttributs().get("titre")!=null) if(!nod.getNodes().get(k).getAttributs().get("titre").isEmpty()){ + code = code + HTML.SautLigne() + HTML.H2(nod.getNodes().get(k).getAttributs().get("titre")) + + HTML.SautLigne(); + }else { + code = code + HTML.SautLigne(); + } + + + if(nod.getNodes().get(k).getAttributs().get("saut")!=null) if(nod.getNodes().get(k).getAttributs().get("saut").equals("true")) { + code = code + HTML.SautLigne(); + } + + if(!nod.getContenu().isEmpty()) code = code + HTML.Paragraph_classp6(nod.getContenu()) + HTML.SautLigne(); + + for(int l = 0 ; l < nod.getNodes().get(k).getNodes().size() ; l++) { + if(!nod.getNodes().get(k).getNodes().get(l).getNomElt().equals("saut")){ + String Tst = nod.getNodes().get(k).getNodes().get(l).getAttributs().get("resultat"); + // String Key = outils.Traduction(nod.getNodes().get(k).getNodes().get(l).getAttributs().get("elt") + " " + outils.withoutCodeAndPoint(nod.getNodes().get(k).getNodes().get(l).getAttributs().get("attribut"))); + String Key2 = outils.traduction.get(nod.getNodes().get(k).getNodes().get(l).getAttributs().get("elt") + " " + outils.withoutCodeAndPoint(nod.getNodes().get(k).getNodes().get(l).getAttributs().get("attribut"))); + if(Key2==null) Key2 = nod.getNodes().get(k).getNodes().get(l).getAttributs().get("elt") + " " + outils.withoutCodeAndPoint(nod.getNodes().get(k).getNodes().get(l).getAttributs().get("attribut")); + String valueStudent = nod.getNodes().get(k).getNodes().get(l).getAttributs().get("valueStudent"); + String valueSujet = outils.withoutCodeAndPoint(nod.getNodes().get(k).getNodes().get(l).getAttributs().get("valueSujet")); + int niveau = Integer.valueOf(nod.getNodes().get(k).getNodes().get(l).getAttributs().get("niveau")); + + code = code + HTML.Table(Tst, Key2, valueStudent, valueSujet, niveau); + }else { + if(nod.getNodes().get(k).getNodes().get(l).getAttributs().get("titre")!=null) code = code + HTML.SautLigneOnduleBleu(nod.getNodes().get(k).getNodes().get(l).getAttributs().get("titre")); + if(nod.getNodes().get(k).getNodes().get(l).getAttributs().get("titre2")!=null) code = code + HTML.SautP8(nod.getNodes().get(k).getNodes().get(l).getAttributs().get("titre2")); + } + + } + + } + + } + + code = code.replace("-NewLine-", "
"); + + return code; + } + + + + // Table correct pour application des styles + public static String TableApplStyle(String NomStyle,ArrayList T, ArrayList S, boolean erreur) { + String T1 = ""; + String T2 = ""; + for(int i=0; i\r"; + } + for(int i=0; i\r"; + } + + String color = "#32cd32"; //vert + if(erreur) color = "#dc143c"; //rouge + + + // table pour l'application des styles + return "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "\r\n" + + "

" + + "Les paragraphes qui sont dans le style \"" + NomStyle + "\"

" + + "

\r\n" + + "Correct/Erreur

" + + "

\r\n" + + "Dans fichier remis

" + + "

\r\n" + + "Consigne

" + + "

\r\n" + + "Correct

" + + "

\r\n" + + T1 + "

" + + "

\r\n" + + T2 + "

" + + "
"; + } + + + + // Aller en haut +// public static String GoToTop() { +// return "

" + ImgTop() +"

"; +// } + + // Les points obtenus sous les tables + public static String Paragraph_SousPartieNote(int ptacquis, int ptotal, double prop ) { + return "

Total des points acquis = " + ptacquis + "
Total des points analysés = " + ptotal + "
Proportion = " + prop + "

\r"; + } + + + // image du logo de la fac + public static String imgLogos() { + return "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " image/svg+xml\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + ""; + } + + // image de la progression + public static String imgProgression() { + return "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " image/svg+xml\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " 0%\r\n" + + " 10%\r\n" + + " 20%\r\n" + + " 30%\r\n" + + " 40%\r\n" + + " 50%\r\n" + + " 60%\r\n" + + " 70%\r\n" + + " 80%\r\n" + + " 90%\r\n" + + " 100%\r\n" + + " 0\r\n" + + " 2\r\n" + + " 4\r\n" + + " 6\r\n" + + " 8\r\n" + + " 10\r\n" + + " 12\r\n" + + " 14\r\n" + + " 16\r\n" + + " 18\r\n" + + " 20\r\n" + + " \r\n" + + " Proportion correcte\r\n" + + " Note sur 20\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " Progression 1 (linéaire)Progression 1,5Progression 0,33Progression 0,5Progression 2Progression 3\r\n" + + " \r\n" + + " \r\n" + + " Progression de la note en fonction de la proportion correcte\r\n" + + " Exemple pour avoir une note de 10/20, lorsque la progression est de 0,33. Il faut 12.5% de proportion correcte. 0,5. Il faut 25% de proportion correcte. 1. Il faut 50% de proportion correcte. 1,5. Il faut 63% de proportion correcte. 2. Il faut 70.7% de proportion correcte. 3. Il faut 79.4% de proportion correcte.\r\n" + + " \r\n" + + " \r\n" + + ""; + } + + public static String NoteA( ) { + return "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n"; + } + + public static String NoteB() { + return "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n"; + } + + public static String NoteC() { + return "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n"; + } + + public static String NoteD() { + return "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + ""; + } + + public static String NoteE() { + return "\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + "\r\n" + + ""; + } + + // image du bouton interrogation + public static String imgInterogation() { + return "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + ""; + } + + /** + * Retourne l'entête et les styles CSS du formulaire + * @return + */ + public static String getHTMLenteteEtCssFormulaireHTML() { + Date aujourdhui = new Date(); + DateFormat mediumDateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM); + + return "\r" + + "\r" + + "\r" + + "\r" + + "Analyse mise en page d'un texte long\r" + + + "" + + "" + + "" + + "" + + "" + + +"" + + +"\r"; + } + + + /** + * Retourne l'ouverture de la balise body + * @return + */ + public static String getHTMLdebutBody(double note, String noteFrom, String NumSujet, String dossier, double proportioncorrect, String progression) { + DecimalFormat df1 = new DecimalFormat("##.##"); + Date aujourdhui = new Date(); + DateFormat mediumDateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM); + + return "\r" + +"
" + +"

\r\n" + + "Feedback - Analyse LibreOffice Writer
"+HTML.imgLogos()+"

\r" + +"

" + df1.format(note) + " / " + noteFrom +"
Sujet "+ NumSujet +"

\r" + +"

Date d'analyse : "+ mediumDateFormat.format(aujourdhui) + "
" + +"
Dossier étudiant : "+ dossier + "Dossier téléchargé depuis la plateforme Moodle.

" + +"Analyse MEPTL : sujet "+ NumSujet + "
\r" + +"Méthode :
Progression " + progression + "Explication
"+ HTML.imgProgression() +"
- Proportion correcte du fichier analysé : " + Math.floor(proportioncorrect*10000)/100 + "%
" + +"
Auteur : P. Rodriguez - Licence GPL v3.0 - Avril 2020

" + +"
"; + } + + /** + * Retourne la fermeture de la balise body et html + * @return + */ + public static String getHTMLfinBodyHTML() { + return "\r"; + } + + /** + * Retourne le code HTML du menu + * @param items + * @return + */ + public static String getHTMLmenu(ArrayList items) { + + String codeHTMLMenu= "
Note"; + for(int i =0 ; i < items.size(); i++) { + codeHTMLMenu = codeHTMLMenu + "" + items.get(i).getAttributs().get("titre") + ""; + } + codeHTMLMenu = codeHTMLMenu + "
"; + + return codeHTMLMenu; + + } + + + /** + * Du javascript pour le menu sticky + * @return + */ + public static String getHTMLJavaScript() { + return ""; + } +} diff --git a/src/MEPTL/StringSimilarity.java b/src/MEPTL/StringSimilarity.java new file mode 100644 index 0000000..a42cb9b --- /dev/null +++ b/src/MEPTL/StringSimilarity.java @@ -0,0 +1,54 @@ +package MEPTL; + +public class StringSimilarity { + /** + * Calculates the similarity (a number within 0 and 1) between two strings. + */ + public static double similarity(String s1, String s2) { + String longer = s1, shorter = s2; + if (s1.length() < s2.length()) { // longer should always have greater length + longer = s2; shorter = s1; + } + int longerLength = longer.length(); + if (longerLength == 0) { return 1.0; /* both strings are zero length */ } + /* // If you have StringUtils, you can use it to calculate the edit distance: + return (longerLength - StringUtils.getLevenshteinDistance(longer, shorter)) / + (double) longerLength; */ + return (longerLength - editDistance(longer, shorter)) / (double) longerLength; + + } + + // Example implementation of the Levenshtein Edit Distance + // See http://r...content-available-to-author-only...e.org/wiki/Levenshtein_distance#Java + public static int editDistance(String s1, String s2) { + s1 = s1.toLowerCase(); + s2 = s2.toLowerCase(); + + int[] costs = new int[s2.length() + 1]; + for (int i = 0; i <= s1.length(); i++) { + int lastValue = i; + for (int j = 0; j <= s2.length(); j++) { + if (i == 0) + costs[j] = j; + else { + if (j > 0) { + int newValue = costs[j - 1]; + if (s1.charAt(i - 1) != s2.charAt(j - 1)) + newValue = Math.min(Math.min(newValue, lastValue), + costs[j]) + 1; + costs[j - 1] = lastValue; + lastValue = newValue; + } + } + } + if (i > 0) + costs[s2.length()] = lastValue; + } + return costs[s2.length()]; + } + + public static void printSimilarity(String s, String t) { + System.out.println(String.format( + "%.3f is the similarity between \"%s\" and \"%s\"", similarity(s, t), s, t)); + } +} diff --git a/src/MEPTL/commandes.java b/src/MEPTL/commandes.java new file mode 100644 index 0000000..c3050ea --- /dev/null +++ b/src/MEPTL/commandes.java @@ -0,0 +1,586 @@ +package MEPTL; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import cXML.Run.UserStatus; + + +/** + * + * @author pablo rodriguez + * + */ +public class commandes { + + static String nameSujet = ""; //sujet par défaut + public static boolean analyse = false; //analyse des fichiers étudiants + public static boolean ecritCode = false; // ecriture du code du sujet + public static boolean ecritSujet = false; // ecriture 2 du code du sujet + public static boolean ecritNoteCSV = false; // ecriture note.csv + public static boolean sansFeeback = false; // pas de feedback étudiant + public static boolean verifHisto = false; // vérification des historiques correspond à la commande -verif + public static boolean verifHisto2 = false; // vérification des historiques lorsqu'il y a aussi analyse + public static boolean fourniCSV = false; // fourni le fichier CSV contenant la liste des étudiants + public static boolean badCommand = false ; //erreur dans les commandes + public static boolean noNote =false; + public static boolean noLogo =false; + public static boolean newLogo=false; + public static boolean licence = false; + public static boolean zipfeedback = false; // Les feedback dans une archive ZIP + static cXML.Run.UserStatus Profil = cXML.Run.UserStatus.TEACHER ; //Le profil TEACHER permet de lire dans les dossiers contenus dans le répertoire courant de l'application. Le profil STUDENT permet de lire au niveau du répertoire courant de l'application. + public static boolean fourniDossierDestination = false; //répertoire de destination des feedbacks et CSV; + public static String nameCSV = ""; //le nom du fichier contenant la liste des étudiants + public static String nameSVG =""; //le nom du nouveau logo + public static String contenuFichierSVG =""; + public static String path =""; + public static String pathDestination =""; + public static String version ="3.5.1"; + public static String Command =""; + public static String culture = "FR"; + //setting valeur par défaut + public static int tolerance_characters = 5; + public static double tolerance_text = 0.79; + public static int number_match = 2; + public static int mini_number_modification = 0; + public static int nombres_modifications_simultané_maxi = 100; + public static int tolerance_rouge = 30; + public static int tolerance_vert = 30; + public static int tolerance_bleu = 30; + + /** + * + * @param args : table des arguments + * @param patch : chemin vers le répertoire courant de l'application + * @throws IOException + * @throws InterruptedException + */ + public commandes(String[] args, String path) throws IOException, InterruptedException { + commandes.path = path; + + try { + if(args.length==0) {badCommand=true; System.out.println("There must be at least one command.");System.out.println("You can type the -help command to get help.");} + for(int i = 0 ; i < args.length ; i++) { + Command = Command + " " +args[i]; + if(args[i].equals("-use")) if((i+1)=0) {if(args[i-1].equals("-use")) analyse=true;}else {badCommand=true; System.out.println("The -use command must be before the name of the analyze file.");} + if(i-1>=0) {if(!args[i-1].equals("-use")) {badCommand=true; System.out.println("The -use command is missing in front of the name of the scan file.");}}else {badCommand=true; System.out.println("The -use command must be before the name of the analyze file.");} + } + if(args[i].contains(".csv")) { + Matcher m = Pattern.compile("{1,}.csv$").matcher(args[i]); + if(m.find()) {fourniCSV=true; nameCSV = args[i];}else {badCommand=true;System.out.println("There is a problem with the extension of the CSV file. The extension must be \".csv\".");} + if(!args[i-1].equals("-csv") && !args[i-1].equals("-verifcsv")) {badCommand=true; System.out.println("The -csv or -verifcsv command is missing in front of the name of the file containing the list of students with their identifiers.");} + } + if(args[i].equals("-csv")) { + if(!analyse) {badCommand=true;System.out.println("You must type the -use analyzefileName.xml command then after the command -csv.");} + ecritNoteCSV=true; + } + if(args[i].contains(".svg")) { + Matcher m = Pattern.compile("{1,}.svg$").matcher(args[i]); + if(m.find()) {newLogo=true; nameSVG = args[i];}else {badCommand=true;System.out.println("There is a problem with the extension of the SVG file. The extension must be \".svg\".");} + if(!args[i-1].equals("-newLogo")) {badCommand=true; System.out.println("The -newLogo command is missing in front of the name of the SVG file.");} + } + if(args[i].equals("-newLogo")) { + if(!analyse) {badCommand=true;System.out.println("You must type the -use analyzefileName.xml command then after the command -newLogo.");} + if(noLogo) {badCommand=true;System.out.println("The -newLogo and -noLogo commands cannot be executed together.");} + newLogo=true; + } + if(args[i].equals("-verifcsv")) { + if(verifHisto) {badCommand=true;System.out.println("The -verifcsv and -verif commands cannot be executed together.");} + ecritNoteCSV=true; + verifHisto=false; + verifHisto2=true; + if(!analyse) {badCommand=true;System.out.println("You must type the command -use analyzeFileName.xml then after the command -verifcsv.");} + } + if(args[i].equals("-nofeedback")) { + if(zipfeedback) {badCommand=true;System.out.println("It is not possible to run the -nofeedback and -zipfeedback commands at the same time. ");} + sansFeeback=true; + } + if(args[i].equals("-verif")) { + if(verifHisto2) {badCommand=true;System.out.println("The -verifcsv and -verif commands cannot be executed together.");} + verifHisto=true; + verifHisto2=false; + } + if(args[i].equals("-help")) { + if(args.length>1) {System.out.println("\n\n***\nThe -help command should be the only command.\n***");clotureWithError();} + helpEN(); + clotureWithHelp(); + } + if(args[i].equals("-aide")) { + if(args.length>1) {System.out.println("\n\n***\nThe -aide command should be the only command.\n***");clotureWithError();} + helpFR(); + clotureWithHelp(); + } + if(args[i].equals("-licence")) { + if(args.length>1) {System.out.println("\n\n***\nThe -licence command should be the only command.\n***");clotureWithError();} + licence(); + } + if(args[i].equals("-write")) { + if(args.length>1) {System.out.println("\n\n***\nThe -write command should be the only command.\n***");clotureWithError();} + ecritCode=true; + Profil = UserStatus.STUDENT; + } + if(args[i].equals("-sujet")) { + if(!analyse) {badCommand=true;System.out.println("You must type the command -use, then the name of analysis file, then the command -sujet.");} + if(args.length>3) {badCommand=true; System.out.println("If you use the command -sujet, you can't use other commands except -use and the filename.");} + ecritSujet=true; + } + if(args[i].equals("-nologo")) { + if(!analyse) {badCommand=true;System.out.println("You must type the command -use , then the filename and after then the command -sujet.");} + if(newLogo) {badCommand=true;System.out.println("The -newLogo and -noLogo commands cannot be executed together.");} + noLogo=true; + } + if(args[i].equals("-about")) { + if(args.length>1) {System.out.println("\n\n***\nThe -about command should be the only command.\n***");clotureWithError();} + about(); + clotureApplication(); + } + if(args[i].equals("-nonote")) { + noNote=true; + } + if(args[i].equals("-zipfeedback")) { + if(!analyse) {badCommand=true;System.out.println("You must type the command -use, then the name of analysis file, then the command -zipfeedback.");} + if(sansFeeback) {badCommand=true;System.out.println("It is not possible to run the -nofeedback and -zipfeedback commands at the same time.");} + zipfeedback=true; + } + if(args[i].equals("-dest")) if((i+1) " + path); + System.out.println(); + System.out.println("P. Rodriguez"); + + } + + /** + * Message dans la console + * @throws IOException + * @throws InterruptedException + */ + private static void helpEN() throws InterruptedException, IOException { + CLS(); + System.out.println(); + System.out.println("**************************************"); + System.out.println("* LIST OF ANALYSEWRITER COMMANDS * "); + System.out.println("**************************************"); + System.out.println(); + + System.out.println(" -use : \t Used to indicate the analysis file."); + System.out.println(" : \t The analysis file (XML format) must be placed just after the command."); + System.out.println(" : \t Student files must be in named folders (export from moodle)."); + System.out.println(" : \t Student files must be in ODF format with the extension .odt."); + System.out.println(); + + System.out.println(" file.xml : \t The analysis file in XML format."); + System.out.println(" : \t file.xml must be placed just after the -use command."); + System.out.println(" : \t The file.xml file must be located in the current folder*."); + System.out.println(" : \t This file must be obtained with the -write command."); + System.out.println(" : \t This file must be manually modified to adapt it to your analysis."); + System.out.println(); + + System.out.println(" -verif : \t Allows you to compare all the modifications between the modification track logs."); + System.out.println(" : \t If this is the only command then there is no analysis, no rating, no feedback."); + System.out.println(" : \t This command does not depend on an analysis file (independent of subjects)."); + System.out.println(" : \t You can analyze the logs even if you do not have an analysis file."); + System.out.println(" : \t In the current folder*, you will find the \"Verif.xml\" file."); + System.out.println(); + + System.out.println(" -cvs : \t Allows to import all the notes in a file in CSV format (separator the semicolon)."); + System.out.println(" : \t The -use file.xml command must be placed before the -csv command."); + System.out.println(" : \t The generated file is located in the current folder*."); + System.out.println(" : \t This command can be followed by a file in CSV format containing the list of students."); + System.out.println(" : \t If this command is followed by the \"file.csv\" file then retrieves the student IDs."); + System.out.println(); + + System.out.println(" -verifcvs : \t Allows you to compare all the modifications between the modification track logs."); + System.out.println(" : \t Allows to import all the notes in a file in CSV format (separator the semicolon)."); + System.out.println(" : \t The -use file.xml command must be placed before the -verifcsv command."); + System.out.println(" : \t In the current folder, you will find the \"Verif.xml\" file."); + System.out.println(" : \t The -verifcsv command can be followed by a file in CSV format containing the list of students."); + System.out.println(" : \t If this command is followed by the \"file.csv\" file then retrieves the student IDs."); + System.out.println(); + + System.out.println(" file.csv : \t The file containing the list of students in CSV format."); + System.out.println(" : \t The \"file.csv\" file must be placed just after the -csv or -verifcsv command."); + System.out.println(" : \t The \"file.csv\" file must be in the current folder*."); + System.out.println(" : \t The default separator in the CSV file is the semicolon."); + System.out.println(" : \t In this file, there must be the columns \"First name\", \"Last name\", \"Identification number\"and \"Email\"."); + System.out.println(" : \t You are exporting this file from the Moodle server (gradebook, exporter)."); + System.out.println(); + + System.out.println(" -write : \t Allows you to write an analysis file."); + System.out.println(" : \t The generated file is located in the current folder*."); + System.out.println(" : \t The generated file is in XML format."); + System.out.println(" : \t You must adapt it by modifying the XML code to perform your own analyzes."); + System.out.println(); + + System.out.println(" -zipfeedback : \t Allows you to generate a ZIP archive containing student feedback. "); + System.out.println(" : \t The archive is named \"moodleFeedback.zip\"."); + System.out.println(" : \t The archive respects the format for importing feedback into Moodle."); + System.out.println(); + + System.out.println(" -nofeedback : \t If TRUE allows you to not generate feedback for the students.."); + System.out.println(" : \t Feedbacks are files in HTML format.."); + System.out.println(" : \t Feedbacks can be found in the current folder*."); + System.out.println(); + + System.out.println(" -nonote : \t Avoid display in the feedbacks of the grade."); + System.out.println(" : \t Avoid placing the student's grade in the file name."); + System.out.println(); + + System.out.println(" -dest : \t Specifies the destination directory for feedbacks and XML and CSV files."); + System.out.println(" : \t Example: -dest \"./output/\" destination folder the \"output\" directory."); + System.out.println(" : \t The destination directory must be in the current directory of the application."); + System.out.println(" : \t There can only be one directory (no subdirectory). "); + System.out.println(" : \t The path must begin with \"./\"."); + System.out.println(" : \t If the folder name contains the $ symbol, it is ignored by the scan. "); + System.out.println(); + + System.out.println(" -sujet : \t Used to retrieve the scan file containing only the evaluated nodes. "); + System.out.println(" : \t The \"sujet.xml\" file is generated from the \"file.xml\" analysis file. "); + System.out.println(" : \t The \"subject.xml\" file is located in the current application folder. "); + System.out.println(); + + System.out.println(" -about : \t Displays the version, author and license. "); + System.out.println(); + + System.out.println(" -licence : \t Displays the text of the application license. "); + System.out.println(); + + System.out.println(" -aide : \t Display application help in French."); + System.out.println(); + + System.out.println(); + System.out.println("---"); + System.out.println("* The current folder is the folder in which the application is located \"analyseWriter.jar\".\n" + +"Dossier courant -> " + path); + System.out.println(); + System.out.println("P. Rodriguez"); + + } + + + /** + * Message dans la console + * @throws IOException + * @throws InterruptedException + */ + private static void about() throws InterruptedException, IOException { + CLS(); + System.out.println(); + System.out.println("*******************************************************************"); + System.out.println("application: analyseWriter"); + System.out.println(); + System.out.println("version : " + version); + System.out.println("Mise à jour : https://github.com/1-pablo-rodriguez/analyseWriter\n"); + System.out.println("enseignant : pablo Rodriguez"); + System.out.println("Université d'Artois - 10 rue du temple 62000 Arras\n"); + System.out.println("LICENCE"); + System.out.println("GNU GENERAL PUBLIC LICENSE\r\nVersion 3, 29 June 2007"); + System.out.println("*******************************************************************"); + System.out.println(); + } + + /** + * Licence de l'application + * @throws IOException + */ + private static void licence() throws IOException { + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + InputStream is = classLoader.getResourceAsStream("licence.txt"); + + Reader initialReader = new BufferedReader(new InputStreamReader(is, "UTF-8")); + char[] arr = new char[8 * 1024]; + StringBuilder buffer = new StringBuilder(); + int numCharsRead; + while ((numCharsRead = initialReader.read(arr, 0, arr.length)) != -1) { + buffer.append(arr, 0, numCharsRead); + } + initialReader.close(); + System.out.println(buffer.toString()); + + System.out.println(); + System.out.println("\t\t┌─────────────────────────────────────────────┐"); + System.out.println("\t\t│ Above, you have the app license. │"); + System.out.println("\t\t│ │"); + System.out.println("\t\t│ (')_(') │"); + System.out.println("\t\t│ ( `.° ) │"); + System.out.println("\t\t│ (\")__(\") .. see you soon, analyseWriter. │"); + System.out.println("\t\t└─────────────────────────────────────────────┘"); + System.out.println(); + System.exit(0); + } + + + /** + * Clôture avec une erreur de commande + */ + public static void clotureWithError() { + System.out.println(); + System.out.println("\t\t┌─────────────────────────────────────────────┐"); + System.out.println("\t\t│ You made a mistake in your command. │"); + System.out.println("\t\t│ │"); + System.out.println("\t\t│ You need to read the above information and │"); + System.out.println("\t\t│ start over. │"); + System.out.println("\t\t│ │"); + System.out.println("\t\t│ (')_(') │"); + System.out.println("\t\t│ ( `.° ) │"); + System.out.println("\t\t│ (\")__(\") .. see you soon, analyseWriter. │"); + System.out.println("\t\t└─────────────────────────────────────────────┘"); + System.out.println(); + System.exit(0); + } + + + /** + * Bye Bye the application + */ + public static void clotureApplication() { + System.out.println(); + System.out.println("\t\t┌────────────────────────────────────────────────────┐"); + System.out.println("\t\t│ (')_(') │"); + System.out.println("\t\t│ ( `.° ) Well done, you've worked very hard! │"); + System.out.println("\t\t│ (\")__(\") .. Bye Bye analyseWriter. │"); + System.out.println("\t\t└────────────────────────────────────────────────────┘"); + System.out.println(); + System.exit(0); + } + + public static void clotureWithHelp() { + System.out.println(); + System.out.println("\t\t┌─────────────────────────────────────────────────────┐"); + System.out.println("\t\t│ Above you have the help of the app. │"); + System.out.println("\t\t│ But don't forget, you also have the documentation │"); + System.out.println("\t\t│ on the github website. And soon in english. │"); + System.out.println("\t\t│ │"); + System.out.println("\t\t│ (')_(') │"); + System.out.println("\t\t│ ( `.° ) │"); + System.out.println("\t\t│ (\")__(\") .. see you soon, analyseWriter. │"); + System.out.println("\t\t└─────────────────────────────────────────────────────┘"); + System.out.println(); + System.exit(0); + System.exit(0); + } + + public static void clotureWithErrorFile(String filename) { + int nbespace = 30-filename.length(); + if (nbespace<0) nbespace=1; + System.out.println(); + System.out.println("\t\t┌───────────────────────────────────────────────────────────┐"); + System.out.println("\t\t│ The file \""+ filename + "\" does not exist." + new String(new char[nbespace]).replace("\0", " ") +"│" ); + System.out.println("\t\t│ │"); + System.out.println("\t\t│ (')_(') │"); + System.out.println("\t\t│ ( `.° ) │"); + System.out.println("\t\t│ (\")__(\") .. see you soon, analyseWriter. │"); + System.out.println("\t\t└───────────────────────────────────────────────────────────┘"); + System.out.println(); + System.exit(0); + } + + + + /** + * Nettoyage de la console.
+ *
+ * @throws InterruptedException + * @throws IOException + */ + public static void CLS() throws InterruptedException, IOException { + new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor(); + } +} + diff --git a/src/MEPTL/meptl.java b/src/MEPTL/meptl.java new file mode 100644 index 0000000..75aa58c --- /dev/null +++ b/src/MEPTL/meptl.java @@ -0,0 +1,5265 @@ +package MEPTL; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.FormatStyle; +import java.util.ArrayList; +import java.util.Date; +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.xml.parsers.ParserConfigurationException; + +import org.xml.sax.SAXException; + +import cXML.Run; +import cXML.Run.UserStatus; +import cXML.node; +import net.lingala.zip4j.exception.ZipException; + + +/** + * + * @author pablo rodriguez + * + * + */ +public class meptl { + + static DecimalFormat df = new DecimalFormat("###.##"); + static String patch =""; + static double progression = 1.0; + + /** + * Démarrage de l'application.
+ *
+ * @param args + * @throws ParserConfigurationException + * @throws SAXException + * @throws IOException + * @throws CloneNotSupportedException + * @throws InterruptedException + */ + public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException, CloneNotSupportedException, InterruptedException { + System.getProperty("file.encoding","UTF-8"); + node nodeCSV = null; //Permet de convertir le fichier contenant la liste des étudiants en node + + patch = System.getProperty("user.dir"); +// patch = "C:/Users/pabr6/OneDrive/Desktop/Nouveau dossier"; + + //les commandes + new commandes(args,patch); + + //Lancement des lectures des dossiers + Run a = new Run(patch,commandes.Profil); + + + //chargement du node sujet (fichier d'analyse) + //La méthode verificationFichier Analyse permet de détecter des erreurs dans le fichier d'analyse + node nodeSujet = new node(); + if(!commandes.ecritCode && commandes.analyse) { + nodeSujet = chargementsujet(a, commandes.nameSujet); + commandes.culture = nodeSujet.retourneFirstEnfantsByName("setting").getAttributs().get("culture"); //récupère la culture de l'utilisateur + new verificationFichierAnalyse(nodeSujet); + if(verificationFichierAnalyse.erreur==true) verificationFichierAnalyse.clotureWithErrorInanalyzeFile(); + //a.ecritureNodeEnXML(nodeSujet, "sujet","",false); // ecriture du node sujet + if(commandes.ecritSujet) { + a.ecritureNodeEnXML(nodeSujet, "sujet","",false, "Sujet"); // ecriture du node sujet + System.out.println(); + System.out.println("\tWriting of the \"sujet.xml\" file completed."); + commandes.clotureApplication(); + System.exit(0); + } + + //Chargement du contenu du nouveau logo + if(commandes.newLogo && !commandes.nameSVG.isEmpty()) { + commandes.contenuFichierSVG= chargementFichierSVG(a,commandes.nameSVG); + } + + //chargement du node translation qui se trouve dans le node setting + outils.chargeTraduction(nodeSujet.retourneFirstEnfantsByName("translation")); + + try { + // Charge les nouvelles tolérances du nombre de caractère et du texte pour la recherche et la comparaison des textes. + if(nodeSujet.containElementByName("text:similarity")) { + node similarity = nodeSujet.retourneFirstEnfantsByName("text:similarity"); + if(similarity.getAttributs().get("tolerance_characters")!=null) commandes.tolerance_characters = Integer.valueOf(similarity.getAttributs().get("tolerance_characters")); + if(similarity.getAttributs().get("tolerance_text")!=null) commandes.tolerance_text = Double.valueOf(similarity.getAttributs().get("tolerance_text")); + } + // Charge le nombre de match limite et le nombre minimal de modification dans le node verification + if(nodeSujet.containElementByName("plagiarism")) { + node plagiarism = nodeSujet.retourneFirstEnfantsByName("plagiarism"); + if(plagiarism.getAttributs().get("number_match") != null) commandes.number_match = Integer.valueOf(plagiarism.getAttributs().get("number_match")); + if(plagiarism.getAttributs().get("mini_number_modification") != null) commandes.mini_number_modification = Integer.valueOf(plagiarism.getAttributs().get("mini_number_modification")); + if(plagiarism.getAttributs().get("nombres_modifications_simultané_maxi") != null) commandes.nombres_modifications_simultané_maxi = Integer.valueOf(plagiarism.getAttributs().get("nombres_modifications_simultané_maxi")); + } + // Charge tolerance pour la couleur + if(nodeSujet.containElementByName("color")) { + node color = nodeSujet.retourneFirstEnfantsByName("color"); + if(color.getAttributs().get("tolerance_rouge") != null) commandes.tolerance_rouge= Integer.valueOf(color.getAttributs().get("tolerance_rouge")); + if(color.getAttributs().get("tolerance_vert") != null) commandes.tolerance_vert= Integer.valueOf(color.getAttributs().get("tolerance_vert")); + if(color.getAttributs().get("tolerance_bleu") != null) commandes.tolerance_bleu= Integer.valueOf(color.getAttributs().get("tolerance_bleu")); + } + }catch (Exception e) { + System.out.println(e); + } + + } + + //chargement et verification du CVS fourni + if(commandes.fourniCSV) nodeCSV = chargementFichierCSV(a, commandes.nameCSV); + + // vérification des historiques + node verif = new node(); + if(commandes.verifHisto || commandes.verifHisto2) { + int nbFichierWriter = a.getLectDossiers().getEC().getListeContentWriter().size(); + node verification = new node(); + verification.setNomElt("verification"); + verification.getAttributs().put("nombre_fichier", String.valueOf(a.getLectDossiers().getEC().getListeFichierodt().size())); + for(int i = 0 ; i < nbFichierWriter ; i++) { + node nod = a.XMLContent(a.getLectDossiers().getEC().getListeContentWriter().get(i)); + node nodStudent = LectureFichierEtudiantPourVerification(nod,a,i); + verification.getNodes().add(nodStudent); + } + //a.ecritureNodeEnXML(verification, "VerificationHistorique","",false); //écriture du node de l'étudiant + verif = verificationHistorique(verification, a); // vérification des correspondances entre les fichiers + a.ecritureNodeEnXML(verif, "Verif",commandes.pathDestination,commandes.fourniDossierDestination, "Verif"); //écriture du node de vérification + if(!commandes.analyse) {commandes.clotureApplication();System.exit(0);} + } + + + //nombre de fichier writer à analyser + int nbFichierWriter = a.getLectDossiers().getEC().getListeContentWriter().size(); + System.getProperty("file.encoding","UTF-8"); + + //ensemble des analyses + node ensembleanalyse = new node(); + ensembleanalyse.setNomElt("analyses"); + + + for(int i = 0 ; i < nbFichierWriter ; i++) { + + // Ne prends pas en compte le dossier destination créé par la commande -dest + // Si pas d'analyse alors le nom doit contenir le caractère $ dans le nom du dossier. + if(commandes.fourniDossierDestination)if(a.getLectDossiers().getEC().getListeNomDossier().get(i).equals(commandes.pathDestination)) continue; + + //Chargement du format (content) et transformation en node pour l'application + node nod = a.XMLContent(a.getLectDossiers().getEC().getListeContentWriter().get(i)); + node nodStudent = LectureFichierEtudiantSousFormeDeNode(nod,a,i); + //a.ecritureNodeEnXML(nodStudent, a.getLectDossiers().getEC().getListeNomDossier().get(i),"",false); //écriture du node de l'étudiant + + // ecriture d'une fichier d'analyse. + // commande -write + if(commandes.ecritCode && ! commandes.verifHisto && !commandes.analyse) { + node nodSujet = nodePourEcritureSujet(nodStudent,a,i); + nodSujet = addSetting(nodSujet); // ajoute le node setting et translation + a.ecritureNodeEnXML(nodSujet, a.getLectDossiers().getEC().getListeNomDossier().get(i),"",false,"Sujet"); + } + + // analyse des fichiers student + if(commandes.analyse) { + node init = InitialisationAvantAnalyse(nodeSujet); + if(!Boolean.valueOf(init.getAttributs().get("erreur"))) { + node ana = analyse(nodStudent, nodeSujet, i, a); +// a.ecritureNodeEnXML(ana, "nodana"+ana.retourneFirstEnfantsByName("ouverture").getAttributs().get("dossier"),"",false); //écriture du node analyse de l'étudiant + + // création des feedbacks avec des tailles définies + if(!commandes.sansFeeback) if(!commandes.zipfeedback) feedback(ana, verif); //classique directement dans le répertoire + if(!commandes.sansFeeback) if(commandes.zipfeedback) { // Dans une archive pour Moodle + try { + long size = 48000000; //valeur par défaut + String nameZip = "feedbackMoodle"; //nom zip par défaut + node zip = nodeSujet.retourneFirstEnfantsByName("zip"); + if(zip!=null) { + if(zip.getAttributs().get("size")!=null)size = Long.valueOf(zip.getAttributs().get("size")); + if(zip.getAttributs().get("name")!=null)nameZip = zip.getAttributs().get("name"); + } + a.AddStreamToZip(feedbackForZip(ana, verif), retourneLeNomDuFeedback(a.getLectDossiers().getEC().getListeNomFichierFeedBack().get(i),ana, verif),size,nameZip); + } catch (ZipException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if(commandes.ecritNoteCSV) ensembleanalyse.addNode(ana); + messageSystem(ana); + }else { + + } + + } + } + //exportation au format CSV + if(commandes.ecritNoteCSV && !commandes.fourniCSV) { + if(!commandes.verifHisto2) ecritureCSV(ensembleanalyse); + if(commandes.verifHisto2) ecritureCSV(ensembleanalyse,verif,a,nodeSujet.retourneFirstEnfantsByName("setting")); + //a.ecritureNodeEnXML(ensembleanalyse, "ensembleAnalyse"); //écriture du node de l'étudiant + } + if(commandes.ecritNoteCSV && commandes.fourniCSV) { + ecritureCSV(ensembleanalyse,verif,a,nodeCSV, nodeSujet.retourneFirstEnfantsByName("setting")); + //a.ecritureNodeEnXML(ensembleanalyse, "ensembleAnalyse"); //écriture du node de l'étudiant + } + + //bye bye + commandes.clotureApplication(); + + } + + + + /** + * Lecture du fichier Student pour vérification.
+ *
+ * @param nod node + * @param a + * @param i + * @return + */ + private static node LectureFichierEtudiantPourVerification(node nod, Run a, Integer i) { + node fichier = new node(); + fichier.setNomElt("fichier"); + fichier.getAttributs().put("filename", a.getLectDossiers().getEC().getListeFichierodt().get(i)); + fichier.getAttributs().put("dossier", a.getLectDossiers().getEC().getListeNomDossier().get(i)); + + + node nodmeta = nod.retourneFirstEnfantsByName("office:meta"); + fichier.getAttributs().put("producteur", nodmeta.retourneFirstEnfantsByName("meta:generator").getContenu()); + fichier.getAttributs().put("dateModification", nodmeta.retourneFirstEnfantsByName("dc:date").getContenu()); + fichier.getAttributs().put("dureeEdition", nodmeta.retourneFirstEnfantsByName("meta:editing-duration").getContenu()); + fichier.getNodes().add(nodmeta); + + node nodhistorique = new node(); + int nbrModif = nod.retourneFirstEnfantsByName("text:tracked-changes").getNodes().size(); + nodhistorique.setNomElt("historique"); + nodhistorique.getAttributs().put("nbrModif", String.valueOf(nbrModif)); + nodhistorique.getNodes().addAll(a.retourneNames(a.NodeFirstName(nod, "office:text"), "text:tracked-changes")); + fichier.getNodes().add(nodhistorique); + + return fichier; + } + + /** + * Lecture du fichier Writer des étudiants et fournir tous les nodes de la lecture dans un node nommé "fichier". + * @param nod Le node Writer de l'étudiant. + * @param a Objet de la class Run package cXML + * @param i Index de l'étudiant dans la liste EC de l'objet a. + * @return le node contenant tous les nodes de la lectures. + * @throws IOException Input Output exception file. + */ + @SuppressWarnings("unchecked") + private static node LectureFichierEtudiantSousFormeDeNode(node nod, Run a, Integer i) throws IOException { + node nodecontent = nod.retourneFirstEnfantsByName("office:document-content"); + node nodestyle = nod.retourneFirstEnfantsByName("office:document-styles"); + node nodbody = a.NodeFirstName(nodecontent, "office:text"); + node nodmeta = nod.retourneFirstEnfantsByName("office:meta"); + + node nodstyle = new node(); + nodstyle.setNomElt("styles"); + nodstyle.addNode(a.NodeFirstName(nodecontent,"office:automatic-styles")); + nodstyle.addNode(a.NodeFirstName(nodestyle, "office:automatic-styles")); + nodstyle.addNode(a.NodeFirstName(nodestyle, "office:styles")); + nodstyle.addNode(a.NodeFirstName(nodestyle, "office:master-styles")); + + // Le node des styles de page + node nodstylepage = new node(); + nodstylepage.setNomElt("style:page"); + nodstylepage.addNode(a.retourneNames(nodstyle, "style:master-page")); + for(int j = 0 ; j < nodstylepage.getNodes().size();j++) { + if(nodstylepage.getNodes().get(j).getAttributs().get("style:page-layout-name")!=null) { + node nod1 = a.retourneFirstNodeByNameAttributValue(nodstyle, "style:page-layout", "style:name", nodstylepage.getNodes().get(j).getAttributs().get("style:page-layout-name")); + if(nod1!=null) nodstylepage.getNodes().get(j).addNode(nod1); + } + } + + // le node des styles de paragraphe + node nodstyleparagraphe = new node(); + nodstyleparagraphe.setNomElt("style:paragraph"); + nodstyleparagraphe.addNode(a.NodesAyantAttribut(nodstyle, "style:family","paragraph")); + nodstyleparagraphe.addNode(a.NodesAyantAttribut(nodstyle, "style:family","text")); + + // le node des styles de formatage direct + node nodstyleformatage = new node(); + nodstyleformatage.setNomElt("style:formatagedirect"); + nodstyleformatage.addNode(a.NodesAyantAttribut(nodstyle, "style:family","text")); //c'est redondant puisque déjà présent dans style:paragraph + + //Le node numérotation des chapitres + node nodnumerochapitre = new node(); + nodnumerochapitre.setNomElt("numerotationchapitre"); + nodnumerochapitre.addNode(a.retourneNames(nodstyle, "text:outline-level-style")); + + + // le node variable de sequence + node nodsequence = new node(); + nodsequence.setNomElt("sequences"); + nodsequence.addNode(a.retourneNames(nodbody, "text:sequence-decl")); + + // le node des frames : renomme les nodes style:style avec le nom de draw:name exemple style:styledraw:name + // si une draw:text-box contenant un attribut fo:min-height alors ajoute dans darw:farme l'attribut svg:height + node nodframe = new node(); + nodframe.setNomElt("frames"); + nodframe.addNode(a.retourneNames(nodbody, "draw:frame")); + for(int j = 0 ; j < nodframe.getNodes().size(); j++) { + node nodframestyle = a.retourneFirstNodeByNameAttributValue(nodstyle, "style:style", "style:name", nodframe.getNodes().get(j).getAttributs().get("draw:style-name")); + String nomObjet = nodframe.getNodes().get(j).getAttributs().get("draw:name"); + if(nomObjet!=null) { + nomObjet= nomObjet.replace(" ", "_"); + if(nodframestyle!=null) nodframestyle.setNomElt("style:style"+nomObjet); + } + nodframe.getNodes().get(j).getNodes().add(nodframestyle); + if(a.retourneName(nodframe.getNodes().get(j), "draw:text-box", "fo:min-height")!=null) { + nodframe.getNodes().get(j).getAttributs().put("svg:height", a.retourneName(nodframe.getNodes().get(j), "draw:text-box", "fo:min-height").getAttributs().get("fo:min-height")); + } + } + + // le node section + node nodsection = new node(); + nodsection.setNomElt("sections"); + //nodsection.addNode(a.retourneNames(nodbody, "text:section")); + + // la bibliographie + node nodbiblio = new node(); + nodbiblio.setNomElt("biblio"); + nodbiblio.addNode(a.retourneNames(nodbody, "text:bibliography")); + + //table des matieres + node nodtable = new node(); + nodtable.setNomElt("tablematieres"); +// nodtable.addNode(a.retourneNames(nodbody, "text:table-of-content")); + // renomme le node text:table-of-content-source en text:table-of-content-sourceTitreIndex + ArrayList A = a.retourneNames(nodbody, "text:table-of-content"); + for(int j = 0 ; j nodpage = new ArrayList(); + node page = new node(); + page.setNomElt("page"); + page.getAttributs().put("numero", "0"); + page.getAttributs().put("style:master-page-name", "Standard"); // style par défaut des pages + nodpage.add(page); + + int compteurpage = 1; + for(int j = 0 ; j< nodstructure.getNodes().size();j++) { + + page = nodpage.get(nodpage.size()-1); // dernière page enregistrer pour insérer des enfants en bas de la boucle + + + // les sauts automatiques de page dans les paragraphe + if(nodstructure.getNodes().get(j).retourneEnfantsByNameExist("text:soft-page-break")) { + ArrayList nods1 = a.retourneNames(nodstructure.getNodes().get(j), "text:soft-page-break"); + if(nods1.size()>1) { + for(int k = 0 ; k < nods1.size();k++) { + node p = new node(); + p.setNomElt("page"); + p.getAttributs().put("numero", String.valueOf(compteurpage)); + p.getAttributs().put("type","automatique"); + p.getAttributs().put("index",String.valueOf(j)); + p.getNodes().add(nods1.get(k)); + nodpage.add(p); + compteurpage++; + } + page = nodpage.get(nodpage.size()-1); + continue; + }else { + node p = new node(); + p.setNomElt("page"); + p.getAttributs().put("numero", String.valueOf(compteurpage)); + p.getAttributs().put("type","automatique"); + p.getAttributs().put("index",String.valueOf(j)); + p.getNodes().add(nodstructure.getNodes().get(j)); + nodpage.add(p); + compteurpage++; + page = nodpage.get(nodpage.size()-1); + continue; + } + } + + // les sauts manuels de page dans les paragraphes et + if(nodstructure.getNodes().get(j).getAttributs().get("text:style-name")!=null) { + node nod2 = a.retourneFirstNodeByNameAttributValue(nodstyle.getNodes(), "style:style", "style:name", nodstructure.getNodes().get(j).getAttributs().get("text:style-name")); + if(nod2!=null) { + if(nod2.getAttributs().get("style:master-page-name")!=null) { + node p = new node(); + p.setNomElt("page"); + p.getAttributs().put("numero", String.valueOf(compteurpage)); + p.getAttributs().put("type","manuel"); + p.getAttributs().put("index",String.valueOf(j)); + p.getAttributs().put("style:master-page-name",nod2.getAttributs().get("style:master-page-name")); + p.getAttributs().put("style:name",nod2.getAttributs().get("style:name")); + node nod3 = a.retourneName(nod2.getNodes(), "style:paragraph-properties","fo:break-before"); + if(nod3!=null) { + if(nod3.getAttributs().get("style:page-number")!=null) p.getAttributs().put("style:page_number", nod3.getAttributs().get("style:page-number")); + }else { + nod3 = nod2.retourneFirstEnfantsByName("style:paragraph-properties"); + if(nod3!=null) if(nod3.getAttributs().get("style:page-number")!=null) { + p.getAttributs().put("style:page_number", nod3.getAttributs().get("style:page-number")); + } + } + p.getNodes().add(nodstructure.getNodes().get(j)); + nodpage.add(p); + compteurpage++; + page = nodpage.get(nodpage.size()-1); + continue; + } + if(a.retourneFirstNodeByNameAttributValue(nod2.getNodes(), "style:paragraph-properties","fo:break-before","page")!=null) { + node p = new node(); + p.setNomElt("page"); + p.getAttributs().put("numero", String.valueOf(compteurpage)); + p.getAttributs().put("type","automatique"); + p.getAttributs().put("index",String.valueOf(j)); + p.getNodes().add(nodstructure.getNodes().get(j)); + nodpage.add(p); + compteurpage++; + page = nodpage.get(nodpage.size()-1); + continue; + } + } + } + + // les sauts manuels hors paragraphe et titre + if(!nodstructure.getNodes().get(j).getNomElt().equals("text:p") && !nodstructure.getNodes().get(j).getNomElt().equals("text:h") ) { + ArrayList lesparagraphes = a.retourneNames(nodstructure.getNodes().get(j).getNodes(), "text:p"); + node nod2 = a.retourneName(lesparagraphes, "text:p", "text:style-name"); + if(nod2!=null) { + node nod3 = a.retourneFirstNodeByNameAttributValue(nodstyle.getNodes(), "style:style", "style:name", nod2.getAttributs().get("text:style-name")); + if(nod3!=null) { + if(nod3.getAttributs().get("style:master-page-name")!=null) { + node p = new node(); + p.setNomElt("page"); + p.getAttributs().put("numero", String.valueOf(compteurpage)); + p.getAttributs().put("type","manuel"); + p.getAttributs().put("index",String.valueOf(j)); + p.getAttributs().put("style:master-page-name",nod3.getAttributs().get("style:master-page-name")); + p.getAttributs().put("style:name",nod3.getAttributs().get("style:name")); + p.getNodes().add(nodstructure.getNodes().get(j)); + node nod4 = a.retourneName(nod3.getNodes(), "style:paragraph-properties","fo:break-before"); + if(nod4!=null) { + if(nod4.getAttributs().get("style:page-number")!=null) p.getAttributs().put("style:page_number", nod4.getAttributs().get("style:page-number")); + } + nodpage.add(p); + compteurpage++; + page = nodpage.get(nodpage.size()-1); + continue; + } + if(a.retourneFirstNodeByNameAttributValue(nod3.getNodes(), "style:paragraph-properties","fo:break-before","page")!=null) { + node p = new node(); + p.setNomElt("page"); + p.getAttributs().put("numero", String.valueOf(compteurpage)); + p.getAttributs().put("type","automatique"); + p.getAttributs().put("index",String.valueOf(j)); + p.getNodes().add(nodstructure.getNodes().get(j)); + nodpage.add(p); + compteurpage++; + page = nodpage.get(nodpage.size()-1); + continue; + } + } + } + } + + // ajoute au node de la page les éléments sauf les paragraphes de texte + page.getNodes().add(nodstructure.getNodes().get(j)); + + + + + } + + + + + // verification que dans la page numero 0 il y a un paragraphe. + // s'il n'y a pas de paragraphe alors ce n'est pas une page et elle est supprimée + // indique le style de la page + // insère les pages vides + // déplace les graphique dans les bonnes pages. + if(nodpage.get(0)!=null) { + boolean pagezerosupprimer = false; + ArrayList noddraw = a.retourneNames(nodpage.get(0), "draw:frame"); //il faut replacer peut être les cadre et image ancrer à la page après numérotation absolue + + //suppresion de la page zéro si inutile + if(!nodpage.get(0).retourneEnfantsByNameExist("text:p") && !nodpage.get(0).retourneEnfantsByNameExist("text:h")) { + nodpage.remove(0); + pagezerosupprimer=true; + } + + + //indiquer le style de chaque page + for(int j = 0 ; j < nodpage.size();j++) { + if(j!=0) { + if(nodpage.get(j).getAttributs().get("type").equals("automatique")) { + if(nodpage.get(j-1).getAttributs().get("style:master-page-name")!=null) { + node nod5 = a.retourneFirstNodeByNameAttributValue(nodstylepage, "style:master-page", "style:name", nodpage.get(j-1).getAttributs().get("style:master-page-name")); + if(nod5.getAttributs().get("style:next-style-name")!=null) { + nodpage.get(j).getAttributs().put("style:master-page-name", nod5.getAttributs().get("style:next-style-name")); + }else { + nodpage.get(j).getAttributs().put("style:master-page-name", nodpage.get(j-1).getAttributs().get("style:master-page-name")); + } + }else { + nodpage.get(j).getAttributs().put("style:master-page-name", "Standard"); //défini une page en style page par défaut + } + } + } + } + + + //insère les pages vides + ArrayList newnodpage = (ArrayList) nodpage.clone(); + int compteurinsertion = 0 ; + for(int j = 0 ; j < nodpage.size();j++) { + if(j!=0) { + String usage1 ="1"; + String usage2 ="2"; + + if(nodpage.get(j).getAttributs().get("style:master-page-name")!=null) { + node nod5 = a.retourneFirstNodeByNameAttributValue(nodstylepage, "style:master-page", "style:name", nodpage.get(j).getAttributs().get("style:master-page-name")); + if(nod5.getAttributs().get("style:page-layout-name")!=null) { + node nod6 = a.retourneFirstNodeByNameAttributValue(nodstylepage, "style:page-layout", "style:name", nod5.getAttributs().get("style:page-layout-name")); + if(nod6.getAttributs().get("style:page-usage")!=null) { + usage1 = nod6.getAttributs().get("style:page-usage"); + nodpage.get(j).getAttributs().put("style:page-usage", usage1); + } + } + } + + + if(nodpage.get(j-1).getAttributs().get("style:master-page-name")!=null) { + node nod5 = a.retourneFirstNodeByNameAttributValue(nodstylepage, "style:master-page", "style:name", nodpage.get(j-1).getAttributs().get("style:master-page-name")); + if(nod5.getAttributs().get("style:page-layout-name")!=null) { + node nod6 = a.retourneFirstNodeByNameAttributValue(nodstylepage, "style:page-layout", "style:name", nod5.getAttributs().get("style:page-layout-name")); + if(nod6.getAttributs().get("style:page-usage")!=null) { + usage2 = nod6.getAttributs().get("style:page-usage"); + } + } + } + + if(j-1==0) usage2="right"; //la première page est toujours à droite. + + //insertion d'un page vide + if(usage1.equals(usage2)) { + node p = new node(); + p.setNomElt("page"); + p.getAttributs().put("vide", "true"); + p.getAttributs().put("style:master-page-name", "page_vide"); + newnodpage.add(j+compteurinsertion,p); + compteurinsertion++; + } + + }else { + if(nodpage.get(j).getAttributs().get("style:master-page-name")!=null) { + node nod5 = a.retourneFirstNodeByNameAttributValue(nodstylepage, "style:master-page", "style:name", nodpage.get(j).getAttributs().get("style:master-page-name")); + if(nod5.getAttributs().get("style:page-layout-name")!=null) { + node nod6 = a.retourneFirstNodeByNameAttributValue(nodstylepage, "style:page-layout", "style:name", nod5.getAttributs().get("style:page-layout-name")); + if(nod6.getAttributs().get("style:page-usage")!=null) { + nodpage.get(j).getAttributs().put("style:page-usage", nod6.getAttributs().get("style:page-usage")); + } + if(j==0) nodpage.get(j).getAttributs().put("style:page-usage", "right"); //la première page est toujours à droite. + } + } + } + + } + + nodpage = (ArrayList) newnodpage.clone(); + + + + // numerotation des pages + int compteurnumeropage = 1 ; + int compteurabsoluepage = 1 ; + for(int j = 0 ; j < nodpage.size();j++) { + if(nodpage.get(j).getAttributs().get("style:page_number")!=null){ + if(!nodpage.get(j).getAttributs().get("style:page_number").equals("auto")) { + compteurnumeropage= Integer.valueOf(nodpage.get(j).getAttributs().get("style:page_number")); + nodpage.get(j).getAttributs().put("numero", String.valueOf(compteurnumeropage)); + nodpage.get(j).getAttributs().put("numeroabsolue", String.valueOf(compteurabsoluepage)); + compteurnumeropage++; + compteurabsoluepage++; + continue; + } + } + nodpage.get(j).getAttributs().put("numero", String.valueOf(compteurnumeropage)); + nodpage.get(j).getAttributs().put("numeroabsolue", String.valueOf(compteurabsoluepage)); + compteurnumeropage++; + compteurabsoluepage++; + + } + + // replacer les cadres et images ancrés dans les bonnes pages de la structure + for(int j = 0 ; j no = nodmeta.getNodes(); + for(int j = 0 ; j < no.size(); j++) { + no.get(j).getAttributs().put("saut", "false"); + no.get(j).getAttributs().put("evaluer", "false"); + no.get(j).getAttributs().put("titre", ""); + no.get(j).getAttributs().put("styletitre", "nostyle"); + no.get(j).getAttributs().put("evalNameNode", "0"); + } + nod.getNodes().add(nodmeta); + } + + + // + //style de page + node nodpage = nod.retourneFirstEnfantsByName("style:page"); + if(nodpage.getNomElt().equals("style:page")) { + nod.getNodes().remove(nodpage); + nodpage.getAttributs().put("evaluer", "false"); + nodpage.getAttributs().put("addmenu", "false"); + nodpage.getAttributs().put("poids", "1"); + nodpage.getAttributs().put("titre", "Les styles de page"); + + nodpage = addAttributsAnalyseWriter(nodpage, "style:master-page"); + nod.getNodes().add(nodpage); + } + + + // + //style de paragraphe + node nodparagraph = nod.retourneFirstEnfantsByName("style:paragraph"); + if(nodparagraph.getNomElt().equals("style:paragraph")) { + nod.getNodes().remove(nodparagraph); + nodparagraph.getAttributs().put("evaluer", "false"); + nodparagraph.getAttributs().put("addmenu", "false"); + nodparagraph.getAttributs().put("poids", "1"); + nodparagraph.getAttributs().put("titre", "Les styles de paragraphe"); + + nodparagraph = addAttributsAnalyseWriter(nodparagraph, "style:style"); + nod.getNodes().add(nodparagraph); + } + + + // + //style de texte + node nodformatage = nod.retourneFirstEnfantsByName("style:formatagedirect"); + if(nodformatage.getNomElt().equals("style:formatagedirect")) { + nod.getNodes().remove(nodformatage); + nodformatage.getAttributs().put("evaluer", "false"); + nodformatage.getAttributs().put("addmenu", "false"); + nodformatage.getAttributs().put("poids", "1"); + nodformatage.getAttributs().put("titre", "Les styles de formatage direct"); + + nodformatage = addAttributsAnalyseWriter(nodformatage, "style:style"); + nod.getNodes().add(nodformatage); + } + + + // + //séquence + node nodsequence = nod.retourneFirstEnfantsByName("sequences"); + if(nodsequence.getNomElt().equals("sequences")) { + nod.getNodes().remove(nodsequence); + nodsequence.getAttributs().put("evaluer", "false"); + nodsequence.getAttributs().put("addmenu", "false"); + nodsequence.getAttributs().put("poids", "1"); + nodsequence.getAttributs().put("titre", "Les variables de séquence"); + + nodsequence = addAttributsAnalyseWriter(nodsequence, "text:sequence-decl"); + nod.getNodes().add(nodsequence); + } + + // + //numérotation des chapitres + node nodnumerotationchapitre = nod.retourneFirstEnfantsByName("numerotationchapitre"); + if(nodnumerotationchapitre.getNomElt().equals("numerotationchapitre")) { + nod.getNodes().remove(nodnumerotationchapitre); + nodnumerotationchapitre.getAttributs().put("evaluer", "false"); + nodnumerotationchapitre.getAttributs().put("addmenu", "false"); + nodnumerotationchapitre.getAttributs().put("poids", "1"); + nodnumerotationchapitre.getAttributs().put("titre", "Numérotation des chapitres"); + + nodnumerotationchapitre = addAttributsAnalyseWriter(nodnumerotationchapitre, "text:outline-level-style"); + nod.getNodes().add(nodnumerotationchapitre); + } + + // + //frame + node nodframe = nod.retourneFirstEnfantsByName("frames"); + if(nodframe.getNomElt().equals("frames")) { + nod.getNodes().remove(nodframe); + nodframe.getAttributs().put("evaluer", "false"); + nodframe.getAttributs().put("addmenu", "false"); + nodframe.getAttributs().put("poids", "1"); + nodframe.getAttributs().put("titre", "Les frames (cadres et images)"); + + nodframe = addAttributsAnalyseWriter(nodframe, "draw:frame"); + nod.getNodes().add(nodframe); + } + + + // + //sections + node nodsection = nod.retourneFirstEnfantsByName("sections"); + if(nodsection.getNomElt().equals("sections")) { + nod.getNodes().remove(nodsection); + nodsection.getAttributs().put("evaluer", "false"); + nodsection.getAttributs().put("addmenu", "false"); + nodsection.getAttributs().put("poids", "1"); + nodsection.getAttributs().put("titre", "Les sections"); + + nodsection = addAttributsAnalyseWriter(nodsection, "text:section"); + nod.getNodes().add(nodsection); + } + + + // + //biblio + node nodbiblio = nod.retourneFirstEnfantsByName("biblio"); + if(nodbiblio.getNomElt().equals("biblio")) { + nod.getNodes().remove(nodbiblio); + nodbiblio.getAttributs().put("evaluer", "false"); + nodbiblio.getAttributs().put("addmenu", "false"); + nodbiblio.getAttributs().put("poids", "1"); + nodbiblio.getAttributs().put("titre", "La bibliographie"); + //nodbiblio.getAttributs().put("styletitre", "H1"); + + nodbiblio = addAttributsAnalyseWriter(nodbiblio, "text:bibliography"); + nod.getNodes().add(nodbiblio); + } + + + // + //table des matières + node nodtable = nod.retourneFirstEnfantsByName("tablematieres"); + if(nodtable.getNomElt().equals("tablematieres")) { + nod.getNodes().remove(nodtable); + nodtable.getAttributs().put("evaluer", "false"); + nodtable.getAttributs().put("addmenu", "false"); + nodtable.getAttributs().put("poids", "1"); + nodtable.getAttributs().put("titre", "Les index tables des matières"); + + nodtable = addAttributsAnalyseWriter(nodtable, "text:table-of-content"); + nod.getNodes().add(nodtable); + } + + + // + //table des illustrations + node nodillustrations = nod.retourneFirstEnfantsByName("tableillustrations"); + if(nodillustrations.getNomElt().equals("tableillustrations")) { + nod.getNodes().remove(nodillustrations); + nodillustrations.getAttributs().put("evaluer", "false"); + nodillustrations.getAttributs().put("addmenu", "false"); + nodillustrations.getAttributs().put("poids", "1"); + nodillustrations.getAttributs().put("titre", "Les index illustrations"); + + nodillustrations = addAttributsAnalyseWriter(nodillustrations, "text:illustration-index"); + nod.getNodes().add(nodillustrations); + } + + + // + //structure document + node nodstructurepage = nod.retourneFirstEnfantsByName("structurepage"); + if(nodstructurepage.getNomElt().equals("structurepage")) { + nod.getNodes().remove(nodstructurepage); + nodstructurepage.getAttributs().put("evaluer", "false"); + nodstructurepage.getAttributs().put("addmenu", "false"); + nodstructurepage.getAttributs().put("poids", "1"); + nodstructurepage.getAttributs().put("titre", "La structure du document"); + + nodstructurepage = addAttributsAnalyseWriter(nodstructurepage, "page"); + nod.getNodes().add(nodstructurepage); + + } + + return nod; + } + + /** + * Chargement du sujet.
+ * Retourne l'ensemble des nodes qui possédent l'attribut evaluer="true". + *
+ * @param a + * @return le node du sujet qui contient les partie à analyser + * @throws IOException + * @throws CloneNotSupportedException + */ + private static node chargementsujet(Run a, String nameSujet) throws CloneNotSupportedException, IOException { + String targetString = ""; + //read file into stream, try-with-resources + + try { + BufferedReader br = new BufferedReader( + new InputStreamReader( + new FileInputStream(a.getPatch() + "/" + nameSujet), "UTF-8")); + + String line; + while ((line = br.readLine()) != null) { + targetString = targetString + line; + } + br.close(); + }catch (Exception e) { + System.out.println(); + System.out.println("** The file \"" + nameSujet + "\" is not in the current directory."); + System.out.println("** The current directory of the application is " + patch); + System.out.println(); + } + + + node LeNodeSujet = new node(); + if(!targetString.isEmpty()) { + // ! Important nettoyage du fichier avant lecture avec cXML + targetString = targetString.replace("\r", ""); + targetString = targetString.replace("\n", ""); + targetString = targetString.replace("\t", ""); + // supprime les espaces multiples au-delà de deux espaces après un guillemets + Pattern p = Pattern.compile(" {2,}"); + targetString = p.matcher(targetString).replaceAll(" "); + + // supprime les espaces entre " et > + p = Pattern.compile("\" {1,}>"); + targetString = p.matcher(targetString).replaceAll("\">"); + + LeNodeSujet = a.XMLContent(targetString); + } + + LeNodeSujet = a.NodesAyantAttributEvaluerTRUEavecComplement(LeNodeSujet); + + + + return LeNodeSujet; + } + + + + /** + * Vérification du node sujet (premier node fichier et des paramètres.
+ *
+ * @param nodSujet + * @return + */ + private static node InitialisationAvantAnalyse(node nodSujet) { + node initSujet = new node(); + initSujet.setNomElt("init"); + + boolean erreur=false; + boolean erreurNomPremierNodeFichier=false; + boolean erreurManqueAttributEvaluerPremierNodeFichier=false; + boolean erreurValeurAttributEvaluerPremierNodeFichier=false; + boolean erreurPasNodesEnfantsAuPremierNodeFichier=false; + boolean erreurPasAttributMetaSujetAuPremierNodeFichier=false; + boolean erreurValeurVideAttributMetaSujetAuPremierNodeFichier=false; + boolean erreurValeurAttributProgressionNonConvertibleEnDouble=false; + boolean erreurValeurAttributNoteFromNonConvertibleEnDouble=false; + + if(!nodSujet.getNomElt().equals("fichier")) { + erreur=true; + erreurNomPremierNodeFichier = true; + } + if(nodSujet.getAttributs().get("evaluer")==null) { + erreur=true; + erreurManqueAttributEvaluerPremierNodeFichier = true; + } + if(!nodSujet.getAttributs().get("evaluer").equals("true")) { + erreur=true; + erreurValeurAttributEvaluerPremierNodeFichier=true; + } + if(nodSujet.getNodes().size()==0) { + erreur=true; + erreurPasNodesEnfantsAuPremierNodeFichier=true; + } + if(nodSujet.getAttributs().get("metaSujet")==null) { + erreur=true; + erreurPasAttributMetaSujetAuPremierNodeFichier=true; + } + if(nodSujet.getAttributs().get("metaSujet")!=null) { + if(nodSujet.getAttributs().get("metaSujet").isEmpty()) { + erreur=true; + erreurValeurVideAttributMetaSujetAuPremierNodeFichier=true; + } + } + if(nodSujet.getAttributs().get("progression")!=null) { + String p = nodSujet.getAttributs().get("progression"); + try { + Double.valueOf(p); + } catch (Exception e) { + erreur=true; + erreurValeurAttributProgressionNonConvertibleEnDouble=true; + } + } + if(nodSujet.getAttributs().get("notefrom")!=null) { + String p = nodSujet.getAttributs().get("notefrom"); + try { + Double.valueOf(p); + } catch (Exception e) { + erreur=true; + erreurValeurAttributNoteFromNonConvertibleEnDouble=true; + } + } + + initSujet.getAttributs().put("erreur",String.valueOf(erreur)); + initSujet.getAttributs().put("erreurNomPremierNodeFichier",String.valueOf(erreurNomPremierNodeFichier)); + initSujet.getAttributs().put("erreurManqueAttributEvaluerPremierNodeFichier",String.valueOf(erreurManqueAttributEvaluerPremierNodeFichier)); + initSujet.getAttributs().put("erreurValeurAttributEvaluerPremierNodeFichier",String.valueOf(erreurValeurAttributEvaluerPremierNodeFichier)); + initSujet.getAttributs().put("erreurPasNodesEnfantsAuPremierNodeFichier",String.valueOf(erreurPasNodesEnfantsAuPremierNodeFichier)); + initSujet.getAttributs().put("erreurPasAttributMetaSujetAuPremierNodeFichier",String.valueOf(erreurPasAttributMetaSujetAuPremierNodeFichier)); + initSujet.getAttributs().put("erreurValeurVideAttributMetaSujetAuPremierNodeFichier",String.valueOf(erreurValeurVideAttributMetaSujetAuPremierNodeFichier)); + initSujet.getAttributs().put("erreurValeurAttributProgressionNonConvertibleEnDouble",String.valueOf(erreurValeurAttributProgressionNonConvertibleEnDouble)); + initSujet.getAttributs().put("erreurValeurAttributNoteFromNonConvertibleEnDouble",String.valueOf(erreurValeurAttributNoteFromNonConvertibleEnDouble)); + + return initSujet; + } + + /** + * Début de l'analyse par comparaison du node étudiant avec le node sujet. + * @param nodStudent, le node étudiant. + * @param nodSujet, le node sujet. + * @param indexStudent, index de l'étudiant + * @param a, objet Run de la class cXML + * @return le node analyse contenant toute l'analyse. + */ + private static node analyse(node nodStudent, node nodSujet, Integer indexStudent, Run a) { + + // initialisation des nodes d'analyse + node erreurs = new node(); + node nodmeta = new node(); + node nodpage = new node(); + node nodparagraph = new node(); + node nodsequence = new node(); + node nodnumerochapitre = new node(); + node nodframes = new node(); + node nodsections = new node(); + node nodbiblio = new node(); + node nodtablematieres = new node(); + node nodtableillustrations = new node(); + node nodstructurepage = new node(); + + // ouverture + node nodouverture = new node(); + nodouverture.setNomElt("ouverture"); + nodouverture.setAttributs(nodSujet.getAttributs()); + nodouverture.getAttributs().put("dossier",a.getLectDossiers().getEC().getListeNomDossier().get(indexStudent)); + nodouverture.getAttributs().put("filename", a.getLectDossiers().getEC().getListeFichierodt().get(indexStudent)); + nodouverture.getAttributs().put("producteur", nodStudent.getAttributs().get("producteur")); + nodouverture.getAttributs().put("dureeEdition", nodStudent.getAttributs().get("dureeEdition")); + nodouverture.getAttributs().put("dateModification", nodStudent.getAttributs().get("dateModification")); + nodouverture.getAttributs().put("patch", a.getPatch()); + if(nodSujet.getAttributs().get("historiquePresent")!=null) nodouverture.getAttributs().put("historiquePresent", nodSujet.getAttributs().get("historiquePresent")); + if(nodSujet.getAttributs().get("controleDateCreation")!=null) nodouverture.getAttributs().put("controleDateCreation", nodSujet.getAttributs().get("controleDateCreation")); + if(nodSujet.getAttributs().get("presenceMetaSujet")!=null) nodouverture.getAttributs().put("presenceMetaSujet", nodSujet.getAttributs().get("presenceMetaSujet")); + if(nodSujet.getAttributs().get("baremeABC")!=null) nodouverture.getAttributs().put("baremeABC", nodSujet.getAttributs().get("baremeABC")); + nodouverture.setClose(true); + + //Body et note (par défaut valeur nulle) + node nodbodyetnotation = new node(); + nodbodyetnotation.setNomElt("bodyetnotation"); + nodbodyetnotation.getAttributs().put("note", "0"); + nodbodyetnotation.getAttributs().put("commentaire", ""); + nodbodyetnotation.getAttributs().put("proportioncorrect", "0"); + nodbodyetnotation.getAttributs().put("baremeABC", "false"); + if(nodSujet.getAttributs().get("baremeABC")!=null) nodbodyetnotation.getAttributs().put("baremeABC", nodSujet.getAttributs().get("baremeABC")); + nodbodyetnotation.setClose(true); + + //Le menu + node nodmenu = new node(); + nodmenu.setNomElt("menu"); + nodmenu = a.retourneNodeMenu(nodSujet, nodmenu, 0, 0); + nodmenu.setClose(true); + + // verification de la métadonnées Sujet + erreurs = retourneNodeErreur(nodStudent, nodSujet, a); + + // verification si au moins une erreur alors l'analyse est terminée + if(Boolean.valueOf(erreurs.getAttributs().get("oneError"))){ + return clotureNodeAnalyse(nodouverture, nodbodyetnotation, nodmenu, erreurs, nodmeta, nodpage, nodparagraph, nodsequence, nodnumerochapitre, nodframes, nodsections, nodbiblio, nodtablematieres, nodtableillustrations, nodstructurepage, nodSujet.getContenu()); + } + + // analyse Meta + if(nodSujet.retourneFirstEnfantsByName("office:meta").getNomElt().equals("office:meta")) { + nodmeta = analyseMeta(nodStudent.retourneFirstEnfantsByName("office:meta"), nodSujet.retourneFirstEnfantsByName("office:meta"), a, nodmenu); + } + + // analyse les pages (nécessaire d'avoir aussi les styles de paragarphes) + if(nodSujet.retourneFirstEnfantsByName("style:page").getNomElt().equals("style:page")) { + if(nodSujet.containElementByName("style:paragraph")) { + nodpage = analysePage(nodStudent.retourneFirstEnfantsByName("style:page"), nodSujet.retourneFirstEnfantsByName("style:page"), a, nodmenu,nodSujet.retourneFirstEnfantsByName("style:paragraph"),nodStudent.retourneFirstEnfantsByName("style:paragraph")); + }else { + nodpage = analysePage(nodStudent.retourneFirstEnfantsByName("style:page"), nodSujet.retourneFirstEnfantsByName("style:page"), a, nodmenu,null,null); + } + } + + + // analyse les paragraphes + if(nodSujet.retourneFirstEnfantsByName("style:paragraph").getNomElt().equals("style:paragraph")) { + nodparagraph = analyseParagraph(nodStudent.retourneFirstEnfantsByName("style:paragraph"), nodSujet.retourneFirstEnfantsByName("style:paragraph"), a, nodmenu); + } + + // analyse les variables de séquence + if(nodSujet.retourneFirstEnfantsByName("sequences").getNomElt().equals("sequences")) { + nodsequence = analyseLesSequences(nodStudent.retourneFirstEnfantsByName("sequences"), nodSujet.retourneFirstEnfantsByName("sequences"), a, nodmenu); + } + + // analyse de la numérotation des chapitres + if(nodSujet.retourneFirstEnfantsByName("numerotationchapitre").getNomElt().equals("numerotationchapitre")) { + nodnumerochapitre = analyseLaNumerotationChapitre(nodStudent.retourneFirstEnfantsByName("numerotationchapitre"), nodSujet.retourneFirstEnfantsByName("numerotationchapitre"), a, nodmenu); + } + + // analyse les frames + if(nodSujet.retourneFirstEnfantsByName("frames").getNomElt().equals("frames")) { + nodframes = analyseLesFrames(nodStudent.retourneFirstEnfantsByName("frames"), nodSujet.retourneFirstEnfantsByName("frames"), a, nodmenu); + } + + // analyse des sections +// if(nodSujet.retourneFirstEnfantsByName("sections").getNomElt().equals("sections")) { +// nodframes = analyseLesFrames(nodStudent.retourneFirstEnfantsByName("sections"), nodSujet.retourneFirstEnfantsByName("sections"), a, nodmenu); +// } + + // analyse la bibliographie de LibreOffice + if(nodSujet.retourneFirstEnfantsByName("biblio").getNomElt().equals("biblio")) { + nodbiblio = analyseLaBiblio(nodStudent.retourneFirstEnfantsByName("biblio"), nodSujet.retourneFirstEnfantsByName("biblio"), a, nodmenu); + } + + // analyse des tables des matières + if(nodSujet.retourneFirstEnfantsByName("tablematieres").getNomElt().equals("tablematieres")) { + nodtablematieres = analyseLesTablesMatieres(nodStudent.retourneFirstEnfantsByName("tablematieres"), nodSujet.retourneFirstEnfantsByName("tablematieres"), a, nodmenu); + } + + // analyse des tables illustrations + if(nodSujet.retourneFirstEnfantsByName("tableillustrations").getNomElt().equals("tableillustrations")) { + nodtableillustrations = analyseLesTablesIllustrations(nodStudent.retourneFirstEnfantsByName("tableillustrations"), nodSujet.retourneFirstEnfantsByName("tableillustrations"), a, nodmenu); + } + + // analyse la structure du document + if(nodSujet.retourneFirstEnfantsByName("structurepage").getNomElt().equals("structurepage")) { + node nodSujetParagraphs = null; + if(nodSujet.retourneFirstEnfantsByName("style:paragraph").getNomElt().equals("style:paragraph")) nodSujetParagraphs = nodSujet.retourneFirstEnfantsByName("style:paragraph"); + node nodStudentParagraphs = nodStudent.retourneFirstEnfantsByName("style:paragraph"); + nodstructurepage = analyseStructurePage(nodStudent.retourneFirstEnfantsByName("structurepage"), nodSujet.retourneFirstEnfantsByName("structurepage"), a, nodmenu,nodSujetParagraphs, nodStudentParagraphs ); + } + + + // retourne le node analyse assemblé et calcul de la note avec le barème + return clotureNodeAnalyse(nodouverture, nodbodyetnotation, nodmenu, erreurs, nodmeta, nodpage, nodparagraph, nodsequence, nodnumerochapitre, nodframes, nodsections, nodbiblio, nodtablematieres, nodtableillustrations, nodstructurepage,nodSujet.getContenu()); + + + } + + + /** + *
Les erreurs dans le fichier étudiant : erreur de métadonnées Sujet, date de création pour identifier le fichier à analyser. + *
Il y a une erreur si pas d'historique de modification dans le fichier de l'étudiant. + *
Il y a une erreur si le premier auteur ne correspond pas. + *
Les erreurs sont dans les attributs du node Erreurs. + *
oneError si VRAI, il y a au moins une erreur. + *
manqueMetaSujet si VRAI, il n'y a pas de méta données Sujet. + *
manqueValeurMetaSujet si VRAI, la valeur de la méta données Sujet n'est pas la bonne. + *
manqueCreationDate si VRAI, il n'y a pas de méta données creationDate. + *
manqueValeurCreationDate si VRAI, la date de la méta données creationDate n'est pas la bonne. + *
manqueHistorique si VRAI, il n'y a pas d'historique des modifications.
+ *
manqueInitialCreator si VRAI, il n'y a pas de premier auteur ou qu'il ne correspond pas.
+ * @param nodStudent : node de l'étudiants. + * @param nodSujet : node du sujet. + * @param a : objet Run de cXML. + * @return retourn le node erreurs. + */ + private static node retourneNodeErreur(node nodStudent, node nodSujet, Run a) { + node erreurs = new node(); + erreurs.setNomElt("erreurs"); + boolean manqueMetaSujet = false; + boolean manqueValeurMetaSujet = false; + boolean manqueCreationDate = false; + boolean manqueValeurCreationDate = false; + boolean manqueHistorique = false; + boolean manqueInitialCreator = false; + + node b = null; + + if(nodSujet.getAttributs().get("presenceMetaSujet")!=null) { + if(nodSujet.getAttributs().get("presenceMetaSujet").equals("true")) { + b = a.retourneFirstNodeByNameAttributValue(nodStudent, "meta:user-defined", "meta:name", "Sujet"); + if(b==null) { + manqueMetaSujet=true; + }else { + if(!nodSujet.getAttributs().get("metaSujet").equals(b.getContenu())) { + manqueValeurMetaSujet=true; + } + } + }else { + + } + }else { + b = a.retourneFirstNodeByNameAttributValue(nodStudent, "meta:user-defined", "meta:name", "Sujet"); + if(b==null) { + manqueMetaSujet=true; + }else { + if(!nodSujet.getAttributs().get("metaSujet").equals(b.getContenu())) { + manqueValeurMetaSujet=true; + } + } + } + + + b = nodStudent.retourneFirstEnfantsByName("meta:creation-date"); + + if(!b.getNomElt().equals("meta:creation-date")) { + manqueValeurCreationDate=true; + } + + if(nodSujet.getAttributs().get("creationDate")!=null) { + if(!(b.getContenu().contains(nodSujet.getAttributs().get("creationDate")))) { //nodSujet.getAttributs().get("creationDate").contains(b.getContenu()) + manqueValeurCreationDate = true; + } + } + + if(nodSujet.getAttributs().get("controleDateCreation")!=null) if(nodSujet.getAttributs().get("controleDateCreation").equals("false")) { + manqueValeurCreationDate = false; + } + + if(nodSujet.getAttributs().get("controle_Initial_Creator")!=null) { + if(nodSujet.getAttributs().get("controle_Initial_Creator").equalsIgnoreCase("true")) { + b = nodStudent.retourneFirstEnfantsByName("meta:initial-creator"); + if(b.getNomElt().equals("meta:initial-creator")) { + if(nodSujet.getAttributs().get("Initial_Creator")!=null) { + if( !b.getContenu().equals(nodSujet.getAttributs().get("Initial_Creator"))) { + manqueInitialCreator = true; + } + }else { + System.out.println("ERROR. There is no Initial_Creator."); + } + }else { + manqueInitialCreator = true; + } + } + } + + + b = nodStudent.retourneFirstEnfantsByName("historique"); + if(b.getNomElt().equals("historique")) { + if(Integer.valueOf(b.getAttributs().get("nbrModif"))<1) { + manqueHistorique =true; + } + } + + + erreurs.getAttributs().put("manqueMetaSujet", String.valueOf(manqueMetaSujet)); + erreurs.getAttributs().put("manqueValeurMetaSujet", String.valueOf(manqueValeurMetaSujet)); + erreurs.getAttributs().put("manqueCreationDate", String.valueOf(manqueCreationDate)); + erreurs.getAttributs().put("manqueValeurCreationDate", String.valueOf(manqueValeurCreationDate)); + erreurs.getAttributs().put("manqueInitialCreator", String.valueOf(manqueInitialCreator)); + + if(nodSujet.getAttributs().get("historiquePresent")!=null) { + if(nodSujet.getAttributs().get("historiquePresent").equalsIgnoreCase("true")) { + if(manqueHistorique) { + erreurs.getAttributs().put("manqueHistorique", "true"); + }else { + erreurs.getAttributs().put("manqueHistorique", "false"); + } + }else { + erreurs.getAttributs().put("manqueHistorique", "false"); + manqueHistorique = false; + } + }else { + erreurs.getAttributs().put("manqueHistorique", "false"); + manqueHistorique = false; + } + + + + + if( manqueMetaSujet == false && manqueValeurMetaSujet == false && manqueCreationDate == false && manqueValeurCreationDate == false + && manqueHistorique == false && manqueInitialCreator == false) { + erreurs.getAttributs().put("oneError", "false"); + }else { + erreurs.getAttributs().put("oneError", "true"); + } + + + + erreurs.setClose(true); + + return erreurs; + } + + + /** + * Assemblage du node annalyse à partir des différents nodes de l'analyse.
+ *
+ * @param nodouverture + * @param nodbodyetnotation + * @param nodmenu + * @param erreurs + * @param nodmeta + * @param nodpage + * @param nodparagraph + * @param nodsequence + * @param nodnumerochapitre + * @param nodframes + * @param nodsections + * @param nodbiblio + * @param nodtablematieres + * @param nodtableillustrations + * @param nodstructurepage + * @return + */ + private static node clotureNodeAnalyse(node nodouverture, node nodbodyetnotation, node nodmenu, node erreurs, node nodmeta, node nodpage, + node nodparagraph, node nodsequence, node nodnumerochapitre, node nodframes, node nodsections, node nodbiblio, node nodtablematieres, + node nodtableillustrations, node nodstructurepage, String texteCommentaire) { + + node nodanalyse = new node(); + + //recalcul les points pour les placer dans le node nodbodyetnotation + double notefrom = 20; // valeur par défaut + double progression = 1; // valeur par défaut + boolean baremeABC = false; + if(nodouverture!=null) if(nodouverture.isClose()) { + if(nodouverture.getAttributs().get("notefrom")!=null) { + try { + notefrom = Math.abs(Double.valueOf(nodouverture.getAttributs().get("notefrom"))); + }catch (Exception e) { + System.out.println("The \"noteFrom\" attribute of the analyze file cannot be converted to a \"double\"."); + System.out.println("Value of notefrom = 20."); + } + } + if(nodouverture.getAttributs().get("progression")!=null) { + try { + progression = Math.abs(Double.valueOf(nodouverture.getAttributs().get("progression"))); + }catch (Exception e) { + System.out.println("The \"progression\" attribute of the analyze file cannot be converted to \"double\"."); + System.out.println("Value of progression = 1."); + } + } + if(nodouverture.getAttributs().get("baremeABC")!=null) { + try { + baremeABC = Boolean.valueOf(nodouverture.getAttributs().get("baremeABC")); + }catch (Exception e) { + System.out.println("The \"baremeABC\" attribute of the analyze file cannot be converted to \"boolean\"."); + System.out.println("Value of baremeABC = false."); + } + } + } + + + + + double pointmeta = 0; double pointmetatotal = 0 ; double poidsmeta = 0; + if(nodmeta!=null) if(nodmeta.isClose()) { + if(nodmeta.getAttributs().get("pointgagner")!=null) pointmeta = Double.valueOf(nodmeta.getAttributs().get("pointgagner")); + if(nodmeta.getAttributs().get("pointtotal")!=null) pointmetatotal = Double.valueOf(nodmeta.getAttributs().get("pointtotal")); + if(nodmeta.getAttributs().get("poids")!=null) try{poidsmeta = Math.abs(Double.valueOf(nodmeta.getAttributs().get("poids")));}catch (Exception e) { }; + } + double pointpage = 0; double pointpagetotal = 0 ; double poidspage = 0; + if(nodpage!=null) if(nodpage.isClose()) { + if(nodpage.getAttributs().get("pointgagner")!=null) pointpage = Double.valueOf(nodpage.getAttributs().get("pointgagner")); + if(nodpage.getAttributs().get("pointtotal")!=null) pointpagetotal = Double.valueOf(nodpage.getAttributs().get("pointtotal")); + if(nodpage.getAttributs().get("poids")!=null) try{poidspage = Math.abs(Double.valueOf(nodpage.getAttributs().get("poids")));}catch (Exception e) { }; + } + double pointparagraph = 0; double pointparagraphtotal = 0 ; double poidsparagraph = 0; + if(nodparagraph!=null) if(nodparagraph.isClose()) { + if(nodparagraph.getAttributs().get("pointgagner")!=null) pointparagraph = Double.valueOf(nodparagraph.getAttributs().get("pointgagner")); + if(nodparagraph.getAttributs().get("pointtotal")!=null) pointparagraphtotal = Double.valueOf(nodparagraph.getAttributs().get("pointtotal")); + if(nodparagraph.getAttributs().get("poids")!=null) try{Math.abs(poidsparagraph = Double.valueOf(nodparagraph.getAttributs().get("poids")));}catch (Exception e) { }; + } + double pointsequence = 0; double pointsequencetotal = 0 ; double poidssequence = 0; + if(nodsequence!=null) if(nodsequence.isClose()) { + if(nodsequence.getAttributs().get("pointgagner")!=null) pointsequence = Double.valueOf(nodsequence.getAttributs().get("pointgagner")); + if(nodsequence.getAttributs().get("pointtotal")!=null) pointsequencetotal = Double.valueOf(nodsequence.getAttributs().get("pointtotal")); + if(nodsequence.getAttributs().get("poids")!=null) try{poidssequence = Math.abs(Double.valueOf(nodsequence.getAttributs().get("poids")));}catch (Exception e) { }; + } + double pointnumerotation = 0; double pointnumerotationtotal = 0 ; double poidsnumerotation = 0; + if(nodnumerochapitre!=null) if(nodnumerochapitre.isClose()) { + if(nodnumerochapitre.getAttributs().get("pointgagner")!=null) pointnumerotation = Double.valueOf(nodnumerochapitre.getAttributs().get("pointgagner")); + if(nodnumerochapitre.getAttributs().get("pointtotal")!=null) pointnumerotationtotal = Double.valueOf(nodnumerochapitre.getAttributs().get("pointtotal")); + if(nodnumerochapitre.getAttributs().get("poids")!=null) try{poidsnumerotation = Math.abs(Double.valueOf(nodnumerochapitre.getAttributs().get("poids")));}catch (Exception e) { }; + } + double pointframe = 0; double pointframetotal = 0 ; double poidsframe = 0; + if(nodframes!=null) if(nodframes.isClose()) { + if(nodframes.getAttributs().get("pointgagner")!=null) pointframe = Double.valueOf(nodframes.getAttributs().get("pointgagner")); + if(nodframes.getAttributs().get("pointtotal")!=null) pointframetotal = Double.valueOf(nodframes.getAttributs().get("pointtotal")); + if(nodframes.getAttributs().get("poids")!=null) try{poidsframe = Math.abs(Double.valueOf(nodframes.getAttributs().get("poids")));}catch (Exception e) { }; + } + double pointbiblio = 0; double pointbibliototal = 0 ; double poidsbiblio = 0; + if(nodbiblio!=null) if(nodbiblio.isClose()) { + if(nodbiblio.getAttributs().get("pointgagner")!=null) pointbiblio = Double.valueOf(nodbiblio.getAttributs().get("pointgagner")); + if(nodbiblio.getAttributs().get("pointtotal")!=null) pointbibliototal = Double.valueOf(nodbiblio.getAttributs().get("pointtotal")); + if(nodbiblio.getAttributs().get("poids")!=null) try{poidsbiblio = Math.abs(Double.valueOf(nodbiblio.getAttributs().get("poids")));}catch (Exception e) { }; + } + double pointtablematieres = 0; double pointtablematierestotal = 0 ; double poidstablematieres = 0; + if(nodtablematieres!=null) if(nodtablematieres.isClose()) { + if(nodtablematieres.getAttributs().get("pointgagner")!=null) pointtablematieres = Double.valueOf(nodtablematieres.getAttributs().get("pointgagner")); + if(nodtablematieres.getAttributs().get("pointtotal")!=null) pointtablematierestotal = Double.valueOf(nodtablematieres.getAttributs().get("pointtotal")); + if(nodtablematieres.getAttributs().get("poids")!=null) try{poidstablematieres = Math.abs(Double.valueOf(nodtablematieres.getAttributs().get("poids")));}catch (Exception e) { }; + } + double pointtableillustration = 0; double pointtableillustrationtotal = 0 ; double poidstableillustration = 0; + if(nodtableillustrations!=null) if(nodtableillustrations.isClose()) { + if(nodtableillustrations.getAttributs().get("pointgagner")!=null) pointtableillustration = Double.valueOf(nodtableillustrations.getAttributs().get("pointgagner")); + if(nodtableillustrations.getAttributs().get("pointtotal")!=null) pointtableillustrationtotal = Double.valueOf(nodtableillustrations.getAttributs().get("pointtotal")); + if(nodtableillustrations.getAttributs().get("poids")!=null) try{poidstableillustration = Math.abs(Double.valueOf(nodtableillustrations.getAttributs().get("poids")));}catch (Exception e) { }; + } + double pointstructure = 0; double pointstructuretotal = 0 ; double poidsstructure = 0; + if(nodstructurepage!=null) if(nodstructurepage.isClose()) { + if(nodstructurepage.getAttributs().get("pointgagner")!=null) pointstructure = Double.valueOf(nodstructurepage.getAttributs().get("pointgagner")); + if(nodstructurepage.getAttributs().get("pointtotal")!=null) pointstructuretotal = Double.valueOf(nodstructurepage.getAttributs().get("pointtotal")); + if(nodstructurepage.getAttributs().get("poids")!=null) try{poidsstructure = Math.abs(Double.valueOf(nodstructurepage.getAttributs().get("poids")));}catch (Exception e) { }; + } + double pointsections = 0; double pointsectionstotal = 0 ; double poidssections = 0; + if(nodsections!=null) if(nodsections.isClose()) { + if(nodsections.getAttributs().get("pointgagner")!=null) pointsections = Double.valueOf(nodsections.getAttributs().get("pointgagner")); + if(nodsections.getAttributs().get("pointtotal")!=null) pointsectionstotal = Double.valueOf(nodsections.getAttributs().get("pointtotal")); + if(nodsections.getAttributs().get("poids")!=null) try{poidssections = Math.abs(Double.valueOf(nodsections.getAttributs().get("poids")));}catch (Exception e) { }; + } + double proportionCorrect = 0 ; + double poidsTotal = 0; + double pointsTotal = 0; + double pointgagner = 0; + double note = 0 ; + + + + proportionCorrect = (poidsmeta*pointmeta + poidspage*pointpage + poidsparagraph*pointparagraph + poidssequence*pointsequence + poidsnumerotation*pointnumerotation + poidsframe*pointframe + poidsbiblio*pointbiblio + poidstablematieres*pointtablematieres + poidstableillustration*pointtableillustration + poidsstructure*pointstructure + poidssections*pointsections) + / (poidsmeta*pointmetatotal + poidspage*pointpagetotal + poidsparagraph*pointparagraphtotal + poidssequence*pointsequencetotal + poidsnumerotation*pointnumerotationtotal + poidsframe*pointframetotal + poidsbiblio*pointbibliototal + poidstablematieres*pointtablematierestotal + poidstableillustration*pointtableillustrationtotal + poidsstructure*pointstructuretotal + poidssections*pointsectionstotal); + + poidsTotal = poidsmeta + poidspage + poidsparagraph + poidssequence + poidsnumerotation + poidsframe + poidsbiblio + poidstablematieres + poidstableillustration + poidsstructure + poidssections; + pointsTotal = pointmetatotal + pointpagetotal + pointparagraphtotal + pointsequencetotal + pointnumerotationtotal + pointframetotal + pointbibliototal + pointtablematierestotal + pointtableillustrationtotal + pointstructuretotal + pointsectionstotal; + pointgagner = pointmeta + pointpage + pointparagraph + pointsequence + pointnumerotation + pointframe + pointbiblio + pointtablematieres + pointtableillustration + pointstructure + pointsections; + note = Math.pow(proportionCorrect, progression)*notefrom; + + DecimalFormat df = new DecimalFormat("###.##"); + + + nodbodyetnotation.getAttributs().put("proportioncorrect", df.format(proportionCorrect*100) + "%"); + nodbodyetnotation.getAttributs().put("note", df.format(note)); + nodbodyetnotation.getAttributs().put("pointstotal", String.valueOf(pointsTotal)); + nodbodyetnotation.getAttributs().put("poidstotal", String.valueOf(poidsTotal)); + nodbodyetnotation.getAttributs().put("pointgagner", String.valueOf(pointgagner)); + + if(Boolean.valueOf(erreurs.getAttributs().get("oneError"))) { + nodbodyetnotation.getAttributs().put("proportioncorrect", "0%"); + nodbodyetnotation.getAttributs().put("note", "0.00"); + proportionCorrect = 0.00; + } + + // si bareme ABC (5 intervalles A, B, C, D, E de 20%) + if(baremeABC) { + double intervalle1 = Math.pow(0.2, 1/progression) ; + double intervalle2 = Math.pow(0.4, 1/progression) ; + double intervalle3 = Math.pow(0.6, 1/progression) ; + double intervalle4 = Math.pow(0.8, 1/progression) ; + + nodbodyetnotation.getAttributs().put("BorneE", String.valueOf(intervalle1)); + nodbodyetnotation.getAttributs().put("BorneD", String.valueOf(intervalle2)); + nodbodyetnotation.getAttributs().put("BorneC", String.valueOf(intervalle3)); + nodbodyetnotation.getAttributs().put("BorneB", String.valueOf(intervalle4)); + nodbodyetnotation.getAttributs().put("BorneA", "1.00"); + + if(proportionCorrect=intervalle1 && proportionCorrect=intervalle2 && proportionCorrect=intervalle3 && proportionCorrect=intervalle4) nodbodyetnotation.getAttributs().put("noteABC", "A"); + } + + nodanalyse.ajouteEnfant(nodouverture); + nodanalyse.ajouteEnfant(nodbodyetnotation); + nodanalyse.ajouteEnfant(nodmenu); + nodanalyse.ajouteEnfant(erreurs); + + nodanalyse.ajouteEnfant(nodmeta); + nodanalyse.ajouteEnfant(nodpage); + nodanalyse.ajouteEnfant(nodparagraph); + nodanalyse.ajouteEnfant(nodsequence); + nodanalyse.ajouteEnfant(nodnumerochapitre); + nodanalyse.ajouteEnfant(nodframes); + nodanalyse.ajouteEnfant(nodsections); + nodanalyse.ajouteEnfant(nodbiblio); + nodanalyse.ajouteEnfant(nodtablematieres); + nodanalyse.ajouteEnfant(nodtableillustrations); + nodanalyse.ajouteEnfant(nodstructurepage); + + node nodfermeturebodyHTML = new node(); + nodfermeturebodyHTML.setNomElt("fermeture"); + nodfermeturebodyHTML.setClose(true); + + nodanalyse.getNodes().add(nodfermeturebodyHTML); + + nodanalyse.setNomElt("analyse"); + nodanalyse.setContenu(texteCommentaire); + nodanalyse.setClose(true); + + return nodanalyse; + } + + + /** + * Analyse du node office:meta. + * @param nodStudentMeta + * @param nodSujetMeta + * @param a + * @param nodmenu + * @return + */ + private static node analyseMeta(node nodStudentMeta, node nodSujetMeta, Run a, node nodmenu) { + node nodmeta = new node(); + nodmeta.setNomElt("meta"); + nodmeta.setAttributs(nodSujetMeta.getAttributs()); + + //ajoute l'identifiant pour le menu + if(a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "office:meta")!=null) { + nodmeta.getAttributs().put("id", a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "office:meta").getAttributs().get("id")); + } + + //Applatir le node sujetMeta + ArrayList sujet = a.Applatir(nodSujetMeta.getNodes(), new ArrayList()); + + //initialise les points + outils.initiliseLesPoints(); + + + for(int i = 0 ; i < sujet.size(); i++) { + + String namenode = sujet.get(i).getNomElt(); + + // parcours les attributs du node "meta:user-defined" + if(namenode.equals("meta:user-defined")) { + Enumeration key = sujet.get(i).getAttributs().keys(); + while(key.hasMoreElements()) { + String k = key.nextElement(); + + if(sujet.get(i).getAttributs().get(k).contains("‽")){ + + // PARTIE AVANT - CETTE PARTIE DONNER SATISFACTION +// boolean trouvelebonnode =false; +// +// ArrayList nod = a.retourneNames(nodStudentMeta, namenode); +// for(int j = 0 ; j < nod.size(); j ++) { +// String Tst = outils.Compare(nod.get(j).getAttributs().get(k), sujet.get(i).getAttributs().get(k)); +// if(Tst.contains("Correct")) { +// trouvelebonnode=true; +// node item = new node("ana:meta", Tst, outils.withoutPoint(sujet.get(i).getAttributs().get(k)), nod.get(j).getAttributs().get(k), sujet.get(i).getAttributs().get(k), 1, outils.getPointEnJeu(),namenode); +// nodmeta.getNodes().add(item); +// break; +// }else { +// outils.decrementPointEnJeuDuTotal(); +// } +// } +// +// if(!trouvelebonnode) { +// String Tst = outils.Compare("null", sujet.get(i).getAttributs().get(k)); +// node item = new node("ana:meta", Tst, outils.withoutPoint(sujet.get(i).getAttributs().get(k)), "null", sujet.get(i).getAttributs().get(k), 2, outils.getPointEnJeu(), namenode); +// nodmeta.getNodes().add(item); +// } + + + String valueOfAttribut = sujet.get(i).getAttributs().get(k); + + node nod2 = a.retourneFirstNodeByNameAttributContainsValueNetTexte(nodStudentMeta, namenode,k,outils.withoutCodeAndPointPourRechercheContenuExact(valueOfAttribut)); + nodmeta = analyseLesAttributEtContenuDuNode(nod2, sujet.get(i), nodmeta, "ana:meta", namenode); + } + } + + + }else { + + // PARTIE AVANT - CETTE PARTIE DONNER SATISFACTION +// Enumeration key = sujet.get(i).getAttributs().keys(); +// while(key.hasMoreElements()) { +// String k = key.nextElement(); +// if( sujet.get(i).getAttributs().get(k).contains("‽")){ +// String valueAttributStudent = nodStudentMeta.retourneFirstEnfantsByName(namenode).getAttributs().get(k); +// String valueAttributSujet = sujet.get(i).getAttributs().get(k); +// node item =retourneNoteAvecResultatsAnalyse("ana:meta", k, valueAttributStudent, valueAttributSujet,namenode); +// nodmeta.getNodes().add(item); +// } +// } + + ArrayList NStudent = a.retourneNames(nodStudentMeta, namenode); + + if(NStudent!=null) { + if(!NStudent.isEmpty()) { + nodmeta = analyseLesAttributEtContenuDuNode(NStudent.get(0), sujet.get(i), nodmeta, "ana:meta", namenode); + }else { + nodmeta = analyseLesAttributEtContenuDuNode(null, sujet.get(i), nodmeta, "ana:meta", namenode); + } + }else { + nodmeta = analyseLesAttributEtContenuDuNode(null, sujet.get(i), nodmeta, "ana:meta", namenode); + } + + + + + } + + // PARTIE AVANT - CETTE PARTIE DONNER SATISFACTION + // parcours le contenu autre que "meta:user-defined" +// if(sujet.get(i).getContenu().contains("‽") && sujet.get(i).getAttributs().get("meta:user-defined")==null) { +// String contentStudent = nodStudentMeta.retourneFirstEnfantsByName(namenode).getContenu(); +// String contentSujet = sujet.get(i).getContenu(); +// +// node item =retourneNoteAvecResultatsAnalyse("ana:meta", "texte", contentStudent, contentSujet,namenode); +// +// nodmeta.getNodes().add(item); +// +// } + + + + + } + nodmeta.getAttributs().put("pointgagner",String.valueOf(outils.getPointsClass())); + nodmeta.getAttributs().put("pointtotal",String.valueOf(outils.getPointTotal())); + nodmeta.getAttributs().put("proportioncorrect",String.valueOf(outils.getProportionCorrect())); + nodmeta.setClose(true); + return nodmeta; + } + + /** + * Analyse du node style:page. + * @param nodStudentPage + * @param nodSujetPage + * @param a + * @param nodmenu + * @return + */ + private static node analysePage(node nodStudentPage, node nodSujetPage, Run a, node nodmenu, node nodSujetParagraphes, node nodStudentParagraphes) { + node nodpages = new node(); + nodpages.setNomElt("pages"); + nodpages.setAttributs(nodSujetPage.getAttributs()); + + //ajoute l'identifiant pour le menu + if(a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "style:page")!=null) { + nodpages.getAttributs().put("id", a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "style:page").getAttributs().get("id")); + } + + //initialise les points + outils.initiliseLesPoints(); + + for(int i = 0 ; i < nodSujetPage.getNodes().size(); i++) { //niveau 1 + if(nodSujetPage.getNodes().get(i).getNomElt().equals("style:master-page")) { + int pointDebut = outils.getPointsClass(); + int pointTotalDebut = outils.getPointTotal(); + String nomDeLaPage = outils.withoutCodeAndPoint(nodSujetPage.getNodes().get(i).getAttributs().get("style:name")); + node page = new node(); + page.setNomElt("page"); + page.getAttributs().put("name", nomDeLaPage); + if(nodSujetPage.getNodes().get(i).getAttributs().get("titre")!=null) page.getAttributs().put("titre", nodSujetPage.getNodes().get(i).getAttributs().get("titre")); + + node pageStudent = a.retourneFirstNodeByNameAttributValue(nodStudentPage, "style:master-page", "style:name", nomDeLaPage); + node pageSujet = nodSujetPage.getNodes().get(i); + + // analyse les attributs du node style:master-page + page = analyseLesAttributEtContenuDuNode(pageStudent, pageSujet, page, "ana:page",pageSujet.getNomElt()); + + // les enfants du premier niveau du node + for(int j = 0 ; j < pageSujet.getNodes().size();j++ ) { //niveau 2 + + node nodSujet = pageSujet.getNodes().get(j); + String nameNode = nodSujet.getNomElt(); + page = addNodeSautTitre(nodSujet, page); // ajoute des saut de page s'il y a des sauts avec des titres + + //recherche le node correspondant de l'étudiant + node nodStudent = null; + if(pageStudent!=null) if(pageStudent.retourneFirstEnfantsByName(nameNode).getNomElt().equals(nameNode)) { + nodStudent = pageStudent.retourneFirstEnfantsByName(nameNode); + } + + //analyse le nom du node +// if(nodSujet.getAttributs().get("evalNameNode")!=null) { +// String point = nodSujet.getAttributs().get("evalNameNode"); +// page =analyseNameNode(page,nodStudent,nodSujet.getNomElt(),point, nodSujet.getNomElt()); +// } + + + // analyse attribut et contenu des enfants du premier niveau + page = analyseLesAttributEtContenuDuNode(nodStudent, nodSujet, page, "ana:page",pageSujet.getNodes().get(j).getNomElt()); + + + for(int k = 0 ; k < nodSujet.getNodes().size();k++) { //niveau 3 + // C'est à ce niveau que se trouve les nodes text:p dans les entêtes et les pieds de page + + node nod2Sujet = nodSujet.getNodes().get(k); + String nameNode2 = nod2Sujet.getNomElt(); + page = addNodeSautTitre(nod2Sujet, page); // ajoute des sauts s'il y a des sauts avec des titres + + + //recherche le node correspondant de l'étudiant + node nod2Student = null; + if(nodStudent!=null) if(nodStudent.retourneFirstEnfantsByName(nameNode2).getNomElt().equals(nameNode2)) { + //nod2Student = nodStudent.retourneFirstEnfantsByName(nameNode2); + nod2Student = rechercheLeNodeEnCascade(nameNode2,nod2Sujet,null,null,nodStudent,a); + } + + + //analyse style du paragraphe + if(nod2Sujet.getAttributs().get("analyseStyle")!=null) { + if(nod2Sujet.getAttributs().get("analyseStyle").equals("true") && nod2Sujet.getNomElt().equals("text:p")) { + page = analyseStyle(page, nod2Sujet, nod2Student, nodSujetParagraphes, nodStudentParagraphes); + } + } + + + // analyse attribut et contenu des enfants du second niveau + page = analyseLesAttributEtContenuDuNode(nod2Student, nod2Sujet, page, "ana:page",nodSujet.getNodes().get(k).getNomElt() ); + + + for(int l = 0 ; l < nod2Sujet.getNodes().size();l++) { //niveau 4 + //C'est à ce niveau qi'il peut y avoir des nodes text:tab ou text:span + + node nod3Sujet = nod2Sujet.getNodes().get(l); + String nameNode3 = nod3Sujet.getNomElt(); + //page = addNodeSautTitre(nod3Sujet, page); + + //recherche du node correspondant de l'étudiant + node nod3Student = null; + if(nod2Student!=null) if(nod2Student.retourneFirstEnfantsByName(nameNode3).getNomElt().equals(nameNode3)) { + nod3Student = rechercheLeNodeEnCascade(nameNode3,nod3Sujet,null,nodStudent,nod2Student,a); + } + + + // analyse attribut et contenu des enfants du troisième niveau + page = analyseLesAttributEtContenuDuNode(nod3Student, nod3Sujet, page, "ana:page", nod2Sujet.getNodes().get(l).getNomElt()); + + + for(int m = 0 ; m < nod3Sujet.getNodes().size();m++) { //niveau 5 + node nod4Sujet = nod3Sujet.getNodes().get(m); + String nameNode4 = nod4Sujet.getNomElt(); + + //recherche du node correspondant de l'étudiant + node nod4Student = null; + if(nod3Student!=null) if(nod3Student.retourneFirstEnfantsByName(nameNode4).getNomElt().equals(nameNode4)) { + nod4Student = rechercheLeNodeEnCascade(nameNode4,nod4Sujet,nodStudent,nod2Student,nod3Student,a); + } + + // analyse attribut et contenu des enfants du troisième niveau + page = analyseLesAttributEtContenuDuNode(nod4Student, nod4Sujet, page, "ana:page", nod3Sujet.getNodes().get(m).getNomElt()); + + } + + + + } + + } + + } + + page.getAttributs().put("point", String.valueOf(outils.getPointsClass()-pointDebut)); + page.getAttributs().put("pointTotal", String.valueOf(outils.getPointTotal()-pointTotalDebut)); + nodpages.getNodes().add(page); + + + } + } + + nodpages.getAttributs().put("pointgagner",String.valueOf(outils.getPointsClass())); + nodpages.getAttributs().put("pointtotal",String.valueOf(outils.getPointTotal())); + nodpages.getAttributs().put("proportioncorrect",String.valueOf(outils.getProportionCorrect())); + nodpages.setClose(true); + return nodpages; + } + + /** + * Analyse du node style:paragraph. + * @param nodStudentParagraph + * @param nodSujetParagraph + * @param a + * @param nodmenu + * @return + */ + private static node analyseParagraph(node nodStudentParagraph, node nodSujetParagraph, Run a, node nodmenu) { + node nodparagraphs = new node(); + nodparagraphs.setNomElt("paragraphs"); + nodparagraphs.setAttributs(nodSujetParagraph.getAttributs()); + + //ajoute l'identifiant pour le menu + if(a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "style:paragraph")!=null) { + nodparagraphs.getAttributs().put("id", a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "style:paragraph").getAttributs().get("id")); + } + + //initialise les points + outils.initiliseLesPoints(); + + for(int i = 0 ; i < nodSujetParagraph.getNodes().size(); i++) { + if(nodSujetParagraph.getNodes().get(i).getNomElt().equals("style:style")) { + int pointDebut = outils.getPointsClass(); + int pointTotalDebut = outils.getPointTotal(); + node paragraphSujet = nodSujetParagraph.getNodes().get(i); + String nomDuParagraph = outils.withoutCodeAndPoint(paragraphSujet.getAttributs().get("style:name")); + node paragraph = new node(); + paragraph.setNomElt("paragraph"); + paragraph.getAttributs().put("name", nomDuParagraph); + if(paragraphSujet.getAttributs().get("titre")!=null) paragraph.getAttributs().put("titre", nodSujetParagraph.getNodes().get(i).getAttributs().get("titre")); + + // trouve le node de l'étudiant + node paragraphStudent = a.retourneFirstNodeByNameAttributValue(nodStudentParagraph, "style:style", "style:name", nomDuParagraph); + + // ajoute les valeurs par héritage + if(paragraphStudent!=null) paragraphStudent = ajouteValeurLesValeursDuStyleParagraphParent(nodStudentParagraph, paragraphStudent); + + // ajoute les valeurs par défauts + if(paragraphStudent!=null) paragraphStudent = ajouteValeurParDefautAuStyleParagraph(nodStudentParagraph, paragraphStudent); + + // analyse les attributs du node + paragraph = analyseLesAttributEtContenuDuNode(paragraphStudent, paragraphSujet, paragraph, "ana:paragraph",paragraphSujet.getNomElt()); + + // les enfants du premier niveau du node + for(int j = 0 ; j < paragraphSujet.getNodes().size();j++ ) { + + node nodSujet = paragraphSujet.getNodes().get(j); + String nameNode = nodSujet.getNomElt(); + node nodStudent = null; + if(paragraphStudent!=null) { + if(paragraphStudent.retourneFirstEnfantsByName(nameNode).getNomElt().equals(nameNode)) { + nodStudent = paragraphStudent.retourneFirstEnfantsByName(nameNode); + } + } + + //insère un saut si titre pas vide et saut=true + paragraph = addNodeSautTitre(nodSujet, paragraph); + + // analyse attribut et contenu des enfants du premier niveau + paragraph = analyseLesAttributEtContenuDuNode(nodStudent, nodSujet, paragraph, "ana:paragraph",nodSujet.getNomElt()); + + + for(int k = 0 ; k < nodSujet.getNodes().size();k++) { + node nod2Sujet = nodSujet.getNodes().get(k); + String nameNode2 = nod2Sujet.getNomElt(); + node nod2Student = null; + if(nodStudent!=null) if(nodStudent.retourneFirstEnfantsByName(nameNode2).getNomElt().equals(nameNode2)) { + nod2Student = paragraphStudent.retourneFirstEnfantsByName(nameNode2); + } + + //insère un saut si titre pas vide et saut=true + paragraph = addNodeSautTitre(nod2Sujet, paragraph); + + // analyse attribut et contenu des enfants du second niveau + paragraph = analyseLesAttributEtContenuDuNode(nod2Student, nod2Sujet, paragraph, "ana:paragraph",nod2Sujet.getNomElt() ); + + for(int l = 0 ; l < nod2Sujet.getNodes().size();l++) { + node nod3Sujet = nod2Sujet.getNodes().get(l); + String nameNode3 = nod3Sujet.getNomElt(); + node nod3Student = null; + if(nod2Student!=null) if(nod2Student.retourneFirstEnfantsByName(nameNode3).getNomElt().equals(nameNode3)) { + nod3Student = paragraphStudent.retourneFirstEnfantsByName(nameNode3); + } + + //insère un saut si titre pas vide et saut=true + paragraph = addNodeSautTitre(nod3Sujet, paragraph); + + // analyse attribut et contenu des enfants du troisième niveau + paragraph = analyseLesAttributEtContenuDuNode(nod3Student, nod3Sujet, paragraph, "ana:paragraph", nod3Sujet.getNomElt()); + } + + } + + } + + paragraph.getAttributs().put("point", String.valueOf(outils.getPointsClass()-pointDebut)); + paragraph.getAttributs().put("pointTotal", String.valueOf(outils.getPointTotal()-pointTotalDebut)); + nodparagraphs.getNodes().add(paragraph); + + + } + } + + nodparagraphs.getAttributs().put("pointgagner",String.valueOf(outils.getPointsClass())); + nodparagraphs.getAttributs().put("pointtotal",String.valueOf(outils.getPointTotal())); + nodparagraphs.getAttributs().put("proportioncorrect",String.valueOf(outils.getProportionCorrect())); + nodparagraphs.setClose(true); + return nodparagraphs; + } + + /** + * Analyse du node sequences. + * @param nodStudentSequence + * @param nodSujetSequence + * @param a + * @param nodmenu + * @return + */ + private static node analyseLesSequences(node nodStudentSequence, node nodSujetSequence, Run a, node nodmenu) { + node nodseq = new node(); + nodseq.setNomElt("sequences"); + nodseq.setAttributs(nodSujetSequence.getAttributs()); + nodseq.setContenu(nodSujetSequence.getContenu()); //ajoute le commantire + + //ajoute l'identifiant pour le menu + if(a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "sequences")!=null) { + nodseq.getAttributs().put("id", a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "sequences").getAttributs().get("id")); + } + + //initialise les points + outils.initiliseLesPoints(); + + for(int i = 0 ; i < nodSujetSequence.getNodes().size(); i++) { + if(nodSujetSequence.getNodes().get(i).getNomElt().equals("text:sequence-decl")) { + int pointDebut = outils.getPointsClass(); + int pointTotalDebut = outils.getPointTotal(); + String nomSequence = outils.withoutCodeAndPoint(nodSujetSequence.getNodes().get(i).getAttributs().get("text:name")); + node seq = new node(); + seq.setNomElt("sequence"); + seq.getAttributs().put("name", nomSequence); + if(nodSujetSequence.getNodes().get(i).getAttributs().get("titre")!=null) seq.getAttributs().put("titre", nodSujetSequence.getNodes().get(i).getAttributs().get("titre")); + + node seqStudent = a.retourneFirstNodeByNameAttributValue(nodStudentSequence, "text:sequence-decl", "text:name", nomSequence); + node seqSujet = nodSujetSequence.getNodes().get(i); + + //insère un saut si titre pas vide et saut=true + seq = addNodeSautTitre(seqSujet, seq); + + // analyse les attributs du node + seq = analyseLesAttributEtContenuDuNode(seqStudent, seqSujet, seq, "ana:seq",seqSujet.getNomElt()); + + seq.getAttributs().put("point", String.valueOf(outils.getPointsClass()-pointDebut)); + seq.getAttributs().put("pointTotal", String.valueOf(outils.getPointTotal()-pointTotalDebut)); + nodseq.getNodes().add(seq); + } + + + + } + nodseq.getAttributs().put("pointgagner",String.valueOf(outils.getPointsClass())); + nodseq.getAttributs().put("pointtotal",String.valueOf(outils.getPointTotal())); + nodseq.getAttributs().put("proportioncorrect",String.valueOf(outils.getProportionCorrect())); + nodseq.setClose(true); + return nodseq; + } + + /** + * Analyse du node numerotationchapitre. + * @param nodStudentNumerotation + * @param nodSujetNumerotation + * @param a + * @param nodmenu + * @return + */ + private static node analyseLaNumerotationChapitre(node nodStudentNumerotation, node nodSujetNumerotation, Run a, node nodmenu) { + node nodnumerotations = new node(); + nodnumerotations.setNomElt("numerotationchapitre"); + nodnumerotations.setAttributs(nodSujetNumerotation.getAttributs());//ajoute tous les attributs du sujet + nodnumerotations.setContenu(nodSujetNumerotation.getContenu()); //ajoute le commantaire du sujet + + //ajoute l'identifiant pour le menu + if(a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "numerotationchapitre")!=null) { + nodnumerotations.getAttributs().put("id", a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "numerotationchapitre").getAttributs().get("id")); + } + + //initialise les points + outils.initiliseLesPoints(); + for(int i = 0 ; i < nodSujetNumerotation.getNodes().size(); i++) { + if(nodSujetNumerotation.getNodes().get(i).getNomElt().equals("text:outline-level-style")) { + int pointDebut = outils.getPointsClass(); + int pointTotalDebut = outils.getPointTotal(); + String levelnumrotation = outils.withoutCodeAndPoint(nodSujetNumerotation.getNodes().get(i).getAttributs().get("text:level")); + node numerotation = new node(); + numerotation.setNomElt("numerotation"); + numerotation.getAttributs().put("level", levelnumrotation); + if(nodSujetNumerotation.getNodes().get(i).getAttributs().get("titre")!=null) numerotation.getAttributs().put("titre", nodSujetNumerotation.getNodes().get(i).getAttributs().get("titre")); + + node numerotationStudent = a.retourneFirstNodeByNameAttributValue(nodStudentNumerotation, "text:outline-level-style", "text:level", levelnumrotation); + node numerotationSujet = nodSujetNumerotation.getNodes().get(i); + + // analyse les attributs du node + numerotation = analyseLesAttributEtContenuDuNode(numerotationStudent, numerotationSujet, numerotation, "ana:numerotation",numerotationSujet.getNomElt()); + + // les enfants du premier niveau du node + for(int j = 0 ; j < numerotationSujet.getNodes().size();j++ ) { + + node nodSujet = numerotationSujet.getNodes().get(j); + String nameNode = nodSujet.getNomElt(); + node nodStudent = null; + if(numerotationStudent!=null) if(numerotationStudent.retourneFirstEnfantsByName(nameNode).getNomElt().equals(nameNode)) { + nodStudent = numerotationStudent.retourneFirstEnfantsByName(nameNode); + } + + //insère un saut si titre pas vide et saut=true + numerotation=addNodeSautTitre(nodSujet, numerotation); + + // analyse attribut et contenu des enfants du premier niveau + numerotation = analyseLesAttributEtContenuDuNode(nodStudent, nodSujet, numerotation, "ana:numerotation",numerotationSujet.getNodes().get(j).getNomElt()); + + + for(int k = 0 ; k < nodSujet.getNodes().size();k++) { + node nod2Sujet = nodSujet.getNodes().get(k); + String nameNode2 = nod2Sujet.getNomElt(); + node nod2Student = null; + if(nodStudent!=null) if(nodStudent.retourneFirstEnfantsByName(nameNode2).getNomElt().equals(nameNode2)) { + nod2Student = numerotationStudent.retourneFirstEnfantsByName(nameNode2); + } + + //insère un saut si titre pas vide et saut=true + numerotation=addNodeSautTitre(nod2Sujet, numerotation); + + // analyse attribut et contenu des enfants du second niveau + numerotation = analyseLesAttributEtContenuDuNode(nod2Student, nod2Sujet, numerotation, "ana:numerotation",nod2Sujet.getNomElt() ); + + + for(int l = 0 ; l < nod2Sujet.getNodes().size();l++) { + node nod3Sujet = nod2Sujet.getNodes().get(l); + String nameNode3 = nod3Sujet.getNomElt(); + node nod3Student = null; + if(nod2Student!=null) if(nod2Student.retourneFirstEnfantsByName(nameNode3).getNomElt().equals(nameNode3)) { + nod3Student = numerotationStudent.retourneFirstEnfantsByName(nameNode3); + } + + //insère un saut si titre pas vide et saut=true + numerotation=addNodeSautTitre(nod3Sujet, numerotation); + + // analyse attribut et contenu des enfants du troisième niveau + numerotation = analyseLesAttributEtContenuDuNode(nod3Student, nod3Sujet, numerotation, "ana:paragraph", nod3Sujet.getNomElt()); + } + + } + + } + + numerotation.getAttributs().put("point", String.valueOf(outils.getPointsClass()-pointDebut)); + numerotation.getAttributs().put("pointTotal", String.valueOf(outils.getPointTotal()-pointTotalDebut)); + nodnumerotations.getNodes().add(numerotation); + + + } + } + + nodnumerotations.getAttributs().put("pointgagner",String.valueOf(outils.getPointsClass())); + nodnumerotations.getAttributs().put("pointtotal",String.valueOf(outils.getPointTotal())); + nodnumerotations.getAttributs().put("proportioncorrect",String.valueOf(outils.getProportionCorrect())); + nodnumerotations.setClose(true); + return nodnumerotations; + + } + + /** + * Analyse du node frames. + * @param nodStudentFrames + * @param nodSujetframes + * @param a + * @param nodmenu + * @return + */ + private static node analyseLesFrames(node nodStudentFrames, node nodSujetFrames, Run a, node nodmenu) { + node nodframes = new node(); + nodframes.setNomElt("frames"); + nodframes.setAttributs(nodSujetFrames.getAttributs()); //ajoute tous les attributs du sujet + nodframes.setContenu(nodSujetFrames.getContenu()); //ajoute le commentaire du sujet + + //ajoute l'identifiant pour le menu + if(a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "frames")!=null) { + nodframes.getAttributs().put("id", a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "frames").getAttributs().get("id")); + } + + //initialise les points + outils.initiliseLesPoints(); + for(int i = 0 ; i < nodSujetFrames.getNodes().size(); i++) { //niveau 1 + if(nodSujetFrames.getNodes().get(i).getNomElt().equals("draw:frame")) { + int pointDebut = outils.getPointsClass(); + int pointTotalDebut = outils.getPointTotal(); + String nomDuFrame = outils.withoutCodeAndPoint(nodSujetFrames.getNodes().get(i).getAttributs().get("draw:name")); + node frame = new node(); + frame.setNomElt("frame"); + frame.getAttributs().put("nameframe", nomDuFrame); + if(nodSujetFrames.getNodes().get(i).getAttributs().get("titre")!=null) frame.getAttributs().put("titre", nodSujetFrames.getNodes().get(i).getAttributs().get("titre")); + + node frameStudent = a.retourneFirstNodeByNameAttributValue(nodStudentFrames, "draw:frame", "draw:name", nomDuFrame); + node frameSujet = nodSujetFrames.getNodes().get(i); + + // analyse les attributs du node + frame = analyseLesAttributEtContenuDuNode(frameStudent, frameSujet, frame, "ana:frame",frameSujet.getNomElt()); + + // les enfants du premier niveau du node + for(int j = 0 ; j < frameSujet.getNodes().size();j++ ) { //niveau 2 + + node nodSujet = frameSujet.getNodes().get(j); + String nameNode = nodSujet.getNomElt(); + node nodStudent = null; + if(frameStudent!=null) if(frameStudent.retourneFirstEnfantsByName(nameNode).getNomElt().equals(nameNode)) { + nodStudent = frameStudent.retourneFirstEnfantsByName(nameNode); + } + if(frameStudent!=null) if(nameNode.equals("text:p")) { + + if(nodSujet.getAttributs().get("index")!=null) { + nodStudent = a.retourneFirstNodeByNameAttributValue(frameStudent, nameNode, "text:p", frameSujet.getNodes().get(j).getAttributs().get("index")); + } + + if(nodStudent==null)if(nodSujet.retourneLesContenusEnfants("").isEmpty()) { //si il n'y a pas de contenu, passe par l'index + nodStudent = a.retourneFirstNodeByNameAttributValue(frameStudent, nameNode, "index", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("index"))); + }else { + nodStudent = a.retourneFirstNodeByFindContent2(frameStudent.getNodes(), nodSujet.retourneLesContenusEnfants(""), commandes.tolerance_characters,commandes.tolerance_text); + } + + } + + //insère un saut si titre pas vide et saut=true + frame=addNodeSautTitre(nodSujet, frame); + + + // analyse attribut et contenu des enfants du premier niveau + frame = analyseLesAttributEtContenuDuNode(nodStudent, nodSujet, frame, "ana:frame",nodSujet.getNomElt()); + + + for(int k = 0 ; k < nodSujet.getNodes().size();k++) { //niveau 3 + node nod2Sujet = nodSujet.getNodes().get(k); + String nameNode2 = nod2Sujet.getNomElt(); + node nod2Student = null; + if(nodStudent!=null) if(nodStudent.retourneFirstEnfantsByName(nameNode2).getNomElt().equals(nameNode2)) { + nod2Student = nodStudent.retourneFirstEnfantsByName(nameNode2); + } + if(nodStudent!=null) if(nameNode2.equals("text:p")) { + if(nod2Sujet.getAttributs().get("index")!=null) { + nod2Student = a.retourneFirstNodeByNameAttributValue(nodStudent, nameNode2, "index", nod2Sujet.getAttributs().get("index")); + } + } + if(nodStudent!=null) if(nameNode2.equals("text:database-display")) { + if(nod2Sujet.getAttributs().get("text:column-name")!=null) { + nod2Student = a.retourneFirstNodeByNameAttributValue(nodStudent, nameNode2, "text:column-name", outils.withoutCodeAndPoint(nod2Sujet.getAttributs().get("text:column-name"))); + } + } + + //insère un saut si titre pas vide et saut=true + frame=addNodeSautTitre(nod2Sujet, frame); + + // analyse attribut et contenu des enfants du second niveau + frame = analyseLesAttributEtContenuDuNode(nod2Student, nod2Sujet, frame, "ana:frame",nod2Sujet.getNomElt() ); + + + for(int l = 0 ; l < nod2Sujet.getNodes().size();l++) { //niveau 4 + node nod3Sujet = nod2Sujet.getNodes().get(l); + String nameNode3 = nod3Sujet.getNomElt(); + node nod3Student = null; + if(nod2Student!=null) if(nod2Student.retourneFirstEnfantsByName(nameNode3).getNomElt().equals(nameNode3)) { + nod3Student = nod2Student.retourneFirstEnfantsByName(nameNode3); + } + if(nod2Student!=null) if(nameNode3.equals("text:database-display")) { + if(nod3Sujet.getAttributs().get("text:column-name")!=null) { + nod3Student = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode3, "text:column-name", outils.withoutCodeAndPoint(nod3Sujet.getAttributs().get("text:column-name"))); + } + } + + // analyse attribut et contenu des enfants du troisième niveau + if(nod3Student!=null) if(nod3Sujet.getNomElt().equals("text:sequence") && nod3Student.getNomElt().equals("text:sequence")) { + ArrayList changements = nod2Student.retourneEnfantsByName("text:change", new ArrayList()); + nod3Student.setNodes(changements); + } + + //insère un saut si titre pas vide et saut=true + frame=addNodeSautTitre(nod3Sujet, frame); + + // analyse attribut et contenu des enfants du second niveau + frame = analyseLesAttributEtContenuDuNode(nod3Student, nod3Sujet, frame, "ana:frame", nod3Sujet.getNomElt()); + } + + } + + } + + frame.getAttributs().put("point", String.valueOf(outils.getPointsClass()-pointDebut)); + frame.getAttributs().put("pointTotal", String.valueOf(outils.getPointTotal()-pointTotalDebut)); + nodframes.getNodes().add(frame); + + + } + } + + nodframes.getAttributs().put("pointgagner",String.valueOf(outils.getPointsClass())); + nodframes.getAttributs().put("pointtotal",String.valueOf(outils.getPointTotal())); + nodframes.getAttributs().put("proportioncorrect",String.valueOf(outils.getProportionCorrect())); + nodframes.setClose(true); + return nodframes; + + } + + /** + * Analyse du node bibliographies. + * @param nodStudentBiblio + * @param nodSujetBiblio + * @param a + * @param nodmenu + * @return + */ + private static node analyseLaBiblio(node nodStudentBiblio, node nodSujetBiblio, Run a, node nodmenu) { + node nodbiblio = new node(); + nodbiblio.setNomElt("bibliographies"); + nodbiblio.setAttributs(nodSujetBiblio.getAttributs());//ajoute tous les attributs du sujet + nodbiblio.setContenu(nodSujetBiblio.getContenu());//ajoute le commentaire du sujet + + //ajoute l'identifiant pour le menu + if(a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "biblio")!=null) { + nodbiblio.getAttributs().put("id", a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "biblio").getAttributs().get("id")); + } + + //initialise les points + outils.initiliseLesPoints(); + + // node biblio + node biblio = new node(); + + for(int i = 0 ; i < nodSujetBiblio.getNodes().size(); i++) { + if(nodSujetBiblio.getNodes().get(i).getNomElt().equals("text:bibliography")) { + int pointDebut = outils.getPointsClass(); + int pointTotalDebut = outils.getPointTotal(); + String nomDeLaBiblio = outils.withoutCodeAndPoint(nodSujetBiblio.getNodes().get(i).getAttributs().get("text:name")); + + biblio.setNomElt("biblio"); + biblio.getAttributs().put("namebiblio", nomDeLaBiblio); + if(nodSujetBiblio.getNodes().get(i).getAttributs().get("titre")!=null) biblio.getAttributs().put("titre", nodSujetBiblio.getNodes().get(i).getAttributs().get("titre")); + + String TitreTable = outils.withoutCodeAndPoint(nodSujetBiblio.getNodes().get(i).retourneFirstEnfantsByName("text:index-title").retourneLesContenusEnfants("")); + + node nodSujet = a.retourneFirstNodeParagrapheContain(a.retourneNames(nodSujetBiblio, "text:index-body"), TitreTable); + node nodStudent = a.retourneFirstNodeParagrapheContain(a.retourneNames(nodStudentBiblio, "text:index-body"), TitreTable); + + biblio = analyseLesAttributEtContenuDuNode(nodStudent, nodSujet, biblio, "ana:biblio", nodSujet.getNomElt()); + + for(int j =0 ; j < nodSujet.getNodes().size();j++) { + if(nodStudent!=null) { + if(j LestextpSujet = a.retourneNames(nodSujet, "text:p"); +// ArrayList LestextpStudent = null; +// if(nodStudent!=null) LestextpStudent = a.retourneNames(nodStudent, "text:p"); +// biblio = analyseLesContenusDesArrayList(LestextpStudent,LestextpSujet,biblio,"ana:biblio","txt:p",a); + + biblio.getAttributs().put("point", String.valueOf(outils.getPointsClass()-pointDebut)); + biblio.getAttributs().put("pointTotal", String.valueOf(outils.getPointTotal()-pointTotalDebut)); + nodbiblio.getNodes().add(biblio); + } + } + + + nodbiblio.getAttributs().put("pointgagner",String.valueOf(outils.getPointsClass())); + nodbiblio.getAttributs().put("pointtotal",String.valueOf(outils.getPointTotal())); + nodbiblio.getAttributs().put("proportioncorrect",String.valueOf(outils.getProportionCorrect())); + nodbiblio.setClose(true); + return nodbiblio; + + } + + /** + * Analyse du node tablematieres. + * @param nodStudentTableM + * @param nodSujetTableM + * @param a + * @param nodmenu + * @return + */ + private static node analyseLesTablesMatieres(node nodStudentTableM, node nodSujetTableM, Run a, node nodmenu) { + node nodTablesMs = new node(); + nodTablesMs.setNomElt("tablematieres"); + nodTablesMs.setAttributs(nodSujetTableM.getAttributs());//ajoute tous les attributs du sujet + nodTablesMs.setContenu(nodSujetTableM.getContenu());//ajoute le commentaire du sujet + + //ajoute l'identifiant pour le menu + if(a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "tablematieres")!=null) { + nodTablesMs.getAttributs().put("id", a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "tablematieres").getAttributs().get("id")); + } + + //initialise les points + outils.initiliseLesPoints(); + + + for(int i = 0 ; i < nodSujetTableM.getNodes().size(); i++) { + if(nodSujetTableM.getNodes().get(i).getNomElt().equals("text:table-of-content")) { + node table = new node(); + table.setNomElt("tablematiere"); + if(nodSujetTableM.getNodes().get(i).getAttributs().get("titre")!=null) { + String titre = nodSujetTableM.getNodes().get(i).getAttributs().get("titre"); + if(!titre.isEmpty()) table.getAttributs().put("titre", titre); + } + + + int pointDebut = outils.getPointsClass(); + int pointTotalDebut = outils.getPointTotal(); + String TitreTable = outils.withoutCodeAndPoint(nodSujetTableM.getNodes().get(i).retourneFirstEnfantsByName("text:index-title").retourneLesContenusEnfants("")); + + node nodSujet = a.retourneFirstNodeParagrapheContain(a.retourneNames(nodSujetTableM, "text:index-body"), TitreTable); + node nodStudent = a.retourneFirstNodeParagrapheContain(a.retourneNames(nodStudentTableM, "text:index-body"), TitreTable); + + table = analyseLesAttributEtContenuDuNode(nodStudent, nodSujet, table, "ana:tablematiere", nodSujet.getNomElt()); + + for(int j =0 ; j < nodSujet.getNodes().size();j++) { + if(nodStudent!=null) { + if(j LestextpSujet = a.retourneNames(nodSujet, "text:p"); +// ArrayList LestextpStudent = null; +// if(nodStudent!=null) LestextpStudent = a.retourneNames(nodStudent, "text:p"); +// +// table = analyseLesContenusDesArrayList(LestextpStudent,LestextpSujet,table,"ana:tablematiere","txt:p",a); + + table.getAttributs().put("point", String.valueOf(outils.getPointsClass()-pointDebut)); + table.getAttributs().put("pointTotal", String.valueOf(outils.getPointTotal()-pointTotalDebut)); + nodTablesMs.getNodes().add(table); + + } + } + + nodTablesMs.getAttributs().put("pointgagner",String.valueOf(outils.getPointsClass())); + nodTablesMs.getAttributs().put("pointtotal",String.valueOf(outils.getPointTotal())); + nodTablesMs.getAttributs().put("proportioncorrect",String.valueOf(outils.getProportionCorrect())); + nodTablesMs.setClose(true); + return nodTablesMs; + } + + /** + * Analyse du node tableillustrations. + * @param nodStudentTableI + * @param nodSujetTableI + * @param a + * @param nodmenu + * @return + */ + private static node analyseLesTablesIllustrations(node nodStudentTableI, node nodSujetTableI, Run a, node nodmenu) { + node nodTablesMs = new node(); + nodTablesMs.setNomElt("tableillustrations"); + nodTablesMs.setAttributs(nodSujetTableI.getAttributs());//ajoute tous les attributs du sujet + nodTablesMs.setContenu(nodSujetTableI.getContenu());//ajoute le commentaire du sujet + + //ajoute l'identifiant pour le menu + if(a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "tableillustrations")!=null) { + nodTablesMs.getAttributs().put("id", a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "tableillustrations").getAttributs().get("id")); + } + + //initialise les points + outils.initiliseLesPoints(); + + + for(int i = 0 ; i < nodSujetTableI.getNodes().size(); i++) { + if(nodSujetTableI.getNodes().get(i).getNomElt().equals("text:illustration-index")) { + node table = new node(); + table.setNomElt("tableillustrations"); + if(nodSujetTableI.getNodes().get(i).getAttributs().get("titre")!=null) { + String titre = nodSujetTableI.getNodes().get(i).getAttributs().get("titre"); + if(!titre.isEmpty()) table.getAttributs().put("titre", titre); + } + + + int pointDebut = outils.getPointsClass(); + int pointTotalDebut = outils.getPointTotal(); + String TitreTable = outils.withoutCodeAndPoint(nodSujetTableI.getNodes().get(i).retourneFirstEnfantsByName("text:index-title").retourneLesContenusEnfants("")); + + node nodSujet = a.retourneFirstNodeParagrapheContain(a.retourneNames(nodSujetTableI, "text:index-body"), TitreTable); + node nodStudent = a.retourneFirstNodeParagrapheContain(a.retourneNames(nodStudentTableI, "text:index-body"), TitreTable); + + table = analyseLesAttributEtContenuDuNode(nodStudent, nodSujet, table, "ana:tableillustration", nodSujet.getNomElt()); + + for(int j =0 ; j < nodSujet.getNodes().size();j++) { + if(nodStudent!=null) { + if(j LestextpSujet = a.retourneNames(nodSujet, "text:p"); +// ArrayList LestextpStudent = a.retourneNames(nodStudent, "text:p"); +// table = analyseLesContenusDesArrayList(LestextpStudent,LestextpSujet,table,"ana:tableillustration","txt:p",a); + + table.getAttributs().put("point", String.valueOf(outils.getPointsClass()-pointDebut)); + table.getAttributs().put("pointTotal", String.valueOf(outils.getPointTotal()-pointTotalDebut)); + nodTablesMs.getNodes().add(table); + + } + } + + nodTablesMs.getAttributs().put("pointgagner",String.valueOf(outils.getPointsClass())); + nodTablesMs.getAttributs().put("pointtotal",String.valueOf(outils.getPointTotal())); + nodTablesMs.getAttributs().put("proportioncorrect",String.valueOf(outils.getProportionCorrect())); + nodTablesMs.setClose(true); + return nodTablesMs; + } + + /** + * Cette méthode permet d'analyse la structure du document.
+ * La structure de l'étudiant est comparé avec la structure du sujet.
+ *
+ * @param nodStudentS : node de la structure de l'étudiant. + * @param nodSujetS : node de la structure du sujet. + * @param a : Objet de la class cXML + * @param nodmenu : node menu. + * @param nodSujetParagraphs : node contenant l'ensemble des styles de paragraphe du sujet. + * @param nodStudentParagraphs : node contenant l'ensemble des styles de paragraphe de l'étudiant. + * @return : le node d'analyse de la structure. + */ + private static node analyseStructurePage(node nodStudentS, node nodSujetS, Run a, node nodmenu, node nodSujetParagraphs, node nodStudentParagraphs) { + node nodSpages = new node(); + nodSpages.setNomElt("structurepage"); + nodSpages.setAttributs(nodSujetS.getAttributs()); + nodSpages.setContenu(nodSujetS.getContenu()); //ajoute le commentaire du sujet + + //ajoute l'identifiant pour le menu + if(a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "structurepage")!=null) { + nodSpages.getAttributs().put("id", a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "name", "structurepage").getAttributs().get("id")); + } + + //initialise les points + outils.initiliseLesPoints(); + + //******************************** + // Premier niveau que les pages + for(int i = 0 ; i < nodSujetS.getNodes().size(); i++) { + if(nodSujetS.getNodes().get(i).getNomElt().equals("page")) { + int pointDebut = outils.getPointsClass(); + int pointTotalDebut = outils.getPointTotal(); + String nomDeLaPage = outils.withoutCodeAndPoint(nodSujetS.getNodes().get(i).getAttributs().get("style:master-page-name")); + if(nomDeLaPage==null) nomDeLaPage="Défaut"; + String numeroabsolue = outils.withoutCodeAndPoint(nodSujetS.getNodes().get(i).getAttributs().get("numeroabsolue")); + node page = new node(); + page.setNomElt("page"); + page.getAttributs().put("namepage", nomDeLaPage); + page.getAttributs().put("numeroabsolue", numeroabsolue); + + if(nodSujetS.getNodes().size()>0) if(nodSujetS.getNodes().get(i).getAttributs().get("titre")!=null) page.getAttributs().put("titre", nodSujetS.getNodes().get(i).getAttributs().get("titre")); + + node pageStudent = a.retourneFirstNodeByNameAttributValue(nodStudentS, "page", "numeroabsolue", numeroabsolue); + node pageSujet = nodSujetS.getNodes().get(i); + + // analyse les attributs du node + page = analyseLesAttributEtContenuDuNode(pageStudent, pageSujet, page, "ana:page",pageSujet.getNomElt()); + + //************************************** + // second niveau + for(int j = 0 ; j < pageSujet.getNodes().size();j++ ) { + + //boolean paragrapheTexte = false; + node nodSujet = pageSujet.getNodes().get(j); + String nameNode = nodSujet.getNomElt(); + node nodStudent = null; + + nodStudent = rechercheLeNodeEnCascade(nameNode,nodSujet,null,null,pageStudent,a); + + //insère un saut s'il y a un titre avec un saut=true + page = addNodeSautTitre(nodSujet, page); + + // analyse attribut et contenu des enfants du premier niveau + page = analyseLesAttributEtContenuDuNode(nodStudent, nodSujet, page, "ana:page",nodSujet.getNomElt()); + + + //analyse le nom du node + if(nodSujet.getAttributs().get("evalNameNode")!=null) { + String point = nodSujet.getAttributs().get("evalNameNode"); + page =analyseNameNode(page,nodStudent,nodSujet.getNomElt(),point, nodSujet.getNomElt()); + } + + // méthode analyseStyle + if(nameNode.equals("text:p") && nodSujetParagraphs!=null) { + page = analyseStyle(page, nodSujet,nodStudent, nodSujetParagraphs,nodStudentParagraphs); + } + + //*************************** + //troisieme niveau + for(int k = 0 ; k < nodSujet.getNodes().size();k++) { + node nod2Sujet = nodSujet.getNodes().get(k); + String nameNode2 = nod2Sujet.getNomElt(); + node nod2Student = null; + + nod2Student = rechercheLeNodeEnCascade(nameNode2,nod2Sujet,null,pageStudent,nodStudent,a); + + //insère un saut s'il y a un titre avec un saut=true + page = addNodeSautTitre(nod2Sujet, page); + + //analyse le nom du node + if(nod2Sujet.getAttributs().get("evalNameNode")!=null) { + String point = nod2Sujet.getAttributs().get("evalNameNode"); + page =analyseNameNode(page,nod2Student,nod2Sujet.getNomElt(),point, nod2Sujet.getNomElt()); + } + + // méthode analyseStyle + if(nameNode.equals("text:p") && nodSujetParagraphs!=null) { + page = analyseStyle(page, nod2Sujet,nod2Student, nodSujetParagraphs,nodStudentParagraphs); + } + + // analyse attribut et contenu des enfants du second niveau + page = analyseLesAttributEtContenuDuNode(nod2Student, nod2Sujet, page, "ana:page",nod2Sujet.getNomElt() ); + + //************************ + //quatrieme niveau + for(int l = 0 ; l < nod2Sujet.getNodes().size();l++) { + node nod3Sujet = nod2Sujet.getNodes().get(l); + String nameNode3 = nod3Sujet.getNomElt(); + node nod3Student = null; + + nod3Student = rechercheLeNodeEnCascade(nameNode3,nod3Sujet,pageStudent,nodStudent,nod2Student,a); + + //insère un saut s'il y a un titre avec un saut=true + page = addNodeSautTitre(nod3Sujet, page); + + + //analyse le nom du node + if(nod3Sujet.getAttributs().get("evalNameNode")!=null) { + String point = nod3Sujet.getAttributs().get("evalNameNode"); + page =analyseNameNode(page,nod3Student,nod3Sujet.getNomElt(),point, nod3Sujet.getNomElt()); + } + + // méthode analyseStyle + if(nameNode.equals("text:p") && nodSujetParagraphs!=null) { + page = analyseStyle(page, nod3Sujet,nod3Student, nodSujetParagraphs,nodStudentParagraphs); + } + + // analyse attribut et contenu des enfants du troisième niveau + page = analyseLesAttributEtContenuDuNode(nod3Student, nod3Sujet, page, "ana:page", nod3Sujet.getNomElt()); + + //**************** + //cinquième niveau + for(int m = 0 ; m < nod3Sujet.getNodes().size();m++) { + node nod4Sujet = nod3Sujet.getNodes().get(m); + String nameNode4 = nod4Sujet.getNomElt(); + node nod4Student = null; + + nod4Student = rechercheLeNodeEnCascade(nameNode4,nod4Sujet,nodStudent,nod2Student,nod3Student,a); + + //insère un saut s'il y a un titre avec un saut=true + page = addNodeSautTitre(nod4Sujet, page); + + //analyse le nom du node + if(nod3Sujet.getAttributs().get("evalNameNode")!=null) { + String point = nod4Sujet.getAttributs().get("evalNameNode"); + page =analyseNameNode(page,nod4Student,nod4Sujet.getNomElt(),point, nod4Sujet.getNomElt()); + } + + // méthode analyseStyle + if(nameNode.equals("text:p") && nodSujetParagraphs!=null) { + page = analyseStyle(page, nod4Sujet,nod4Student, nodSujetParagraphs,nodStudentParagraphs); + } + + // analyse attribut et contenu des enfants du troisième niveau + page = analyseLesAttributEtContenuDuNode(nod4Student, nod4Sujet, page, "ana:page", nod4Sujet.getNomElt()); + + + //************ + // Sixieme niveau + for(int p = 0 ; p < nod4Sujet.getNodes().size();p++) { + node nod5Sujet = nod4Sujet.getNodes().get(p); + String nameNode5 = nod5Sujet.getNomElt(); + node nod5Student = null; + + nod5Student = rechercheLeNodeEnCascade(nameNode5,nod5Sujet,nod2Student,nod3Student,nod4Student,a); + + //insère un saut s'il y a un titre avec un saut=true + page = addNodeSautTitre(nod5Sujet, page); + + //analyse le nom du node + if(nod5Sujet.getAttributs().get("evalNameNode")!=null) { + String point = nod5Sujet.getAttributs().get("evalNameNode"); + page =analyseNameNode(page,nod5Student,nod5Sujet.getNomElt(),point, nod5Sujet.getNomElt()); + } + + // méthode analyseStyle + if(nameNode.equals("text:p") && nodSujetParagraphs!=null) { + page = analyseStyle(page, nod5Sujet,nod5Student, nodSujetParagraphs,nodStudentParagraphs); + } + + // analyse attribut et contenu des enfants du troisième niveau + page = analyseLesAttributEtContenuDuNode(nod5Student, nod5Sujet, page, "ana:page", nod5Sujet.getNomElt()); + + } + } + + } + + } + + } + + page.getAttributs().put("point", String.valueOf(outils.getPointsClass()-pointDebut)); + page.getAttributs().put("pointTotal", String.valueOf(outils.getPointTotal()-pointTotalDebut)); + nodSpages.getNodes().add(page); + + + } + } + + nodSpages.getAttributs().put("pointgagner",String.valueOf(outils.getPointsClass())); + nodSpages.getAttributs().put("pointtotal",String.valueOf(outils.getPointTotal())); + nodSpages.getAttributs().put("proportioncorrect",String.valueOf(outils.getProportionCorrect())); + nodSpages.setClose(true); + return nodSpages; + + } + + /** + * Analyse tous les attributs et les contenus d'un node.
+ * Les attributs et les contenus doivent posséder la carcatère ‽ ou ‼.
+ *
+ * @param nodeStudent : le node de l'étudiant. + * @param sujet : le node du sujet + * @param retour : le node à retourner avec les enfants nommés nameItem. + * @param nameItem : le nom des nodes enfants. + * @param nameElt : le nom de l'élément (node) analysé. + * @return le node retour avec tous les nodes enfants nameItem contenant les différentes analyse. + */ + private static node analyseLesAttributEtContenuDuNode(node nodeStudent, node sujet, node retour, String nameItem, String nameElt) { + Enumeration key = sujet.getAttributs().keys(); + while(key.hasMoreElements()) { + String k = key.nextElement(); + + if( sujet.getAttributs().get(k).contains("‽")){ + if(nodeStudent!=null) { + String valueAttributStudent = nodeStudent.getAttributs().get(k); + String valueAttributSujet = sujet.getAttributs().get(k); + + node item = retourneNoteAvecResultatsAnalyse(nameItem,k, valueAttributStudent, valueAttributSujet,nameElt); + retour.getNodes().add(item); + }else { + String valueAttributStudent = "null"; + String valueAttributSujet = sujet.getAttributs().get(k); + + node item = retourneNoteAvecResultatsAnalyse(nameItem, k, valueAttributStudent, valueAttributSujet,nameElt); + retour.getNodes().add(item); + } + } + + if(k.equals("evalNameNode")) { + if(nodeStudent!=null) { + retour = analyseNameNode(retour,nodeStudent, sujet.getNomElt(), sujet.getAttributs().get("evalNameNode"),sujet.getNomElt()); + }else { + retour = analyseNameNode(retour,null, sujet.getNomElt(), sujet.getAttributs().get("evalNameNode"),sujet.getNomElt()); + } + } + } + //avec l'attribut allContent="strict1" ou allContent="environ1" alors analyse tout le contenu du node + if(sujet.getAttributs().get("allContent")!=null) if(!sujet.getAttributs().get("allContent").isEmpty()){ + String points ="‽0"; + if(sujet.getAttributs().get("allContent").contains("strict")) points = sujet.getAttributs().get("allContent").replace("strict", "‽"); + if(sujet.getAttributs().get("allContent").contains("strictSansEspace")) points = sujet.getAttributs().get("allContent").replace("strictSansEspace", "≡‽"); + if(sujet.getAttributs().get("allContent").contains("environ")) points = sujet.getAttributs().get("allContent").replace("environ", "¢‽"); + + String allContentSujet = sujet.retourneLesContenusEnfants("") + points; + String allContentStudent = "null"; + if( nodeStudent!=null) allContentStudent = nodeStudent.retourneLesContenusEnfants(""); + node item = retourneNoteAvecResultatsAnalyse(nameItem,"Contenu textuel", allContentStudent, allContentSujet, nameElt); + retour.getNodes().add(item); + } + + // analyse le contenu du node avec tous les nodes sauf "text:sequence" + if(sujet.getContenu().contains("‽") && !sujet.getNomElt().equals("text:sequence")) { + String contenuStudent =""; + if(nodeStudent!=null) contenuStudent = nodeStudent.getContenu(); + String contenuSujet = sujet.getContenu(); + node item = retourneNoteAvecResultatsAnalyse(nameItem,"Contenu textuel", contenuStudent, contenuSujet, nameElt); + retour.getNodes().add(item); + } + + // analyse le contenu du node text:sequence et tous les enfants text:change (lorsque les légendes sont modifiées) + if(sujet.getContenu().contains("‽") && sujet.getNomElt().equals("text:sequence")) { + String contenuStudent =""; + if(nodeStudent!=null) contenuStudent = nodeStudent.retourneLesContenusEnfants("text:change"); + String contenuSujet = sujet.getContenu(); + node item = retourneNoteAvecResultatsAnalyse(nameItem,"Contenu textuel", contenuStudent, contenuSujet, nameElt); + retour.getNodes().add(item); + } + + return retour; + } + + /** + * Analyse tous les attributs des styles de paragraphes.
+ * Formatage direct des styles de paragraphe. Les attributs doivent contenir le code ‼.
+ *
+ * @param nodeStudent : le node de l'étudiant. + * @param sujet : le node du sujet + * @param retour : le node à retourner avec les enfants nommés nameItem. + * @param nameItem : le nom des nodes enfants. + * @param nameElt : le nom de l'élément (node) analysé. + * @return le node retour avec tous les nodes enfants nameItem contenant les différentes analyse. + */ + private static node analyseLesAttributAnalyseStyle(node nodeStyleParagraphStudent, node nodeStyleParagraphSujet, node retour, String nameItem, String nameElt) { + + Enumeration key = nodeStyleParagraphSujet.getAttributs().keys(); + while(key.hasMoreElements()) { + String k = key.nextElement(); + if(nodeStyleParagraphSujet.getAttributs().get(k).contains("‼") || nodeStyleParagraphSujet.getAttributs().get(k).contains("‽")){ + if(nodeStyleParagraphStudent!=null) { + String valueAttributStudent = nodeStyleParagraphStudent.getAttributs().get(k); + String valueAttributSujet = nodeStyleParagraphSujet.getAttributs().get(k).replace("‼", "‽"); + node item = retourneNoteAvecResultatsAnalyse(nameItem,k, valueAttributStudent, valueAttributSujet,nameElt); + retour.getNodes().add(item); + }else { + String valueAttributStudent = "null"; + String valueAttributSujet = nodeStyleParagraphSujet.getAttributs().get(k).replace("‼", "‽"); + node item = retourneNoteAvecResultatsAnalyse(nameItem, k, valueAttributStudent, valueAttributSujet,nameElt); + retour.getNodes().add(item); + } + } + } + + if(nodeStyleParagraphStudent!=null) { + if(nodeStyleParagraphSujet.retourneEnfantsByNameExist("style:paragraph-properties") && nodeStyleParagraphStudent.retourneEnfantsByNameExist("style:paragraph-properties") ) { + node propertiesSujet = nodeStyleParagraphSujet.retourneFirstEnfantsByName("style:paragraph-properties"); + node propertiesStudent = nodeStyleParagraphStudent.retourneFirstEnfantsByName("style:paragraph-properties"); + key = propertiesSujet.getAttributs().keys(); + while(key.hasMoreElements()) { + String k = key.nextElement(); + if(propertiesSujet.getAttributs().get(k).contains("‼") || propertiesSujet.getAttributs().get(k).contains("‽")){ + if(propertiesStudent!=null) { + String valueAttributStudent = propertiesStudent.getAttributs().get(k); + String valueAttributSujet = propertiesSujet.getAttributs().get(k).replace("‼", "‽"); + node item = retourneNoteAvecResultatsAnalyse(nameItem,k, valueAttributStudent, valueAttributSujet,"style:paragraph-properties"); + retour.getNodes().add(item); + }else { + String valueAttributStudent = "null"; + String valueAttributSujet = propertiesSujet.getAttributs().get(k).replace("‼", "‽"); + node item = retourneNoteAvecResultatsAnalyse(nameItem, k, valueAttributStudent, valueAttributSujet,"style:paragraph-properties"); + retour.getNodes().add(item); + } + } + } + } + }else { + node propertiesSujet = nodeStyleParagraphSujet.retourneFirstEnfantsByName("style:paragraph-properties"); + key = propertiesSujet.getAttributs().keys(); + while(key.hasMoreElements()) { + String k = key.nextElement(); + if(propertiesSujet.getAttributs().get(k).contains("‼") || propertiesSujet.getAttributs().get(k).contains("‽")){ + String valueAttributStudent = "null"; + String valueAttributSujet = propertiesSujet.getAttributs().get(k).replace("‼", "‽"); + + node item = retourneNoteAvecResultatsAnalyse(nameItem, k, valueAttributStudent, valueAttributSujet,"style:paragraph-properties"); + retour.getNodes().add(item); + } + } + } + + if(nodeStyleParagraphStudent!=null) { + if(nodeStyleParagraphSujet.retourneEnfantsByNameExist("style:text-properties") && nodeStyleParagraphStudent.retourneEnfantsByNameExist("style:text-properties") ) { + node propertiesSujet = nodeStyleParagraphSujet.retourneFirstEnfantsByName("style:text-properties"); + node propertiesStudent = nodeStyleParagraphStudent.retourneFirstEnfantsByName("style:text-properties"); + key = propertiesSujet.getAttributs().keys(); + while(key.hasMoreElements()) { + String k = key.nextElement(); + if(propertiesSujet.getAttributs().get(k).contains("‼") || propertiesSujet.getAttributs().get(k).contains("‽")){ + if(propertiesStudent!=null) { + String valueAttributStudent = propertiesStudent.getAttributs().get(k); + String valueAttributSujet = propertiesSujet.getAttributs().get(k).replace("‼", "‽"); + + node item = retourneNoteAvecResultatsAnalyse(nameItem,k, valueAttributStudent, valueAttributSujet,"style:text-properties"); + retour.getNodes().add(item); + }else { + String valueAttributStudent = "null"; + String valueAttributSujet = propertiesSujet.getAttributs().get(k).replace("‼", "‽"); + + node item = retourneNoteAvecResultatsAnalyse(nameItem, k, valueAttributStudent, valueAttributSujet,"style:text-properties"); + retour.getNodes().add(item); + } + } + } + } + }else { + node propertiesSujet = nodeStyleParagraphSujet.retourneFirstEnfantsByName("style:text-properties"); + key = propertiesSujet.getAttributs().keys(); + while(key.hasMoreElements()) { + String k = key.nextElement(); + if(propertiesSujet.getAttributs().get(k).contains("‼") || propertiesSujet.getAttributs().get(k).contains("‽")){ + String valueAttributStudent = "null"; + String valueAttributSujet = propertiesSujet.getAttributs().get(k).replace("‼", "‽"); + + node item = retourneNoteAvecResultatsAnalyse(nameItem, k, valueAttributStudent, valueAttributSujet,"style:text-properties"); + retour.getNodes().add(item); + } + } + } + + return retour; + } + + + /** + * Analyse toutes les contenus des enfants et les compares.
+ * Utiliser pour les nodes
+ *
+ * @param Student + * @param Sujet + * @param retour + * @param nameItem + * @param nameElt + * @param a + * @return + */ + private static node analyseLesContenusDesArrayList(ArrayList Student, ArrayList Sujet, node retour, String nameItem, String nameElt, Run a) { + + for(int i = 0 ; i < Sujet.size();i++) { + String sujetContent = Sujet.get(i).retourneLesContenusEnfants(""); + node StudentNode = a.retourneFirstNodeByFindContent2(Student, outils.withoutCodeAndPoint(sujetContent),commandes.tolerance_characters,commandes.tolerance_text); + String studentContent = "null"; + if(StudentNode!=null) studentContent = outils.NetChiffreALaFin(StudentNode.retourneLesContenusEnfants("")); + + node item = retourneNoteAvecResultatsAnalyse(nameItem, "Contenu textuel", studentContent, sujetContent,nameElt); + retour.getNodes().add(item); + + } + + return retour; + } + + + /** + * Retourne le node avec les résultats de la comparaison entre les deux valeurs (étudiant et sujet).
+ *
+ * @param nameNode + * @param Tst (résultat de la comparaison) + * @param property + * @param valueAttributStudent + * @param valueAttributSujet + * @return + */ + private static node retourneNoteAvecResultatsAnalyse(String nameNode, String property, String valueStudent, String valueSujet, String nameElt) { + String Tst = outils.Compare(valueStudent, valueSujet); + int niveau = 3; + if(Tst.contains("Correct")) niveau = 1; + if(Tst.contains("Erreur")) niveau = 2; + valueStudent = outils.remplaceCaracteresCodageAttribut(valueStudent); + valueSujet = outils.remplaceCaracteresCodageAttribut(valueSujet); + node item = new node(nameNode, Tst, property , valueStudent, valueSujet, niveau, outils.getPointEnJeu(),nameElt); + return item; + } + + /** + * Création du feedback (compte-rendu) au format HTML.
+ *
+ * @param nodana + * @throws IOException + */ + private static void feedback(node nodana, node verif) throws IOException { + + System.getProperty("file.encoding","UTF-8"); + Date aujourdhui = new Date(); + + int number_match = 2; + int mini_modification = 0; + boolean plagiat = false; + boolean copiercoller = false; + boolean pasAssezDeModification =false; + boolean baremeABC = false; + boolean producteur = false; + String SuiteBureautique = ""; + String VersionLibreOffice = ""; + String SystemeStudent = ""; + node verifStudent = null; + if((commandes.verifHisto||commandes.verifHisto2)&&commandes.ecritNoteCSV&&commandes.fourniCSV) { + if(verif.getAttributs().get("number_match") != null) number_match = Integer.valueOf(verif.getAttributs().get("number_match")); + if(verif.getAttributs().get("mini_number_modification") != null) mini_modification = Integer.valueOf(verif.getAttributs().get("mini_number_modification")); + + //verification du plagiat + verifStudent = verif.retourneFirstNodeByNameAndAttributValue("fichier", "dossier", nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("dossier")); + if(verifStudent != null) { + if(verifStudent.getAttributs().get("filename").equals(nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("filename"))) { + if(Integer.valueOf(verifStudent.getAttributs().get("nombre_correspondances_consecutives"))>number_match) plagiat=true; + if(!verifStudent.getAttributs().get("first_modification_identique").equals("null") && Integer.valueOf(verifStudent.getAttributs().get("nombre_correspondances_consecutives"))>=number_match) plagiat=true; + if(verifStudent.getAttributs().get("copier_coller")!=null) copiercoller=true; + if(Integer.valueOf(verifStudent.getAttributs().get("nombre_modification"))<=mini_modification) pasAssezDeModification=true; + } + } + } + + //BaremeABC + if(nodana.retourneFirstEnfantsByName("bodyetnotation").getAttributs().get("baremeABC")!=null) { + try { + baremeABC= Boolean.valueOf(nodana.retourneFirstEnfantsByName("bodyetnotation").getAttributs().get("baremeABC")); + }catch (Exception e) { + System.out.println("Problème avec la valeur binaire de l'attribut baremeABC."); + } + } + + + + //nom du fichier feedback + String metaS = nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("metaSujet"); + if(metaS.equals("?")) metaS = "metaSujet-inconnu"; + if(metaS.isEmpty()) metaS = "metaSujet-inconnu"; + String cheminFeedBack = nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("dossier") + "-DateLong" + aujourdhui.getTime()+"-"+metaS; + if(!commandes.noNote&&!baremeABC) { + if(!plagiat&&!copiercoller)cheminFeedBack = cheminFeedBack + "-" + nodana.retourneFirstEnfantsByName("bodyetnotation").getAttributs().get("note") + ".html"; + if(plagiat) cheminFeedBack = cheminFeedBack + "- plagiat.html"; + if(copiercoller) cheminFeedBack = cheminFeedBack + "- copier-coller.html"; + if(pasAssezDeModification) cheminFeedBack = cheminFeedBack + "- pas assez de modification.html"; + } + if(!commandes.noNote&&baremeABC) { + if(!plagiat)cheminFeedBack = cheminFeedBack + "-" + nodana.retourneFirstEnfantsByName("bodyetnotation").getAttributs().get("noteABC") + ".html"; + if(copiercoller) cheminFeedBack = cheminFeedBack + "- copier-coller.html"; + if(plagiat) cheminFeedBack = cheminFeedBack + "- plagiat.html"; + if(pasAssezDeModification) cheminFeedBack = cheminFeedBack + "- pas assez de modification.html"; + } + if(commandes.noNote) { + cheminFeedBack = cheminFeedBack + ".html"; + } + + // Chemin vers le dossier de destination + Path outputFilePath = Paths.get(patch + "/" + cheminFeedBack); + if(commandes.fourniDossierDestination) outputFilePath = Paths.get(patch + "/" + commandes.pathDestination+ "/" + cheminFeedBack); + + + BufferedWriter fichier = Files.newBufferedWriter(outputFilePath, StandardCharsets.UTF_8); + + //ajoute le chemin vers le feedback dans le node d'analyse + nodana.retourneFirstEnfantsByName("ouverture").getAttributs().put("feedback", patch + "/" + cheminFeedBack); + + // auteur du sujet + String auteurSujet = nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("auteur"); + if(auteurSujet==null) auteurSujet=""; + + + //création du feedback + fichier.write("\r" + + "\r" + + "\r" + + "\r" + + "Analyse LibreOffice Calc\r"); + + fichier.write("" + + "" + + ""); + + + fichier.write(""); + + fichier.write("\r"); + fichier.write("\r"); + + fichier.write("
"); + if(!commandes.noLogo) { + if(!commandes.newLogo) { + fichier.write("

\r\n" + + "Feedback - AnalyseWriter - format ODF 1.2
"+HTML.imgLogos()+"

\r"); + }else { + + fichier.write("

\r\n" + + "Feedback - AnalyseWriter - format ODF 1.2
"+commandes.contenuFichierSVG+"

\r"); + } + }else { + fichier.write("

\r\n" + + "Feedback - AnalyseWriter - format ODF 1.2

\r"); + } + + + //Note + node ouvre = nodana.retourneFirstEnfantsByName("ouverture"); + String noteFrom = ouvre.getAttributs().get("notefrom"); + node notation = nodana.retourneFirstEnfantsByName("bodyetnotation"); + if(!baremeABC) { + if(noteFrom ==null) noteFrom="20"; + if(!commandes.noNote) if(!plagiat&&!copiercoller&&!pasAssezDeModification) fichier.write("

" + notation.getAttributs().get("note") + " / " + noteFrom +"
"+ ouvre.getAttributs().get("metaSujet") +"

\r"); + if(plagiat || copiercoller || pasAssezDeModification) { + notation.getAttributs().put("note","0"); + String AffichageNote = ""; + if(plagiat) AffichageNote = " Plagiat "; + if(copiercoller) AffichageNote = AffichageNote + " Copier Coller "; + if(pasAssezDeModification) AffichageNote = AffichageNote + " Pas assez de modification "; + if(!commandes.noNote) fichier.write("

" + AffichageNote + " / " + noteFrom +"
"+ ouvre.getAttributs().get("metaSujet") +"

\r"); + } + }else { + String imageNote = ""; + switch (notation.getAttributs().get("noteABC")) { + case "A": + imageNote = HTML.NoteA(); + break; + case "B": + imageNote = HTML.NoteB(); + break; + case "C": + imageNote = HTML.NoteC(); + break; + case "D": + imageNote = HTML.NoteD(); + break; + case "E": + imageNote = HTML.NoteE(); + break; + default: + imageNote = ""; + break; + } + if(!commandes.noNote) if(!plagiat&& !copiercoller &&!pasAssezDeModification) fichier.write("

" + imageNote +"
"+ ouvre.getAttributs().get("metaSujet") +"

\r"); + if(plagiat || copiercoller || pasAssezDeModification) { + notation.getAttributs().put("note","0"); + notation.getAttributs().put("noteABC","E"); + String AffichageNote = ""; + if(plagiat) AffichageNote = " Plagiat "; + if(copiercoller) AffichageNote = AffichageNote + " Copier Coller "; + if(pasAssezDeModification) AffichageNote = AffichageNote + " Pas assez de modification "; + if(!commandes.noNote) fichier.write("

" + AffichageNote + " / " + "
"+ ouvre.getAttributs().get("metaSujet") +"

\r"); + } + } + + //producteur + if(ouvre.getAttributs().get("producteur")!=null) { + try { + producteur= true; + String[] decompose = ouvre.getAttributs().get("producteur").split("/"); + SuiteBureautique=decompose[0]; + VersionLibreOffice=decompose[1].substring(0, decompose[1].lastIndexOf("$")); + SystemeStudent=decompose[1].substring(decompose[1].lastIndexOf("$")+1, decompose[1].lastIndexOf(" ")); + }catch (Exception e) { + System.out.println("Problème avec l'attribut producteur."); + + }finally { + + } + } + + //informations + // date d'analyse, dossier étudiant, auteur sujet, date de la dernière modificatio, lien, algorithme + DateFormat mediumDateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM); + LocalDateTime dateTimeModif = null; + String dateModif=""; + if(ouvre.getAttributs().get("dateModification")!=null) if(!ouvre.getAttributs().get("dateModification").isEmpty()) { + try { + dateTimeModif = LocalDateTime.parse(ouvre.getAttributs().get("dateModification")); + dateModif = dateTimeModif.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM)); + }catch (Exception e) { + System.out.println(e.toString()); + } + } + + fichier.write("

Date d'analyse : "+ mediumDateFormat.format(aujourdhui) + "
"); + fichier.write("Dossier étudiant : "+ ouvre.getAttributs().get("dossier") + "
"); + fichier.write("Nom du fichier analysé et évalué : "+ ouvre.getAttributs().get("filename") + "
"); + fichier.write("Date de la dernière modification du fichier analysé : "+ dateModif + "
"); + fichier.write("Durée d'édition du fichier analysé : "+ traitementDureeEdition(ouvre.getAttributs().get("dureeEdition") + "
")); + if(producteur) { + fichier.write("Suite de bureautique : "+ SuiteBureautique + ""); + fichier.write(" - Version : "+ VersionLibreOffice + ""); + fichier.write(" - Système : "+ SystemeStudent + "
"); + } + if(!auteurSujet.isEmpty()) {fichier.write("Sujet créé par : "+ auteurSujet + "
");}else {fichier.write("
");} + + if(!commandes.noNote) { + if(!plagiat&&!copiercoller&&!pasAssezDeModification) fichier.write("Méthode :
Progression " + ouvre.getAttributs().get("progression") + "Explication
"+ HTML.imgProgression() +"
- Pourcentage correcte : " + nodana.retourneFirstEnfantsByName("bodyetnotation").getAttributs().get("proportioncorrect") +"
"); + if(plagiat || copiercoller || pasAssezDeModification) { + String AffichageNote = ""; + if(plagiat) AffichageNote = " Plagiat "; + if(copiercoller) AffichageNote = AffichageNote + " Copier Coller "; + if(pasAssezDeModification) AffichageNote = AffichageNote + " Pas assez de modification "; + fichier.write("Méthode :
Progression " + ouvre.getAttributs().get("progression") + "Explication
"+ HTML.imgProgression() +"
- Pourcentage correcte : "+ AffichageNote +"
"); + } + } + + if(baremeABC) { + fichier.append("Barème :
0% → E → " + Math.round(Double.valueOf(notation.getAttributs().get("BorneE"))*100) + "% → D → " + Math.round(Double.valueOf(notation.getAttributs().get("BorneD"))*100) + "% → C → " + Math.round(Double.valueOf(notation.getAttributs().get("BorneC"))*100) + "% → B → " + Math.round(Double.valueOf(notation.getAttributs().get("BorneB"))*100) + "% → A → 100%Prendre en compte le coefficient de progression.
"); + } + + if(ouvre.getAttributs().get("link_sujet")!=null) { + String linkSujet= ouvre.getAttributs().get("link_sujet"); + Matcher m = Pattern.compile("^https://.{1,}|^http://.{1,}").matcher(linkSujet); + if(m.find()) {fichier.write("
Lien vers le sujet
");} + } + if(ouvre.getAttributs().get("link_help")!=null) { + String linkSujet= ouvre.getAttributs().get("link_help"); + Matcher m = Pattern.compile("^https://.{1,}|^http://.{1,}").matcher(linkSujet); + if(m.find()) {fichier.write("
Lien vers le support
");} + } + + fichier.write("
Analysé avec la version : " + commandes.version + "

"); + + + fichier.write(HTML.SautLigne()); + + fichier.write("
"); + + //ajoute le menu + fichier.write(HTML.getHTMLmenu(nodana.retourneFirstEnfantsByName("menu").getNodes())); + + + //Les erreurs + node errors = nodana.retourneFirstEnfantsByName("erreurs"); + if(Boolean.valueOf(errors.getAttributs().get("oneError"))) { + fichier.write(HTML.SautLigne()); + if(Boolean.valueOf(errors.getAttributs().get("manqueHistorique"))) fichier.write(HTML.Paragraph_classp5("ERREUR : Il n'y a pas d'historique des modifications dans ce fichier. Le fichier n'a pas été modifié ou il a été réinitialisé.
L'analyse de l'historique n'a pas pu se faire.")); + if(Boolean.valueOf(errors.getAttributs().get("manqueCreationDate"))) fichier.write(HTML.Paragraph_classp5("ERREUR : La date de création du fichier a été supprimée. Le fichier a été réïnitialisé ou ce n'est pas le fichier du sujet.")); + if(Boolean.valueOf(errors.getAttributs().get("manqueValeurCreationDate"))) fichier.write(HTML.Paragraph_classp5("ERREUR : Ce n'est pas la bonne date de création du fichier. Le fichier a été réïnitialisé ou ce n'est pas fichier du sujet.")); + if(Boolean.valueOf(errors.getAttributs().get("manqueMetaSujet"))) fichier.write(HTML.Paragraph_classp5("ERREUR : La méta donnée \"Sujet\" dans les propriétés du fichier a été supprimée ou renommée.")); + if(Boolean.valueOf(errors.getAttributs().get("manqueValeurMetaSujet"))) fichier.write(HTML.Paragraph_classp5("ERREUR : La valeur de la méta donnée \"Sujet\" dans les propriétés du fichier n'est pas \"" + nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("metaSujet"))+".\""); + if(Boolean.valueOf(errors.getAttributs().get("manqueInitialCreator"))) fichier.write(HTML.Paragraph_classp5("ERREUR : La valeur de la méta donnée \"initial-creator\" dans les propriétés du fichier n'est pas \"" + nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("Initial_Creator"))+".\""); + } + + //plagiat + if(plagiat) if(verifStudent!=null){ + fichier.append(HTML.SautLigne()); + ArrayList correspondance = verifStudent.retourneEnfantsByName("correspondance", new ArrayList()); + for(int j = 0 ; j < correspondance.size();j++) { + fichier.write(HTML.Paragraph_classp5("Correspondance à la date=" + correspondance.get(j).getAttributs().get("date") + " avec l'étudiant " + correspondance.get(j).getAttributs().get("Avec_etudiant"))); + } + } + + + fichier.write(HTML.SautLigne()); + + + if(!plagiat && !copiercoller && !pasAssezDeModification) { + + //Ajoute de commentaire de l'exercice + fichier.write(HTML.H3(nodana.getContenu()).replace("-NewLine-", "
")); + + fichier.write(HTML.SautLigne()); + + + fichier.write(HTML.H2("Synthèse")); + + fichier.write(HTML.TableEnteteTableurSynthese()); + String IdError = ""; // permet de récupérer les id des menu ou la proportioncorrect est NaN. (à cause de l'attribut analyseStyle=true) + for(int k = 0 ; k < nodana.getNodes().size();k++) { + if(nodana.getNodes().get(k).getAttributs().get("addmenu")!=null) if(nodana.getNodes().get(k).getAttributs().get("addmenu").equals("true")) { + if(!nodana.getNodes().get(k).getAttributs().get("proportioncorrect").equals("NaN")) { + fichier.write(HTML.TablePointsSyntheseStyle(nodana.getNodes().get(k).getAttributs().get("titre"),Double.valueOf(nodana.getNodes().get(k).getAttributs().get("proportioncorrect")),nodana.getNodes().get(k).getAttributs().get("pointtotal") + " pt",nodana.getNodes().get(k).getAttributs().get("pointgagner") + " pt", nodana.getNodes().get(k).getAttributs().get("poids"),nodana.getNodes().get(k).getAttributs().get("id"))); + }else { + IdError = IdError + nodana.getNodes().get(k).getAttributs().get("id"); + } + } + } + + + //Metadonnées + if(nodana.retourneFirstEnfantsByName("meta")!=null) if(nodana.retourneFirstEnfantsByName("meta").isClose()) { + fichier.write(HTML.Table(nodana.retourneFirstEnfantsByName("meta"))); + } + + //style de paragraphe + if(nodana.retourneFirstEnfantsByName("paragraphs")!=null) if(nodana.retourneFirstEnfantsByName("paragraphs").isClose()) { + //il est possible qu'il n'y ai aucun point car passé par analyseStyle dans le node structurepage + if(!IdError.contains(nodana.retourneFirstEnfantsByName("paragraphs").getAttributs().get("id"))){ + fichier.write(HTML.Table(nodana.retourneFirstEnfantsByName("paragraphs"))); + } + } + + //pages + if(nodana.retourneFirstEnfantsByName("pages")!=null) if(nodana.retourneFirstEnfantsByName("pages").isClose()) { + fichier.write(HTML.Table(nodana.retourneFirstEnfantsByName("pages"))); + } + + //sequences + if(nodana.retourneFirstEnfantsByName("sequences")!=null) if(nodana.retourneFirstEnfantsByName("sequences").isClose()) { + fichier.write(HTML.Table(nodana.retourneFirstEnfantsByName("sequences"))); + } + + //numerotationchapitre + if(nodana.retourneFirstEnfantsByName("numerotationchapitre")!=null) if(nodana.retourneFirstEnfantsByName("numerotationchapitre").isClose()) { + fichier.write(HTML.Table(nodana.retourneFirstEnfantsByName("numerotationchapitre"))); + } + + //frames + if(nodana.retourneFirstEnfantsByName("frames")!=null) if(nodana.retourneFirstEnfantsByName("frames").isClose()) { + fichier.write(HTML.Table(nodana.retourneFirstEnfantsByName("frames"))); + } + + //section + if(nodana.retourneFirstEnfantsByName("sections")!=null) if(nodana.retourneFirstEnfantsByName("sections").isClose()) { + fichier.write(HTML.Table(nodana.retourneFirstEnfantsByName("sections"))); + } + + //bibliographies + if(nodana.retourneFirstEnfantsByName("bibliographies")!=null) if(nodana.retourneFirstEnfantsByName("bibliographies").isClose()) { + fichier.write(HTML.Table(nodana.retourneFirstEnfantsByName("bibliographies"))); + } + + //tablematieres + if(nodana.retourneFirstEnfantsByName("tablematieres")!=null) if(nodana.retourneFirstEnfantsByName("tablematieres").isClose()) { + fichier.write(HTML.Table(nodana.retourneFirstEnfantsByName("tablematieres"))); + } + + //tableillustrations + if(nodana.retourneFirstEnfantsByName("tableillustrations")!=null) if(nodana.retourneFirstEnfantsByName("tableillustrations").isClose()) { + fichier.write(HTML.Table(nodana.retourneFirstEnfantsByName("tableillustrations"))); + } + + //structurepage + if(nodana.retourneFirstEnfantsByName("structurepage")!=null) if(nodana.retourneFirstEnfantsByName("structurepage").isClose()) { + fichier.write(HTML.Table(nodana.retourneFirstEnfantsByName("structurepage"))); + } + + } + + + + fichier.write("



"); + + //footer + fichier.write("
"); + fichier.write("analyseWriter - P. Rodriguez (université d'Artois) - Licence GPL v3.0 - analysé avec la version : " + commandes.version + " - "); + fichier.write("Fichier d'analyse créé avec la version : " + ouvre.getAttributs().get("version") + ""); + fichier.write("
"); + + fichier.write(""); + + fichier.write("\r"); + fichier.write(""); + + fichier.close(); + + //affichage dans la console + if(!commandes.fourniDossierDestination) System.out.println("\n\t The feedback file has been written.\n\t " + patch + "\\" + cheminFeedBack); + if(commandes.fourniDossierDestination) System.out.println("\n\t The feedback file has been written.\n\t " + patch + "\\" + commandes.pathDestination + "\\" + cheminFeedBack); + + + } + + + /** + * Retourne le nom du fichier de l'étudiant pour le Zip de Moodle.
+ *
+ * @param filename + * @param nodana + * @return + */ + private static String retourneLeNomDuFeedback( String filename,node nodana, node verif) { + System.getProperty("file.encoding","UTF-8"); + + int number_match = 2; + int mini_modification = 0; + boolean plagiat = false; + boolean copiercoller = false; + boolean pasAssezDeModification =false; + + node verifStudent = null; + if((commandes.verifHisto||commandes.verifHisto2)) { //&&commandes.ecritNoteCSV&&commandes.fourniCSV + if(verif.getAttributs().get("number_match") != null) number_match = Integer.valueOf(verif.getAttributs().get("number_match")); + if(verif.getAttributs().get("mini_number_modification") != null) mini_modification = Integer.valueOf(verif.getAttributs().get("mini_number_modification")); + + + //verification du plagiat + verifStudent = verif.retourneFirstNodeByNameAndAttributValue("fichier", "dossier", nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("dossier")); + if(verifStudent != null) { + if(verifStudent.getAttributs().get("filename").equals(nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("filename"))) { + if(Integer.valueOf(verifStudent.getAttributs().get("nombre_correspondances_consecutives"))>number_match) plagiat=true; + if(!verifStudent.getAttributs().get("first_modification_identique").equals("null") && Integer.valueOf(verifStudent.getAttributs().get("nombre_correspondances_consecutives"))>=number_match) plagiat=true; + if(verifStudent.getAttributs().get("copier_coller")!=null) copiercoller=true; + if(Integer.valueOf(verifStudent.getAttributs().get("nombre_modification"))<=mini_modification) pasAssezDeModification=true; + } + } + } + + //nom du fichier feedback + String metaS = nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("metaSujet"); + if(metaS.equals("?")) metaS = "metaSujet-inconnu"; + if(metaS.isEmpty()) metaS = "metaSujet-inconnu"; + String cheminFeedBack = nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("dossier") +"-"+metaS; //+ "-DateLong" + aujourdhui.getTime() + + boolean baremeABC = false; + if(nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("baremeABC")!=null) { + try { + baremeABC = Boolean.valueOf(nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("baremeABC")); + }catch (Exception e) { + + } + } + + if(!baremeABC) { + if(!commandes.noNote) { + if(!plagiat) cheminFeedBack = cheminFeedBack + "-" + nodana.retourneFirstEnfantsByName("bodyetnotation").getAttributs().get("note") + ".html"; + if(plagiat) cheminFeedBack = cheminFeedBack + "-Plagiat.html"; + if(copiercoller) cheminFeedBack = cheminFeedBack + "-Copier-Coller.html"; + if(pasAssezDeModification) cheminFeedBack = cheminFeedBack + "-Pas assez de modification.html"; + }else { + cheminFeedBack = cheminFeedBack + ".html"; + } + }else { + if(!commandes.noNote) { + if(!plagiat) cheminFeedBack = cheminFeedBack + "-" + nodana.retourneFirstEnfantsByName("bodyetnotation").getAttributs().get("noteABC") + ".html"; + if(plagiat) cheminFeedBack = cheminFeedBack + "-Plagiat.html"; + if(copiercoller) cheminFeedBack = cheminFeedBack + "-Copier-Coller.html"; + if(pasAssezDeModification) cheminFeedBack = cheminFeedBack + "-Pas assez de modification.html"; + }else { + cheminFeedBack = cheminFeedBack + ".html"; + } + } + + + return filename + cheminFeedBack; + } + + + /** + * Ecriture du fichier pour l'archive ZIP de moodle.
+ *
+ * @param nodana + * @return + * @throws IOException + */ + private static StringBuilder feedbackForZip(node nodana, node verif) throws IOException { + + System.getProperty("file.encoding","UTF-8"); + Date aujourdhui = new Date(); + + int number_match = 2; + int mini_modification = 0; + boolean plagiat = false; + boolean copiercoller = false; + boolean pasAssezDeModification =false; + boolean baremeABC = false; + boolean producteur =false; + String SuiteBureautique=""; + String VersionLibreOffice=""; + String SystemeStudent=""; + node verifStudent = null; + if((commandes.verifHisto||commandes.verifHisto2)) { //&&commandes.ecritNoteCSV&&commandes.fourniCSV + if(verif.getAttributs().get("number_match") != null) number_match = Integer.valueOf(verif.getAttributs().get("number_match")); + if(verif.getAttributs().get("mini_number_modification") != null) mini_modification = Integer.valueOf(verif.getAttributs().get("mini_number_modification")); + + //verification du plagiat + verifStudent = verif.retourneFirstNodeByNameAndAttributValue("fichier", "dossier", nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("dossier")); + if(verifStudent != null) { + if(verifStudent.getAttributs().get("filename").equals(nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("filename"))) { + if(Integer.valueOf(verifStudent.getAttributs().get("nombre_correspondances_consecutives"))>number_match) plagiat=true; + if(!verifStudent.getAttributs().get("first_modification_identique").equals("null") && Integer.valueOf(verifStudent.getAttributs().get("nombre_correspondances_consecutives"))>=number_match) plagiat=true; + if(verifStudent.getAttributs().get("copier_coller")!=null) copiercoller=true; + if(Integer.valueOf(verifStudent.getAttributs().get("nombre_modification"))<=mini_modification) pasAssezDeModification=true; + } + } + } + if(nodana.retourneFirstEnfantsByName("bodyetnotation").getAttributs().get("baremeABC")!=null) { + try { + baremeABC= Boolean.valueOf(nodana.retourneFirstEnfantsByName("bodyetnotation").getAttributs().get("baremeABC")); + }catch (Exception e) { + System.out.println("Problème avec la valeur binaire de l'attribut baremeABC."); + } + } + + + StringBuilder fichier = new StringBuilder(); + + //ajoute le chemin vers le feedback dans le node d'analyse + //nodana.retourneFirstEnfantsByName("ouverture").getAttributs().put("feedback", patch + "/" + cheminFeedBack); + + // auteur du sujet + String auteurSujet = nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("auteur"); + if(auteurSujet==null) auteurSujet=""; + + + //création du feedback + fichier.append("\r" + + "\r" + + "\r" + + "\r" + + "Analyse LibreOffice Calc\r"); + + fichier.append("" + + "" + + ""); + + + fichier.append(""); + + fichier.append("\r"); + fichier.append("\r"); + + fichier.append("
"); + if(!commandes.noLogo) { + if(!commandes.newLogo) { + fichier.append("

\r\n" + + "Feedback - AnalyseWriter - format ODF 1.2
"+HTML.imgLogos()+"

\r"); + }else { + + fichier.append("

\r\n" + + "Feedback - AnalyseWriter - format ODF 1.2
"+commandes.contenuFichierSVG+"

\r"); + } + }else { + fichier.append("

\r\n" + + "Feedback - AnalyseWriter - format ODF 1.2

\r"); + } + + //Note + node ouvre = nodana.retourneFirstEnfantsByName("ouverture"); + String noteFrom = ouvre.getAttributs().get("notefrom"); + node notation = nodana.retourneFirstEnfantsByName("bodyetnotation"); + if(!baremeABC) { + if(noteFrom ==null) noteFrom="20"; + if(!commandes.noNote) if(!plagiat&&!copiercoller&&!pasAssezDeModification) fichier.append("

" + notation.getAttributs().get("note") + " / " + noteFrom +"
"+ ouvre.getAttributs().get("metaSujet") +"

\r"); + if(plagiat || copiercoller || pasAssezDeModification) { + notation.getAttributs().put("note","0"); + String AffichageNote = ""; + if(plagiat) AffichageNote = " Plagiat "; + if(copiercoller) AffichageNote = AffichageNote + " Copier Coller "; + if(pasAssezDeModification) AffichageNote = AffichageNote + " Pas assez de modification "; + if(!commandes.noNote) fichier.append("

" + AffichageNote + " / " + noteFrom +"
"+ ouvre.getAttributs().get("metaSujet") +"

\r"); + } + }else { + String imageNote = ""; + switch (notation.getAttributs().get("noteABC")) { + case "A": + imageNote = HTML.NoteA(); + break; + case "B": + imageNote = HTML.NoteB(); + break; + case "C": + imageNote = HTML.NoteC(); + break; + case "D": + imageNote = HTML.NoteD(); + break; + case "E": + imageNote = HTML.NoteE(); + break; + default: + imageNote = ""; + break; + } + if(!commandes.noNote) if(!plagiat&& !copiercoller &&!pasAssezDeModification) fichier.append("

" + imageNote +"
"+ ouvre.getAttributs().get("metaSujet") +"

\r"); + if(plagiat || copiercoller || pasAssezDeModification) { + notation.getAttributs().put("note","0"); + notation.getAttributs().put("noteABC","E"); + String AffichageNote = ""; + if(plagiat) AffichageNote = " Plagiat "; + if(copiercoller) AffichageNote = AffichageNote + " Copier Coller "; + if(pasAssezDeModification) AffichageNote = AffichageNote + " Pas assez de modification "; + if(!commandes.noNote) fichier.append("

" + AffichageNote + " / " + "
"+ ouvre.getAttributs().get("metaSujet") +"

\r"); + } + } + + + //producteur + if(ouvre.getAttributs().get("producteur")!=null) { + try { + producteur= true; + String[] decompose = ouvre.getAttributs().get("producteur").split("/"); + SuiteBureautique=decompose[0]; + VersionLibreOffice=decompose[1].substring(0, decompose[1].lastIndexOf("$")); + SystemeStudent=decompose[1].substring(decompose[1].lastIndexOf("$")+1, decompose[1].lastIndexOf(" ")); + }catch (Exception e) { + System.out.println("Problème avec l'attribut producteur."); + + }finally { + + } + } + + //informations + // date d'analyse, dossier étudiant, auteur sujet, date de la dernière modificatio, lien, algorithme + DateFormat mediumDateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM); + LocalDateTime dateTimeModif = null; + String dateModif=""; + if(!ouvre.getAttributs().get("dateModification").isEmpty()) { + try { + dateTimeModif = LocalDateTime.parse(ouvre.getAttributs().get("dateModification")); + dateModif = dateTimeModif.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM)); + }catch (Exception e) { + System.out.println(e.toString()); + } + } + + fichier.append("

Date d'analyse : "+ mediumDateFormat.format(aujourdhui) + "
"); + fichier.append("Dossier étudiant : "+ ouvre.getAttributs().get("dossier") + "
"); + fichier.append("Nom du fichier analysé et évalué : "+ ouvre.getAttributs().get("filename") + "
"); + fichier.append("Date de la dernière modification du fichier analysé : "+ dateModif + "
"); + fichier.append("Durée d'édition du fichier analysé : "+ traitementDureeEdition(ouvre.getAttributs().get("dureeEdition") + "
")); + if(producteur) { + fichier.append("Suite de bureautique : "+ SuiteBureautique + ""); + fichier.append(" - Version : "+ VersionLibreOffice + ""); + fichier.append(" - Système : "+ SystemeStudent + "
"); + } + if(!auteurSujet.isEmpty()) {fichier.append("Sujet créé par : "+ auteurSujet + "
");}else {fichier.append("
");} + + if(!commandes.noNote) { + if(!plagiat&&!copiercoller&&!pasAssezDeModification) fichier.append("Méthode :
Progression " + ouvre.getAttributs().get("progression") + "Explication
"+ HTML.imgProgression() +"
- Pourcentage correcte : " + nodana.retourneFirstEnfantsByName("bodyetnotation").getAttributs().get("proportioncorrect") +"
"); + if(plagiat || copiercoller || pasAssezDeModification) { + String AffichageNote = ""; + if(plagiat) AffichageNote = " Plagiat "; + if(copiercoller) AffichageNote = AffichageNote + " Copier Coller "; + if(pasAssezDeModification) AffichageNote = AffichageNote + " Pas assez de modification "; + fichier.append("Méthode :
Progression " + ouvre.getAttributs().get("progression") + "Explication
"+ HTML.imgProgression() +"
- Pourcentage correcte : "+ AffichageNote +"
"); + } + } + + if(baremeABC) { + fichier.append("Barème :
0% → E → " + Math.round(Double.valueOf(notation.getAttributs().get("BorneE"))*100) + "% → D → " + Math.round(Double.valueOf(notation.getAttributs().get("BorneD"))*100) + "% → C → " + Math.round(Double.valueOf(notation.getAttributs().get("BorneC"))*100) + "% → B → " + Math.round(Double.valueOf(notation.getAttributs().get("BorneB"))*100) + "% → A → 100%Prendre en compte le coefficient de progression.
"); + } + + + if(ouvre.getAttributs().get("link_sujet")!=null) { + String linkSujet= ouvre.getAttributs().get("link_sujet"); + Matcher m = Pattern.compile("^https://.{1,}|^http://.{1,}").matcher(linkSujet); + if(m.find()) {fichier.append("
Lien vers le sujet
");} + } + if(ouvre.getAttributs().get("link_help")!=null) { + String linkSujet= ouvre.getAttributs().get("link_help"); + Matcher m = Pattern.compile("^https://.{1,}|^http://.{1,}").matcher(linkSujet); + if(m.find()) {fichier.append("
Lien vers le support
");} + } + + fichier.append("
Analysé avec la version : " + commandes.version + "

"); + + + fichier.append(HTML.SautLigne()); + + fichier.append("
"); + + //ajoute le menu + fichier.append(HTML.getHTMLmenu(nodana.retourneFirstEnfantsByName("menu").getNodes())); + + + //Les erreurs + node errors = nodana.retourneFirstEnfantsByName("erreurs"); + if(Boolean.valueOf(errors.getAttributs().get("oneError"))) { + fichier.append(HTML.SautLigne()); + if(Boolean.valueOf(errors.getAttributs().get("manqueHistorique"))) fichier.append(HTML.Paragraph_classp5("ERREUR : Il n'y a pas d'historique des modifications dans ce fichier. Le fichier n'a pas été modifié ou il a été réïnitialisé.
L'analyse de l'historique n'a pas pu se faire.")); + if(Boolean.valueOf(errors.getAttributs().get("manqueCreationDate"))) fichier.append(HTML.Paragraph_classp5("ERREUR : La date de création du fichier a été supprimée. Le fichier a été réïnitialisé ou ce n'est pas le fichier du sujet.")); + if(Boolean.valueOf(errors.getAttributs().get("manqueValeurCreationDate"))) fichier.append(HTML.Paragraph_classp5("ERREUR : Ce n'est pas la bonne date de création du fichier. Le fichier a été réïnitialisé ou ce n'est pas le fichier du sujet.")); + if(Boolean.valueOf(errors.getAttributs().get("manqueMetaSujet"))) fichier.append(HTML.Paragraph_classp5("ERREUR : La méta donnée \"Sujet\" dans les propriétés du fichier a été supprimée ou renommée.")); + if(Boolean.valueOf(errors.getAttributs().get("manqueValeurMetaSujet"))) fichier.append(HTML.Paragraph_classp5("ERREUR : La valeur de la méta donnée \"Sujet\" dans les propriétés du fichier n'est pas \"" + nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("metaSujet"))+".\""); + if(Boolean.valueOf(errors.getAttributs().get("manqueInitialCreator"))) fichier.append(HTML.Paragraph_classp5("ERREUR : La valeur de la méta donnée \"initial-creator\" dans les propriétés du fichier n'est pas \"" + nodana.retourneFirstEnfantsByName("ouverture").getAttributs().get("Initial_Creator"))+".\""); + } + + //plagiat + if(plagiat) if(verifStudent!=null){ + fichier.append(HTML.SautLigne()); + ArrayList correspondance = verifStudent.retourneEnfantsByName("correspondance", new ArrayList()); + for(int j = 0 ; j < correspondance.size();j++) { + fichier.append(HTML.Paragraph_classp5("Correspondance à la date=" + correspondance.get(j).getAttributs().get("date") + " avec l'étudiant " + correspondance.get(j).getAttributs().get("Avec_etudiant"))); + } + } + + + fichier.append(HTML.SautLigne()); + + if(!plagiat && !copiercoller && !pasAssezDeModification) { + + //Ajoute de commentaire de l'exercice + fichier.append(HTML.H3(nodana.getContenu()).replace("-NewLine-", "
")); + + fichier.append(HTML.SautLigne()); + + + fichier.append(HTML.H2("Synthèse")); + + fichier.append(HTML.TableEnteteTableurSynthese()); + String IdError = ""; // permet de récupérer les id des menu ou la proportioncorrect est NaN. (à cause de l'attribut analyseStyle=true) + for(int k = 0 ; k < nodana.getNodes().size();k++) { + if(nodana.getNodes().get(k).getAttributs().get("addmenu")!=null) if(nodana.getNodes().get(k).getAttributs().get("addmenu").equals("true")) { + if(!nodana.getNodes().get(k).getAttributs().get("proportioncorrect").equals("NaN")) { + fichier.append(HTML.TablePointsSyntheseStyle(nodana.getNodes().get(k).getAttributs().get("titre"),Double.valueOf(nodana.getNodes().get(k).getAttributs().get("proportioncorrect")),nodana.getNodes().get(k).getAttributs().get("pointtotal") + " pt",nodana.getNodes().get(k).getAttributs().get("pointgagner") + " pt", nodana.getNodes().get(k).getAttributs().get("poids"),nodana.getNodes().get(k).getAttributs().get("id"))); + }else { + IdError = IdError + nodana.getNodes().get(k).getAttributs().get("id"); + } + } + } + + + //Metadonnées + if(nodana.retourneFirstEnfantsByName("meta")!=null) if(nodana.retourneFirstEnfantsByName("meta").isClose()) { + fichier.append(HTML.Table(nodana.retourneFirstEnfantsByName("meta"))); + } + + //style de paragraphe + if(nodana.retourneFirstEnfantsByName("paragraphs")!=null) if(nodana.retourneFirstEnfantsByName("paragraphs").isClose()) { + //il est possible qu'il n'y ai aucun point car passé par analyseStyle dans le node structurepage + if(!IdError.contains(nodana.retourneFirstEnfantsByName("paragraphs").getAttributs().get("id"))){ + fichier.append(HTML.Table(nodana.retourneFirstEnfantsByName("paragraphs"))); + } + } + + //pages + if(nodana.retourneFirstEnfantsByName("pages")!=null) if(nodana.retourneFirstEnfantsByName("pages").isClose()) { + fichier.append(HTML.Table(nodana.retourneFirstEnfantsByName("pages"))); + } + + //sequences + if(nodana.retourneFirstEnfantsByName("sequences")!=null) if(nodana.retourneFirstEnfantsByName("sequences").isClose()) { + fichier.append(HTML.Table(nodana.retourneFirstEnfantsByName("sequences"))); + } + + //numerotationchapitre + if(nodana.retourneFirstEnfantsByName("numerotationchapitre")!=null) if(nodana.retourneFirstEnfantsByName("numerotationchapitre").isClose()) { + fichier.append(HTML.Table(nodana.retourneFirstEnfantsByName("numerotationchapitre"))); + } + + //frames + if(nodana.retourneFirstEnfantsByName("frames")!=null) if(nodana.retourneFirstEnfantsByName("frames").isClose()) { + fichier.append(HTML.Table(nodana.retourneFirstEnfantsByName("frames"))); + } + + //bibliographies + if(nodana.retourneFirstEnfantsByName("bibliographies")!=null) if(nodana.retourneFirstEnfantsByName("bibliographies").isClose()) { + fichier.append(HTML.Table(nodana.retourneFirstEnfantsByName("bibliographies"))); + } + + //tablematieres + if(nodana.retourneFirstEnfantsByName("tablematieres")!=null) if(nodana.retourneFirstEnfantsByName("tablematieres").isClose()) { + fichier.append(HTML.Table(nodana.retourneFirstEnfantsByName("tablematieres"))); + } + + //tableillustrations + if(nodana.retourneFirstEnfantsByName("tableillustrations")!=null) if(nodana.retourneFirstEnfantsByName("tableillustrations").isClose()) { + fichier.append(HTML.Table(nodana.retourneFirstEnfantsByName("tableillustrations"))); + } + + //structurepage + if(nodana.retourneFirstEnfantsByName("structurepage")!=null) if(nodana.retourneFirstEnfantsByName("structurepage").isClose()) { + fichier.append(HTML.Table(nodana.retourneFirstEnfantsByName("structurepage"))); + } + + fichier.append("



"); + } + + + + + //footer + fichier.append("
"); + fichier.append("analyseWriter - P. Rodriguez (université d'Artois) - Licence GPL v3.0 - analysé avec la version : " + commandes.version + " - "); + fichier.append("Fichier d'analyse créé avec la version : " + ouvre.getAttributs().get("version") + ""); + fichier.append("
"); + + fichier.append(""); + + fichier.append("\r"); + fichier.append(""); + + + //affichage dans la console +// if(!commandes.fourniDossierDestination) System.out.println("\n\t The feedback file has been written.\n\t " + patch + "\\" + cheminFeedBack); +// if(commandes.fourniDossierDestination) System.out.println("\n\t The feedback file has been written.\n\t " + patch + "\\" + commandes.pathDestination + "\\" + cheminFeedBack); + + return fichier; + } + + + + /** + * Affichage uniquement dans la console des erreurs + * @param nod + */ + private static void messageSystem(node nod) { + node ouverture = nod.retourneFirstEnfantsByName("ouverture"); + node notation = nod.retourneFirstEnfantsByName("bodyetnotation"); + node erreurs = nod.retourneFirstEnfantsByName("erreurs"); + boolean flagError = Boolean.valueOf(erreurs.getAttributs().get("oneError")); + + System.out.println("\t Folder analyzed : " + ouverture.getAttributs().get("dossier")); + if(notation.getAttributs().get("baremeABC").equals("true")) { + System.out.println("\t Grade : " + notation.getAttributs().get("noteABC")); + }else { + System.out.println("\t Grade : " + notation.getAttributs().get("note") + "/" + ouverture.getAttributs().get("notefrom")); + } + + if(flagError) { + System.out.println("\t ERROR in student's file."); + if(Boolean.valueOf(erreurs.getAttributs().get("manqueHistorique"))) System.out.println("\t ERROR : There is no historic in the file. Perhaps, the file has not been modified or it has been reset by the student."); + if(Boolean.valueOf(erreurs.getAttributs().get("manqueCreationDate"))) System.out.println("\t ERROR : This is the wrong file creation date. The file has been reset or it is not the correct file."); + if(Boolean.valueOf(erreurs.getAttributs().get("manqueValeurCreationDate"))) System.out.println("\t ERROR : This is the wrong file creation date."); + + if(Boolean.valueOf(erreurs.getAttributs().get("manqueMetaSujet"))) System.out.println("\t ERROR : The metadata \"Sujet\" has been deleted in the student's file. It is impossible to identify the exercise."); + if(Boolean.valueOf(erreurs.getAttributs().get("manqueValeurMetaSujet"))) System.out.println("\t ERROR : The metadata value of \"Sujet \" in the student's file is not. \"" + ouverture.getAttributs().get("metaSujet")+"\""); + if(Boolean.valueOf(erreurs.getAttributs().get("manqueInitialCreator"))) System.out.println("\t ERROR : The initial creator value in the student's file is wrong. \"" + ouverture.getAttributs().get("metaSujet")+"\""); + } + System.out.println(); + } + + + /** + * Place au node le contenu saut de ligne
+ * Et place un titre1, ou titre2, ou titre3 + *
+ * @param nod + * @return + */ + private static node addNodeSautTitre(node nodSujet, node nodanalyse) { + if(nodSujet.getAttributs().get("saut")!=null) if(Boolean.valueOf(nodSujet.getAttributs().get("saut"))) { + if(nodSujet.getAttributs().get("titre")!=null) { + node N = new node(); + N.setNomElt("saut"); + N.getAttributs().put("titre", nodSujet.getAttributs().get("titre")); + N.setClose(true); + nodanalyse.getNodes().add(N); + } + if(nodSujet.getAttributs().get("titre2")!=null) { + node N = new node(); + N.setNomElt("saut"); + N.getAttributs().put("titre2", nodSujet.getAttributs().get("titre2")); + N.setClose(true); + nodanalyse.getNodes().add(N); + } + if(nodSujet.getAttributs().get("titre3")!=null) { + node N = new node(); + N.setNomElt("saut"); + N.getAttributs().put("titre3", nodSujet.getAttributs().get("titre3")); + N.setClose(true); + nodanalyse.getNodes().add(N); + } + } + return nodanalyse; + } + + /** + * Vérirication des historiques + * @param verification + * @param a + * @return le node verif + */ + private static node verificationHistorique(node verification, Run a) { + + + node verif = new node(); + verif.setNomElt("verification"); + verif.setAttributs(verification.getAttributs()); + verif.getAttributs().put("number_match", String.valueOf(commandes.number_match)); + verif.getAttributs().put("mini_number_modification", String.valueOf(commandes.mini_number_modification)); + verif.getAttributs().put("nombres_modifications_simultané_maxi", String.valueOf(commandes.nombres_modifications_simultané_maxi)); + + ArrayList LesFichiers = verification.retourneLesEnfantsByName("fichier", new ArrayList()); + + for(int i = 0 ; i < LesFichiers.size() ; i++) { + node nodStudent = new node(); + nodStudent.setNomElt("fichier"); + nodStudent.setAttributs(LesFichiers.get(i).getAttributs()); + + //String nameStudent1 = LesFichiers.get(i).getAttributs().get("dossier"); + + ArrayList HitoriqueDuFichier = LesFichiers.get(i).retourneEnfantsByName("text:changed-region", new ArrayList()); + int nombreModifications = HitoriqueDuFichier.size(); + + nodStudent.getAttributs().put("nombre_modification", String.valueOf(nombreModifications)); + + int compteurnombreCorrespondance = 0 ; + int compteurnombreCorrespondancesSuivi = 0; + int compteurnombreCorrespondancesconsecutive = 0; + + System.out.println(LesFichiers.get(i).getAttributs().get("dossier") + " - number of modifications : " + nombreModifications); + + @SuppressWarnings("unchecked") + ArrayList LesFichiers2 = (ArrayList) LesFichiers.clone(); + LesFichiers2.remove(i); + Dictionary lesdates = new Hashtable(); + + Date DateMini = null; //Première date de modification + + // Parcours toutes les modifications dans l'historique + for(int j = 0 ; j < HitoriqueDuFichier.size(); j++) { + + String dcdate1 = HitoriqueDuFichier.get(j).retourneFirstEnfantsByName("dc:date").getContenu(); + String dccreator = HitoriqueDuFichier.get(j).retourneFirstEnfantsByName("dc:creator").getContenu(); + + Date DcDate1 = DateLibreOffice(dcdate1); + + if(DateMini==null) DateMini = DcDate1; // Amorçage de la date premère date de modification + if(DateMini!=null && DateMini.after(DcDate1)) DateMini = DcDate1; //recherche la première date de modification + + + if(lesdates.get(dcdate1)==null) { + lesdates.put(dcdate1, 1); + }else { + int compteur = lesdates.get(dcdate1) + 1; + lesdates.put(dcdate1, compteur); + } + + + node N1 = HitoriqueDuFichier.get(j).getNodes().get(0); + + + for(int i2 = 0 ; i2 < LesFichiers2.size(); i2++) { + String nameStudent2 = LesFichiers2.get(i2).getAttributs().get("dossier"); + ArrayList HitoriqueDuFichier2 = LesFichiers2.get(i2).retourneEnfantsByName("text:changed-region", new ArrayList()); + for(int j2 = 0 ; j2 correspondances = nodStudent.retourneEnfantsByName("correspondance", new ArrayList()); + node c = correspondances.get(correspondances.size()-1); + if(c.getAttributs().get("Avec_etudiant").equals(nameStudent2)&&c.getAttributs().get("dc:creator").equals(dccreator2)) { + compteurnombreCorrespondancesSuivi++; + if(compteurnombreCorrespondancesconsecutive+1>compteurnombreCorrespondancesconsecutive) compteurnombreCorrespondancesconsecutive++; + }else { + compteurnombreCorrespondancesSuivi=0; + } + } + + node correspondance = new node(); + correspondance.getNodes().add(N2); + + correspondance.setNomElt("correspondance"); + correspondance.getAttributs().put("date", dcdate1); + correspondance.getAttributs().put("type",N1.getNomElt()); + correspondance.getAttributs().put("Avec_etudiant", nameStudent2); + correspondance.getAttributs().put("dc:creator", dccreator2); + nodStudent.getNodes().add(correspondance); + System.out.println("\t** Find a match ** " + dcdate1); + break; + } + } + } + } + } + + } + + Enumeration key = lesdates.keys(); + while(key.hasMoreElements()) { + String k = key.nextElement(); + if(lesdates.get(k)>1) { + node modificationsMemeDate = new node(); + modificationsMemeDate.setNomElt("memeinstant"); + modificationsMemeDate.getAttributs().put("date", k); + modificationsMemeDate.getAttributs().put("nombres_modifications_simultané", String.valueOf(lesdates.get(k))); + if(commandes.nombres_modifications_simultané_maxi0)compteurnombreCorrespondancesconsecutive++; //C'est histoire des arbres et des intervalles entre les arbres. Il faut ajouter plus 1 au nombre de correspondances consecutives. + + nodStudent.getAttributs().put("nombre_correspondance", String.valueOf(compteurnombreCorrespondance)); + nodStudent.getAttributs().put("nombre_modifications_date_unique", String.valueOf(lesdates.size())); + nodStudent.getAttributs().put("nombre_correspondances_consecutives", String.valueOf(compteurnombreCorrespondancesconsecutive)); + nodStudent.getAttributs().put("first_modification_date", String.valueOf(DateMini)); + + verif.getNodes().add(nodStudent); + System.out.println("\tDate de modification date unique " + String.valueOf(lesdates.size())); + + } + + // Ci-dessous le code pour vérifier la première date de modification dans le fichier. + // Recherche dans le node verif + int lastIndex = verif.getNodes().size(); + for(int i = 0 ; i < lastIndex;i++) { + String D1 = verif.getNodes().get(i).getAttributs().get("first_modification_date"); + boolean trouve =false; + for(int j = 0; j < lastIndex; j++) { + if(i!=j) { + String D2 = verif.getNodes().get(j).getAttributs().get("first_modification_date"); + if(!D1.equals("null") && D1.equals(D2)) { + if(verif.getNodes().get(i).getAttributs().get("")==null) { + verif.getNodes().get(i).getAttributs().put("first_modification_identique", verif.getNodes().get(j).getAttributs().get("dossier")); + }else { + verif.getNodes().get(i).getAttributs().put("first_modification_identique_2", verif.getNodes().get(j).getAttributs().get("dossier")); + } + if(verif.getNodes().get(j).getAttributs().get("")==null) { + verif.getNodes().get(j).getAttributs().put("first_modification_identique", verif.getNodes().get(i).getAttributs().get("dossier")); + }else { + verif.getNodes().get(j).getAttributs().put("first_modification_identique_2", verif.getNodes().get(i).getAttributs().get("dossier")); + } + trouve=true; + } + } + } + if(!trouve) { + verif.getNodes().get(i).getAttributs().put("first_modification_identique","null"); + }else { + verif.getNodes().get(i).getAttributs().put("plagiat", "probable"); + System.out.println("\t\t ************************"); + System.out.println("\t\t ** Plagiat PROBABLE **"); + System.out.println("\t\t ************************"); + } + } + + return verif; + + } + + /** + * Ecriture de l'ensemble des notes brutes sans vérification et sans rechercher les identifiants des étudiants + * @param nodesana + * @throws IOException + */ + private static void ecritureCSV(node ana) throws IOException{ + Date aujourdhui = new Date(); + Path outputFilePath = Paths.get(patch + "/DateLong" + aujourdhui.getTime()+ "-Notes.csv"); + if(commandes.fourniDossierDestination) outputFilePath = Paths.get(patch +"/"+ commandes.pathDestination + "/DateLong" + aujourdhui.getTime()+ "-Notes.csv"); + + if(!commandes.fourniDossierDestination) System.out.println(patch +"\\DateLong" + aujourdhui.getTime()+ "-Notes.csv"); + if(commandes.fourniDossierDestination) System.out.println(patch +"\\"+ commandes.pathDestination + "\\DateLong" + aujourdhui.getTime()+ "-Notes.csv"); + + BufferedWriter fichier = Files.newBufferedWriter(outputFilePath, StandardCharsets.UTF_8); + fichier.write("prénom nom;date modification;producteur;durée edition;sujet;note\n"); + + + for (int i = 0 ; i < ana.getNodes().size() ; i++) { + node nodouverture = ana.getNodes().get(i).retourneFirstEnfantsByName("ouverture"); + String identification = nodouverture.getAttributs().get("dossier"); + String sujet = nodouverture.getAttributs().get("metaSujet"); + String dateModif = nodouverture.getAttributs().get("dateModification"); + String producteur = nodouverture.getAttributs().get("producteur"); + String dureeEdition = nodouverture.getAttributs().get("dureeEdition"); + String note = ana.getNodes().get(i).retourneFirstEnfantsByName("bodyetnotation").getAttributs().get("note"); + if(nodouverture.getAttributs().get("baremeABC")!=null) { + try { + if(Boolean.valueOf(nodouverture.getAttributs().get("baremeABC"))) { + note = ana.getNodes().get(i).retourneFirstEnfantsByName("bodyetnotation").getAttributs().get("noteABC"); + } + }catch (Exception e) { + + } + } + fichier.write(identification + ";" + dateModif + ";" + producteur + ";" + traitementDureeEdition(dureeEdition) + ";"+ sujet + ";" + traitementNote(note) + "\n"); + + } + fichier.close(); + } + + /** + * Ecriture du fichier CSV avec vérification mais sans rechercher les identifiants des étudiants + * @param ana + * @param verif + * @param a + * @throws IOException + */ + private static void ecritureCSV(node ana, node verif, Run a, node setting) throws IOException{ + String separator =";"; //valeur par défaut du séparteur + + + Date aujourdhui = new Date(); + Path outputFilePath = Paths.get(patch + "/DateLong" + aujourdhui.getTime()+ "-Notes.csv"); + if(commandes.fourniDossierDestination) outputFilePath = Paths.get(patch +"/"+ commandes.pathDestination + "/DateLong" + aujourdhui.getTime()+ "-Notes.csv"); + + if(!commandes.fourniDossierDestination) System.out.println(patch +"\\DateLong" + aujourdhui.getTime()+ "-Notes.csv"); + if(commandes.fourniDossierDestination) System.out.println(patch +"\\"+ commandes.pathDestination + "\\DateLong" + aujourdhui.getTime()+ "-Notes.csv"); + + + + BufferedWriter fichier = Files.newBufferedWriter(outputFilePath, StandardCharsets.UTF_8); + fichier.write("prénom nom;date modification;producteur;durée edition;sujet;nbr modification;nbr modification date unique;nbr match;note\n"); + + for (int i = 0 ; i < ana.getNodes().size() ; i++) { + node nodouverture = ana.getNodes().get(i).retourneFirstEnfantsByName("ouverture"); + String identification = nodouverture.getAttributs().get("dossier"); + String sujet = nodouverture.getAttributs().get("metaSujet"); + String dateModif = nodouverture.getAttributs().get("dateModification"); + String producteur = nodouverture.getAttributs().get("producteur"); + String dureeEdition = nodouverture.getAttributs().get("dureeEdition"); + + node verifStudent = a.retourneNodeByNameAttributValueAttributValueExact(verif, "fichier", "dossier", identification, "dateModification", dateModif); + String note = "plagiat"; + if(verifStudent!=null) { + int nbreCorrespondance = Integer.valueOf(verifStudent.getAttributs().get("nombre_correspondance")); + int nbrDateModificationUnique = Integer.valueOf(verifStudent.getAttributs().get("nombre_modifications_date_unique")); + + if(nbreCorrespondance<=commandes.number_match) { + note = ana.getNodes().get(i).retourneFirstEnfantsByName("bodyetnotation").getAttributs().get("note"); + if(nodouverture.getAttributs().get("baremeABC")!=null) { + try { + if(Boolean.valueOf(nodouverture.getAttributs().get("baremeABC"))) { + note = ana.getNodes().get(i).retourneFirstEnfantsByName("bodyetnotation").getAttributs().get("noteABC"); + } + }catch (Exception e) { + + } + } + } + if(nbrDateModificationUnique + * @param ana + * @param verif + * @param a + * @param nodeCVS + * @param verification + * @throws IOException + */ + private static void ecritureCSV(node ana, node verif, Run a, node nodeCVS, node setting) throws IOException { + + String separator =";"; //valeur par défaut du séparteur + Charset encoding = StandardCharsets.UTF_8; //valeur par défaut + String champMoodleEmail = "adresse"; + String champMoodleNumeroEtudiant = "identification"; + String champPrenom = "prenom"; + String champNom= "nom"; + + if(setting.getNomElt().equals("setting")) { + if(setting.containElementByName("csv")){ + node csv = setting.retourneFirstEnfantsByName("csv"); + if(csv.getAttributs().get("separator")!=null)separator = csv.getAttributs().get("separator"); + if(csv.getAttributs().get("encoding")!=null) { + if(csv.getAttributs().get("encoding").equals("UFT-8")) encoding = StandardCharsets.UTF_8; + if(csv.getAttributs().get("encoding").equals("ISO-8859-1")) encoding = StandardCharsets.ISO_8859_1; + if(csv.getAttributs().get("encoding").equals("US-ASCII")) encoding = StandardCharsets.US_ASCII; + if(csv.getAttributs().get("encoding").equals("UTF-16")) encoding = StandardCharsets.UTF_16; + if(csv.getAttributs().get("encoding").equals("UTF-16BE")) encoding = StandardCharsets.UTF_16BE; + if(csv.getAttributs().get("encoding").equals("UTF-16LE")) encoding = StandardCharsets.UTF_16LE; + if(csv.containElementByName("import_moodle")) { + node import_moodle = csv.retourneFirstEnfantsByName("import_moodle"); + if(import_moodle.getAttributs().get("email")!=null) champMoodleEmail=import_moodle.getAttributs().get("email"); + if(import_moodle.getAttributs().get("id")!=null) champMoodleNumeroEtudiant=import_moodle.getAttributs().get("id"); + if(import_moodle.getAttributs().get("firstname")!=null) champPrenom=import_moodle.getAttributs().get("firstname"); + if(import_moodle.getAttributs().get("name")!=null) champNom=import_moodle.getAttributs().get("name"); + } + } + } + } + + + + Date aujourdhui = new Date(); + Path outputFilePath = Paths.get(patch + "/DateLong" + aujourdhui.getTime()+ "-Notes.csv"); + if(commandes.fourniDossierDestination) outputFilePath = Paths.get(patch +"/"+ commandes.pathDestination + "/DateLong" + aujourdhui.getTime()+ "-Notes.csv"); + + if(!commandes.fourniDossierDestination) System.out.println(patch +"\\DateLong" + aujourdhui.getTime()+ "-Notes.csv"); + if(commandes.fourniDossierDestination) System.out.println(patch +"\\"+ commandes.pathDestination + "\\DateLong" + aujourdhui.getTime()+ "-Notes.csv"); + + BufferedWriter fichier = Files.newBufferedWriter(outputFilePath, encoding); + fichier.write("prénom nom"+separator+"email"+separator+"identifiant"+separator+"date modification"+separator+"producteur"+separator+"durée edition"+separator+"sujet"+separator+"nbr modification" + separator + "nbr modifications date unique" + separator+ "nbr match consecutif" + separator +"note" + separator +"commentaire\n"); + + for (int i = 0 ; i < ana.getNodes().size() ; i++) { + node nodouverture = ana.getNodes().get(i).retourneFirstEnfantsByName("ouverture"); + node bodyetnotation = ana.getNodes().get(i).retourneFirstEnfantsByName("bodyetnotation"); + String identification = nodouverture.getAttributs().get("dossier"); + String sujet = nodouverture.getAttributs().get("metaSujet"); + String dateModif = nodouverture.getAttributs().get("dateModification"); + String producteur = nodouverture.getAttributs().get("producteur"); + String dureeEdition = nodouverture.getAttributs().get("dureeEdition"); + String mail = "-"; + String numeroEtudiant = "-"; + + node verifStudent = null; + + if(commandes.verifHisto2) verifStudent = a.retourneNodeByNameAttributValueAttributValueExact(verif, "fichier", "dossier", identification, "dateModification", dateModif); + String note = ""; + + // rechercher les correspondances avec le prénom et le nom de l'étudiant + String[] ident = identification.split(" "); //séparateur entre le prénom et le nom par un espace + node A=null; + if(ident.length==2) { + A = a.retourneNodeByNameAttributValueAttributValueExact(nodeCVS, "student", champPrenom, ident[0], champNom, ident[1]); + if(A!=null) { + mail = A.getAttributs().get("\"" + champMoodleEmail + "\""); + if(mail==null) mail = A.getAttributs().get("'"+ champMoodleEmail +"'"); + if(mail==null) mail = A.getAttributs().get(champMoodleEmail); + numeroEtudiant = A.getAttributs().get("\"" + champMoodleNumeroEtudiant + "\""); + if(numeroEtudiant==null) numeroEtudiant = A.getAttributs().get("'" + champMoodleNumeroEtudiant + "'"); + if(numeroEtudiant==null) numeroEtudiant = A.getAttributs().get(champMoodleNumeroEtudiant); + } + } + if(ident.length==3) { + A = a.retourneNodeByNameAttributValueAttributValueExact(nodeCVS, "student", champPrenom, "\"" + ident[0] + " " + ident[1] +"\"", champNom, ident[2]); + if(A!=null) { + mail = A.getAttributs().get("\"" + champMoodleEmail + "\""); + if(mail==null) mail = A.getAttributs().get("'"+ champMoodleEmail +"'"); + if(mail==null) mail = A.getAttributs().get(champMoodleEmail); + numeroEtudiant = A.getAttributs().get("\"" + champMoodleNumeroEtudiant + "\""); + if(numeroEtudiant==null) numeroEtudiant = A.getAttributs().get("'" + champMoodleNumeroEtudiant + "'"); + if(numeroEtudiant==null) numeroEtudiant = A.getAttributs().get(champMoodleNumeroEtudiant); + } + if(A==null) { + A = a.retourneNodeByNameAttributValueAttributValueExact(nodeCVS, "student", champPrenom, ident[0], champNom, "\"" +ident[1] + " " + ident[2] + "\""); + if(A!=null) { + mail = A.getAttributs().get("\"" + champMoodleEmail + "\""); + if(mail==null) mail = A.getAttributs().get("'"+ champMoodleEmail +"'"); + if(mail==null) mail = A.getAttributs().get(champMoodleEmail); + numeroEtudiant = A.getAttributs().get("\"" + champMoodleNumeroEtudiant + "\""); + if(numeroEtudiant==null) numeroEtudiant = A.getAttributs().get("'" + champMoodleNumeroEtudiant + "'"); + if(numeroEtudiant==null) numeroEtudiant = A.getAttributs().get(champMoodleNumeroEtudiant); + } + } + } + if(ident.length==4) { + A = a.retourneNodeByNameAttributValueAttributValueExact(nodeCVS, "student", champPrenom, ident[0], champNom, "\"" + ident[1] + " " + ident[2] + " " + ident[3] + "\""); + if(A!=null) { + mail = A.getAttributs().get("\"" + champMoodleEmail + "\""); + if(mail==null) mail = A.getAttributs().get("'"+ champMoodleEmail +"'"); + if(mail==null) mail = A.getAttributs().get(champMoodleEmail); + numeroEtudiant = A.getAttributs().get("\"" + champMoodleNumeroEtudiant + "\""); + if(numeroEtudiant==null) numeroEtudiant = A.getAttributs().get("'" + champMoodleNumeroEtudiant + "'"); + if(numeroEtudiant==null) numeroEtudiant = A.getAttributs().get(champMoodleNumeroEtudiant); + } + if(A==null) { + A = a.retourneNodeByNameAttributValueAttributValueExact(nodeCVS, "student", champPrenom, "\"" + ident[0] + " " + ident[1] +"\"", champNom, "\"" + ident[2] + " " + ident[3] + "\""); + if(A!=null) { + mail = A.getAttributs().get("\"" + champMoodleEmail + "\""); + if(mail==null) mail = A.getAttributs().get("'"+ champMoodleEmail +"'"); + if(mail==null) mail = A.getAttributs().get(champMoodleEmail); + numeroEtudiant = A.getAttributs().get("\"" + champMoodleNumeroEtudiant + "\""); + if(numeroEtudiant==null) numeroEtudiant = A.getAttributs().get("'" + champMoodleNumeroEtudiant + "'"); + if(numeroEtudiant==null) numeroEtudiant = A.getAttributs().get(champMoodleNumeroEtudiant); + } + } + if(A==null) { + A = a.retourneNodeByNameAttributValueAttributValueExact(nodeCVS, "student", champPrenom, "\"" + ident[0] + " " + ident[1] + ident[2] + "\"", champNom, ident[3]); + if(A!=null) { + mail = A.getAttributs().get("\"" + champMoodleEmail + "\""); + if(mail==null) mail = A.getAttributs().get("'"+ champMoodleEmail +"'"); + if(mail==null) mail = A.getAttributs().get(champMoodleEmail); + numeroEtudiant = A.getAttributs().get("\"" + champMoodleNumeroEtudiant + "\""); + if(numeroEtudiant==null) numeroEtudiant = A.getAttributs().get("'" + champMoodleNumeroEtudiant + "'"); + if(numeroEtudiant==null) numeroEtudiant = A.getAttributs().get(champMoodleNumeroEtudiant); + } + } + } + + + if(commandes.verifHisto2) if(verifStudent!=null) { + int nbreCorrespondanceConsecutive = Integer.valueOf(verifStudent.getAttributs().get("nombre_correspondances_consecutives")); + int nbrDateModificationUnique = Integer.valueOf(verifStudent.getAttributs().get("nombre_modifications_date_unique")); + note = bodyetnotation.getAttributs().get("note"); + if(bodyetnotation.getAttributs().get("baremeABC")!=null) { + try { + if(Boolean.valueOf(bodyetnotation.getAttributs().get("baremeABC"))) { + note = bodyetnotation.getAttributs().get("noteABC"); + } + }catch (Exception e) { + + } + } + if(nbreCorrespondanceConsecutive>commandes.number_match) { + bodyetnotation.getAttributs().put("commentaire","Echange de fichier - plagiat"); + note = "0" ; + } + if(nbrDateModificationUnique<=commandes.mini_number_modification) { + bodyetnotation.getAttributs().put("commentaire","pas assez de modification."); + note="0"; + } + if(!verifStudent.getAttributs().get("first_modification_identique").equals("null") && nbreCorrespondanceConsecutive>=commandes.number_match) { + note = "0" ; + bodyetnotation.getAttributs().put("commentaire","Echange de fichier - plagiat"); + } + if(verifStudent.getAttributs().get("copier_coller")!=null){ + bodyetnotation.getAttributs().put("commentaire","des copiés et des collés"); + } + String nbrModification = verifStudent.getAttributs().get("nombre_modification"); + String nombre_modifications_date_unique = verifStudent.getAttributs().get("nombre_modifications_date_unique"); + + fichier.write(identification + separator + mail + separator + numeroEtudiant + separator + dateModif + separator + producteur + separator + traitementDureeEdition(dureeEdition) + separator + sujet + separator + nbrModification +separator + nombre_modifications_date_unique + separator + nbreCorrespondanceConsecutive + separator + traitementNote(note) + separator + bodyetnotation.getAttributs().get("commentaire")+"\n"); + } + + if(!commandes.verifHisto2) { + note = bodyetnotation.getAttributs().get("note"); + if(bodyetnotation.getAttributs().get("baremeABC")!=null) { + try { + if(Boolean.valueOf(bodyetnotation.getAttributs().get("baremeABC"))) { + note = bodyetnotation.getAttributs().get("noteABC"); + } + }catch (Exception e) { + + } + } + fichier.write(identification + separator + mail + separator + numeroEtudiant + separator + dateModif + separator + producteur + separator + traitementDureeEdition(dureeEdition) + separator + sujet + separator + "" + separator + "" + "" + separator + "" + separator + traitementNote(note) + separator + bodyetnotation.getAttributs().get("commentaire")+"\n"); + } + + + } + fichier.close(); + } + + /** + * Traitement de la durée d'édition.
+ *
+ * @param dureeEdition + * @return + */ + private static String traitementDureeEdition(String dureeEdition) { + dureeEdition = dureeEdition.replace("P", ""); + dureeEdition = dureeEdition.replace("D", " j "); + dureeEdition = dureeEdition.replace("T", " "); + dureeEdition = dureeEdition.replace("H", " h "); + dureeEdition = dureeEdition.replace("M", " min "); + dureeEdition = dureeEdition.replace("S", " s"); + return dureeEdition; + } + + /** + * Remplace la virgule par un point.
+ *
+ * @param note + * @return + */ + private static String traitementNote(String note) { + if(note==null) return note; + note = note.replace(",", "."); + return note; + } + + /** + * + * @param libreoffice_date + * @return + */ + private static Date DateLibreOffice(String libreoffice_date){ + boolean contientHeure = false; + if(libreoffice_date.contains("T")) { + libreoffice_date=libreoffice_date.replace("T", " "); + contientHeure=true; + } + SimpleDateFormat simpledateformat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + Date d = null; + if(!contientHeure) simpledateformat = new SimpleDateFormat("yyyy-MM-dd"); + + try { + d = simpledateformat.parse(libreoffice_date); + }catch(ParseException e) { + e.printStackTrace(); + } + + return d; + } + + + /** + * Chargement dans un node du fichier CSV de la liset des étudiants.
+ * La liste des étudiants doit contenir les champs Prénom, Nom, Numéro d'identification, Adresse de courriel + * Le séparateur doit être le point-virgule et l'encodage UTF-8 + * @param a + * @param nameCSV + * @return + * @throws IOException + */ + private static node chargementFichierCSV(Run a, String nameCSV) { + String targetString = ""; + try { + BufferedReader br = new BufferedReader( + new InputStreamReader( + new FileInputStream(a.getPatch() + "/" + nameCSV), "UTF-8")); + + String line; + while ((line = br.readLine()) != null) { + targetString = targetString + line + "\n"; + } + + br.close(); + } catch (IOException e) { + commandes.clotureWithErrorFile(nameCSV); + e.printStackTrace(); + } + + + String[] target = targetString.split("\\n"); + node nodeCVS = new node(); + nodeCVS.setNomElt("fileCSV"); + String[] line1 = target[0].split(";"); + for(int i = 1 ; i < target.length ; i++) { + node nodeEtudiant = new node(); + nodeEtudiant.setNomElt("student"); + for(int j = 0 ; j < line1.length; j++) { + nodeEtudiant.getAttributs().put(line1[j], target[i].split(";")[j]); + } + nodeCVS.getNodes().add(nodeEtudiant); + } + //a.ecritureNodeEnXML(nodeCVS, "nodeCVS"); //écriture du node du node CSV + return nodeCVS; + } + + /** + * Charge le fichier SVG pour le nouveau Logo dans les feedbacks + * @param a + * @param nameSVG + * @return + */ + private static String chargementFichierSVG(Run a, String nameSVG) { + String targetString = ""; + try { + BufferedReader br = new BufferedReader( + new InputStreamReader( + new FileInputStream(a.getPatch() + "/" + nameSVG), "UTF-8")); + + String line; + while ((line = br.readLine()) != null) { + targetString = targetString + line + "\n"; + } + + br.close(); + } catch (IOException e) { + commandes.clotureWithErrorFile(nameSVG); + e.printStackTrace(); + } + return targetString; + } + + /** + * Ajoute les valeurs par défauts pour les styles de paragraphes.
+ *
+ * @param LesStyleStudents : Tous les styles de paragraphes du fichiers de l'étudiants. + * @param styleParagraph : le node dont il faut ajouter les valerus par défauts. + * @return le node styleParagraph. + */ + private static node ajouteValeurParDefautAuStyleParagraph(node ensembleDesParagraphes , node styleParagraph) { + + node LesStyleDefaut = null; + + if(ensembleDesParagraphes.retourneEnfantsByNameExist("style:default-style")) { + LesStyleDefaut = ensembleDesParagraphes.retourneFirstEnfantsByName("style:default-style"); + } + + if(LesStyleDefaut!=null && styleParagraph!=null) { + + //le paragarph properties + node nodeStyleParDefautParagraphProperties = LesStyleDefaut.retourneFirstEnfantsByName("style:paragraph-properties"); + node LesNodesStyleParagraph = styleParagraph.retourneFirstEnfantsByName("style:paragraph-properties"); + Enumeration K = nodeStyleParDefautParagraphProperties.getAttributs().keys(); + while(K.hasMoreElements()){ + String Key = K.nextElement(); + if(LesNodesStyleParagraph.getNomElt().equals("style:paragraph-properties")) { + if(LesNodesStyleParagraph.getAttributs().get(Key)==null) { + LesNodesStyleParagraph.getAttributs().put(Key, nodeStyleParDefautParagraphProperties.getAttributs().get(Key)); + } + }else { + node n = new node(); + n.setNomElt("style:paragraph-properties"); + n.setAttributs(nodeStyleParDefautParagraphProperties.getAttributs()); + styleParagraph.getNodes().add(n); + break; + } + } + + //le text properties + node nodeStyleParDefautTextProperties = LesStyleDefaut.retourneFirstEnfantsByName("style:text-properties"); + node LesNodesStyleText = styleParagraph.retourneFirstEnfantsByName("style:text-properties"); + K = nodeStyleParDefautTextProperties.getAttributs().keys(); + while(K.hasMoreElements()){ + String Key = K.nextElement(); + if(LesNodesStyleText.getNomElt().equals("style:text-properties")) { + if(LesNodesStyleText.getAttributs().get(Key)==null) { + LesNodesStyleText.getAttributs().put(Key, nodeStyleParDefautTextProperties.getAttributs().get(Key)); + } + }else { + node n = new node(); + n.setNomElt("style:text-properties"); + n.setAttributs(nodeStyleParDefautTextProperties.getAttributs()); + styleParagraph.getNodes().add(n); + break; + } + } + + + + } + return styleParagraph; + } + + /** + * Même méthode que "ajouteValeurParDefautAuStyleParagraph".
+ *
+ * @param ensembleDesParagraphes + * @param styleParagraph + * @return + */ + private static node ajouteValeurLesValeursDuStyleParagraphParent(node ensembleDesParagraphes , node styleParagraph) { + + node parent = null; + if(styleParagraph.getAttributs().get("style:parent-style-name")!=null) { + String nameStyleParent = styleParagraph.getAttributs().get("style:parent-style-name"); + if(ensembleDesParagraphes.retourneFirstNodeByNameAndAttributValue("style:style", "style:name", nameStyleParent)!=null) { + parent = ensembleDesParagraphes.retourneFirstNodeByNameAndAttributValue("style:style", "style:name", nameStyleParent); + } + } + + + if(parent!=null) { + + //le paragarph properties + node nodeStyleParDefautParagraphProperties = parent.retourneFirstEnfantsByName("style:paragraph-properties"); + node LesNodesStyleParagraph = styleParagraph.retourneFirstEnfantsByName("style:paragraph-properties"); + Enumeration K = nodeStyleParDefautParagraphProperties.getAttributs().keys(); + while(K.hasMoreElements()){ + String Key = K.nextElement(); + if(LesNodesStyleParagraph.getNomElt().equals("style:paragraph-properties")) { + if(LesNodesStyleParagraph.getAttributs().get(Key)==null) { + LesNodesStyleParagraph.getAttributs().put(Key, nodeStyleParDefautParagraphProperties.getAttributs().get(Key)); + } + }else { + node n = new node(); + n.setNomElt("style:paragraph-properties"); + n.setAttributs(nodeStyleParDefautParagraphProperties.getAttributs()); + styleParagraph.getNodes().add(n); + break; + } + } + + //le text properties + node nodeStyleParDefautTextProperties = parent.retourneFirstEnfantsByName("style:text-properties"); + node LesNodesStyleText = styleParagraph.retourneFirstEnfantsByName("style:text-properties"); + K = nodeStyleParDefautTextProperties.getAttributs().keys(); + while(K.hasMoreElements()){ + String Key = K.nextElement(); + if(LesNodesStyleText.getNomElt().equals("style:text-properties")) { + if(LesNodesStyleText.getAttributs().get(Key)==null) { + LesNodesStyleText.getAttributs().put(Key, nodeStyleParDefautTextProperties.getAttributs().get(Key)); + } + }else { + node n = new node(); + n.setNomElt("style:text-properties"); + n.setAttributs(nodeStyleParDefautTextProperties.getAttributs()); + styleParagraph.getNodes().add(n); + break; + } + } + } + return styleParagraph; + } + + + private static node addAttributsAnalyseWriter(node noPourPlacerEvaluer, String nameNodeRacine) { + ArrayList no = noPourPlacerEvaluer.retourneEnfantsByName(nameNodeRacine, new ArrayList()); + for(int j = 0 ; j < no.size(); j++) { + noPourPlacerEvaluer.getNodes().remove(no.get(j)); + no.get(j).getAttributs().put("saut", "false"); + no.get(j).getAttributs().put("evaluer", "false"); + no.get(j).getAttributs().put("titre", ""); + no.get(j).getAttributs().put("styletitre", "nostyle"); + ArrayList no1 = no.get(j).getNodes(); + for(int k=0 ; k < no1.size(); k++) { + no1.get(k).getAttributs().put("evaluer", "false"); + if(listeDesNodesAvecEvalNode(no1.get(k).getNomElt())) no1.get(k).getAttributs().put("evalNameNode", "0"); + if(listeDesNodesSautEtTitre(no1.get(k).getNomElt())) {no1.get(k).getAttributs().put("saut", "false"); no1.get(k).getAttributs().put("titre", ""); no1.get(k).getAttributs().put("styletitre", "nostyle");} + if(listeDesNodesRecherche(no1.get(k).getNomElt())) {no1.get(k).getAttributs().put("recherche_index", "false"); no1.get(k).getAttributs().put("recherche_contenu_exact", "false");} + if(listeDesNodesAnalyseStyle(no1.get(k).getNomElt())) no1.get(k).getAttributs().put("analyseStyle", "false"); + + ArrayList no2 = no1.get(k).getNodes(); + for(int l=0 ; l < no2.size(); l++) { + no2.get(l).getAttributs().put("evaluer", "false"); + if(listeDesNodesAvecEvalNode(no2.get(l).getNomElt())) no2.get(l).getAttributs().put("evalNameNode", "0"); + if(listeDesNodesSautEtTitre(no2.get(l).getNomElt())) {no2.get(l).getAttributs().put("saut", "false"); no2.get(l).getAttributs().put("titre", "");no2.get(l).getAttributs().put("styletitre", "nostyle");} + if(listeDesNodesRecherche(no2.get(l).getNomElt())) {no2.get(l).getAttributs().put("recherche_index", "false"); no2.get(l).getAttributs().put("recherche_contenu_exact", "false");} + if(listeDesNodesAnalyseStyle(no2.get(l).getNomElt())) no2.get(l).getAttributs().put("analyseStyle", "false"); + + ArrayList no3 = no2.get(l).getNodes(); + for(int m=0 ; m < no3.size(); m++) { + no3.get(m).getAttributs().put("evaluer", "false"); + if(listeDesNodesAvecEvalNode(no3.get(m).getNomElt())) no3.get(m).getAttributs().put("evalNameNode", "0"); + if(listeDesNodesSautEtTitre(no3.get(m).getNomElt())) {no3.get(m).getAttributs().put("saut", "false"); no3.get(m).getAttributs().put("titre", "");no3.get(m).getAttributs().put("styletitre", "nostyle");} + if(listeDesNodesRecherche(no3.get(m).getNomElt())) {no3.get(m).getAttributs().put("recherche_index", "false"); no3.get(m).getAttributs().put("recherche_contenu_exact", "false");} + if(listeDesNodesAnalyseStyle(no3.get(m).getNomElt())) no3.get(m).getAttributs().put("analyseStyle", "false"); + + ArrayList no4 = no3.get(m).getNodes(); + for(int n=0 ; n < no4.size(); n++) { + no4.get(n).getAttributs().put("evaluer", "false"); + if(listeDesNodesAvecEvalNode(no4.get(n).getNomElt())) no4.get(n).getAttributs().put("evalNameNode", "0"); + if(listeDesNodesSautEtTitre(no4.get(n).getNomElt())) {no4.get(n).getAttributs().put("saut", "false"); no4.get(n).getAttributs().put("titre", "");no4.get(n).getAttributs().put("styletitre", "nostyle");} + if(listeDesNodesRecherche(no4.get(n).getNomElt())) {no4.get(n).getAttributs().put("recherche_index", "false"); no4.get(n).getAttributs().put("recherche_contenu_exact", "false");} + if(listeDesNodesAnalyseStyle(no4.get(n).getNomElt())) no4.get(n).getAttributs().put("analyseStyle", "false"); + + } + } + } + } + } + noPourPlacerEvaluer.getNodes().addAll(no); + return noPourPlacerEvaluer; + } + + private static boolean listeDesNodesAvecEvalNode(String nameNode) { + if(nameNode.contains("meta:")) return true; + if(nameNode.contains("dc:")) return true; + if(nameNode.contains("text:")) return true; + return false; + } + + private static boolean listeDesNodesSautEtTitre(String nameNode) { + if(nameNode.contains("meta:")) return true; + if(nameNode.contains("dc:")) return true; + if(nameNode.contains("style:")) return true; + if(nameNode.contains("text:")) return true; + return false; + } + + private static boolean listeDesNodesRecherche(String nameNode) { + if(nameNode.contains("text:")) return true; + return false; + } + + private static boolean listeDesNodesAnalyseStyle(String nameNode) { + if(nameNode.equals("text:p")) return true; + if(nameNode.equals("text:span")) return true; + return false; + } + + /** + * Ce node permet la configuration personnalisé de l'application.
+ * Ajoute le node setting avec les différentes valeurs.
+ * + * @param sujet Le node du sujet. + * @return Le node du sujet avec le node setting ajouté. + */ + private static node addSetting(node sujet) { + //node setting + node setting = new node(); + setting.setNomElt("setting"); + setting.getAttributs().put("culture","FR"); + + + //node csv + node csv = new node(); + csv.setNomElt("csv"); + csv.getAttributs().put("encoding", "UTF-8"); + csv.getAttributs().put("separator", ";"); + csv.setContenu("choose the encoding from this list : UTF-8 US-ASCII ISO-8859-1 UTF-16BE UTF-16LE UTF-16"); + csv.setClose(true); + + //node export du csv + node export = new node(); + export.setNomElt("import_moodle"); + export.getAttributs().put("email", "adresse"); + export.getAttributs().put("id", "identification"); + export.getAttributs().put("firstname", "prenom"); + export.getAttributs().put("name", "nom"); + export.setClose(true); + + //node taille zip + node zip = new node(); + zip.setNomElt("zip"); + zip.getAttributs().put("size", "48000000"); + zip.getAttributs().put("nameZip", "feedbackMoodle"); + zip.isClose(); + + //node verif + node plagiarism = new node(); + plagiarism.setNomElt("plagiarism"); + plagiarism.getAttributs().put("number_match", "2"); + plagiarism.getAttributs().put("mini_number_modification", "-1"); + plagiarism.getAttributs().put("nombres_modifications_simultané_maxi", "100"); + plagiarism.setClose(true); + + //construction node similitude + node similarity = new node(); + similarity.setNomElt("text:similarity"); + similarity.getAttributs().put("tolerance_characters", "5"); + similarity.getAttributs().put("tolerance_text", "0.79"); + similarity.setClose(true); + + //node color + node color = new node(); + color.setNomElt("color"); + color.getAttributs().put("tolerance_rouge", "30"); + color.getAttributs().put("tolerance_vert", "30"); + color.getAttributs().put("tolerance_bleu", "30"); + color.setClose(true); + + //construction du node setting + csv.getNodes().add(export); + setting.getNodes().add(csv); + setting.getNodes().add(zip); + setting.getNodes().add(plagiarism); + setting.getNodes().add(similarity); + setting.getNodes().add(color); + + //ajoute la node translation + setting.getNodes().add(Run.translation()); + + + // ajoute le node setting au node sujet + sujet.getNodes().add(setting); + + //fermeture du node + setting.setClose(true); + + return sujet; + } + + /** + * recherche en cascade des nodes en fonction de leur contenu. + * @param nameNode : nom du node + * @param nodSujet : nod sujet + * @param nod0Student : node contenant le node nod1Student + * @param nod1Student : node contenant le node nod2Student. + * @param nod2Student : node de niveau le plus haut. + * @param a : Run cXML + * @return : le node recherché + */ + private static node rechercheLeNodeEnCascade(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a ) { + + node nodStudent =null; + // recherche le node uniquement par son contenu et pas celui de ses enfants + if(nodSujet.getAttributs().get("recherche_contenu_exact")!=null){ + if(nodSujet.getAttributs().get("recherche_index")!=null) { + if(nodSujet.getAttributs().get("recherche_contenu_exact").equals("true") && nodSujet.getAttributs().get("recherche_index").equals("false") ) { + String valueAttribut = outils.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getContenu()); + if(nod2Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContentExact(nod2Student.getNodes(), valueAttribut); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContentExact(nod1Student.getNodes(), valueAttribut); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContentExact(nod0Student.getNodes(), valueAttribut); + if(nodStudent!=null) {return nodStudent;}else {return null;} + } + if(nodSujet.getAttributs().get("recherche_contenu_exact").equals("true") && nodSujet.getAttributs().get("recherche_index").equals("true") && nodSujet.getAttributs().get("index")!=null ) { + String valueAttribut = outils.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getContenu()); + String indexSujet = nodSujet.getAttributs().get("index"); + + if(!valueAttribut.isEmpty()&&!indexSujet.isEmpty()) { + if(nod2Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContentExact(nod2Student.getNodes(), valueAttribut); + if(nodStudent!=null) if(nodStudent.getAttributs().get("index").equals(indexSujet)) {return nodStudent;}else {nodStudent=null;} + + if(nod1Student!=null) if(nodStudent==null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContentExact(nod1Student.getNodes(), valueAttribut); + if(nodStudent!=null) if(nodStudent.getAttributs().get("index").equals(indexSujet)) {return nodStudent;}else {nodStudent=null;} + + if(nod0Student!=null) if(nodStudent==null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContentExact(nod0Student.getNodes(), valueAttribut); + if(nodStudent!=null) if(nodStudent.getAttributs().get("index").equals(indexSujet)) {return nodStudent;}else {nodStudent=null;} + } + } + }else { + if(nodSujet.getAttributs().get("recherche_contenu_exact").equals("true")) { + String valueAttribut = outils.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getContenu()); + if(nod2Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContentExact(nod2Student.getNodes(), valueAttribut); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContentExact(nod1Student.getNodes(), valueAttribut); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContentExact(nod0Student.getNodes(), valueAttribut); + if(nodStudent!=null) {return nodStudent;}else {return null;} + } + } + } + + // recherche le node par index uniquement + if(nodSujet.getAttributs().get("recherche_index")!=null){ + if(nodSujet.getAttributs().get("recherche_index").equals("true")) { + String valueAttribut = nodSujet.getAttributs().get("index"); + if(nod2Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student.getNodes(), nodSujet.getNomElt(),"index",valueAttribut); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student.getNodes(), nodSujet.getNomElt(),"index",valueAttribut); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student.getNodes(), nodSujet.getNomElt(),"index",valueAttribut); + if(nodStudent!=null) {return nodStudent;}else {return null;} + } + } + + + + // recherche par différent contenu du node + if(nameNode.equals("text:p")) { + //si le node "text:p" contient un "text:user-defined" alors le recherche par le "text:name" de ce node "text:user-defined" + if(nodSujet.containElementByName("text:user-defined")) { + String valueAttribut = outils.withoutCodeAndPoint(nodSujet.retourneFirstEnfantsByName("text:user-defined").getAttributs().get("text:name")); + if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:user-defined", "text:name", valueAttribut); + if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:user-defined", "text:name", valueAttribut); + if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:user-defined", "text:name", valueAttribut); + } + //si le node "text:p" contient un "text:conditional-text" alors le recherche par le "text:condition" de ce node "text:conditional-text" + if(nodSujet.containElementByName("text:conditional-text")) { + String valueAttribut = outils.withoutCodeAndPoint(nodSujet.retourneFirstEnfantsByName("text:conditional-text").getAttributs().get("text:condition")); + if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:conditional-text", "text:condition", valueAttribut); + if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:conditional-text", "text:condition", valueAttribut); + if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:conditional-text", "text:condition", valueAttribut); + } + //si le node "text:p" contient un "text:database-display" alors le recherche par le "text:column-name" de ce node "text:database-display" + if(nodSujet.containElementByName("text:database-display")) { + String valueAttribut = outils.withoutCodeAndPoint(nodSujet.retourneFirstEnfantsByName("text:database-display").getAttributs().get("text:column-name")); + if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:database-display", "text:column-name", valueAttribut); + if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:database-display", "text:column-name", valueAttribut); + if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:database-display", "text:column-name", valueAttribut); + } + //si le node "text:p" contient un "text:date" alors le recherche par le "text:fixed" de ce node "text:date" + if(nodSujet.containElementByName("text:date")) { + String valueAttribut = outils.withoutCodeAndPoint(nodSujet.retourneFirstEnfantsByName("text:date").getAttributs().get("text:fixed")); + if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:date", "text:fixed", valueAttribut); + if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:date", "text:fixed", valueAttribut); + if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:date", "text:fixed", valueAttribut); + } + if(nodSujet.containElementByName("text:subject")) { + if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:subject"); + if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:subject"); + if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:subject"); + } + if(nodSujet.containElementByName("text:title")) { + if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:title"); + if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:title"); + if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:title"); + } + if(nodSujet.containElementByName("text:initial-creator")) { + if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:initial-creator"); + if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:initial-creator"); + if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:initial-creator"); + } + if(nodSujet.containElementByName("text:creator")) { + if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:creator"); + if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:creator"); + if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:creator"); + } + if(nodStudent==null) { + if(nodSujet.retourneLesContenusEnfants("").isEmpty()) { //s'il n'y a pas de contenu, passe par l'index + if(nodSujet.getAttributs().get("index")!=null) { + if(nod2Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode, "index", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("index"))); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student, nameNode, "index", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("index"))); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student, nameNode, "index", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("index"))); + } + }else { + if(nod2Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContent2(nod2Student.getNodes(), nodSujet.retourneLesContenusEnfants(""),commandes.tolerance_characters,commandes.tolerance_text); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContent2(nod1Student.getNodes(), nodSujet.retourneLesContenusEnfants(""),commandes.tolerance_characters,commandes.tolerance_text); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContent2(nod0Student.getNodes(), nodSujet.retourneLesContenusEnfants(""),commandes.tolerance_characters,commandes.tolerance_text); + } + } + } + + if(nameNode.equals("text:title")) { + if(nod2Student!=null) nodStudent = nod2Student.retourneFirstEnfantsByName("text:title"); + if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstEnfantsByName("text:title"); + if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstEnfantsByName("text:title"); + return nodStudent; + } + + if(nameNode.equals("text:subject")) { + if(nod2Student!=null) nodStudent = nod2Student.retourneFirstEnfantsByName("text:subject"); + if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstEnfantsByName("text:subject"); + if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstEnfantsByName("text:subject"); + } + + if(nameNode.equals("text:initial-creator")) { + if(nod2Student!=null) nodStudent = nod2Student.retourneFirstEnfantsByName("text:initial-creator"); + if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstEnfantsByName("text:initial-creator"); + if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstEnfantsByName("text:initial-creator"); + } + + if(nameNode.equals("text:user-defined")) { + if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode, "text:name", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("text:name"))); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student, nameNode, "text:name", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("text:name"))); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student, nameNode, "text:name", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("text:name"))); + } + + + //recherche par le contenu enfant du node + if(nameNode.equals("text:h")) { + if(nod2Student!=null) nodStudent = a.retourneFirstNodeByFindContent2(nod2Student.getNodes(), nodSujet.retourneLesContenusEnfants(""),commandes.tolerance_characters,commandes.tolerance_text); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContent2(nod1Student.getNodes(), nodSujet.retourneLesContenusEnfants(""),commandes.tolerance_characters,commandes.tolerance_text); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContent2(nod0Student.getNodes(), nodSujet.retourneLesContenusEnfants(""),commandes.tolerance_characters,commandes.tolerance_text); + } + + //recherche par text:name + if(nameNode.equals("text:section")) { + if(nodSujet.getAttributs().get("recherche_index")==null) { + if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValueNetTexte(nod2Student, nameNode, "text:name", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("text:name"))); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValueNetTexte(nod1Student, nameNode, "text:name", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("text:name"))); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValueNetTexte(nod0Student, nameNode, "text:name", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("text:name"))); + }else { + if(nodSujet.getAttributs().get("recherche_index").equals("false")) { + if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValueNetTexte(nod2Student, nameNode, "text:name", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("text:name"))); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValueNetTexte(nod1Student, nameNode, "text:name", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("text:name"))); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValueNetTexte(nod0Student, nameNode, "text:name", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("text:name"))); + } + if(nodSujet.getAttributs().get("recherche_index").equals("true")) { + if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValueNetTexte(nod2Student, nameNode, "index", nodSujet.getAttributs().get("index")); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValueNetTexte(nod1Student, nameNode, "index", nodSujet.getAttributs().get("index")); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValueNetTexte(nod0Student, nameNode, "index", nodSujet.getAttributs().get("index")); + } + } + } + + //recherche par le nom de la colonne + if(nameNode.equals("text:database-display")) { + if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode, "text:column-name", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("text:column-name"))); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student, nameNode, "text:column-name", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("text:column-name"))); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student, nameNode, "text:column-name", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("text:column-name"))); + } + + //recherche par le nom de l'objet draw:name ou par text:anchor-page-number si ancrer à la page + if(nameNode.equals("draw:frame")) { + if(nodSujet.getAttributs().get("recherche_anchor-page-number")==null) { + if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode, "draw:name", outils.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getAttributs().get("draw:name"))); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student, nameNode, "draw:name", outils.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getAttributs().get("draw:name"))); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student, nameNode, "draw:name", outils.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getAttributs().get("draw:name"))); + }else { + if(nodSujet.getAttributs().get("recherche_anchor-page-number").equals("false")) { + if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode, "draw:name", outils.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getAttributs().get("draw:name"))); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student, nameNode, "draw:name", outils.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getAttributs().get("draw:name"))); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student, nameNode, "draw:name", outils.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getAttributs().get("draw:name"))); + } + if(nodSujet.getAttributs().get("recherche_anchor-page-number").equals("true")) { + if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode, "text:anchor-page-number", outils.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getAttributs().get("text:anchor-page-number"))); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student, nameNode, "text:anchor-page-number", outils.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getAttributs().get("text:anchor-page-number"))); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student, nameNode, "text:anchor-page-number", outils.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getAttributs().get("text:anchor-page-number"))); + //si recherche l'ancrage de la page pas trouvé alors recherche par draw:name + if(nodStudent==null) { + if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode, "draw:name", outils.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getAttributs().get("draw:name"))); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student, nameNode, "draw:name", outils.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getAttributs().get("draw:name"))); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student, nameNode, "draw:name", outils.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getAttributs().get("draw:name"))); + } + } + } + } + //recherche par le nom de l'objet + if(nameNode.equals("style:graphic-properties")) { + if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameContent(nod2Student, nameNode, nodSujet.getContenu()); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameContent(nod1Student, nameNode, nodSujet.getContenu()); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameContent(nod0Student, nameNode, nodSujet.getContenu()); + } + + //recherche par l'index + if(nameNode.equals("table:table-row")) { + if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode, "index", nodSujet.getAttributs().get("index")); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student, nameNode, "index", nodSujet.getAttributs().get("index")); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student, nameNode, "index", nodSujet.getAttributs().get("index")); + + } + + //recherche par texte:name + if(nameNode.equals("text:table-of-content")) { + if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode, "text:name", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("text:name"))); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student, nameNode, "text:name", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("text:name"))); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student, nameNode, "text:name", outils.withoutCodeAndPoint(nodSujet.getAttributs().get("text:name"))); + } + + //recherche par contenu + if(nameNode.equals("text:span")) { + if(nod2Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContent2(nod2Student.getNodes(), nodSujet.retourneLesContenusEnfants(""),commandes.tolerance_characters,commandes.tolerance_text); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContent2(nod1Student.getNodes(), nodSujet.retourneLesContenusEnfants(""),commandes.tolerance_characters,commandes.tolerance_text); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContent2(nod0Student.getNodes(), nodSujet.retourneLesContenusEnfants(""),commandes.tolerance_characters,commandes.tolerance_text); + + } + + //recherche par contenu + if(nameNode.equals("text:tab")) { + if(!nodSujet.retourneLesContenusEnfants("").isEmpty()) { + if(nod2Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContent2(nod2Student.getNodes(), nodSujet.retourneLesContenusEnfants(""),commandes.tolerance_characters,commandes.tolerance_text); + if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContent2(nod1Student.getNodes(), nodSujet.retourneLesContenusEnfants(""),commandes.tolerance_characters,commandes.tolerance_text); + if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContent2(nod0Student.getNodes(), nodSujet.retourneLesContenusEnfants(""),commandes.tolerance_characters,commandes.tolerance_text); + } + } + + + // dernière tentative si le node est vide, recherche par le nom du node + if(nodStudent==null && !nameNode.equals("text:p")) { + if(nod2Student!=null) if(nod2Student.retourneEnfantsByNameExist(nameNode)) nodStudent = nod2Student.retourneFirstEnfantsByName(nameNode); + if(nod1Student!=null) if(nodStudent==null) if(nod1Student.retourneEnfantsByNameExist(nameNode)) nodStudent = nod1Student.retourneFirstEnfantsByName(nameNode); + if(nod0Student!=null) if(nodStudent==null) if(nod0Student.retourneEnfantsByNameExist(nameNode)) nodStudent = nod0Student.retourneFirstEnfantsByName(nameNode); + } + + + + return nodStudent; + } + + + private static node analyseStyle(node page, node nodSujet, node nodStudent, node nodSujetParagraphs, node nodStudentParagraphs ) { + node StyleParagraphSujet = null; + node StyleParagraphStudent = null; + + if(nodSujet.getAttributs().get("analyseStyle")!=null) { + + if(nodSujet.getAttributs().get("analyseStyle").equals("true") && nodSujet.getAttributs().get("text:style-name")!=null) { + //paragrapheTexte=true; + String NameStyleParagrapheSujet = nodSujet.getAttributs().get("text:style-name"); + StyleParagraphSujet = nodSujetParagraphs.retourneFirstNodeStyleByValueAttribut("style:style", "style:name", NameStyleParagrapheSujet); + } + + if(nodStudent!=null && StyleParagraphSujet!=null) { + if(nodStudent.getAttributs().get("text:style-name")!=null && StyleParagraphSujet!=null) { + String NameStyleParagrapheStudent = nodStudent.getAttributs().get("text:style-name"); + StyleParagraphStudent = nodStudentParagraphs.retourneFirstNodeStyleByValueAttribut("style:style", "style:name",NameStyleParagrapheStudent); + } + } + + // ajoute les valeurs par héritage. + if(StyleParagraphSujet!=null) { + if(StyleParagraphStudent!=null) StyleParagraphStudent = ajouteValeurLesValeursDuStyleParagraphParent(nodStudentParagraphs , StyleParagraphStudent); + + //ajoute les valeurs par défaut. + if(StyleParagraphStudent!=null) StyleParagraphStudent = ajouteValeurParDefautAuStyleParagraph(nodStudentParagraphs , StyleParagraphStudent); + + + // analyse attribut et contenu des enfants du premier niveau + page = analyseLesAttributAnalyseStyle(StyleParagraphStudent, StyleParagraphSujet, page, "ana:page","style:style"); + } + + } + return page; + } + + + /** + * + * @param retour : le node retour qui contient l'item ajouté + * @param nodStudent : le node Student qui peut être null + * @param nameNode : le nom du node + * @param point : les points + * @param nameElt : le nom de l'élément + * @return + */ + private static node analyseNameNode(node retour, node nodStudent, String nameNode, String point, String nameElt) { + node item = null; + if(nodStudent!=null) { + item = retourneNoteAvecResultatsAnalyse(nameNode,"name", nodStudent.getNomElt(),nameNode + "‽" +point, nameElt ); + }else { + outils.IncrementPointTotal(Integer.valueOf(point)); + item = new node(nameNode, "Erreur", "Nom du node" , "null", nameNode, 2, outils.getPointEnJeu(),nameElt); + } + retour.getNodes().add(item); + return retour; + } + + + + +} + + + diff --git a/src/MEPTL/outils.java b/src/MEPTL/outils.java new file mode 100644 index 0000000..8615893 --- /dev/null +++ b/src/MEPTL/outils.java @@ -0,0 +1,1049 @@ +package MEPTL; + + +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.Dictionary; +import java.util.Hashtable; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import cXML.node; +/** + * + * @author pablo rodriguez + * + */ +public class outils { + + public static Dictionary traduction = new Hashtable(); + + private static int pointsClass = 0; + private static int pointTotal=0; + private static int pointEnJeu = 0; + + + /** + * Chargement des traductions des éléments de l'exercice an utilsant le node "translation" du fichier d'analyse.
+ * Les noms des éléments sont placés dans un dictionnaire la key et la valeur est le code HTML. + * + * @param translation Le node "translation" qui se trouve dans le node "setting" du fichier d'analyse. + */ + public static void chargeTraduction(node translation) { + if(translation!=null) { + + String classText = ""; + if(translation.getAttributs().get("classtext")!=null) if(!translation.getAttributs().get("classtext").isEmpty()) classText = ""; + + String className = ""; + if(translation.getAttributs().get("class")!=null) if(!translation.getAttributs().get("class").isEmpty()) className = "
"; + + for(int i = 0 ; i < translation.getNodes().size();i++) { + String translate = ""; + String contenu =""; + String link = ""; + String color = ""; + String codeHTML = ""; + boolean T = false; + + if(translation.getNodes().get(i).getAttributs().get("translate")!=null) if(!translation.getNodes().get(i).getAttributs().get("translate").isEmpty()) translate=translation.getNodes().get(i).getAttributs().get("translate"); + if(!translation.getNodes().get(i).getContenu().isEmpty()) contenu = translation.getNodes().get(i).getContenu().replace("-!", "<").replace("!-", ">"); + if(translation.getNodes().get(i).getAttributs().get("link")!=null) if(!translation.getNodes().get(i).getAttributs().get("link").isEmpty()) link="

Lien

"; + if(translation.getNodes().get(i).getAttributs().get("color")!=null) if(!translation.getNodes().get(i).getAttributs().get("color").isEmpty()) color=""; + if(translation.getNodes().get(i).getAttributs().get("image")!=null) if(!translation.getNodes().get(i).getAttributs().get("image").isEmpty()) if(translation.getNodes().get(i).getAttributs().get("image").equals("true")) T=true; + + if(!contenu.isEmpty() && !className.isEmpty() && !classText.isEmpty()) { + if(!link.isEmpty()) { + if(!color.isEmpty()) { + if(!T) codeHTML = className + color + translate + "" + classText + contenu + link + "
" ; + if(T) codeHTML = className + HTML.imgInterogation() + color + translate + "
" + classText + contenu + link + "" ; + }else { + if(!T) codeHTML = className + translate + "" + classText + contenu + link + "" ; + if(T) codeHTML = className + HTML.imgInterogation() + translate + "" + classText + contenu + link + "" ; + } + }else { + if(!color.isEmpty()) { + if(!T) codeHTML = className + color + translate + ""+ classText + contenu + "" ; + if(T) codeHTML = className + HTML.imgInterogation() + color + translate + ""+ classText + contenu + "" ; + }else { + if(!T) codeHTML = className + translate + classText + contenu + "" ; + if(T) codeHTML = className + HTML.imgInterogation() + translate + classText + contenu + "" ; + } + } + }else { + if(!link.isEmpty()) { + if(!color.isEmpty()) { + if(!T) codeHTML = color + translate+ "" + link; + if(T) codeHTML = color + HTML.imgInterogation() + translate+ "" + link; + }else { + if(!T) codeHTML = translate + link; + if(T) codeHTML = HTML.imgInterogation() + translate + link; + } + }else { + if(!color.isEmpty()) { + if(!T) codeHTML = color + translate+ ""; + if(T) codeHTML = color + HTML.imgInterogation() + translate+ ""; + }else { + if(!T) codeHTML = translate; + if(T) codeHTML = HTML.imgInterogation() + translate; + } + } + } + codeHTML = codeHTML.replace("-!", "<").replace("!-", ">"); + if(!codeHTML.isEmpty()) { + traduction.put(translation.getNodes().get(i).getNomElt().replace("..", " "),codeHTML); + } + } + } + } + + + + + /** + * Compare les chaînes de caractères A et sujet en fonction des 8 fonctions ‽ † ¢ → ¦ ↕ ↑ † ×
+ * + * @param A le texte de l'étudiant. + * @param Sujet le tetxte du sujet. + * @return Une chaine de caractère contenant "Correct" ou "Erreur". + */ + public static String Compare(String A, String Sujet ) { + + // les points + String pointString = "" ; + pointEnJeu=0; + if(Sujet!=null) if(Sujet.contains("‽")) { + pointString = TraitePoint(Sujet); + Sujet=Sujet.substring(0, Sujet.indexOf("‽")); + } + + // optionnel pas d'analyse + if(pointEnJeu==0) return "Optionnel"; + + + // autre chose que null, none ou vide (analyse très simple) toutes les autres fonctions sont ignorées + if(Sujet!=null) if(Sujet.contains("†")) { + if(A==null) return "Erreur : -" + pointString; + if(A.equals("none")) return "Erreur : -" + pointString; + if(A.isEmpty()) return "Erreur : -" + pointString; + IncrementPointClass(pointEnJeu); + return "Correct : +" + pointString; + } + + + // fonction ET CONTIENT plusieurs textes - quelque chose mais pas vide - + if(Sujet!=null) if(Sujet.contains("×") && !Sujet.contains("¢") && !Sujet.contains("→") && !Sujet.contains("#") && !Sujet.contains("¦") && !Sujet.contains("↕") && !Sujet.contains("↑") ) { + if(A==null) return "Erreur : -" + pointString; + if(A.equals("none")) return "Erreur : -" + pointString; + if(A.isEmpty()) return "Erreur : -" + pointString; + + if(TraitementETContient(A,Sujet).equals("Correct : ")) { + IncrementPointClass(pointEnJeu); + return "Correct : +" + pointString; + } + + return "Erreur : -" + pointString; + } + + + // fonction OU puis ET CONTIENT plusieurs textes - quelque chose mais pas vide - + if(Sujet!=null) if(Sujet.contains("×") && Sujet.contains("¦") && !Sujet.contains("¦(") && !Sujet.contains("¢") && !Sujet.contains("→") && !Sujet.contains("#") && !Sujet.contains("↕") && !Sujet.contains("↑") ) { + if(A==null) return "Erreur : -" + pointString; + if(A.equals("none")) return "Erreur : -" + pointString; + if(A.isEmpty()) return "Erreur : -" + pointString; + + if(TraitementOUETcontient(A,Sujet).equals("Correct : ")) { + IncrementPointClass(pointEnJeu); + return "Correct : +" + pointString; + } + return "Erreur : -" + pointString; + } + + + // nettoyage du texte avant de l'analyser et similitude + // si ne contient pas d'autres fonctions cette fonction ne peut pas être combinée + if(Sujet!=null) if(Sujet.contains("¢") && !Sujet.contains("→") && !Sujet.contains("#") && !Sujet.contains("¦") && !Sujet.contains("↕") && !Sujet.contains("↑") ) { + if(A==null) A="null"; + if(similitudeString(A, Sujet,commandes.tolerance_text)) { + IncrementPointClass(pointEnJeu); + return "Correct : +" + pointString; + } + return "Erreur : -" + pointString; + } + + + //intervalle valeur simple pas de bordure, pas de couleur, et pas d'autres fonctions + if(Sujet.contains("→") && A!=null && !Sujet.contains("#") && !Sujet.contains("¦") && !Sujet.contains("↕") && !Sujet.contains("↑") && !Sujet.contains("¢")) { + if (TraitementIntervalle(A,Sujet).equals("Correct : ")) { + IncrementPointClass(pointEnJeu); + return "Correct : +" + pointString; + }else { + return "Erreur : -" + pointString; + } + } + + + // bordure simple avec ou sans intervalles ou autres fonctions + if(Sujet.contains("#") && Sujet.contains("pt") && Sujet.contains(" ") && !Sujet.contains("¦") && !Sujet.contains("↕") && !Sujet.contains("↑") && !Sujet.contains("¢") ) { + if(TraitementBordure2(Sujet,A).equals("Correct : ")) { + IncrementPointClass(pointEnJeu); + return "Correct : +" + pointString; + }else { + return "Erreur : -" + pointString; + } + } + + + // couleur simple pas de bordure ou pas d'autres fonctions + if(Sujet.contains("#") && !Sujet.contains("pt") && Sujet.contains(" ") && !Sujet.contains("¦") && !Sujet.contains("↕") && !Sujet.contains("↑") && !Sujet.contains("¢") ) { + if(TraitementCouleur(Sujet,A).equals("Correct : ")) { + IncrementPointClass(pointEnJeu); + return "Correct : +" + pointString; + }else { + return "Erreur : -" + pointString; + } + } + + //Exact avec OU sans d'autres fonctions OU + if(Sujet.contains("¦") && !Sujet.contains("↕") && !Sujet.contains("↑") && !Sujet.contains("¢")) { + if(TraitementOUExact(A,Sujet).equals("Correct : ")) { + IncrementPointClass(pointEnJeu); + return "Correct : +" + pointString; + }else { + return "Erreur : -" + pointString; + } + } + + //OU Exact mais sans les espaces et sans d'autres fonctions OU + if(Sujet.contains("≡") && !Sujet.contains("¦") && !Sujet.contains("↕") && !Sujet.contains("↑") && !Sujet.contains("¢")) { + if(TraitementOUExactSansEspace(A,Sujet).equals("Correct : ")) { + IncrementPointClass(pointEnJeu); + return "Correct : +" + pointString; + }else { + return "Erreur : -" + pointString; + } + } + + //Opérateur OU avec nettoyage du texte + if(Sujet.contains("↕") && !Sujet.contains("¦") && !Sujet.contains("↑") && !Sujet.contains("¢")) { + if(TraitementOU(A,Sujet).equals("Correct : ")) { + IncrementPointClass(pointEnJeu); + return "Correct : +" + pointString; + }else { + return "Erreur : -" + pointString; + } + } + + //Opérateur ou avec nettoyage des caractères spéciaux et des chiffres + if(Sujet.contains("↑") && !Sujet.contains("¦") && !Sujet.contains("↕") && !Sujet.contains("¢")) { + if(TraitementOUSupprimeChiffreEtsansCase(A,Sujet).equals("Correct : ")) { + IncrementPointClass(pointEnJeu); + return "Correct : +" + pointString; + }else { + return "Erreur : -" + pointString; + } + } + + + // ne contient aucune fonction + if(!Sujet.contains("≡") && !Sujet.contains("¦") && !Sujet.contains("↕") && !Sujet.contains("↑") && !Sujet.contains("¢") && !Sujet.contains("†") && !Sujet.contains("→")) { + if(A!=null)if(A.equals("auto")) A=null; + if(Sujet!=null)if(Sujet.equals("auto")) Sujet=null; + + if(A!=null) if(A.equals("0cm")) A=null; + if(Sujet!=null) if(Sujet.equals("0cm")) Sujet=null; + + if(A!=null) if(A.equals("none")) A=null; + if(Sujet!=null) if(Sujet.equals("none")) Sujet=null; + + if(A!=null) if(A.isEmpty()) A=null; + if(Sujet!=null) if(Sujet.isEmpty()) Sujet=null; + + if(A!=null) if(A.equals("0")) A=null; + if(Sujet!=null) if(Sujet.equals("0")) Sujet=null; + + if(A!=null) if(A.equals("null")) A=null; + if(Sujet!=null) if(Sujet.equals("null")) Sujet=null; + + if(A!=null) if(A.equals("false")) A=null; + if(Sujet!=null) if(Sujet.equals("false")) Sujet=null; + + if(A!=null) if(Sujet==null) if(!pointString.isEmpty()) { return "Erreur : -" + pointString;} + if(A!=null) if(Sujet==null) if(pointString.isEmpty()) {return "Erreur";} + if(A==null) if(Sujet==null) if(!pointString.isEmpty()){IncrementPointClass(pointEnJeu); return "Correct : +" + pointString;} + if(A==null) if(Sujet==null) if(pointString.isEmpty()) {IncrementPointClass(pointEnJeu); return "Correct";} + + if(A==null) if(Sujet!=null) if(!pointString.isEmpty()) return "Erreur : -" + pointString; + if(A==null) if(Sujet!=null) if(pointString.isEmpty()) return "Erreur"; + + if(!pointString.isEmpty()) { + if(A.equals(Sujet)){ + IncrementPointClass(pointEnJeu); + return "Correct : +" + pointString;} + else { + return "Erreur : -" + pointString; + } + }else { + if(A.equals(Sujet)){ + IncrementPointClass(pointEnJeu); + return "Correct";} + else { + return "Erreur"; + } + } + }else { + return "Erreur combinaison avec † ¢ → ¦ ↕ ↑ ×"; + } + } + + + /** + * Traitement des points du paramètre + * @param B + * @return + */ + public static String TraitePoint(String B) { + int point = 0; + pointEnJeu=0; + String pointString =""; + String C =B.substring(B.indexOf("‽")+1,B.length()); + if(B!=null) if(B.contains("‽")) if(B.length()>1) if(!C.isEmpty()) { + try { + point = Integer.valueOf(B.substring(B.indexOf("‽")+1,B.length())); + }catch (Exception e) { + System.out.println("erreur sur un point : " +B); + e.getMessage(); + } + }else { + point=0; + } + + if(point==0) { + pointString=""; + } + + if(point>0) { + pointString = Integer.valueOf(point) + " pt"; + IncrementPointTotal(point); + pointEnJeu= point; + } + + return pointString; + } + + /** + * Traitement des intervalles + * @return + */ + private static String TraitementIntervalle(String A, String B) { + if(A.isEmpty()) return "Erreur : "; + + String Text[] = B.split("→"); + + // rechercher un digite une ou plusieur fois en fin. + Pattern p = Pattern.compile("[^0-9\\.]"); + + // remplacement de toutes les occurrences par "" + Text[0]= p.matcher(Text[0]).replaceAll(""); + Text[1] = p.matcher(Text[1]).replaceAll(""); + A = p.matcher(A).replaceAll(""); + + double b0 = Double.valueOf(Text[0]); + double b1 = Double.valueOf(Text[1]); + + if(A.isEmpty()) return "Erreur : "; + double v = Double.valueOf(A); + + if(v<=b1 && v>=b0 ) return "Correct : "; + + return "Erreur : "; + } + + + + /** + * Traitement des bordures + * Avec ou sans intervalle sur l'épaisseur des traits + * Avec 3 styles de tarits solid, dashed, double + * Avec traitement de la couleur + * @param Sujet + * @param B + * @return + */ + private static String TraitementBordure2(String Sujet, String B) { + if(Sujet.isEmpty()) return "Erreur : "; + if(B==null) return "Erreur : "; + + String TextB[] = B.split(" "); + String TextA[] = Sujet.split(" "); + + if(TextB.length!=3 || TextA.length!=3) return "Erreur : "; + + boolean taille = false; + boolean type = false; + boolean couleur =false; + + // traitement de la taille (epaisseur du trait) + if(TextA[0].contains("→")) { + if(TraitementIntervalle(TextB[0], TextA[0]).equals("Correct : ")) taille = true; + }else { + double tailleA = Double.valueOf(TextA[0].replace("pt","")); + double tailleB = Double.valueOf(TextB[0].replace("pt","")); + double IT = 0.02; + if((tailleAtailleB-IT))taille = true; + } + + + // traitement du type de trait + String typeA = TextA[1]; + String typeB = TextB[1]; + + //trait pointillé + if(typeA.equals("dash-dot")) typeA="dashed"; + if(typeB.equals("dash-dot")) typeB="dashed"; + if(typeA.equals("dotted")) typeA="dashed"; + if(typeB.equals("dotted")) typeB="dashed"; + if(typeA.equals("fine-dashed")) typeA="dashed"; + if(typeB.equals("fine-dashed")) typeB="dashed"; + if(typeB.equals("dash-dot-dot")) typeB="dashed"; + if(typeA.equals("dash-dot-dot")) typeA="dashed"; + + if(typeA.equals("double-thin")) typeA="double"; + if(typeB.equals("double-thin")) typeB="double"; + if(typeA.equals("outset")) typeA="double"; + if(typeB.equals("outset")) typeB="double"; + if(typeA.equals("inset")) typeA="double"; + if(typeB.equals("inset")) typeB="double"; + + + if(typeA.equals("groove")) typeA="solid"; + if(typeB.equals("groove")) typeB="solid"; + if(typeA.equals("ridge")) typeA="solid"; + if(typeB.equals("ridge")) typeB="solid"; + + + if(typeA.equals(typeB)) type=true; + + // traitement de la couleur du trait + String couleurA = TextA[2].replace("#", ""); + String couleurB = TextB[2].replace("#", ""); + + if(couleurA.equals(couleurB)) couleur = true; + + if(!couleur) { + if(TraitementCouleur(couleurA, couleurB).equals("Correct : ")) { + couleur =true; + } + } + + if(taille && type && couleur) return "Correct : "; + + return "Erreur : "; + } + + /** + * Traitement de la couleur par comparaison + * La tolérance sur les 3 couleurs primaires RVB est de plus ou moins 30 par défaut. + * @param A + * @param B + * @return + */ + private static String TraitementCouleur(String Sujet, String B) { + if(B==null) return "Erreur : "; + if(B.isEmpty()) return "Erreur : "; + + // traitement de la couleur du trait + String couleurS = Sujet.replace("#", ""); + String couleurB = B.replace("#", ""); + + if(couleurS.equals(couleurB)) return "Correct : "; + + if(couleurS.length()==6 && couleurB.length()==6) { + int Sred = Integer.parseInt(couleurS.substring(0, 2),16); + int Sgreen = Integer.parseInt(couleurS.substring(2, 4),16); + int Sblue = Integer.parseInt(couleurS.substring(4, 6),16); + + int Bred = Integer.parseInt(couleurB.substring(0, 2),16); + int Bgreen = Integer.parseInt(couleurB.substring(2, 4),16); + int Bblue = Integer.parseInt(couleurB.substring(4, 6),16); + + // couleur dominante avec 10 niveau +// if(Sred>Sgreen+10 && Sred>Sblue+10 && Bred>Bgreen+10 && Bred>=Bblue+10) return "Correct : ";//couleur=true; //Couleur dominante rouge +// if(Sgreen>Sred+10 && Sgreen>Sblue+10 && Bgreen>Bred+10 && Bgreen>Bblue+10) return "Correct : "; //couleur = true; //Couleur dominante vert +// if(Sblue>Sred+10 && Sblue>Sgreen+10 && Bblue>Bred+10 && Bblue>Bgreen+10) return "Correct : "; //couleur = true; //Couleur dominante bleu +// if(Sblue==Sred && Sblue==Sgreen && Bblue==Bred && Bblue==Bgreen) return "Correct : "; //couleur = true; //Couleur gris (tous les gris) + if(procheCouleur(Sred,Bred,Sgreen,Bgreen,Sblue,Bblue)) return "Correct : "; //couleur = true; //Couleur gris (tous les gris) + } + //if(couleur) return "Correct : "; + + return "Erreur : "; + } + + /** + * Couleur proche avec une tolérance par défaut de 20 nuances dans l'espace colorométrique RVB. + * @param R1 Rouge Sujet + * @param R2 Rouge Student + * @param V1 Vert Sujet + * @param V2 Vert Student + * @param B1 Bleu Sujet + * @param B2 Bleu Student + * @return + */ + private static Boolean procheCouleur(int R1, int R2, int V1, int V2, int B1, int B2) { + int ecartR = Math.abs(R1-R2); + int ecartV = Math.abs(V1-V2); + int ecartB = Math.abs(B1-B2); + if((ecartR <=commandes.tolerance_rouge)&&(ecartV <=commandes.tolerance_vert)&&(ecartB <=commandes.tolerance_bleu) )return true; + return false; + } + + /** + * Traitement des conditions OU avec nettoyage du texte + * Comparaison egale, contient , similitude + * @param A + * @param B + * @return + */ + private static String TraitementOU(String A, String B) { + if(A==null) A="none"; + if(A.isEmpty()) A="none"; + + A = NetTexte(A); + + + String TextB[] = B.split("↕"); + for(int i=0;i + * pour effectuer la recherche d'un node par son contenu. + * @param B un string + * @return B un string + */ + public static String withoutCodeAndPointPourRechercheContenuExact(String B) { + if(B!=null) { + if(B.contains("‽")) B=B.substring(0, B.indexOf("‽")); + if(B.contains("↑")) B=B.replace("↑", ""); + if(B.contains("↕")) B=B.replace("↕", ""); + if(B.contains("≡")) B=B.replace("≡", ""); + if(!B.isEmpty()) B=B.replace("¢", ""); + } + return B; + } + + + /** + * Supprime les caracatères spéciaux, la pontuaction, tous les espaces, et les chiffres
+ * Bascule le texte en minuscule.
+ * @param A Le texte qui doit être nettoyé. + * @return Le texte nettoyé. + */ + private static String NetTexte(String A) { + if (A!=null) { + A=A.toLowerCase().trim(); + A = A.replace("'", ""); + A = A.replace(""", ""); + + Pattern pt = Pattern.compile("[^a-zA-Z0-9]"); // avec les chiffres "[^a-zA-Z0-9]" + Matcher match= pt.matcher(A); + while(match.find()){ + String s= match.group(); + A=A.replaceAll("\\"+s, ""); + } + + A=A.replaceAll("[0-9]", ""); + A=A.replace(" ", ""); + + A=A.toLowerCase(); + + } + return A; + } + + + /** + * Netoyage les chiffres placés à la fin du texte.
+ * Cette méthode est utilisée pour supprimer les numéros de page dans les index (table de matières par exemple).
+ * @param A Le texte. + * @return Le texte A sans chiffre à la fin du texte. + */ + public static String NetChiffreALaFin(String A) { + A=A.replaceAll("{1,}[0-9]", ""); + return A; + } + + + + /** + * Retourne la chaîne sans le numéro à la fin + * @param A + * @return + */ + public static String RemoveLastNumber(String A) { + Pattern p = Pattern.compile("[0-9]+$"); + Matcher m = p.matcher(A); + A= m.replaceAll(""); + return A; + } + + + /** + * + * @param A + * @param B + * @return + */ + public static ArrayList AjouteDansALesNodesB(ArrayList A,ArrayList B){ + for(int i=0; i + * Lorsque les deux chaînes de caractères partages 79% des caractères comparés par groupe de 2 ou 3 ou 4. Alors retourne TRUE.
+ * Lorsque les deux chaînes de caractères partages moins de 79% des caractères comparés par groupe de 2 ou 3 ou 4. Alors retourne FALSE.
+ * Les Chaînes de caractères doivent avoir au moins 6 caractères, après néttoyage du texte avec la méthode NetTexte().
+ * Sinon le seuil de tolérance est de 99.99%.
+ *
    + *
  • Lorsque la longueur de la chaîne de caractères est inférieure à 50 caractères alors compare par groupe de 2 caractères.
  • + *
  • Lorsque la longueur de la chaîne de caractères est entre à 50 et 200 caractères alors compare par groupe de 3 caractères.
  • + *
  • Lorsque la longueur de la chaîne de caractères est supérieure à 200 caractères alors compare par groupe de 4 caractères.
  • + *
+ *
+ * @param A Chaîne de caracatères de l'étudiant. + * @param Modele Chaîne de caractères du sujet. + * @param tolerance_text Le seuil de tolérance pour la comparaison (valeur comprise entre 0 et 1). + * @return TRUE ou FALSE en fonction de la comparaison et du seuil de tolérance. + */ + private static boolean similitudeString(String A, String Modele, Double tolerance_text) { + if(tolerance_text==null) tolerance_text = 0.79 ; + + Modele = NetTexte(Modele); + A = NetTexte(A); + + double Sim = StringSimilarity.similarity(A, Modele); + + if(Sim=50 && Modele.length()<200) step=3; +// if(Modele.length()>=200) step = 4; +// +// +// for(int i = 0 ; i < Modele.length()-step;i=i+step) { +// B = Modele.substring(i, i+step); +// if(A.contains(B)) compteur2++; +// total2++; +// if(i+step>Modele.length()-step) { +// B = Modele.substring(i+step, Modele.length()); +// if(A.contains(B)) compteur2++; +// total2++; +// } +// } +// +// +// int compteur2b = 0 ; +// int total2b = 0; +// +// for(int i = 0 ; i < A.length()-step;i=i+step) { +// B = A.substring(i, i+step); +// if(Modele.contains(B)) compteur2b++; +// total2b++; +// if(i+step>A.length()-step) { +// B = A.substring(i+step, A.length()); +// if(Modele.contains(B)) compteur2b++; +// total2b++; +// } +// } +// +// +// double rapport1 = ((double)compteur2/(double)total2); +// double rapport2 = ((double)compteur2b/(double)total2b); +// +// if(rapport1 table1 = new ArrayList(); + byte[] V = A.getBytes(); + + byte[] W = new byte[V.length]; + int c =0; + for(int i = 0 ; i < V.length;i++) { + if(V[i]>0) { + //if (V[i]!=63 && V[i]!=-128 && V[i]!=-103) { //63 les accents é ; -128 le symbole € -30,-128,-103 l'apostrophe + W[c]=V[i]; + table1.add((int) W[c]); + c++; + } + } + try { + A = new String(W,"UTF-8"); + + } catch (UnsupportedEncodingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + A=A.replace("@", ""); + A=A.replace("?", ""); + A=A.replace("!", ""); + A=A.replace("α", ""); + A=A.replace("β", ""); + A=A.replace("γ", ""); + A=A.replace("δ", ""); + A=A.replace("ε", ""); + A=A.replace("σ", ""); + A=A.replace("τ", ""); + A=A.replace("ζ", ""); + A=A.replace("η", ""); + A=A.replace("θ", ""); + A=A.replace("ι", ""); + A=A.replace("’", ""); + A=A.replace("'", ""); + + A=A.replace(" ", ""); + A=A.replace("'", ""); + A=A.replace("«", ""); + A=A.replace("»", ""); + A=A.replace("'", ""); + A=A.replace("d'", ""); + + + A=A.replace("’", ""); + A=A.replace("e", ""); + A=A.replace("é", ""); + A=A.replace("é", ""); // pas le même encodage + + A=A.replace("è", ""); + A=A.replace("è", ""); // pas le même encodage + A=A.replace("ê", ""); + + + A=A.replace("o", ""); + A=A.replace("ô", ""); + + A=A.replace("a", ""); + A=A.replace("â", ""); + A=A.replace("â", ""); // pas le même encodage + + A=A.replace("à", ""); + A=A.replace("à", ""); // pas le même encodage + + A=A.replace("u", ""); + A=A.replace("ù", ""); + A=A.replace("û", ""); + + A=A.replace("c", ""); + A=A.replace("ç", ""); + + A=A.replace("i", ""); + A=A.replace("î", ""); + A=A.replace("ï", ""); + A=A.replace("ï", ""); // pas le même encodage + + A=A.replace("0", ""); + A=A.replace("1", ""); + A=A.replace("2", ""); + A=A.replace("3", ""); + A=A.replace("4", ""); + A=A.replace("5", ""); + A=A.replace("6", ""); + A=A.replace("7", ""); + A=A.replace("8", ""); + A=A.replace("9", ""); + + + A=A.replace(":", ""); + A=A.replace("-", ""); + A=A.replace(".", ""); + A=A.replace(",", ""); + A=A.replace("_", ""); + A=A.replace("_", ""); + A=A.replace("(", ""); + A=A.replace(")", ""); + A=A.replace("\"", ""); + A=A.replace("+", ""); + A=A.replace("Œ", ""); + A=A.replace("œ", ""); + A=A.replace("oe", ""); + A=A.replace("\r", ""); + A=A.replace("\n", ""); + A=A.replace("\t", ""); + A=A.replace("/", ""); + A=A.replace("(", ""); + A=A.replace(")", ""); + A=A.replace(" ",""); + + + + A=A.trim(); + + } + return A; + } + + + + + + public static int getPointsClass() { + return pointsClass; + } + + + public static int getPointTotal() { + return pointTotal; + } + + + public static int getPointEnJeu() { + return pointEnJeu; + } + + public static double getProportionCorrect() { + return (double) pointsClass/pointTotal; + } + + public static void setPointsClass(int ptsClass) { + pointsClass = ptsClass; + } + + + public static void setPointTotal(int ptTotal) { + pointTotal = ptTotal; + } + + + public static void setPointEnJeu(int ptEnJeu) { + pointEnJeu = ptEnJeu; + } + + public static void IncrementPointTotal(Integer pt) { + pointTotal=pointTotal+ pt; + } + + public static void decrementPointEnJeuDuTotal() { + pointTotal=pointTotal-pointEnJeu; + } + + private static void IncrementPointClass(Integer pt) { + pointsClass=pointsClass+ pt; + } + + + + +} + diff --git a/src/MEPTL/verificationFichierAnalyse.java b/src/MEPTL/verificationFichierAnalyse.java new file mode 100644 index 0000000..9f54ad5 --- /dev/null +++ b/src/MEPTL/verificationFichierAnalyse.java @@ -0,0 +1,462 @@ +package MEPTL; + +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import cXML.node; + +public class verificationFichierAnalyse { + public static boolean erreur = false; + + public verificationFichierAnalyse(node Sujet) throws CloneNotSupportedException{ + if(Sujet==null) { + System.out.println(); + System.out.println("**-** Error, the analysis file is null."); + System.out.println(); + clotureWithErrorInanalyzeFile(); + } + + //vérification des attributs du node fichier + if(Sujet.getAttributs().size()>0) { + verificationNodeFichier(Sujet.getAttributs()); + }else { + System.out.println(); + System.out.println("**-** ERROR in the analysis file."); + System.out.println("* The node \"fichier\" does not contain any attributes."); + System.out.println(); + erreur=true; + } + + + + //Vérification des attributs du node style:paragraph et vérification style de paragraphe par défaut + if(Sujet.retourneEnfantsByNameExist("style:paragraph")) { + verificationNodeEvaluate(Sujet.retourneFirstEnfantsByName("style:paragraph").getAttributs(),"style:paragraph"); + if(Sujet.retourneFirstEnfantsByName("style:paragraph").retourneEnfantsByNameExist("style:default-style")) { + verifcationStyleParagraphDefaut(Sujet.retourneFirstEnfantsByName("style:paragraph").retourneFirstEnfantsByName("style:default-style")); + } + } + + //Vérification des attributs du node office:meta + if(Sujet.retourneEnfantsByNameExist("office:meta")) { + verificationNodeEvaluate(Sujet.retourneFirstEnfantsByName("office:meta").getAttributs(),"office:meta"); + } + + //Vérification des attributs du node style:page + if(Sujet.retourneEnfantsByNameExist("style:page")) { + verificationNodeEvaluate(Sujet.retourneFirstEnfantsByName("style:page").getAttributs(),"style:page"); + } + + //Vérification des attributs du node sequences + if(Sujet.retourneEnfantsByNameExist("sequences")) { + verificationNodeEvaluate(Sujet.retourneFirstEnfantsByName("sequences").getAttributs(),"sequences"); + } + + //Vérification des attributs du node numerotationchapitre + if(Sujet.retourneEnfantsByNameExist("numerotationchapitre")) { + verificationNodeEvaluate(Sujet.retourneFirstEnfantsByName("numerotationchapitre").getAttributs(),"numerotationchapitre"); + } + + //Vérification des attributs du node frames + if(Sujet.retourneEnfantsByNameExist("frames")) { + verificationNodeEvaluate(Sujet.retourneFirstEnfantsByName("frames").getAttributs(),"frames"); + } + + //Vérification des attributs du node sections + if(Sujet.retourneEnfantsByNameExist("sections")) { + verificationNodeEvaluate(Sujet.retourneFirstEnfantsByName("sections").getAttributs(),"sections"); + } + + //Vérification des attributs du node biblio + if(Sujet.retourneEnfantsByNameExist("biblio")) { + verificationNodeEvaluate(Sujet.retourneFirstEnfantsByName("biblio").getAttributs(),"biblio"); + } + + //Vérification des attributs du node tablematieres + if(Sujet.retourneEnfantsByNameExist("tablematieres")) { + verificationNodeEvaluate(Sujet.retourneFirstEnfantsByName("tablematieres").getAttributs(),"tablematieres"); + } + + //Vérification des attributs du node tableillustrations + if(Sujet.retourneEnfantsByNameExist("tableillustrations")) { + verificationNodeEvaluate(Sujet.retourneFirstEnfantsByName("tableillustrations").getAttributs(),"tableillustrations"); + } + + //Vérification des attributs du node structurepage + if(Sujet.retourneEnfantsByNameExist("structurepage")) { + verificationNodeEvaluate(Sujet.retourneFirstEnfantsByName("structurepage").getAttributs(),"structurepage"); + } + + + //vérification du node structure + if(Sujet.retourneEnfantsByNameExist("structurepage")) { + verifNodeAutoriserDansStructure(Sujet.retourneFirstEnfantsByName("structurepage")); + } + + //vérification du node setting + if(Sujet.retourneEnfantsByNameExist("setting")) { + verificationNodeSetting(Sujet.retourneFirstEnfantsByName("setting")); + } + + } + + + private static void verificationNodeFichier(Dictionary attribut) { + // le node fichier ne doit pas avoir un attribut addmenu="true" + if(attribut.get("addmenu")!=null) if(attribut.get("addmenu").equals("true")) { + System.out.println(); + System.out.println("**-** ERROR in the analysis file at node \"fichier\"."); + System.out.println("The \"fichier\" node must not have the attribute \"addmenu = true\"."); + System.out.println("This node not allowed to create a menu."); + System.out.println("Only main nodes can have this attribute with this value."); + System.out.println(); + erreur=true; + } + + // le node fichier doit avoir l'attribut evaluer=true + if(attribut.get("evaluer")==null) { + System.out.println(); + System.out.println("**-** ERROR in the analysis file at node \"fichier\"."); + System.out.println("The \"fichier\" node must contain the attribute \"evaluer = true\"."); + System.out.println("This attribute has been deleted or has been renamed."); + System.out.println(); + erreur=true; + }else { + if(!attribut.get("evaluer").equals("true")) { + System.out.println(); + System.out.println("**-** ERROR in the analysis file at node \"fichier\"."); + System.out.println("The \"fichier\" node must contain the attribute \"evaluer = true\"."); + System.out.println("The value of this attribute is not correct."); + System.out.println(); + erreur=true; + } + } + + // le node fichier doit contenir l'attribut metaSujet et une valeur autre que le point d'interrogation ou vide + if(attribut.get("metaSujet")==null) { + System.out.println(); + System.out.println("**-** ERROR in the analysis file at node \"fichier\"."); + System.out.println("The \"fichier\" node must contain the attribute \"sujetMeta\"."); + System.out.println("This attribute has been deleted or has been renamed."); + System.out.println("This attribute must contain a value."); + System.out.println(); + erreur=true; + }else { + if(attribut.get("evaluer").equals("?") || attribut.get("evaluer").isEmpty() ) { + System.out.println(); + System.out.println("**-** ERROR in the analysis file at node \"fichier\"."); + System.out.println("The \"sujetMeta\" node must contain a value other than \"?\" And not empty."); + System.out.println("In the custom properties of the ODF file, create the \"Sujet\" property and enter some text as the value."); + System.out.println(); + erreur=true; + } + } + + + } + + /** + * Vérification de la présence de l'attribut addmenu=true lorsque l'attribut evaluer=true.
+ * Uniquement pour les nodes principaux.
+ *
+ * @param attribut + * @param nameNode + */ + private static void verificationNodeEvaluate(Dictionary attribut, String nameNode) { + if(attribut.get("evaluer")!=null) { + if(attribut.get("evaluer").equals("true")) { + if(attribut.get("addmenu")!=null) { + if(!attribut.get("addmenu").equals("true")) { + System.out.println(); + System.out.println("**-** ERROR in analysis file at node \""+ nameNode +"\"."); + System.out.println("The main node \"" + nameNode +"\" must contain the attribute \"addmenu=true\"."); + System.out.println("For this version, it is necessary to create a summary and a menu for the main nodes."); + System.out.println(); + erreur=true; + } + }else { + System.out.println(); + System.out.println("**-** ERROR in analysis file at node \""+ nameNode +"\"."); + System.out.println("The main node \"" + nameNode +"\" must contain the attribute \"addmenu=true\". This attribute has been deleted."); + System.out.println("For this version, it is necessary to create a summary and a menu for the main nodes."); + System.out.println(); + erreur=true; + } + } + } + } + + + private static void verifNodeAutoriserDansStructure(node structure) throws CloneNotSupportedException { + + String nom = structure.getNomElt(); + if(nom.equals("text:p") || nom.equals("text:h")||nom.equals("text:database-display")||nom.equals("table:table-cell") + ||nom.equals("text:section")||nom.equals("draw:frame")||nom.equals("text:user-defined")||nom.equals("table:table-row") + ||nom.equals("table:table-row")||nom.equals("structurepage")||nom.equals("page")||nom.contains("text:table-of-content") + ||nom.contains("text:illustration")||nom.equals("text:note")||nom.equals("text:conditional-text")||nom.equals("text:date") + ||nom.contains("style:graphic-properties")||nom.isEmpty()) { + }else { + Enumeration key = structure.getAttributs().keys(); + while(key.hasMoreElements()) { + String k = key.nextElement(); + if(structure.getAttributs().get(k).contains("‽")) { + System.out.println(); + System.out.println("**-** ERROR in analysis file at node \"structurepage\"."); + System.out.println("The node " + nom + " must not have evaluated attributes."); + System.out.println("The node " + nom + " can have the attribut \"evaluer=true\" but any attributes values cannot contain \"‽\"."); + System.out.println(); + erreur= true; + } + } + } + + + + //verification des nodes autorisés dans la structure + for(int i = 0 ; i < structure.getNodes().size(); i++) { + nom = structure.getNodes().get(i).getNomElt(); + + if(nom.equals("text:p") || nom.equals("text:h")||nom.equals("text:database-display")||nom.equals("table:table-cell") + ||nom.equals("text:section")||nom.equals("draw:frame")||nom.equals("text:user-defined")||nom.equals("table:table-row") + ||nom.equals("table:table-row")||nom.equals("structurepage")||nom.equals("page")||nom.contains("text:table-of-content") + ||nom.contains("text:illustration")||nom.equals("text:note")||nom.equals("text:conditional-text") + ||nom.contains("style:graphic-properties")||nom.equals("text:date")||nom.isEmpty()) { + }else { + Enumeration key = structure.getNodes().get(i).getAttributs().keys(); + while(key.hasMoreElements()) { + String k = key.nextElement(); + if(structure.getNodes().get(i).getAttributs().get(k).contains("‽")) { + System.out.println(); + System.out.println("**-** ERROR in analysis file at node \"structurepage\"."); + System.out.println("The node " + nom + " must not have evaluated attributes."); + System.out.println("The node " + nom + " can have the attribut \"evaluer=true\" but any attributes values cannot contain \"‽\"."); + System.out.println(); + System.out.println(); + erreur= true; + } + } + } + verifNodeAutoriserDansStructure(structure.getNodes().get(i)); + } + } + + + /** + * Evaluation du node seeting + * @param attribut + * @param nameNode + */ + private static void verificationNodeSetting(node setting) { + if(setting.getAttributs().get("culture") != null) { + if(!setting.getAttributs().get("culture").equals("FR")) { + System.out.println(); + System.out.println("**-** WARNING in analysis file at node \"setting\"."); + System.out.println("The culture cannot be different than \"FR\"."); + System.out.println(); + } + } + + if(setting.containElementByName("csv")) { + node csv = setting.retourneFirstEnfantsByName("csv"); + if(csv.getAttributs().get("encoding") != null) { + if(!csv.getAttributs().get("encoding").equals("UTF-8") && !csv.getAttributs().get("encoding").equals("US-ASCII") && !csv.getAttributs().get("encoding").equals("ISO-8859-1") + && !csv.getAttributs().get("encoding").equals("UTF-16BE") && !csv.getAttributs().get("encoding").equals("UTF-16LE") && !csv.getAttributs().get("encoding").equals("UTF-16")) { + System.out.println(); + System.out.println("**-** WARNING in analysis file at node \"setting\"."); + System.out.println("The encoding cannot be "+ csv.getAttributs().get("encoding") +"in csv node."); + System.out.println(); + } + } + } + + if(setting.containElementByName("zip")) { + node zip = setting.retourneFirstEnfantsByName("zip"); + if(zip.getAttributs().get("size") != null) { + Long size = (long) 0; + try { + size = Long.valueOf(zip.getAttributs().get("size")); + }catch (Exception e) { + System.out.println(); + System.out.println("**-** ERROR in analysis file at node \"setting\"."); + System.out.println("The zip size cannot be different from a numeric value."); + System.out.println(); + erreur=true; + } + if(size<1000000) { + System.out.println(); + System.out.println("**-** ERROR in analysis file at node \"setting\"."); + System.out.println("The zip size is too low."); + System.out.println("The zip size should be bigger than 1Mo."); + System.out.println(); + erreur=true; + } + } + if(zip.getAttributs().get("name") != null) { + String name = zip.getAttributs().get("name"); + Pattern pt = Pattern.compile("[^a-zA-Z0-9]"); // avec les chiffres "[^a-zA-Z0-9]" + Matcher match= pt.matcher(name); + if(match.find()) { + System.out.println(); + System.out.println("**-** ERROR in analysis file at node \"setting\"."); + System.out.println("The name of the zip cannot contain a special character."); + System.out.println(); + erreur=true; + } + } + } + + if(setting.containElementByName("plagiarism")) { + node plagiarism = setting.retourneFirstEnfantsByName("plagiarism"); + if(plagiarism.getAttributs().get("number_match") != null) { + int number_match = -1; + try { + number_match = Integer.valueOf(plagiarism.getAttributs().get("number_match")); + }catch (Exception e) { + System.out.println(); + System.out.println("**-** ERROR in analysis file at node \"setting\"."); + System.out.println("The number of match must be a numeric value."); + System.out.println(); + erreur=true; + } + if(number_match<0) { + System.out.println(); + System.out.println("**-** ERROR in analysis file at node \"setting\"."); + System.out.println("The number of matches must be a positive numeric value."); + System.out.println(); + erreur=true; + } + + } + if(plagiarism.getAttributs().get("mini_number_modification") != null) { + int mini_number_modification = -1; + try { + mini_number_modification = Integer.valueOf(plagiarism.getAttributs().get("mini_number_modification")); + }catch (Exception e) { + System.out.println(); + System.out.println("**-** ERROR in analysis file at node \"setting\"."); + System.out.println("The minimum number of modifications must be a numeric value."); + System.out.println(); + erreur=true; + } + if(mini_number_modification<-1) { + System.out.println(); + System.out.println("**-** ERROR in analysis file at node \"setting\"."); + System.out.println("The minimum number of modifications must be a positive numeric value."); + System.out.println(); + erreur=true; + } + + } + if(plagiarism.getAttributs().get("nombres_modifications_simultané_maxi") != null) { + int nombres_modifications_simultané_maxi = -1; + try { + nombres_modifications_simultané_maxi = Integer.valueOf(plagiarism.getAttributs().get("nombres_modifications_simultané_maxi")); + }catch (Exception e) { + System.out.println(); + System.out.println("**-** ERROR in analysis file at node \"setting\"."); + System.out.println("The nombres_modifications_simultané_maxi must be a numeric value."); + System.out.println(); + erreur=true; + } + if(nombres_modifications_simultané_maxi<0) { + System.out.println(); + System.out.println("**-** ERROR in analysis file at node \"setting\"."); + System.out.println("The nombres_modifications_simultané_maxi must be a positive numeric value."); + System.out.println(); + erreur=true; + } + + } + + + } + + if(setting.containElementByName("text:similarity")) { + node similarity = setting.retourneFirstEnfantsByName("text:similarity"); + if(similarity.getAttributs().get("tolerance_characters")!=null) { + int tolerance_characters = -1; + try { + tolerance_characters = Integer.valueOf(similarity.getAttributs().get("tolerance_characters")); + }catch (Exception e) { + System.out.println(); + System.out.println("**-** ERROR in analysis file at node \"setting\"."); + System.out.println("The tolerance_characters is not an integer."); + System.out.println(); + erreur=true; + } + if(tolerance_characters<0) { + System.out.println(); + System.out.println("**-** ERROR in analysis file at node \"setting\"."); + System.out.println("The tolerance_characters must be a positive numeric value."); + System.out.println(); + erreur=true; + } + } + if(similarity.getAttributs().get("tolerance_text")!=null) { + double tolerance_text = 0.0; + try { + tolerance_text = Double.valueOf(similarity.getAttributs().get("tolerance_text")); + }catch (Exception e) { + System.out.println(); + System.out.println("**-** ERROR in analysis file at node \"setting\"."); + System.out.println("The tolerance_text is not a numeric."); + System.out.println(); + erreur=true; + } + if(tolerance_text<0 || tolerance_text>1) { + System.out.println(); + System.out.println("**-** ERROR in analysis file at node \"setting\"."); + System.out.println("The tolerance_text must be between 0.01 and 0.99."); + System.out.println(); + erreur=true; + } + + } + + } + + + + + + } + + + + + private static void verifcationStyleParagraphDefaut(node styleParagraphDefault) { + if(styleParagraphDefault.getAttributs().get("evaluer")!=null) { + if(styleParagraphDefault.getAttributs().get("evaluer").equals("true")) { + System.out.println(); + System.out.println("**-** WARNING in analysis file at node \"style:default-style\"."); + System.out.println("The node \"style:default-style\" must not contain \"evaluer=true\"."); + System.out.println("Default values are added to the different nodes \"style:style\" that are evaluated."); + System.out.println("Read the documentation about the node \"style:paragraph\"."); + System.out.println(); + } + } + } + + /** + * Clôture lorsqu'il y a une erreur dans le fichier d'analyse + */ + public static void clotureWithErrorInanalyzeFile() { + System.out.println(); + System.out.println("\t\t┌─────────────────────────────────────────────┐"); + System.out.println("\t\t│ You made a mistake in your analyze file. │"); + System.out.println("\t\t│ │"); + System.out.println("\t\t│ You need to look for your error in the │"); + System.out.println("\t\t│ analyze file. Read the information above. │"); + System.out.println("\t\t│ │"); + System.out.println("\t\t│ (')_(') │"); + System.out.println("\t\t│ ( `.° ) │"); + System.out.println("\t\t│ (\")__(\") .. see you soon, analyseWriter. │"); + System.out.println("\t\t└─────────────────────────────────────────────┘"); + System.out.println(); + System.exit(0); + } + + +} diff --git a/src/resources/licence.txt b/src/resources/licence.txt new file mode 100644 index 0000000..80e659d --- /dev/null +++ b/src/resources/licence.txt @@ -0,0 +1,674 @@ +GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. \ No newline at end of file