|
@ -100,9 +100,11 @@ def gen_resitele(rnd, osoby, skoly): |
|
|
|
|
|
|
|
|
def gen_prijemci(rnd, osoby, kolik=10): |
|
|
def gen_prijemci(rnd, osoby, kolik=10): |
|
|
prijemci = [] |
|
|
prijemci = [] |
|
|
|
|
|
osoby = [] |
|
|
|
|
|
for i in range(kolik): |
|
|
|
|
|
osoby.append(rnd.choice(osoby)) |
|
|
for i in range(kolik): |
|
|
for i in range(kolik): |
|
|
rand_os = rnd.choice(osoby) |
|
|
prijemci.append(Prijemce.objects.create(osoba=osoby[i])) |
|
|
prijemci.append(Prijemce.objects.create(osoba=rand_os)) |
|
|
|
|
|
return prijemci |
|
|
return prijemci |
|
|
|
|
|
|
|
|
def gen_organizatori(rnd, osoby, last_rocnik, users): |
|
|
def gen_organizatori(rnd, osoby, last_rocnik, users): |
|
@ -169,13 +171,22 @@ def gen_ulohy_do_cisla(rnd, cislo, organizatori, resitele, slovnik_cisel, size): |
|
|
rnd.choice(jmeno), |
|
|
rnd.choice(jmeno), |
|
|
rnd.choice(kde)] |
|
|
rnd.choice(kde)] |
|
|
) |
|
|
) |
|
|
p.vzorak = " - ".join([p.zadani, rnd.choice(reseni)]) |
|
|
|
|
|
|
|
|
#Tomův pokus o opravu bugu: |
|
|
|
|
|
text_vzoraku = Text.objects.create( |
|
|
|
|
|
na_web = rnd.choice(reseni), |
|
|
|
|
|
do_cisla = rnd.choice(reseni) |
|
|
|
|
|
) |
|
|
|
|
|
vzorak = TextNode.objects.create(text = text_vzoraku) |
|
|
|
|
|
uloha_vzorak = UlohaVzorakNode.objects.create(uloha=p, first_child = vzorak) |
|
|
|
|
|
p.UlohaVzorakNode = uloha_vzorak |
|
|
|
|
|
|
|
|
p.opravovatele = rnd.sample(organizatori, poc_op) |
|
|
p.opravovatele = rnd.sample(organizatori, poc_op) |
|
|
p.save() |
|
|
p.save() |
|
|
|
|
|
|
|
|
# reseni ulohy |
|
|
# reseni ulohy |
|
|
poc_reseni = rnd.randint(size // 2, size * 2) |
|
|
poc_reseni = rnd.randint(size // 2, size * 2) |
|
|
poc_resitel = rnd.randint(1, 3) |
|
|
#poc_resitel = rnd.randint(1, 3) <- k čemu je himbajs tahle proměnná? |
|
|
# vybereme nahodny vzorek resitelu o delce poctu reseni |
|
|
# vybereme nahodny vzorek resitelu o delce poctu reseni |
|
|
# (nebo skoro vsechny resitele, pokud jich je mene nez pocet reseni) |
|
|
# (nebo skoro vsechny resitele, pokud jich je mene nez pocet reseni) |
|
|
res_vyber = rnd.sample(resitele, min(poc_reseni, len(resitele) - 2)) |
|
|
res_vyber = rnd.sample(resitele, min(poc_reseni, len(resitele) - 2)) |
|
@ -204,8 +215,7 @@ def gen_soustredeni(): |
|
|
datum_zacatku=datetime.date(2000, 11, 23), |
|
|
datum_zacatku=datetime.date(2000, 11, 23), |
|
|
datum_konce=datetime.date(2000, 11, 27) |
|
|
datum_konce=datetime.date(2000, 11, 27) |
|
|
) |
|
|
) |
|
|
|
|
|
for res in rnd.sample(resitele, min(len(resitele), 20)): |
|
|
for res in rnd.sample(resitele, 6): |
|
|
|
|
|
Soustredeni_Ucastnici.objects.create(resitel=res, soustredeni=sous) |
|
|
Soustredeni_Ucastnici.objects.create(resitel=res, soustredeni=sous) |
|
|
sous.save() |
|
|
sous.save() |
|
|
|
|
|
|
|
@ -276,14 +286,15 @@ def create_test_data(size = 6, rnd = None): |
|
|
|
|
|
|
|
|
# posledni 2 cisla v rocniku nemaji deadline |
|
|
# posledni 2 cisla v rocniku nemaji deadline |
|
|
if (ci + 2 > cisel): |
|
|
if (ci + 2 > cisel): |
|
|
deadline = datetime.date(r.druhy_rok, ci - 1, |
|
|
|
|
|
rnd.randint(1, 28)) |
|
|
|
|
|
else: |
|
|
|
|
|
deadline = None |
|
|
deadline = None |
|
|
|
|
|
|
|
|
cislo = Cislo.objects.create(rocnik = r, cislo = str(ci), |
|
|
cislo = Cislo.objects.create( |
|
|
datum_vydani=vydano, datum_deadline=deadline, |
|
|
rocnik = r, |
|
|
verejne_db=True) |
|
|
cislo = str(ci), |
|
|
|
|
|
datum_vydani=vydano, |
|
|
|
|
|
datum_deadline=deadline, |
|
|
|
|
|
verejne_db=True |
|
|
|
|
|
) |
|
|
slovnik_cisel[ci] = cislo |
|
|
slovnik_cisel[ci] = cislo |
|
|
|
|
|
|
|
|
# generovani uloh |
|
|
# generovani uloh |
|
@ -339,7 +350,17 @@ def create_test_data(size = 6, rnd = None): |
|
|
max_body = rnd.randint(1, 8)) |
|
|
max_body = rnd.randint(1, 8)) |
|
|
p.zadani = " ".join([rnd.choice(sloveso), rnd.choice(koho), |
|
|
p.zadani = " ".join([rnd.choice(sloveso), rnd.choice(koho), |
|
|
rnd.choice(ceho), rnd.choice(jmeno), rnd.choice(kde)]) |
|
|
rnd.choice(ceho), rnd.choice(jmeno), rnd.choice(kde)]) |
|
|
p.vzorak = " - ".join([p.zadani, rnd.choice(reseni)]) |
|
|
|
|
|
|
|
|
#Tomův pokus o opravu bugu: |
|
|
|
|
|
text_vzoraku = Text.objects.create( |
|
|
|
|
|
na_web = rnd.choice(reseni), |
|
|
|
|
|
do_cisla = rnd.choice(reseni) |
|
|
|
|
|
) |
|
|
|
|
|
vzorak = TextNode.objects.create(text = text_vzoraku) |
|
|
|
|
|
uloha_vzorak = UlohaVzorakNode.objects.create(uloha=p, first_child = vzorak) |
|
|
|
|
|
p.UlohaVzorakNode = uloha_vzorak |
|
|
|
|
|
|
|
|
|
|
|
#p.vzorak = " - ".join([p.zadani, rnd.choice(reseni)]) |
|
|
p.save() |
|
|
p.save() |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -354,6 +375,10 @@ def create_test_data(size = 6, rnd = None): |
|
|
# FIXME: misto typu ruzne typy objektu a vnoreni do sebe |
|
|
# FIXME: misto typu ruzne typy objektu a vnoreni do sebe |
|
|
# TODO: vytvorit temata s ruznymi vlakny |
|
|
# TODO: vytvorit temata s ruznymi vlakny |
|
|
# TODO: nagenerovat starsim rocnikum pohadku |
|
|
# TODO: nagenerovat starsim rocnikum pohadku |
|
|
|
|
|
# TODO: nagenerovat články |
|
|
|
|
|
# TODO: nagenerovat konfery |
|
|
|
|
|
# TODO: vecpat obrázky všude, kde to jde |
|
|
|
|
|
# TODO: nagenerovat nějaký strom nodů? |
|
|
|
|
|
|
|
|
# TODO: nahodne nagenerovat problemum reseni a prilohy reseni, hodnoceni |
|
|
# TODO: nahodne nagenerovat problemum reseni a prilohy reseni, hodnoceni |
|
|
|
|
|
|
|
|