package MEPTL; import java.time.LocalDateTime; import java.util.ArrayList; import cXML.Run; import cXML.node; import list.listeDesNodesAnalyseStyle; import list.listeDesNodesAvecEvalNameNode; import list.listeDesNodesEvalPlacement; import list.listeDesNodesRechercheByContenu; import list.listeRechercheParAnchorPageNumber; /** * * @author pablo rodriguez * */ public class ecritureSujet { /** * Fourni le node du sujet avec les attributs d'evaluation et les attributs de la mise en page du feedback. * @param nod * @param a * @param i * @return * @throws CloneNotSupportedException */ public static node nodePourEcritureSujet(node nod, Run a, Integer i) throws CloneNotSupportedException { LocalDateTime aujourdhui = LocalDateTime.now(); // fichier nod.getAttributs().put("evaluer", "true"); nod.getAttributs().put("progression", "1"); nod.getAttributs().put("notefrom", "20"); nod.getAttributs().put("baremeABC", "false"); nod.getAttributs().put("date", String.valueOf(aujourdhui)); nod.getAttributs().put("version", commandes.version); nod.getAttributs().put("titre", "Le titre de l'exercice"); nod.getAttributs().put("link_sujet", "https://moodle.univ-artois.fr/cours/"); nod.getAttributs().put("link_help", "https://moodle.univ-artois.fr/cours/"); nod.getAttributs().put("historiquePresent", "false"); nod.getAttributs().put("controleDateCreation", "false"); nod.getAttributs().put("controle_Initial_Creator", "false"); nod.getAttributs().put("presenceMetaSujet", "false"); node b = a.retourneName(nod.retourneFirstEnfantsByName("office:meta"),"meta:user-defined","meta:name","Sujet"); if(b!=null) { nod.getAttributs().put("metaSujet", b.getContenu().get(0));}else {nod.getAttributs().put("metaSujet", "?");} b = nod.retourneFirstEnfantsByName("office:meta").retourneFirstEnfantsByName("meta:creation-date"); if(b!=null) if(b.getContenu().size()>0) { if(b.getContenu().get(0).contains(".")) { nod.getAttributs().put("creationDate", b.getContenu().get(0).substring(0, b.getContenu().get(0).lastIndexOf("."))); }else { nod.getAttributs().put("creationDate", b.getContenu().get(0)); } } b = nod.retourneFirstEnfantsByName("office:meta").retourneFirstEnfantsByName("meta:initial-creator"); if(b!=null) if(b.getContenu().size()>0) { nod.getAttributs().put("Initial_Creator", b.getContenu().get(0));}else {nod.getAttributs().put("Initial_Creator", "");} nod.getAttributs().put("auteur", "votre nom et prénom"); nod.setContenu("Commentaire sur cet exercice.-NewLine-Seconde ligne de commentaire."); nod.getAttributs().remove("dossier"); b = nod.retourneFirstEnfantsByName("office:meta").retourneFirstEnfantsByName("meta:generator"); if(b!=null) if(!b.getContenu().isEmpty()) { nod.getAttributs().put("producteur", b.getContenu().get(0));}else {nod.getAttributs().put("producteur", "");} // //metadonnées node nodmeta = nod.retourneFirstEnfantsByName("office:meta"); if(nodmeta.getNomElt().equals("office:meta")) { nod.getNodes().remove(nodmeta); nodmeta.getAttributs().put("evaluer", "false"); nodmeta.getAttributs().put("addmenu", "false"); nodmeta.getAttributs().put("poids", "1"); nodmeta.getAttributs().put("titre", "Les metadonnées"); ArrayList no = nodmeta.getNodes(); for(int j = 0 ; j < no.size(); j++) { no.get(j).getAttributs().put("saut", "false"); no.get(j).getAttributs().put("evaluer", "false"); no.get(j).getAttributs().put("titre", ""); no.get(j).getAttributs().put("evalNameNode", "0"); if(no.get(j).getNomElt().equals("dc:creator")) no.get(j).getAttributs().put("evalNameCreator", "0"); if(no.get(j).getNomElt().equals("meta:initial-creator")) no.get(j).getAttributs().put("evalNameInitialCreator", "0"); } nod.getNodes().add(nodmeta); } // //style de page node nodpage = nod.retourneFirstEnfantsByName("style:page"); if(nodpage.getNomElt().equals("style:page")) { nod.getNodes().remove(nodpage); nodpage.getAttributs().put("evaluer", "false"); nodpage.getAttributs().put("addmenu", "false"); nodpage.getAttributs().put("poids", "1"); nodpage.getAttributs().put("titre", "Les styles de page"); nodpage = addAttributsAnalyseWriter(nodpage, "style:master-page"); nod.getNodes().add(nodpage); } // //style de paragraphe node nodparagraph = nod.retourneFirstEnfantsByName("style:paragraph"); if(nodparagraph.getNomElt().equals("style:paragraph")) { nod.getNodes().remove(nodparagraph); nodparagraph.getAttributs().put("evaluer", "false"); nodparagraph.getAttributs().put("addmenu", "false"); nodparagraph.getAttributs().put("poids", "1"); nodparagraph.getAttributs().put("titre", "Les styles de paragraphe"); nodparagraph = addAttributsAnalyseWriter(nodparagraph, "style:style"); nod.getNodes().add(nodparagraph); } // //style de texte node nodformatage = nod.retourneFirstEnfantsByName("style:formatagedirect"); if(nodformatage.getNomElt().equals("style:formatagedirect")) { nod.getNodes().remove(nodformatage); nodformatage.getAttributs().put("evaluer", "false"); nodformatage.getAttributs().put("addmenu", "false"); nodformatage.getAttributs().put("poids", "1"); nodformatage.getAttributs().put("titre", "Les styles de formatage direct"); nodformatage = addAttributsAnalyseWriter(nodformatage, "style:style"); nod.getNodes().add(nodformatage); } // //séquence node nodsequence = nod.retourneFirstEnfantsByName("sequences"); if(nodsequence.getNomElt().equals("sequences")) { nod.getNodes().remove(nodsequence); nodsequence.getAttributs().put("evaluer", "false"); nodsequence.getAttributs().put("addmenu", "false"); nodsequence.getAttributs().put("poids", "1"); nodsequence.getAttributs().put("titre", "Les variables de séquence"); nodsequence = addAttributsAnalyseWriter(nodsequence, "text:sequence-decl"); nod.getNodes().add(nodsequence); } // //numérotation des chapitres node nodnumerotationchapitre = nod.retourneFirstEnfantsByName("numerotationchapitre"); if(nodnumerotationchapitre.getNomElt().equals("numerotationchapitre")) { nod.getNodes().remove(nodnumerotationchapitre); nodnumerotationchapitre.getAttributs().put("evaluer", "false"); nodnumerotationchapitre.getAttributs().put("addmenu", "false"); nodnumerotationchapitre.getAttributs().put("poids", "1"); nodnumerotationchapitre.getAttributs().put("titre", "Numérotation des chapitres"); nodnumerotationchapitre = addAttributsAnalyseWriter(nodnumerotationchapitre, "text:outline-level-style"); nod.getNodes().add(nodnumerotationchapitre); } // //frame node nodframe = nod.retourneFirstEnfantsByName("frames"); if(nodframe.getNomElt().equals("frames")) { nod.getNodes().remove(nodframe); nodframe.getAttributs().put("evaluer", "false"); nodframe.getAttributs().put("addmenu", "false"); nodframe.getAttributs().put("poids", "1"); nodframe.getAttributs().put("titre", "Les frames (cadres et images)"); nodframe = addAttributsAnalyseWriter(nodframe, "draw:frame"); nod.getNodes().add(nodframe); } // //sections node nodsection = nod.retourneFirstEnfantsByName("sections"); if(nodsection.getNomElt().equals("sections")) { nod.getNodes().remove(nodsection); nodsection.getAttributs().put("evaluer", "false"); nodsection.getAttributs().put("addmenu", "false"); nodsection.getAttributs().put("poids", "1"); nodsection.getAttributs().put("titre", "Les sections"); nodsection = addAttributsAnalyseWriter(nodsection, "text:section"); nod.getNodes().add(nodsection); } // //tableaux node nodtableaux = nod.retourneFirstEnfantsByName("tableaux"); if(nodtableaux.getNomElt().equals("tableaux")) { nod.getNodes().remove(nodtableaux); nodtableaux.getAttributs().put("evaluer", "false"); nodtableaux.getAttributs().put("addmenu", "false"); nodtableaux.getAttributs().put("poids", "1"); nodtableaux.getAttributs().put("titre", "Les tableaux"); nodtableaux = addAttributsAnalyseWriter(nodtableaux, "table:table"); nod.getNodes().add(nodtableaux); } // //biblio node nodbiblio = nod.retourneFirstEnfantsByName("biblio"); if(nodbiblio.getNomElt().equals("biblio")) { nod.getNodes().remove(nodbiblio); nodbiblio.getAttributs().put("evaluer", "false"); nodbiblio.getAttributs().put("addmenu", "false"); nodbiblio.getAttributs().put("poids", "1"); nodbiblio.getAttributs().put("titre", "La bibliographie"); nodbiblio = addAttributsAnalyseWriter(nodbiblio, "text:bibliography"); nod.getNodes().add(nodbiblio); } // //table des matières node nodtable = nod.retourneFirstEnfantsByName("tablematieres"); if(nodtable.getNomElt().equals("tablematieres")) { nod.getNodes().remove(nodtable); nodtable.getAttributs().put("evaluer", "false"); nodtable.getAttributs().put("addmenu", "false"); nodtable.getAttributs().put("poids", "1"); nodtable.getAttributs().put("titre", "Les index tables des matières"); nodtable = addAttributsAnalyseWriter(nodtable, "text:table-of-content"); nod.getNodes().add(nodtable); } // //table des illustrations node nodillustrations = nod.retourneFirstEnfantsByName("tableillustrations"); if(nodillustrations.getNomElt().equals("tableillustrations")) { nod.getNodes().remove(nodillustrations); nodillustrations.getAttributs().put("evaluer", "false"); nodillustrations.getAttributs().put("addmenu", "false"); nodillustrations.getAttributs().put("poids", "1"); nodillustrations.getAttributs().put("titre", "Les index illustrations"); nodillustrations = addAttributsAnalyseWriter(nodillustrations, "text:illustration-index"); nod.getNodes().add(nodillustrations); } // //structure document node nodstructurepage = nod.retourneFirstEnfantsByName("structurepage"); if(nodstructurepage.getNomElt().equals("structurepage")) { nod.getNodes().remove(nodstructurepage); nodstructurepage.getAttributs().put("evaluer", "false"); nodstructurepage.getAttributs().put("addmenu", "false"); nodstructurepage.getAttributs().put("poids", "1"); nodstructurepage.getAttributs().put("titre", "La structure du document"); nodstructurepage = addAttributsAnalyseWriter(nodstructurepage, "page"); nod.getNodes().add(nodstructurepage); } // ajoute le node setting et translation nod = addSetting(nod); // ajoute le hash du code String hash = String.valueOf(Run.HashNode(Run.NodesAyantAttributEvaluerTRUEavecComplement(nod),0)); nod.getAttributs().put("hash", hash); return nod; } /** * Ajoute les différents attributs aux nodes enfants des nodes principaux.
* @param noPourPlacerEvaluer * @param nameNodeRacine * @return */ private static node addAttributsAnalyseWriter(node noPourPlacerEvaluer, String nameNodeRacine) { ArrayList no = noPourPlacerEvaluer.retourneEnfantsByName(nameNodeRacine, new ArrayList()); for(int j = 0 ; j < no.size(); j++) { noPourPlacerEvaluer.getNodes().remove(no.get(j)); no.get(j).getAttributs().put("saut", "false"); no.get(j).getAttributs().put("evaluer", "false"); no.get(j).getAttributs().put("titre", ""); if(!no.get(j).getNodes().isEmpty()) { nextNodesEnfants(no.get(j).getNodes()); } } noPourPlacerEvaluer.getNodes().addAll(no); return noPourPlacerEvaluer; } /** * Ajoute les attributs d'analyseWriter par défaut.
* @param no */ private static void nextNodesEnfants(ArrayList no) { for(int k=0 ; k < no.size(); k++) { if(no.get(k)!=null) { no.get(k).getAttributs().put("evaluer", "false"); if( listeDesNodesAvecEvalNameNode.isEvalNameNode(no.get(k))) no.get(k).getAttributs().put("evalNameNode", "0"); if(listeDesNodesSautEtTitre(no.get(k).getNomElt())) {no.get(k).getAttributs().put("saut", "false"); no.get(k).getAttributs().put("titre", "");} if(listeDesNodesRechercheByContenu.isRechercheByContenu(no.get(k))) {no.get(k).getAttributs().put("recherche_index", "false"); no.get(k).getAttributs().put("recherche_contenu_exact", "false");no.get(k).getAttributs().put("recherche_contenu_plus_proche_voisin", "false");no.get(k).getAttributs().put("allContent", "strict0");} if(listeDesNodesEvalPlacement.isPlacement(no.get(k)))no.get(k).getAttributs().put("evalPlacement", "0"); if(listeDesNodesAnalyseStyle.isAnalyseStyle(no.get(k))) {no.get(k).getAttributs().put("analyseStyle", "false");no.get(k).getAttributs().put("evalNameLegacyStyle", "0");} if(listeRechercheParAnchorPageNumber.isRechercheParAnchorPageNumber(no.get(k))) no.get(k).getAttributs().put("recherche_anchor-page-number", "false"); if(!no.get(k).getNodes().isEmpty()) { nextNodesEnfants(no.get(k).getNodes()); } } } } /** * Liste des nodes qui peuvent contenir les attributs saut et titre * @param nameNode * @return */ public static boolean listeDesNodesSautEtTitre(String nameNode) { if(nameNode.contains("meta:")) return true; if(nameNode.contains("dc:")) return true; if(nameNode.contains("style:")) return true; if(nameNode.contains("text:")) return true; return false; } /** * Ce node permet la configuration personnalisé de l'application.
* Ajoute le node setting avec les différentes valeurs par défaut.
* * @param sujet Le node du sujet. * @return Le node du sujet avec le node setting ajouté. */ private static node addSetting(node sujet) { //node setting node setting = new node(); setting.setNomElt("setting"); setting.getAttributs().put("culture","FR"); //node csv node csv = new node(); csv.setNomElt("csv"); csv.getAttributs().put("encoding", "UTF-8"); csv.getAttributs().put("separator", ";"); csv.setContenu("choose the encoding from this list : UTF-8 US-ASCII ISO-8859-1 UTF-16BE UTF-16LE UTF-16"); csv.setClose(true); //node export du csv node export = new node(); export.setNomElt("import_moodle"); export.getAttributs().put("email", "adresse"); export.getAttributs().put("id", "identification"); export.getAttributs().put("firstname", "prenom"); export.getAttributs().put("name", "nom"); export.setClose(true); //node taille zip node zip = new node(); zip.setNomElt("zip"); zip.getAttributs().put("size", "48000000"); zip.getAttributs().put("nameZip", "feedbackMoodle"); zip.isClose(); //node verif node plagiarism = new node(); plagiarism.setNomElt("plagiarism"); plagiarism.getAttributs().put("number_match", "2"); plagiarism.getAttributs().put("mini_number_modification", "-1"); plagiarism.getAttributs().put("nombres_modifications_simultané_maxi", "100"); plagiarism.setClose(true); //construction node similitude node similarity = new node(); similarity.setNomElt("text:similarity"); similarity.getAttributs().put("tolerance_characters", "5"); similarity.getAttributs().put("tolerance_text", "0.79"); similarity.setClose(true); //node color node color = new node(); color.setNomElt("color"); color.getAttributs().put("tolerance_rouge", "30"); color.getAttributs().put("tolerance_vert", "30"); color.getAttributs().put("tolerance_bleu", "30"); color.setClose(true); //construction du node setting csv.getNodes().add(export); setting.getNodes().add(csv); setting.getNodes().add(zip); setting.getNodes().add(plagiarism); setting.getNodes().add(similarity); setting.getNodes().add(color); //ajoute la node translation setting.getNodes().add(Run.translation()); // ajoute le node setting au node sujet sujet.getNodes().add(setting); //fermeture du node setting.setClose(true); return sujet; } }