forked from ScoDoc/DocScoDoc
Merge branch 'master' of https://scodoc.org/git/viennet/ScoDoc into table
This commit is contained in:
commit
8af28d2f36
@ -571,7 +571,10 @@ class DecisionsProposeesAnnee(DecisionsProposees):
|
||||
continue # ignore cette UE antérieure non capitalisée
|
||||
# et l'UE impaire doit être actuellement meilleure que
|
||||
# celle éventuellement capitalisée
|
||||
if self.decisions_ues[ue_impair.id].ue_status["is_capitalized"]:
|
||||
if (
|
||||
self.decisions_ues[ue_impair.id].ue_status
|
||||
and self.decisions_ues[ue_impair.id].ue_status["is_capitalized"]
|
||||
):
|
||||
continue # ignore cette UE car capitalisée et actuelle moins bonne
|
||||
if ue_pair.niveau_competence_id == ue_impair.niveau_competence_id:
|
||||
rcue = RegroupementCoherentUE(
|
||||
|
@ -25,7 +25,7 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
"""Gestion evaluations (ScoDoc7, sans SQlAlchemy)
|
||||
"""Gestion évaluations (ScoDoc7, code en voie de modernisation)
|
||||
"""
|
||||
|
||||
import pprint
|
||||
@ -34,16 +34,15 @@ import flask
|
||||
from flask import url_for, g
|
||||
from flask_login import current_user
|
||||
|
||||
from app import log
|
||||
from app import db, log
|
||||
|
||||
from app.models import ModuleImpl, ScolarNews
|
||||
from app.models import Evaluation, ModuleImpl, ScolarNews
|
||||
from app.models.evaluations import evaluation_enrich_dict, check_evaluation_args
|
||||
import app.scodoc.sco_utils as scu
|
||||
import app.scodoc.notesdb as ndb
|
||||
from app.scodoc.sco_exceptions import AccessDenied, ScoValueError
|
||||
|
||||
from app.scodoc import sco_cache
|
||||
from app.scodoc import sco_edit_module
|
||||
from app.scodoc import sco_moduleimpl
|
||||
from app.scodoc import sco_permissions_check
|
||||
|
||||
@ -135,7 +134,7 @@ def do_evaluation_create(
|
||||
raise ValueError("module not found")
|
||||
check_evaluation_args(args)
|
||||
# Check numeros
|
||||
module_evaluation_renumber(moduleimpl_id, only_if_unumbered=True)
|
||||
moduleimpl_evaluation_renumber(moduleimpl_id, only_if_unumbered=True)
|
||||
if not "numero" in args or args["numero"] is None:
|
||||
n = None
|
||||
# determine le numero avec la date
|
||||
@ -158,7 +157,7 @@ def do_evaluation_create(
|
||||
next_eval = e
|
||||
break
|
||||
if next_eval:
|
||||
n = module_evaluation_insert_before(mod_evals, next_eval)
|
||||
n = moduleimpl_evaluation_insert_before(mod_evals, next_eval)
|
||||
else:
|
||||
n = None # a placer en fin
|
||||
if n is None: # pas de date ou en fin:
|
||||
@ -215,13 +214,11 @@ def do_evaluation_edit(args):
|
||||
|
||||
def do_evaluation_delete(evaluation_id):
|
||||
"delete evaluation"
|
||||
the_evals = do_evaluation_list({"evaluation_id": evaluation_id})
|
||||
if not the_evals:
|
||||
raise ValueError("evaluation inexistante !")
|
||||
moduleimpl_id = the_evals[0]["moduleimpl_id"]
|
||||
if not sco_permissions_check.can_edit_evaluation(moduleimpl_id=moduleimpl_id):
|
||||
evaluation: Evaluation = Evaluation.query.get_or_404(evaluation_id)
|
||||
modimpl: ModuleImpl = evaluation.moduleimpl
|
||||
if not sco_permissions_check.can_edit_evaluation(moduleimpl_id=modimpl.id):
|
||||
raise AccessDenied(
|
||||
"Modification évaluation impossible pour %s" % current_user.get_nomplogin()
|
||||
f"Modification évaluation impossible pour {current_user.get_nomplogin()}"
|
||||
)
|
||||
notes_db = do_evaluation_get_all_notes(evaluation_id) # { etudid : value }
|
||||
notes = [x["value"] for x in notes_db.values()]
|
||||
@ -230,24 +227,24 @@ def do_evaluation_delete(evaluation_id):
|
||||
"Impossible de supprimer cette évaluation: il reste des notes"
|
||||
)
|
||||
|
||||
cnx = ndb.GetDBConnexion()
|
||||
db.session.delete(evaluation)
|
||||
db.session.commit()
|
||||
|
||||
_evaluationEditor.delete(cnx, evaluation_id)
|
||||
# inval cache pour ce semestre
|
||||
M = sco_moduleimpl.moduleimpl_list(moduleimpl_id=moduleimpl_id)[0]
|
||||
sco_cache.invalidate_formsemestre(formsemestre_id=M["formsemestre_id"])
|
||||
sco_cache.invalidate_formsemestre(formsemestre_id=modimpl.formsemestre_id)
|
||||
# news
|
||||
|
||||
mod = sco_edit_module.module_list(args={"module_id": M["module_id"]})[0]
|
||||
mod["moduleimpl_id"] = M["moduleimpl_id"]
|
||||
mod["url"] = (
|
||||
scu.NotesURL() + "/moduleimpl_status?moduleimpl_id=%(moduleimpl_id)s" % mod
|
||||
url = url_for(
|
||||
"notes.moduleimpl_status",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
moduleimpl_id=modimpl.id,
|
||||
)
|
||||
ScolarNews.add(
|
||||
typ=ScolarNews.NEWS_NOTE,
|
||||
obj=moduleimpl_id,
|
||||
text='Suppression d\'une évaluation dans <a href="%(url)s">%(titre)s</a>' % mod,
|
||||
url=mod["url"],
|
||||
obj=modimpl.id,
|
||||
text=f"""Suppression d'une évaluation dans <a href="{
|
||||
url
|
||||
}">{modimpl.module.titre}</a>""",
|
||||
url=url,
|
||||
)
|
||||
|
||||
|
||||
@ -263,7 +260,7 @@ def do_evaluation_get_all_notes(
|
||||
) # pas de cache pour (rares) appels via undo_notes ou specifiant un enseignant
|
||||
if do_cache:
|
||||
r = sco_cache.EvaluationCache.get(evaluation_id)
|
||||
if r != None:
|
||||
if r is not None:
|
||||
return r
|
||||
cnx = ndb.GetDBConnexion()
|
||||
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
|
||||
@ -291,13 +288,13 @@ def do_evaluation_get_all_notes(
|
||||
return d
|
||||
|
||||
|
||||
def module_evaluation_renumber(moduleimpl_id, only_if_unumbered=False, redirect=0):
|
||||
def moduleimpl_evaluation_renumber(moduleimpl_id, only_if_unumbered=False, redirect=0):
|
||||
"""Renumber evaluations in this module, according to their date. (numero=0: oldest one)
|
||||
Needed because previous versions of ScoDoc did not have eval numeros
|
||||
Note: existing numeros are ignored
|
||||
"""
|
||||
redirect = int(redirect)
|
||||
# log('module_evaluation_renumber( moduleimpl_id=%s )' % moduleimpl_id )
|
||||
# log('moduleimpl_evaluation_renumber( moduleimpl_id=%s )' % moduleimpl_id )
|
||||
# List sorted according to date/heure, ignoring numeros:
|
||||
# (note that we place evaluations with NULL date at the end)
|
||||
mod_evals = do_evaluation_list(
|
||||
@ -327,7 +324,7 @@ def module_evaluation_renumber(moduleimpl_id, only_if_unumbered=False, redirect=
|
||||
)
|
||||
|
||||
|
||||
def module_evaluation_insert_before(mod_evals, next_eval):
|
||||
def moduleimpl_evaluation_insert_before(mod_evals, next_eval):
|
||||
"""Renumber evals such that an evaluation with can be inserted before next_eval
|
||||
Returns numero suitable for the inserted evaluation
|
||||
"""
|
||||
@ -335,7 +332,7 @@ def module_evaluation_insert_before(mod_evals, next_eval):
|
||||
n = next_eval["numero"]
|
||||
if not n:
|
||||
log("renumbering old evals")
|
||||
module_evaluation_renumber(next_eval["moduleimpl_id"])
|
||||
moduleimpl_evaluation_renumber(next_eval["moduleimpl_id"])
|
||||
next_eval = do_evaluation_list(
|
||||
args={"evaluation_id": next_eval["evaluation_id"]}
|
||||
)[0]
|
||||
@ -353,19 +350,20 @@ def module_evaluation_insert_before(mod_evals, next_eval):
|
||||
return n
|
||||
|
||||
|
||||
def module_evaluation_move(evaluation_id, after=0, redirect=1):
|
||||
def moduleimpl_evaluation_move(evaluation_id: int, after=0, redirect=1):
|
||||
"""Move before/after previous one (decrement/increment numero)
|
||||
(published)
|
||||
"""
|
||||
e = do_evaluation_list(args={"evaluation_id": evaluation_id})[0]
|
||||
evaluation: Evaluation = Evaluation.query.get_or_404(evaluation_id)
|
||||
moduleimpl_id = evaluation.moduleimpl_id
|
||||
redirect = int(redirect)
|
||||
# access: can change eval ?
|
||||
if not sco_permissions_check.can_edit_evaluation(moduleimpl_id=e["moduleimpl_id"]):
|
||||
if not sco_permissions_check.can_edit_evaluation(moduleimpl_id=moduleimpl_id):
|
||||
raise AccessDenied(
|
||||
"Modification évaluation impossible pour %s" % current_user.get_nomplogin()
|
||||
f"Modification évaluation impossible pour {current_user.get_nomplogin()}"
|
||||
)
|
||||
|
||||
module_evaluation_renumber(e["moduleimpl_id"], only_if_unumbered=True)
|
||||
moduleimpl_evaluation_renumber(moduleimpl_id, only_if_unumbered=True)
|
||||
e = do_evaluation_list(args={"evaluation_id": evaluation_id})[0]
|
||||
|
||||
after = int(after) # 0: deplace avant, 1 deplace apres
|
||||
@ -381,8 +379,10 @@ def module_evaluation_move(evaluation_id, after=0, redirect=1):
|
||||
neigh = mod_evals[idx + 1]
|
||||
if neigh: #
|
||||
if neigh["numero"] == e["numero"]:
|
||||
log("Warning: module_evaluation_move: forcing renumber")
|
||||
module_evaluation_renumber(e["moduleimpl_id"], only_if_unumbered=False)
|
||||
log("Warning: moduleimpl_evaluation_move: forcing renumber")
|
||||
moduleimpl_evaluation_renumber(
|
||||
e["moduleimpl_id"], only_if_unumbered=False
|
||||
)
|
||||
else:
|
||||
# swap numero with neighbor
|
||||
e["numero"], neigh["numero"] = neigh["numero"], e["numero"]
|
||||
|
@ -433,7 +433,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
|
||||
if nb_evaluations > 0:
|
||||
top_table_links += f"""
|
||||
<a class="stdlink" style="margin-left:2em;" href="{
|
||||
url_for("notes.module_evaluation_renumber", scodoc_dept=g.scodoc_dept, moduleimpl_id=M['moduleimpl_id'],
|
||||
url_for("notes.moduleimpl_evaluation_renumber", scodoc_dept=g.scodoc_dept, moduleimpl_id=M['moduleimpl_id'],
|
||||
redirect=1)
|
||||
}">Trier par date</a>
|
||||
"""
|
||||
@ -601,7 +601,7 @@ def _ligne_evaluation(
|
||||
# Fleches:
|
||||
if eval_index != (nb_evals - 1) and can_edit_evals:
|
||||
H.append(
|
||||
f"""<a href="{url_for("notes.module_evaluation_move",
|
||||
f"""<a href="{url_for("notes.moduleimpl_evaluation_move",
|
||||
scodoc_dept=g.scodoc_dept, evaluation_id=evaluation.id, after=0)
|
||||
}" class="aud">{arrow_up}</a>"""
|
||||
)
|
||||
@ -609,7 +609,7 @@ def _ligne_evaluation(
|
||||
H.append(arrow_none)
|
||||
if (eval_index > 0) and can_edit_evals:
|
||||
H.append(
|
||||
f"""<a href="{url_for("notes.module_evaluation_move",
|
||||
f"""<a href="{url_for("notes.moduleimpl_evaluation_move",
|
||||
scodoc_dept=g.scodoc_dept, evaluation_id=evaluation.id, after=1)
|
||||
}" class="aud">{arrow_down}</a>"""
|
||||
)
|
||||
|
@ -367,13 +367,13 @@ sco_publish(
|
||||
Permission.ScoView,
|
||||
)
|
||||
sco_publish(
|
||||
"/module_evaluation_renumber",
|
||||
sco_evaluation_db.module_evaluation_renumber,
|
||||
"/moduleimpl_evaluation_renumber",
|
||||
sco_evaluation_db.moduleimpl_evaluation_renumber,
|
||||
Permission.ScoView,
|
||||
)
|
||||
sco_publish(
|
||||
"/module_evaluation_move",
|
||||
sco_evaluation_db.module_evaluation_move,
|
||||
"/moduleimpl_evaluation_move",
|
||||
sco_evaluation_db.moduleimpl_evaluation_move,
|
||||
Permission.ScoView,
|
||||
)
|
||||
sco_publish(
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- mode: python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
SCOVERSION = "9.4.32"
|
||||
SCOVERSION = "9.4.33"
|
||||
|
||||
SCONAME = "ScoDoc"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user