forked from ScoDoc/ScoDoc
pylint
This commit is contained in:
parent
cf091d2c1a
commit
ec006442c4
@ -27,15 +27,23 @@
|
||||
|
||||
"""Evaluations
|
||||
"""
|
||||
import time
|
||||
import urllib
|
||||
import operator
|
||||
import datetime
|
||||
|
||||
from notes_log import log, logCallStack
|
||||
from sco_utils import *
|
||||
from notesdb import *
|
||||
import sco_utils as scu
|
||||
from notesdb import ScoDocCursor
|
||||
from sco_exceptions import AccessDenied, ScoValueError
|
||||
import VERSION
|
||||
from gen_tables import GenTable
|
||||
from TrivialFormulator import TrivialFormulator
|
||||
import sco_news
|
||||
import sco_formsemestre
|
||||
import sco_groups
|
||||
import ZAbsences
|
||||
import sco_evaluations
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
#
|
||||
@ -47,7 +55,7 @@ def notes_moyenne_median_mini_maxi(notes):
|
||||
notes = [
|
||||
x
|
||||
for x in notes
|
||||
if (x != None) and (x != NOTES_NEUTRALISE) and (x != NOTES_ATTENTE)
|
||||
if (x != None) and (x != scu.NOTES_NEUTRALISE) and (x != scu.NOTES_ATTENTE)
|
||||
]
|
||||
n = len(notes)
|
||||
if not n:
|
||||
@ -136,8 +144,8 @@ def do_evaluation_etat(
|
||||
NotesDB = context._notes_getall(evaluation_id) # { etudid : value }
|
||||
notes = [x["value"] for x in NotesDB.values()]
|
||||
nb_abs = len([x for x in notes if x is None])
|
||||
nb_neutre = len([x for x in notes if x == NOTES_NEUTRALISE])
|
||||
nb_att = len([x for x in notes if x == NOTES_ATTENTE])
|
||||
nb_neutre = len([x for x in notes if x == scu.NOTES_NEUTRALISE])
|
||||
nb_att = len([x for x in notes if x == scu.NOTES_ATTENTE])
|
||||
moy_num, median_num, mini_num, maxi_num = notes_moyenne_median_mini_maxi(notes)
|
||||
if moy_num is None:
|
||||
median, moy = "", ""
|
||||
@ -145,10 +153,10 @@ def do_evaluation_etat(
|
||||
mini, maxi = "", ""
|
||||
mini_num, maxi_num = None, None
|
||||
else:
|
||||
median = fmt_note(median_num)
|
||||
moy = fmt_note(moy_num)
|
||||
mini = fmt_note(mini_num)
|
||||
maxi = fmt_note(maxi_num)
|
||||
median = scu.fmt_note(median_num)
|
||||
moy = scu.fmt_note(moy_num)
|
||||
mini = scu.fmt_note(mini_num)
|
||||
maxi = scu.fmt_note(maxi_num)
|
||||
# cherche date derniere modif note
|
||||
if len(NotesDB):
|
||||
t = [x["date"] for x in NotesDB.values()]
|
||||
@ -159,7 +167,7 @@ def do_evaluation_etat(
|
||||
E = context.do_evaluation_list(args={"evaluation_id": evaluation_id})[0]
|
||||
M = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
|
||||
Mod = context.do_module_list(args={"module_id": M["module_id"]})[0]
|
||||
is_malus = Mod["module_type"] == MODULE_MALUS # True si module de malus
|
||||
is_malus = Mod["module_type"] == scu.MODULE_MALUS # True si module de malus
|
||||
formsemestre_id = M["formsemestre_id"]
|
||||
# Si partition_id is None, prend 'all' ou bien la premiere:
|
||||
if partition_id is None:
|
||||
@ -186,8 +194,8 @@ def do_evaluation_etat(
|
||||
|
||||
# On considere une note "manquante" lorsqu'elle n'existe pas
|
||||
# ou qu'elle est en attente (ATT)
|
||||
GrNbMissing = DictDefault() # group_id : nb notes manquantes
|
||||
GrNotes = DictDefault(defaultvalue=[]) # group_id: liste notes valides
|
||||
GrNbMissing = scu.DictDefault() # group_id : nb notes manquantes
|
||||
GrNotes = scu.DictDefault(defaultvalue=[]) # group_id: liste notes valides
|
||||
TotalNbMissing = 0
|
||||
TotalNbAtt = 0
|
||||
groups = {} # group_id : group
|
||||
@ -201,14 +209,14 @@ def do_evaluation_etat(
|
||||
isMissing = False
|
||||
if NotesDB.has_key(i["etudid"]):
|
||||
val = NotesDB[i["etudid"]]["value"]
|
||||
if val == NOTES_ATTENTE:
|
||||
if val == scu.NOTES_ATTENTE:
|
||||
isMissing = True
|
||||
TotalNbAtt += 1
|
||||
if group:
|
||||
GrNotes[group["group_id"]].append(val)
|
||||
else:
|
||||
if group:
|
||||
junk = GrNotes[group["group_id"]] # create group
|
||||
_ = GrNotes[group["group_id"]] # create group
|
||||
isMissing = True
|
||||
if isMissing:
|
||||
TotalNbMissing += 1
|
||||
@ -219,7 +227,7 @@ def do_evaluation_etat(
|
||||
gr_incomplets.sort()
|
||||
if (
|
||||
(TotalNbMissing > 0)
|
||||
and (E["evaluation_type"] != EVALUATION_RATTRAPAGE)
|
||||
and (E["evaluation_type"] != scu.EVALUATION_RATTRAPAGE)
|
||||
and not is_malus
|
||||
):
|
||||
complete = False
|
||||
@ -244,15 +252,15 @@ def do_evaluation_etat(
|
||||
"group_id": group_id,
|
||||
"group_name": groups[group_id]["group_name"],
|
||||
"gr_moy_num": gr_moy,
|
||||
"gr_moy": fmt_note(gr_moy),
|
||||
"gr_moy": scu.fmt_note(gr_moy),
|
||||
"gr_median_num": gr_median,
|
||||
"gr_median": fmt_note(gr_median),
|
||||
"gr_mini": fmt_note(gr_mini),
|
||||
"gr_maxi": fmt_note(gr_maxi),
|
||||
"gr_mini": gr_mini,
|
||||
"gr_maxi": gr_maxi,
|
||||
"gr_median": scu.fmt_note(gr_median),
|
||||
"gr_mini": scu.fmt_note(gr_mini),
|
||||
"gr_maxi": scu.fmt_note(gr_maxi),
|
||||
"gr_mini_num": gr_mini,
|
||||
"gr_maxi_num": gr_maxi,
|
||||
"gr_nb_notes": len(notes),
|
||||
"gr_nb_att": len([x for x in notes if x == NOTES_ATTENTE]),
|
||||
"gr_nb_att": len([x for x in notes if x == scu.NOTES_ATTENTE]),
|
||||
}
|
||||
)
|
||||
gr_moyennes.sort(key=operator.itemgetter("group_name"))
|
||||
@ -380,7 +388,7 @@ def _eval_etat(evals):
|
||||
nb_evals_en_cours += 1
|
||||
dates.append(e["etat"]["last_modif"])
|
||||
|
||||
dates = sort_dates(dates)
|
||||
dates = scu.sort_dates(dates)
|
||||
|
||||
if len(dates):
|
||||
last_modif = dates[-1] # date de derniere modif d'une note dans un module
|
||||
@ -511,18 +519,18 @@ def evaluation_date_first_completion(context, evaluation_id):
|
||||
if not etat["evalcomplete"]:
|
||||
return None
|
||||
|
||||
E = context.do_evaluation_list(args={"evaluation_id": evaluation_id})[0]
|
||||
M = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
|
||||
formsemestre_id = M["formsemestre_id"]
|
||||
|
||||
# XXX inachevé ou à revoir ?
|
||||
# Il faut considerer les inscriptions au semestre
|
||||
# (pour avoir l'etat et le groupe) et aussi les inscriptions
|
||||
# au module (pour gerer les modules optionnels correctement)
|
||||
insem = context.do_formsemestre_inscription_listinscrits(formsemestre_id)
|
||||
insmod = context.do_moduleimpl_inscription_list(moduleimpl_id=E["moduleimpl_id"])
|
||||
insmodset = set([x["etudid"] for x in insmod])
|
||||
# E = context.do_evaluation_list(args={"evaluation_id": evaluation_id})[0]
|
||||
# M = context.do_moduleimpl_list(moduleimpl_id=E["moduleimpl_id"])[0]
|
||||
# formsemestre_id = M["formsemestre_id"]
|
||||
# insem = context.do_formsemestre_inscription_listinscrits(formsemestre_id)
|
||||
# insmod = context.do_moduleimpl_inscription_list(moduleimpl_id=E["moduleimpl_id"])
|
||||
# insmodset = set([x["etudid"] for x in insmod])
|
||||
# retire de insem ceux qui ne sont pas inscrits au module
|
||||
ins = [i for i in insem if i["etudid"] in insmodset]
|
||||
# ins = [i for i in insem if i["etudid"] in insmodset]
|
||||
|
||||
notes = context._notes_getall(evaluation_id, filter_suppressed=False).values()
|
||||
notes_log = context._notes_getall(
|
||||
@ -560,8 +568,8 @@ def formsemestre_evaluations_delai_correction(
|
||||
for e in evals:
|
||||
M = context.do_moduleimpl_list(moduleimpl_id=e["moduleimpl_id"])[0]
|
||||
Mod = context.do_module_list(args={"module_id": M["module_id"]})[0]
|
||||
if (e["evaluation_type"] != EVALUATION_NORMALE) or (
|
||||
Mod["module_type"] == MODULE_MALUS
|
||||
if (e["evaluation_type"] != scu.EVALUATION_NORMALE) or (
|
||||
Mod["module_type"] == scu.MODULE_MALUS
|
||||
):
|
||||
continue
|
||||
e["date_first_complete"] = evaluation_date_first_completion(
|
||||
@ -612,8 +620,8 @@ def formsemestre_evaluations_delai_correction(
|
||||
caption="Correction des évaluations du semestre",
|
||||
preferences=context.get_preferences(formsemestre_id),
|
||||
base_url="%s?formsemestre_id=%s" % (REQUEST.URL0, formsemestre_id),
|
||||
origin="Généré par %s le " % VERSION.SCONAME + timedate_human_repr() + "",
|
||||
filename=make_filename("evaluations_delais_" + sem["titreannee"]),
|
||||
origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "",
|
||||
filename=scu.make_filename("evaluations_delais_" + sem["titreannee"]),
|
||||
)
|
||||
return tab.make_page(context, format=format, REQUEST=REQUEST)
|
||||
|
||||
@ -727,7 +735,6 @@ def evaluation_describe(context, evaluation_id="", edit_in_place=True, REQUEST=N
|
||||
M = context.do_moduleimpl_list(moduleimpl_id=moduleimpl_id)[0]
|
||||
Mod = context.do_module_list(args={"module_id": M["module_id"]})[0]
|
||||
formsemestre_id = M["formsemestre_id"]
|
||||
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
|
||||
u = context.Users.user_info(M["responsable_id"])
|
||||
resp = u["prenomnom"]
|
||||
nomcomplet = u["nomcomplet"]
|
||||
@ -747,13 +754,13 @@ def evaluation_describe(context, evaluation_id="", edit_in_place=True, REQUEST=N
|
||||
etit = E["description"] or ""
|
||||
if etit:
|
||||
etit = ' "' + etit + '"'
|
||||
if Mod["module_type"] == MODULE_MALUS:
|
||||
if Mod["module_type"] == scu.MODULE_MALUS:
|
||||
etit += ' <span class="eval_malus">(points de malus)</span>'
|
||||
H = [
|
||||
'<span class="eval_title">Evaluation%s</span><p><b>Module : %s</b></p>'
|
||||
% (etit, mod_descr)
|
||||
]
|
||||
if Mod["module_type"] == MODULE_MALUS:
|
||||
if Mod["module_type"] == scu.MODULE_MALUS:
|
||||
# Indique l'UE
|
||||
ue = context.do_ue_list(args={"ue_id": Mod["ue_id"]})[0]
|
||||
H.append("<p><b>UE : %(acronyme)s</b></p>" % ue)
|
||||
@ -804,9 +811,9 @@ def evaluation_create_form(
|
||||
moduleimpl_id = the_eval["moduleimpl_id"]
|
||||
#
|
||||
M = context.do_moduleimpl_withmodule_list(moduleimpl_id=moduleimpl_id)[0]
|
||||
is_malus = M["module"]["module_type"] == MODULE_MALUS # True si module de malus
|
||||
is_malus = M["module"]["module_type"] == scu.MODULE_MALUS # True si module de malus
|
||||
formsemestre_id = M["formsemestre_id"]
|
||||
min_note_max = NOTES_PRECISION # le plus petit bareme possible
|
||||
min_note_max = scu.NOTES_PRECISION # le plus petit bareme possible
|
||||
if not readonly:
|
||||
try:
|
||||
context._evaluation_check_write_access(REQUEST, moduleimpl_id=moduleimpl_id)
|
||||
@ -853,17 +860,16 @@ def evaluation_create_form(
|
||||
# Note maximale actuelle dans cette eval ?
|
||||
etat = do_evaluation_etat(context, evaluation_id)
|
||||
if etat["maxi_num"] is not None:
|
||||
min_note_max = max(NOTES_PRECISION, etat["maxi_num"])
|
||||
min_note_max = max(scu.NOTES_PRECISION, etat["maxi_num"])
|
||||
else:
|
||||
min_note_max = NOTES_PRECISION
|
||||
min_note_max = scu.NOTES_PRECISION
|
||||
#
|
||||
if min_note_max > NOTES_PRECISION:
|
||||
min_note_max_str = fmt_note(min_note_max)
|
||||
if min_note_max > scu.NOTES_PRECISION:
|
||||
min_note_max_str = scu.fmt_note(min_note_max)
|
||||
else:
|
||||
min_note_max_str = "0"
|
||||
#
|
||||
Mod = context.do_module_list(args={"module_id": M["module_id"]})[0]
|
||||
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
|
||||
#
|
||||
help = """<div class="help"><p class="help">
|
||||
Le coefficient d'une évaluation n'est utilisé que pour pondérer les évaluations au sein d'un module.
|
||||
@ -973,7 +979,7 @@ def evaluation_create_form(
|
||||
"title": "Notes de 0 à",
|
||||
"explanation": "barème (note max actuelle: %s)" % min_note_max_str,
|
||||
"allow_null": False,
|
||||
"max_value": NOTES_MAX,
|
||||
"max_value": scu.NOTES_MAX,
|
||||
"min_value": min_note_max,
|
||||
},
|
||||
),
|
||||
@ -1008,7 +1014,7 @@ def evaluation_create_form(
|
||||
{
|
||||
"input_type": "menu",
|
||||
"title": "Modalité",
|
||||
"allowed_values": (EVALUATION_NORMALE, EVALUATION_RATTRAPAGE),
|
||||
"allowed_values": (scu.EVALUATION_NORMALE, scu.EVALUATION_RATTRAPAGE),
|
||||
"type": "int",
|
||||
"labels": ("Normale", "Rattrapage"),
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user