""" % (cssclass, title)
# ]
@@ -130,7 +87,7 @@ def defMenuStats(context, formsemestre_id):
{
"title": "Graphe des parcours",
"url": "formsemestre_graph_parcours?formsemestre_id=" + formsemestre_id,
- "enabled": WITH_PYDOT,
+ "enabled": scu.WITH_PYDOT,
},
{
"title": "Codes des parcours",
@@ -364,7 +321,7 @@ def formsemestre_status_menubar(context, sem, REQUEST):
{
"title": "Créer/modifier les partitions...",
"url": "editPartitionForm?formsemestre_id=" + formsemestre_id,
- "enabled": context.can_change_groups(REQUEST, formsemestre_id),
+ "enabled": sco_groups.can_change_groups(context, REQUEST, formsemestre_id),
},
]
# 1 item / partition:
@@ -372,7 +329,9 @@ def formsemestre_status_menubar(context, sem, REQUEST):
context, formsemestre_id, with_default=False
)
submenu = []
- enabled = context.can_change_groups(REQUEST, formsemestre_id) and partitions
+ enabled = (
+ sco_groups.can_change_groups(context, REQUEST, formsemestre_id) and partitions
+ )
for partition in partitions:
submenu.append(
{
@@ -453,12 +412,12 @@ def formsemestre_status_menubar(context, sem, REQUEST):
H = [
# '
@@ -476,8 +435,8 @@ def retreive_formsemestre_from_request(context, REQUEST):
if REQUEST.form.has_key("formsemestre_id"):
formsemestre_id = REQUEST.form["formsemestre_id"]
elif REQUEST.form.has_key("moduleimpl_id"):
- modimpl = context.do_moduleimpl_list(
- moduleimpl_id=REQUEST.form["moduleimpl_id"]
+ modimpl = sco_moduleimpl.do_moduleimpl_list(
+ context, moduleimpl_id=REQUEST.form["moduleimpl_id"]
)
if not modimpl:
return None # suppressed ?
@@ -488,7 +447,9 @@ def retreive_formsemestre_from_request(context, REQUEST):
if not E:
return None # evaluation suppressed ?
E = E[0]
- modimpl = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
+ modimpl = sco_moduleimpl.do_moduleimpl_list(
+ context, moduleimpl_id=E["moduleimpl_id"]
+ )[0]
formsemestre_id = modimpl["formsemestre_id"]
elif REQUEST.form.has_key("group_id"):
group = sco_groups.get_group(context, REQUEST.form["group_id"])
@@ -557,15 +518,15 @@ def fill_formsemestre(context, sem, REQUEST=None):
] = """%s""" % (
notes_url,
sem["formsemestre_id"],
- icontag("lock_img", border="0", title="Semestre verrouillé"),
+ scu.icontag("lock_img", border="0", title="Semestre verrouillé"),
)
else:
sem["locklink"] = ""
if context.get_preference("bul_display_publication", formsemestre_id):
if sem["bul_hide_xml"] != "0":
- eyeicon = icontag("hide_img", border="0", title="Bulletins NON publiés")
+ eyeicon = scu.icontag("hide_img", border="0", title="Bulletins NON publiés")
else:
- eyeicon = icontag("eye_img", border="0", title="Bulletins publiés")
+ eyeicon = scu.icontag("eye_img", border="0", title="Bulletins publiés")
sem["eyelink"] = (
"""%s"""
% (notes_url, sem["formsemestre_id"], eyeicon)
@@ -614,7 +575,9 @@ def formsemestre_description_table(
use_ue_coefs = context.get_preference("use_ue_coefs", formsemestre_id)
F = context.formation_list(args={"formation_id": sem["formation_id"]})[0]
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
- Mlist = context.do_moduleimpl_withmodule_list(formsemestre_id=formsemestre_id)
+ Mlist = sco_moduleimpl.do_moduleimpl_withmodule_list(
+ context, formsemestre_id=formsemestre_id
+ )
R = []
sum_coef = 0
@@ -641,8 +604,8 @@ def formsemestre_description_table(
ue_info["Coef._class"] = "ue_coef"
R.append(ue_info)
- ModInscrits = context.do_moduleimpl_inscription_list(
- moduleimpl_id=M["moduleimpl_id"]
+ ModInscrits = sco_moduleimpl.do_moduleimpl_inscription_list(
+ context, moduleimpl_id=M["moduleimpl_id"]
)
enseignants = ", ".join(
[
@@ -715,13 +678,13 @@ def formsemestre_description_table(
titles["coefficient"] = "Coef. éval."
titles["evalcomplete_str"] = "Complète"
titles["publish_incomplete_str"] = "Toujours Utilisée"
- title = "%s %s" % (strcapitalize(parcours.SESSION_NAME), sem["titremois"])
+ title = "%s %s" % (scu.strcapitalize(parcours.SESSION_NAME), sem["titremois"])
return GenTable(
columns_ids=columns_ids,
rows=R,
titles=titles,
- origin="Généré par %s le " % VERSION.SCONAME + timedate_human_repr() + "",
+ origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "",
caption=title,
html_caption=title,
html_class="table_leftalign formsemestre_description",
@@ -779,8 +742,8 @@ def html_expr_diagnostic(context, diagnostics):
last_id, last_msg = None, None
for diag in diagnostics:
if "moduleimpl_id" in diag:
- mod = context.do_moduleimpl_withmodule_list(
- moduleimpl_id=diag["moduleimpl_id"]
+ mod = sco_moduleimpl.do_moduleimpl_withmodule_list(
+ context, moduleimpl_id=diag["moduleimpl_id"]
)[0]
H.append(
'- module %s: %s
'
@@ -875,10 +838,12 @@ def formsemestre_status(context, formsemestre_id=None, REQUEST=None):
# porté du DTML
cnx = context.GetDBConnexion()
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
- Mlist = context.do_moduleimpl_withmodule_list(formsemestre_id=formsemestre_id)
- inscrits = context.do_formsemestre_inscription_list(
- args={"formsemestre_id": formsemestre_id}
+ Mlist = sco_moduleimpl.do_moduleimpl_withmodule_list(
+ context, formsemestre_id=formsemestre_id
)
+ # inscrits = context.do_formsemestre_inscription_list(
+ # args={"formsemestre_id": formsemestre_id}
+ # )
prev_ue_id = None
can_edit = sco_formsemestre_edit.can_edit_sem(
@@ -926,8 +891,8 @@ def formsemestre_status(context, formsemestre_id=None, REQUEST=None):
ModEns += " (resp.), " + ", ".join(
[context.Users.user_info(e["ens_id"])["nomcomplet"] for e in M["ens"]]
)
- ModInscrits = context.do_moduleimpl_inscription_list(
- moduleimpl_id=M["moduleimpl_id"]
+ ModInscrits = sco_moduleimpl.do_moduleimpl_inscription_list(
+ context, moduleimpl_id=M["moduleimpl_id"]
)
mails_enseignants.add(
context.Users.user_info(M["responsable_id"], REQUEST)["email"]
@@ -960,7 +925,7 @@ def formsemestre_status(context, formsemestre_id=None, REQUEST=None):
% (formsemestre_id, ue["ue_id"])
)
H.append(
- icontag(
+ scu.icontag(
"formula",
title="Mode calcul moyenne d'UE",
style="vertical-align:middle",
@@ -976,7 +941,7 @@ def formsemestre_status(context, formsemestre_id=None, REQUEST=None):
H.append("")
- if M["ue"]["type"] != UE_STANDARD:
+ if M["ue"]["type"] != sco_codes_parcours.UE_STANDARD:
fontorange = " fontorange" # style css additionnel
else:
fontorange = ""
@@ -1011,7 +976,7 @@ def formsemestre_status(context, formsemestre_id=None, REQUEST=None):
)
)
- if Mod["module_type"] == MODULE_STANDARD:
+ if Mod["module_type"] == scu.MODULE_STANDARD:
H.append('')
nb_evals = (
etat["nb_evals_completes"]
@@ -1033,7 +998,7 @@ def formsemestre_status(context, formsemestre_id=None, REQUEST=None):
' [en attente]'
% M["moduleimpl_id"]
)
- elif Mod["module_type"] == MODULE_MALUS:
+ elif Mod["module_type"] == scu.MODULE_MALUS:
nb_malus_notes = sum(
[
e["etat"]["nb_notes"]
diff --git a/sco_formsemestre_validation.py b/sco_formsemestre_validation.py
index 09739779..8ca807de 100644
--- a/sco_formsemestre_validation.py
+++ b/sco_formsemestre_validation.py
@@ -1212,11 +1212,11 @@ def do_formsemestre_validate_previous_ue(
context, formsemestre_id
) # > get_etud_ue_status
if ue_coefficient != None:
- sco_formsemestre_edit.do_formsemestre_uecoef_edit_or_create(
+ sco_formsemestre.do_formsemestre_uecoef_edit_or_create(
context, cnx, formsemestre_id, ue_id, ue_coefficient
)
else:
- sco_formsemestre_edit.do_formsemestre_uecoef_delete(
+ sco_formsemestre.do_formsemestre_uecoef_delete(
context, cnx, formsemestre_id, ue_id
)
sco_parcours_dut.do_formsemestre_validate_ue(
diff --git a/sco_groups.py b/sco_groups.py
index 7cc57d40..71a6456f 100644
--- a/sco_groups.py
+++ b/sco_groups.py
@@ -28,16 +28,9 @@
"""Gestion des groupes, nouvelle mouture (juin/nov 2009)
TODO:
-
-* Groupes:
-
- - changement de groupe d'un seul etudiant:
- formChangeGroupe: pour l'instant supprimé, pas vraiment utile ?
- doChangeGroupe
-
Optimisation possible:
revoir do_evaluation_listeetuds_groups() pour extraire aussi les groupes (de chaque etudiant)
- et eviter ainsi l'appel ulterieur à get_etud_groups() dans _make_table_notes
+ et éviter ainsi l'appel ulterieur à get_etud_groups() dans _make_table_notes
"""
@@ -58,6 +51,20 @@ import scolars
import sco_parcours_dut
+def can_change_groups(context, REQUEST, formsemestre_id):
+ "Vrai si l'utilisateur peut changer les groupes dans ce semestre"
+ sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
+ if sem["etat"] != "1":
+ return False # semestre verrouillé
+ authuser = REQUEST.AUTHENTICATED_USER
+ if authuser.has_permission(ScoEtudChangeGroups, context):
+ return True # admin, chef dept
+ uid = str(authuser)
+ if uid in sem["responsables"]:
+ return True
+ return False
+
+
def checkGroupName(
groupName,
): # XXX unused: now allow any string as a group or partition name
@@ -606,7 +613,7 @@ def setGroups(
"""
partition = get_partition(context, partition_id)
formsemestre_id = partition["formsemestre_id"]
- if not context.Notes.can_change_groups(REQUEST, formsemestre_id):
+ if not can_change_groups(context, REQUEST, formsemestre_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
log("***setGroups: partition_id=%s" % partition_id)
log("groupsLists=%s" % groupsLists)
@@ -693,7 +700,7 @@ def createGroup(context, partition_id, group_name="", default=False, REQUEST=Non
"""
partition = get_partition(context, partition_id)
formsemestre_id = partition["formsemestre_id"]
- if REQUEST and not context.Notes.can_change_groups(REQUEST, formsemestre_id):
+ if REQUEST and not can_change_groups(context, REQUEST, formsemestre_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
#
if group_name:
@@ -730,7 +737,7 @@ def suppressGroup(context, group_id, partition_id=None, REQUEST=None):
else:
partition_id = group["partition_id"]
partition = get_partition(context, partition_id)
- if not context.Notes.can_change_groups(REQUEST, partition["formsemestre_id"]):
+ if not can_change_groups(context, REQUEST, partition["formsemestre_id"]):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
log(
"suppressGroup: group_id=%s group_name=%s partition_name=%s"
@@ -749,7 +756,7 @@ def partition_create(
redirect=1,
):
"""Create a new partition"""
- if REQUEST and not context.Notes.can_change_groups(REQUEST, formsemestre_id):
+ if REQUEST and not can_change_groups(context, REQUEST, formsemestre_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
if partition_name:
partition_name = partition_name.strip()
@@ -793,7 +800,7 @@ def getArrowIconsTags(context, REQUEST):
def editPartitionForm(context, formsemestre_id=None, REQUEST=None):
"""Form to create/suppress partitions"""
# ad-hoc form
- if not context.Notes.can_change_groups(REQUEST, formsemestre_id):
+ if not can_change_groups(context, REQUEST, formsemestre_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
partitions = get_partitions_list(context, formsemestre_id)
arrow_up, arrow_down, arrow_none = getArrowIconsTags(context, REQUEST)
@@ -805,7 +812,7 @@ def editPartitionForm(context, formsemestre_id=None, REQUEST=None):
context.sco_header(
REQUEST, page_title="Partitions...", javascripts=["js/editPartitionForm.js"]
),
- """
""",
- """Partitions du semestre
+ r"""Partitions du semestre
""")
else: # SUBMISSION
# inscrit a ce module tous les etuds selectionnes
- context.do_moduleimpl_inscrit_etuds(
- moduleimpl_id, formsemestre_id, etuds, reset=True, REQUEST=REQUEST
+ sco_moduleimpl.do_moduleimpl_inscrit_etuds(
+ context, moduleimpl_id, formsemestre_id, etuds, reset=True, REQUEST=REQUEST
)
REQUEST.RESPONSE.redirect(
"moduleimpl_status?moduleimpl_id=%s" % (moduleimpl_id)
@@ -187,37 +190,6 @@ def moduleimpl_inscriptions_edit(
return "\n".join(H)
-def _make_menu_old_xxx(context, partitions, title="", check="true"):
- H = [
- """
- """
- % title
- ]
- # 'tous'
- H.append(
- """- Tous
""" % (check)
- )
- p_idx = 0
- for partition in partitions:
- if partition["partition_name"] != None:
- p_idx += 1
- for group in sco_groups.get_partition_groups(context, partition):
- H.append(
- """- %s %s
"""
- % (
- group["group_name"],
- p_idx,
- check,
- partition["partition_name"],
- group["group_name"],
- )
- )
-
- H.append(" ")
-
- return "".join(H)
-
-
def _make_menu(context, partitions, title="", check="true"):
"""Menu with list of all groups"""
items = [{"title": "Tous", "attr": "onclick=\"group_select('', -1, %s)\"" % check}]
@@ -236,7 +208,7 @@ def _make_menu(context, partitions, title="", check="true"):
)
return (
' | "
)
@@ -275,7 +247,9 @@ def moduleimpl_inscriptions_stats(context, formsemestre_id, REQUEST=None):
can_change = authuser.has_permission(ScoEtudInscrit, context) and sem["etat"] == "1"
# Liste des modules
- Mlist = context.do_moduleimpl_withmodule_list(formsemestre_id=formsemestre_id)
+ Mlist = sco_moduleimpl.do_moduleimpl_withmodule_list(
+ context, formsemestre_id=formsemestre_id
+ )
# Decrit les inscriptions aux modules:
commons = [] # modules communs a tous les etuds du semestre
options = [] # modules ou seuls quelques etudiants sont inscrits
@@ -423,7 +397,9 @@ def descr_inscrs_module(
context, sem, moduleimpl_id, set_all, partitions, partitions_etud_groups
):
"""returns tous_inscrits, nb_inscrits, descr"""
- ins = context.do_moduleimpl_inscription_list(moduleimpl_id=moduleimpl_id)
+ ins = sco_moduleimpl.do_moduleimpl_inscription_list(
+ context, moduleimpl_id=moduleimpl_id
+ )
set_m = set([x["etudid"] for x in ins]) # ens. des inscrits au module
non_inscrits = set_all - set_m
if len(non_inscrits) == 0:
@@ -580,7 +556,8 @@ def do_etud_inscrit_ue(context, etudid, formsemestre_id, ue_id, REQUEST=None):
)
res = cursor.dictfetchall()
for moduleimpl_id in [x["moduleimpl_id"] for x in res]:
- context.do_moduleimpl_inscription_create(
+ sco_moduleimpl.do_moduleimpl_inscription_create(
+ context,
{"moduleimpl_id": moduleimpl_id, "etudid": etudid},
REQUEST=REQUEST,
formsemestre_id=formsemestre_id,
diff --git a/sco_moduleimpl_status.py b/sco_moduleimpl_status.py
index 08c32bfc..16016520 100644
--- a/sco_moduleimpl_status.py
+++ b/sco_moduleimpl_status.py
@@ -27,21 +27,30 @@
"""Tableau de bord module
"""
+import time
+import urllib
-from notesdb import *
-from sco_utils import *
+import sco_utils as scu
+from sco_utils import (
+ EVALUATION_NORMALE,
+ EVALUATION_RATTRAPAGE,
+)
+from sco_permissions import ScoEtudInscrit, ScoAbsChange
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
-from notes_table import *
+
+# from notes_table import *
import sco_groups
import sco_evaluations
import htmlutils
import sco_excel
from gen_tables import GenTable
from htmlutils import histogram_notes
+import sco_moduleimpl
import sco_formsemestre
import sco_formsemestre_status
-from sco_formsemestre_status import makeMenu
+import htmlutils
+import sco_saisie_notes
import sco_compute_moy
import sco_abs
@@ -51,13 +60,15 @@ import sco_abs
def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None):
"Menu avec actions sur une evaluation"
E = context.do_evaluation_list({"evaluation_id": evaluation_id})[0]
- modimpl = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
+ modimpl = sco_moduleimpl.do_moduleimpl_list(
+ context, moduleimpl_id=E["moduleimpl_id"]
+ )[0]
group_id = sco_groups.get_default_group(context, modimpl["formsemestre_id"])
if (
- context.can_edit_notes(
- REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
+ sco_saisie_notes.can_edit_notes(
+ context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
)
and nbnotes != 0
):
@@ -69,30 +80,30 @@ def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None):
{
"title": "Saisir notes",
"url": "saisie_notes?evaluation_id=" + evaluation_id,
- "enabled": context.can_edit_notes(
- REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"]
+ "enabled": sco_saisie_notes.can_edit_notes(
+ context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"]
),
},
{
"title": "Modifier évaluation",
"url": "evaluation_edit?evaluation_id=" + evaluation_id,
- "enabled": context.can_edit_notes(
- REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
+ "enabled": sco_saisie_notes.can_edit_notes(
+ context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
),
},
{
"title": sup_label,
"url": "evaluation_delete?evaluation_id=" + evaluation_id,
"enabled": nbnotes == 0
- and context.can_edit_notes(
- REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
+ and sco_saisie_notes.can_edit_notes(
+ context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
),
},
{
"title": "Supprimer toutes les notes",
"url": "evaluation_suppress_alln?evaluation_id=" + evaluation_id,
- "enabled": context.can_edit_notes(
- REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
+ "enabled": sco_saisie_notes.can_edit_notes(
+ context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
),
},
{
@@ -104,7 +115,9 @@ def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None):
"title": "Placement étudiants",
"url": "placement_eval_selectetuds?evaluation_id=" + evaluation_id,
"enabled": nbnotes == 0
- and context.can_edit_notes(REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"]),
+ and sco_saisie_notes.can_edit_notes(
+ context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"]
+ ),
},
{
"title": "Absences ce jour",
@@ -119,19 +132,19 @@ def moduleimpl_evaluation_menu(context, evaluation_id, nbnotes=0, REQUEST=None):
},
]
- return makeMenu("actions", menuEval, alone=True)
+ return htmlutils.make_menu("actions", menuEval, alone=True)
def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=None):
"""Tableau de bord module (liste des evaluations etc)"""
authuser = REQUEST.AUTHENTICATED_USER
- M = context.do_moduleimpl_list(moduleimpl_id=moduleimpl_id)[0]
+ M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)[0]
formsemestre_id = M["formsemestre_id"]
Mod = context.do_module_list(args={"module_id": M["module_id"]})[0]
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
F = context.formation_list(args={"formation_id": sem["formation_id"]})[0]
- ModInscrits = context.do_moduleimpl_inscription_list(
- moduleimpl_id=M["moduleimpl_id"]
+ ModInscrits = sco_moduleimpl.do_moduleimpl_inscription_list(
+ context, moduleimpl_id=M["moduleimpl_id"]
)
nt = context._getNotesCache().get_NotesTable(context, formsemestre_id)
@@ -141,10 +154,10 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
) # la plus RECENTE en tête
#
- caneditevals = context.can_edit_notes(
- authuser, moduleimpl_id, allow_ens=sem["ens_can_edit_eval"]
+ caneditevals = sco_saisie_notes.can_edit_notes(
+ context, authuser, moduleimpl_id, allow_ens=sem["ens_can_edit_eval"]
)
- caneditnotes = context.can_edit_notes(authuser, moduleimpl_id)
+ caneditnotes = sco_saisie_notes.can_edit_notes(context, authuser, moduleimpl_id)
arrow_up, arrow_down, arrow_none = sco_groups.getArrowIconsTags(context, REQUEST)
#
H = [
@@ -160,7 +173,7 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
"""(%(responsable_id)s)""" % M,
]
try:
- context.can_change_module_resp(REQUEST, moduleimpl_id)
+ sco_moduleimpl.can_change_module_resp(context, REQUEST, moduleimpl_id)
H.append(
"""modifier"""
% moduleimpl_id
@@ -173,7 +186,7 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
)
H.append("""""")
try:
- context.can_change_ens(REQUEST, moduleimpl_id)
+ sco_moduleimpl.can_change_ens(context, REQUEST, moduleimpl_id)
H.append(
"""modifier les enseignants"""
% moduleimpl_id
@@ -189,7 +202,7 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
else:
H.append(""" | """)
if sem["etat"] != "1":
- H.append(icontag("lock32_img", title="verrouillé"))
+ H.append(scu.icontag("lock32_img", title="verrouillé"))
H.append(
""" | Coef dans le semestre: %(coefficient)s | | """
% Mod
@@ -216,7 +229,9 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
'Règle de calcul: moyenne=%s'
% M["computation_expr"]
)
- if context.can_change_ens(REQUEST, moduleimpl_id, raise_exc=False):
+ if sco_moduleimpl.can_change_ens(
+ context, REQUEST, moduleimpl_id, raise_exc=False
+ ):
H.append(
'modifier'
% moduleimpl_id
@@ -226,7 +241,9 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
H.append(
' |
règle de calcul standard'
)
- if context.can_change_ens(REQUEST, moduleimpl_id, raise_exc=False):
+ if sco_moduleimpl.can_change_ens(
+ context, REQUEST, moduleimpl_id, raise_exc=False
+ ):
H.append(
' (changer)'
% moduleimpl_id
@@ -407,7 +424,9 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
"""%s"""
% (
eval["evaluation_id"],
- icontag("edit_img", alt="modifier", title="Modifier informations"),
+ scu.icontag(
+ "edit_img", alt="modifier", title="Modifier informations"
+ ),
)
)
if caneditnotes:
@@ -415,7 +434,9 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
"""%s"""
% (
eval["evaluation_id"],
- icontag("notes_img", alt="saisie notes", title="Saisie des notes"),
+ scu.icontag(
+ "notes_img", alt="saisie notes", title="Saisie des notes"
+ ),
)
)
if etat["nb_notes"] == 0:
@@ -424,13 +445,13 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
""""""
% eval
)
- H.append(icontag("delete_img", alt="supprimer", title="Supprimer"))
+ H.append(scu.icontag("delete_img", alt="supprimer", title="Supprimer"))
if caneditevals:
H.append("""""")
elif etat["evalcomplete"]:
H.append(
"""%s"""
- % (eval["evaluation_id"], icontag("status_green_img", title="ok"))
+ % (eval["evaluation_id"], scu.icontag("status_green_img", title="ok"))
)
else:
if etat["evalattente"]:
@@ -438,7 +459,7 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
"""%s"""
% (
eval["evaluation_id"],
- icontag(
+ scu.icontag(
"status_greenorange_img",
file_format="gif",
title="notes en attente",
@@ -450,13 +471,13 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
"""%s"""
% (
eval["evaluation_id"],
- icontag("status_orange_img", title="il manque des notes"),
+ scu.icontag("status_orange_img", title="il manque des notes"),
)
)
#
if eval["visibulletin"] == "1":
H.append(
- icontag(
+ scu.icontag(
"status_visible_img", title="visible dans bulletins intermédiaires"
)
)
@@ -556,7 +577,7 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
if caneditevals or sem["etat"] != "1":
H.append(""" |
""")
if sem["etat"] != "1":
- H.append("""%s semestre verrouillé""" % icontag("lock32_img"))
+ H.append("""%s semestre verrouillé""" % scu.icontag("lock32_img"))
else:
H.append(top_table_links)
@@ -582,12 +603,12 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
"""
% (
- icontag("edit_img"),
- icontag("notes_img"),
- icontag("delete_img"),
- icontag("status_orange_img"),
- icontag("status_green_img"),
- icontag("status_visible_img"),
+ scu.icontag("edit_img"),
+ scu.icontag("notes_img"),
+ scu.icontag("delete_img"),
+ scu.icontag("status_orange_img"),
+ scu.icontag("status_green_img"),
+ scu.icontag("status_visible_img"),
)
)
H.append(context.sco_footer(REQUEST))
diff --git a/sco_news.py b/sco_news.py
index ba6acd34..a5860880 100644
--- a/sco_news.py
+++ b/sco_news.py
@@ -28,15 +28,17 @@
"""Gestions des "nouvelles"
"""
-import PyRSS2Gen
+import PyRSS2Gen # pylint: disable=import-error
from cStringIO import StringIO
import datetime, re
import time
from stripogram import html2text, html2safehtml
-from email.MIMEMultipart import MIMEMultipart
-from email.MIMEText import MIMEText
-from email.Header import Header
-from email import Encoders
+from email.MIMEMultipart import ( # pylint: disable=no-name-in-module,import-error
+ MIMEMultipart,
+)
+from email.MIMEText import MIMEText # pylint: disable=no-name-in-module,import-error
+from email.Header import Header # pylint: disable=no-name-in-module,import-error
+from email import Encoders # pylint: disable=no-name-in-module,import-error
from notesdb import * # pylint: disable=unused-wildcard-import
@@ -44,6 +46,7 @@ from notes_log import log
import scolars
from sco_utils import SCO_ENCODING, SCO_ANNONCES_WEBSITE
import sco_formsemestre
+import sco_moduleimpl
_scolar_news_editor = EditableTable(
"scolar_news",
@@ -165,7 +168,7 @@ def _get_formsemestre_infos_from_news(context, n):
formsemestre_id = n["object"]
elif n["type"] == NEWS_NOTE:
moduleimpl_id = n["object"]
- mods = context.Notes.do_moduleimpl_list(moduleimpl_id=moduleimpl_id)
+ mods = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)
if not mods:
return {} # module does not exists anymore
mod = mods[0]
diff --git a/sco_page_etud.py b/sco_page_etud.py
index b850243b..737b3ac2 100644
--- a/sco_page_etud.py
+++ b/sco_page_etud.py
@@ -40,7 +40,7 @@ import sco_groups
import sco_formsemestre
from scolars import format_telephone, format_pays, make_etud_args
import sco_formsemestre_status
-from sco_formsemestre_status import makeMenu
+import htmlutils
from sco_bulletins import etud_descr_situation_semestre
import sco_parcours_dut
from sco_formsemestre_validation import formsemestre_recap_parcours_table
@@ -135,7 +135,9 @@ def _menuScolarite(context, authuser, sem, etudid):
},
]
- return makeMenu("Scolarité", items, css_class="direction_etud", alone=True)
+ return htmlutils.make_menu(
+ "Scolarité", items, css_class="direction_etud", alone=True
+ )
def ficheEtud(context, etudid=None, REQUEST=None):
@@ -521,7 +523,7 @@ def menus_etud(context, REQUEST=None):
},
]
- return makeMenu(
+ return htmlutils.make_menu(
"Etudiant", menuEtud, base_url=context.absolute_url() + "/", alone=True
)
diff --git a/sco_permissions.py b/sco_permissions.py
index 9ec7f114..7a05f3a7 100644
--- a/sco_permissions.py
+++ b/sco_permissions.py
@@ -5,9 +5,6 @@
# prefix all permissions by "Sco" to group them in Zope management tab
-# Attention: si on change ces valeurs, il faut verifier les codes
-# DTML qui utilisent directement les chaines de caractères...
-
ScoChangeFormation = "Sco Change Formation"
ScoEditAllNotes = "Sco Modifier toutes notes"
ScoEditAllEvals = "Sco Modifier toutes les evaluations"
diff --git a/sco_placement.py b/sco_placement.py
index 8c296ac2..62c51ec2 100644
--- a/sco_placement.py
+++ b/sco_placement.py
@@ -36,8 +36,10 @@ from sco_utils import *
from notes_log import log
import scolars
import sco_formsemestre
+import sco_moduleimpl
import sco_groups
import sco_evaluations
+import sco_saisie_notes
import sco_excel
from sco_excel import *
from gen_tables import GenTable
@@ -46,15 +48,14 @@ import random
def do_placement_selectetuds(context, REQUEST):
"""
- Choisi les etudiants et les infos sur la salle pour le placement des etudiants
+ Choisi les étudiants et les infos sur la salle pour leur placement.
"""
evaluation_id = REQUEST.form["evaluation_id"]
E = context.do_evaluation_list({"evaluation_id": evaluation_id})
if not E:
raise ScoValueError("invalid evaluation_id")
E = E[0]
- M = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
- formsemestre_id = M["formsemestre_id"]
+ # M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0]
# groupes
groups = sco_groups.do_evaluation_listegroupes(
context, evaluation_id, include_default=True
@@ -230,11 +231,10 @@ def do_placement(context, REQUEST):
"Formulaire incomplet ! Vous avez sans doute attendu trop longtemps, veuillez vous reconnecter. Si le problème persiste, contacter l'administrateur. Merci."
)
E = context.do_evaluation_list({"evaluation_id": evaluation_id})[0]
- jour_iso = DateDMYtoISO(E["jour"])
# Check access
# (admin, respformation, and responsable_id)
- if not context.can_edit_notes(authuser, E["moduleimpl_id"]):
+ if not sco_saisie_notes.can_edit_notes(context, authuser, E["moduleimpl_id"]):
return (
"Génération du placement impossible pour %s" % authusername
+ """(vérifiez que le semestre n'est pas verrouillé et que vous
@@ -256,7 +256,7 @@ def do_placement(context, REQUEST):
group_ids = REQUEST.form.get("group_ids", [])
groups = sco_groups.listgroups(context, group_ids)
gr_title_filename = sco_groups.listgroups_filename(groups)
- gr_title = sco_groups.listgroups_abbrev(groups)
+ # gr_title = sco_groups.listgroups_abbrev(groups)
if None in [g["group_name"] for g in groups]: # tous les etudiants
getallstudents = True
@@ -270,7 +270,7 @@ def do_placement(context, REQUEST):
if not etudids:
return " Aucun groupe sélectionné ! "
- M = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
+ M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0]
Mod = context.do_module_list(args={"module_id": M["module_id"]})[0]
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
evalname = "%s-%s" % (Mod["code"], DateDMYtoISO(E["jour"]))
diff --git a/sco_saisie_notes.py b/sco_saisie_notes.py
index 09d0edf3..7284a008 100644
--- a/sco_saisie_notes.py
+++ b/sco_saisie_notes.py
@@ -29,18 +29,28 @@
Formulaire revu en juillet 2016
"""
+import time
import datetime
+import psycopg2
-from notesdb import *
-from sco_utils import *
+# from notesdb import *
+import sco_utils as scu
from notes_log import log
from TrivialFormulator import TrivialFormulator, TF
-from notes_table import *
+from notesdb import ScoDocCursor, quote_dict, DateISOtoDMY, DateDMYtoISO
+from sco_exceptions import (
+ InvalidNoteValue,
+ AccessDenied,
+ NoteProcessError,
+ ScoValueError,
+)
+from sco_permissions import ScoEditAllNotes
import sco_formsemestre
+import sco_moduleimpl
import sco_groups
import sco_groups_view
-from sco_formsemestre_status import makeMenu
import sco_evaluations
+import sco_parcours_dut
import sco_undo_notes
import htmlutils
import sco_excel
@@ -49,10 +59,45 @@ import sco_news
from sco_news import NEWS_INSCR, NEWS_NOTE, NEWS_FORM, NEWS_SEM, NEWS_MISC
+def can_edit_notes(context, authuser, moduleimpl_id, allow_ens=True):
+ """True if authuser can enter or edit notes in this module.
+ If allow_ens, grant access to all ens in this module
+
+ Si des décisions de jury ont déjà été saisies dans ce semestre,
+ seul le directeur des études peut saisir des notes (et il ne devrait pas).
+ """
+ uid = str(authuser)
+ M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)[0]
+ sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
+ if sem["etat"] != "1":
+ return False # semestre verrouillé
+
+ if sco_parcours_dut.formsemestre_has_decisions(context, sem["formsemestre_id"]):
+ # il y a des décisions de jury dans ce semestre !
+ return (
+ authuser.has_permission(ScoEditAllNotes, context)
+ or uid in sem["responsables"]
+ )
+ else:
+ if (
+ (not authuser.has_permission(ScoEditAllNotes, context))
+ and uid != M["responsable_id"]
+ and uid not in sem["responsables"]
+ ):
+ # enseignant (chargé de TD) ?
+ if allow_ens:
+ for ens in M["ens"]:
+ if ens["ens_id"] == uid:
+ return True
+ return False
+ else:
+ return True
+
+
def convert_note_from_string(
note,
note_max,
- note_min=NOTES_MIN,
+ note_min=scu.NOTES_MIN,
etudid=None,
absents=[],
tosuppress=[],
@@ -68,11 +113,11 @@ def convert_note_from_string(
note_value = None
absents.append(etudid)
elif note[:3] == "NEU" or note[:3] == "EXC":
- note_value = NOTES_NEUTRALISE
+ note_value = scu.NOTES_NEUTRALISE
elif note[:3] == "ATT":
- note_value = NOTES_ATTENTE
+ note_value = scu.NOTES_ATTENTE
elif note[:3] == "SUP":
- note_value = NOTES_SUPPRESS
+ note_value = scu.NOTES_SUPPRESS
tosuppress.append(etudid)
else:
try:
@@ -93,11 +138,11 @@ def _displayNote(val):
"""
if val is None:
val = "ABS"
- elif val == NOTES_NEUTRALISE:
+ elif val == scu.NOTES_NEUTRALISE:
val = "EXC" # excuse, note neutralise
- elif val == NOTES_ATTENTE:
+ elif val == scu.NOTES_ATTENTE:
val = "ATT" # attente, note neutralise
- elif val == NOTES_SUPPRESS:
+ elif val == scu.NOTES_SUPPRESS:
val = "SUPR"
else:
val = "%g" % val
@@ -111,9 +156,9 @@ def _check_notes(notes, evaluation, mod):
and 4 lists of etudid: invalids, withoutnotes, absents, tosuppress, existingjury
"""
note_max = evaluation["note_max"]
- if mod["module_type"] == MODULE_STANDARD:
- note_min = NOTES_MIN
- elif mod["module_type"] == MODULE_MALUS:
+ if mod["module_type"] == scu.MODULE_STANDARD:
+ note_min = scu.NOTES_MIN
+ elif mod["module_type"] == scu.MODULE_MALUS:
note_min = -20.0
else:
raise ValueError("Invalid module type") # bug
@@ -153,10 +198,12 @@ def do_evaluation_upload_xls(context, REQUEST):
evaluation_id = REQUEST.form["evaluation_id"]
comment = REQUEST.form["comment"]
E = context.do_evaluation_list({"evaluation_id": evaluation_id})[0]
- M = context.do_moduleimpl_withmodule_list(moduleimpl_id=E["moduleimpl_id"])[0]
+ M = sco_moduleimpl.do_moduleimpl_withmodule_list(
+ context, moduleimpl_id=E["moduleimpl_id"]
+ )[0]
# Check access
# (admin, respformation, and responsable_id)
- if not context.can_edit_notes(authuser, E["moduleimpl_id"]):
+ if not can_edit_notes(context, authuser, E["moduleimpl_id"]):
# XXX imaginer un redirect + msg erreur
raise AccessDenied("Modification des notes impossible pour %s" % authuser)
#
@@ -168,7 +215,6 @@ def do_evaluation_upload_xls(context, REQUEST):
# -- search eval code
n = len(lines)
i = 0
- ok = True
while i < n:
if not lines[i]:
diag.append("Erreur: format invalide (ligne vide ?)")
@@ -231,9 +277,10 @@ def do_evaluation_upload_xls(context, REQUEST):
context, authuser, evaluation_id, L, comment
)
# news
- cnx = context.GetDBConnexion()
E = context.do_evaluation_list({"evaluation_id": evaluation_id})[0]
- M = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
+ M = sco_moduleimpl.do_moduleimpl_list(
+ context, moduleimpl_id=E["moduleimpl_id"]
+ )[0]
mod = context.do_module_list(args={"module_id": M["module_id"]})[0]
mod["moduleimpl_id"] = M["moduleimpl_id"]
mod["url"] = "Notes/moduleimpl_status?moduleimpl_id=%(moduleimpl_id)s" % mod
@@ -274,10 +321,12 @@ def do_evaluation_set_missing(
authuser = REQUEST.AUTHENTICATED_USER
evaluation_id = REQUEST.form["evaluation_id"]
E = context.do_evaluation_list({"evaluation_id": evaluation_id})[0]
- M = context.do_moduleimpl_withmodule_list(moduleimpl_id=E["moduleimpl_id"])[0]
+ M = sco_moduleimpl.do_moduleimpl_withmodule_list(
+ context, moduleimpl_id=E["moduleimpl_id"]
+ )[0]
# Check access
# (admin, respformation, and responsable_id)
- if not context.can_edit_notes(authuser, E["moduleimpl_id"]):
+ if not can_edit_notes(context, authuser, E["moduleimpl_id"]):
# XXX imaginer un redirect + msg erreur
raise AccessDenied("Modification des notes impossible pour %s" % authuser)
#
@@ -323,8 +372,7 @@ def do_evaluation_set_missing(
context, authuser, evaluation_id, L, comment
)
# news
- cnx = context.GetDBConnexion()
- M = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
+ M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0]
mod = context.do_module_list(args={"module_id": M["module_id"]})[0]
mod["moduleimpl_id"] = M["moduleimpl_id"]
mod["url"] = "Notes/moduleimpl_status?moduleimpl_id=%(moduleimpl_id)s" % mod
@@ -356,17 +404,17 @@ def evaluation_suppress_alln(context, evaluation_id, REQUEST, dialog_confirmed=F
authuser = REQUEST.AUTHENTICATED_USER
E = context.do_evaluation_list({"evaluation_id": evaluation_id})[0]
- if context.can_edit_notes(authuser, E["moduleimpl_id"], allow_ens=False):
+ if can_edit_notes(context, authuser, E["moduleimpl_id"], allow_ens=False):
# On a le droit de modifier toutes les notes
# recupere les etuds ayant une note
NotesDB = context._notes_getall(evaluation_id)
- elif context.can_edit_notes(authuser, E["moduleimpl_id"], allow_ens=True):
+ elif can_edit_notes(context, authuser, E["moduleimpl_id"], allow_ens=True):
# Enseignant associé au module: ne peut supprimer que les notes qu'il a saisi
NotesDB = context._notes_getall(evaluation_id, by_uid=str(authuser))
else:
raise AccessDenied("Modification des notes impossible pour %s" % authuser)
- notes = [(etudid, NOTES_SUPPRESS) for etudid in NotesDB.keys()]
+ notes = [(etudid, scu.NOTES_SUPPRESS) for etudid in NotesDB.keys()]
if not dialog_confirmed:
nb_changed, nb_suppress, existing_decisions = _notes_add(
@@ -399,10 +447,9 @@ def evaluation_suppress_alln(context, evaluation_id, REQUEST, dialog_confirmed=F
% E["moduleimpl_id"]
]
# news
- M = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
+ M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0]
mod = context.do_module_list(args={"module_id": M["module_id"]})[0]
mod["moduleimpl_id"] = M["moduleimpl_id"]
- cnx = context.GetDBConnexion()
mod["url"] = "Notes/moduleimpl_status?moduleimpl_id=%(moduleimpl_id)s" % mod
sco_news.add(
context,
@@ -450,7 +497,7 @@ def _notes_add(context, uid, evaluation_id, notes, comment=None, do_it=True):
nb_changed = 0
nb_suppress = 0
E = context.do_evaluation_list({"evaluation_id": evaluation_id})[0]
- M = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
+ M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0]
existing_decisions = (
[]
) # etudids pour lesquels il y a une decision de jury et que la note change
@@ -459,7 +506,7 @@ def _notes_add(context, uid, evaluation_id, notes, comment=None, do_it=True):
changed = False
if not NotesDB.has_key(etudid):
# nouvelle note
- if value != NOTES_SUPPRESS:
+ if value != scu.NOTES_SUPPRESS:
if do_it:
aa = {
"etudid": etudid,
@@ -481,7 +528,7 @@ def _notes_add(context, uid, evaluation_id, notes, comment=None, do_it=True):
if type(value) != type(oldval):
changed = True
elif type(value) == type(1.0) and (
- abs(value - oldval) > NOTES_PRECISION
+ abs(value - oldval) > scu.NOTES_PRECISION
):
changed = True
elif value != oldval:
@@ -502,7 +549,7 @@ def _notes_add(context, uid, evaluation_id, notes, comment=None, do_it=True):
"uid": uid,
}
quote_dict(aa)
- if value != NOTES_SUPPRESS:
+ if value != scu.NOTES_SUPPRESS:
if do_it:
cursor.execute(
"update notes_notes set value=%(value)s, comment=%(comment)s, date=%(date)s, uid=%(uid)s where etudid=%(etudid)s and evaluation_id=%(evaluation_id)s",
@@ -519,7 +566,7 @@ def _notes_add(context, uid, evaluation_id, notes, comment=None, do_it=True):
aa,
)
# garde trace de la suppression dans l'historique:
- aa["value"] = NOTES_SUPPRESS
+ aa["value"] = scu.NOTES_SUPPRESS
cursor.execute(
"insert into notes_notes_log (etudid,evaluation_id,value,comment,date,uid) values (%(etudid)s, %(evaluation_id)s, %(value)s, %(comment)s, %(date)s, %(uid)s)",
aa,
@@ -553,9 +600,9 @@ def saisie_notes_tableur(context, evaluation_id, group_ids=[], REQUEST=None):
if not evals:
raise ScoValueError("invalid evaluation_id")
E = evals[0]
- M = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
+ M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0]
formsemestre_id = M["formsemestre_id"]
- if not context.can_edit_notes(authuser, E["moduleimpl_id"]):
+ if not can_edit_notes(context, authuser, E["moduleimpl_id"]):
return (
context.sco_header(REQUEST)
+ "Modification des notes impossible pour %s" % authusername
@@ -673,8 +720,8 @@ def saisie_notes_tableur(context, evaluation_id, group_ids=[], REQUEST=None):
)
#
H.append("""Autres opérations""")
- if context.can_edit_notes(
- REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
+ if can_edit_notes(
+ context, REQUEST.AUTHENTICATED_USER, E["moduleimpl_id"], allow_ens=False
):
H.append(
"""
@@ -728,14 +775,14 @@ def feuille_saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
if not evals:
raise ScoValueError("invalid evaluation_id")
E = evals[0]
- M = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
+ M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0]
formsemestre_id = M["formsemestre_id"]
Mod = context.do_module_list(args={"module_id": M["module_id"]})[0]
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
if E["jour"]:
indication_date = DateDMYtoISO(E["jour"])
else:
- indication_date = sanitize_filename(E["description"])[:12]
+ indication_date = scu.sanitize_filename(E["description"])[:12]
evalname = "%s-%s" % (Mod["code"], indication_date)
if E["description"]:
@@ -746,7 +793,7 @@ def feuille_saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
evaltitre,
Mod["abbrev"],
Mod["code"],
- strcapitalize(M["responsable_id"]),
+ scu.strcapitalize(M["responsable_id"]),
)
groups_infos = sco_groups_view.DisplayedGroupsInfos(
@@ -769,8 +816,6 @@ def feuille_saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
etudids = sco_groups.do_evaluation_listeetuds_groups(
context, evaluation_id, groups, getallstudents=getallstudents, include_dems=True
)
- # Notes existantes
- NotesDB = context._notes_getall(evaluation_id)
# une liste de liste de chaines: lignes de la feuille de calcul
L = []
@@ -784,8 +829,8 @@ def feuille_saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
L.append(
[
"%s" % etudid,
- strupper(e["nom"]),
- strcapitalize(strlower(e["prenom"])),
+ scu.strupper(e["nom"]),
+ scu.strcapitalize(scu.strlower(e["prenom"])),
e["inscr"]["etat"],
grc,
e["val"],
@@ -831,11 +876,13 @@ def saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
if not evals:
raise ScoValueError("invalid evaluation_id")
E = evals[0]
- M = context.do_moduleimpl_withmodule_list(moduleimpl_id=E["moduleimpl_id"])[0]
+ M = sco_moduleimpl.do_moduleimpl_withmodule_list(
+ context, moduleimpl_id=E["moduleimpl_id"]
+ )[0]
formsemestre_id = M["formsemestre_id"]
# Check access
# (admin, respformation, and responsable_id)
- if not context.can_edit_notes(authuser, E["moduleimpl_id"]):
+ if not can_edit_notes(context, authuser, E["moduleimpl_id"]):
return (
context.sco_header(REQUEST)
+ "Modification des notes impossible pour %s" % authusername
@@ -880,7 +927,7 @@ def saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
H.append(sco_groups_view.form_groups_choice(context, groups_infos))
H.append(' | ')
H.append(
- makeMenu(
+ htmlutils.make_menu(
"Autres opérations",
[
{
@@ -1008,7 +1055,6 @@ def _form_saisie_notes(context, E, M, group_ids, REQUEST=None):
"""
evaluation_id = E["evaluation_id"]
formsemestre_id = M["formsemestre_id"]
- groups = sco_groups.listgroups(context, group_ids)
etudids = sco_groups.do_evaluation_listeetuds_groups(
context, evaluation_id, getallstudents=True, include_dems=True
@@ -1035,7 +1081,7 @@ def _form_saisie_notes(context, E, M, group_ids, REQUEST=None):
("comment", {"size": 44, "title": "Commentaire", "return_focus_next": True}),
("changed", {"default": "0", "input_type": "hidden"}), # changed in JS
]
- if M["module"]["module_type"] == MODULE_STANDARD:
+ if M["module"]["module_type"] == scu.MODULE_STANDARD:
descr.append(
(
"s3",
@@ -1048,7 +1094,7 @@ def _form_saisie_notes(context, E, M, group_ids, REQUEST=None):
},
)
)
- elif M["module"]["module_type"] == MODULE_MALUS:
+ elif M["module"]["module_type"] == scu.MODULE_MALUS:
descr.append(
(
"s3",
@@ -1186,12 +1232,12 @@ def save_note(
% (evaluation_id, etudid, authuser, value)
)
E = context.do_evaluation_list({"evaluation_id": evaluation_id})[0]
- M = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
+ M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0]
Mod = context.do_module_list(args={"module_id": M["module_id"]})[0]
Mod["url"] = "Notes/moduleimpl_status?moduleimpl_id=%(moduleimpl_id)s" % M
result = {"nbchanged": 0} # JSON
# Check access: admin, respformation, or responsable_id
- if not context.can_edit_notes(authuser, E["moduleimpl_id"]):
+ if not can_edit_notes(context, authuser, E["moduleimpl_id"]):
result["status"] = "unauthorized"
else:
L, invalids, withoutnotes, absents, tosuppress = _check_notes(
@@ -1219,9 +1265,7 @@ def save_note(
else:
result["history_menu"] = "" # no update needed
result["status"] = "ok"
-
- # time.sleep(5)
- return sendJSON(REQUEST, result)
+ return scu.sendJSON(REQUEST, result)
def get_note_history_menu(context, evaluation_id, etudid):
diff --git a/sco_trombino.py b/sco_trombino.py
index 04ffb314..798b2368 100644
--- a/sco_trombino.py
+++ b/sco_trombino.py
@@ -44,7 +44,7 @@ import sco_formsemestre
import sco_groups
import sco_groups_view
import sco_portal_apogee
-from sco_formsemestre_status import makeMenu
+import htmlutils
from sco_pdf import *
import ImportScolars
import sco_excel
@@ -119,7 +119,9 @@ def trombino_html(context, groups_infos, REQUEST=None):
]
if groups_infos.members:
H.append(
- " | " + makeMenu("Gérer les photos", menuTrombi, alone=True) + " | "
+ ""
+ + htmlutils.make_menu("Gérer les photos", menuTrombi, alone=True)
+ + " | "
)
H.append("
")
H.append("")
diff --git a/sco_ue_external.py b/sco_ue_external.py
index 3c3677bd..ba7bb931 100644
--- a/sco_ue_external.py
+++ b/sco_ue_external.py
@@ -58,6 +58,7 @@ from notesdb import *
from sco_utils import *
from notes_log import log
import sco_formsemestre
+import sco_moduleimpl
import sco_edit_ue
import sco_saisie_notes
import sco_codes_parcours
@@ -117,14 +118,15 @@ def external_ue_create(
REQUEST,
)
- moduleimpl_id = context.do_moduleimpl_create(
+ moduleimpl_id = sco_moduleimpl.do_moduleimpl_create(
+ context,
{
"module_id": module_id,
"formsemestre_id": formsemestre_id,
"responsable_id": sem["responsables"][
0
], # affecte le 1er responsable du semestre comme resp. du module
- }
+ },
)
return moduleimpl_id
@@ -138,8 +140,8 @@ def external_ue_inscrit_et_note(
% (moduleimpl_id, notes_etuds)
)
# Inscription des étudiants
- context.do_moduleimpl_inscrit_etuds(
- moduleimpl_id, formsemestre_id, notes_etuds.keys(), REQUEST=REQUEST
+ sco_moduleimpl.do_moduleimpl_inscrit_etuds(
+ context, moduleimpl_id, formsemestre_id, notes_etuds.keys(), REQUEST=REQUEST
)
# Création d'une évaluation si il n'y en a pas déjà:
diff --git a/sco_undo_notes.py b/sco_undo_notes.py
index ef612000..43f6e730 100644
--- a/sco_undo_notes.py
+++ b/sco_undo_notes.py
@@ -53,7 +53,7 @@ from notesdb import *
from notes_log import log
from gen_tables import GenTable
import sco_formsemestre
-
+import sco_moduleimpl
# deux notes (de même uid) sont considérées comme de la même opération si
# elles sont séparées de moins de 2*tolerance:
@@ -138,7 +138,7 @@ def list_operations(context, evaluation_id):
def evaluation_list_operations(context, REQUEST, evaluation_id):
"""Page listing operations on evaluation"""
E = context.do_evaluation_list({"evaluation_id": evaluation_id})[0]
- M = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
+ M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0]
Ops = list_operations(context, evaluation_id)
diff --git a/scolars.py b/scolars.py
index 3a21bb1c..7a17a772 100644
--- a/scolars.py
+++ b/scolars.py
@@ -27,14 +27,24 @@
""" Accès donnees etudiants
"""
+import time
-from sco_utils import *
-
-from notesdb import *
+import sco_utils as scu
+from sco_utils import SCO_ENCODING
+from sco_exceptions import ScoGenError, ScoValueError
+from notesdb import (
+ EditableTable,
+ ScoDocCursor,
+ DateDMYtoISO,
+ DateISOtoDMY,
+ int_null_is_null,
+)
+from notes_log import log
from TrivialFormulator import TrivialFormulator
import safehtml
from scolog import logdb
-from notes_table import *
+
+# from notes_table import *
import sco_news
# XXXXXXXXX HACK: zope 2.7.7 bug turaround ?
@@ -42,11 +52,13 @@ import locale
locale.setlocale(locale.LC_ALL, ("en_US", SCO_ENCODING))
-from email.MIMEMultipart import MIMEMultipart
-from email.MIMEText import MIMEText
-from email.MIMEBase import MIMEBase
-from email.Header import Header
-from email import Encoders
+from email.MIMEMultipart import ( # pylint: disable=no-name-in-module,import-error
+ MIMEMultipart,
+)
+from email.MIMEText import MIMEText # pylint: disable=no-name-in-module,import-error
+from email.MIMEBase import MIMEBase # pylint: disable=no-name-in-module,import-error
+from email.Header import Header # pylint: disable=no-name-in-module,import-error
+from email import Encoders # pylint: disable=no-name-in-module,import-error
abbrvmonthsnames = [
"Jan ",
@@ -111,7 +123,7 @@ def format_etud_ident(etud):
def force_uppercase(s):
if s:
- s = strupper(s)
+ s = scu.strupper(s)
return s
@@ -145,13 +157,13 @@ def format_nom(s, uppercase=True):
if not s:
return ""
if uppercase:
- return strupper(s)
+ return scu.strupper(s)
else:
return format_prenom(s)
def format_sexe(sexe):
- sexe = strlower(sexe)
+ sexe = scu.strlower(sexe)
if sexe == "mr" or sexe == "m." or sexe == "m":
return "M."
else:
@@ -160,7 +172,7 @@ def format_sexe(sexe):
def normalize_sexe(sexe):
"returns 'MR' ou 'MME'"
- sexe = strupper(sexe).strip()
+ sexe = scu.strupper(sexe).strip()
if sexe in ("M.", "M", "MR", "H"):
return "MR"
elif sexe in ("MLLE", "MLLE.", "MELLE", "MME", "F"):
@@ -170,7 +182,7 @@ def normalize_sexe(sexe):
def format_lycee(nomlycee):
nomlycee = nomlycee.strip()
- s = strlower(nomlycee)
+ s = scu.strlower(nomlycee)
if s[:5] == "lycee" or s[:5] == "lycée":
return nomlycee[5:]
else:
@@ -200,7 +212,7 @@ def format_telephone(n):
def format_pays(s):
"laisse le pays seulement si != FRANCE"
- if strupper(s) != "FRANCE":
+ if scu.strupper(s) != "FRANCE":
return s
else:
return ""
@@ -279,13 +291,13 @@ def check_nom_prenom(cnx, nom="", prenom="", etudid=None):
Returns:
True | False, NbHomonyms
"""
- if not nom or (not prenom and not CONFIG.ALLOW_NULL_PRENOM):
+ if not nom or (not prenom and not scu.CONFIG.ALLOW_NULL_PRENOM):
return False, 0
nom = nom.decode(SCO_ENCODING).lower().strip().encode(SCO_ENCODING)
if prenom:
prenom = prenom.decode(SCO_ENCODING).lower().strip().encode(SCO_ENCODING)
# Don't allow some special cars (eg used in sql regexps)
- if FORBIDDEN_CHARS_EXP.search(nom) or FORBIDDEN_CHARS_EXP.search(prenom):
+ if scu.FORBIDDEN_CHARS_EXP.search(nom) or scu.FORBIDDEN_CHARS_EXP.search(prenom):
return False, 0
# Now count homonyms:
cursor = cnx.cursor(cursor_factory=ScoDocCursor)
@@ -540,7 +552,7 @@ _admissionEditor = EditableTable(
"classement": int_null_is_null,
"apb_classsment_gr": int_null_is_null,
},
- output_formators={"type_admission": lambda x: x or TYPE_ADMISSION_DEFAULT},
+ output_formators={"type_admission": lambda x: x or scu.TYPE_ADMISSION_DEFAULT},
convert_null_outputs_to_empty=True,
)
@@ -575,7 +587,7 @@ class EtudIdentEditor:
# print "*** pas d'info admission pour %s" % str(i)
void_adm = {
k: None
- for k in scolars._admissionEditor.dbfields
+ for k in _admissionEditor.dbfields
if k != "etudid" and k != "adm_id"
}
res[-1].update(void_adm)
@@ -657,7 +669,7 @@ def create_etud(context, cnx, args={}, REQUEST=None):
etudid=etudid,
msg="creation initiale",
)
- etud = scolars.etudident_list(cnx, {"etudid": etudid})[0]
+ etud = etudident_list(cnx, {"etudid": etudid})[0]
context.fillEtudsInfo([etud])
etud["url"] = "ficheEtud?etudid=%(etudid)s" % etud
sco_news.add(
@@ -766,7 +778,7 @@ appreciations_edit = _appreciationsEditor.edit
# -------- Noms des Lycées à partir du code
def read_etablissements():
- filename = SCO_SRCDIR + "/" + CONFIG.ETABL_FILENAME
+ filename = scu.SCO_SRCDIR + "/" + scu.CONFIG.ETABL_FILENAME
log("reading %s" % filename)
f = open(filename)
L = [x[:-1].split(";") for x in f]
diff --git a/scotests/sco_fake_gen.py b/scotests/sco_fake_gen.py
index f0df52bf..9caaaa77 100644
--- a/scotests/sco_fake_gen.py
+++ b/scotests/sco_fake_gen.py
@@ -27,6 +27,7 @@ import scolars
import sco_formsemestre
import sco_formsemestre_inscriptions
import sco_formsemestre_validation
+import sco_moduleimpl
import sco_synchro_etuds
import sco_edit_formation
import sco_edit_ue
@@ -233,8 +234,10 @@ class ScoFake:
formsemestre_id=None,
responsable_id=None,
):
- oid = self.context.do_moduleimpl_create(locals())
- oids = self.context.do_moduleimpl_list(moduleimpl_id=oid) # API inconsistency
+ oid = sco_moduleimpl.do_moduleimpl_create(self.context, locals())
+ oids = sco_moduleimpl.do_moduleimpl_list(
+ self.context, moduleimpl_id=oid
+ ) # API inconsistency
if not oids:
raise ScoValueError("moduleimpl not created !")
return oids[0]
diff --git a/scotests/test_bonusmalus.py b/scotests/test_bonusmalus.py
index a10a222b..c2a629d0 100644
--- a/scotests/test_bonusmalus.py
+++ b/scotests/test_bonusmalus.py
@@ -14,6 +14,7 @@ Utiliser comme:
import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error
import sco_utils as scu
+import sco_moduleimpl
G = sco_fake_gen.ScoFake(context.Notes) # pylint: disable=undefined-variable
G.verbose = False
@@ -45,7 +46,10 @@ sem, eval_list = G.setup_formsemestre(
)
# --- Recupère le module de malus
-modimpls = context.Notes.do_moduleimpl_list(formsemestre_id=sem["formsemestre_id"])
+modimpls = sco_moduleimpl.do_moduleimpl_list(
+ context, # pylint: disable=undefined-variable
+ formsemestre_id=sem["formsemestre_id"],
+)
# de façon tout à fait inefficace ;-)
moduleimpl_malus = [m for m in modimpls if m["module_id"] == mod_malus["module_id"]][0]
# et l'évaluation de malus, de la même façon: