forked from ScoDoc/ScoDoc
Assiduites : champs "heure_deb" "heure_fin" timeline
This commit is contained in:
parent
9f357e1a2f
commit
83765b584e
@ -217,6 +217,14 @@
|
||||
}
|
||||
|
||||
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);
|
||||
fin = snapToQuarter(fin);
|
||||
let leftPercentage = (deb - t_start) / (t_end - t_start) * 100;
|
||||
@ -231,13 +239,13 @@
|
||||
|
||||
function snapHandlesToQuarters() {
|
||||
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) {
|
||||
lef = 0;
|
||||
}
|
||||
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) {
|
||||
wid = 100;
|
||||
}
|
||||
@ -251,10 +259,23 @@
|
||||
function computePercentage(a, b) {
|
||||
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();
|
||||
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>
|
||||
<style>
|
||||
.timeline-container {
|
||||
|
@ -262,6 +262,10 @@ def signal_assiduites_etud():
|
||||
|
||||
# Récupération de la date (par défaut la date du jour)
|
||||
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)
|
||||
|
||||
@ -320,7 +324,7 @@ def signal_assiduites_etud():
|
||||
date=date,
|
||||
morning=morning,
|
||||
lunch=lunch,
|
||||
timeline=_timeline(),
|
||||
timeline=_timeline(heures=",".join([f"'{s}'" for s in heures])),
|
||||
afternoon=afternoon,
|
||||
nonworkdays=_non_work_days(),
|
||||
forcer_module=sco_preferences.get_preference(
|
||||
@ -576,6 +580,10 @@ def signal_assiduites_group():
|
||||
formsemestre_id: int = request.args.get("formsemestre_id", -1)
|
||||
moduleimpl_id: int = request.args.get("moduleimpl_id")
|
||||
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)
|
||||
if group_ids is None:
|
||||
group_ids = []
|
||||
@ -701,7 +709,7 @@ def signal_assiduites_group():
|
||||
formsemestre_id=formsemestre_id,
|
||||
grp=sco_groups_view.menu_groups_choice(groups_infos),
|
||||
moduleimpl_select=_module_selector(formsemestre, moduleimpl_id),
|
||||
timeline=_timeline(),
|
||||
timeline=_timeline(heures=",".join([f"'{s}'" for s in heures])),
|
||||
nonworkdays=_non_work_days(),
|
||||
formsemestre_date_debut=str(formsemestre.date_debut),
|
||||
formsemestre_date_fin=str(formsemestre.date_fin),
|
||||
@ -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
|
||||
|
||||
@ -1483,6 +1491,7 @@ def _timeline(formsemestre_id: int = None) -> str:
|
||||
periode_defaut=sco_preferences.get_preference(
|
||||
"periode_defaut", formsemestre_id
|
||||
),
|
||||
heures=heures,
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user