2022-06-03 21:30:14 +02:00
package app ;
2022-06-09 17:49:22 +02:00
import java.awt.Desktop ;
import java.io.BufferedOutputStream ;
import java.io.File ;
import java.io.FileOutputStream ;
2022-06-03 21:30:14 +02:00
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 ;
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 ( ) ;
commandes . message . append ( " \ n *** LES FICHIERS ANALYSES & EVALUES *** \ n " ) ;
commandes . message . append ( " \ n " ) ;
commandes . message . append ( " \ n Dossier contenant les fichiers des étudiants. " ) ;
commandes . message . append ( " \ n " + commandes . path + " \ n " ) ;
commandes . message . append ( " \ n Les fichiers des étudiants ne sont pas dans des dossiers nominatifs ? " ) ;
commandes . message . append ( " " + commandes . fichierStudentMoodle + " \ n " ) ;
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 ;
commandes . message . append ( " \ nNombre de fichier à analyser et évaluer : " + Integer . valueOf ( nbFichierWriter ) + " \ n " ) ;
//***************************************
//** -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
commandes . message . append ( " \ n******************************************************* " ) ;
commandes . message . append ( " \ nEcriture du fichier Verif.xml dans le dossier d'analyse " ) ;
commandes . message . append ( " \ n******************************************************* " ) ;
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-04 15:43:08 +02:00
txt . setText ( " \ nEvaluation du fichier n° " + String . valueOf ( i ) + " / " + String . valueOf ( nbFichierWriter - 1 ) + " 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
node ana = meptl . analyse ( nodStudent , commandes . sujet , i , a ) ;
//**************************************************
//** 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 ( ) ) ;
}
}
txt . setText ( commandes . message . 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-09 17:49:22 +02:00
2022-06-03 21:30:14 +02:00
}