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

46 lines
1.1 KiB
Python

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