analyseWriter/src/MEPTL/commandes.java

738 lines
43 KiB
Java

package MEPTL;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import cXML.*;
import cXML.Run.UserStatus;
/**
*
* @author pablo rodriguez
*
*/
public class commandes {
//** Application console par défaut.
//** Si la valeur ets false alors c'est une application avec inteface graphique.
public static boolean console = true;
//** Le node du fichier d'analyse
public static node sujet = new node();
//***************************************************
//** Les commandes par défaut à travers la console **
//***************************************************
public static String nameSujet = ""; //sujet par défaut
public static boolean analyse = false; //analyse des fichiers étudiants
public static boolean ecritCode = false; // -write : ecriture du code du sujet
public static boolean ecritSujet = false; // -sujet : ecriture 2 du code du sujet, uniquement les nodes évalués
public static boolean ecritNodeAnalyse = false;
public static boolean ecritNoteCSV = false; // ecriture note.csv
public static boolean writefiles = false; // -writefiles permet d'écrire tous les fichiers XML après la lecture en node
public static boolean calculLeHashDuFichier = false; // -hash retourne le hash du fichier d'analyse
public static boolean sansFeeback = false; // pas de feedback étudiant
public static boolean verifHisto = false; // vérification des historiques correspond à la commande -verif
public static boolean verifHisto2 = false; // vérification des historiques lorsqu'il y a aussi analyse
public static boolean fourniCSV = false; // fourni le fichier CSV contenant la liste des étudiants
public static boolean badCommand = false ; //erreur dans les commandes
public static boolean noNote =false; // pas de note dans les feedbacks
public static boolean noLogo =false; // pas de logo dans les feedbacks
public static boolean newLogo=false; // un nouveau logo dans le feedback
public static boolean licence = false; // affiche la licence
public static boolean zipfeedback = false; // Les feedback dans une archive ZIP
public static boolean fichierStudentMoodle = false; // Les fichiers étudiants sont directement dans le dossier courant de l'application.
public static cXML.Run.UserStatus Profil = cXML.Run.UserStatus.TEACHER ; //Le profil TEACHER permet de lire dans les dossiers contenus dans le répertoire courant de l'application. Le profil STUDENT permet de lire au niveau du répertoire courant de l'application.
public static boolean fourniDossierDestination = false; //répertoire de destination des feedbacks et CSV;
public static String nameCSV = ""; //le nom du fichier contenant la liste des étudiants
public static String nameSVG =""; //le nom du nouveau logo
public static String contenuFichierSVG =""; // Le nouveau logo
public static String path ="";
public static String pathDestination =""; //Pour le mode console uniquement
public static String version ="3.6.1"; // La version actuelle
public static String Command =""; //récupère le texte de la commande dans la console
//** setting valeur par défaut
public static String culture = "FR";
public static int tolerance_characters = 5;
public static double tolerance_text = 0.79;
public static int number_match = 2;
public static int mini_number_modification = 0;
public static int nombres_modifications_simultané_maxi = 100;
public static int tolerance_rouge = 30;
public static int tolerance_vert = 30;
public static int tolerance_bleu = 30;
//** Variables de mise à jour du fichier d'analyse
public static boolean MAJnameAnalysisFile =false;
public static boolean MAJFichierAnalyse = false;
public static String hash ="0";
//** Variables du fichier d'analyse
public static String analyse_culture = "FR";
public static String analyse_metaSujet="";
public static String analyse_auteur="";
public static String analyse_Initial_Creator="";
public static String analyse_version="";
public static String analyse_creationDate="";
public static String analyse_titre="";
public static String analyse_link_sujet="";
public static String analyse_link_help="";
public static String analyse_date="";
public static boolean analyse_historiquePresent=false;
public static boolean analyse_presenceMetaSujet=false;
public static boolean analyse_controleDateCreation=false;
public static boolean analyse_controle_Initial_Creator=false;
public static boolean analyse_baremeABC=false;
public static double analyse_progression=1;
public static double analyse_notefrom=20;
public static int analyse_tolerance_characters = 5;
public static double analyse_tolerance_text = 0.79;
public static int analyse_number_match = 2;
public static int analyse_mini_number_modification = 0;
public static int analyse_nombres_modifications_simultané_maxi = 100;
public static int analyse_tolerance_rouge = 30;
public static int analyse_tolerance_vert = 30;
public static int analyse_tolerance_bleu = 30;
public static long analyse_size = 48000000;
public static String analyse_nameZip = "feedbackMoodle";
public static String analyse_hash = "";
public static String analysis_filename = "";
//** Variables pour l'interface du logiciel
public static String Titre = "analyseWriter";
public static String filename="";
public static boolean fichierAnalyseValide = false; //mise à jour de la valeur dans MEPTL.verificationFichierAnalyse
public static String Annee ="2022";
public static int analyse_Nbre_Fichier_Student = 0;
public static int analyse_index_Fichier_Student = 0;
public static StringBuilder message = new StringBuilder();
/**
*
* @param args : table des arguments
* @param patch : chemin vers le répertoire courant de l'application
* @throws IOException
* @throws InterruptedException
*/
public commandes(String[] args, String path) throws IOException, InterruptedException {
commandes.path = path;
for(int i = 0 ; i < args.length ; i++) {
Command = Command + " " +args[i];
}
try {
if(args.length==0) {badCommand=true; System.out.println("Il doit y avoir une commande.");System.out.println("Vous pouvez saisir les commandes -aide ou -help pour obtenir la liste des commandes.");}
for(int i = 0 ; i < args.length ; i++) {
if(args[i].equals("-use")) if((i+1)<args.length) { if(!args[i+1].contains(".xml")) {badCommand=true; System.out.println("La commande -use doit être suivi du nom du fichier.");}}else {badCommand=true; System.out.println("La commande -use doit être suivi du nom du fichier.");}
if(args[i].contains(".xml")) {
Matcher m = Pattern.compile("{1,}.xml$").matcher(args[i]);
if(m.find()) {nameSujet = args[i];}else {badCommand=true;System.out.println("Il y a un problème avec l'extension du fichier d'analyse.\nL'extension doit être \".xml\".");};
if(i-1>=0){
if(args[i-1].equals("-use")) analyse=true;
if(args[i-1].equals("-hash")) calculLeHashDuFichier=true;
if(args[i-1].equals("-a")) ecritNodeAnalyse=true;
if(!analyse&&!calculLeHashDuFichier&&!ecritNodeAnalyse) {
badCommand=true;
System.out.println("Les commandes -use ou -hash ou -a doit être suivi du nom du fichier d'analyse.");
}
}
}
if(args[i].contains(".csv")) {
Matcher m = Pattern.compile("{1,}.csv$").matcher(args[i]);
if(m.find()) {fourniCSV=true; nameCSV = args[i];}else {badCommand=true;System.out.println("Il y a un problème avec l'extension du fichier CSV.\nL'extension doit être \".csv\".");}
if(!args[i-1].equals("-csv") && !args[i-1].equals("-verifcsv")) {badCommand=true; System.out.println("Les commandes -csv ou -verifcsv doivent être suivies par le fichier CSV contenant les identifiants des étudiants.");}
}
if(args[i].equals("-csv")) {
if(!analyse) {badCommand=true;System.out.println("Vous devez saisir la commande -use suivi du nom du fichier d'analyse et après la commande -csv.");}
ecritNoteCSV=true;
}
if(args[i].contains(".svg")) {
Matcher m = Pattern.compile("{1,}.svg$").matcher(args[i]);
if(m.find()) {newLogo=true; nameSVG = args[i];}else {badCommand=true;System.out.println("Il y a un problème avec l'extension du fichier SVG.\nL'extension doit être \".svg\".");}
if(!args[i-1].equals("-newLogo")) {badCommand=true; System.out.println("La commande -newLogo doit être suivi du nom du fichier SVG.");}
}
if(args[i].equals("-newLogo")) {
if(!analyse) {badCommand=true;System.out.println("Vous devez saisir la commade -use puis le nom du fichier d'analyse et après la commande -newLogo.");}
if(noLogo) {badCommand=true;System.out.println("la commande -newLogo et -nologo ne peuvent pas être executées ensemble.");}
newLogo=true;
}
if(args[i].equals("-verifcsv")) {
if(verifHisto) {badCommand=true;System.out.println("Les commandes -verifcsv et -verif ne peuvent pas être executées ensemble.");}
ecritNoteCSV=true;
verifHisto=false;
verifHisto2=true;
if(!analyse) {badCommand=true;System.out.println("Vous devez saisir la commade -use puis le nom du fichier d'analyse et après la commande -verifcsv.");}
}
if(args[i].equals("-nofeedback")) {
if(zipfeedback) {badCommand=true;System.out.println("Ce n'est pas possible d'executer les commandes -nofeedback et -zipfeedback en même temps.");}
sansFeeback=true;
}
if(args[i].equals("-verif")) {
if(verifHisto2) {badCommand=true;System.out.println("Les commandes -verifcsv et -verif ne peuvent pas être executées ensemble.");}
verifHisto=true;
verifHisto2=false;
}
if(args[i].equals("-help")) {
if(args.length>1) {System.out.println("\n\n***\nLa commande -help doit être la seule commande.\n***");clotureWithError();}
helpEN();
clotureWithHelp();
}
if(args[i].equals("-aide")) {
if(args.length>1) {System.out.println("\n\n***\nLa commande -aide doit être la seule commande.\n***");clotureWithError();}
helpFR();
clotureWithHelp();
}
if(args[i].equals("-licence")) {
if(args.length>1) {System.out.println("\n\n***\nla commande -licence doite être la seule commande..\n***");clotureWithError();}
licence();
}
if(args[i].equals("-write")) {
if(args.length>1) {System.out.println("\n\n***\nLa commande -write doit être la seule commande.\n***");clotureWithError();}
ecritCode=true;
Profil = UserStatus.STUDENT;
}
if(args[i].equals("-writefiles")) {
if(!(args.length==1 && Command.contains("-writefiles") || args.length==2 && Command.contains("-writefiles")&&Command.contains("-f")) ) {System.out.println("\n\n***\nLa commande -writefiles doit être la seule commande.\nElle peut être suivi de la commande -f uniquement.\n***");clotureWithError();}
writefiles=true;
}
if(args[i].equals("-hash")) {
if(args.length>2) {System.out.println("\n\n***\nLa commande -hash suivi du nom du fichier d'analyse doit être la seule commande.\n***");clotureWithError();}
calculLeHashDuFichier=true;
}
if(args[i].equals("-a")) {
if(args.length>=3 && !Command.contains("-f")) {System.out.println("\n\n***\nLa commande -a suivi du nom du fichier d'analyse doit être la seule commande, à l'exception de la commande -f.\n***");clotureWithError();}
ecritNodeAnalyse=true;
}
if(args[i].equals("-sujet")) {
if(!(analyse&&args.length==3&&Command.contains("-use"))) {badCommand=true; System.out.println("Vous devez saisir la commande -use suivi du fichier d'analyse et après vous pouvez saisir la commande -sujet.");}
ecritSujet=true;
}
if(args[i].equals("-nologo")) {
if(!analyse) {badCommand=true;System.out.println("Vous devez saisir la commande -use suivi du fichier d'analyse et après vous pouvez saisir la commande -nologo.");}
if(newLogo) {badCommand=true;System.out.println("Les commandes -newlogo et -nologo ne peuvent pas être executées en même temps.");}
noLogo=true;
}
if(args[i].equals("-about")) {
if(args.length>1) {System.out.println("\n\n***\nLa commande -about doit être la seule commande.\n***");clotureWithError();}
about();
clotureApplication();
}
if(args[i].equals("-nonote")) {
noNote=true;
}
if(args[i].equals("-zipfeedback")) {
if(!analyse) {badCommand=true;System.out.println("Vous devez saisir la commande -use suivi du fichier d'analyse et après vous pouvez saisir la commande -zipfeedback.");}
if(sansFeeback) {badCommand=true;System.out.println("Ce n'est pas possible d'executer les commandes -nofeedback et -zipfeedback en même temps.");}
zipfeedback=true;
}
if(args[i].equals("-f")) {
if(Command.contains(" -d ")) {badCommand=true;System.out.println("Les commandes -f et -d ne peuvent pas être executées ensemble.");}
fichierStudentMoodle=true;
}
if(args[i].equals("-dest")) if((i+1)<args.length) {
Matcher m = Pattern.compile("^\\./.{1,}/$").matcher(args[i+1]);
if(m.find()) {
fourniDossierDestination=true;
pathDestination = args[i+1].substring(2, args[i+1].length()-1);
pathDestination = pathDestination.replace("\\","/");
File file = new File(path+"/"+ pathDestination);
if (!file.exists()) {
if (file.mkdir()) {
System.out.println("Le dossier \"" + pathDestination + "\" a été créé.");
} else {
System.out.println("Impossible de créer le dossier " + pathDestination);
}
}else {
System.out.println("Le dossier \"" + pathDestination + "\" n'a pas été créé.");
}
}else {
System.out.println(args[i+1]);
System.out.println("Après la commande -dest, il doit y avoir le chemin de destination vers le dossier.\nLe chemin de destination n'est pas correct.");
badCommand =true;
}
}
Matcher m = Pattern.compile("^\\./.{1,}/$").matcher(args[i]);
if(!args[i].equals("-use")&&!args[i].equals("-write")&&!args[i].equals("-csv")&&!args[i].equals("-verif")&&!args[i].equals("-verifcsv")
&&!args[i].contains(".csv")&&!args[i].contains(".svg")&&!args[i].contains(".xml")&&!args[i].contains("-nofeedback")&&!args[i].contains("-help")&&!args[i].equals("-aide")
&&!args[i].equals("-about")&&!args[i].equals("-nonote") &&!args[i].equals("-dest")&&!args[i].equals("-sujet")&&!args[i].equals("-nologo")
&&!args[i].equals("-licence")&&!args[i].equals("-zipfeedback")&&!args[i].equals("-newLogo")&&!args[i].equals("-f")&&!m.find()&&!args[i].equals("-writefiles")
&&!args[i].equals("-hash")&&!m.find() &&!args[i].equals("-a")&&!m.find()) {
badCommand=true; System.out.println("La commande " + args[i] + " est inconnu.");System.out.println("Vous pouvez taper \"java -jar analyseWriter.jar -aide\" pour obtenir la liste des commandes.");
}
}
}catch (ArrayIndexOutOfBoundsException e){
System.out.println("Error...bad argument.");
clotureWithError();
System.exit(0);
}
if(badCommand) clotureWithError();
//affichage dans la console des commandes passées
CLS();
System.out.println();
System.out.println("---------------------------------------------------");
System.out.println("AnalyseWriter Version : " + version );
System.out.println();
System.out.println("Analysis of student files = " + analyse);
System.out.println("The name of the analysis file is = " + nameSujet);
System.out.println("Student's file in the current directory = " + fichierStudentMoodle);
System.out.println("Zip feedback = " + zipfeedback);
System.out.println("No feedback = " + sansFeeback);
System.out.println("No logo = " + noLogo);
System.out.println("New logo = " + newLogo);
System.out.println("Name of the SVG file = " + nameSVG);
System.out.println("No student grade = " + noNote);
System.out.println("Writing an analysis file = "+ ecritCode);
System.out.println("Write the subject file \"sujet.xml\" = "+ ecritSujet);
System.out.println("Write all student's files to XML = "+ writefiles);
System.out.println("Hash = "+ calculLeHashDuFichier);
System.out.println("Check historics (-verif) = " + verifHisto);
System.out.println("Check historics and write CSV file (-verifcsv) = " + verifHisto2);
System.out.println("Export in CSV format = " + ecritNoteCSV);
System.out.println("File containing the student identifiers provided = " + fourniCSV);
System.out.println("Name of the CSV file containing the student identifiers = " + nameCSV);
System.out.println("Provides a destination directory = " + fourniDossierDestination);
System.out.println("Destination directory = " + pathDestination);
System.out.println();
System.out.println("Command(s) = " + Command);
System.out.println();
System.out.println("Current directory = " + path);
System.out.println("---------------------------------------------------");
System.out.println();
}
/**
* Message dans la console
* @throws IOException
* @throws InterruptedException
*/
private static void helpFR() throws InterruptedException, IOException {
CLS();
System.out.println();
System.out.println("***************************************");
System.out.println("* LISTE DES COMMANDES D'ANALYSEWRITER * ");
System.out.println("***************************************");
System.out.println();
System.out.println("List of analiseWriter commands (only in french), soon in english.");
System.out.println();
System.out.println(" -use : \t Permet d'indiquer le fichier d'analyse.");
System.out.println(" : \t Le fichier d'analyse (format XML) doit être placé juste après la commande.");
System.out.println(" : \t Les fichiers des étudiants doivent être dans des dossiers nominatifs (exporter depuis moodle).");
System.out.println(" : \t Les fichiers des étudiants doivent être au format ODF avec l'extension .odt.");
System.out.println();
System.out.println(" file.xml : \t Le fichier d'analyse au format XML.");
System.out.println(" : \t file.xml doit être placé juste après la commande -use.");
System.out.println(" : \t Le fchier file.xml doit se trouver dans le dossier courant*.");
System.out.println(" : \t Ce fichier doit être obtenu avec la commande -write.");
System.out.println(" : \t Ce fichier doit être manuellement modifié pour l'adapter à votre analyse.");
System.out.println();
System.out.println(" -f : \t Permet d'indiquer que tous les fichiers des étudiants");
System.out.println(" : \t sont directement dans le dossier courant de l'application.");
System.out.println(" : \t Par défaut les fichiers des étudiants sont dans des dossiers nominatifs.");
System.out.println(" : \t Les fichiers des étudiants doivent être au format ODF avec l'extension .odt.");
System.out.println();
System.out.println(" -verif : \t Permet de comparer toutes les modifications entre les historiques du suivi de modification.");
System.out.println(" : \t Si c'est la seule commande alors il n'y a pas d'analyse, pas de note, pas de feedback.");
System.out.println(" : \t Cette commande ne dépend pas d'un fichier d'analyse (indépendant des sujets).");
System.out.println(" : \t Vous pouvez analyser les historiques même si vous n'avez pas de fichier d'analyse.");
System.out.println(" : \t Dans le dossier courant*, vous trouverez le fichier Verif.xml.");
System.out.println();
System.out.println(" -cvs : \t Permet d'importer toutes les notes dans un fichier au format CSV (séparateur le point virgule).");
System.out.println(" : \t La commande -use file.xml doit être placé avant la commande -csv.");
System.out.println(" : \t Le fichier généré se trouve dans le dossier courant*.");
System.out.println(" : \t Cette commande doit être suivi d'un fichier au format CSV contenant la liste des étudiants.");
System.out.println(" : \t Si cette commande est suivi du fichier file.csv alors récupère les identifiants des étudiants.");
System.out.println();
System.out.println(" -verifcvs : \t Permet de comparer toutes les modifications entre les historiques du suivi de modification.");
System.out.println(" : \t Permet d'importer toutes les notes dans un fichier au format CSV (séparateur le point virgule).");
System.out.println(" : \t La commande -use file.xml doit être placé avant la commande -verifcsv.");
System.out.println(" : \t Dans le dossier courant, vous trouverez le fichier Verif.xml.");
System.out.println(" : \t La commande -verifcsv peut être suivi d'un fichier au format CSV contenant la liste des étudiants.");
System.out.println(" : \t Si cette commande est suivi du fichier file.csv alors récupère les identifiants des étudiants.");
System.out.println();
System.out.println(" file.csv : \t Le fichier contenant la liste des étudiants au format CSV.");
System.out.println(" : \t Le fichier file.csv doit être placé juste après la commande -csv ou -verifcsv.");
System.out.println(" : \t Le fichier file.csv doit se trouver dans le dossier courant*.");
System.out.println(" : \t Le séparateur dans le fichier CSV doit être le point virgule.");
System.out.println(" : \t Dans ce fichier, il doit y avoir les colonnes \"prenom\", \"nom\",\"identification\" et \"adresse\".");
System.out.println(" : \t Vous pouvez modifier les noms des colonnes dans les settings du fichier d'analyse.");
System.out.println(" : \t Vous exportez ce fichier depuis le serveur Moodle (carnet de note, exporter).");
System.out.println();
System.out.println(" -write : \t Permet d'écrire un fichier d'analyse.");
System.out.println(" : \t Le fichier généré se trouve dans le dossier courant*.");
System.out.println(" : \t Le fichier généré est au format XML.");
System.out.println(" : \t Vous devez l'adapter en modifiant le code XML pour réaliser vos propres analyses.");
System.out.println();
System.out.println(" -writefiles : \t Permet d'écrire tous les fichiers en XML.");
System.out.println(" : \t Les fichiers générés se trouvent dans le dossier courant*.");
System.out.println(" : \t Les fichiers générés sont au format XML.");
System.out.println();
System.out.println(" -zipfeedback : \t Permet de générer une archive ZIP contenant les feedbacks des étudiant.");
System.out.println(" : \t L'archive se nomme moodleFeedback.zip.");
System.out.println(" : \t L'archive respecte le format pour l'importation des feedbacks dans Moodle.");
System.out.println();
System.out.println(" -newLogo : \t Permet l'affichage dans les feedbacks d'un nouveau logo autre que celui de l'université de l'Artois.");
System.out.println(" : \t Cette commande doit être suivi d'un fichier au format SVG.");
System.out.println();
System.out.println(" file.svg : \t Le fichier au format SVG du nouveau logo.");
System.out.println(" : \t Le fichier file.svg doit être placé juste après la commande -newLogo.");
System.out.println(" : \t Le fichier file.svg doit se trouver dans le dossier courant*.");
System.out.println();
System.out.println(" -nofeedback : \t Permet de ne pas générer les feedbacks pour les étudiants.");
System.out.println(" : \t Les feedbacks sont des fichiers au format HTML.");
System.out.println(" : \t Les feedbacks se trouvent dans le dossier courant*.");
System.out.println();
System.out.println(" -nonote : \t Evite l'affichage dans les feedbacks de la note.");
System.out.println(" : \t Evite de placer la note dans le nom du fichier.");
System.out.println();
System.out.println(" -noLogo : \t Evite l'affichage dans les feedbacks du logo de l'université de l'Artois.");
System.out.println();
System.out.println(" -dest : \t Indique le répertoire de destination des feedbacks et des fichiers XML et CSV.");
System.out.println(" : \t Exemple : -dest \"./sortie/\" dossier de destination le répertoire \"sortie\".");
System.out.println(" : \t Le répertoire de destination se trouve obligatoirement dans le dossier courant de l'application.");
System.out.println(" : \t Il ne peut y avoir qu'un seul répertoire (pas de sous répertoire).");
System.out.println(" : \t Le chemin commence obligatoirement par \"./\".");
System.out.println(" : \t Si le nom du dossier contient le symbole $ alors il est ignoré par l'analyse.");
System.out.println();
System.out.println(" -sujet : \t Permet de récupérer le fichier d'analyse contenant uniquement les nodes évalués.");
System.out.println(" : \t C'est à partir du fichier d'analyse \"file.xml\" qu'est généré le fichier \"sujet.xml\".");
System.out.println(" : \t Le fichier \"sujet.xml\" se trouve dans le dossier courant de l'application.");
System.out.println();
System.out.println(" -hash : \t Permet calculer le hash d'un fichier.");
System.out.println(" : \t Permet de vérifier qu'un fichier d'analyse n'a pas été mofidié.");
System.out.println();
System.out.println(" -about : \t Affiche la version, l'auteur et la licence.");
System.out.println();
System.out.println(" -licence : \t Affiche le texte de la licence de l'application.");
System.out.println();
System.out.println(" -help : \t Affiche l'aide de l'application en Anglais.");
System.out.println();
System.out.println();
System.out.println("---");
System.out.println("* Le dossier courant est le dossier dans lequel se trouve l'application \"analyseWriter.jar\".\n"
+"Dossier courant -> " + path);
System.out.println();
System.out.println("P. Rodriguez");
}
/**
* Message dans la console
* @throws IOException
* @throws InterruptedException
*/
private static void helpEN() throws InterruptedException, IOException {
CLS();
System.out.println();
System.out.println("**************************************");
System.out.println("* LIST OF ANALYSEWRITER COMMANDS * ");
System.out.println("**************************************");
System.out.println();
System.out.println(" -use : \t Used to indicate the analysis file.");
System.out.println(" : \t The analysis file (XML format) must be placed just after the command.");
System.out.println(" : \t Student files must be in named folders (export from moodle).");
System.out.println(" : \t Student files must be in ODF format with the extension .odt.");
System.out.println();
System.out.println(" file.xml : \t The analysis file in XML format.");
System.out.println(" : \t file.xml must be placed just after the -use command.");
System.out.println(" : \t The file.xml file must be located in the current folder*.");
System.out.println(" : \t This file must be obtained with the -write command.");
System.out.println(" : \t This file must be manually modified to adapt it to your analysis.");
System.out.println();
System.out.println(" -f : \t Indicates that all student files are directly in the current folder.");
System.out.println(" : \t By default student files are in named folders.");
System.out.println(" : \t Student files must be in ODF format with the extension .odt.");
System.out.println();
System.out.println(" -verif : \t Allows you to compare all the modifications between the modification track logs.");
System.out.println(" : \t If this is the only command then there is no analysis, no rating, no feedback.");
System.out.println(" : \t This command does not depend on an analysis file (independent of subjects).");
System.out.println(" : \t You can analyze the logs even if you do not have an analysis file.");
System.out.println(" : \t In the current folder*, you will find the \"Verif.xml\" file.");
System.out.println();
System.out.println(" -cvs : \t Allows to import all the notes in a file in CSV format (separator the semicolon).");
System.out.println(" : \t The -use file.xml command must be placed before the -csv command.");
System.out.println(" : \t The generated file is located in the current folder*.");
System.out.println(" : \t This command can be followed by a file in CSV format containing the list of students.");
System.out.println(" : \t If this command is followed by the \"file.csv\" file then retrieves the student IDs.");
System.out.println();
System.out.println(" -verifcvs : \t Allows you to compare all the modifications between the modification track logs.");
System.out.println(" : \t Allows to import all the notes in a file in CSV format (separator the semicolon).");
System.out.println(" : \t The -use file.xml command must be placed before the -verifcsv command.");
System.out.println(" : \t In the current folder, you will find the \"Verif.xml\" file.");
System.out.println(" : \t The -verifcsv command can be followed by a file in CSV format containing the list of students.");
System.out.println(" : \t If this command is followed by the \"file.csv\" file then retrieves the student IDs.");
System.out.println();
System.out.println(" file.csv : \t The file containing the list of students in CSV format.");
System.out.println(" : \t The \"file.csv\" file must be placed just after the -csv or -verifcsv command.");
System.out.println(" : \t The \"file.csv\" file must be in the current folder*.");
System.out.println(" : \t The default separator in the CSV file is the semicolon.");
System.out.println(" : \t In this file, there must be the columns \"First name\", \"Last name\", \"Identification number\"and \"Email\".");
System.out.println(" : \t You are exporting this file from the Moodle server (gradebook, exporter).");
System.out.println();
System.out.println(" -write : \t Allows you to write an analysis file.");
System.out.println(" : \t The generated file is located in the current folder*.");
System.out.println(" : \t The generated file is in XML format.");
System.out.println(" : \t You must adapt it by modifying the XML code to perform your own analyzes.");
System.out.println();
System.out.println(" -writefiles : \t Allows you to write all files in XML.");
System.out.println(" : \t The generated files are located in the current folder*.");
System.out.println(" : \t The generated files are in XML format.");
System.out.println();
System.out.println(" -zipfeedback : \t Allows you to generate a ZIP archive containing student feedback. ");
System.out.println(" : \t The archive is named \"moodleFeedback.zip\".");
System.out.println(" : \t The archive respects the format for importing feedback into Moodle.");
System.out.println();
System.out.println(" -nofeedback : \t If TRUE allows you to not generate feedback for the students..");
System.out.println(" : \t Feedbacks are files in HTML format..");
System.out.println(" : \t Feedbacks can be found in the current folder*.");
System.out.println();
System.out.println(" -nonote : \t Avoid display in the feedbacks of the grade.");
System.out.println(" : \t Avoid placing the student's grade in the file name.");
System.out.println();
System.out.println(" -dest : \t Specifies the destination directory for feedbacks and XML and CSV files.");
System.out.println(" : \t Example: -dest \"./output/\" destination folder the \"output\" directory.");
System.out.println(" : \t The destination directory must be in the current directory of the application.");
System.out.println(" : \t There can only be one directory (no subdirectory). ");
System.out.println(" : \t The path must begin with \"./\".");
System.out.println(" : \t If the folder name contains the $ symbol, it is ignored by the scan. ");
System.out.println();
System.out.println(" -sujet : \t Used to retrieve the scan file containing only the evaluated nodes. ");
System.out.println(" : \t The \"sujet.xml\" file is generated from the \"file.xml\" analysis file. ");
System.out.println(" : \t The \"subject.xml\" file is located in the current application folder. ");
System.out.println();
System.out.println(" -hash : \t Allows you to calculate the hash of a file.");
System.out.println(" : \t Allows you to verify that an analysis file has not been mofidized.");
System.out.println();
System.out.println(" -about : \t Displays the version, author and license. ");
System.out.println();
System.out.println(" -licence : \t Displays the text of the application license. ");
System.out.println();
System.out.println(" -aide : \t Display application help in French.");
System.out.println();
System.out.println();
System.out.println("---");
System.out.println("* The current folder is the folder in which the application is located \"analyseWriter.jar\".\n"
+"Dossier courant -> " + path);
System.out.println();
System.out.println("P. Rodriguez");
}
/**
* Message dans la console
* @throws IOException
* @throws InterruptedException
*/
private static void about() throws InterruptedException, IOException {
CLS();
int nbespace = 58-version.length();
if (nbespace<0) nbespace=1;
System.out.println();
System.out.println("\t\t┌─────────────────────────────────────────────────────────────────────┐");
System.out.println("\t\t│ ANALYSEWRITER (Origin ) │");
System.out.println("\t\t│ Version : " + version+ new String(new char[nbespace]).replace("\0", " ") +"" );
System.out.println("\t\t│ │");
System.out.println("\t\t│ Mise à jour : https://github.com/1-pablo-rodriguez/analyseWriter │");
System.out.println("\t\t│ Mise à jour : https://forge.chapril.org/pablo/analyseWriter/releases│");
System.out.println("\t\t│ │");
System.out.println("\t\t│ Développeur : pablo Rodriguez │");
System.out.println("\t\t│ │");
System.out.println("\t\t│ LICENCE GNU GENERAL PUBLIC LICENSE │");
System.out.println("\t\t│ Version 3, 29 June 2007 │");
System.out.println("\t\t└─────────────────────────────────────────────────────────────────────┘");
System.out.println();
}
/**
* Licence de l'application
* @throws IOException
*/
private static void licence() throws IOException {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream is = classLoader.getResourceAsStream("licence.txt");
Reader initialReader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
char[] arr = new char[8 * 1024];
StringBuilder buffer = new StringBuilder();
int numCharsRead;
while ((numCharsRead = initialReader.read(arr, 0, arr.length)) != -1) {
buffer.append(arr, 0, numCharsRead);
}
initialReader.close();
System.out.println(buffer.toString());
System.out.println();
System.out.println("\t\t┌─────────────────────────────────────────────┐");
System.out.println("\t\t│ Au-dessus, vous avez la licence. │");
System.out.println("\t\t│ │");
System.out.println("\t\t│ (')_(') │");
System.out.println("\t\t│ ( `.° ) │");
System.out.println("\t\t│ (\")__(\") .. à bientôt, analyseWriter. │");
System.out.println("\t\t└─────────────────────────────────────────────┘");
System.out.println();
System.exit(0);
}
/**
* Clôture avec une erreur de commande
*/
public static void clotureWithError() {
System.out.println();
System.out.println("\t\t┌─────────────────────────────────────────────┐");
System.out.println("\t\t│ Vous avez commis une erreur dans votre │");
System.out.println("\t\t│ commande. │");
System.out.println("\t\t│ │");
System.out.println("\t\t│ Lisez les informations ci-dessus et │");
System.out.println("\t\t│ recommencez. │");
System.out.println("\t\t│ │");
System.out.println("\t\t│ (')_(') │");
System.out.println("\t\t│ ( `.° ) │");
System.out.println("\t\t│ (\")__(\") .. à bientôt, analyseWriter. │");
System.out.println("\t\t└─────────────────────────────────────────────┘");
System.out.println();
System.exit(0);
}
/**
* Bye Bye the application
*/
public static void clotureApplication() {
System.out.println();
System.out.println("\t\t┌────────────────────────────────────────────────────┐");
System.out.println("\t\t│ (')_(') │");
System.out.println("\t\t│ ( `.° ) Bravo, vous avez travaillé très dur! │");
System.out.println("\t\t│ (\")__(\") ... Bye Bye analyseWriter. │");
System.out.println("\t\t└────────────────────────────────────────────────────┘");
System.out.println();
System.exit(0);
}
/**
*
*/
public static void clotureApplicationAvecErreur() {
System.out.println();
System.out.println("\t\t┌────────────────────────────────────────────────────┐");
System.out.println("\t\t│ (')_(') │");
System.out.println("\t\t│ ( ;.; ) Une erreur c'est produite. │");
System.out.println("\t\t│ (\")__(\") ... Bye Bye analyseWriter. │");
System.out.println("\t\t└────────────────────────────────────────────────────┘");
System.out.println();
System.exit(0);
}
public static void clotureWithHelp() {
System.out.println();
System.out.println("\t\t┌─────────────────────────────────────────────────────┐");
System.out.println("\t\t│ Au-dessus, vous avez la liste des commandes. │");
System.out.println("\t\t│ Mais vous avez aussi la documentation sur le │");
System.out.println("\t\t│ le serveur de github ou chapril. │");
System.out.println("\t\t│ │");
System.out.println("\t\t│ (')_(') │");
System.out.println("\t\t│ ( `.° ) │");
System.out.println("\t\t│ (\")__(\") .. à bientôt, analyseWriter. │");
System.out.println("\t\t└─────────────────────────────────────────────────────┘");
System.out.println();
System.exit(0);
System.exit(0);
}
public static void clotureWithErrorFile(String filename) {
int nbespace = 30-filename.length();
if (nbespace<0) nbespace=1;
System.out.println();
System.out.println("\t\t┌───────────────────────────────────────────────────────────┐");
System.out.println("\t\t│ Le fichier \""+ filename + "\" n'existe pas." + new String(new char[nbespace]).replace("\0", " ") +"" );
System.out.println("\t\t│ │");
System.out.println("\t\t│ (')_(') │");
System.out.println("\t\t│ ( `.° ) │");
System.out.println("\t\t│ (\")__(\") .. see you soon, analyseWriter. │");
System.out.println("\t\t└───────────────────────────────────────────────────────────┘");
System.out.println();
commandes.message.append("\n");
commandes.message.append("\n*************************");
commandes.message.append("\nERREUR Le fichier \""+ filename + "\" n'existe pas.");
commandes.message.append("\n*************************");
commandes.message.append("\n");
if(commandes.console) System.exit(0);
}
/**
* Nettoyage de la console.<br/>
* <br/>
* @throws InterruptedException
* @throws IOException
*/
public static void CLS() throws InterruptedException, IOException {
new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor();
}
}