366 lines
15 KiB
Java
366 lines
15 KiB
Java
package app;
|
|
|
|
import java.awt.BorderLayout;
|
|
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.border.EmptyBorder;
|
|
import javax.xml.parsers.ParserConfigurationException;
|
|
|
|
import org.xml.sax.SAXException;
|
|
|
|
import MEPTL.commandes;
|
|
import MEPTL.feedbacks;
|
|
import MEPTL.meptl;
|
|
import MEPTL.verificationFichierAnalyse;
|
|
import cXML.Run;
|
|
import cXML.node;
|
|
import net.lingala.zip4j.exception.ZipException;
|
|
|
|
import javax.swing.JFileChooser;
|
|
|
|
import javax.swing.JToolBar;
|
|
import javax.swing.JButton;
|
|
import javax.swing.ImageIcon;
|
|
import javax.swing.JLabel;
|
|
import java.awt.event.ActionListener;
|
|
import java.io.IOException;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.GridBagLayout;
|
|
import java.awt.GridBagConstraints;
|
|
import javax.swing.JCheckBox;
|
|
import java.awt.Insets;
|
|
import java.awt.Font;
|
|
import javax.swing.JSeparator;
|
|
import javax.swing.JTextPane;
|
|
import java.awt.Color;
|
|
import java.awt.Toolkit;
|
|
|
|
@SuppressWarnings("unused")
|
|
public class evaluate extends JFrame {
|
|
|
|
/**
|
|
*
|
|
*/
|
|
private static final long serialVersionUID = 1L;
|
|
private JPanel contentPane;
|
|
private JLabel lblPath = new JLabel();
|
|
private JCheckBox chckbxfichiersEtudaints = new JCheckBox();
|
|
private JCheckBox chckbxZipfeedback = new JCheckBox();
|
|
private JCheckBox chckbxnoFeedback = new JCheckBox();
|
|
private JCheckBox chckbxNoNote = new JCheckBox();
|
|
private JTextPane textPane = new JTextPane();
|
|
|
|
/**
|
|
* Create the frame.
|
|
*/
|
|
public evaluate() {
|
|
|
|
setIconImage(Toolkit.getDefaultToolkit().getImage(evaluate.class.getResource("/resources/evalwriter.ico")));
|
|
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
setBounds(100, 100, 882, 533);
|
|
contentPane = new JPanel();
|
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
|
setContentPane(contentPane);
|
|
contentPane.setLayout(new BorderLayout(0, 0));
|
|
|
|
JToolBar toolBar = new JToolBar();
|
|
contentPane.add(toolBar, BorderLayout.NORTH);
|
|
|
|
JButton btnSelectFolder = new JButton("Selection dossier");
|
|
btnSelectFolder.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
JFileChooser chooser = new JFileChooser();
|
|
|
|
chooser.setCurrentDirectory(new java.io.File(commandes.path));
|
|
chooser.setDialogTitle("choosertitle");
|
|
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
|
chooser.setAcceptAllFileFilterUsed(false);
|
|
|
|
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
|
|
System.out.println("getCurrentDirectory(): " + chooser.getCurrentDirectory());
|
|
System.out.println("getSelectedFile() : " + chooser.getSelectedFile().getAbsolutePath());
|
|
commandes.path = chooser.getSelectedFile().getAbsolutePath();
|
|
} else {
|
|
System.out.println("No Selection ");
|
|
}
|
|
|
|
refreshLabel();
|
|
|
|
}
|
|
});
|
|
btnSelectFolder.setIcon(new ImageIcon(evaluate.class.getResource("/resources/open.png")));
|
|
btnSelectFolder.setSelectedIcon(new ImageIcon(evaluate.class.getResource("/resources/evalwriter.png")));
|
|
btnSelectFolder.setToolTipText("Sélectionner un dossier (CTRL+O)");
|
|
toolBar.add(btnSelectFolder);
|
|
|
|
JButton btnNewButton = new JButton("Evaluer");
|
|
btnNewButton.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent e) {
|
|
try {
|
|
evaluerLesFichiersEtudiants();
|
|
} catch (ParserConfigurationException | SAXException | IOException | CloneNotSupportedException e1) {
|
|
// TODO Auto-generated catch block
|
|
e1.printStackTrace();
|
|
}
|
|
|
|
}
|
|
});
|
|
btnNewButton.setIcon(new ImageIcon(evaluate.class.getResource("/resources/evaluate.png")));
|
|
toolBar.add(btnNewButton);
|
|
|
|
JPanel panel = new JPanel();
|
|
contentPane.add(panel, BorderLayout.WEST);
|
|
GridBagLayout gbl_panel = new GridBagLayout();
|
|
gbl_panel.columnWidths = new int[]{104, 0};
|
|
gbl_panel.rowHeights = new int[]{14, 0, 0, 0, 0, 0, 0, 0};
|
|
gbl_panel.columnWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
|
panel.setLayout(gbl_panel);
|
|
lblPath.setFont(new Font("Tahoma", Font.PLAIN, 14));
|
|
lblPath.setText("<HTML><B><U>Dossier de l'analyse</U></B> : " + commandes.path.substring(commandes.path.lastIndexOf("\\")+1,commandes.path.length()) + "</HTML>");
|
|
|
|
|
|
|
|
GridBagConstraints gbc_lblPath = new GridBagConstraints();
|
|
gbc_lblPath.insets = new Insets(0, 0, 5, 0);
|
|
gbc_lblPath.anchor = GridBagConstraints.NORTHWEST;
|
|
gbc_lblPath.gridx = 0;
|
|
gbc_lblPath.gridy = 1;
|
|
panel.add(lblPath, gbc_lblPath);
|
|
|
|
chckbxfichiersEtudaints = new JCheckBox("Les fichiers ne sont pas dans des dossiers nominatifs");
|
|
chckbxfichiersEtudaints.setFont(new Font("Tahoma", Font.PLAIN, 12));
|
|
chckbxfichiersEtudaints.setToolTipText("Cochez si les fichiers des étudiants ne sont pas dans des dossier nominatifs");
|
|
GridBagConstraints gbc_chckbxfichiersEtudaints = new GridBagConstraints();
|
|
gbc_chckbxfichiersEtudaints.anchor = GridBagConstraints.WEST;
|
|
gbc_chckbxfichiersEtudaints.insets = new Insets(0, 0, 5, 0);
|
|
gbc_chckbxfichiersEtudaints.gridx = 0;
|
|
gbc_chckbxfichiersEtudaints.gridy = 2;
|
|
panel.add(chckbxfichiersEtudaints, gbc_chckbxfichiersEtudaints);
|
|
|
|
chckbxnoFeedback = new JCheckBox("Pas de feedback");
|
|
chckbxnoFeedback.setFont(new Font("Tahoma", Font.PLAIN, 12));
|
|
GridBagConstraints gbc_chckbxnoFeedback = new GridBagConstraints();
|
|
gbc_chckbxnoFeedback.anchor = GridBagConstraints.WEST;
|
|
gbc_chckbxnoFeedback.insets = new Insets(0, 0, 5, 0);
|
|
gbc_chckbxnoFeedback.gridx = 0;
|
|
gbc_chckbxnoFeedback.gridy = 4;
|
|
panel.add(chckbxnoFeedback, gbc_chckbxnoFeedback);
|
|
|
|
chckbxZipfeedback = new JCheckBox("Zip les feedbacks");
|
|
chckbxZipfeedback.setFont(new Font("Tahoma", Font.PLAIN, 12));
|
|
GridBagConstraints gbc_chckbxZipfeedback = new GridBagConstraints();
|
|
gbc_chckbxZipfeedback.insets = new Insets(0, 0, 5, 0);
|
|
gbc_chckbxZipfeedback.anchor = GridBagConstraints.NORTHWEST;
|
|
gbc_chckbxZipfeedback.gridx = 0;
|
|
gbc_chckbxZipfeedback.gridy = 5;
|
|
panel.add(chckbxZipfeedback, gbc_chckbxZipfeedback);
|
|
|
|
chckbxNoNote = new JCheckBox("Pas de note dans les feedbacks");
|
|
chckbxNoNote.setFont(new Font("Tahoma", Font.PLAIN, 12));
|
|
GridBagConstraints gbc_chckbxNoNote = new GridBagConstraints();
|
|
gbc_chckbxNoNote.anchor = GridBagConstraints.WEST;
|
|
gbc_chckbxNoNote.gridx = 0;
|
|
gbc_chckbxNoNote.gridy = 6;
|
|
panel.add(chckbxNoNote, gbc_chckbxNoNote);
|
|
|
|
|
|
JPanel panel_1 = new JPanel();
|
|
contentPane.add(panel_1, BorderLayout.CENTER);
|
|
panel_1.setLayout(null);
|
|
|
|
textPane = new JTextPane();
|
|
textPane.setFont(new Font("Tahoma", Font.PLAIN, 12));
|
|
textPane.setBounds(30, 28, 495, 412);
|
|
panel_1.add(textPane);
|
|
|
|
|
|
|
|
refreshLabel();
|
|
setVisible(true);
|
|
}
|
|
|
|
|
|
private void refreshLabel() {
|
|
if(!commandes.fichierAnalyseValide) {
|
|
textPane.setText(MEPTL.verificationFichierAnalyse.messageErreur.toString());
|
|
chckbxfichiersEtudaints.setEnabled(false);
|
|
chckbxZipfeedback.setEnabled(false);
|
|
chckbxnoFeedback.setEnabled(false);
|
|
chckbxNoNote.setEnabled(false);
|
|
}
|
|
|
|
lblPath.setText("<HTML><B><U>Dossier de l'analyse</U></B> : " + commandes.path.substring(commandes.path.lastIndexOf("\\")+1,commandes.path.length()) + "</HTML>");
|
|
|
|
}
|
|
|
|
|
|
private void evaluerLesFichiersEtudiants() throws ParserConfigurationException, SAXException, IOException, CloneNotSupportedException {
|
|
|
|
commandes.analyse=true;
|
|
|
|
if(chckbxfichiersEtudaints.isSelected()) commandes.fichierStudentMoodle=true;
|
|
if(chckbxZipfeedback.isSelected()) commandes.zipfeedback=true;
|
|
if(chckbxnoFeedback.isSelected()) commandes.sansFeeback=true;
|
|
if(chckbxNoNote.isSelected()) commandes.noNote=true;
|
|
|
|
Run a = new Run(commandes.path,commandes.Profil, commandes.fichierStudentMoodle);
|
|
|
|
//** Nouveau node qui permet de convertir le fichier contenant la liste des étudiants en node.
|
|
node nodeCSV = null;
|
|
|
|
//*****************************************
|
|
//** Nombre de fichier writer à analyser **
|
|
//*****************************************
|
|
int nbFichierWriter = a.getLectDossiers().getEC().getListeContentWriter().size();
|
|
|
|
|
|
|
|
//***************************************
|
|
//** -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 = meptl.verificationHistorique(verification, a); // vérification des correspondances entre les fichiers
|
|
|
|
//********************************
|
|
//** Ecriture du node verif.xml **
|
|
//********************************
|
|
Run.ecritureNodeEnXML(verif, "Verif",commandes.pathDestination,commandes.fourniDossierDestination, "Verif"); //écriture du node de vérification
|
|
if(!commandes.analyse) {
|
|
//** bye bye analyseWriter
|
|
commandes.clotureApplication();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
System.getProperty("file.encoding","UTF-8");
|
|
|
|
//*********************************************************
|
|
//** Node contenant l'ensemble des analyses des étudiants **
|
|
//*********************************************************
|
|
node ensembleanalyse = new node();
|
|
ensembleanalyse.setNomElt("analyses");
|
|
|
|
|
|
StringBuilder textMessage = new StringBuilder();
|
|
|
|
//*****************************************************
|
|
//** Parcours l'ensemble des fichiers des étudiants ***
|
|
//*****************************************************
|
|
for(int i = 0 ; i < nbFichierWriter ; 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 = meptl.analyse(nodStudent, commandes.sujet, i, a);
|
|
|
|
//**************************************************
|
|
//** Ecriture des fichiers d'analyse des students **
|
|
//**************************************************
|
|
if(commandes.ecritNodeAnalyse) {
|
|
Run.ecritureNodeEnXML(ana, "nodana"+ana.retourneFirstEnfantsByName("ouverture").getAttributs().get("dossier"),"",false,""); //é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);
|
|
}
|
|
if(commandes.zipfeedback) { // Dans une archive pour Moodle
|
|
try {
|
|
long size = 48000000; //valeur par défaut
|
|
String nameZip = "feedbackMoodle"; //nom zip par défaut
|
|
node zip = commandes.sujet.retourneFirstEnfantsByName("zip");
|
|
if(zip!=null) {
|
|
if(zip.getAttributs().get("size")!=null)size = Long.valueOf(zip.getAttributs().get("size"));
|
|
if(zip.getAttributs().get("name")!=null)nameZip = zip.getAttributs().get("name");
|
|
}
|
|
//a.AddStreamToZip(feedbackForZip(ana, verif), retourneLeNomDuFeedback(a.getLectDossiers().getEC().getListeNomFichierFeedBack().get(i),ana, verif),size,nameZip);
|
|
a.AddStreamToZip(feedbacks.feedback(ana, verif, true), meptl.retourneLeNomDuFeedback(a.getLectDossiers().getEC().getListeNomFichierFeedBack().get(i),ana, verif),size,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 **
|
|
//*********************************************************
|
|
textMessage.append(meptl.messageSystem(ana).toString());
|
|
textPane.setText(textMessage.toString());
|
|
|
|
}
|
|
}
|
|
|
|
if(commandes.sujet!=null) {
|
|
//*****************************************************
|
|
//** Exportation au format CSV si -csv ou -verifcsv **
|
|
//*****************************************************
|
|
if(commandes.ecritNoteCSV && !commandes.fourniCSV) {
|
|
if(!commandes.verifHisto2) meptl.ecritureCSV(ensembleanalyse);
|
|
if(commandes.verifHisto2) meptl.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) {
|
|
meptl.ecritureCSV(ensembleanalyse,verif,a,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();
|
|
// }
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|