264 lines
9.1 KiB
Java
264 lines
9.1 KiB
Java
package baseEvaluations;
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.FileNotFoundException;
|
|
import java.io.InputStreamReader;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.nio.file.Paths;
|
|
import java.util.Date;
|
|
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JOptionPane;
|
|
|
|
import MEPTL.commandes;
|
|
import MEPTL.meptl;
|
|
import MEPTL.verificationFichierAnalyse_node_commandesSujet;
|
|
import cXML.node;
|
|
import fenetres.ChargeFichierXML;
|
|
|
|
/**
|
|
* Charge le node évaluation avec le node sujet.
|
|
* @author pabr6
|
|
*
|
|
*/
|
|
public class chargeEvaluation {
|
|
|
|
/**
|
|
* Charge en mémoire le node évaluation avec le node sujet.<br>
|
|
* Le node commandes.evaluationChargeEnMemoire en mémoire.
|
|
* Le node commandes.nameSujet en mémoire.
|
|
* @param index
|
|
*/
|
|
public static void chargeEnMémoireEvaluationSelected(Integer index) {
|
|
|
|
String directoryName = "";
|
|
File file = null;
|
|
node evaluation = new node();
|
|
if(commandes.PathBaseEvaluationDefaut) {
|
|
directoryName = Paths.get("").toAbsolutePath().toString();
|
|
}else {
|
|
directoryName = commandes.PathBaseEvaluations;
|
|
}
|
|
|
|
if(commandes.os.contains("Win")) {
|
|
file = new File(directoryName + "\\" + commandes.NameBaseEvaluations);
|
|
}else {
|
|
file = new File(directoryName + "/" + commandes.NameBaseEvaluations);
|
|
}
|
|
|
|
|
|
if(file!=null) {
|
|
BufferedReader br;
|
|
try {
|
|
br = new BufferedReader(
|
|
new InputStreamReader(
|
|
new FileInputStream(file.getAbsoluteFile()), "UTF-8"));
|
|
String line;
|
|
StringBuilder targetString = new StringBuilder();
|
|
while ((line = br.readLine()) != null) {
|
|
targetString.append(line);
|
|
}
|
|
evaluation = evaluation.chargeNodeEvaluationIndex(index,targetString.toString().replace("\t","").replace("\r", "").replace("\n", ""));
|
|
}catch (Exception e) {
|
|
JFrame frame = new JFrame("Erreur");
|
|
JLabel texte = new JLabel("<html><h1>Erreur</h1><p>L'évaluation n'a pas été trouvé dans la base de données.</p></html>");
|
|
JOptionPane.showMessageDialog(frame, texte);
|
|
}
|
|
|
|
|
|
//* Charge le node sujet provisoirement
|
|
commandes.evaluationChargeEnMemoire = evaluation;
|
|
commandes.NameEvaluationCharger= evaluation.getAttributs().get("name");
|
|
commandes.path = evaluation.getAttributs().get("path"); //Dossier des fichiers des étudiants
|
|
|
|
// Chargement du node sujet depuis la base
|
|
commandes.nameSujet = evaluation.getAttributs().get("analysis_filename");
|
|
commandes.sujet = evaluation.retourneFirstEnfantsByName("fichier");
|
|
commandes.PathFilenameAnalysis = evaluation.getAttributs().get("PathFilenameAnalysis");
|
|
|
|
//** Les paramètres de l'évaluation
|
|
commandes.versionEvaluation = evaluation.getAttributs().get("version");
|
|
commandes.fichierStudentMoodle = Boolean.valueOf(evaluation.getAttributs().get("fichierStudentMoodle"));
|
|
commandes.sansFeeback = Boolean.valueOf(evaluation.getAttributs().get("sansFeeback"));
|
|
commandes.noDetail = Boolean.valueOf(evaluation.getAttributs().get("noDetail"));
|
|
commandes.noNote = Boolean.valueOf(evaluation.getAttributs().get("noNote"));
|
|
commandes.noAfficheProgression = Boolean.valueOf(evaluation.getAttributs().get("noAfficheProgression"));
|
|
commandes.zipfeedback = Boolean.valueOf(evaluation.getAttributs().get("zipfeedback"));
|
|
commandes.verifHisto2 = Boolean.valueOf(evaluation.getAttributs().get("verifHisto2"));
|
|
commandes.ecritNoteCSV = Boolean.valueOf(evaluation.getAttributs().get("ecritNoteCSV"));
|
|
commandes.newLogo = Boolean.valueOf(evaluation.getAttributs().get("newLogo"));
|
|
commandes.noLogo = Boolean.valueOf(evaluation.getAttributs().get("noLogo"));
|
|
commandes.fourniCSV = Boolean.valueOf(evaluation.getAttributs().get("fourniCSV"));
|
|
commandes.nameCSV = evaluation.getAttributs().get("nameCSV");
|
|
|
|
|
|
if(evaluation.getAttributs().get("analyse_nombres_modifications_simultané_maxi")!=null) {
|
|
commandes.analyse_nombres_modifications_simultané_maxi = Integer.valueOf(evaluation.getAttributs().get("analyse_nombres_modifications_simultané_maxi"));
|
|
}
|
|
|
|
commandes.fourniCSV = Boolean.valueOf(evaluation.getAttributs().get("fourniCSV"));
|
|
commandes.nameSVG = evaluation.getAttributs().get("nameSVG");
|
|
|
|
|
|
commandes.nodeCSV = evaluation.retourneFirstEnfantsByName("fileCSV");
|
|
|
|
commandes.contenuFichierSVG = evaluation.retourneFirstEnfantsByName("nodSVG").retourneLesContenusEnfants("");
|
|
|
|
commandes.fichierAnalyseValide = true;
|
|
|
|
|
|
try {
|
|
commandes.sujetSauvegarde = commandes.sujet.clone();
|
|
} catch (CloneNotSupportedException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
//Chargement des paramètres du fichier d'analyse
|
|
meptl.chargementParametresFichierAnalyse();
|
|
|
|
//** Remise à zéro de la base dans la mémoire de l'application
|
|
commandes.evaluationsBase = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Retourne le node évaluation sélectionné.
|
|
* @param index
|
|
* @return
|
|
*/
|
|
public static node retourneEvaluationSelected(Integer index) {
|
|
String directoryName = "";
|
|
File file = null;
|
|
node evaluation = new node();
|
|
if(commandes.PathBaseEvaluationDefaut) {
|
|
directoryName = Paths.get("").toAbsolutePath().toString();
|
|
}else {
|
|
directoryName = commandes.PathBaseEvaluations;
|
|
}
|
|
|
|
if(commandes.os.contains("Win")) {
|
|
file = new File(directoryName + "\\" + commandes.NameBaseEvaluations);
|
|
}else {
|
|
file = new File(directoryName + "/" + commandes.NameBaseEvaluations);
|
|
}
|
|
|
|
if(file!=null) {
|
|
BufferedReader br;
|
|
try {
|
|
br = new BufferedReader(
|
|
new InputStreamReader(
|
|
new FileInputStream(file.getAbsoluteFile()), "UTF-8"));
|
|
String line;
|
|
StringBuilder targetString = new StringBuilder();
|
|
while ((line = br.readLine()) != null) {
|
|
targetString.append(line);
|
|
}
|
|
evaluation = evaluation.chargeNodeEvaluationIndex(index,targetString.toString().replace("\t","").replace("\r", "").replace("\n", ""));
|
|
}catch (Exception e) {
|
|
JFrame frame = new JFrame("Erreur");
|
|
JLabel texte = new JLabel("<html><h1>Erreur</h1><p>L'évaluation n'a pas été trouvé dans la base de données.</p></html>");
|
|
JOptionPane.showMessageDialog(frame, texte);
|
|
}
|
|
}
|
|
return evaluation;
|
|
}
|
|
|
|
/**
|
|
* Charge le fichier d'analyse de l'évaluation.<br>
|
|
* @param file
|
|
*/
|
|
@SuppressWarnings("unused")
|
|
private void chargeLeNodeSujet(File file) {
|
|
|
|
BufferedReader br;
|
|
try {
|
|
br = new BufferedReader(
|
|
new InputStreamReader(
|
|
new FileInputStream(file.getAbsoluteFile()), "UTF-8"));
|
|
String line;
|
|
StringBuilder targetString = new StringBuilder();
|
|
while ((line = br.readLine()) != null) {
|
|
targetString.append(line);
|
|
}
|
|
|
|
//node.node2(targetString);
|
|
node sujetLoad = new node(targetString.toString().replace("\t","").replace("\r", "").replace("\n", ""));
|
|
|
|
// Vérification de la conformité du fichier d'analyse
|
|
if(!ChargeFichierXML.fichierSujetValide(sujetLoad)) {
|
|
JOptionPane.showMessageDialog(null, "Le fichier d'analyse n'est pas valide.");
|
|
}else {
|
|
commandes.initialiseParametresSettingProprietes();
|
|
commandes.sujet = sujetLoad;
|
|
commandes.sujetSauvegarde = commandes.sujet.clone();
|
|
|
|
//Chargement des paramètres du fichier d'analyse
|
|
System.out.println( "Chargement des paramètres du fichier d'analyse");
|
|
meptl.chargementParametresFichierAnalyse();
|
|
|
|
// Rechercher des erreurs dans le fichier d'analyse
|
|
System.out.println( "Vérification du fichier d'analyse" );
|
|
new verificationFichierAnalyse_node_commandesSujet();
|
|
}
|
|
|
|
} catch (UnsupportedEncodingException e1) {
|
|
e1.printStackTrace();
|
|
} catch (FileNotFoundException e1) {
|
|
e1.printStackTrace();
|
|
} catch (Exception e) {
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* Récupère la date de modification du fichier d'analyse.
|
|
* @param file
|
|
* @return
|
|
*/
|
|
@SuppressWarnings("unused")
|
|
private Date recupereDateFichierAnalyseSource(File file) {
|
|
BufferedReader br;
|
|
try {
|
|
br = new BufferedReader(
|
|
new InputStreamReader(
|
|
new FileInputStream(file.getAbsoluteFile()), "UTF-8"));
|
|
String line;
|
|
StringBuilder targetString = new StringBuilder();
|
|
while ((line = br.readLine()) != null) {
|
|
targetString.append(line);
|
|
}
|
|
|
|
//node.node2(targetString);
|
|
node sujetLoad = new node(targetString.toString().replace("\t","").replace("\r", "").replace("\n", ""));
|
|
|
|
// Vérification de la conformité du fichier d'analyse
|
|
if(!ChargeFichierXML.fichierSujetValide(sujetLoad)) {
|
|
JOptionPane.showMessageDialog(null, "Le fichier d'analyse n'est pas valide.");
|
|
}else {
|
|
if(sujetLoad.getAttributs().get("date")!=null) {
|
|
String dateString = sujetLoad.getAttributs().get("date");
|
|
return calcul.formatDateWriter.DateLibreOffice(dateString);
|
|
}
|
|
|
|
}
|
|
|
|
} catch (UnsupportedEncodingException e1) {
|
|
e1.printStackTrace();
|
|
} catch (FileNotFoundException e1) {
|
|
e1.printStackTrace();
|
|
} catch (Exception e) {
|
|
}
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|