analyseWriter/src/baseEvaluations/creerNouvelleEvaluation.java

129 lines
4.5 KiB
Java

package baseEvaluations;
import java.text.ParseException;
import java.util.Date;
import MEPTL.commandes;
import cXML.node;
public class creerNouvelleEvaluation {
boolean majBase = false;
/**
* Mise à jour d'une évaluation
* @param evaluation
*/
public creerNouvelleEvaluation(node evaluation) {
this.majBase=true;
commandes.evaluationChargeEnMemoire = nouvelleEvaluation(evaluation, evaluation.getAttributs().get("name"));
}
public creerNouvelleEvaluation(node evaluation, String name, boolean majBase) {
this.majBase = majBase;
commandes.evaluationChargeEnMemoire = nouvelleEvaluation(evaluation, name);
// if(!majBase) commandes.evaluationChargeEnMemoire = evaluation;
}
private node nouvelleEvaluation(node evaluation, String nameEvaluation) {
// création du nouveau node evaluation
evaluation.setNomElt("evaluation");
// La date est modifiée à la création de l'évaluation..
Date aujourdhui = new Date();
try {
if(!majBase) {
evaluation.getAttributs().put("date", calcul.formatDateWriter.DateLibreOffice(aujourdhui));
}else {
evaluation.getAttributs().put("dateModification", calcul.formatDateWriter.DateLibreOffice(aujourdhui));
}
} catch (ParseException e) {
e.printStackTrace();
}
// informations de l'évaluation
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);
}
}
}
//Création d'une évaluation
if(!majBase) {
if(commandes.evaluationsBase!=null) {
commandes.evaluationsBase.getNodes().add(0, evaluation);
commandes.IndexEvaluationCharger=0;
}
}
new ecritureBaseEvaluation(evaluation);
return evaluation;
}
}