MAJ V4.5.0

This commit is contained in:
pablo rodriguez 2024-04-24 15:02:03 +02:00
parent bb1491944a
commit dda9ef4191
4 changed files with 28117 additions and 150 deletions

File diff suppressed because one or more lines are too long

View File

@ -2017,16 +2017,26 @@ public class meptl {
public static StringBuilder afficheNodeCSV() {
StringBuilder sb = new StringBuilder();
if(commandes.fourniCSV) {
node import_csv = commandes.sujet.retourneFirstEnfantsByName("csv").retourneFirstEnfantsByName("import_moodle");
node filecsv = commandes.evaluationChargeEnMemoire.retourneFirstEnfantsByName("fileCSV");
String namelistStudent = "";
if(filecsv.getAttributs().get("nameListStudent")!=null) namelistStudent = filecsv.getAttributs().get("nameListStudent");
// Importation par défaut
node import_csv = commandes.sujet.retourneFirstEnfantsByName("import_moodle");
String nameid = import_csv.getAttributs().get("id");
String nameemail = import_csv.getAttributs().get("email");
String name = import_csv.getAttributs().get("name");
String firstname = import_csv.getAttributs().get("firstname");
if(filecsv.getAttributs().get("id")!=null) nameid = filecsv.getAttributs().get("id");
if(filecsv.getAttributs().get("email")!=null) nameemail = filecsv.getAttributs().get("email");
if(filecsv.getAttributs().get("name")!=null) name = filecsv.getAttributs().get("name");
if(filecsv.getAttributs().get("firstname")!=null) firstname = filecsv.getAttributs().get("firstname");
sb.append("<html>");
sb.append("<h3>Liste des étudiants</h3>");
sb.append("<p>Cette liste permettra de réaliser l'importation des notes dans le canet de note sur Moodle.</p>"
sb.append("<p>Nom de la liste : <b>" + namelistStudent + "</b></p>");
sb.append("<p>Cette liste permettra de réaliser l'importation des notes dans le carnet de note sur Moodle.</p>"
+ "<p>Vous pouvez réaliser un copié dans le tableau.</p><br>");
sb.append("<table>");
sb.append("<tr>");
@ -2046,9 +2056,9 @@ public class meptl {
}
sb.append("</table>");
sb.append("<br>");
sb.append("<p>Nom de la liste : <b>" + namelistStudent + "</b></p>");
sb.append("<p><b>Nombre d'étudiant dans la liste : " + commandes.nodeCSV.getNbrEnfants() + "</b></p>");
sb.append("</html>");
}
return sb;
}

View File

@ -0,0 +1,134 @@
package fenetres;
import java.awt.Color;
import java.awt.Font;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.filechooser.FileNameExtensionFilter;
import MEPTL.commandes;
import MEPTL.meptl;
import cXML.node;
public class CustomInputDialogListeEtudiant {
public static String showCustominputDialog() {
String separateur ="";
String encodage ="";
String email ="inconnu";
String name = "inconnu";
String firstname = "inconnu";
String id = "inconnu";
String nameListStudent = "";
if(commandes.fichierAnalyseValide) {
if(commandes.fourniCSV) {
node CSV = commandes.sujet.retourneFirstEnfantsByName("csv");
separateur = CSV.getAttributs().get("separator");
encodage = CSV.getAttributs().get("encoding");
node importCSV = CSV.retourneFirstEnfantsByName("import_moodle");
if(CSV.isHasAttributs()) {
if(importCSV.getAttributs().get("email")!=null) {
email = importCSV.getAttributs().get("email");
}
if(importCSV.getAttributs().get("name")!=null) {
name = importCSV.getAttributs().get("name");
}
if(importCSV.getAttributs().get("firstname")!=null) {
firstname = importCSV.getAttributs().get("firstname");
}
if(importCSV.getAttributs().get("id")!=null) {
id = importCSV.getAttributs().get("id");
}
}
}
if(commandes.evaluationChargeEnMemoire.retourneFirstEnfantsByName("fileCSV")!=null) {
if(commandes.evaluationChargeEnMemoire.retourneFirstEnfantsByName("fileCSV").getAttributs().get("nameListStudent")!=null) {
nameListStudent = commandes.evaluationChargeEnMemoire.retourneFirstEnfantsByName("fileCSV").getAttributs().get("nameListStudent");
}
}
}
JLabel lblTitre = new JLabel("<html><h2>Ajouter une liste d'étudiant à l'évaluation<h2></html>");
lblTitre.setForeground(new Color(50,50,200));
JLabel lblExpliaction = new JLabel("<html><p>Le fichier au format CSV pour importer une liste d'étudiant doit avoir<br>"
+ "les caractéristiques suivantes :</p><br>"
+ "<p>Séparateur : <b>" + separateur +"</b><br>"
+ "Encodage : <b>" + encodage + "</b><br>"
+ "Nom des étudiants, la colonne : <b>" + name + "</b><br>"
+ "Prénom des étudiants, la colonne : <b>" + firstname + "</b><br>"
+ "Numéro des étudiants, la colonne : <b>" + id +"</b><br>"
+ "Courriel des étudiants, la colonne : <b>" + email + "</b></p><br>"
+ "</html>");
lblExpliaction.setFont(new Font("Tahoma", Font.BOLD, 12));
lblExpliaction.setForeground(Color.blue);
JTextField textField = new JTextField(String.valueOf(nameListStudent));
textField.setFont(new Font("Tahoma", Font.BOLD, 14));
textField.setHorizontalAlignment(SwingConstants.LEFT);
ImageIcon icon = new ImageIcon(create.class.getResource("/resources/fichierCSV.png"));
Object[] message = {
lblTitre,
lblExpliaction,
"<html><p><b>Le nom d'une liste doit être unique.</b><br>"
+ "Dans le cas contraire la liste sera écrasée.</p><br>"
+ "<p>Quel doit être le nom de cette liste ?</p>",
textField
};
String[] options = {"Importer la liste", "Annuler"};
int optionSelected = JOptionPane.showOptionDialog(
null,
message,
"Importer une liste d'étudiant.",
JOptionPane.DEFAULT_OPTION,
JOptionPane.INFORMATION_MESSAGE,
icon,
options,
options[0]);
if (optionSelected == 0) { // Bouton "Valiser" sélectionné
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();
meptl.chargementFichierCSV();
commandes.nodeCSV.getAttributs().put("nameListStudent", nameListStudent);
commandes.nodeCSV.getAttributs().put("encoding", encodage);
commandes.nodeCSV.getAttributs().put("separator", separateur);
commandes.nodeCSV.getAttributs().put("name", name);
commandes.nodeCSV.getAttributs().put("firstname", firstname);
commandes.nodeCSV.getAttributs().put("email", email);
commandes.nodeCSV.getAttributs().put("id", id);
if(commandes.nodeCSV.getNbrEnfants()>=1) commandes.fourniCSV=true;
return nameListStudent;
}
return "Code_Annule";
} else if (optionSelected == 1) { // Bouton "Désactivé" sélectionné
return "Code_Annule";
} else { // Si la boîte de dialogue est annulée ou fermée
return "Code_Annule";
}
}
}

View File

@ -597,33 +597,23 @@ public class evaluate extends JFrame {
toolBar.addSeparator();
JButton btnInformationAnalyse = toolBar.add( actCodeFichierAnalyse );
btnInformationAnalyse.setVisible(false);
btnInformationAnalyse.setHideActionText(true);
btnInformationAnalyse.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierAnalyseInfo2.png")));
JButton btnAfficheCodeFichierAnalyse = toolBar.add( actAboutFichierAnalyse );
btnAfficheCodeFichierAnalyse.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
btnAfficheCodeFichierAnalyse.setHideActionText(true);
btnAfficheCodeFichierAnalyse.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierAnalyseInfo.png")));
toolBar.add(btnAfficheCodeFichierAnalyse);
JButton btnModifierFichierAnalyse = toolBar.add(actModifierFichierAnalyse);
btnModifierFichierAnalyse.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
btnModifierFichierAnalyse.setIcon(new ImageIcon(evaluate.class.getResource("/resources/versfichierAnalyse.png")));
btnModifierFichierAnalyse.setHideActionText(true);
toolBar.add(btnModifierFichierAnalyse);
JButton btnEvaluerLesFichiers = toolBar.add(actEvaluate);
btnEvaluerLesFichiers.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
btnEvaluerLesFichiers.setHideActionText(true);
toolBar.addSeparator();
@ -633,35 +623,26 @@ public class evaluate extends JFrame {
btnFichierCSV.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierCSV.png")));
toolBar.add(btnFichierCSV);
// Pour l'instant je cache ce bouton car il n'est pas utile.
JButton btnVerificationCSVavecFichierAnalyse = toolBar.add( actVerifCSV );
btnVerificationCSVavecFichierAnalyse.setVisible(false);
btnVerificationCSVavecFichierAnalyse.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierCSVInfoXML.png")));
btnVerificationCSVavecFichierAnalyse.setHideActionText(true);
toolBar.add(btnVerificationCSVavecFichierAnalyse);
JButton btnFichierCSV_delete = toolBar.add(actDeleteListeEtudiantCSV);
btnFichierCSV_delete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
btnFichierCSV_delete.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierCSV_delete.png")));
btnFichierCSV_delete.setHideActionText(true);
JButton btnInfoListeEtudiant = toolBar.add(actAfficheListeEtudiant);
btnInfoListeEtudiant.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
btnInfoListeEtudiant.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichierCSVInfo.png")));
btnInfoListeEtudiant.setHideActionText(true);
toolBar.add(btnInfoListeEtudiant);
JButton btnFichierCSV_modifier = toolBar.add(actModificationListeEtudiantCSV);
btnFichierCSV_modifier.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
btnFichierCSV_modifier.setIcon(new ImageIcon(evaluate.class.getResource("/resources/fichier_csv_studen_modif.png")));
btnFichierCSV_modifier.setHideActionText(true);
@ -841,75 +822,75 @@ public class evaluate extends JFrame {
};
/**
* Ouvre et affiche un fichier d'analyse au format XML.</br>
*/
@SuppressWarnings("unused")
private AbstractAction actOpen = new AbstractAction() {
private static final long serialVersionUID = 1L;
{
putValue(LARGE_ICON_KEY, new ImageIcon(evaluate.class.getResource("/resources/fichierAnalyse.png")));
putValue( Action.NAME, "Ouvrir un nouveau fichier d'analyse" );
putValue( Action.SMALL_ICON, new ImageIcon(create.class.getResource("/resources/fichierAnalysemini.png")) );
putValue( Action.MNEMONIC_KEY, KeyEvent.VK_O );
putValue( Action.SHORT_DESCRIPTION, "Ouvrir un nouveau fichier d'analyse (CTRL+O)" );
putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK) );
}
@Override
public void actionPerformed( ActionEvent e ) {
new ChargeFichierXML();
refreshLabel();
}
};
/**
* Ouvre et affiche un fichier d'analyse au format XML.</br>
*/
@SuppressWarnings("unused")
private AbstractAction actOpen = new AbstractAction() {
private static final long serialVersionUID = 1L;
{
putValue(LARGE_ICON_KEY, new ImageIcon(evaluate.class.getResource("/resources/fichierAnalyse.png")));
putValue( Action.NAME, "Ouvrir un nouveau fichier d'analyse" );
putValue( Action.SMALL_ICON, new ImageIcon(create.class.getResource("/resources/fichierAnalysemini.png")) );
putValue( Action.MNEMONIC_KEY, KeyEvent.VK_O );
putValue( Action.SHORT_DESCRIPTION, "Ouvrir un nouveau fichier d'analyse (CTRL+O)" );
putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK) );
}
@Override
public void actionPerformed( ActionEvent e ) {
new ChargeFichierXML();
refreshLabel();
}
};
/**
* Chargement d'un logo SVG.</br>
*/
private AbstractAction actChargeLogo = new AbstractAction() {
private static final long serialVersionUID = 1L;
{
putValue(Action.LARGE_ICON_KEY, new ImageIcon(evaluate.class.getResource("/resources/fichierSVG.png")));
putValue( Action.NAME, "Charge un logo SVG" );
putValue( Action.SMALL_ICON, new ImageIcon(evaluate.class.getResource("/resources/fichierSVGmini.png")));
putValue( Action.MNEMONIC_KEY, KeyEvent.VK_G );
putValue( Action.SHORT_DESCRIPTION, "Charge un logo SVG (CTRL+G)" );
putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_DOWN_MASK) );
}
@Override
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.setContentType("text/plain");
txtpnmessages.setText(commandes.contenuFichierSVG);
} else {
commandes.nameSVG = "";
commandes.contenuFichierSVG="";
System.out.println("No Selection ");
}
refreshLabel();
}
};
/**
* Chargement d'un logo SVG.</br>
*/
private AbstractAction actChargeLogo = new AbstractAction() {
private static final long serialVersionUID = 1L;
{
putValue(Action.LARGE_ICON_KEY, new ImageIcon(evaluate.class.getResource("/resources/fichierSVG.png")));
putValue( Action.NAME, "Charge un logo SVG" );
putValue( Action.SMALL_ICON, new ImageIcon(evaluate.class.getResource("/resources/fichierSVGmini.png")));
putValue( Action.MNEMONIC_KEY, KeyEvent.VK_G );
putValue( Action.SHORT_DESCRIPTION, "Charge un logo SVG (CTRL+G)" );
putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_DOWN_MASK) );
}
@Override
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.setContentType("text/plain");
txtpnmessages.setText(commandes.contenuFichierSVG);
} else {
commandes.nameSVG = "";
commandes.contenuFichierSVG="";
System.out.println("No Selection ");
}
refreshLabel();
}
};
/**
* Sélectionne le dossier courant contenant les fichiers des étudiants
*/
@ -1080,39 +1061,34 @@ private AbstractAction actOpen = new AbstractAction() {
};
/**
*
*/
@SuppressWarnings("unused")
private AbstractAction actSavePreference = new AbstractAction() {
private static final long serialVersionUID = 1L;
{
putValue( Action.NAME, "Enregistrer prefrences" );
putValue( Action.SMALL_ICON, new ImageIcon(create.class.getResource("/resources/savepreferencemini.png")) );
putValue( Action.LARGE_ICON_KEY, new ImageIcon(create.class.getResource("/resources/savepreference.png")) );
putValue( Action.MNEMONIC_KEY, KeyEvent.VK_W );
putValue( Action.SHORT_DESCRIPTION, "Enregistrer prefrences" );
putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.ALT_DOWN_MASK) );
}
@Override public void actionPerformed( ActionEvent e ) {
if(commandes.fichierAnalyseValide) {
}else {
JOptionPane.showMessageDialog(null, "Charger un fichier Writer (.odt) ou un fichier d'évaluaton (.xml).");
}
System.out.println( "Configuration" );
}
};
/**
*
*/
@SuppressWarnings("unused")
private AbstractAction actSavePreference = new AbstractAction() {
private static final long serialVersionUID = 1L;
{
putValue( Action.NAME, "Enregistrer prefrences" );
putValue( Action.SMALL_ICON, new ImageIcon(create.class.getResource("/resources/savepreferencemini.png")) );
putValue( Action.LARGE_ICON_KEY, new ImageIcon(create.class.getResource("/resources/savepreference.png")) );
putValue( Action.MNEMONIC_KEY, KeyEvent.VK_W );
putValue( Action.SHORT_DESCRIPTION, "Enregistrer prefrences" );
putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.ALT_DOWN_MASK) );
}
@Override public void actionPerformed( ActionEvent e ) {
if(commandes.fichierAnalyseValide) {
}else {
JOptionPane.showMessageDialog(null, "Charger un fichier Writer (.odt) ou un fichier d'évaluaton (.xml).");
}
System.out.println( "Configuration" );
}
};
/**
@ -1168,7 +1144,8 @@ private AbstractAction actOpen = new AbstractAction() {
/**
* Charge la liste des étudiants sous la forme d'un fichier XML.
* Charge la liste des étudiants à partir d'un fichier CSV<br>
* Et le converti sous la forme d'un node (pour fichier XML).
*/
private AbstractAction actChargeListeEtudiantCSV = new AbstractAction() {
@ -1184,35 +1161,21 @@ private AbstractAction actOpen = new AbstractAction() {
}
@Override 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();
int nbrStudent = 0;
int nbrStudent = 0;
if(commandes.nodeCSV==null) {
commandes.nodeCSV = new node("fileCSV");
nbrStudent=0;
}else {
if(commandes.nodeCSV.getNomElt()==null) commandes.nodeCSV.setNomElt("fileCSV");
if(commandes.nodeCSV.getNomElt().isBlank()) commandes.nodeCSV.setNomElt("fileCSV");
nbrStudent = commandes.nodeCSV.getNbrEnfants();
}
meptl.chargementFichierCSV();
if(commandes.nodeCSV.getNbrEnfants()>=1) {
commandes.fourniCSV=true;
}
// Chargement du fichier CSV
String nameListStudent = CustomInputDialogListeEtudiant.showCustominputDialog();
if(nameListStudent.equals("Code_Annule")) return;
if(commandes.nodeCSV.getNbrEnfants()==nbrStudent) {
txtpnmessages.setContentType("text/html");
@ -1228,7 +1191,7 @@ private AbstractAction actOpen = new AbstractAction() {
}
}
System.out.println( "Charge la liste des étudiants." );
}
if(commandes.fourniCSV) {
lblChargementFichierCSV.setBackground(new Color(40,180,40));