2022-06-14 20:09:16 +02:00
|
|
|
package calcul;
|
|
|
|
|
2022-06-14 21:24:10 +02:00
|
|
|
import java.util.ArrayList;
|
2022-06-14 20:09:16 +02:00
|
|
|
import java.util.Enumeration;
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
import javax.swing.JOptionPane;
|
|
|
|
|
2022-06-14 21:24:10 +02:00
|
|
|
import MEPTL.commandes;
|
2022-06-14 20:09:16 +02:00
|
|
|
import cXML.node;
|
|
|
|
|
|
|
|
public class calculNombrePointEvaluation {
|
|
|
|
|
2022-06-14 21:24:10 +02:00
|
|
|
/**
|
|
|
|
* Ensemble des points dans les différents node principaux.
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public static ArrayList<String> calculPointDansToutExercice(){
|
|
|
|
ArrayList<String> ListeNodeEvaluer = new ArrayList<String>();;
|
|
|
|
for(int i = 0 ; i < commandes.sujet.getNodes().size();i++) {
|
|
|
|
if(!commandes.sujet.getNodes().get(i).getNomElt().equals("setting")) {
|
|
|
|
ListeNodeEvaluer.add(commandes.sujet.getNodes().get(i).getNomElt() + " " +
|
|
|
|
String.valueOf(calculNombreDepoint(commandes.sujet.getNodes().get(i), 0)) + " " +
|
|
|
|
String.valueOf(commandes.sujet.getNodes().get(i).getAttributs().get("poids")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ListeNodeEvaluer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-14 20:09:16 +02:00
|
|
|
public static int calculNombreDepoint(node nod, int point) {
|
|
|
|
|
2022-12-02 10:17:36 +01:00
|
|
|
if(nod.getAttributs().get("evaluer")!=null) if(nod.getAttributs().get("evaluer").equals("true")){
|
|
|
|
|
2022-06-14 20:09:16 +02:00
|
|
|
if(nod.getAttributs().get("allContent")!=null) {
|
|
|
|
Pattern pt = Pattern.compile("[0-9]{1,}$");
|
|
|
|
Matcher match= pt.matcher(nod.getAttributs().get("allContent"));
|
|
|
|
if(match.find()) {
|
|
|
|
String s= match.group();
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(s);
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut allContent");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nod.getAttributs().get("evalNameInitialCreator")!=null) {
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(nod.getAttributs().get("evalNameInitialCreator"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut evalNameInitialCreator");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nod.getAttributs().get("evalNameCreator")!=null) {
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(nod.getAttributs().get("evalNameCreator"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut evalNameCreator");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nod.getAttributs().get("evalNameNode")!=null) {
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(nod.getAttributs().get("evalNameNode"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut evalNameCreator");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-02 10:17:36 +01:00
|
|
|
if(nod.getAttributs().get("evalNamePage")!=null) {
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(nod.getAttributs().get("evalNamePage"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut evalNamePage");
|
2022-12-01 15:44:22 +01:00
|
|
|
}
|
2022-12-02 10:17:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(nod.getAttributs().get("evalNumeroPage")!=null) {
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(nod.getAttributs().get("evalNumeroPage"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut evalNumeroPage");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nod.getAttributs().get("evalNumeroAbsoluePage")!=null) {
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(nod.getAttributs().get("evalNumeroAbsoluePage"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut evalNumeroAbsoluePage");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nod.getAttributs().get("evalEntetePasActive")!=null) {
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(nod.getAttributs().get("evalEntetePasActive"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut evalEntetePasActive");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nod.getAttributs().get("evalPiedPageActive")!=null) {
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(nod.getAttributs().get("evalPiedPageActive"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut evalEntetePasActive");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-10 20:23:53 +01:00
|
|
|
if(nod.getAttributs().get("evalPlacement")!=null) {
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(nod.getAttributs().get("evalPlacement"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut evalPlacement");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-12 19:25:53 +01:00
|
|
|
if(nod.getAttributs().get("evalNameLegacyStyle")!=null) {
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(nod.getAttributs().get("evalNameLegacyStyle"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut evalPlacement");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-14 13:37:48 +01:00
|
|
|
if(nod.getAttributs().get("evalFirstChild")!=null) {
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(nod.getAttributs().get("evalFirstChild"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut evalFirstChild");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nod.getAttributs().get("evalLastChild")!=null) {
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(nod.getAttributs().get("evalLastChild"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut evalLastChild");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-22 13:24:04 +01:00
|
|
|
if(nod.getAttributs().get("evalAncrageNumeroAbsoluePage")!=null) {
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(nod.getAttributs().get("evalAncrageNumeroAbsoluePage"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut evalAncrageNumeroAbsoluePage");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-23 19:24:59 +01:00
|
|
|
if(nod.getAttributs().get("evalFormatageDirect")!=null) {
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(nod.getAttributs().get("evalFormatageDirect"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut evalFormatageDirect");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-25 18:00:02 +01:00
|
|
|
if(nod.getAttributs().get("evalSautPageColonne")!=null) {
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(nod.getAttributs().get("evalSautPageColonne"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut evalSautPageColonne");
|
|
|
|
}
|
|
|
|
}
|
2022-12-22 13:24:04 +01:00
|
|
|
|
2022-12-26 10:30:23 +01:00
|
|
|
if(nod.getAttributs().get("evalPasParagrapheVide")!=null) {
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(nod.getAttributs().get("evalPasParagrapheVide"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut evalPasParagrapheVide");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-01 18:42:29 +01:00
|
|
|
if(nod.getAttributs().get("evalNombreDePageMaxi")!=null) {
|
|
|
|
try {
|
|
|
|
String valeur = nod.getAttributs().get("evalNombreDePageMaxi");
|
|
|
|
String A = valeur.substring(valeur.lastIndexOf("page")+4, valeur.length());
|
|
|
|
point = point + Integer.valueOf(A);;
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut evalNombreDePageMaxi");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-02 10:17:36 +01:00
|
|
|
//***********************************************
|
|
|
|
//** Les points par la méthode analyseStyle *****
|
|
|
|
//***********************************************
|
|
|
|
if(nod.getAttributs().get("analyseStyle")!=null) {
|
|
|
|
if(nod.getAttributs().get("analyseStyle").equals("true")) {
|
|
|
|
String nomDuStyle = nod.getAttributs().get("text:style-name");
|
|
|
|
point = calculNombreDepointDeAnalyseStyle(commandes.sujet.retourneFirstNodeByNameAndAttributValueExactStrict("style:style", "style:name", nomDuStyle), point);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Enumeration<String> key = nod.getAttributs().keys();
|
|
|
|
while(key.hasMoreElements()) {
|
|
|
|
String k = key.nextElement();
|
|
|
|
if(nod.getAttributs().get(k).contains("‽")) {
|
|
|
|
Pattern pt = Pattern.compile("[0-9]{1,}$");
|
|
|
|
Matcher match= pt.matcher(nod.getAttributs().get(k));
|
|
|
|
if(match.find()) {
|
|
|
|
String s= match.group();
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(s);
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut "+ k);
|
|
|
|
}
|
|
|
|
}
|
2022-06-14 20:09:16 +02:00
|
|
|
}
|
|
|
|
}
|
2022-12-01 15:44:22 +01:00
|
|
|
|
2022-12-02 10:17:36 +01:00
|
|
|
|
2022-06-14 20:09:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0 ; i < nod.getNodes().size();i++) {
|
|
|
|
if(nod.getNodes().get(i)!=null) {
|
2022-12-02 10:17:36 +01:00
|
|
|
if(!nod.getNodes().get(i).getNomElt().equals("style:default-style")) {
|
|
|
|
point = calculNombreDepoint(nod.getNodes().get(i), point);
|
|
|
|
}
|
2022-06-14 20:09:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return point;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-12-02 10:17:36 +01:00
|
|
|
/**
|
|
|
|
* Calcul les points d'un style évalué par la méthode analyseStyle.<br>
|
|
|
|
* @param nod
|
|
|
|
* @param point
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
private static int calculNombreDepointDeAnalyseStyle(node nod, int point) {
|
2022-12-14 13:37:48 +01:00
|
|
|
if(nod!=null) {
|
|
|
|
if(nod.getAttributs().get("evaluer")!=null) if(nod.getAttributs().get("evaluer").equals("true")){
|
|
|
|
|
|
|
|
Enumeration<String> key = nod.getAttributs().keys();
|
|
|
|
while(key.hasMoreElements()) {
|
|
|
|
String k = key.nextElement();
|
|
|
|
if(nod.getAttributs().get(k).contains("‼")) {
|
|
|
|
Pattern pt = Pattern.compile("[0-9]{1,}$");
|
|
|
|
Matcher match= pt.matcher(nod.getAttributs().get(k));
|
|
|
|
if(match.find()) {
|
|
|
|
String s= match.group();
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(s);
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut "+ k);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(nod.getNodes().size()>0) {
|
|
|
|
for(int i = 0 ; i < nod.getNodes().size();i++) {
|
|
|
|
point = calculNombreDepointDeAnalyseStyle(nod.getNodes().get(i), point);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return point;
|
|
|
|
}
|
2022-12-02 10:17:36 +01:00
|
|
|
|
2022-12-14 13:37:48 +01:00
|
|
|
/**
|
|
|
|
* Calcul les points d'un style évalué par la méthode analyseStyle et qui hérite du node nod.<br>
|
|
|
|
* @param nod
|
|
|
|
* @param point
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
private static int calculNombreDepointDepuisUnStyleDeAnalyseStyle(node nod, int point) {
|
|
|
|
|
2022-12-02 10:17:36 +01:00
|
|
|
Enumeration<String> key = nod.getAttributs().keys();
|
|
|
|
while(key.hasMoreElements()) {
|
|
|
|
String k = key.nextElement();
|
2022-12-14 13:37:48 +01:00
|
|
|
if(nod.getAttributs().get(k).contains("‼")||nod.getAttributs().get(k).contains("‽")) {
|
2022-12-02 10:17:36 +01:00
|
|
|
Pattern pt = Pattern.compile("[0-9]{1,}$");
|
|
|
|
Matcher match= pt.matcher(nod.getAttributs().get(k));
|
|
|
|
if(match.find()) {
|
|
|
|
String s= match.group();
|
|
|
|
try {
|
|
|
|
point = point + Integer.valueOf(s);
|
|
|
|
} catch (Exception e) {
|
|
|
|
JOptionPane.showInternalMessageDialog(null, "Erreur dans la valeur de l'attribut "+ k);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nod.getNodes().size()>0) {
|
|
|
|
for(int i = 0 ; i < nod.getNodes().size();i++) {
|
2022-12-14 13:37:48 +01:00
|
|
|
point = calculNombreDepointDepuisUnStyleDeAnalyseStyle(nod.getNodes().get(i), point);
|
2022-12-02 10:17:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-14 13:37:48 +01:00
|
|
|
return point;
|
2022-12-02 10:17:36 +01:00
|
|
|
|
|
|
|
}
|
2022-06-14 20:09:16 +02:00
|
|
|
|
|
|
|
}
|