44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
def printer_set(consigne, exo, serie):
|
|
if len(consigne) < 30 and len(consigne) > len(exo):
|
|
longueur_max = len(consigne) + 5
|
|
elif len(consigne) > 30 and len(consigne) > len(exo):
|
|
longueur_max = 30
|
|
elif len(consigne) > 30 and len(consigne) < len(exo):
|
|
longueur_max = len(exo)
|
|
elif len(consigne) < 30 and len(consigne) < len(exo):
|
|
longueur_max = len(exo)
|
|
else:
|
|
longueur_max = len(exo)
|
|
lines = []
|
|
|
|
if len(consigne) > 30:
|
|
cons = consigne.replace(',', ' ').split(' ')
|
|
text_longueur = ''
|
|
|
|
for i in cons:
|
|
text_longueur = text_longueur + i + ' '
|
|
if len(text_longueur) > longueur_max:
|
|
lines.append(text_longueur)
|
|
text_longueur = ''
|
|
# print(text_longueur)
|
|
else:
|
|
lines.append(consigne)
|
|
#taille du plus grand = taille exo si > taille consigne
|
|
max_length = len(exo) if len(exo) > longueur_max else longueur_max
|
|
#taille d'un ex au total + l'espace
|
|
total_length = max_length + 19
|
|
|
|
|
|
#nombre d'ex sur une ligne = nb total sur une page / total_lenght^^
|
|
number_in_line = int(108/total_length)
|
|
if (108 - (total_length * number_in_line) + 19) > max_length:
|
|
number_in_line += 1
|
|
b = 1
|
|
while b * (serie+len(lines)+1) < 53: # b * le nombre de lignes par serie + la consigne + le saut de ligne > nombre de ligne d'une page en police 10
|
|
b += 1
|
|
seriesNumber = b-1
|
|
return {
|
|
'consigne': lines,
|
|
'seriesQuantity': seriesNumber,
|
|
'lineNumber': number_in_line,
|
|
} |