forked from ScoDoc/ScoDoc
minor refactor
This commit is contained in:
parent
b3225e07f7
commit
5f6c434497
@ -30,57 +30,50 @@
|
|||||||
Contribution M. Salomon, UFC / IUT DE BELFORT-MONTBÉLIARD, 2016
|
Contribution M. Salomon, UFC / IUT DE BELFORT-MONTBÉLIARD, 2016
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error
|
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
|
||||||
import wtforms.validators
|
import wtforms.validators
|
||||||
from flask import request, render_template, url_for
|
from flask import request, render_template
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from werkzeug import Response
|
|
||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
|
from openpyxl.styles import PatternFill, Alignment, Border, Side, Font
|
||||||
from wtforms import (
|
from wtforms import (
|
||||||
StringField,
|
StringField,
|
||||||
PasswordField,
|
|
||||||
BooleanField,
|
|
||||||
SubmitField,
|
SubmitField,
|
||||||
SelectField,
|
SelectField,
|
||||||
RadioField,
|
RadioField,
|
||||||
HiddenField,
|
HiddenField,
|
||||||
SelectMultipleField,
|
SelectMultipleField,
|
||||||
validators,
|
|
||||||
)
|
)
|
||||||
from wtforms.validators import ValidationError, DataRequired, Email, EqualTo
|
|
||||||
|
|
||||||
from app.scodoc.sco_exceptions import ScoValueError
|
|
||||||
import app.scodoc.sco_utils as scu
|
import app.scodoc.sco_utils as scu
|
||||||
import app.scodoc.notesdb as ndb
|
import app.scodoc.notesdb as ndb
|
||||||
from app.scodoc import html_sco_header
|
from app import ScoValueError
|
||||||
|
from app.scodoc import html_sco_header, sco_preferences
|
||||||
from app.scodoc import sco_edit_module
|
from app.scodoc import sco_edit_module
|
||||||
from app.scodoc import sco_evaluations
|
from app.scodoc import sco_evaluations
|
||||||
from app.scodoc import sco_excel
|
from app.scodoc import sco_excel
|
||||||
|
from app.scodoc.sco_excel import ScoExcelBook, COLORS
|
||||||
from app.scodoc import sco_formsemestre
|
from app.scodoc import sco_formsemestre
|
||||||
from app.scodoc import sco_formsemestre_inscriptions
|
from app.scodoc import sco_formsemestre_inscriptions
|
||||||
from app.scodoc import sco_groups
|
from app.scodoc import sco_groups
|
||||||
from app.scodoc import sco_moduleimpl
|
from app.scodoc import sco_moduleimpl
|
||||||
from app.scodoc import sco_permissions_check
|
from app.scodoc import sco_permissions_check
|
||||||
from app.scodoc import sco_preferences
|
from app.scodoc.gen_tables import GenTable
|
||||||
from app.scodoc import sco_saisie_notes
|
|
||||||
from app.scodoc import sco_etud
|
from app.scodoc import sco_etud
|
||||||
import sco_version
|
import sco_version
|
||||||
from app.scodoc.gen_tables import GenTable
|
|
||||||
from app.scodoc.sco_excel import * # XXX à vérifier
|
|
||||||
from app.scodoc.TrivialFormulator import TrivialFormulator
|
|
||||||
|
|
||||||
_ = lambda x: x # sans babel
|
# _ = lambda x: x # sans babel
|
||||||
_l = _
|
# _l = _
|
||||||
|
|
||||||
COORD = "Coordonnées"
|
COORD = "Coordonnées"
|
||||||
SEQ = "Continue"
|
SEQ = "Continue"
|
||||||
|
|
||||||
|
|
||||||
class PlacementForm(FlaskForm):
|
class PlacementForm(FlaskForm):
|
||||||
|
"""Formulaire pour placement des étudiants en Salle"""
|
||||||
|
|
||||||
TOUS = "Tous"
|
TOUS = "Tous"
|
||||||
evaluation_id = HiddenField("evaluation_id")
|
evaluation_id = HiddenField("evaluation_id")
|
||||||
file_format = RadioField(
|
file_format = RadioField(
|
||||||
@ -115,7 +108,6 @@ class PlacementForm(FlaskForm):
|
|||||||
eval_data = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})
|
eval_data = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})
|
||||||
if not eval_data:
|
if not eval_data:
|
||||||
raise ScoValueError("invalid evaluation_id")
|
raise ScoValueError("invalid evaluation_id")
|
||||||
eval_data = eval_data[0]
|
|
||||||
# groupes
|
# groupes
|
||||||
groups = sco_groups.do_evaluation_listegroupes(
|
groups = sco_groups.do_evaluation_listegroupes(
|
||||||
evaluation_id, include_default=True
|
evaluation_id, include_default=True
|
||||||
@ -123,7 +115,7 @@ class PlacementForm(FlaskForm):
|
|||||||
self.groups_tree = {}
|
self.groups_tree = {}
|
||||||
self.has_groups = False
|
self.has_groups = False
|
||||||
for group in groups:
|
for group in groups:
|
||||||
partition = group["partition_name"] or self.TOUS # TODO check required
|
partition = group["partition_name"] or self.TOUS
|
||||||
group_id = group["group_id"]
|
group_id = group["group_id"]
|
||||||
group_name = group["group_name"] or self.TOUS
|
group_name = group["group_name"] or self.TOUS
|
||||||
if partition not in self.groups_tree:
|
if partition not in self.groups_tree:
|
||||||
@ -190,10 +182,12 @@ def placement_eval_selectetuds(evaluation_id):
|
|||||||
)
|
)
|
||||||
return runner.exec_placement() # calcul et generation du fichier
|
return runner.exec_placement() # calcul et generation du fichier
|
||||||
# return flask.redirect(url_for("scodoc.index"))
|
# return flask.redirect(url_for("scodoc.index"))
|
||||||
H = [html_sco_header.sco_header(init_jquery_ui=True)]
|
H = [
|
||||||
H.append(sco_evaluations.evaluation_describe(evaluation_id=evaluation_id))
|
html_sco_header.sco_header(init_jquery_ui=True),
|
||||||
H.append("<h3>Placement et émargement des étudiants</h3>")
|
sco_evaluations.evaluation_describe(evaluation_id=evaluation_id),
|
||||||
H.append(render_template("scodoc/forms/placement.html", form=form))
|
"<h3>Placement et émargement des étudiants</h3>",
|
||||||
|
render_template("scodoc/forms/placement.html", form=form),
|
||||||
|
]
|
||||||
F = html_sco_header.sco_footer()
|
F = html_sco_header.sco_footer()
|
||||||
return "\n".join(H) + "<p>" + F
|
return "\n".join(H) + "<p>" + F
|
||||||
|
|
||||||
@ -269,7 +263,6 @@ class PlacementRunner:
|
|||||||
def _build_listetud(self):
|
def _build_listetud(self):
|
||||||
if None in [g["group_name"] for g in self.groups]: # tous les etudiants
|
if None in [g["group_name"] for g in self.groups]: # tous les etudiants
|
||||||
getallstudents = True
|
getallstudents = True
|
||||||
gr_title_filename = "tous"
|
|
||||||
else:
|
else:
|
||||||
getallstudents = False
|
getallstudents = False
|
||||||
etudids = sco_groups.do_evaluation_listeetuds_groups(
|
etudids = sco_groups.do_evaluation_listeetuds_groups(
|
||||||
@ -330,7 +323,6 @@ class PlacementRunner:
|
|||||||
"ligne": "Ligne",
|
"ligne": "Ligne",
|
||||||
"place": "Place",
|
"place": "Place",
|
||||||
}
|
}
|
||||||
nb_rangs = int(self.nb_rangs)
|
|
||||||
if self.etiquetage == COORD:
|
if self.etiquetage == COORD:
|
||||||
columns_ids = ["nom", "prenom", "colonne", "ligne"]
|
columns_ids = ["nom", "prenom", "colonne", "ligne"]
|
||||||
else:
|
else:
|
||||||
@ -531,7 +523,7 @@ class PlacementRunner:
|
|||||||
ws0.append_row(cells_c)
|
ws0.append_row(cells_c)
|
||||||
ws0.set_row_dimension_height(row, space / 25)
|
ws0.set_row_dimension_height(row, space / 25)
|
||||||
|
|
||||||
def _next_page(ws):
|
def _next_page(self, ws):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _feuille1(self, ws, maxlines):
|
def _feuille1(self, ws, maxlines):
|
||||||
|
Loading…
Reference in New Issue
Block a user