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:
log('Exception in DBSelectArgs:\n\treq="%s"\n\tvals="%s"\n' % (req, vals))
log(traceback.format_exc())
cnx.rollback()
raise ScoException()
return cursor.dictfetchall()

View File

@ -1004,7 +1004,13 @@ def descr_situation_etud(context, etudid, ne=""):
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
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},
)
r = cursor.dictfetchone()

View File

@ -1473,7 +1473,11 @@ def listgroups(context, group_ids):
groups = []
for group_id in group_ids:
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},
)
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.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 sco_abs
from app.scodoc import sco_cache
@ -142,6 +142,7 @@ def _check_notes(notes, evaluation, mod):
for (etudid, note) in notes:
note = str(note).strip().upper()
etudid = int(etudid) #
if note[:3] == "DEM":
continue # skip !
if note:
@ -198,7 +199,7 @@ def do_evaluation_upload_xls(context, REQUEST):
diag.append("Erreur: format invalide ! (pas de ligne evaluation_id)")
raise InvalidNoteValue()
eval_id = lines[i][0].strip()[1:]
eval_id = int(lines[i][0].strip()[1:])
if eval_id != evaluation_id:
diag.append(
"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
if do_it:
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},
)
aa = {
@ -520,7 +527,11 @@ def _notes_add(
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",
"""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,
)
else: # suppression ancienne note
@ -530,13 +541,18 @@ def _notes_add(
% (evaluation_id, etudid, oldval)
)
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,
)
# garde trace de la suppression dans l'historique:
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)",
"""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,
)
nb_suppress += 1
@ -748,6 +764,7 @@ def feuille_saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
formsemestre_id = M["formsemestre_id"]
Mod = sco_edit_module.do_module_list(context, args={"module_id": M["module_id"]})[0]
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
mod_responsable = sco_users.user_info(M["responsable_id"])
if E["jour"]:
indication_date = ndb.DateDMYtoISO(E["jour"])
else:
@ -762,7 +779,7 @@ def feuille_saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
evaltitre,
Mod["abbrev"],
Mod["code"],
scu.strcapitalize(M["responsable_id"]),
mod_responsable["prenomnom"],
)
groups_infos = sco_groups_view.DisplayedGroupsInfos(
@ -1098,7 +1115,7 @@ def _form_saisie_notes(context, E, M, group_ids, destination="", REQUEST=None):
disabled_attr = ""
# attribue a chaque element une classe css par groupe:
for group_info in e["groups"]:
etud_classes.append(group_info["group_id"])
etud_classes.append("group-" + str(group_info["group_id"]))
label = (
'<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 """
+ " ".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():
return None
elif (not tf.submitted()) or not tf.result:
# ajout formularie saisie notes manquantes
# ajout formulaire saisie notes manquantes
H.append(
"""
<div>

View File

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