2022-05-24 18:25:41 +02:00
package app ;
import java.awt.BorderLayout ;
2022-05-25 09:30:49 +02:00
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 ;
2022-05-24 18:25:41 +02:00
2022-05-25 09:30:49 +02:00
import javax.swing.ImageIcon ;
import javax.swing.JButton ;
import javax.swing.JCheckBox ;
import javax.swing.JFileChooser ;
2022-05-24 18:25:41 +02:00
import javax.swing.JFrame ;
2022-05-25 09:30:49 +02:00
import javax.swing.JLabel ;
2022-05-24 18:25:41 +02:00
import javax.swing.JPanel ;
2022-05-25 09:30:49 +02:00
import javax.swing.JTextPane ;
import javax.swing.JToolBar ;
2022-05-24 18:25:41 +02:00
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 cXML.Run ;
import cXML.node ;
import net.lingala.zip4j.exception.ZipException ;
2022-05-25 15:28:58 +02:00
import javax.swing.SwingConstants ;
import java.awt.GridLayout ;
import javax.swing.JTextArea ;
import javax.swing.JScrollPane ;
import java.awt.Component ;
import javax.swing.Box ;
2022-05-24 18:25:41 +02:00
public class evaluate extends JFrame {
/ * *
*
* /
private static final long serialVersionUID = 1L ;
private JPanel contentPane ;
private JLabel lblPath = new JLabel ( ) ;
2022-05-25 15:28:58 +02:00
private JLabel lblFileAnalyse = new JLabel ( ) ;
2022-05-24 18:25:41 +02:00
private JCheckBox chckbxfichiersEtudaints = new JCheckBox ( ) ;
private JCheckBox chckbxZipfeedback = new JCheckBox ( ) ;
private JCheckBox chckbxnoFeedback = new JCheckBox ( ) ;
private JCheckBox chckbxNoNote = new JCheckBox ( ) ;
2022-05-25 15:28:58 +02:00
private JTextArea textAreaMessage = new JTextArea ( ) ;
2022-05-24 18:25:41 +02:00
/ * *
* Create the frame .
* /
public evaluate ( ) {
setIconImage ( Toolkit . getDefaultToolkit ( ) . getImage ( evaluate . class . getResource ( " /resources/evalwriter.ico " ) ) ) ;
setDefaultCloseOperation ( JFrame . EXIT_ON_CLOSE ) ;
2022-05-25 15:28:58 +02:00
setBounds ( 100 , 100 , 960 , 677 ) ;
2022-05-24 18:25:41 +02:00
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 ) ;
2022-05-25 15:28:58 +02:00
JButton btnSelectFolder = new JButton ( " Selection dossier d'analyse " ) ;
2022-05-24 18:25:41 +02:00
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 ( ) ;
}
} ) ;
2022-05-25 15:28:58 +02:00
btnSelectFolder . setIcon ( new ImageIcon ( evaluate . class . getResource ( " /resources/open2.png " ) ) ) ;
2022-05-24 18:25:41 +02:00
btnSelectFolder . setSelectedIcon ( new ImageIcon ( evaluate . class . getResource ( " /resources/evalwriter.png " ) ) ) ;
2022-05-25 15:28:58 +02:00
btnSelectFolder . setToolTipText ( " Sélectionner le dossier d'analyse (CTRL+O) " ) ;
2022-05-24 18:25:41 +02:00
toolBar . add ( btnSelectFolder ) ;
2022-05-25 15:28:58 +02:00
JButton btnNewButton = new JButton ( " Evaluer les fichiers des étudiants " ) ;
2022-05-24 18:25:41 +02:00
btnNewButton . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent e ) {
try {
evaluerLesFichiersEtudiants ( ) ;
} catch ( ParserConfigurationException | SAXException | IOException | CloneNotSupportedException e1 ) {
// TODO Auto-generated catch block
e1 . printStackTrace ( ) ;
}
}
} ) ;
2022-05-25 15:28:58 +02:00
JButton btnSelectFileAnalyse = new JButton ( " Selection fichier analyse " ) ;
btnSelectFileAnalyse . addActionListener ( new ActionListener ( ) {
public void actionPerformed ( ActionEvent e ) {
new filechooserXML ( ) ;
refreshLabel ( ) ;
}
} ) ;
btnSelectFileAnalyse . setToolTipText ( " Sélection du fichier d'analyse " ) ;
btnSelectFileAnalyse . setIcon ( new ImageIcon ( evaluate . class . getResource ( " /resources/fichierAnalyse.png " ) ) ) ;
toolBar . add ( btnSelectFileAnalyse ) ;
2022-05-24 18:25:41 +02:00
btnNewButton . setIcon ( new ImageIcon ( evaluate . class . getResource ( " /resources/evaluate.png " ) ) ) ;
toolBar . add ( btnNewButton ) ;
JPanel panel = new JPanel ( ) ;
contentPane . add ( panel , BorderLayout . WEST ) ;
2022-05-25 15:28:58 +02:00
panel . setLayout ( new GridLayout ( 0 , 1 , 0 , 0 ) ) ;
lblFileAnalyse = new JLabel ( " <HTML><B><U>Fichier de l'analyse</U></B> : </HTML> " ) ;
lblFileAnalyse . setHorizontalAlignment ( SwingConstants . LEFT ) ;
lblFileAnalyse . setFont ( new Font ( " Tahoma " , Font . PLAIN , 14 ) ) ;
panel . add ( lblFileAnalyse ) ;
lblPath . setHorizontalAlignment ( SwingConstants . LEFT ) ;
2022-05-24 18:25:41 +02:00
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> " ) ;
2022-05-25 15:28:58 +02:00
panel . add ( lblPath ) ;
2022-05-24 18:25:41 +02:00
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 " ) ;
2022-05-25 15:28:58 +02:00
panel . add ( chckbxfichiersEtudaints ) ;
2022-05-24 18:25:41 +02:00
chckbxnoFeedback = new JCheckBox ( " Pas de feedback " ) ;
chckbxnoFeedback . setFont ( new Font ( " Tahoma " , Font . PLAIN , 12 ) ) ;
2022-05-25 15:28:58 +02:00
panel . add ( chckbxnoFeedback ) ;
2022-05-24 18:25:41 +02:00
chckbxZipfeedback = new JCheckBox ( " Zip les feedbacks " ) ;
chckbxZipfeedback . setFont ( new Font ( " Tahoma " , Font . PLAIN , 12 ) ) ;
2022-05-25 15:28:58 +02:00
panel . add ( chckbxZipfeedback ) ;
2022-05-24 18:25:41 +02:00
chckbxNoNote = new JCheckBox ( " Pas de note dans les feedbacks " ) ;
chckbxNoNote . setFont ( new Font ( " Tahoma " , Font . PLAIN , 12 ) ) ;
2022-05-25 15:28:58 +02:00
panel . add ( chckbxNoNote ) ;
2022-05-24 18:25:41 +02:00
JPanel panel_1 = new JPanel ( ) ;
contentPane . add ( panel_1 , BorderLayout . CENTER ) ;
2022-05-25 15:28:58 +02:00
panel_1 . setLayout ( new GridLayout ( 1 , 0 , 0 , 0 ) ) ;
2022-05-24 18:25:41 +02:00
2022-05-25 15:28:58 +02:00
JScrollPane scrollPane = new JScrollPane ( ) ;
panel_1 . add ( scrollPane ) ;
textAreaMessage = new JTextArea ( ) ;
scrollPane . setViewportView ( textAreaMessage ) ;
textAreaMessage . setText ( " " ) ;
2022-05-24 18:25:41 +02:00
refreshLabel ( ) ;
setVisible ( true ) ;
}
private void refreshLabel ( ) {
if ( ! commandes . fichierAnalyseValide ) {
2022-05-25 15:28:58 +02:00
textAreaMessage . setText ( MEPTL . verificationFichierAnalyse . messageErreur . toString ( ) ) ;
2022-05-24 18:25:41 +02:00
chckbxfichiersEtudaints . setEnabled ( false ) ;
chckbxZipfeedback . setEnabled ( false ) ;
chckbxnoFeedback . setEnabled ( false ) ;
chckbxNoNote . setEnabled ( false ) ;
2022-05-25 15:28:58 +02:00
} else {
chckbxfichiersEtudaints . setEnabled ( true ) ;
chckbxZipfeedback . setEnabled ( true ) ;
chckbxnoFeedback . setEnabled ( true ) ;
chckbxNoNote . setEnabled ( true ) ;
StringBuilder text = new StringBuilder ( ) ;
text . append ( " Le titre de l'exercice est " + commandes . analyse_titre ) ;
text . append ( " \ n " ) ;
text . append ( " Le sujet (metaSujet) est " + commandes . analyse_metaSujet ) ;
text . append ( " \ n " ) ;
text . append ( " L'auteur de l'exercice est " + commandes . analyse_auteur ) ;
text . append ( " \ n " ) ;
text . append ( " \ n " ) ;
if ( commandes . analyse_baremeABC = = true ) {
text . append ( " La notation est sous la forme d'un barème alphabétique ABCDE. " ) ;
text . append ( " \ n " ) ;
} else {
text . append ( " La notation est sous la forme d'une note numérique. " ) ;
text . append ( " Le barème est sur " + String . valueOf ( commandes . analyse_notefrom ) ) ;
text . append ( " \ n " ) ;
}
textAreaMessage . setText ( text . toString ( ) ) ;
2022-05-24 18:25:41 +02:00
}
lblPath . setText ( " <HTML><B><U>Dossier de l'analyse</U></B> : " + commandes . path . substring ( commandes . path . lastIndexOf ( " \\ " ) + 1 , commandes . path . length ( ) ) + " </HTML> " ) ;
2022-05-25 15:28:58 +02:00
lblFileAnalyse . setText ( " <HTML><B><U>Fichier de l'analyse</U></B> : " + commandes . filename + " </HTML> " ) ;
2022-05-24 18:25:41 +02:00
}
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 {
2022-05-25 15:28:58 +02:00
a . AddStreamToZip ( feedbacks . feedback ( ana , verif , true ) , meptl . retourneLeNomDuFeedback ( a . getLectDossiers ( ) . getEC ( ) . getListeNomFichierFeedBack ( ) . get ( i ) , ana , verif ) , commandes . analyse_size , commandes . analyse_nameZip ) ;
2022-05-24 18:25:41 +02:00
} 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 ( ) ) ;
2022-05-25 15:28:58 +02:00
textAreaMessage . setText ( textMessage . toString ( ) ) ;
2022-05-24 18:25:41 +02:00
}
}
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();
// }
}
}
2022-05-25 09:30:49 +02:00
2022-05-24 18:25:41 +02:00
}