1
0
forked from ScoDoc/ScoDoc
ScoDoc/scotests/test-all-moys.py

44 lines
1.1 KiB
Python
Raw Normal View History

2020-09-26 16:19:37 +02:00
# -*- mode: python -*-
# -*- coding: utf-8 -*-
"""
2020-12-26 00:11:55 +01:00
Enregistre les moyennes générales de tous les étudiants de tous les
2020-09-26 16:19:37 +02:00
semestres.
A utiliser avec debug.py (côté serveur).
"""
from __future__ import print_function
2020-12-26 00:11:55 +01:00
from debug import go_dept
2020-09-26 16:19:37 +02:00
import time
2020-12-26 00:11:55 +01:00
DeptName = "CJ"
2020-09-26 16:19:37 +02:00
context = go_dept(app, DeptName)
sems = context.Notes.formsemestre_list()
2020-12-26 00:11:55 +01:00
print("%d semestres" % len(sems))
2020-09-26 16:19:37 +02:00
2020-12-26 00:11:55 +01:00
L = []
n = 0
2020-09-26 16:19:37 +02:00
for sem in sems:
2020-12-26 00:11:55 +01:00
formsemestre_id = sem["formsemestre_id"]
2020-09-26 16:19:37 +02:00
nt = context.Notes._getNotesCache().get_NotesTable(context.Notes, formsemestre_id)
etudids = nt.get_etudids()
2020-12-26 00:11:55 +01:00
use_ue_coef = context.get_preference("use_ue_coefs", formsemestre_id)
2020-09-26 16:19:37 +02:00
n += 1
print("%d %s (%d) use_ue_coef=%s" % (n, formsemestre_id, len(etudids), use_ue_coef))
for etudid in etudids:
mg = nt.get_etud_moy_gen(etudid)
2020-12-26 00:11:55 +01:00
L.append((formsemestre_id, str(use_ue_coef), etudid, str(mg)))
2020-09-26 16:19:37 +02:00
print("Done: %s moys computed" % len(L))
2020-12-26 00:11:55 +01:00
filename = "/opt/tests/%s-%s" % (DeptName, time.strftime("%Y-%m-%dT%H:%M:%S"))
2020-09-26 16:19:37 +02:00
print("Writing file '%s'..." % filename)
2020-12-26 00:11:55 +01:00
f = open(filename, "w")
2020-09-26 16:19:37 +02:00
for l in L:
2020-12-26 00:11:55 +01:00
f.write("\t".join(l) + "\n")
2020-09-26 16:19:37 +02:00
f.close()