package app; import java.awt.BorderLayout; import java.awt.EventQueue; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextPane; import javax.swing.JToolBar; import javax.swing.border.EmptyBorder; import javax.swing.filechooser.FileNameExtensionFilter; import javax.xml.parsers.ParserConfigurationException; import org.xml.sax.SAXException; import MEPTL.commandes; import MEPTL.feedbacks; import MEPTL.meptl; import cXML.Run; import cXML.node; import net.lingala.zip4j.exception.ZipException; import javax.swing.SwingConstants; import javax.swing.Timer; import java.awt.GridLayout; import java.awt.Image; import javax.swing.JTextArea; import javax.swing.JScrollPane; import java.awt.Component; import javax.swing.Box; import javax.swing.JEditorPane; import javax.swing.JProgressBar; import javax.swing.JSeparator; import net.miginfocom.swing.MigLayout; import java.awt.Label; public class evaluate extends JFrame { /** * */ private static final long serialVersionUID = 1L; private JPanel contentPane; private JLabel lblPath = new JLabel(); private JLabel lblFileAnalyse = new JLabel(); private JLabel lblFichierCSV = new JLabel(); private JLabel lblFichierSVG = new JLabel(); private JCheckBox chckbxfichiersEtudaints = new JCheckBox(); private JCheckBox chckbxZipfeedback = new JCheckBox(); private JCheckBox chckbxnoFeedback = new JCheckBox(); private JCheckBox chckbxNoNote = new JCheckBox(); private JCheckBox chckCSVNotes = new JCheckBox(); private JCheckBox chckbxNoLogo = new JCheckBox(); JCheckBox chckbxNewLogo = new JCheckBox(); private JTextPane txtpnmessages = new JTextPane(); private JProgressBar progressBar = new JProgressBar(); private JButton btnSelectFileAnalyse = new JButton(); private JButton btnSelectFolder = new JButton(); private JButton btnEvaluerLesFichiers = new JButton(); private JButton btnFichierCSV = new JButton(); private JButton btnAbout = new JButton(); private JButton btnFichierSVG = new JButton(); /** * Create the frame. */ public evaluate() { ImageIcon img = new ImageIcon(getClass().getResource("/evalwriter.png") ); this.setIconImage(img.getImage()); this.setTitle(commandes.Titre); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 960, 677); 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); btnSelectFileAnalyse = new JButton(""); btnSelectFileAnalyse.setToolTipText("Sélection du fichier d'analyse"); btnSelectFileAnalyse.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierAnalyse.png"))); toolBar.add(btnSelectFileAnalyse); btnSelectFolder = new JButton(""); btnSelectFolder.setIcon(new ImageIcon(evaluate.class.getResource("/resources/open2.png"))); btnSelectFolder.setSelectedIcon(new ImageIcon(evaluate.class.getResource("/resources/evalwriter.png"))); btnSelectFolder.setToolTipText("Sélectionner le dossier contenant les fichiers des étudiants"); toolBar.add(btnSelectFolder); toolBar.addSeparator(); btnEvaluerLesFichiers = new JButton(""); btnEvaluerLesFichiers.setToolTipText("Evaluer les fichiers des étudiants"); btnFichierCSV = new JButton(""); btnFichierCSV.setToolTipText("Sélectionner la liste des étudiants"); btnFichierCSV.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierCSV.png"))); toolBar.add(btnFichierCSV); btnFichierSVG = new JButton(""); btnFichierSVG.setToolTipText("Sélectionner le fichier Logo"); btnFichierSVG.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierSVG.png"))); toolBar.add(btnFichierSVG); toolBar.addSeparator(); JButton btnNewButton_1 = new JButton(""); btnNewButton_1.setToolTipText("Créer un fichier d'analyse à partir d'un fichier ODF"); btnNewButton_1.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierODF.png"))); toolBar.add(btnNewButton_1); toolBar.addSeparator(); btnEvaluerLesFichiers.setIcon(new ImageIcon(evaluate.class.getResource("/resources/evaluate.png"))); toolBar.add(btnEvaluerLesFichiers); toolBar.addSeparator(); btnAbout = new JButton(""); btnAbout.setIcon(new ImageIcon(evaluate.class.getResource("/resources/apropos.png"))); btnAbout.setToolTipText("Informations"); toolBar.add(btnAbout); JPanel panel = new JPanel(); contentPane.add(panel, BorderLayout.WEST); panel.setLayout(new MigLayout("", "[309px]", "[71px][71px][][71px][][74.00][][]")); lblFileAnalyse = new JLabel("Fichier de l'analyse : "); lblFileAnalyse.setHorizontalAlignment(SwingConstants.LEFT); lblFileAnalyse.setFont(new Font("Tahoma", Font.BOLD, 14)); panel.add(lblFileAnalyse, "flowy,cell 0 0,alignx left,growy"); 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"); panel.add(chckbxfichiersEtudaints, "flowy,cell 0 1,grow"); lblFichierCSV = new JLabel("Fichier CSV liste des étudiants :"); lblFichierCSV.setFont(new Font("Tahoma", Font.BOLD, 14)); panel.add(lblFichierCSV, "flowy,cell 0 3,grow"); lblFichierSVG = new JLabel("Fichier SVG :"); lblFichierSVG.setFont(new Font("Tahoma", Font.BOLD, 14)); panel.add(lblFichierSVG, "flowy,cell 0 5,growx"); chckCSVNotes = new JCheckBox("Créer un fichier CSV des notes"); panel.add(chckCSVNotes, "cell 0 3,grow"); lblPath.setHorizontalAlignment(SwingConstants.LEFT); lblPath.setFont(new Font("Tahoma", Font.BOLD, 14)); lblPath.setText("Dossier de l'analyse : " + commandes.path.substring(commandes.path.lastIndexOf("\\")+1,commandes.path.length()) + ""); panel.add(lblPath, "cell 0 0,grow"); chckbxnoFeedback = new JCheckBox("Pas de feedback"); chckbxnoFeedback.setFont(new Font("Tahoma", Font.PLAIN, 12)); panel.add(chckbxnoFeedback, "cell 0 1,grow"); chckbxZipfeedback = new JCheckBox("Zip les feedbacks"); chckbxZipfeedback.setFont(new Font("Tahoma", Font.PLAIN, 12)); panel.add(chckbxZipfeedback, "cell 0 1,grow"); chckbxNoNote = new JCheckBox("Pas de note dans les feedbacks"); chckbxNoNote.setFont(new Font("Tahoma", Font.PLAIN, 12)); panel.add(chckbxNoNote, "cell 0 1,grow"); chckbxNewLogo = new JCheckBox("Nouveau logo"); chckbxNewLogo.setFont(new Font("Tahoma", Font.PLAIN, 11)); panel.add(chckbxNewLogo, "cell 0 5"); chckbxNoLogo = new JCheckBox("Pas de logo"); panel.add(chckbxNoLogo, "cell 0 5"); JPanel panel_1 = new JPanel(); contentPane.add(panel_1, BorderLayout.CENTER); panel_1.setLayout(new GridLayout(1, 0, 0, 0)); JScrollPane scrollPane = new JScrollPane(); panel_1.add(scrollPane); progressBar = new JProgressBar(); progressBar.setEnabled(false); scrollPane.setColumnHeaderView(progressBar); txtpnmessages = new JTextPane(); txtpnmessages.setFont(new Font("Tahoma", Font.PLAIN, 12)); txtpnmessages.setText("Charger un fichier d'analyse."); scrollPane.setViewportView(txtpnmessages); CommandeListener(); refreshLabel(); setVisible(true); } /** * Raffraichi les informations */ private void refreshLabel() { if(!commandes.fichierAnalyseValide) { txtpnmessages.setText(MEPTL.verificationFichierAnalyse.messageErreur.toString()); chckbxfichiersEtudaints.setEnabled(false); chckbxZipfeedback.setEnabled(false); chckbxnoFeedback.setEnabled(false); chckbxNoNote.setEnabled(false); chckCSVNotes.setEnabled(false); chckbxNewLogo.setEnabled(false); chckbxNoLogo.setEnabled(false); }else { chckbxfichiersEtudaints.setEnabled(true); chckbxZipfeedback.setEnabled(true); chckbxnoFeedback.setEnabled(true); chckbxNoNote.setEnabled(true); chckCSVNotes.setEnabled(true); chckbxNewLogo.setEnabled(true); chckbxNoLogo.setEnabled(true); StringBuilder text = new StringBuilder(); text.append("\n***********************************************"); text.append("\n INFORMATIONS"); text.append("\n***********************************************"); text.append("\nLe titre de l'exercice est : " + commandes.analyse_titre); text.append("\n"); text.append("\nLe sujet (metaSujet) est : " + commandes.analyse_metaSujet); text.append("\n"); text.append("\nL'auteur de l'exercice est : " + commandes.analyse_auteur); text.append("\n"); if(commandes.analyse_baremeABC==true) { text.append("\nLa notation est sous la forme d'un barème alphabétique ABCDE."); text.append("\n\tLa progression est de " + String.valueOf(commandes.analyse_progression)); }else { text.append("\nLa notation est sous la forme d'une note numérique."); text.append("\n\tLe barème est sur " + String.valueOf(commandes.analyse_notefrom)); text.append("\n\tLa progression est de " + String.valueOf(commandes.analyse_progression)); } text.append("\n______"); text.append("\nLe nom du fichier : " + commandes.analysis_filename); text.append("\nLe hash de l'évaluation est : " + commandes.hash); text.append("\n______"); text.append("\nHistoriques des modifications present : " + commandes.analyse_historiquePresent); text.append("\n______"); text.append("\nVerification de la presence metaSujet : " + commandes.analyse_presenceMetaSujet); text.append("\n______"); text.append("\nContrôle la date de céation : " + commandes.analyse_controleDateCreation); text.append("\n______"); text.append("\nContrôle l'auteur initial du fichier : " + commandes.analyse_controle_Initial_Creator); text.append("\n***********************************************"); progressBar.setVisible(false); txtpnmessages.setText(text.toString()); } lblPath.setText("Dossier de l'analyse : " + commandes.path.substring(commandes.path.lastIndexOf("\\")+1,commandes.path.length()) + ""); lblFileAnalyse.setText("Fichier de l'analyse : " + commandes.analysis_filename + ""); lblFichierSVG.setText("Fichier SVG : " + commandes.nameSVG.substring(commandes.nameSVG.lastIndexOf("\\")+1,commandes.nameSVG.length()) + ""); lblFichierCSV.setText("Fichier CSV : " + commandes.nameCSV + ""); } /** * Les actionListener */ private void CommandeListener() { // Sélectionne un dossier pour analyser le contenu btnSelectFolder.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(commandes.path)); chooser.setDialogTitle("Sélectionner le dossier contenant les fichiers des étudiants."); 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(); } }); // Sélectionne un fichier d'analyse btnSelectFileAnalyse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new filechooserXML(); refreshLabel(); } }); // Analyse le contenu du dossier btnEvaluerLesFichiers.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(commandes.fichierAnalyseValide) { try { msgBox V = new msgBox("Je travaille dure.",false,false,"Attendez"); Thread.sleep(500); evaluerLesFichiersEtudiants(); V.close(); } catch (ParserConfigurationException | SAXException | IOException | CloneNotSupportedException e1) { e1.printStackTrace(); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }else { new msgBox("Le fichier d'analyse n'est pas valide.",true,false,"Avertissement"); } } }); // Sélectionne un fichier CSV btnFichierCSV.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("Choisir un fichier CSV"); chooser.setCurrentDirectory(new java.io.File(commandes.path)); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); FileNameExtensionFilter filter = new FileNameExtensionFilter("Format CSV", "csv"); chooser.setFileFilter(filter); chooser.setAcceptAllFileFilterUsed(true); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { System.out.println("getCurrentDirectory(): " + chooser.getCurrentDirectory()); System.out.println("getSelectedFile() : " + chooser.getSelectedFile().getAbsolutePath()); commandes.nameCSV = chooser.getSelectedFile().getAbsolutePath(); commandes.fourniCSV=true; } else { commandes.nameCSV = ""; commandes.fourniCSV=false; System.out.println("No Selection "); } refreshLabel(); } }); // Bouton SVG btnFichierSVG.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("Choisir un fichier SVG"); chooser.setCurrentDirectory(new java.io.File(commandes.path)); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); FileNameExtensionFilter filter = new FileNameExtensionFilter("Format SVG", "svg"); chooser.setFileFilter(filter); chooser.setAcceptAllFileFilterUsed(true); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { System.out.println("getCurrentDirectory(): " + chooser.getCurrentDirectory()); System.out.println("getSelectedFile() : " + chooser.getSelectedFile().getAbsolutePath()); commandes.nameSVG = chooser.getSelectedFile().getAbsolutePath(); commandes.contenuFichierSVG= meptl.chargementFichierSVG(); txtpnmessages.setText(commandes.contenuFichierSVG); } else { commandes.nameSVG = ""; commandes.contenuFichierSVG=""; System.out.println("No Selection "); } refreshLabel(); } }); // Bouton About btnAbout.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new about(); } }); } /** * Permet l'évaluation des fichiers des étudaints. * @throws ParserConfigurationException * @throws SAXException * @throws IOException * @throws CloneNotSupportedException */ private void evaluerLesFichiersEtudiants() throws ParserConfigurationException, SAXException, IOException, CloneNotSupportedException { commandes.analyse=true; progressBar.setVisible(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; if(chckCSVNotes.isSelected()) commandes.ecritNoteCSV=true; if(chckbxNewLogo.isSelected()) commandes.newLogo=true; if(chckbxNoLogo.isSelected()) commandes.noLogo = true; meptl.analyseVerifieHistoriqueLesFichiersEtudiantsEtExportNoteCSV(); txtpnmessages.setText(commandes.message.toString()); progressBar.setVisible(false); } }