From 3878d68b38666fd86a2c89646b0a7d7cf33c10c1 Mon Sep 17 00:00:00 2001
From: IDK <idk@scodoc.org>
Date: Tue, 19 Oct 2021 15:52:02 +0200
Subject: [PATCH] Utilise NA pour les notes manquants (et plus NA0, ...)

---
 app/scodoc/notes_table.py      |  7 +++----
 app/scodoc/sco_compute_moy.py  | 10 ++++++----
 app/scodoc/sco_recapcomplet.py |  6 +++---
 app/scodoc/sco_tag_module.py   |  2 +-
 app/scodoc/sco_utils.py        |  2 +-
 5 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/app/scodoc/notes_table.py b/app/scodoc/notes_table.py
index fb18d050d..e3d6e4193 100644
--- a/app/scodoc/notes_table.py
+++ b/app/scodoc/notes_table.py
@@ -630,7 +630,8 @@ class NotesTable(object):
                         matiere_sum_notes += val * coef
                         matiere_sum_coefs += coef
                         matiere_id_last = matiere_id
-                    except:
+                    except:  # val == "NI" "NA"
+                        assert val == "NI" or val == "NA"
                         nb_missing = nb_missing + 1
                         coefs.append(0)
                         coefs_mask.append(0)
@@ -728,9 +729,7 @@ class NotesTable(object):
 
         Prend toujours en compte les UE capitalisées.
         """
-        # log('comp_etud_moy_gen(etudid=%s)' % etudid)
-
-        # Si l'étudiant a Demissionné ou est DEFaillant, on n'enregistre pas ses moyennes
+        # Si l'étudiant a Démissionné ou est DEFaillant, on n'enregistre pas ses moyennes
         block_computation = (
             self.inscrdict[etudid]["etat"] == "D"
             or self.inscrdict[etudid]["etat"] == DEF
diff --git a/app/scodoc/sco_compute_moy.py b/app/scodoc/sco_compute_moy.py
index 4d46f065c..3e5059012 100644
--- a/app/scodoc/sco_compute_moy.py
+++ b/app/scodoc/sco_compute_moy.py
@@ -160,7 +160,7 @@ def compute_user_formula(
         # log('expression : %s\nvariables=%s\n' % (formula, variables)) #  debug
         user_moy = sco_formulas.eval_user_expression(formula, variables)
         # log('user_moy=%s' % user_moy)
-        if user_moy != "NA0" and user_moy != "NA":
+        if user_moy != "NA":
             user_moy = float(user_moy)
             if (user_moy > 20) or (user_moy < 0):
                 etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
@@ -295,15 +295,17 @@ def compute_moduleimpl_moyennes(nt, modimpl):
                 # il manque une note ! (si publish_incomplete, cela peut arriver, on ignore)
                 if e["coefficient"] > 0 and not e["publish_incomplete"]:
                     nb_missing += 1
+                    # ne devrait pas arriver ?
+                    log("\nXXX SCM298\n")
         if nb_missing == 0 and sum_coefs > 0:
             if sum_coefs > 0:
                 R[etudid] = sum_notes / sum_coefs
                 moy_valid = True
             else:
-                R[etudid] = "na"
+                R[etudid] = "NA"
                 moy_valid = False
         else:
-            R[etudid] = "NA%d" % nb_missing
+            R[etudid] = "NA"
             moy_valid = False
 
         if user_expr:
@@ -361,7 +363,7 @@ def compute_moduleimpl_moyennes(nt, modimpl):
                         if eval_rattr["evaluation_type"] == EVALUATION_RATTRAPAGE:
                             # rattrapage classique: prend la meilleure note entre moyenne
                             # module et note eval rattrapage
-                            if (R[etudid] == "NA0") or (note_sur_20 > R[etudid]):
+                            if (R[etudid] == "NA") or (note_sur_20 > R[etudid]):
                                 # log('note_sur_20=%s' % note_sur_20)
                                 R[etudid] = note_sur_20
                         elif eval_rattr["evaluation_type"] == EVALUATION_SESSION2:
diff --git a/app/scodoc/sco_recapcomplet.py b/app/scodoc/sco_recapcomplet.py
index 06f7b95eb..325aec530 100644
--- a/app/scodoc/sco_recapcomplet.py
+++ b/app/scodoc/sco_recapcomplet.py
@@ -669,11 +669,11 @@ def make_formsemestre_recapcomplet(
                 else:
                     cells = '<tr class="recap_row_odd" id="etudid%s">' % etudid
             ir += 1
-            # XXX nsn = [ x.replace('NA0', '-') for x in l[:-2] ]
-            # notes sans le NA0:
+            # XXX nsn = [ x.replace('NA', '-') for x in l[:-2] ]
+            # notes sans le NA:
             nsn = l[:-2]  # copy
             for i in range(len(nsn)):
-                if nsn[i] == "NA0":
+                if nsn[i] == "NA":
                     nsn[i] = "-"
             cells += '<td class="recap_col">%s</td>' % nsn[0]  # rang
             cells += '<td class="recap_col">%s</td>' % el  # nom etud (lien)
diff --git a/app/scodoc/sco_tag_module.py b/app/scodoc/sco_tag_module.py
index b106a754e..50ec8f01c 100644
--- a/app/scodoc/sco_tag_module.py
+++ b/app/scodoc/sco_tag_module.py
@@ -280,7 +280,7 @@ def get_etud_tagged_modules(etudid, tagname):
                 R.append(
                     {
                         "sem": sem,
-                        "moy": moy,  # valeur réelle, ou NI (non inscrit au module ou NA0 (pas de note)
+                        "moy": moy,  # valeur réelle, ou NI (non inscrit au module ou NA (pas de note)
                         "moduleimpl": modimpl,
                         "tags": tags,
                     }
diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py
index e5dec56b8..68321aba1 100644
--- a/app/scodoc/sco_utils.py
+++ b/app/scodoc/sco_utils.py
@@ -132,7 +132,7 @@ def fmt_note(val, note_max=None, keep_numeric=False):
             s = "0" * (5 - len(s)) + s  # padding: 0 à gauche pour longueur 5: "12.34"
             return s
     else:
-        return val.replace("NA0", "-")  # notes sans le NA0
+        return val.replace("NA", "-")
 
 
 def fmt_coef(val):