avant tests

This commit is contained in:
Jean-Marie Place 2021-09-17 08:22:54 +02:00
parent 0ef822cfd8
commit b3225e07f7

View File

@ -188,7 +188,7 @@ def placement_eval_selectetuds(evaluation_id):
""" """
% runner.__dict__ % runner.__dict__
) )
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 = [html_sco_header.sco_header(init_jquery_ui=True)]
H.append(sco_evaluations.evaluation_describe(evaluation_id=evaluation_id)) H.append(sco_evaluations.evaluation_describe(evaluation_id=evaluation_id))
@ -235,16 +235,14 @@ class PlacementRunner:
self.evaltitre = self.eval_data["description"] self.evaltitre = self.eval_data["description"]
else: else:
self.evaltitre = "évaluation du %s" % self.eval_data["jour"] self.evaltitre = "évaluation du %s" % self.eval_data["jour"]
self.desceval = [ self.desceval = [ # une liste de chaines: description de l'evaluation
["%s" % self.sem["titreannee"]], "%s" % self.sem["titreannee"],
["Module : %s - %s" % (self.Mod["code"], self.Mod["abbrev"])], "Module : %s - %s" % (self.Mod["code"], self.Mod["abbrev"]),
["Surveillants : %s" % self.surveillants], "Surveillants : %s" % self.surveillants,
["Batiment : %(batiment)s - Salle : %(salle)s" % self.__dict__], "Batiment : %(batiment)s - Salle : %(salle)s" % self.__dict__,
[
"Controle : %s (coef. %g)" "Controle : %s (coef. %g)"
% (self.evaltitre, self.eval_data["coefficient"]) % (self.evaltitre, self.eval_data["coefficient"]),
], ]
] # une liste de liste de chaines: description de l'evaluation
def check_placement(self): def check_placement(self):
# Check access (admin, respformation, and responsable_id) # Check access (admin, respformation, and responsable_id)
@ -252,7 +250,7 @@ class PlacementRunner:
self.current_user, self.moduleimpl_id self.current_user, self.moduleimpl_id
) )
def _exec_placement(self): def exec_placement(self):
self._repartition() self._repartition()
if self.file_format == "xls": if self.file_format == "xls":
return self._production_xls() return self._production_xls()
@ -310,18 +308,21 @@ class PlacementRunner:
return plan return plan
def _production_xls(self): def _production_xls(self):
filename = "placement_%s_%s%s" % (self.evalname, self.gr_title_filename, scu.XLSX_SUFFIX) filename = "placement_%s_%s%s" % (
self.evalname,
self.gr_title_filename,
scu.XLSX_SUFFIX,
)
xls = self._excel_feuille_placement() xls = self._excel_feuille_placement()
return sco_excel.send_from_flask(xls, filename) return sco_excel.send_from_flask(xls, filename)
def _production_pdf(self): def _production_pdf(self):
pdf_title = self.desceval pdf_title = "<br/>".join(self.desceval)
pdf_title += ( pdf_title += (
"Date : %(jour)s - Horaire : %(heure_debut)s à %(heure_fin)s" "\nDate : %(jour)s - Horaire : %(heure_debut)s à %(heure_fin)s"
% self.eval_data % self.eval_data
) )
breakpoint() filename = "placement_%(evalname)s_%(gr_title_filename)s" % self.__dict__
filename = "placement_%(evalname)s_%(gr_title_filename)s.pdf" % self.__dict__
titles = { titles = {
"nom": "Nom", "nom": "Nom",
"prenom": "Prenom", "prenom": "Prenom",
@ -348,7 +349,6 @@ class PlacementRunner:
) )
else: else:
rows.append({"nom": etud[0][0], "prenom": etud[0][1], "place": etud[1]}) rows.append({"nom": etud[0][0], "prenom": etud[0][1], "place": etud[1]})
tab = GenTable( tab = GenTable(
titles=titles, titles=titles,
columns_ids=columns_ids, columns_ids=columns_ids,
@ -359,10 +359,11 @@ class PlacementRunner:
+ "", + "",
pdf_title=pdf_title, pdf_title=pdf_title,
# pdf_shorttitle = '', # pdf_shorttitle = '',
preferences=sco_preferences.SemPreferences(self.moduleimpl_data["formsemestre_id"]), preferences=sco_preferences.SemPreferences(
# html_generate_cells=False # la derniere ligne (moyennes) est incomplete self.moduleimpl_data["formsemestre_id"]
),
) )
t = tab.make_page(format="pdf", with_html_headers=False, REQUEST=REQUEST) t = tab.make_page(format="pdf", with_html_headers=False)
return t return t
def _one_header(self, ws): def _one_header(self, ws):
@ -476,7 +477,7 @@ class PlacementRunner:
for line, desceval in enumerate(self.desceval): for line, desceval in enumerate(self.desceval):
if line in [1, 4, 7]: if line in [1, 4, 7]:
ws.append_blank_row() ws.append_blank_row()
ws.append_single_cell_row(desceval[0], self.styles["titres"]) ws.append_single_cell_row(desceval, self.styles["titres"])
ws.append_single_cell_row( ws.append_single_cell_row(
"Date : %(jour)s - Horaire : %(heure_debut)s à %(heure_fin)s" "Date : %(jour)s - Horaire : %(heure_debut)s à %(heure_fin)s"
% self.eval_data, % self.eval_data,
@ -517,7 +518,9 @@ class PlacementRunner:
ws0.append_row(cells_a) # on affiche les 3 lignes construites ws0.append_row(cells_a) # on affiche les 3 lignes construites
ws0.append_row(cells_b) ws0.append_row(cells_b)
ws0.append_row(cells_c) ws0.append_row(cells_c)
cells_a = [ws0.make_cell(rang, self.styles["2b"])] # on réinitialise les 3 lignes cells_a = [
ws0.make_cell(rang, self.styles["2b"])
] # on réinitialise les 3 lignes
cells_b = [ws0.make_cell("", self.styles["2b"])] cells_b = [ws0.make_cell("", self.styles["2b"])]
cells_c = [ws0.make_cell("", self.styles["2b"])] cells_c = [ws0.make_cell("", self.styles["2b"])]
col = 0 col = 0