2022-06-03 21:30:14 +02:00
package app ;
import java.io.IOException ;
import javax.swing.JEditorPane ;
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 ;
2022-06-11 12:10:28 +02:00
import calcul.calculIntervalleBaremeABCDE ;
2022-06-16 16:45:48 +02:00
import evaluer.analyseFichier ;
2022-06-03 21:30:14 +02:00
import net.lingala.zip4j.exception.ZipException ;
public class evaluerLesFichiersEtudiants implements Runnable {
private final JEditorPane txt ;
2022-06-09 17:49:22 +02:00
public evaluerLesFichiersEtudiants ( JEditorPane txt ) {
2022-06-03 21:30:14 +02:00
commandes . analyse = true ;
2022-06-09 17:49:22 +02:00
// if(listeEtudiantCSV) commandes.fichierStudentMoodle=true;
// if(zipfeedback) commandes.zipfeedback=true;
// if(nofeedback) commandes.sansFeeback=true;
// if(nonote) commandes.noNote=true;
// if(notedansunCSV) commandes.ecritNoteCSV=true;
// if(newlogo) commandes.newLogo=true;
// if(nologo) commandes.noLogo = true;
// if(verifhisto2uniquement) commandes.verifHisto2 = true;
2022-06-03 21:30:14 +02:00
this . txt = txt ;
2022-06-09 09:13:46 +02:00
this . txt . setContentType ( " text/plain " ) ;
2022-06-03 21:30:14 +02:00
}
@Override
public synchronized void run ( ) {
commandes . message = new StringBuilder ( ) ;
2022-06-11 12:10:28 +02:00
commandes . message . append ( baliseStyle . balise ( ) ) ;
commandes . message . append ( " <hr><h1>*** LES FICHIERS DES ETUDIANTS ANALYSÉS ET ÉVALUÉS ***</h1><hr> " ) ;
commandes . message . append ( " <p>Dossier contenant les fichiers des étudiants.</p> " ) ;
commandes . message . append ( " <p><b> " + commandes . path + " </b></p> " ) ;
commandes . message . append ( " <br> " ) ;
if ( commandes . analyse_baremeABC ) {
commandes . message . append ( " <p>Barème alphabétique ABCDE.<p> " ) ;
commandes . message . append ( " <p>progression= " + String . valueOf ( commandes . analyse_progression ) + " <p> " ) ;
calculIntervalleBaremeABCDE C = new calculIntervalleBaremeABCDE ( commandes . analyse_progression ) ;
commandes . message . append ( " <p> " + C . getMessageLigne ( ) + " </p> " ) ;
commandes . message . append ( " <br> " ) ;
}
if ( commandes . zipfeedback ) {
commandes . message . append ( " <p>Les feedbacks sont dans une archive ou des archives ZIP dans le dossier contenant les fichiers des étudiants.</p> " ) ;
commandes . message . append ( " <br> " ) ;
}
if ( commandes . ecritNoteCSV ) {
commandes . message . append ( " <p>Un fichiers CSV contenant les notes a été créé dans le dossier contenant les fichiers des étudiants.</p> " ) ;
commandes . message . append ( " <br> " ) ;
}
commandes . message . append ( " <hr> " ) ;
2022-06-03 21:30:14 +02:00
Run a = null ;
try {
a = new Run ( commandes . path , commandes . Profil , commandes . fichierStudentMoodle ) ;
} catch ( ParserConfigurationException e2 ) {
e2 . printStackTrace ( ) ;
} catch ( SAXException e2 ) {
e2 . printStackTrace ( ) ;
} catch ( IOException e2 ) {
e2 . printStackTrace ( ) ;
}
//**********************************************
//** Chargement et verification du CVS fourni **
//**********************************************
if ( commandes . fourniCSV ) {
commandes . nodeCSV = meptl . chargementFichierCSV ( ) ;
}
//*****************************************
//** Nombre de fichier writer à analyser **
//*****************************************
int nbFichierWriter = a . getLectDossiers ( ) . getEC ( ) . getListeContentWriter ( ) . size ( ) ;
commandes . analyse_Nbre_Fichier_Student = nbFichierWriter ;
2022-06-11 12:10:28 +02:00
commandes . message . append ( " <br> " ) ;
commandes . message . append ( " <p>Nombre de fichier à analyser et évaluer : " + Integer . valueOf ( nbFichierWriter ) + " </p> " ) ;
2022-06-11 16:53:59 +02:00
commandes . message . append ( " <br> " ) ;
commandes . message . append ( " <hr> " ) ;
2022-06-03 21:30:14 +02:00
//***************************************
//** -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 + + ) {
2022-06-04 15:43:08 +02:00
txt . setText ( " \ nChargement de l'historique du fichier n° " + String . valueOf ( i ) + " par comparaison avec les " + String . valueOf ( nbFichierWriter - 1 ) + " autres fichiers " ) ;
2022-06-03 21:30:14 +02:00
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
2022-06-04 15:43:08 +02:00
txt . setText ( " \ nRecherche des concordances temporelles et d'auteur dans l'historique des modifications des " + nbFichierWriter + " fichiers. "
+ " \ nPatientez, cela peut prendre quelques secondes ou minutes. " ) ;
2022-06-03 21:30:14 +02:00
verif = meptl . verificationHistorique ( verification , a ) ; // vérification des correspondances entre les fichiers
//********************************
//** Ecriture du node verif.xml **
//********************************
try {
Run . ecritureNodeEnXML ( verif , " Verif " , commandes . path , " Verif " ) ;
} catch ( IOException e ) {
e . printStackTrace ( ) ;
} //écriture du node de vérification
2022-06-11 12:10:28 +02:00
commandes . message . append ( " <br> " ) ;
2022-06-11 16:53:59 +02:00
commandes . message . append ( " <hr><h1> *** Ecriture du fichier Verif.xml dans le dossier d'analyse *** </h1><hr> " ) ;
2022-06-11 12:10:28 +02:00
commandes . message . append ( " <br> " ) ;
2022-06-03 21:30:14 +02:00
if ( ! commandes . analyse ) {
//** bye bye analyseWriter
commandes . clotureApplication ( ) ;
}
}
//*********************************************************
//** Node contenant l'ensemble des analyses des étudiants **
//*********************************************************
node ensembleanalyse = new node ( ) ;
ensembleanalyse . setNomElt ( " analyses " ) ;
//*****************************************************
//** Parcours l'ensemble des fichiers des étudiants ***
//*****************************************************
for ( int i = 0 ; i < nbFichierWriter ; i + + ) {
2022-06-11 12:10:28 +02:00
txt . setText ( " \ nEvaluation du fichier n° " + String . valueOf ( i + 1 ) + " / " + String . valueOf ( nbFichierWriter ) + " fichier(s) " ) ;
2022-06-03 21:30:14 +02:00
//index de l'étudiant
commandes . analyse_index_Fichier_Student = 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 = null ;
try {
nodStudent = meptl . LectureFichierEtudiantSousFormeDeNode ( nod , a , i ) ;
} catch ( IOException e1 ) {
e1 . printStackTrace ( ) ;
}
//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
2022-06-16 16:45:48 +02:00
node ana = analyseFichier . analyse ( nodStudent , commandes . sujet , i , a ) ;
2022-06-03 21:30:14 +02:00
//**************************************************
//** Ecriture des fichiers d'analyse des students **
//**************************************************
if ( commandes . ecritNodeAnalyse ) {
try {
Run . ecritureNodeEnXML ( ana , " nodana " + ana . retourneFirstEnfantsByName ( " ouverture " ) . getAttributs ( ) . get ( " dossier " ) , commandes . path , " " ) ;
} catch ( IOException e ) {
e . printStackTrace ( ) ;
}
}
//****************************
//** Création des feedbacks **
//****************************
if ( ! commandes . sansFeeback & & ! commandes . ecritNodeAnalyse ) {
if ( ! commandes . zipfeedback ) {
//feedback(ana, verif); //classique directement dans le répertoire
2022-06-09 17:49:22 +02:00
System . out . println ( " feedback non zippé. " ) ;
2022-06-03 21:30:14 +02:00
try {
2022-06-09 17:49:22 +02:00
feedbacks . feedback ( ana , verif , false , false ) ;
2022-06-03 21:30:14 +02:00
} catch ( IOException e ) {
e . printStackTrace ( ) ;
}
}
if ( commandes . zipfeedback ) { // Dans une archive pour Moodle
try {
2022-06-09 17:49:22 +02:00
System . out . println ( " feedback zippé. " ) ;
a . AddStreamToZip ( feedbacks . feedback ( ana , verif , true , false ) , meptl . retourneLeNomDuFeedback ( a . getLectDossiers ( ) . getEC ( ) . getListeNomFichierFeedBack ( ) . get ( i ) , ana , verif ) , commandes . analyse_size , commandes . analyse_nameZip ) ;
2022-06-03 21:30:14 +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 **
//*********************************************************
commandes . message . append ( meptl . messageSystem ( ana ) . toString ( ) ) ;
}
}
//*****************************************************
//** Exportation au format CSV si -csv ou -verifcsv **
//*****************************************************
if ( commandes . ecritNoteCSV & & ! commandes . fourniCSV ) {
if ( ! commandes . verifHisto2 )
try {
meptl . ecritureCSV ( ensembleanalyse ) ;
} catch ( IOException e ) {
e . printStackTrace ( ) ;
}
if ( commandes . verifHisto2 )
try {
meptl . ecritureCSV ( ensembleanalyse , verif , a , commandes . sujet . retourneFirstEnfantsByName ( " setting " ) ) ;
} catch ( IOException e ) {
e . printStackTrace ( ) ;
}
}
//***********************************************************************
//** Exportation au format CSV si -csv file.csv ou -verifcsv file.csv **
//***********************************************************************
if ( commandes . ecritNoteCSV & & commandes . fourniCSV ) {
try {
meptl . ecritureCSV ( ensembleanalyse , verif , a , commandes . nodeCSV , commandes . sujet . retourneFirstEnfantsByName ( " setting " ) ) ;
} catch ( IOException e ) {
e . printStackTrace ( ) ;
}
//a.ecritureNodeEnXML(ensembleanalyse, "ensembleAnalyse"); //écriture du node de l'étudiant
}
//**************************************
//** Mise à jour du fichier d'analyse **
//**************************************
if ( commandes . MAJFichierAnalyse | | commandes . MAJnameAnalysisFile ) {
try {
verificationFichierAnalyse . MiseAJourFichierAnalyse ( ) ;
} catch ( CloneNotSupportedException | IOException e ) {
e . printStackTrace ( ) ;
}
verificationFichierAnalyse . messagMiseAJourFichierAnalyseAprèsAnalyse ( ) ;
}
2022-06-11 12:10:28 +02:00
txt . setContentType ( " text/html " ) ;
txt . setText ( commandes . message . toString ( ) ) ;
2022-06-03 21:30:14 +02:00
}
2022-06-09 17:49:22 +02:00
2022-06-03 21:30:14 +02:00
}