analyseWriter/src/baseEvaluations/creerNouvelleEvaluation.java

129 lines
4.4 KiB
Java

package baseEvaluations;
import java.text.ParseException;
import java.util.Date;
import MEPTL.commandes;
import cXML.node;
public class creerNouvelleEvaluation {
node evaluation = new node();
boolean addBase = false;
public node getEvaluation() {
return evaluation;
}
public creerNouvelleEvaluation(String nameEval, boolean addBase) {
this.addBase=addBase;
evaluation = nouvelleEvaluation(evaluation, nameEval);
}
public creerNouvelleEvaluation(node evaluation) {
String name = "Nouvelle évaluation";
evaluation = nouvelleEvaluation(evaluation, name);
}
public creerNouvelleEvaluation(node evaluation, String name, boolean addBase) {
this.addBase = addBase;
evaluation = nouvelleEvaluation(evaluation, name);
commandes.evaluationChargeEnMemoire = evaluation;
}
private node nouvelleEvaluation(node evaluation, String nameEvaluation) {
evaluation.setNomElt("evaluation");
if(addBase) {
Date aujourdhui = new Date();
try {
evaluation.getAttributs().put("date", calcul.formatDateWriter.DateLibreOffice(aujourdhui));
} catch (ParseException e) {
e.printStackTrace();
}
}
evaluation.getAttributs().put("version", commandes.version);
evaluation.getAttributs().put("name", nameEvaluation);
evaluation.getAttributs().put("PathFilenameAnalysis", commandes.PathFilenameAnalysis);
evaluation.getAttributs().put("path", commandes.path);
evaluation.getAttributs().put("fichierStudentMoodle", String.valueOf(commandes.fichierStudentMoodle));
evaluation.getAttributs().put("sansFeeback", String.valueOf(commandes.sansFeeback) );
evaluation.getAttributs().put("noDetail", String.valueOf(commandes.noDetail) );
evaluation.getAttributs().put("noNote", String.valueOf(commandes.noNote) );
evaluation.getAttributs().put("zipfeedback", String.valueOf(commandes.zipfeedback) );
evaluation.getAttributs().put("verifHisto2", String.valueOf(commandes.verifHisto2) );
evaluation.getAttributs().put("ecritNoteCSV", String.valueOf(commandes.ecritNoteCSV) );
evaluation.getAttributs().put("newLogo", String.valueOf(commandes.newLogo) );
evaluation.getAttributs().put("noLogo", String.valueOf(commandes.noLogo) );
evaluation.getAttributs().put("analyse_nombres_modifications_simultané_maxi", String.valueOf(commandes.analyse_nombres_modifications_simultané_maxi) );
//Supprime le node fichier s'il existe, déjà pour le remplacer par le node commandes.sujet
node nodremove = evaluation.retourneFirstEnfantsByName("fichier");
if(!nodremove.isVide()) evaluation.getNodes().remove(nodremove);
evaluation.getNodes().add(commandes.sujet);
if(commandes.sujet.getAttributs().get("analysis_filename").contains(".xml")) {
evaluation.getAttributs().put("analysis_filename",commandes.sujet.getAttributs().get("analysis_filename"));
}else {
evaluation.getAttributs().put("analysis_filename",commandes.nameSujet);
}
evaluation.getAttributs().put("fourniCSV", String.valueOf(commandes.fourniCSV) );
if(commandes.nameCSV!=null) {
evaluation.getAttributs().put("nameCSV", commandes.nameCSV );
}else {
evaluation.getAttributs().put("nameCSV", "");
}
evaluation.getAttributs().put("fourniCSV", String.valueOf(commandes.fourniCSV) );
if(commandes.nameSVG!=null) {
evaluation.getAttributs().put("nameSVG", commandes.nameSVG );
}else {
evaluation.getAttributs().put("nameSVG", "" );
}
//Supprime le node CSV s'il existe, pour le remplacer par le node commandes.nodeCSV
nodremove = evaluation.retourneFirstEnfantsByName("fileCSV");
if(!nodremove.isVide()) evaluation.getNodes().remove(nodremove);
if(commandes.nodeCSV!=null) {
evaluation.getNodes().add(commandes.nodeCSV);
}
if(commandes.nameSVG!=null) {
if(!commandes.nameSVG.isBlank() && !commandes.contenuFichierSVG.isBlank()) {
node SVG = new node();
SVG.setNomElt("nodSVG");
SVG.setContenu(commandes.contenuFichierSVG);
if(SVG!=null) {
evaluation.getNodes().add(SVG);
}
}
}
if(addBase) {
if(commandes.evaluationsBase!=null) {
commandes.evaluationsBase.getNodes().add(0, evaluation);
commandes.IndexEvaluationCharger=0;
}
}else {
commandes.evaluationsBase.getNodes().remove(commandes.IndexEvaluationCharger);
commandes.evaluationsBase.getNodes().add(commandes.IndexEvaluationCharger, evaluation);
}
return evaluation;
}
}