1
0
forked from ScoDoc/ScoDoc

Saisie notes + import excel

This commit is contained in:
Emmanuel Viennet 2021-08-11 13:01:37 +02:00
parent 31b2e259a1
commit c3eb401fe1
5 changed files with 43 additions and 13 deletions

View File

@ -220,6 +220,7 @@ def DBSelectArgs(
except: except:
log('Exception in DBSelectArgs:\n\treq="%s"\n\tvals="%s"\n' % (req, vals)) log('Exception in DBSelectArgs:\n\treq="%s"\n\tvals="%s"\n' % (req, vals))
log(traceback.format_exc()) log(traceback.format_exc())
cnx.rollback()
raise ScoException() raise ScoException()
return cursor.dictfetchall() return cursor.dictfetchall()

View File

@ -1004,7 +1004,13 @@ def descr_situation_etud(context, etudid, ne=""):
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( cursor.execute(
"select I.formsemestre_id, I.etat from notes_formsemestre_inscription I, notes_formsemestre S where etudid=%(etudid)s and S.formsemestre_id = I.formsemestre_id and date_debut < now() and date_fin > now() order by S.date_debut desc;", """SELECT I.formsemestre_id, I.etat
FROM notes_formsemestre_inscription I, notes_formsemestre S
WHERE etudid=%(etudid)s
and S.id = I.formsemestre_id
and date_debut < now()
and date_fin > now()
ORDER BY S.date_debut DESC;""",
{"etudid": etudid}, {"etudid": etudid},
) )
r = cursor.dictfetchone() r = cursor.dictfetchone()

View File

@ -1473,7 +1473,11 @@ def listgroups(context, group_ids):
groups = [] groups = []
for group_id in group_ids: for group_id in group_ids:
cursor.execute( cursor.execute(
"SELECT gd.*, p.* FROM group_descr gd, partition p WHERE p.partition_id = gd.partition_id AND gd.group_id = %(group_id)s", """SELECT gd.*, p.*
FROM group_descr gd, partition p
WHERE p.id = gd.partition_id
AND gd.id = %(group_id)s
""",
{"group_id": group_id}, {"group_id": group_id},
) )
r = cursor.dictfetchall() r = cursor.dictfetchall()

View File

@ -48,7 +48,7 @@ from app.scodoc.sco_exceptions import (
) )
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission
from app.scodoc.TrivialFormulator import TrivialFormulator, TF from app.scodoc.TrivialFormulator import TrivialFormulator, TF
from app.scodoc import html_sco_header from app.scodoc import html_sco_header, sco_users
from app.scodoc import htmlutils from app.scodoc import htmlutils
from app.scodoc import sco_abs from app.scodoc import sco_abs
from app.scodoc import sco_cache from app.scodoc import sco_cache
@ -142,6 +142,7 @@ def _check_notes(notes, evaluation, mod):
for (etudid, note) in notes: for (etudid, note) in notes:
note = str(note).strip().upper() note = str(note).strip().upper()
etudid = int(etudid) #
if note[:3] == "DEM": if note[:3] == "DEM":
continue # skip ! continue # skip !
if note: if note:
@ -198,7 +199,7 @@ def do_evaluation_upload_xls(context, REQUEST):
diag.append("Erreur: format invalide ! (pas de ligne evaluation_id)") diag.append("Erreur: format invalide ! (pas de ligne evaluation_id)")
raise InvalidNoteValue() raise InvalidNoteValue()
eval_id = lines[i][0].strip()[1:] eval_id = int(lines[i][0].strip()[1:])
if eval_id != evaluation_id: if eval_id != evaluation_id:
diag.append( diag.append(
"Erreur: fichier invalide: le code d'évaluation de correspond pas ! ('%s' != '%s')" "Erreur: fichier invalide: le code d'évaluation de correspond pas ! ('%s' != '%s')"
@ -505,7 +506,13 @@ def _notes_add(
# recopie l'ancienne note dans notes_notes_log, puis update # recopie l'ancienne note dans notes_notes_log, puis update
if do_it: if do_it:
cursor.execute( cursor.execute(
"insert into notes_notes_log (etudid,evaluation_id,value,comment,date,uid) select etudid,evaluation_id,value,comment,date,uid from notes_notes where etudid=%(etudid)s and evaluation_id=%(evaluation_id)s", """INSERT INTO notes_notes_log
(etudid,evaluation_id,value,comment,date,uid)
SELECT etudid, evaluation_id, value, comment, date, uid
FROM notes_notes
WHERE etudid=%(etudid)s
and evaluation_id=%(evaluation_id)s
""",
{"etudid": etudid, "evaluation_id": evaluation_id}, {"etudid": etudid, "evaluation_id": evaluation_id},
) )
aa = { aa = {
@ -520,7 +527,11 @@ def _notes_add(
if value != scu.NOTES_SUPPRESS: if value != scu.NOTES_SUPPRESS:
if do_it: if do_it:
cursor.execute( 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", """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
""",
aa, aa,
) )
else: # suppression ancienne note else: # suppression ancienne note
@ -530,13 +541,18 @@ def _notes_add(
% (evaluation_id, etudid, oldval) % (evaluation_id, etudid, oldval)
) )
cursor.execute( cursor.execute(
"delete from notes_notes where etudid=%(etudid)s and evaluation_id=%(evaluation_id)s", """DELETE FROM notes_notes
WHERE etudid = %(etudid)s
AND evaluation_id = %(evaluation_id)s
""",
aa, aa,
) )
# garde trace de la suppression dans l'historique: # garde trace de la suppression dans l'historique:
aa["value"] = scu.NOTES_SUPPRESS aa["value"] = scu.NOTES_SUPPRESS
cursor.execute( 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)", """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, aa,
) )
nb_suppress += 1 nb_suppress += 1
@ -748,6 +764,7 @@ def feuille_saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
formsemestre_id = M["formsemestre_id"] formsemestre_id = M["formsemestre_id"]
Mod = sco_edit_module.do_module_list(context, args={"module_id": M["module_id"]})[0] Mod = sco_edit_module.do_module_list(context, args={"module_id": M["module_id"]})[0]
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"]) sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
mod_responsable = sco_users.user_info(M["responsable_id"])
if E["jour"]: if E["jour"]:
indication_date = ndb.DateDMYtoISO(E["jour"]) indication_date = ndb.DateDMYtoISO(E["jour"])
else: else:
@ -762,7 +779,7 @@ def feuille_saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
evaltitre, evaltitre,
Mod["abbrev"], Mod["abbrev"],
Mod["code"], Mod["code"],
scu.strcapitalize(M["responsable_id"]), mod_responsable["prenomnom"],
) )
groups_infos = sco_groups_view.DisplayedGroupsInfos( groups_infos = sco_groups_view.DisplayedGroupsInfos(
@ -1098,7 +1115,7 @@ def _form_saisie_notes(context, E, M, group_ids, destination="", REQUEST=None):
disabled_attr = "" disabled_attr = ""
# attribue a chaque element une classe css par groupe: # attribue a chaque element une classe css par groupe:
for group_info in e["groups"]: for group_info in e["groups"]:
etud_classes.append(group_info["group_id"]) etud_classes.append("group-" + str(group_info["group_id"]))
label = ( label = (
'<span class="%s">' % classdem '<span class="%s">' % classdem
@ -1144,7 +1161,9 @@ def _form_saisie_notes(context, E, M, group_ids, destination="", REQUEST=None):
], ],
"template": """<tr%(item_dom_attr)s class="etud_elem """ "template": """<tr%(item_dom_attr)s class="etud_elem """
+ " ".join(etud_classes) + " ".join(etud_classes)
+ """"><td class="tf-fieldlabel">%(label)s</td><td class="tf-field">%(elem)s</td></tr>""", + """"><td class="tf-fieldlabel">%(label)s</td>
<td class="tf-field">%(elem)s</td></tr>
""",
}, },
) )
) )
@ -1174,7 +1193,7 @@ def _form_saisie_notes(context, E, M, group_ids, destination="", REQUEST=None):
if tf.canceled(): if tf.canceled():
return None return None
elif (not tf.submitted()) or not tf.result: elif (not tf.submitted()) or not tf.result:
# ajout formularie saisie notes manquantes # ajout formulaire saisie notes manquantes
H.append( H.append(
""" """
<div> <div>

View File

@ -88,7 +88,7 @@ function toggle_visible_etuds() {
var qargs = ""; var qargs = "";
$("#group_ids_sel option:selected").each(function (index, opt) { $("#group_ids_sel option:selected").each(function (index, opt) {
var group_id = opt.value; var group_id = opt.value;
$("." + group_id).show(); $(".group-" + group_id).show();
qargs += "&group_ids=" + group_id; qargs += "&group_ids=" + group_id;
}); });
// Update url saisie tableur: // Update url saisie tableur: