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.DecimalFormat; import java.util.ArrayList; import java.util.Date; import java.util.Enumeration; import java.util.regex.Pattern; import javax.swing.JOptionPane; import cXML.Run; import cXML.Run.UserStatus; import cXML.node; import calcul.formatDateWriter; import evaluer.evaluation; /** * * @author pablo rodriguez * * */ public class meptl { static DecimalFormat df = new DecimalFormat("###.##"); //static String patch =""; //static double progression = 1.0; /** * Lecture du fichier Student pour vérification des historiques.
*
* @param nod node * @param a * @param i * @return */ public 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"); if(!nodmeta.retourneFirstEnfantsByName("meta:generator").getContenu().isEmpty()) { fichier.getAttributs().put("producteur", nodmeta.retourneFirstEnfantsByName("meta:generator").getContenu().get(0)); }else { fichier.getAttributs().put("producteur", "nobody"); } if(!nodmeta.retourneFirstEnfantsByName("meta:generator").getContenu().isEmpty()) { fichier.getAttributs().put("producteur", nodmeta.retourneFirstEnfantsByName("meta:generator").getContenu().get(0)); }else { fichier.getAttributs().put("producteur", "unknow"); } if(!nodmeta.retourneFirstEnfantsByName("dc:date").getContenu().isEmpty()) { fichier.getAttributs().put("dateModification", nodmeta.retourneFirstEnfantsByName("dc:date").getContenu().get(0)); }else { fichier.getAttributs().put("dateModification", "unknow"); } if(!nodmeta.retourneFirstEnfantsByName("meta:editing-duration").getContenu().isEmpty()) { fichier.getAttributs().put("dureeEdition", nodmeta.retourneFirstEnfantsByName("meta:editing-duration").getContenu().get(0)); }else { fichier.getAttributs().put("dureeEdition", "unknow"); } 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(nod, "office:text")); fichier.getNodes().add(nodhistorique); return fichier; } /** * Retourne le node menu qui est réalisé à partir de l'attibut "addmenu=true".
* L'attribut "addmenu=true" se trouve uniquement dans les node de niveu 1 (les nodes principaux).
* Retourne le node avec ce shéma
*
* @param nod : Le node dans lequel on recherche les nodes. * @param menu : Le node menu. * @param niv : Le niveau du node. * @param Compteur : Le compteur permet d'incrémenter les niveaux des nodes. * @return Le node menu est retourner avec des nodes "item" ajoutés. */ public static node retourneNodeMenu(node nod , node menu, Integer niv, Integer Compteur) { if(nod==null) return null; if(nod.getAttributs().get("addmenu")!=null) { boolean erreur = false; if(nod.getAttributs().get("addmenu").equals("true")) { node newnode = new node(); newnode.setNomElt("item"); String titre =""; if(nod.getAttributs().get("titre")!=null) { titre = nod.getAttributs().get("titre"); newnode.getAttributs().put("titre",titre); } if(nod.getAttributs().get("titre1")!=null) { titre = nod.getAttributs().get("titre1"); newnode.getAttributs().put("titre",titre); } if(nod.getAttributs().get("titre2")!=null) { titre = nod.getAttributs().get("titre2"); newnode.getAttributs().put("titre",titre); } if(nod.getAttributs().get("titre3")!=null) { titre = nod.getAttributs().get("titre3"); newnode.getAttributs().put("titre",titre); } newnode.getAttributs().put("niveau",String.valueOf(niv)); newnode.getAttributs().put("name",nod.getNomElt()); newnode.getAttributs().put("id","#M"+ titre.replace(" ", "")); menu.getNodes().add(newnode); } if(nod.getAttributs().get("evaluer")!=null) { if(nod.getAttributs().get("evaluer").equalsIgnoreCase("true")) { if(nod.getAttributs().get("addmenu").equals("false") && niv==1) { System.out.println(); System.out.println("** ERREUR -- L'attribut \"addmenu\" n'est pas associé au node principal <" + nod.getNomElt() + "> dans le fichier d'analyse."); System.out.println("** -- Changer la valeur de l'attribut \"addmenu\" à TRUE."); System.out.println(); commandes.message.append("\n******************************************************"); commandes.message.append("\n ERREUR L'attribut \"addmenu\" n'est pas associé au node principal <" + nod.getNomElt() + "> dans le fichier d'analyse."); commandes.message.append("\n Changer la valeur de l'attribut \"addmenu\" à TRUE."); commandes.message.append("\n******************************************************"); erreur =true; } if(nod.getAttributs().get("addmenu").equals("true") && nod.getAttributs().get("titre")==null && nod.getAttributs().get("titre1")==null && nod.getAttributs().get("titre2")==null && nod.getAttributs().get("titre3")==null) { System.out.println(); System.out.println("** WARNING -- L'attribut \"addmenu\" n'est pas associé à un titre dans le node <" + nod.getNomElt() + ">, dans le fichier d'analyse."); commandes.message.append("\n******************************************************"); commandes.message.append("\nAVERTISSEMENT -- L'attribut \"addmenu\" n'est pas associé à un titre dans le node <" + nod.getNomElt() + ">, dans le fichier d'analyse."); commandes.message.append("\n******************************************************"); if(nod.getAttributs().get("titre")==null && nod.getAttributs().get("titre1")==null && nod.getAttributs().get("titre2")==null && nod.getAttributs().get("titre3")==null){ System.out.println("** -- Ajouter l'attribut \"titre\" à ce node."); commandes.message.append("\n******************************************************"); commandes.message.append("\n Ajouter l'attribut \"titre\" à ce node."); commandes.message.append("\n******************************************************"); } if(nod.getAttributs().get("titre").isEmpty()){ System.out.println("** -- Ajouter l'attribut \"titre\" une valeur."); commandes.message.append("\n******************************************************"); commandes.message.append("\n Ajouter l'attribut \"titre\" une valeur."); commandes.message.append("\n******************************************************"); } if(nod.getAttributs().get("titre1").isEmpty()){ System.out.println("** -- Ajouter l'attribut \"titre1\" une valeur."); commandes.message.append("\n******************************************************"); commandes.message.append("\n Ajouter l'attribut \"titre1\" une valeur."); commandes.message.append("\n******************************************************"); } if(nod.getAttributs().get("titre2").isEmpty()){ System.out.println("** -- Ajouter l'attribut \"titre2\" une valeur."); commandes.message.append("\n******************************************************"); commandes.message.append("\n Ajouter l'attribut \"titre2\" une valeur."); commandes.message.append("\n******************************************************"); } if(nod.getAttributs().get("titre3").isEmpty()){ System.out.println("** -- Ajouter l'attribut \"titre2\" une valeur."); commandes.message.append("\n******************************************************"); commandes.message.append("\n Ajouter l'attribut \"titre2\" une valeur."); commandes.message.append("\n******************************************************"); } System.out.println(); erreur =true; } //*************************** //** bye bye analyseWriter ** //*************************** if(commandes.console) if(erreur) commandes.clotureApplicationAvecErreur(); } } } for(int i = 0 ; i < nod.getNodes().size();i++) { menu = retourneNodeMenu(nod.getNodes().get(i), menu, niv+1, Compteur++); } return menu; } /** * Lecture du fichier Writer des étudiants et fournir tous les nodes de la lecture dans un node nommé "fichier".
* Permet aussi de créer un fichier d'analyse à partir d'un fichier ODF.
* @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") public 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 = nod.retourneFirstEnfantsByName("office:text"); //a.NodeFirstName(nodecontent, "office:text"); node nodmeta = nod.retourneFirstEnfantsByName("office:meta"); // ajoute les créateurs ou éditeur dans les nodes dc:creator ou meta:initial-creator // Pour permettre l'analyse avec les attributs evalNameCreator ou evalNameInitialCreator if(nodmeta.retourneEnfantsByNameExist("dc:creator")) { if(a.getLectDossiers().getEC().getListeNomDossier().get(i)!=null) { nodmeta.retourneFirstEnfantsByName("dc:creator").getAttributs().put("creator", a.getLectDossiers().getEC().getListeNomDossier().get(i)); }else { nodmeta.retourneFirstEnfantsByName("dc:creator").getAttributs().put("creator", "null"); } } if(nodmeta.retourneEnfantsByNameExist("meta:initial-creator")) { if(a.getLectDossiers().getEC().getListeNomDossier().get(i)!=null) { nodmeta.retourneFirstEnfantsByName("meta:initial-creator").getAttributs().put("initial-creator", a.getLectDossiers().getEC().getListeNomDossier().get(i)); }else { nodmeta.retourneFirstEnfantsByName("meta:initial-creator").getAttributs().put("initial-creator", "null"); } } 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")); nodstyleparagraphe.addNode(a.NodesAyantAttribut(nodstyle, "style:family","section")); nodstyleparagraphe.addNode(a.NodesAyantAttribut(nodstyle, "style:family","graphic")); nodstyleparagraphe.addNode(a.NodesAyantAttribut(nodstyle, "style:family","table")); nodstyleparagraphe.addNode(a.NodesAyantAttribut(nodstyle, "style:family","table-column")); nodstyleparagraphe.addNode(a.NodesAyantAttribut(nodstyle, "style:family","table-row")); nodstyleparagraphe.addNode(a.NodesAyantAttribut(nodstyle, "style:family","table-cell")); nodstyleparagraphe.addNode(nodstyle.retourneEnfantsByName("number:date-style", new ArrayList())); nodstyleparagraphe.addNode(nodstyle.retourneEnfantsByName("number:time-style", new ArrayList())); nodstyleparagraphe = ajouteValeurLesValeursDuStyleParagraphParent(nodstyleparagraphe); nodstyleparagraphe = ajouteValeurParDefautAuStyleParagraph(nodstyleparagraphe); //Nettoyer des nodes null les styles // nettoyerDesNoddesNull(nodstyleparagraphe); //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")); //Problème place des doublons dans la liste des nodes 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")); // le node table:table node nodtableaux = new node(); nodtableaux.setNomElt("tableaux"); nodtableaux.addNode(a.retourneNames(nodbody, "table:table")); // 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 ; j0) { String titreIndex=A.get(j).retourneFirstEnfantsByName("text:index-title-template").getContenu().get(0).toLowerCase(); titreIndex = titreIndex.replace(" ", "_"); A.get(j).retourneFirstEnfantsByName("text:table-of-content-source").setNomElt("text:table-of-content-source"+titreIndex); nodtable.getNodes().add(A.get(j)); }else { String titreIndex = "null"; titreIndex = titreIndex.replace(" ", "_"); A.get(j).retourneFirstEnfantsByName("text:table-of-content-source").setNomElt("text:table-of-content-source"+titreIndex); nodtable.getNodes().add(A.get(j)); } } //index illustration node nodillustrations = new node(); nodillustrations.setNomElt("tableillustrations"); //nodillustrations.addNode(a.retourneNames(nodbody, "text:illustration-index")); //avant // renomme le node text:illustration-index-source en text:illustration-index-sourceTitreIndex A = a.retourneNames(nodbody, "text:illustration-index"); 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; //************************************************************************************** //** Cette partie est a revoir car lorsque la table des matières est sur deux pages ** //** alors n'affiche pas les deux pages. ** //************************************************************************************** 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 de page manuel if(sautDePage(nodstructure, compteurpage, j, a, nodstyleparagraphe, nodpage, page)) continue; // Les sauts de page manuel if(sautDePageHorsTextEtTitre(nodstructure, j, compteurpage, a, nodstyleparagraphe, nodpage, page)) continue; // Les sauts de page manuel if(sautDePageParmiTousLesEnfants(nodstructure, j, compteurpage, a, nodstyleparagraphe, nodpage, page)) continue; // Les sauts de page automatique if(sautDePageAutomatique(nodstructure, compteurpage, j, a, nodpage, page))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 graphiques 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!=null) 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(usage1=="1") { if(nodpage.get(j).getNodes().size()>0) { if(nodpage.get(j).getNodes().get(0)!=null) { if(nodpage.get(j).getNodes().get(0).getAttributs().get("text:style-name")!=null) { String styleParagraphe = nodpage.get(j).getNodes().get(0).getAttributs().get("text:style-name"); node nod6 = a.retourneFirstNodeByNameAttributValue(nodstyleparagraphe, "style:style", "style:name", styleParagraphe); if(nod6!=null) { node nod7 = nod6.retourneFirstEnfantsByName("style:paragraph-properties"); if(nod7.getAttributs().get("style:page-number")!=null) { if(!nod7.getAttributs().get("style:page-number").equals("auto")) { int numeroPage = Integer.valueOf(nod7.getAttributs().get("style:page-number")); if(numeroPage%2==0) {usage1="left";}else{usage1="right";} } } } } } } } 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!=null) 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(usage2=="2") { if(nodpage.get(j-1).getNodes().size()>0) { if(nodpage.get(j-1).getNodes().get(0)!=null) { if(nodpage.get(j).getNodes().size()>0) { if(nodpage.get(j).getNodes().get(0).getAttributs().get("text:style-name")!=null) { String styleParagraphe = nodpage.get(j).getNodes().get(0).getAttributs().get("text:style-name"); node nod6 = a.retourneFirstNodeByNameAttributValue(nodstyleparagraphe, "style:style", "style:name", styleParagraphe); if(nod6!=null) { node nod7 = nod6.retourneFirstEnfantsByName("style:paragraph-properties"); if(nod7.getAttributs().get("style:page-number")!=null) { if(!nod7.getAttributs().get("style:page-number").equals("auto")) { int numeroPage = Integer.valueOf(nod7.getAttributs().get("style:page-number")); if(numeroPage%2==0) {usage2="left";}else{usage2="right";} } } } } } } } } 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!=null) 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 * @param suitenodes * @return */ public static node attributLesParentsAuxNodes(node nod){ for(int i = 0 ; i * @param nod * @return */ private static node PlaceLePere(node nod) { for(int i = 0 ; i * 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 */ public static node chargementFichierAnalyse(String nameSujet, Boolean sansNodeEvaluer) throws CloneNotSupportedException, IOException { String targetString = ""; //read file into stream, try-with-resources String cheminVerFichierAnalyse = Run.path + "/" + nameSujet; if(!commandes.console) cheminVerFichierAnalyse = commandes.PathFilenameAnalysis; try { BufferedReader br = new BufferedReader( new InputStreamReader( new FileInputStream(cheminVerFichierAnalyse), "UTF-8")); String line; while ((line = br.readLine()) != null) { targetString = targetString + line; } br.close(); }catch (Exception e) { System.out.println(); System.out.println("** Le fichier \"" + nameSujet + "\" n'est pas dans le dossier courant."); System.out.println("** Le dossier courant de l'application est : " + commandes.path); 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 = Run.XMLContent(targetString); //Supprime l'historique des modifications commandes.sujet.supprimeTousLesNodesEnfantWithThisName("text:tracked-changes"); commandes.sujet.supprimeTousLesNodesEnfantWithThisName("text:change-start"); commandes.sujet.supprimeTousLesNodesEnfantWithThisName("text:change-end"); commandes.sujet.supprimeTousLesNodesEnfantWithThisName("text:deletion"); commandes.sujetSauvegarde = commandes.sujet.clone(); } if(sansNodeEvaluer) { LeNodeSujet = Run.NodesAyantAttributEvaluerTRUEavecComplement(LeNodeSujet); } return LeNodeSujet; } /** * Chargement des paramètres du fichier d'analyse.
*/ public static void chargementParametresFichierAnalyse() { try { //** Chargement du titre de l'exercice if(commandes.sujet.getAttributs().get("titre")!=null) { commandes.analyse_titre=commandes.sujet.getAttributs().get("titre"); }else { commandes.analyse_titre = ""; } // Chargement de la progression if(commandes.sujet.getAttributs().get("progression")!=null) { commandes.analyse_progression= Double.valueOf(commandes.sujet.getAttributs().get("progression")); }else { commandes.analyse_progression = 1.0; } // Chargement de la notefrom if(commandes.sujet.getAttributs().get("notefrom")!=null) { commandes.analyse_notefrom= Double.valueOf(commandes.sujet.getAttributs().get("notefrom")); }else { commandes.analyse_notefrom = 20.0; } // Chargement de la date de creation if(commandes.sujet.getAttributs().get("creationDate")!=null) { commandes.analyse_creationDate= commandes.sujet.getAttributs().get("creationDate"); }else { commandes.analyse_creationDate = ""; } // Chargement de modificationDateMini if(commandes.sujet.getAttributs().get("modificationDateMini")!=null) { commandes.analyse_modificationDateMini= formatDateWriter.DateLibreOffice(commandes.sujet.getAttributs().get("modificationDateMini")); }else { commandes.analyse_modificationDateMini= null; } // Chargement de la version if(commandes.sujet.getAttributs().get("version")!=null) { commandes.analyse_version= commandes.sujet.getAttributs().get("version"); }else { commandes.analyse_version = ""; } // Chargement du link_sujet if(commandes.sujet.getAttributs().get("link_sujet")!=null) { commandes.analyse_link_sujet= commandes.sujet.getAttributs().get("link_sujet"); }else { commandes.analyse_link_sujet = ""; } // Chargement du link_help if(commandes.sujet.getAttributs().get("link_help")!=null) { commandes.analyse_link_help= commandes.sujet.getAttributs().get("link_help"); }else { commandes.analyse_link_help = ""; } // Chargement du controleDateCreation if(commandes.sujet.getAttributs().get("controleDateCreation")!=null) { commandes.analyse_controleDateCreation = Boolean.valueOf(commandes.sujet.getAttributs().get("controleDateCreation")); }else { commandes.analyse_controleDateCreation = false; } // Chargement du modificationDateMini if(commandes.sujet.getAttributs().get("controleDateModificationMini")!=null) { commandes.analyse_controleDateModificationMini = Boolean.valueOf(commandes.sujet.getAttributs().get("controleDateModificationMini")); }else { commandes.analyse_controleDateModificationMini = false; } // Chargement du presenceMetaSujet if(commandes.sujet.getAttributs().get("presenceMetaSujet")!=null) { commandes.analyse_presenceMetaSujet = Boolean.valueOf(commandes.sujet.getAttributs().get("presenceMetaSujet")); }else { commandes.analyse_presenceMetaSujet = false; } // Chargement du historiquePresent if(commandes.sujet.getAttributs().get("historiquePresent")!=null) { commandes.analyse_historiquePresent = Boolean.valueOf(commandes.sujet.getAttributs().get("historiquePresent")); }else { commandes.analyse_historiquePresent = false; } // Chargement du baremeABC if(commandes.sujet.getAttributs().get("baremeABC")!=null) { commandes.analyse_baremeABC = Boolean.valueOf(commandes.sujet.getAttributs().get("baremeABC")); }else { commandes.analyse_baremeABC = false; } // Chargement du controle_Initial_Creator if(commandes.sujet.getAttributs().get("controle_Initial_Creator")!=null) { commandes.analyse_controle_Initial_Creator = Boolean.valueOf(commandes.sujet.getAttributs().get("controle_Initial_Creator")); }else { commandes.analyse_controle_Initial_Creator = false; } // Chargement du metaSujet if(commandes.sujet.getAttributs().get("metaSujet")!=null) { commandes.analyse_metaSujet= commandes.sujet.getAttributs().get("metaSujet"); }else { commandes.analyse_metaSujet = "?"; } // Chargement du auteur if(commandes.sujet.getAttributs().get("auteur")!=null) { commandes.analyse_auteur= commandes.sujet.getAttributs().get("auteur"); }else { commandes.analyse_auteur = ""; } // Chargement du Initial_Creator if(commandes.sujet.getAttributs().get("Initial_Creator")!=null) { commandes.analyse_Initial_Creator= commandes.sujet.getAttributs().get("Initial_Creator"); }else { commandes.analyse_Initial_Creator = ""; } // Chargement du date if(commandes.sujet.getAttributs().get("date")!=null) { commandes.analyse_date= commandes.sujet.getAttributs().get("date"); }else { commandes.analyse_date = ""; } //Charge le hash if(commandes.sujet.getAttributs().get("hash")!=null) { commandes.analyse_hash= commandes.sujet.getAttributs().get("hash"); }else { commandes.analyse_hash = ""; } //Charge le analysis_filename if(commandes.sujet.getAttributs().get("analysis_filename")!=null) { commandes.analysis_filename= commandes.sujet.getAttributs().get("analysis_filename"); }else { commandes.analysis_filename =""; } //***************************************************************** //** chargement de la culture qui se trouve dans le node setting ** //***************************************************************** if(commandes.sujet.retourneFirstEnfantsByName("setting").isHasAttributs()) { if(commandes.sujet.retourneFirstEnfantsByName("setting").getAttributs().get("culture")!=null) { commandes.culture = commandes.sujet.retourneFirstEnfantsByName("setting").getAttributs().get("culture"); //récupère la culture de l'utilisateur } } //******************************************************************* //** Charge pour la taille et le nom de l'archive de l'archive ZIP ** //******************************************************************* if(commandes.sujet.containElementByName("zip")) { node zip = commandes.sujet.retourneFirstEnfantsByName("zip"); if(zip.getAttributs().get("size")!=null) commandes.analyse_size = Long.valueOf(zip.getAttributs().get("size")); if(zip.getAttributs().get("nameZip")!=null) commandes.analyse_nameZip = zip.getAttributs().get("nameZip"); } //*********************************************************************** //** chargement du node translation qui se trouve dans le node setting ** //*********************************************************************** evaluation.chargeTraduction(Run.translation()); //Premièrement chargement depuis l'application if(commandes.sujet.containElementByName("translation")) { evaluation.chargeTraduction(commandes.sujet.retourneFirstEnfantsByName("translation")); //Mise à jour depuis le fichier } //************************************************ //** Charge les nouvelles tolérances pour texte ** //************************************************ if(commandes.sujet.containElementByName("text:similarity")) { node similarity = commandes.sujet.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 les paramètres pour analyse de l'historique ** //*********************************************************** if(commandes.sujet.containElementByName("plagiarism")) { node plagiarism = commandes.sujet.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")); if(plagiarism.getAttributs().get("analyse_exclure_name_creator") != null) commandes.analyse_exclure_name_creator = Boolean.valueOf(plagiarism.getAttributs().get("analyse_exclure_name_creator")); if(plagiarism.getAttributs().get("analyse_auteur_exclure_historique") != null) commandes.analyse_auteur_exclure_historique = String.valueOf(plagiarism.getAttributs().get("analyse_auteur_exclure_historique")); } //************************************** //** Charge tolerance pour la couleur ** //************************************** if(commandes.sujet.containElementByName("color")) { node color = commandes.sujet.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); } //** Adéquation par les valeurs par défaut si pas dans le fichier d'analyse commandes.analyse_culture = commandes.culture; commandes.analyse_tolerance_characters = commandes.tolerance_characters; commandes.analyse_tolerance_text = commandes.tolerance_text; } // /** // * Parcour l'ensemble des fichiers des étudiants, verification, analyse, création des feedbacks et CSV. // * @throws IOException // * @throws ParserConfigurationException // * @throws SAXException // * @throws CloneNotSupportedException // * @throws ParseException // */ // public static void analyseVerifieHistoriqueLesFichiersEtudiantsEtExportNoteCSV(JEditorPane txt) throws IOException, ParserConfigurationException, SAXException, CloneNotSupportedException, ParseException { // // commandes.message = new StringBuilder(); // commandes.message.append("\n *** LES FICHIERS ANALYSES & EVALUES ***\n"); // commandes.message.append("\n"); // commandes.message.append("\n Dossier contenant les fichiers des étudiants."); // commandes.message.append("\n " + commandes.path + "\n"); // commandes.message.append("\n Les fichiers des étudiants ne sont pas dans des dossiers nominatifs ?"); // commandes.message.append(" " + commandes.fichierStudentMoodle+"\n"); // // Run a = new Run(commandes.path,commandes.Profil, commandes.fichierStudentMoodle); // // // // // //***************************************** // //** Nombre de fichier writer à analyser ** // //***************************************** // int nbFichierWriter = a.getLectDossiers().getEC().getListeContentWriter().size(); // commandes.analyse_Nbre_Fichier_Student = nbFichierWriter; // commandes.message.append("\nNombre de fichier à analyser et évaluer : " + Integer.valueOf(nbFichierWriter) + "\n"); // // // //*************************************** // //** -verif ou -use file.xml -verifcsv ** // //*************************************** // node verif = new node(); // if(commandes.verifHisto || commandes.verifHisto2) { // 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 = Run.XMLContent(a.getLectDossiers().getEC().getListeContentWriter().get(i)); // node nodStudent = meptl.LectureFichierEtudiantPourVerification(nod,a,i); // verification.getNodes().add(nodStudent); // } // //a.ecritureNodeEnXML(verification, "VerificationHistorique","",false); //écriture du node de l'étudiant // verif = VerificationHistorique.verificationHistorique(verification, a, evaluate.getTxtpnmessages()); // vérification des correspondances entre les fichiers // // //******************************** // //** Ecriture du node verif.xml ** // //******************************** // Run.ecritureNodeEnXML(verif, "Verif",commandes.path, Run.TypeFile.Verif); //écriture du node de vérification // commandes.message.append("\n*******************************************************"); // commandes.message.append("\nEcriture du fichier Verif.xml dans le dossier d'analyse"); // commandes.message.append("\n*******************************************************"); // if(!commandes.analyse) { // //** bye bye analyseWriter // commandes.clotureApplication(); // } // } // // //********************************************************* // //** Node contenant l'ensemble des analyses des étudiants ** // //********************************************************* // node ensembleanalyse = new node(); // ensembleanalyse.setNomElt("analyses"); // // //***************************************************** // //** Parcours l'ensemble des fichiers des étudiants *** // //***************************************************** // for(int i = 0 ; i < nbFichierWriter ; i++) { // // //index de l'étudiant // commandes.analyse_index_Fichier_Student = 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; // // //*********************************************************** // //** Lecture et transformation en node du fichier étudiant ** // //*********************************************************** // node nod = Run.XMLContent(a.getLectDossiers().getEC().getListeContentWriter().get(i)); // node nodStudent = meptl.LectureFichierEtudiantSousFormeDeNode(nod,a,i); // //a.ecritureNodeEnXML(nodStudent, a.getLectDossiers().getEC().getListeNomDossier().get(i),"",false,""); //écriture du node de l'étudiant // // //********************************** // //** Analyse des fichiers student ** // //********************************** // if(commandes.analyse||commandes.ecritNodeAnalyse) { //// Run.ecritureNodeEnXML(nodStudent, "fichier student","",false,""); //écriture du node nodStudent de l'étudiant // node ana = analyseFichier.analyse(nodStudent, commandes.sujet, i, a, txt, String.valueOf(nbFichierWriter)); // // //************************************************** // //** Ecriture des fichiers d'analyse des students ** // //************************************************** // if(commandes.ecritNodeAnalyse) { // Run.ecritureNodeEnXML(ana, "nodana"+ana.retourneFirstEnfantsByName("ouverture").getAttributs().get("dossier"),commandes.path,Run.TypeFile.Analyse); //écriture du node analyse de l'étudiant // } // // //**************************** // //** Création des feedbacks ** // //**************************** // if(!commandes.sansFeeback&&!commandes.ecritNodeAnalyse) { // if(!commandes.zipfeedback) { // //feedback(ana, verif); //classique directement dans le répertoire // feedbacks.feedback(ana,verif, false,false); // } // if(commandes.zipfeedback) { // Dans une archive pour Moodle // try { //// a.AddStreamToZip(feedbacks.feedback(ana, verif, true,false), meptl.retourneLeNomDuFeedback(a.getLectDossiers().getEC().getListeNomFichierFeedBack().get(i),ana, verif),commandes.analyse_size,commandes.analyse_nameZip); // //Modification suite à Moodle4 // a.AddStreamToZip(feedbacks.feedback(ana, verif, true,false), meptl.retourneLeNomDuFeedbackMoodle4(a.getLectDossiers().getEC().getListeFichierodt().get(i),ana, verif),commandes.analyse_size,commandes.analyse_nameZip); // } catch (ZipException e) { // e.printStackTrace(); // } catch (IOException e) { // e.printStackTrace(); // } // } // } // // //******************************************************************************** // //** Ajoute au node ensembleanalyse lorsque -csv file.csv ou -verifcsv file.scv ** // //******************************************************************************** // if(commandes.ecritNoteCSV) ensembleanalyse.addNode(ana); // // //********************************************************* // //** Message dans la console sur l'analyse de l'étudiant ** // //********************************************************* // commandes.message.append(meptl.messageSystem(ana).toString()); // } // } // // // //***************************************************** // //** Exportation au format CSV si -csv ou -verifcsv ** // //***************************************************** // if(commandes.ecritNoteCSV && !commandes.fourniCSV) { // if(!commandes.verifHisto2) ecritureCSV(ensembleanalyse); // if(commandes.verifHisto2) ecritureCSV(ensembleanalyse,verif,a,commandes.sujet.retourneFirstEnfantsByName("setting")); // //a.ecritureNodeEnXML(ensembleanalyse, "ensembleAnalyse"); //écriture du node de l'étudiant // } // // //*********************************************************************** // //** Exportation au format CSV si -csv file.csv ou -verifcsv file.csv ** // //*********************************************************************** // if(commandes.ecritNoteCSV && commandes.fourniCSV) { // ecritureCSV(ensembleanalyse,verif,a,commandes.nodeCSV, commandes.sujet.retourneFirstEnfantsByName("setting")); // //a.ecritureNodeEnXML(ensembleanalyse, "ensembleAnalyse"); //écriture du node de l'étudiant // } // // //************************************** // //** Mise à jour du fichier d'analyse ** // //************************************** // if(commandes.MAJFichierAnalyse||commandes.MAJnameAnalysisFile) { // verificationFichierAnalyse.MiseAJourFichierAnalyse(); // verificationFichierAnalyse.messagMiseAJourFichierAnalyseAprèsAnalyse(); // } // // // } /** * 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. */ public 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().get(0))) { 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().toString().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().get(0).equals(nodSujet.getAttributs().get("Initial_Creator"))) { manqueInitialCreator = true; } }else { System.out.println("Erreur, il n'y a pas de créateur initial."); } }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; } /** * Retourne le nom du fichier de l'étudiant pour le Zip pour Moodle 3.
*
* @param filename * @param nodana * @return */ public 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; } /** * Retourne le nom du fichier de l'étudiant pour le Zip pour Moodle 4.
* @param filename * @param nodana * @param verif * @return */ public static String retourneLeNomDuFeedbackMoodle4( String filename,node nodana, node verif) { filename = filename.replace(".odt", ""); return filename + ".html"; } /** * Affichage uniquement dans la console Les erreurs. * @param nod */ public static StringBuilder messageSystem(node nod) { StringBuilder Text = new StringBuilder(); node ouverture = nod.retourneFirstEnfantsByName("ouverture"); node notation = nod.retourneFirstEnfantsByName("bodyetnotation"); node erreurs = nod.retourneFirstEnfantsByName("erreurs"); boolean flagError = Boolean.valueOf(erreurs.getAttributs().get("oneError")); Text.append("
"); if(!commandes.fichierStudentMoodle) { Text.append("

Dossier analysé : " + ouverture.getAttributs().get("dossier") + "

"); } else { Text.append("

Fichier analysé : " + ouverture.getAttributs().get("dossier")+"

"); } if(notation.getAttributs().get("baremeABC").equals("true")) { Text.append("

Note : " + notation.getAttributs().get("noteABC")+"

"); System.out.println("\nNote : " + notation.getAttributs().get("noteABC")); }else { Text.append("

Note : " + notation.getAttributs().get("note") + "/" + ouverture.getAttributs().get("notefrom")+"

"); System.out.println("\nNote : " + notation.getAttributs().get("note") + "/" + ouverture.getAttributs().get("notefrom")); } if(flagError) { Text.append("

ERREUR dans le fichier de l'étudiant.

"); System.out.println("\t ERREUR dans le fichier de l'étudiant."); if(Boolean.valueOf(erreurs.getAttributs().get("manqueHistorique"))) { Text.append("

Erreur : Il n'y a pas d'historique dans le fichier.Peut être que le fichier n'a pas été modifié ou il a été réïnitialisé par l'étudiant.

"); System.out.println("\t Erreur : Il n'y a pas d'historique dans le fichier.Peut être que le fichier n'a pas été modifié ou il a été réïnitialisé par l'étudiant."); } if(Boolean.valueOf(erreurs.getAttributs().get("manqueCreationDate"))) { Text.append("

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 de l'évaluation.

"); System.out.println("\t 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 de l'évaluation."); } if(Boolean.valueOf(erreurs.getAttributs().get("manqueValeurCreationDate"))) { Text.append("

Erreur : Ce n'est pas la bonne date de création du fichier.

"); System.out.println("\t Erreur : Ce n'est pas la bonne date de création du fichier."); } if(Boolean.valueOf(erreurs.getAttributs().get("manqueMetaSujet"))) { Text.append("

Erreur : La propriété personnalisé \"Sujet\" a été supprimé dans le fichier de l'étudiant.

"); System.out.println("\t Erreur : La propriété personnalisé \"Sujet\" a été supprimé dans le fichier de l'étudiant."); } if(Boolean.valueOf(erreurs.getAttributs().get("manqueValeurMetaSujet"))) { Text.append("

Erreur : La propriété personnalisé \"Sujet \" a été modifié par l'étudiant.\nLa valeur de cette propriété personnalisé dans le fichier de l'étudiant est \"" + ouverture.getAttributs().get("metaSujet")+"\".\nCe n'est pas la valeur correct.

"); System.out.println("\t Erreur : La propriété personnalisé \"Sujet \" a été modifié par l'étudiant.\nLa valeur de cette propriété personnalisé dans le fichier de l'étudiant est \"" + ouverture.getAttributs().get("metaSujet")+"\".\nCe n'est pas la valeur correct."); } if(Boolean.valueOf(erreurs.getAttributs().get("manqueInitialCreator"))) { Text.append("

Erreur : Le créateur initial ne correspond pas au créateur initial du fichier fourni à l'étudiant.

"); System.out.println("\t Erreur : Le créateur initial n'est pas correct."); } } Text.append("

"); System.out.println(); return Text; } /** * Ajoute dans le node nodanalyse.
* Le node saut et son attribut titre
* Et place un titre, ou titre1, ou titre2, ou titre3
*
* @param nod * @return */ public static node addNodeSautTitre(node nodSujet, node nodanalyse, node nodmenu, Run a) { if(nodSujet.getAttributs().get("marquenode")!=null) { node N = new node(); N.setNomElt("saut"); N.getAttributs().put("marquenode", nodSujet.getAttributs().get("marquenode")); N.setParent(nodanalyse); N.setClose(true); nodanalyse.getNodes().add(N); } if(nodSujet.getAttributs().get("titre")!=null) { node N = new node(); N.setNomElt("saut"); N.getAttributs().put("titre", nodSujet.getAttributs().get("titre")); N.setParent(nodanalyse); N.setClose(true); nodanalyse.getNodes().add(N); if(nodSujet.getAttributs().get("addmenu")!=null) if(nodSujet.getAttributs().get("addmenu").equalsIgnoreCase("true")) { if(a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "titre", nodSujet.getAttributs().get("titre"))!=null) { N.getAttributs().put("id", a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "titre", nodSujet.getAttributs().get("titre")).getAttributs().get("id")); N.getAttributs().put("addmenu", "true"); } } } if(nodSujet.getAttributs().get("titre1")!=null) { node N = new node(); N.setNomElt("saut"); N.getAttributs().put("titre1", nodSujet.getAttributs().get("titre1")); N.setParent(nodanalyse); N.setClose(true); nodanalyse.getNodes().add(N); if(nodSujet.getAttributs().get("addmenu")!=null) if(nodSujet.getAttributs().get("addmenu").equalsIgnoreCase("true")) { if(a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "titre", nodSujet.getAttributs().get("titre1"))!=null) { N.getAttributs().put("id", a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "titre", nodSujet.getAttributs().get("titre1")).getAttributs().get("id")); N.getAttributs().put("addmenu", "true"); } } } if(nodSujet.getAttributs().get("titre2")!=null) { node N = new node(); N.setNomElt("saut"); N.getAttributs().put("titre2", nodSujet.getAttributs().get("titre2")); N.setParent(nodanalyse); N.setClose(true); nodanalyse.getNodes().add(N); if(nodSujet.getAttributs().get("addmenu")!=null) if(nodSujet.getAttributs().get("addmenu").equalsIgnoreCase("true")) { if(a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "titre", nodSujet.getAttributs().get("titre2"))!=null) { N.getAttributs().put("id", a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "titre", nodSujet.getAttributs().get("titre2")).getAttributs().get("id")); N.getAttributs().put("addmenu", "true"); } } } if(nodSujet.getAttributs().get("titre3")!=null) { node N = new node(); N.setNomElt("saut"); N.getAttributs().put("titre3", nodSujet.getAttributs().get("titre3")); N.setParent(nodanalyse); N.setClose(true); nodanalyse.getNodes().add(N); if(nodSujet.getAttributs().get("addmenu")!=null) if(nodSujet.getAttributs().get("addmenu").equalsIgnoreCase("true")) { if(a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "titre", nodSujet.getAttributs().get("titre3"))!=null) { N.getAttributs().put("id", a.retourneFirstNodeByNameAttributValue(nodmenu, "item", "titre", nodSujet.getAttributs().get("titre3")).getAttributs().get("id")); N.getAttributs().put("addmenu", "true"); } } } if(nodSujet.getAttributs().get("information")!=null) { node N = new node(); N.setNomElt("saut"); N.getAttributs().put("information", nodSujet.getAttributs().get("information")); N.setParent(nodanalyse); N.setClose(true); nodanalyse.getNodes().add(N); } return nodanalyse; } /** * Ajoute un saut de ligne.
* @param nodSujet * @param nodanalyse * @return */ public static node addSaut(node nodSujet, node nodanalyse) { if(nodSujet.getAttributs().get("saut")!=null) { if(nodSujet.getAttributs().get("saut").equals("true")) { node N = new node(); N.setNomElt("saut"); //N.getAttributs().put("titre", ""); N.setClose(true); nodanalyse.getNodes().add(N); } } return nodanalyse; } /** * Ecriture de l'ensemble des notes brutes sans vérification et sans rechercher les identifiants des étudiants * @param nodesana * @throws IOException */ public static void ecritureCSV(node ana) throws IOException{ Date aujourdhui = new Date(); Path outputFilePath = Paths.get(commandes.path + "/DateLong" + aujourdhui.getTime()+ "-Notes.csv"); if(commandes.fourniDossierDestination) outputFilePath = Paths.get(commandes.path +"/"+ commandes.pathDestination + "/DateLong" + aujourdhui.getTime()+ "-Notes.csv"); if(!commandes.fourniDossierDestination) System.out.println(commandes.path +"\\DateLong" + aujourdhui.getTime()+ "-Notes.csv"); if(commandes.fourniDossierDestination) System.out.println(commandes.path +"\\"+ 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(); commandes.message.append("\n"); commandes.message.append("*************************"); commandes.message.append("\n"); commandes.message.append("\nLe fichier au format CSV a été généré."); commandes.message.append("\n" + outputFilePath.toString()); commandes.message.append("\n"); commandes.message.append("*************************"); } /** * Ecriture du fichier CSV avec vérification.
* Mais sans rechercher les identifiants des étudiants. * @param ana * @param verif * @param a * @throws IOException */ public 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(commandes.path + "/DateLong" + aujourdhui.getTime()+ "-Notes.csv"); if(commandes.fourniDossierDestination) outputFilePath = Paths.get(commandes.path +"/"+ commandes.pathDestination + "/DateLong" + aujourdhui.getTime()+ "-Notes.csv"); if(!commandes.fourniDossierDestination) System.out.println(commandes.path +"\\DateLong" + aujourdhui.getTime()+ "-Notes.csv"); if(commandes.fourniDossierDestination) System.out.println(commandes.path +"\\"+ 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 * Mais avec rechercher des identifiants des étudiants.
* @param ana * @param verif * @param a * @param nodeCVS * @param verification * @throws IOException */ public 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(commandes.path + "/DateLong" + aujourdhui.getTime()+ "-Notes.csv"); if(commandes.fourniDossierDestination) outputFilePath = Paths.get(commandes.path +"/"+ commandes.pathDestination + "/DateLong" + aujourdhui.getTime()+ "-Notes.csv"); if(!commandes.fourniDossierDestination) System.out.println(commandes.path +"\\DateLong" + aujourdhui.getTime()+ "-Notes.csv"); if(commandes.fourniDossierDestination) System.out.println(commandes.path +"\\"+ 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 //** correction des noms ayant des " - - " ou "- -" en "--" if(identification.contains(" - - ")) identification.replaceAll(" - - ", "--"); if(identification.contains("- -")) identification.replaceAll("- -", "--"); if(identification.contains(" - ")) identification.replaceAll(" - ", "-"); 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(); commandes.message.append("\n"); commandes.message.append("*-***********************"); commandes.message.append("\n"); commandes.message.append("\nLe fichier au format CSV a été généré."); commandes.message.append("\n" + outputFilePath.toString()); commandes.message.append("\n"); commandes.message.append("*************************"); } /** * Traitement de la durée d'édition.
*
* @param dureeEdition * @return */ public 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; } /** * Chargement et ajoute dans le node fileCSV la liste des étudiants.
* Par défaut :
* La liste des étudiants doit contenir les champs Prénom, Nom, identification, adresse
* Le séparateur doit être le point-virgule et l'encodage UTF-8.
* @param a * @param nameCSV * @return * @throws IOException */ public static void chargementFichierCSV() { String targetString = ""; String cheminVersLeFichierCSV = ""; if(commandes.console) cheminVersLeFichierCSV = commandes.path + "/" + commandes.nameCSV; if(!commandes.console) { commandes.nameCSV = commandes.nameCSV.replace("\\", "/"); cheminVersLeFichierCSV = commandes.nameCSV; } try { BufferedReader br = new BufferedReader( new InputStreamReader( new FileInputStream(cheminVersLeFichierCSV), "UTF-8")); String line; while ((line = br.readLine()) != null) { targetString = targetString + line + "\n"; } br.close(); } catch (IOException e) { commandes.ErrorFile(cheminVersLeFichierCSV); e.printStackTrace(); } String[] target = targetString.split("\\n"); node csv = commandes.sujet.retourneFirstEnfantsByName("csv"); String separator = csv.getAttributs().get("separator"); node import_csv = csv.retourneFirstEnfantsByName("import_moodle"); String nameid = import_csv.getAttributs().get("id"); String nameemail = import_csv.getAttributs().get("email"); String nameStudent = import_csv.getAttributs().get("name"); String firstnameStudent = import_csv.getAttributs().get("firstname"); if(!target[0].contains(separator)||!target[0].contains(nameid) ||!target[0].contains(nameemail)||!target[0].contains(nameStudent) ||!target[0].contains(firstnameStudent)) { JOptionPane.showMessageDialog(null, "Le fichier CSV ne correspond pas\nà la définition des paramètres d'importation", "Erreur CSV", JOptionPane.INFORMATION_MESSAGE); return ; } 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(separator)[j]); } if(nodeEtudiant.getAttributs().get(nameemail)!=null && nodeEtudiant.getAttributs().get(nameid)!=null && nodeEtudiant.getNbrAttributs()==4) { node n1 = commandes.nodeCSV.retourneFirstNodeByNameAndAttributValueExactStrict("student", nameid, nodeEtudiant.getAttributs().get(nameid)); node n2 = commandes.nodeCSV.retourneFirstNodeByNameAndAttributValueExactStrict("student", nameemail, nodeEtudiant.getAttributs().get(nameemail)); if(n1==null && n2==null) commandes.nodeCSV.getNodes().add(nodeEtudiant); } } } /** * Supprime le node du fichier CSV de la liste des étudiants.
* @param a * @param nameCSV * @return * @throws IOException */ public static node supprimeFichierCSV() { node nodeCVS = new node("fileCSV"); commandes.nameCSV=""; return nodeCVS; } /** * Affiche la liste des étudiants chargée. * @return */ public static StringBuilder afficheNodeCSV() { StringBuilder sb = new StringBuilder(); if(commandes.fourniCSV) { node filecsv = commandes.evaluationChargeEnMemoire.retourneFirstEnfantsByName("fileCSV"); String namelistStudent = ""; if(filecsv.getAttributs().get("nameListStudent")!=null) namelistStudent = filecsv.getAttributs().get("nameListStudent"); // Importation par défaut node import_csv = commandes.sujet.retourneFirstEnfantsByName("import_moodle"); String nameid = import_csv.getAttributs().get("id"); String nameemail = import_csv.getAttributs().get("email"); String name = import_csv.getAttributs().get("name"); String firstname = import_csv.getAttributs().get("firstname"); if(filecsv.getAttributs().get("id")!=null) nameid = filecsv.getAttributs().get("id"); if(filecsv.getAttributs().get("email")!=null) nameemail = filecsv.getAttributs().get("email"); if(filecsv.getAttributs().get("name")!=null) name = filecsv.getAttributs().get("name"); if(filecsv.getAttributs().get("firstname")!=null) firstname = filecsv.getAttributs().get("firstname"); sb.append(""); sb.append("

Liste des étudiants

"); sb.append("

Nom de la liste : " + namelistStudent + "

"); sb.append("

Cette liste permettra de réaliser l'importation des notes dans le carnet de note sur Moodle.

" + "

Vous pouvez réaliser un copié dans le tableau.


"); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); for(int i = 0 ; i < commandes.nodeCSV.getNbrEnfants();i++) { sb.append(""); } sb.append("
PrénomNomNuméro étudiantCourriel
" + (i+1) + "" + commandes.nodeCSV.getNodes().get(i).getAttributs().get(firstname) + "" + commandes.nodeCSV.getNodes().get(i).getAttributs().get(name) + "" + commandes.nodeCSV.getNodes().get(i).getAttributs().get(nameid) + "" + commandes.nodeCSV.getNodes().get(i).getAttributs().get(nameemail) +"
"); sb.append("
"); sb.append("

Nom de la liste : " + namelistStudent + "

"); sb.append("

Nombre d'étudiant dans la liste : " + commandes.nodeCSV.getNbrEnfants() + "

"); sb.append(""); } return sb; } /** * Charge le fichier SVG pour le nouveau Logo dans les feedbacks * @param a * @param nameSVG * @return */ public static String chargementFichierSVG() { String targetString = ""; String cheminVersFichier = commandes.nameSVG; if(commandes.console) cheminVersFichier =commandes.path + "/" + commandes.nameSVG; try { BufferedReader br = new BufferedReader( new InputStreamReader( new FileInputStream(cheminVersFichier), "UTF-8")); String line; while ((line = br.readLine()) != null) { targetString = targetString + line + "\n"; } br.close(); } catch (IOException e) { commandes.ErrorFile(commandes.nameSVG); e.printStackTrace(); } return targetString; } /** * Ajoute les valeurs par défaut du style de paragraphe par défaut.
* @param ensembleDesParagraphes * @return */ public static node ajouteValeurParDefautAuStyleParagraph(node ensembleDesParagraphes ) { node LeStyleDefaut = null; if(ensembleDesParagraphes.retourneEnfantsByNameExist("style:default-style")) { LeStyleDefaut = ensembleDesParagraphes.retourneFirstNodeByNameAndAttributValue("style:default-style","style:family","paragraph"); if(LeStyleDefaut==null) return ensembleDesParagraphes; if(LeStyleDefaut!=null) { if(LeStyleDefaut.getAttributs().get("style:master-page-name")==null)LeStyleDefaut.getAttributs().put("style:master-page-name","none"); node styleparagraphproperties = LeStyleDefaut.retourneFirstEnfantsByName("style:paragraph-properties"); if(styleparagraphproperties!=null) { if(styleparagraphproperties.getAttributs().get("fo:margin-bottom")==null) styleparagraphproperties.getAttributs().put("fo:margin-bottom", "0"); if(styleparagraphproperties.getAttributs().get("fo:margin-left")==null) styleparagraphproperties.getAttributs().put("fo:margin-left", "0"); if(styleparagraphproperties.getAttributs().get("fo:margin-right")==null) styleparagraphproperties.getAttributs().put("fo:margin-right", "0"); if(styleparagraphproperties.getAttributs().get("fo:margin-top")==null) styleparagraphproperties.getAttributs().put("fo:margin-top", "0"); if(styleparagraphproperties.getAttributs().get("fo:text-indent")==null) styleparagraphproperties.getAttributs().put("fo:text-indent", "0"); if(styleparagraphproperties.getAttributs().get("fo:line-height")==null) styleparagraphproperties.getAttributs().put("fo:line-height", "100%"); if(styleparagraphproperties.getAttributs().get("fo:orphans")==null) styleparagraphproperties.getAttributs().put("fo:orphans", "2"); if(styleparagraphproperties.getAttributs().get("fo:widows")==null) styleparagraphproperties.getAttributs().put("fo:widows", "2"); if(styleparagraphproperties.getAttributs().get("fo:border-bottom")==null) styleparagraphproperties.getAttributs().put("fo:border-bottom", "none"); if(styleparagraphproperties.getAttributs().get("fo:border-left")==null) styleparagraphproperties.getAttributs().put("fo:border-left", "none"); if(styleparagraphproperties.getAttributs().get("fo:border-right")==null) styleparagraphproperties.getAttributs().put("fo:border-right", "none"); if(styleparagraphproperties.getAttributs().get("fo:border-top")==null) styleparagraphproperties.getAttributs().put("fo:border-top", "none"); if(styleparagraphproperties.getAttributs().get("fo:keep-together")==null) styleparagraphproperties.getAttributs().put("fo:keep-together", "none"); if(styleparagraphproperties.getAttributs().get("fo:keep-with-next")==null) styleparagraphproperties.getAttributs().put("fo:keep-with-next", "none"); if(styleparagraphproperties.getAttributs().get("fo:break-after")==null) styleparagraphproperties.getAttributs().put("fo:break-after", "none"); if(styleparagraphproperties.getAttributs().get("fo:break-before")==null) styleparagraphproperties.getAttributs().put("fo:break-before", "none"); if(styleparagraphproperties.getAttributs().get("fo:text-align")==null) styleparagraphproperties.getAttributs().put("fo:text-align", "start"); } } } for(int i =0 ; i < ensembleDesParagraphes.getNodes().size(); i++) { node nodStyle = ensembleDesParagraphes.getNodes().get(i); if(nodStyle.getAttributs().get("style:family")!=null) { if(!nodStyle.getAttributs().get("style:family").equals("paragraph")) continue; }else { continue; } //le paragraphe properties node nodeStyleParDefautParagraphProperties = LeStyleDefaut.retourneFirstEnfantsByName("style:paragraph-properties"); node LesNodesStyleParagraph = nodStyle.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()); nodStyle.getNodes().add(n); break; } } //le text properties node nodeStyleParDefautTextProperties = LeStyleDefaut.retourneFirstEnfantsByName("style:text-properties"); node LesNodesStyleText = nodStyle.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()); nodStyle.getNodes().add(n); break; } } } return ensembleDesParagraphes; } /** * * @param ensembleDesParagraphes * @return */ public static node ajouteValeurLesValeursDuStyleParagraphParent(node ensembleDesParagraphes) { for(int i = 0 ; i < ensembleDesParagraphes.getNodes().size(); i++) { node nodStyle = ensembleDesParagraphes.getNodes().get(i); node parent = null; if(nodStyle.getAttributs().get("style:parent-style-name")!=null) { String nameStyleParent = nodStyle.getAttributs().get("style:parent-style-name"); if(ensembleDesParagraphes.retourneFirstNodeByNameAndAttributValueExactStrict("style:style", "style:name", nameStyleParent)!=null) { parent = ensembleDesParagraphes.retourneFirstNodeByNameAndAttributValueExactStrict("style:style", "style:name", nameStyleParent); } } if(parent!=null) addStyleParent(parent, nodStyle, ensembleDesParagraphes); } return ensembleDesParagraphes; } //*********************************************** //*** Ajoute les informations du style parent *** //*********************************************** private static void addStyleParent(node parent, node nodStyle, node ensembleDesParagraphes) { if(parent.getAttributs().get("style:parent-style-name")!=null) { String nameStyleParent = nodStyle.getAttributs().get("style:parent-style-name"); if(ensembleDesParagraphes.retourneFirstNodeByNameAndAttributValueExactStrict("style:style", "style:name", nameStyleParent)!=null) { node parent2 = ensembleDesParagraphes.retourneFirstNodeByNameAndAttributValueExactStrict("style:style", "style:name", nameStyleParent); if(parent!=null) addStyleParent(parent2, parent, ensembleDesParagraphes); } } //Au niveau du node Enumeration key = parent.getAttributs().keys(); while(key.hasMoreElements()) { String k = key.nextElement(); if(nodStyle.getAttributs().get(k)==null) nodStyle.getAttributs().put(k, parent.getAttributs().get(k)); } //le node enfant : style:paragraph-properties node nodeStyleParentParagraphProperties = parent.retourneFirstEnfantsByName("style:paragraph-properties"); node LesNodesStyleParagraph = nodStyle.retourneFirstEnfantsByName("style:paragraph-properties"); if(nodeStyleParentParagraphProperties!=null) { Enumeration K = nodeStyleParentParagraphProperties.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, nodeStyleParentParagraphProperties.getAttributs().get(Key)); } }else { node n = new node(); n.setNomElt("style:paragraph-properties"); n.setAttributs(nodeStyleParentParagraphProperties.getAttributs()); nodStyle.getNodes().add(n); break; } } } //le node enfant : text-properties node nodeStyleParDefautTextProperties = parent.retourneFirstEnfantsByName("style:text-properties"); node LesNodesStyleText = nodStyle.retourneFirstEnfantsByName("style:text-properties"); if(nodeStyleParDefautTextProperties!=null) { Enumeration 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()); nodStyle.getNodes().add(n); break; } } } //le node enfant : loext:graphic-properties node nodeStyleParDefautGraphicProperties = parent.retourneFirstEnfantsByName("loext:graphic-properties"); node LesNodesStyleGraphixProperties = nodStyle.retourneFirstEnfantsByName("loext:graphic-properties"); if(nodeStyleParDefautGraphicProperties!=null) { Enumeration K = nodeStyleParDefautGraphicProperties.getAttributs().keys(); while(K.hasMoreElements()){ String Key = K.nextElement(); if(LesNodesStyleGraphixProperties.getNomElt().equals("loext:graphic-properties")) { if(LesNodesStyleGraphixProperties.getAttributs().get(Key)==null) { LesNodesStyleGraphixProperties.getAttributs().put(Key, nodeStyleParDefautGraphicProperties.getAttributs().get(Key)); } }else { node n = new node(); n.setNomElt("loext:graphic-properties"); n.setAttributs(nodeStyleParDefautGraphicProperties.getAttributs()); nodStyle.getNodes().add(n); break; } } } } /** * Transformation des nodes number:date-style en style:style (pour évaluation avec analyseStyle)
* @param nodStyles */ private static void transformationNumberDateToStyle(node nodStyles, node structure) { for(int i = 0 ; i < nodStyles.getNodes().size();i++) { if(nodStyles.getNodes().get(i).getNomElt().equals("number:date-style")) { nodStyles.getNodes().get(i).setNomElt("style:style"); nodStyles.getNodes().get(i).getAttributs().put("style:family", "number:date-style"); String nameStyle= nodStyles.getNodes().get(i).getAttributs().get("style:name"); node nod = structure.retourneFirstNodeByNameAndAttributValueExactStrict("text:date", "style:data-style-name", nameStyle); if(nod!=null) { nod.getAttributs().put("text:style-name", nameStyle); } } if(nodStyles.getNodes().get(i).getNomElt().equals("number:time-style")) { nodStyles.getNodes().get(i).setNomElt("style:style"); nodStyles.getNodes().get(i).getAttributs().put("style:family", "number:time-style"); String nameStyle= nodStyles.getNodes().get(i).getAttributs().get("style:name"); node nod = structure.retourneFirstNodeByNameAndAttributValueExactStrict("text:time", "style:data-style-name", nameStyle); if(nod!=null) { nod.getAttributs().put("text:style-name", nameStyle); }else{ nod = structure.retourneFirstNodeByNameAndAttributValueExactStrict("text:editing-duration", "style:data-style-name", nameStyle); if(nod!=null) { nod.getAttributs().put("text:style-name", nameStyle); } } } } } //****************************************************************************** //** Les sauts automatiques de page dans les paragraphes (text:soft-page-break) //****************************************************************************** /** * Les sauts automatiques de page dans les paragraphes (text:soft-page-break) * Sauf dans les nodes "text:table-of-content" * @param nodstructure * @param compteurpage * @param j * @param a * @param nodpage * @param page */ private static boolean sautDePageAutomatique(node nodstructure, int compteurpage, int j, Run a, ArrayList nodpage, node page) { if(nodstructure.getNodes().get(j).retourneEnfantsByNameExist("text:soft-page-break") ) { //&& !nodstructure.getNodes().get(j).getNomElt().equals("text:table-of-content") ArrayList nods1 = a.retourneNames(nodstructure.getNodes().get(j), "text:soft-page-break"); if(nods1.size()>1) { 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)); // recherche de l'index parmis les enfants du node text:soft-page-break. int[] indexBreak = new int[nods1.size()]; indexBreak[0]=0; for(int v = 0 ; v < nods1.size() ; v++) { indexBreak[v]=-1; } int i2 = 0; for(int v = 0 ; v < nodstructure.getNodes().get(j).getNodes().size(); v++) { if(nodstructure.getNodes().get(j).getNodes().get(v).getNomElt().equals("text:soft-page-break")) { indexBreak[i2]=v; i2++; } } //Détermine s'il y a que du texte vide avant le saut automatique boolean[] ContenusVidesAvantBreak = new boolean[nods1.size()]; boolean[] insertionRealiser = new boolean[nods1.size()]; for(int v = 0 ; v < nods1.size() ; v++) { ContenusVidesAvantBreak[v]=true; insertionRealiser[v]=false; } for(int u = 0; u < nods1.size() ; u++) { for(int v = 0 ; v <= indexBreak[u]; v++) { if(nodstructure.getNodes().get(j).getContenu().size()>=1) { if(nodstructure.getNodes().get(j).getContenu().get(v)!=null) { if(ContenusVidesAvantBreak[u]) { if(!nodstructure.getNodes().get(j).getContenu().get(v).isEmpty()) { ContenusVidesAvantBreak[u]=false; } } if(v==indexBreak[u] && !ContenusVidesAvantBreak[u]) { nodstructure.getNodes().get(j).getContenu().set( v,nodstructure.getNodes().get(j).getContenu().get(v) + "** TEXT:SOFT-PAGE-BREAK **"); } } } } } // Contenu & node après le text:soft-page-break node[] textSoftPageBreak = new node[nods1.size()]; for(int u = 0; u < nods1.size() ; u++) { textSoftPageBreak[u] = new node(); textSoftPageBreak[u].setNomElt("saut:automatique"); if(!ContenusVidesAvantBreak[u]) { // Ajoute dans le node textSoftPageBreak for(int v = indexBreak[u]+1 ; v <= nodstructure.getNodes().get(j).getNodes().size(); v++) { if(nodstructure.getNodes().get(j).getContenu().size()>v) { textSoftPageBreak[u].getContenu().add(nodstructure.getNodes().get(j).getContenu().get(v)); } if(nodstructure.getNodes().get(j).getNodes().size()>v) { textSoftPageBreak[u].getNodes().add(nodstructure.getNodes().get(j).getNodes().get(v)); } } // suprresion des contenus et des nodes enfants dans le paragraphe dans le paragraphe for(int v = indexBreak[u]+1 ; v <= nodstructure.getNodes().get(j).getNodes().size(); v++) { if(nodstructure.getNodes().get(j).getContenu().size()>indexBreak[u]+1) nodstructure.getNodes().get(j).getContenu().remove(indexBreak[u]+1); } for(int v = indexBreak[u] ; v <= nodstructure.getNodes().get(j).getNodes().size(); v++) { if(nodstructure.getNodes().get(j).getNodes().size()>indexBreak[u]) nodstructure.getNodes().get(j).getNodes().remove(indexBreak[u]); } } } for(int u = 0; u < nods1.size() ; u++) { if(ContenusVidesAvantBreak[0]) { if(!insertionRealiser[0]) { p.getNodes().add(nodstructure.getNodes().get(j)); insertionRealiser[0]=true; nodpage.add(p); compteurpage++; node p1 = new node(); p1.setNomElt("page"); p1.getAttributs().put("numero", String.valueOf(compteurpage)); p1.getAttributs().put("type","automatique"); p1.getAttributs().put("index",String.valueOf(j)); p1.getNodes().add(textSoftPageBreak[u+1]); insertionRealiser[1]=true; if(nods1.size()<3) { nodpage.add(p1); compteurpage++; } } if(!insertionRealiser[0]&&!ContenusVidesAvantBreak[0]) { // place le node de la page précédente nodpage.get(nodpage.size()-1).getNodes().add(nodstructure.getNodes().get(j)); //ok // place le textSoftPageBreak sur la page du node p. p.getNodes().add(textSoftPageBreak[u]); } } } if(!insertionRealiser[0]&&!insertionRealiser[1]) { nodpage.add(p); compteurpage++; } page = nodpage.get(nodpage.size()-1); if(nodstructure.getNodes().get(j).getNomElt().equals("text:table-of-content")) return false; return true; }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)); // recherche de l'index parmis les enfants du node text:soft-page-break. int indexBreak = -1; for(int v = 0 ; v < nodstructure.getNodes().get(j).getNodes().size(); v++) { if(nodstructure.getNodes().get(j).getNodes().get(v).getNomElt().equals("text:soft-page-break")) indexBreak=v; } //Détermine s'il y a que du texte vide avant le saut automatique boolean ContenusVidesAvantBreak = true; // Contenu & node après le text:soft-page-break node textSoftPageBreak = new node(); textSoftPageBreak.setNomElt("saut:automatique"); for(int v = 0 ; v <= indexBreak; v++) { if(!nodstructure.getNodes().get(j).getContenu().isEmpty()) { if(nodstructure.getNodes().get(j).getContenu().size()>v) { if(nodstructure.getNodes().get(j).getContenu().get(v)!=null) { if(!nodstructure.getNodes().get(j).getContenu().get(v).isEmpty()) { ContenusVidesAvantBreak=false; } } } } } if(!ContenusVidesAvantBreak && nodstructure.getNodes().get(j)!=null) { // Ajoute dans le node textSoftPageBreak for(int v = indexBreak+1 ; v <= nodstructure.getNodes().get(j).getNodes().size(); v++) { if(nodstructure.getNodes().get(j).getContenu().size()>v) { textSoftPageBreak.getContenu().add(nodstructure.getNodes().get(j).getContenu().get(v)); } if(nodstructure.getNodes().get(j).getNodes().size()>v) { textSoftPageBreak.getNodes().add(nodstructure.getNodes().get(j).getNodes().get(v)); } } for(int v = indexBreak+1 ; v <= nodstructure.getNodes().get(j).getNodes().size(); v++) { if(nodstructure.getNodes().get(j).getContenu().size()>indexBreak+1) nodstructure.getNodes().get(j).getContenu().remove(indexBreak+1); } for(int v = indexBreak ; v <= nodstructure.getNodes().get(j).getNodes().size(); v++) { if(nodstructure.getNodes().get(j).getNodes().size()>indexBreak) nodstructure.getNodes().get(j).getNodes().remove(indexBreak); } } // S'il y a que du texte vide. if(ContenusVidesAvantBreak) { // place le node dans la même page du node p. p.getNodes().add(nodstructure.getNodes().get(j)); }else { // place le node de la page précédente nodpage.get(nodpage.size()-1).getNodes().add(nodstructure.getNodes().get(j)); // place le textSoftPageBreak sur la page du node p. p.getNodes().add(textSoftPageBreak); } nodpage.add(p); compteurpage++; page = nodpage.get(nodpage.size()-1); if(nodstructure.getNodes().get(j).getNomElt().equals("text:table-of-content")) return false; return true; } } return false; } //**************************************************************************************** //*** les sauts manuels de page dans les paragraphes , et *** //**************************************************************************************** /** * Les sauts manuels de page dans les paragraphes text:p, text:list et text:h * @param nodstructure * @param compteurpage * @param j * @param a * @param nodstyle * @param nodpage * @param page * @return */ private static boolean sautDePage(node nodstructure, int compteurpage, int j, Run a, node nodstyle, ArrayList nodpage, node page) { 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); return true; } 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); return true; } } } return false; } //************************************************* // les sauts manuels hors paragraphe et titre //************************************************* /** * Les sauts de page manuel hors text:p et text:h et text:list * @param nodstructure * @param j * @param compteurpage * @param a * @param nodstyle * @param nodpage * @param page * @return */ private static boolean sautDePageHorsTextEtTitre(node nodstructure, int j, int compteurpage,Run a, node nodstyle, ArrayList nodpage, node page) { if(!nodstructure.getNodes().get(j).getNomElt().equals("text:p") && !nodstructure.getNodes().get(j).getNomElt().equals("text:h") && !nodstructure.getNodes().get(j).getNomElt().equals("text:list") ) { 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")); 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")); p.getNodes().add(nodstructure.getNodes().get(j)); }else { nodpage.get(nodpage.size()-1).getNodes().add(nodstructure.getNodes().get(j)); } nodpage.add(p); compteurpage++; page = nodpage.get(nodpage.size()-1); return true; } 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); return true; } } } } return false; } //************************************************************************ //** Les sauts de page manuel parmi tous les nodes enfants des enfants ** //************************************************************************ /** * Les sauts de page manuel parmi tous les nodes enfants des enfants * @param nodstructure * @param j * @param compteurpage * @param a * @param nodstyle * @param nodpage * @param page * @return */ private static boolean sautDePageParmiTousLesEnfants(node nodstructure, int j, int compteurpage,Run a, node nodstyle, ArrayList nodpage, node page) { if(nodstructure.getNodes().get(j).retourneEnfantsContainAttribut("text:style-name").size()>0) { for(node n : nodstructure.getNodes().get(j).retourneEnfantsContainAttribut("text:style-name")) { String nameStyle = n.getAttributs().get("text:style-name"); node nod2 = a.retourneFirstNodeByNameAttributValue(nodstyle.getNodes(), "style:style", "style:name", nameStyle); 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); return true; } 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); return true; } } } } return false; } // private static boolean sautDePage2(node nod, int compteurpage, int index, Run a, node nodstyle, ArrayList nodpage, node page) { // if(nod.getAttributs().get("text:style-name")!=null) { // // node nod2 = a.retourneFirstNodeByNameAttributValue(nodstyle.getNodes(), "style:style", "style:name", nod.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(index)); // 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(nod); // nodpage.add(p); // compteurpage++; // page = nodpage.get(nodpage.size()-1); // return true; // } // 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(index)); // // p.getNodes().add(nod); // nodpage.add(p); // compteurpage++; // page = nodpage.get(nodpage.size()-1); // return true; // } // } // } // return false; // } // // private static boolean sautDePageAutomatique2(node nod, int compteurpage, int index, Run a, ArrayList nodpage, node page) { // // if(nod.retourneEnfantsByNameExist("text:soft-page-break") ) { //&& !nodstructure.getNodes().get(j).getNomElt().equals("text:table-of-content") // ArrayList nods1 = a.retourneNames(nod, "text:soft-page-break"); // // if(nods1.size()>1) { // 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(index)); // // // recherche de l'index parmis les enfants du node text:soft-page-break. // int[] indexBreak = new int[nods1.size()]; // indexBreak[0]=0; // for(int v = 0 ; v < nods1.size() ; v++) { // indexBreak[v]=-1; // } // // int i2 = 0; // for(int v = 0 ; v < nod.getNodes().size(); v++) { // if(nod.getNodes().get(v).getNomElt().equals("text:soft-page-break")) { // indexBreak[i2]=v; // i2++; // } // } // // // //Détermine s'il y a que du texte vide avant le saut automatique // boolean[] ContenusVidesAvantBreak = new boolean[nods1.size()]; // boolean[] insertionRealiser = new boolean[nods1.size()]; // for(int v = 0 ; v < nods1.size() ; v++) { // ContenusVidesAvantBreak[v]=true; // insertionRealiser[v]=false; // } // // for(int u = 0; u < nods1.size() ; u++) { // for(int v = 0 ; v <= indexBreak[u]; v++) { // if(nod.getContenu().size()>=1) { // if(nod.getContenu().get(v)!=null) { // if(ContenusVidesAvantBreak[u]) { // if(!nod.getContenu().get(v).isEmpty()) { // ContenusVidesAvantBreak[u]=false; // } // } // if(v==indexBreak[u] && !ContenusVidesAvantBreak[u]) { // nod.getContenu().set( // v,nod.getContenu().get(v) + "** TEXT:SOFT-PAGE-BREAK **"); // } // } // } // } // } // // // Contenu & node après le text:soft-page-break // node[] textSoftPageBreak = new node[nods1.size()]; // // // for(int u = 0; u < nods1.size() ; u++) { // textSoftPageBreak[u] = new node(); // textSoftPageBreak[u].setNomElt("saut:automatique"); // // if(!ContenusVidesAvantBreak[u]) { // // Ajoute dans le node textSoftPageBreak // for(int v = indexBreak[u]+1 ; v <= nod.getNodes().size(); v++) { // if(nod.getContenu().size()>v) { // textSoftPageBreak[u].getContenu().add(nod.getContenu().get(v)); // } // if(nod.getNodes().size()>v) { // textSoftPageBreak[u].getNodes().add(nod.getNodes().get(v)); // } // } // // // suprresion des contenus et des nodes enfants dans le paragraphe dans le paragraphe // for(int v = indexBreak[u]+1 ; v <= nod.getNodes().size(); v++) { // if(nod.getContenu().size()>indexBreak[u]+1) nod.getContenu().remove(indexBreak[u]+1); // } // // for(int v = indexBreak[u] ; v <= nod.getNodes().size(); v++) { // if(nod.getNodes().size()>indexBreak[u]) nod.getNodes().remove(indexBreak[u]); // } // } // // } // // for(int u = 0; u < nods1.size() ; u++) { // // // if(ContenusVidesAvantBreak[0]) { // if(!insertionRealiser[0]) { // p.getNodes().add(nod); // insertionRealiser[0]=true; // nodpage.add(p); // compteurpage++; // // node p1 = new node(); // p1.setNomElt("page"); // p1.getAttributs().put("numero", String.valueOf(compteurpage)); // p1.getAttributs().put("type","automatique"); // p1.getAttributs().put("index",String.valueOf(index)); // p1.getNodes().add(textSoftPageBreak[u+1]); // // insertionRealiser[1]=true; // // if(nods1.size()<3) { // nodpage.add(p1); // compteurpage++; // } // // } // // if(!insertionRealiser[0]&&!ContenusVidesAvantBreak[0]) { // // place le node de la page précédente // nodpage.get(nodpage.size()-1).getNodes().add(nod); //ok // // place le textSoftPageBreak sur la page du node p. // p.getNodes().add(textSoftPageBreak[u]); // } // // // } // // } // // // if(!insertionRealiser[0]&&!insertionRealiser[1]) { // nodpage.add(p); // compteurpage++; // } // // page = nodpage.get(nodpage.size()-1); // if(nod.getNomElt().equals("text:table-of-content")) return false; // return true; // }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(index)); // // // recherche de l'index parmis les enfants du node text:soft-page-break. // int indexBreak = -1; // for(int v = 0 ; v < nod.getNodes().size(); v++) { // if(nod.getNodes().get(v).getNomElt().equals("text:soft-page-break")) indexBreak=v; // } // // //Détermine s'il y a que du texte vide avant le saut automatique // boolean ContenusVidesAvantBreak = true; // // Contenu & node après le text:soft-page-break // node textSoftPageBreak = new node(); // textSoftPageBreak.setNomElt("saut:automatique"); // // for(int v = 0 ; v <= indexBreak; v++) { // if(!nod.getContenu().isEmpty()) { // if(nod.getContenu().size()>v) { // if(nod.getContenu().get(v)!=null) { // if(!nod.getContenu().get(v).isEmpty()) { // ContenusVidesAvantBreak=false; // } // } // } // } // } // // if(!ContenusVidesAvantBreak && nod!=null) { // // Ajoute dans le node textSoftPageBreak // for(int v = indexBreak+1 ; v <= nod.getNodes().size(); v++) { // if(nod.getContenu().size()>v) { // textSoftPageBreak.getContenu().add(nod.getContenu().get(v)); // } // if(nod.getNodes().size()>v) { // textSoftPageBreak.getNodes().add(nod.getNodes().get(v)); // } // } // // for(int v = indexBreak+1 ; v <= nod.getNodes().size(); v++) { // if(nod.getContenu().size()>indexBreak+1) nod.getContenu().remove(indexBreak+1); // } // // for(int v = indexBreak ; v <= nod.getNodes().size(); v++) { // if(nod.getNodes().size()>indexBreak) nod.getNodes().remove(indexBreak); // } // } // // // // // S'il y a que du texte vide. // if(ContenusVidesAvantBreak) { // // place le node dans la même page du node p. // p.getNodes().add(nod); // }else { // // place le node de la page précédente // nodpage.get(nodpage.size()-1).getNodes().add(nod); // // place le textSoftPageBreak sur la page du node p. // p.getNodes().add(textSoftPageBreak); // } // // nodpage.add(p); // compteurpage++; // page = nodpage.get(nodpage.size()-1); // if(nod.getNomElt().equals("text:table-of-content")) return false; // return true; // } // } // return false; // } // }