* 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(commandes.sujet.retourneFirstEnfantsByName("translation"));
//************************************************
//** 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 le nombre de match limite et le nombre minimal **
//***********************************************************
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"));
}
//**************************************
//** 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);
//**********************************************
//** Chargement et verification du CVS fourni **
//**********************************************
if(commandes.fourniCSV) {
commandes.nodeCSV = chargementFichierCSV();
}
//*****************************************
//** 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); // 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);
} 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.
*
* @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;
}
/**
* 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") + "
");
System.out.println("\nDossier analysé : " + ouverture.getAttributs().get("dossier"));}
else {
Text.append("Fichier analysé : " + ouverture.getAttributs().get("dossier")+"
");
System.out.println("\nFichier 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
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 dans un node du fichier CSV de la liste des étudiants.
* La liste des étudiants doit contenir les champs Prénom, Nom, Numéro d'identification, Adresse de courriel
* Le séparateur doit être le point-virgule et l'encodage UTF-8.
* @param a
* @param nameCSV
* @return
* @throws IOException
*/
public static node 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.clotureWithErrorFile(cheminVersLeFichierCSV);
e.printStackTrace();
}
String[] target = targetString.split("\\n");
node nodeCVS = new node();
nodeCVS.setNomElt("fileCSV");
String[] line1 = target[0].split(";");
for(int i = 1 ; i < target.length ; i++) {
node nodeEtudiant = new node();
nodeEtudiant.setNomElt("student");
for(int j = 0 ; j < line1.length; j++) {
nodeEtudiant.getAttributs().put(line1[j], target[i].split(";")[j]);
}
nodeCVS.getNodes().add(nodeEtudiant);
}
//a.ecritureNodeEnXML(nodeCVS, "nodeCVS"); //écriture du node du node CSV
return nodeCVS;
}
/**
* Charge le fichier SVG pour le nouveau Logo dans les feedbacks
* @param a
* @param nameSVG
* @return
*/
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.clotureWithErrorFile(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;
}
//Ajout 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);
}
}
//le paragraph properties
node nodeStyleParentParagraphProperties = parent.retourneFirstEnfantsByName("style:paragraph-properties");
node LesNodesStyleParagraph = nodStyle.retourneFirstEnfantsByName("style:paragraph-properties");
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 text properties
node nodeStyleParDefautTextProperties = parent.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;
}
}
}
/**
* 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);
}
}
}
}
}
}