forked from ScoDoc/ScoDoc
Assiduites : champs "heure_deb" "heure_fin" timeline
This commit is contained in:
parent
9f357e1a2f
commit
83765b584e
@ -131,12 +131,12 @@
|
|||||||
document.addEventListener(
|
document.addEventListener(
|
||||||
"mouseup",
|
"mouseup",
|
||||||
mouseUp,
|
mouseUp,
|
||||||
{once:true}
|
{ once: true }
|
||||||
);
|
);
|
||||||
document.addEventListener(
|
document.addEventListener(
|
||||||
"touchend",
|
"touchend",
|
||||||
mouseUp,
|
mouseUp,
|
||||||
{once:true}
|
{ once: true }
|
||||||
|
|
||||||
);
|
);
|
||||||
} else if (event.target === periodTimeLine) {
|
} else if (event.target === periodTimeLine) {
|
||||||
@ -217,6 +217,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setPeriodValues(deb, fin) {
|
function setPeriodValues(deb, fin) {
|
||||||
|
if (fin < deb) {
|
||||||
|
throw new RangeError(`le paramètre 'deb' doit être inférieur au paramètre 'fin' ([${deb};${fin}])`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deb < 0 || fin < 0) {
|
||||||
|
throw new RangeError(`Les paramètres doivent être des entiers positifis ([${deb};${fin}])`)
|
||||||
|
}
|
||||||
|
|
||||||
deb = snapToQuarter(deb);
|
deb = snapToQuarter(deb);
|
||||||
fin = snapToQuarter(fin);
|
fin = snapToQuarter(fin);
|
||||||
let leftPercentage = (deb - t_start) / (t_end - t_start) * 100;
|
let leftPercentage = (deb - t_start) / (t_end - t_start) * 100;
|
||||||
@ -231,13 +239,13 @@
|
|||||||
|
|
||||||
function snapHandlesToQuarters() {
|
function snapHandlesToQuarters() {
|
||||||
const periodValues = getPeriodValues();
|
const periodValues = getPeriodValues();
|
||||||
let lef = Math.min(computePercentage(periodValues[0], t_start), computePercentage(t_end, tick_delay));
|
let lef = Math.min(computePercentage(Math.abs(periodValues[0]), t_start), computePercentage(Math.abs(t_end), tick_delay));
|
||||||
if (lef < 0) {
|
if (lef < 0) {
|
||||||
lef = 0;
|
lef = 0;
|
||||||
}
|
}
|
||||||
const left = `${lef}%`;
|
const left = `${lef}%`;
|
||||||
|
|
||||||
let wid = Math.max(computePercentage(periodValues[1], periodValues[0]), computePercentage(tick_delay, 0));
|
let wid = Math.max(computePercentage(Math.abs(periodValues[1]), Math.abs(periodValues[0])), computePercentage(tick_delay, 0));
|
||||||
if (wid > 100) {
|
if (wid > 100) {
|
||||||
wid = 100;
|
wid = 100;
|
||||||
}
|
}
|
||||||
@ -251,10 +259,23 @@
|
|||||||
function computePercentage(a, b) {
|
function computePercentage(a, b) {
|
||||||
return ((a - b) / (t_end - t_start)) * 100;
|
return ((a - b) / (t_end - t_start)) * 100;
|
||||||
}
|
}
|
||||||
|
function fromTime(time, separator = ":") {
|
||||||
|
const [hours, minutes] = time.split(separator).map((el) => Number(el))
|
||||||
|
return hours + minutes / 60
|
||||||
|
}
|
||||||
|
|
||||||
createTicks();
|
createTicks();
|
||||||
setPeriodValues(t_start, t_start + period_default);
|
setPeriodValues(t_start, t_start + period_default);
|
||||||
|
|
||||||
|
{% if heures %}
|
||||||
|
let [heure_deb, heure_fin] = [{{ heures | safe }}]
|
||||||
|
if (heure_deb != '' && heure_fin != '') {
|
||||||
|
heure_deb = fromTime(heure_deb);
|
||||||
|
heure_fin = fromTime(heure_fin);
|
||||||
|
setPeriodValues(heure_deb, heure_fin)
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
.timeline-container {
|
.timeline-container {
|
||||||
|
@ -262,6 +262,10 @@ def signal_assiduites_etud():
|
|||||||
|
|
||||||
# Récupération de la date (par défaut la date du jour)
|
# Récupération de la date (par défaut la date du jour)
|
||||||
date = request.args.get("date", datetime.date.today().isoformat())
|
date = request.args.get("date", datetime.date.today().isoformat())
|
||||||
|
heures: list[str] = [
|
||||||
|
request.args.get("heure_deb", ""),
|
||||||
|
request.args.get("heure_fin", ""),
|
||||||
|
]
|
||||||
|
|
||||||
# gestion évaluations (Appel à la page depuis les évaluations)
|
# gestion évaluations (Appel à la page depuis les évaluations)
|
||||||
|
|
||||||
@ -320,7 +324,7 @@ def signal_assiduites_etud():
|
|||||||
date=date,
|
date=date,
|
||||||
morning=morning,
|
morning=morning,
|
||||||
lunch=lunch,
|
lunch=lunch,
|
||||||
timeline=_timeline(),
|
timeline=_timeline(heures=",".join([f"'{s}'" for s in heures])),
|
||||||
afternoon=afternoon,
|
afternoon=afternoon,
|
||||||
nonworkdays=_non_work_days(),
|
nonworkdays=_non_work_days(),
|
||||||
forcer_module=sco_preferences.get_preference(
|
forcer_module=sco_preferences.get_preference(
|
||||||
@ -576,6 +580,10 @@ def signal_assiduites_group():
|
|||||||
formsemestre_id: int = request.args.get("formsemestre_id", -1)
|
formsemestre_id: int = request.args.get("formsemestre_id", -1)
|
||||||
moduleimpl_id: int = request.args.get("moduleimpl_id")
|
moduleimpl_id: int = request.args.get("moduleimpl_id")
|
||||||
date: str = request.args.get("jour", datetime.date.today().isoformat())
|
date: str = request.args.get("jour", datetime.date.today().isoformat())
|
||||||
|
heures: list[str] = [
|
||||||
|
request.args.get("heure_deb", ""),
|
||||||
|
request.args.get("heure_fin", ""),
|
||||||
|
]
|
||||||
group_ids: list[int] = request.args.get("group_ids", None)
|
group_ids: list[int] = request.args.get("group_ids", None)
|
||||||
if group_ids is None:
|
if group_ids is None:
|
||||||
group_ids = []
|
group_ids = []
|
||||||
@ -701,7 +709,7 @@ def signal_assiduites_group():
|
|||||||
formsemestre_id=formsemestre_id,
|
formsemestre_id=formsemestre_id,
|
||||||
grp=sco_groups_view.menu_groups_choice(groups_infos),
|
grp=sco_groups_view.menu_groups_choice(groups_infos),
|
||||||
moduleimpl_select=_module_selector(formsemestre, moduleimpl_id),
|
moduleimpl_select=_module_selector(formsemestre, moduleimpl_id),
|
||||||
timeline=_timeline(),
|
timeline=_timeline(heures=",".join([f"'{s}'" for s in heures])),
|
||||||
nonworkdays=_non_work_days(),
|
nonworkdays=_non_work_days(),
|
||||||
formsemestre_date_debut=str(formsemestre.date_debut),
|
formsemestre_date_debut=str(formsemestre.date_debut),
|
||||||
formsemestre_date_fin=str(formsemestre.date_fin),
|
formsemestre_date_fin=str(formsemestre.date_fin),
|
||||||
@ -1259,12 +1267,12 @@ def generate_bul_list(etud: Identite, semestre: FormSemestre) -> str:
|
|||||||
assiduites, metric=metrique, filtered={"split": True}
|
assiduites, metric=metrique, filtered={"split": True}
|
||||||
)
|
)
|
||||||
|
|
||||||
# On sépare :
|
# On sépare :
|
||||||
# - abs_j = absences justifiées
|
# - abs_j = absences justifiées
|
||||||
# - abs_nj = absences non justifiées
|
# - abs_nj = absences non justifiées
|
||||||
# - retards = les retards
|
# - retards = les retards
|
||||||
# - justifs = les justificatifs
|
# - justifs = les justificatifs
|
||||||
|
|
||||||
abs_j: list[str] = [
|
abs_j: list[str] = [
|
||||||
{"date": _get_date_str(assi.date_debut, assi.date_fin)}
|
{"date": _get_date_str(assi.date_debut, assi.date_fin)}
|
||||||
for assi in assiduites
|
for assi in assiduites
|
||||||
@ -1463,7 +1471,7 @@ def _dynamic_module_selector() -> str:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _timeline(formsemestre_id: int = None) -> str:
|
def _timeline(formsemestre_id: int = None, heures=None) -> str:
|
||||||
"""
|
"""
|
||||||
_timeline retourne l'html de la timeline
|
_timeline retourne l'html de la timeline
|
||||||
|
|
||||||
@ -1483,6 +1491,7 @@ def _timeline(formsemestre_id: int = None) -> str:
|
|||||||
periode_defaut=sco_preferences.get_preference(
|
periode_defaut=sco_preferences.get_preference(
|
||||||
"periode_defaut", formsemestre_id
|
"periode_defaut", formsemestre_id
|
||||||
),
|
),
|
||||||
|
heures=heures,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user