first commit

This commit is contained in:
Kilton937342 2022-05-18 10:15:54 +02:00
commit 60a2197970
447 changed files with 54159 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/backend/env
/frontend/node_modules

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}

View File

@ -0,0 +1,15 @@
from .violet import Violet
from .verte import Verte
from .parc_division import Division
from .soustraction import soustraction
from .decimaux import Decimaux
from .jaune_list import Jaune
from .marron import Marron
from .noire import Noire
from .orange import Orange
from .bleu import Bleu
from .blanche_list import Blanche
from .addition import Addition
from .algo_generateur_csv import GenerateurModel
from .multplication import Multiplication
from .entiers import EntiersList

View File

@ -0,0 +1,15 @@
import csv
import random
def Addition(step, number = 5):
calcul_list = []
for i in range(number):
terme1 = random.randint(100, 99999)
terme2 = random.randint(100, 99999)
calcul_list.append({
'calcul': f"{terme1} + {terme2} = ",
'result': f"{terme1} + {terme2} = {terme2 + terme1}"
})
return calcul_list

View File

@ -0,0 +1,240 @@
import random as rnd
""" def strCalc(str_to_calc):
str_to_calc = str_to_calc.replace('+', ' + ')
str_to_calc = str_to_calc.replace('-', ' - ')
str_to_calc = str_to_calc.replace('x', ' x ')
str_to_calc = str_to_calc.replace(':', ' : ')
str_to_calc = str_to_calc.split()
num1 = str_to_calc[0]
op = str_to_calc[1]
num2 = str_to_calc[2]
res = 0
if op == '-':
res = int(num1) - int(num2)
elif op == '+':
res = int(num1) + int(num2)
elif op == ':':
res = int(num1) / int(num2)
elif op == 'x':
res = int(num1) * int(num2)
return res """
def exoGen(model):
# print(model)
model = model.replace('{', ' {') # ajout d'espace pour le .split a venir
model = model.replace('}', '} ') # ajout d'espace pour le .split a venir
model = model.replace('(', ' (') # ajout d'espace pour le .split a venir
model = model.replace(')', ') ') # ajout d'espace pour le .split a venir
model = model.split()
index_brackets = {}
# print(model)
starts = -1
result = [] # resultat afficher
workResult = model[:] # resultat de travail
i = 0
#print(model)
while i < len(model):
c = model[i]
# print(c)
if c == '(':
starts = model.index(c)
# print('found', starts)
if c == ')' and starts != -1:
#print('found end ')
end = model.index(c)
index_brackets[starts] = end
#print('() ', ''.join(model[starts + 1:end]))
bra_result = exo(''.join(model[starts + 1:end]))
# print(bra_result)
# print(starts, end)
#print("modmode", model)
del model[starts:end]
del workResult[starts:end]
model[starts] = f'({bra_result["result"]})'
workResult[starts] = str(bra_result["resultat"])
starts = -1
i -= end-starts
#print('mod', model, workResult)
""" workResult.append(f'({bra_result["resultat"]})')
result.append(f'({bra_result["result"]})') """
i += 1
#print('resultats: \n',result, '\n', workResult, '\n', model)
for item in model:
if item[0] == '{':
item = item.replace('{', '')
item = item.replace('}', '')
choices_list = item.split('/')
if choices_list[0].replace('.', '').isdigit() or choices_list[1].replace('.', '').isdigit():
result.append(item)
workResult[model.index('{'+item+'}')] = item
model[model.index('{'+item+'}')] = item
else:
choice = rnd.choice(choices_list)
result.append(str(choice) + '')
workResult[model.index('{'+item+'}')] = choice
model[model.index('{'+item+'}')] = choice
else:
result.append(item + '')
# print(model, 'mod\nres', result, '\n wr', workResult)
calc_result = 0
result = workResult[:]
for i in range(0, len(workResult)):
choices = workResult[i]
if choices.count('/') >= 1:
choices_list = choices.split('/')
if choices_list[0].replace('.', '').isdigit() or choices_list[1].replace('.', '').isdigit():
# trouver le type pour les conversion
Type = ('int', 'float')[choices_list[0].count('.') >= 1]
TypeLimit = Type
passer = False
try:
DecimalNumber = len(choices_list[0].split('.')[1])
except:
DecimalNumber = 0
previous = workResult[i - 1].replace(' ', '') # item précédent
#print('previous', result.index(previous))
try:
# si il y a un next item sinon on le set a rien
next_item = workResult[i + 1].replace(' ', '')
except:
next_item = ''
if previous == '-':
#si le précédent est un moins, on vérifie que le max pour l'item actuel ne dépasse pas le résultat actuel
previous_number = float(
workResult[i - 2]) if workResult[i - 2].count('.') >= 1 else int(workResult[i - 2])
maxGive = int(choices_list[1]) if Type == 'int' else float(
choices_list[1])
max_limit = (calc_result, maxGive)[calc_result >= maxGive]
TypeLimit = 'float' if type(
calc_result) == float else 'int'
# print('max --', max_limit)
elif previous == ':':
try:
nextChoices = workResult[i + 2].split('/')
nextMin = int(nextChoices[0]) if nextChoices[1].count(
".") < 1 else float(nextChoices[0])
nextMax = int(nextChoices[1]) if nextChoices[1].count(
".") < 1 else float(nextChoices[1])
max_limit = calc_result/nextMin
min_limit = calc_result/nextMax
passer = True
except:
max_limit = float(choices_list[1]) if Type == 'float' else int(
choices_list[1])
else:
if not passer:
max_limit = float(choices_list[1]) if Type == 'float' else int(
choices_list[1])
if next_item == '-' and not passer:
if i != 0:
next_number = workResult[i + 2]
next_choices = next_number.split('/')
next_min = float(next_choices[0]) if Type == 'float' else int(
next_choices[0])
# print('previous', previous)
# print('to calc',f'{calc_result}{previous}{next_min}')
#print('calc_result next _min',strCalc(f'{calc_result}{previous}{next_min}'))
next_number = workResult[i + 2]
next_choices = next_number.split('/')
next_min = float(next_choices[0]) if Type == 'float' else int(
next_choices[0])
actual_min = float(choices_list[0]) if Type == 'float' else int(
choices_list[0])
if next_min > actual_min:
min_limit = float(next_choices[0]) if Type == 'float' else int(
next_choices[0])
elif next_min < actual_min:
min_limit = float(choices_list[0]) if Type == 'float' else int(
choices_list[0])
elif next_min == actual_min:
min_limit = float(choices_list[0]) if Type == 'float' else int(
choices_list[0])
#print('min ---', min_limit)
else:
if not passer:
next_min = -0
min_limit = float(choices_list[0]) if Type == 'float' else int(
choices_list[0])
#print('min &&', min_limit)
#print(min_limit, max_limit)
item_result = rnd.randint(min_limit, max_limit) if TypeLimit == 'int' else round(
rnd.uniform(min_limit, max_limit), DecimalNumber)
if previous.replace(' ', '') == '-':
calc_result = calc_result - item_result
elif previous.replace(' ', '') == '+':
calc_result = calc_result + item_result
elif previous.replace(' ', '') == ':':
calc_result = calc_result / item_result
elif previous.replace(' ', '') == 'x':
calc_result = calc_result * item_result
else:
calc_result = calc_result + item_result
#print((tempo_result < next_min and next_item == '- '), 'next')
if calc_result < next_min and i != 0 and next_min != -0 and previous.replace(' ', '') == '-':
previous_max = result[i - 2].split('/')[1]
if previous_number + next_min > (int(previous_max) if type(previous_max) == int else float(previous_max)):
item_result -= next_min
max_limit -= next_min
calc_result += next_min
else:
max_limit += next_min
workResult[i - 2] = str((int(workResult[i - 2]) if type(workResult[i - 1])
== int else float(workResult[i-2])) + next_min)
calc_result += next_min
if type(item_result) == float and item_result - int(item_result) == 0 and Type == 'int':
item_result = int(item_result)
workResult[i] = str(item_result) + ''
model[i] = str(item_result) + ''
#print('changed', workResult)
elif choices.count('/') == 0:
if choices.replace('.', '').isdigit() or choices.replace('.', '').isdigit():
calc_result += int(choices) if choices.count(
'.') == 0 else float(choices)
result = ' '.join(model)
return {'result': result, 'resultat': calc_result}
def exo(model):
result = None
while result == None:
try:
result = exoGen(model)
return result
except:
result = None
return result

View File

@ -0,0 +1,10 @@
from .algo import exo
import csv
def GenerateurModel(model, consigne, number = 5):
calcul_list = []
for i in range(number):
calcul_list.append({'calcul': exo(model)['result'], "result": None})
return calcul_list

View File

@ -0,0 +1,48 @@
import csv
import random
def Blanche(step, number=5):
if step == 1:
calcul_list = []
for i in range(number):
terme1 = random.randint(2,10)
terme2 = random.randint(2,10)
calcul_list.append({
'calcul': f'{terme1} + {terme2} = [{terme1 + terme2}]',
#'result': f'{terme1} + {terme2} = [{terme1 + terme2}]'
})
return calcul_list
if step == 2:
calcul_list = []
for i in range(number):
terme1 = random.randint(10,20)
terme2 = random.randint(2,10)
calcul_list.append({
'calcul': f"{terme1} - {terme2} = [{terme1 - terme2}]",
#'result': f"{terme1} - {terme2} = [{terme1 - terme2}]"
})
return calcul_list
if step == 3:
calcul_list = []
for i in range(number):
terme1 = random.randint(1,4)
calcul_list.append({
'calcul': f"{terme1}+[{5 - terme1}]=5",
# 'result': f'{terme1}+[{5 - terme1}] = 5'
})
return calcul_list
if step == 4:
calcul_list = []
for i in range(number):
terme1 = random.randint(1, 10)
calcul_list.append({
'calcul': f"{terme1}+[]=10",
'result': f'{terme1} + [{10 - terme1}] = 10'
})
return calcul_list

View File

@ -0,0 +1,50 @@
import csv
import random
import math
def Bleu(step, number=5):
if step == 1:
calcul_list = []
for x in range(number):
fac = random.randint(10,1000)
calcul_list.append({
'calcul': f"{fac} x 10 = ",
'result': f"{fac} x 10 = {fac * 10}"
})
return calcul_list
if step == 2:
calcul_list = []
for x in range(number):
fac = random.randint(10, 1000)
calcul_list.append({
'calcul': f"{fac} x 100 = ",
'result': f"{fac} x 100 = {fac * 100}"
})
return calcul_list
if step == 3:
calcul_list = []
for x in range(number):
fac1 = random.randint(5, 100)
multiple10 = math.ceil(random.randint(20,100) / 10) * 10
calcul_list.append({
'calcul': f"{fac1} x {multiple10} = ",
'result': f"{fac1} x {multiple10} = {fac1 * multiple10}"
})
return calcul_list
if step == 4:
calcul_list = []
for x in range(number):
fac1 = random.randint(1, 9)
fac2 = random.randint(1, 9)
fac3 = random.randint(1, 9)
calcul_list.append({
'calcul': f"{fac1} + {fac2} + {fac3} = ",
'result': f"{fac1} + {fac2} + {fac3}= {fac1 + fac2 + fac3}"
})
return calcul_list

View File

@ -0,0 +1,165 @@
import random
import csv
from math import *
from .modules import nbletter
def Decimaux(step, number=5):
if step == 1:
calcul_list = []
start = random.randint(1, 1000)
end = start + 3
for i in range(number):
lister = [str(round(random.uniform(start, end), 2)), ' ; ', str(round(random.uniform(start, end), 2)), ' ; ', str(round(
random.uniform(start, end), 2)), ' ; ', str(round(random.uniform(start, end), 2)), ' ; ',str( round(random.uniform(start, end), 2)), ' ; ']
calcul_list.append({
'calcul': ' '.join(lister),
'result': None
})
return calcul_list
if step == 2:
calcul_list = []
for i in range(number):
nb = round(random.uniform(0.1, 100.0), random.randint(1, 3))
calcul_list.append({
'calcul': f" < {nb} < ",
'result': f"floor(nb) < {nb} < ceil(nb) "
})
return calcul_list
if step == 3:
calcul_list = []
for i in range(number):
nb = round(random.uniform(0.1, 100.0), random.randint(1, 3))
calcul_list.append({
'calcul': f"{nb} {chr(8771)} ",
'result': f"{nb} {chr(8771)} {ceil(nb)}"
})
return calcul_list
if step == 4:
calcul_list = []
for i in range(int(number / 2)):
nb = round(random.uniform(0.1, 100.0), random.randint(1, 2))
number_mode = nbletter(nb)
res = nb
calcul_list.append({
'calcul': f"{number_mode} = ",
'result': f'{number_mode} = {res}'
})
for i in range(int(number / 2)):
nb = round(random.uniform(0.1, 100.0), random.randint(1, 2))
number_mode = nb
res = nbletter(nb)
calcul_list.append({
'calcul': f"{number_mode} = ",
'result': f'{number_mode} = {res}'
})
for i in range(number - (int(number / 2) * 2 )):
nb = round(random.uniform(0.1, 100.0), random.randint(1, 2))
number_mode = nb
res = nbletter(nb)
calcul_list.append({
'calcul': f"{number_mode} = ",
'result': f'{number_mode} = {res}'
})
return calcul_list
if step == 5:
calcul_list = []
for i in range(number):
nb = round(random.uniform(11, 99.9), 1)
dizaine = int(str(nb)[0]) * 10
unit = int(str(nb)[1])
dixieme = int(str(nb)[3])
calcul_list.append({
'calcul': f"{nb} = ",
'result': f'{nb} = {dizaine} + {unit} + 0,{dixieme}'
})
return calcul_list
if step == 6:
calcul_list = []
for i in range(number):
nb_list = [round(random.uniform(0.1, 999.0), random.randint(1, 4)), round(
random.uniform(0.1, 999.0), random.randint(1, 4))]
if nb_list[0] > nb_list[1]:
res = '>'
if nb_list[0] < nb_list[1]:
res = '<'
if nb_list[0] == nb_list[1]:
res = '='
calcul_list.append({
'calcul': f"{nb_list[0]} ...... {nb_list[1]}",
'result': f"{nb_list[0]} {res} {nb_list[1]}"
})
return calcul_list
if step == 7:
calcul_list = []
for i in range(int(number / 2)):
nb_list = [f'{i},{random.randint(1,9999)}', f'{i},{random.randint(1,9999)}',
f'{i},{random.randint(1,9999)}', f'{i},{random.randint(1,9999)}', f'{i},{random.randint(1,9999)}']
calcul_list.append({
'calcul': f"{nb_list[0]} ... {nb_list[1]} ... {nb_list[2]} ... {nb_list[3]} ... {nb_list[4]} ",
'result': None
})
for i in range(int(number / 2)):
nb_list = [round(random.uniform(0,100), random.randint(1,4)),round(random.uniform(0,100), random.randint(1,4)),round(random.uniform(0,100), random.randint(1,4)),round(random.uniform(0,100), random.randint(1,4)),round(random.uniform(0,100), random.randint(1,4)),]
for i in range(len(nb_list)):
nb_list[i] = str(nb_list[i])
calcul_list.append({
'calcul': f"{nb_list[0]} {nb_list[1]} {nb_list[2]} {nb_list[3]} {nb_list[4]} ",
'result': None
})
for i in range(number - int((number / 2) ) *2):
nb_list = [round(random.uniform(0,100), random.randint(1,4)),round(random.uniform(0,100), random.randint(1,4)),round(random.uniform(0,100), random.randint(1,4)),round(random.uniform(0,100), random.randint(1,4)),round(random.uniform(0,100), random.randint(1,4)),]
for i in range(len(nb_list)):
nb_list[i] = str(nb_list[i])
calcul_list.append({
'calcul': f"{nb_list[0]} {nb_list[1]} {nb_list[2]} {nb_list[3]} {nb_list[4]} ",
'result': None
})
return calcul_list
if step == 8:
calcul_list = []
for i in range(number):
nb = round(random.uniform(11, 99.9), 3)
if len(str(nb)) < 5:
nb = str(nb) + '0'
centieme = int(str(nb)[4])
round_up = (round(float(nb), 1), round(float(nb),1) + 0.1)[centieme < 5]
round_down = (round(float(nb), 1), round(float(nb), 1) + 0.1)[centieme >= 5]
calcul_list.append({
'calcul': f" {nb} ",
'result': f'{round_down} < {nb} < {round_up}'
})
return calcul_list
if step == 9:
calcul_list = []
for i in range(number):
nb1 = (random.randint(0,999), round(random.uniform(0.1, 999), random.randint(1,3)))[i >= 4]
nb2 = round(random.uniform(0.1,999.0), random.randint(1,3))
calcul_list.append({
'calcul': f"{nb1} + {nb2} = ",
'result': f'{nb1} + {nb2} = {nb1 + nb2}'
})
return calcul_list
if step == 10:
calcul_list = []
for i in range(number):
sup = round(random.uniform(1,999), random.randint(1,3))
inf = (random.randint(0, int(sup)), round(
random.uniform(0, sup), random.randint(1, 3)))[i > 2]
calcul_list.append({
'calcul': f"{sup} - {inf} = ",
'result': f'{sup} - {inf} = {sup - inf}'
})
return calcul_list

View File

@ -0,0 +1,70 @@
from ..modules import random_verif, verif, nbletter, printer_set
import csv
import random
def EntiersList(step, number = 5):
if step == 1:
calcul_list = []
for i in range(number):
nb = random.randint(1, 9999)
calcul_list.append({
'calcul': nbletter(nb),
'result': f'{nbletter(random.randint(1,9999))} = {nb}'
})
return calcul_list
if step == 4:
calcul_list = []
for i in range(number):
nb = random.randint(1, 9999)
wordList = ['unités', 'dizaines',
'centaines', 'milliers']
index ={'unités': 0, "dizaines": 1, 'centaines': 2, "milliers": 3}
nbToGive = random.choice(wordList[0:len(str(nb)) - 1])
res = str(nb)[index[nbToGive]]
calcul_list.append({
'calcul': f"Donnez le chiffre des {nbToGive} dans {nb}.",
'result': f'Le chiffre des {nbToGive} dans {nb} est {res}.'
})
return calcul_list
if step == 5:
calcul_list = []
for i in range(number):
nb = random.randint(1, 9999)
wordList = ['unités', 'dizaines',
'centaines', 'milliers']
index = {'unités': 0, "dizaines": 1, 'centaines': 2, "milliers": 3}
try:
nbToGive = random.choice(wordList[0:len(str(nb)) - 1])
except:
nbToGive = random.choice(wordList[0:len(str(nb)) - 1])
res = str(nb)[index[nbToGive]:]
calcul_list.append({
'calcul': f"Donnez le nombre de {nbToGive} dans {nb}",
'result': f'Le nombre de {nbToGive} dans {nb} est {res}.'
})
return calcul_list
if step == 7:
calcul_list = []
for i in range(number):
nb = random.randint(1, 9999)
wordList = ['unité', 'dizaine',
'centaine', 'millier']
nbToGive = random.choice(wordList[0:len(str(nb)) - 1])
cons = ''
if nbToGive == 'millier':
cons=f"Encadrer au {nbToGive} près: ... <{nb}> ..."
if nbToGive == 'unité':
cons=f"Encadrer à l'{nbToGive} près: ... <{nb}> ..."
else:
cons = f"Encadrer à la {nbToGive} près: ... <{nb}> ..."
calcul_list.append({
'calcul': cons,
'result': None
})
return calcul_list

View File

@ -0,0 +1,63 @@
import csv
import random
import math
#modifier le .format a la fin
def Jaune(step, number=5):
if step == 1:
calcul_list = []
for x in range(number):
forComplete=random.randint(1,99)
toComplete = math.ceil(forComplete/10) * 10
res = toComplete - forComplete
calcul_list.append({
'calcul': f"{forComplete} pour aller à {toComplete} : ",
'result': f"{forComplete} pour aller à {toComplete} : {res} "
})
return calcul_list
if step == 2:
calcul_list = []
for x in range(number):
terme = random.randint(2,99)
calcul_list.append({
'calcul': f"{terme} + 10 = ",
'result': f"{terme} + 10= {terme + 10}"
})
return calcul_list
if step == 3:
calcul_list = []
for x in range(number):
terme = random.randint(11, 99)
calcul_list.append({
'calcul': f"{terme} - 10 = ",
'result': f"{terme} - 10= {terme - 10}"
})
return calcul_list
if step == 4:
calcul_list = []
for x in range(number):
inferieur = random.randint(1,250)
superieur = math.ceil(random.randint(inferieur, 500) /10) * 10 + 10
calcul_list.append({
'calcul': f"{inferieur} + ... = {superieur}",
'result': f'{inferieur} + {superieur - inferieur} = {superieur}'
})
return calcul_list
if step == 5:
calcul_list = []
for x in range(number):
inferieur = random.randint(1,90)
superieur = math.ceil(random.randint(inferieur, 110) /10) * 10 + 10
calcul_list.append({
'calcul': f"{inferieur} + ... = {superieur}",
'result': f'{inferieur} + {superieur - inferieur} = {superieur}'
})
return calcul_list

View File

@ -0,0 +1,54 @@
import csv
import random
def Marron(step, number=5):
if step == 1:
calcul_list = []
for x in range(number):
terme = random.randint(2, 100)
calcul_list.append({
'calcul': f"{terme} x 11 = ",
'result': f"{terme} x 11 = {terme * 11}"
})
return calcul_list
if step == 2:
calcul_list = []
for x in range(number):
nb = random.randint(100, 1000)
multiple_10 = (10 * round(nb/10), nb)[nb % 10 == 0]
calcul_list.append({
'calcul': f"{multiple_10} : 10 = ",
'result': f"{multiple_10}: 10 = {int(multiple_10 / 10)}"
})
return calcul_list
if step == 3:
calcul_list = []
for x in range(number):
div_nb = random.choice([5,3])
nb = random.randint(100,999)
vf = ('Vrai', 'Faux')[nb % div_nb != 0]
calcul_list.append({
'calcul': f"{nb} est divisible par {div_nb}: Vrai / Faux",
'result': f"{nb} est divisible par {div_nb}: {vf}"
})
return calcul_list
if step == 4:
calcul_list = []
for x in range(number):
nb = random.randint(10, 100)
pair = (nb + 1, nb)[nb % 2 == 0]
res = pair / 2
calcul_list.append({
'calcul': f"La moitié de {pair} est ",
'result': f"La moitié de {pair} est {res}"
})
return calcul_list

View File

@ -0,0 +1,3 @@
from .verif import Verificateur
from .nbletter import nbletter
from .random_verif import *

View File

@ -0,0 +1,110 @@
def nbletter(nombre):
ten_pre = {'2': "vingt-",
'3': "trente-",
"4": "quarante-",
"5": "cinquante-",
"6": "soixante-",
"7": "soixante-",
"8": "quatre-vingt-"}
chiffre = {'0': "zéro ",
'1': "un",
'2': "deux",
'3': "trois",
'4': "quatre",
'5': "cinq",
'6': "six",
'7': "sept",
'8': "huit",
'9': "neuf",
'10': "dix",
'11': "onze",
'12': "douze",
'13': "treize",
'14': "quatorze",
'15': "quinze",
'16': "seize",
'20': "vingt",
'30': "trente",
'40': "quarante",
'50': "cinquante",
'60': "soixante",
'70': "soixante-dix",
'80': "quatre-vingts",
'90': "quatre-vingt-dix",
'100': "cent",
'71': "soixante et onze",
'91': "quatre-vingts-onze"}
for i in range(7, 10):
chiffre[str(i+10)] = "dix-"+chiffre[str(i)]
for x in range(2, 7):
#print(str(x * 10))
chiffre[str(x) +
"1"] = chiffre[str(x * 10)] + " et un"
#print("\n", chiffre.get(61))
for y in range(1, 10):
#print(90+y)
chiffre[str(90 + y)] = "quatre-vingts-" + \
chiffre[str(y + 10)]
for y in range(1, 10):
#print(90+y)
chiffre[str(70 + y)] = "soixante-" + \
chiffre[str(y + 10)]
#print(chiffre["99"])
avirgule = str(nombre).split(".")[0]
aprevirgule = str(nombre).split(".")[1]
#print(avirgule)
def letter(nbrond):
if nbrond[0] == "0":
return "zero " + str(chiffre[nbrond[1]])
if nbrond[0] == "1":
return chiffre[nbrond]
else:
part = ten_pre[str(nbrond[0])]
return part+str(chiffre[nbrond[1]])
try:
avirgule = chiffre[str(avirgule)]
#print("try")
except:
avirgule = letter(avirgule)
#print(avirgule)
def fraction(nb):
if len(nb) == 1:
# print("2 : ", len(nb))
if nb == "1":
# print(f"ON EST LAAAA : {nb}")
return chiffre[str(nb)] + " dixième"
else:
# print(f"eh non : {nb}")
return chiffre[str(nb)] + " dixièmes"
elif len(nb) == 2:
if nb[0] == "0":
if nb[1] == "1":
#print("ttttest" +nb[1])
return chiffre[str(nb[1])] + " centième"
else:
#print("test" +nb[1])
return chiffre[str(nb[1])] + " centièmes"
else:
#print(f"tesst : {nb[0]}")
try:
aprevirgule = chiffre[nb]
except:
aprevirgule = letter(nb)
finally:
return aprevirgule + " centièmes"
aprevirgule = fraction(aprevirgule)
#print(f"{avirgule}, {aprevirgule}")
return avirgule + " et " + aprevirgule

View File

@ -0,0 +1,25 @@
from .verif import Verificateur
import random
verifi = Verificateur()
def integer(nb1, nb2):
pass
def floater(nb1, nb2, rounder):
verifi.set_interval(nb1, nb2)
ran = verifi.verif(round(random.uniform(nb1, nb2), rounder))
return ran
def reinit():
verifi.reinit()
lister = []
ver = []
for x in range(1, 101):
lister.append(floater(1.0, 200.83, 2))
for x in range(0, len(lister)):
ver.append(lister.count(lister[x]))

View File

@ -0,0 +1,2 @@
def rounder(num, rounder):
return num + (rounder - int(str(num)[len(str(num)) - 1]))

View File

@ -0,0 +1,96 @@
import random
import sys
sys.setrecursionlimit(1000000000)
class Verificateur():
""" obj verif"""
def __init__(self):
self.nblist = []
self.nb1 = 1
self.nb2 = 10
self.i = 0
def set_interval(self,nb1 = 1, nb2 = 10):
self.nb1 = nb1
self.nb2 = nb2
def verif(self, nb):
if type(nb) == float:
self.nb = str(nb).split(".")
#print(self.nb)
#print("\n")
self.nb = len(self.nb[1])
#print(self.nb)
self.len = (self.nb2 - self.nb1) * 10 ** self.nb
elif type(nb) == int:
self.len = self.nb2 - self.nb1
else:
pass
if len(self.nblist) >= self.len:
#print(f"test : {self.nblist}")
return nb
if self.nblist.count(nb) < 1:
self.nblist.append(nb)
#print(self.nblist)
#print("bon")
return nb
else:
if type(nb) == int:
self.n = 0
self.n = random.randint(self.nb1, self.nb2)
#print(f"C'EST N = {self.n}")
#print(f"Faux : {nb}; test : {self.n}")
# print(f"except : {self.n} ; {self.nblist.count(self.n)}, tour : {self.i}")
self.i += 1
return self.verif(self.n)
if type(nb) == float:
self.n = 0
self.n = round(random.uniform(self.nb1, self.nb2), len(str(nb).split(".")[1]))
#print(f"C'EST N = {self.n}")
#print(f"Faux : {nb}; test : {self.n}")
# print(f"except : {self.n} ; {self.nblist.count(self.n)}, tour : {self.i}")
self.i += 1
return self.verif(self.n)
#return self.n
def int_verif(self, nb, nb1, nb2):
if self.nblist.count(nb) < 1:
self.nblist.append(nb)
# print(self.nblist)
return True
else:
#print(len(self.nblist))
if len(self.nblist) == nb2:
print("BREAAAAAAK")
return input()
self.n = random.randint(nb1, nb2)
print(f"Faux : {nb}; test : {self.n}")
self.int_verif(self.n, nb1, nb2)
print(self.nblist)
return False
def reinit(self):
self.nblist[:] = []
self.nb1 = 1
self.nb2 = 10
"""test.verif(5)
for x in range(1, 10):
n = random.randint(1, 10)
print(f"{test.verif(n)}")
print(test.nblist)
for x in range(0, len(test.nblist)):
print(test.nblist.count(x))
"""

View File

@ -0,0 +1,53 @@
from .modules.roundUp import rounder
import random
import csv
def Multiplication(step, number=5):
if step == 1:
calcul_list = []
for i in range(number):
terme1 = random.randint(10, 9999)
terme2 = random.randint(2, 9)
calcul_list.append({
'calcul': f'{terme1} x {terme2} = ',
'result': f'{terme1} x {terme2} = {terme1 + terme2}'
})
return calcul_list
if step == 2:
calcul_list = []
for i in range(number):
terme1 = random.randint(10, 999)
terme2 = random.choice(['10','100', '1000'])
calcul_list.append({
'calcul': f'{terme1} x {terme2} = ',
'result': f'{terme1} x {terme2} = {int(terme1) * int(terme2)}'
})
return calcul_list
if step == 3:
calcul_list = []
for i in range(number):
terme1 =rounder( random.randint(10, 900), 10)
terme2 = random.randint(10, 999)
calcul_list.append({
'calcul': f'{terme2} x {terme1} = ',
'result': f'{terme2} x {terme1} = {terme1 * terme2}'
})
return calcul_list
if step == 4:
calcul_list = []
for i in range(number):
terme1 = rounder(random.randint(10, 999), 10)
terme2 = rounder(random.randint(10, 999), 10)
calcul_list.append({
'calcul': f'{terme1} x {terme2} = ',
'result': f'{terme1} x {terme2} = {terme1 * terme2}'
})
return calcul_list

View File

@ -0,0 +1,90 @@
import csv
import random
import math
def Noire(step, number=5):
if step == 1:
calcul_list = []
for x in range(number):
dividande = random.randint(20, 100)
diviseur = random.randint(19, dividande)
calcul_list.append({
'calcul': f"{dividande} : {diviseur} = r = ",
'result': f"{dividande} : {diviseur} = { math.floor(dividande / diviseur)} r = {dividande % diviseur} "
})
return calcul_list
if step == 2:
calcul_list = []
for x in range(number ):
op1 = random.choice(['+', '-', 'x', ':'])
op2 = random.choice(['+', '-', 'x', ':'])
n1 = random.randint(2, 10)
#print('N1', n1, op1)
if op1 == '-' or op1 == ":":
n2 = random.randint(1, n1)
else:
n2 = random.randint(1, 10)
#premier calcul
if op1 == '-':
res1 = n1 - n2
elif op1 == '+':
res1 = n1 + n2
elif op1 == 'x':
res1 = n1 * n2
elif op1 == ':':
res1 = n1 / n2
if op2 == '-' or op2 == '/':
max_limit = (10, int(res1))[res1 < 10]
min_limit = (1, 0)[int(res1) == 0]
n3 = random.randint(min_limit, max_limit)
else:
n3 = random.randint(1, 10)
#deuxieme
if op2 == '-':
final_result = res1 - n3
if op2 == '+':
final_result = res1 + n3
if op2 == 'x':
final_result = res1 * n3
if op2 == ':':
final_result = res1 / n3
calcul_list.append({
'calcul': f"({n1} {op1} {n2}) {op2} {n3} = ",
'result': f"({n1} {op1} {n2}) {op2} {n3} = {final_result}"
})
return calcul_list
if step == 3:
calcul_list = []
for x in range(number):
nb = random.randint(0,2000)
centaine_sup = math.ceil(nb/100) * 100
calcul_list.append({
'calcul': f"{nb} + ... = {centaine_sup}",
'result': f'{nb} + {centaine_sup - nb} = {centaine_sup}'
})
return calcul_list
if step == 4:
calcul_list = []
for x in range(number):
nb = random.randint(2, 10)
calcul_list.append({
'calcul': f"{nb} x 25 = ",
'result': f"{nb} x 25 = {nb * 25}"
})
return calcul_list

View File

@ -0,0 +1,60 @@
from .modules.roundUp import rounder
import csv
import random
def Orange(step, number=5):
if step == 1:
calcul_list = []
for x in range(number):
terme = random.randint(2, 99)
calcul_list.append({
'calcul': f'{terme} + 9 = ',
'result': f'{terme} + 9={terme + 9}'
})
return calcul_list
if step == 2:
calcul_list = []
for x in range(number):
terme = random.randint(10, 99)
calcul_list.append({
'calcul': f'{terme} - 9 = ',
'result': f'{terme} - 9={terme - 9}'
})
return calcul_list
if step == 3:
calcul_list = []
for x in range(number):
terme = random.randint(2, 99)
calcul_list.append({
'calcul': f'{terme} + 11 = ',
'result': f'{terme} + 11 = {terme + 11}'
})
return calcul_list
if step == 4:
calcul_list = []
for x in range(number):
terme = random.randint(12, 99)
calcul_list.append({
'calcul': f'{terme} - 11 = ',
'result': f'{terme} - 11 = {terme - 11}'
})
return calcul_list
if step == 5:
calcul_list = []
for x in range(number):
inf = rounder(random.randint(10, 190), 10)
n2 = rounder(random.randint(10, 190), 10)
calcul_list.append({
'calcul': f'{inf} + {n2} = ',
'result': f'{inf} + {n2} = {inf + n2} '
})
return calcul_list

View File

@ -0,0 +1,62 @@
import random
import csv
import math
def Division(step, number=5):
if step == 1:
calcul_list = []
for i in range(number):
nb_model = random.randint(2, 10)
diviseur = random.randint(2, 10)
dividande = nb_model * diviseur
calcul_list.append({
'calcul': f"{dividande} : {diviseur} = ",
'result': f"{dividande}: {diviseur}={int(dividande / diviseur)}"
})
return calcul_list
if step == 2:
calcul_list = []
for i in range(number):
diviseur = (random.randint(2, 5), random.randint(2, 9))[i >= 4]
dividande = (random.randint(50, 99),
random.randint(100, 500))[i >= 4]
while dividande % diviseur != 0:
dividande = (random.randint(50, 99),
random.randint(100, 500))[i >= 4]
calcul_list.append({
'calcul': f"{dividande} : {diviseur} = ",
'result': f"{dividande}: {diviseur}={int(dividande / diviseur)}"
})
return calcul_list
if step == 3:
calcul_list = []
for i in range(number):
diviseur = random.randint(2, 9)
dividande = random.randint(100, 500)
while dividande % diviseur == 0:
dividande = random.randint(100, 500)
calcul_list.append({
'calcul': f"{dividande} : {diviseur} = r = ",
'result': f"{dividande} : {diviseur} = {math.floor(dividande / diviseur)} r = {dividande % diviseur} "
})
return calcul_list
if step == 4:
calcul_list = []
for i in range(number):
diviseur = random.randint(1, 50)
dividande = random.randint(250, 1000)
calcul_list.append({
'calcul': f"{dividande} : {diviseur} = ",
'result': {
'result': math.floor(dividande / diviseur),
'reste': f"{dividande} : {diviseur} = {math.floor(dividande / diviseur)} r = {dividande % diviseur} "
}
})
return calcul_list

View File

@ -0,0 +1,57 @@
import csv
import random
def soustraction(name):
pass
""" with open(name, 'w', newline='') as csvfile:
fichier = csv.writer(
csvfile, delimiter=',', quotechar=',', quoting=csv.QUOTE_MINIMAL)
for z in range(1, 11):
for x in range(1, 5):
fichier.writerow(
["Soustraction", "", "Soustraction", "", "Soustraction", "", "Soustraction"])
for u in range(1, 7):
listesup = []
listeinf = []
while len(listesup) != 4 and len(listeinf) != 4:
nombre1 = random.randint(100, 99999)
nombre2 = random.randint(100, 99999)
if nombre1 < nombre2:
listesup.append(nombre2)
listeinf.append(nombre1)
if nombre1 > nombre2:
listesup.append(nombre1)
listeinf.append(nombre2)
fichier.writerow([str(listesup[0])+"-"+str(listeinf[0])+"=", "", str(listesup[1])+"-"+str(
listeinf[1])+"=", "", str(listesup[2])+"-"+str(listeinf[2])+"=", "", str(listesup[3])+"-"+str(listeinf[3])+"="])
listesup = []
listeinf = []
while len(listesup) != 4 and len(listeinf) != 4:
nombre1 = random.randint(100, 99999)
nombre2 = random.randint(
100, 99999)
if nombre1 < nombre2:
listesup.append(nombre2)
listeinf.append(nombre1)
if nombre1 > nombre2:
listesup.append(nombre1)
listeinf.append(nombre2)
fichier.writerow([str(listeinf[0])+"-"+str(listesup[0])+"=", "", str(listeinf[1])+"-"+str(listesup[1])+"=", "", str( listeinf[2])+"-"+str( listesup[2])+"=", "", str( listeinf[3])+"-"+str( listesup[3])+"="])
for u in range(1, 4):
listesup = []
listeinf = []
while len(listesup) != 4 and len(listeinf) != 4:
nombre1 = random.randint(100, 99999)
nombre2 = random.randint(100, 99999)
if nombre1 < nombre2:
listesup.append(nombre2)
listeinf.append(nombre1)
if nombre1 > nombre2:
listesup.append(nombre1)
listeinf.append(nombre2)
fichier.writerow([str(listesup[0])+"-"+str(listeinf[0])+"=", "", str(listesup[1])+"-"+str(listeinf[1])+"=", "", str( listesup[2])+"-"+str( listeinf[2])+"=", "", str( listesup[3])+"-"+str( listeinf[3])+"="])
fichier.writerow([""])
fichier.writerow([""])
fichier.writerow([""])
"""

View File

@ -0,0 +1,74 @@
import csv
import random
def Verte(step, number=5):
if step == 1:
calcul_list = []
for x in range(number):
fac1 = random.randint(2,10)
fac2 = random.randint(2,10)
calcul_list.append({
'calcul': f"{fac1} x {fac2} = ",
'result': f"{fac1} x {fac2} = {fac1 * fac2}"
})
return calcul_list
if step == 2:
calcul_list = []
for x in range(number):
toDouble = random.randint(2,50)
calcul_list.append({
'calcul': f"Le double de {toDouble} est ",
'result': f"Le double de {toDouble} est {toDouble * 2}"
})
return calcul_list
if step == 3:
calcul_list = []
for x in range(int(number / 2)):
terme = random.randint(100,1000)
calcul_list.append({
'calcul': f"{terme} + 99 = ",
'result': f"{terme} + 99 = {terme + 99}"
})
for x in range(int(number / 2)):
terme = random.randint(100,1000)
calcul_list.append({
'calcul': f"{terme} - 99 = ",
'result': f"{terme} - 99 = {terme - 99}"
})
for x in range(number - int(number / 2)):
terme = random.randint(100,1000)
calcul_list.append({
'calcul': f"{terme} - 99 = ",
'result': f"{terme} - 99 = {terme - 99}"
})
return calcul_list
if step == 4:
calcul_list = []
for x in range(int(number / 2)):
terme = random.randint(102, 1000)
calcul_list.append({
'calcul': f"{terme} + 101 = ",
'result': f"{terme} + 101 = {terme + 101}"
})
for x in range(int(number/ 2)):
terme = random.randint(102, 1000)
calcul_list.append({
'calcul': f"{terme} - 101 = ",
'result': f"{terme} - 101 = {terme - 101}"
})
for x in range(number - int(number/ 2)):
terme = random.randint(102, 1000)
calcul_list.append({
'calcul': f"{terme} - 101 = ",
'result': f"{terme} - 101 = {terme - 101}"
})
return calcul_list

View File

@ -0,0 +1,85 @@
import csv
import random
def Violet(step, number=5):
if step == 1:
calcul_list = []
for x in range(number):
op1 = random.choice(['+','-','x',':'])
op2 = random.choice(['+','-'])
n1 = random.randint(2, 10)
#print('N1', n1, op1)
if op1 == '-' or op1 == ":":
n2 = random.randint(1, n1)
else:
n2 = random.randint(1,10)
#premier calcul
if op1 == '-':
res1 = n1 - n2
elif op1 == '+':
res1 = n1 + n2
elif op1 == 'x':
res1 = n1 * n2
elif op1 == ':':
res1 = n1 / n2
if op2 == '-':
max_limit = (10, int(res1))[res1 < 10]
min_limit = (1, 0)[int(res1) == 0]
n3 = random.randint(min_limit, max_limit)
else:
n3 = random.randint(1,10)
#deuxieme
if op2 == '-':
final_result = res1 - n3
if op2 == '+':
final_result = res1 + n3
calcul_list.append({
'calcul': f"({n1} {op1} {n2}) {op2} {n3} = ",
'result': f"({n1} {op1} {n2}) {op2} {n3} = {final_result} "
})
return calcul_list
if step == 2:
calcul_list = []
for x in range(number):
nb_model = random.randint(2,10)
diviseur = random.randint(2,10)
dividande = nb_model * diviseur
calcul_list.append({
'calcul': f"{dividande} : {diviseur} = ",
'result': f"{dividande}: {diviseur} = {int(dividande / diviseur)}"
})
return calcul_list
if step == 3:
calcul_list = []
for x in range(number):
nb = random.randint(10,100)
pair = (nb + 1, nb)[nb % 2 == 0]
calcul_list.append({
'calcul': f"{pair} : 2 = ",
'result': f"{pair}: 2 = {int(pair / 2)}"
})
return calcul_list
if step == 4:
calcul_list = []
for x in range(number):
nb = random.randint(10, 100)
multiple_5 = (5 * round(nb/5), nb)[nb % 5 == 0]
calcul_list.append({
'calcul': f"{multiple_5} : 5 = ",
'result': f"{multiple_5}: 5={int(multiple_5 / 5)}"
})
return calcul_list

View File

@ -0,0 +1,2 @@
from .generateur_main import Generateur
from .generateur_csv import Csv_generator

View File

@ -0,0 +1,76 @@
from . import Generateur
PAGE_LINES = {
10: 53,
12: 49,
14: 39,
16: 34,
18: 31
}
MAX_LENGTH = {
10: 38,
12: 32,
14: 25,
16: 23,
18: 20
}
def Csv_generator(path, nb_in_serie, nb_page, police, consigne, writer):
exo_exemple = Generateur(path, 1, 'csv')
if len(consigne) < MAX_LENGTH[police] and len(consigne) > len(exo_exemple):
longueur_max = len(consigne) + 5
elif len(consigne) > MAX_LENGTH[police] and len(consigne) > len(exo_exemple):
longueur_max = MAX_LENGTH[police]
elif len(consigne) > MAX_LENGTH[police] and len(consigne) < len(exo_exemple):
longueur_max = len(exo_exemple)
elif len(consigne) < MAX_LENGTH[police] and len(consigne) < len(exo_exemple):
longueur_max = len(exo_exemple)
else:
longueur_max = len(exo_exemple)
consigne_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:
consigne_lines.append(text_longueur)
text_longueur = ''
# print(text_longueur)
else:
consigne_lines.append(consigne)
serie_page_vertical = int(PAGE_LINES[police] / \
(nb_in_serie + 1 + len(consigne_lines)) )
rest_line = PAGE_LINES[police] - (serie_page_vertical * nb_in_serie + serie_page_vertical * len(consigne_lines) + serie_page_vertical)
max_length = len(exo_exemple) if len(exo_exemple) > longueur_max else longueur_max
max_in_line = 2 * MAX_LENGTH[police]
space = max_in_line / 8
nb_in_line = int(max_in_line / (max_length + space)) + 1
for p in range(nb_page):
for c in range(serie_page_vertical):
for w in consigne_lines:
writer.writerow([*[w, ""] * nb_in_line])
for k in range(nb_in_serie):
calcul_list = list(
map(lambda calc: calc['calcul'], Generateur(path, nb_in_line, 'csv')))
n = 1
for i in range(n, len(calcul_list)+ n + 1 , n+1):
calcul_list.insert(i, '')
writer.writerow(calcul_list)
writer.writerow([''])
for r in range(rest_line):
writer.writerow([''])

View File

@ -0,0 +1,51 @@
import re
import importlib.util
def getObjectKey(obj, key):
if obj[key] == None:
return None
return key if obj[key] != False else 'calcul' if obj['calcul'] != False else None
def getCorrectionKey(obj, key):
return key if (obj[key] != False and obj['correction'] == False) else 'calcul' if(obj['calcul'] != False and obj['correction'] == False) else 'correction' if obj['correction'] != False else None
def parseCorrection(calc, replacer='...'):
exp_list = re.findall(r"\[([A-Za-z0-9_]+)\]", calc)
for exp in exp_list:
calc = calc.replace(f'[{exp}]', replacer)
return calc
def Generateur(path, quantity, key):
spec = importlib.util.spec_from_file_location(
"tmp", path)
tmp = importlib.util.module_from_spec(spec)
spec.loader.exec_module(tmp)
try:
main_func = tmp.main
except:
return None
main_result = main_func()
default_object = {"calcul": False, 'pdf': False, 'csv': False,
'web': False, 'correction': False} # les valeurs par défaut
# Si l'utilisateur n'a pas entré une valeur, elle est définie à False
result_object = {**default_object, **main_result}
print(result_object)
object_key = getObjectKey(result_object, key)
correction_key = getCorrectionKey(result_object, key)
op_list = []
try:
replacer = tmp.CORRECTION_REPLACER
except:
replacer = '...'
for i in range(quantity):
main_result = main_func()
main = {**default_object, **main_result}
op_list.append({'calcul': parseCorrection(main[
object_key], replacer) if (key != 'web' and main['correction'] == False) else main[object_key], 'correction': main[correction_key]})
return op_list

View File

@ -0,0 +1,4 @@
from .verif import Verificateur
from .nbletter import nbletter
from .random_verif import *
from .print_settings import printer_set

View File

@ -0,0 +1,161 @@
def nbletter(nombre):
ten_pre = {'2': "vingt-",
'3': "trente-",
"4": "quarante-",
"5": "cinquante-",
"6": "soixante-",
"7": "soixante-",
"8": "quatre-vingt-"}
chiffre = {'0': "zéro ",
'1': "un",
'2': "deux",
'3': "trois",
'4': "quatre",
'5': "cinq",
'6': "six",
'7': "sept",
'8': "huit",
'9': "neuf",
'10': "dix",
'11': "onze",
'12': "douze",
'13': "treize",
'14': "quatorze",
'15': "quinze",
'16': "seize",
'20': "vingt",
'30': "trente",
'40': "quarante",
'50': "cinquante",
'60': "soixante",
'70': "soixante-dix",
'80': "quatre-vingts",
'90': "quatre-vingt-dix",
'100': "cent",
'71': "soixante et onze",
'91': "quatre-vingts-onze"}
for i in range(7, 10):
chiffre[str(i+10)] = "dix-"+chiffre[str(i)]
for x in range(2, 7):
#print(str(x * 10))
chiffre[str(x) +
"1"] = chiffre[str(x * 10)] + " et un"
#print("\n", chiffre.get(61))
for y in range(1, 10):
#print(90+y)
chiffre[str(90 + y)] = "quatre-vingts-" + \
chiffre[str(y + 10)]
for y in range(1, 10):
#print(90+y)
chiffre[str(70 + y)] = "soixante-" + \
chiffre[str(y + 10)]
#print(chiffre["99"])
def cent(nb):
if nb[0] == '0':
return ''
elif nb[0] == '1':
return 'cent-'
else:
return chiffre[nb[0]] + '-cent'
def dizaine(nb):
#print('dizaine', nb, nb[0] == '0', nb[1] == '0')
if nb[0] == '0' and nb[1] != '0':
return '-' + chiffre[nb[1]]
elif nb[0] == '1':
return '-' + chiffre[nb]
elif nb[0] == '9':
return '-' + chiffre[nb]
elif nb[0] == '7':
return '-' + chiffre[nb]
elif nb[0] == '0' and nb[1] == '0':
#print('00000')
return ''
elif nb[1] == '0':
#print('2 0')
return ten_pre[nb[0]].replace('-', '')
else:
#print('nope')
return '-' + ten_pre[nb[0]] + chiffre[nb[1]]
def mille(nb):
if nb[0] == '1':
return 'mille-'
else:
return chiffre[nb[0]] + '-mille-'
def letter(nbrond):
if len(nbrond) == 3:
return cent(nbrond) + dizaine(nbrond[1:])
if len(nbrond) == 4:
return mille(nbrond) + cent(nbrond[1:4]) + dizaine(nbrond[2:4])
else:
if nbrond[0] == '0' and len(nbrond) == 2:
return chiffre[nbrond[1]]
if nbrond[0] == '1' and len(nbrond) == 2:
return chiffre[nbrond]
else:
part = ten_pre[str(nbrond[0])]
return part+str(chiffre[nbrond[1]])
def deciSuffixe(nb):
deciWords = ['dixième', ' centième', ' millième']
if int(nb.replace('0', '')) == 1 and nb[0] == '0':
return deciWords[len(nb) - 1] + ' '
else:
return deciWords[len(nb) - 1] + 's '
if str(nombre).count('.') == 1:
avirgule = str(nombre).split(".")[0]
aprevirgule = str(nombre).split(".")[1]
#print(avirgule)
try:
avirgule = chiffre[str(avirgule)]
#print("try")
except:
avirgule = letter(avirgule)
#print(avirgule)
#print(aprevirgule)
deciWords = ['dixièmes ', ' centièmes', ' millièmes']
aprevirgule = letter(aprevirgule) + deciSuffixe(aprevirgule)
#print(f"{avirgule}, {aprevirgule}")
return avirgule + " et " + aprevirgule
if str(nombre).count('.') == 0:
nb = str(nombre)
#print(avirgule)
def letter(nbrond):
if len(nbrond) == 3:
return cent(nbrond) + dizaine(nbrond[1:])
if len(nbrond) == 4:
return mille(nbrond) + cent(nbrond[1:4]) + dizaine(nbrond[2:4])
else:
part = ten_pre[str(nbrond[0])]
return part+str(chiffre[nbrond[1]])
try:
nb = chiffre[str(nb)]
#print("try")
except:
nb = letter(nb)
#print(avirgule)
return nb
else:
return 'error'

View File

@ -0,0 +1,44 @@
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,
}

View File

@ -0,0 +1,25 @@
from .verif import Verificateur
import random
verifi = Verificateur()
def integer(nb1, nb2):
pass
def floater(nb1, nb2, rounder):
verifi.set_interval(nb1, nb2)
ran = verifi.verif(round(random.uniform(nb1, nb2), rounder))
return ran
def reinit():
verifi.reinit()
lister = []
ver = []
for x in range(1, 101):
lister.append(floater(1.0, 200.83, 2))
for x in range(0, len(lister)):
ver.append(lister.count(lister[x]))

View File

@ -0,0 +1,96 @@
import random
import sys
sys.setrecursionlimit(1000000000)
class Verificateur():
""" obj verif"""
def __init__(self):
self.nblist = []
self.nb1 = 1
self.nb2 = 10
self.i = 0
def set_interval(self,nb1 = 1, nb2 = 10):
self.nb1 = nb1
self.nb2 = nb2
def verif(self, nb):
if type(nb) == float:
self.nb = str(nb).split(".")
#print(self.nb)
#print("\n")
self.nb = len(self.nb[1])
#print(self.nb)
self.len = (self.nb2 - self.nb1) * 10 ** self.nb
elif type(nb) == int:
self.len = self.nb2 - self.nb1
else:
pass
if len(self.nblist) >= self.len:
#print(f"test : {self.nblist}")
return nb
if self.nblist.count(nb) < 1:
self.nblist.append(nb)
#print(self.nblist)
#print("bon")
return nb
else:
if type(nb) == int:
self.n = 0
self.n = random.randint(self.nb1, self.nb2)
#print(f"C'EST N = {self.n}")
#print(f"Faux : {nb}; test : {self.n}")
# print(f"except : {self.n} ; {self.nblist.count(self.n)}, tour : {self.i}")
self.i += 1
return self.verif(self.n)
if type(nb) == float:
self.n = 0
self.n = round(random.uniform(self.nb1, self.nb2), len(str(nb).split(".")[1]))
#print(f"C'EST N = {self.n}")
#print(f"Faux : {nb}; test : {self.n}")
# print(f"except : {self.n} ; {self.nblist.count(self.n)}, tour : {self.i}")
self.i += 1
return self.verif(self.n)
#return self.n
def int_verif(self, nb, nb1, nb2):
if self.nblist.count(nb) < 1:
self.nblist.append(nb)
# print(self.nblist)
return True
else:
#print(len(self.nblist))
if len(self.nblist) == nb2:
print("BREAAAAAAK")
return input()
self.n = random.randint(nb1, nb2)
print(f"Faux : {nb}; test : {self.n}")
self.int_verif(self.n, nb1, nb2)
print(self.nblist)
return False
def reinit(self):
self.nblist[:] = []
self.nb1 = 1
self.nb2 = 10
"""test.verif(5)
for x in range(1, 10):
n = random.randint(1, 10)
print(f"{test.verif(n)}")
print(test.nblist)
for x in range(0, len(test.nblist)):
print(test.nblist.count(x))
"""

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

33
backend/api/api/asgi.py Normal file
View File

@ -0,0 +1,33 @@
"""
ASGI config for api project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.security.websocket import AllowedHostsOriginValidator
import room.routing
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'api.settings')
application = get_asgi_application()
application = ProtocolTypeRouter({
"http": get_asgi_application(),
"websocket": AllowedHostsOriginValidator(
AuthMiddlewareStack(
URLRouter(
room.routing.websocket_urlpatterns
)
)
),
# Just HTTP for now. (We can add other protocols later.)
})

188
backend/api/api/settings.py Normal file
View File

@ -0,0 +1,188 @@
"""
Django settings for api project.
Generated by 'django-admin startproject' using Django 4.0.3.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-*9shuddjs^!i00=go!8a=^8bmdje*ex3dbj7hv2(((m^u3$lap'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['192.168.1.18', 'localhost', '127.0.0.1']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
#3rd party
'rest_framework',
'corsheaders',
'channels',
#local
'exercices',
'room',
]
''' REST_FRAMEWORK = {
'DATETIME_FORMAT': "%m/%d/%Y %I:%M%P",
'DEFAULT_AUTHENTICATION_CLASSES': ['rest_framework.authentication.TokenAuthentication',
],
} '''
MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware",
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies"
#CORS
CORS_ALLOWED_ORIGINS = ['http://localhost:8000', 'http://141.136.42.178:8001', 'http://141.136.42.178:8002', 'http://141.136.42.178:80', 'http://lilandco42.com',
'http://127.0.0.1:8002', 'http://localhost:8001', 'http://192.168.1.18:8000']
CSRF_TRUSTED_ORIGINS = ['http://localhost:8000', 'http://141.136.42.178:8001', 'http://141.136.42.178:8002', 'http://141.136.42.178:80', 'http://lilandco42.com',
'http://127.0.0.1:8002', 'http://localhost:8001', 'http://192.168.1.18:8000']
CORS_ALLOW_HEADERS = [
"accept",
"accept-encoding",
"authorization",
"content-type",
"dnt",
"origin",
"user-agent",
"x-csrftoken",
"x-requested-with",
'access-control-allow-origin',
]
ROOT_URLCONF = 'api.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
{
'NAME': 'tex',
'BACKEND': 'django_tex.engine.TeXEngine',
'APP_DIRS': True,
'DIRS': [
'exercices/tex'
],
},
]
WSGI_APPLICATION = 'api.wsgi.application'
ASGI_APPLICATION = "api.asgi.application"
# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/
LANGUAGE_CODE = 'fr-FR'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
MEDIA_ROOT= os.path.join(BASE_DIR)
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": [("127.0.0.1", 6379)],
},
},
}

24
backend/api/api/urls.py Normal file
View File

@ -0,0 +1,24 @@
"""api URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('api/admin/', admin.site.urls),
path('api/exos/', include('exercices.urls')),
path('api/room/', include('room.urls')),
#path('api/users/', include('users.urls'))
]

16
backend/api/api/wsgi.py Normal file
View File

@ -0,0 +1,16 @@
"""
WSGI config for api project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'api.settings')
application = get_wsgi_application()

BIN
backend/api/db.sqlite3 Normal file

Binary file not shown.

View File

Some files were not shown because too many files have changed in this diff Show More