|
|
@ -7,7 +7,7 @@ import django.contrib.auth |
|
|
|
from django.db import transaction |
|
|
|
import unidecode |
|
|
|
|
|
|
|
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Soustredeni_Organizatori, Osoba, Organizator, Prijemce, Tema, Uloha, Konfera, KonferaNode, RocnikNode |
|
|
|
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Soustredeni_Organizatori, Osoba, Organizator, Prijemce, Tema, Uloha, Konfera, KonferaNode, TextNode, UlohaVzorakNode, RocnikNode, CisloNode, TemaVCisleNode |
|
|
|
|
|
|
|
from django.contrib.flatpages.models import FlatPage |
|
|
|
from django.contrib.sites.models import Site |
|
|
@ -148,7 +148,7 @@ def gen_ulohy_do_cisla(rnd, cislo, organizatori, resitele, slovnik_cisel, size): |
|
|
|
"sporné", "nepopsatelně jednoduché", "pokud jste na to nepřišli," |
|
|
|
"tak jste fakt hloupí"] |
|
|
|
|
|
|
|
if cislo >= 3: |
|
|
|
if cislo >= 3: #TODO nagenerovat i nody!!! |
|
|
|
for pi in range(1, ((size + 1) // 2) + 1): |
|
|
|
poc_op = rnd.randint(1, 4) # počet opravovatelů |
|
|
|
poc_oboru = rnd.randint(1, 2) |
|
|
@ -368,52 +368,53 @@ def gen_ulohy_k_tematum(rocniky, slovnik_rocnik_cisla, slovnik_rocnik_temata): # |
|
|
|
for rocnik in rocniky: |
|
|
|
slovnik_cisel = slovnik_rocnik_cisla[rocnik] |
|
|
|
slovnik_temat = slovnik_rocnik_temata[rocnik] |
|
|
|
for cislo in slovnik_cisel: |
|
|
|
syn = cislo.CisloNode.first_child |
|
|
|
while syn != None: |
|
|
|
tema = syn.tema |
|
|
|
for i in range(1, rnd.randint(1, 4)) |
|
|
|
poc_op = rnd.randint(1, 4) |
|
|
|
poc_oboru = rnd.randint(1, 2) |
|
|
|
p = Uloha.objects.create( |
|
|
|
nazev=": ".join([tema.nazev, |
|
|
|
"úloha {}.".format(i)]), |
|
|
|
nadproblem=tema, |
|
|
|
stav=Problem.STAV_ZADANY, |
|
|
|
zamereni=tema.zamereni, |
|
|
|
autor=tema.autor, |
|
|
|
garant=tema.garant, |
|
|
|
opravovatele=rnd.sample(organizatori, poc_op), |
|
|
|
kod=str(i), |
|
|
|
cislo_zadani=cislo, |
|
|
|
cislo_reseni=slovnik_cisel[cislo.cislo+2], |
|
|
|
cislo_deadline=slovnik_cisel[cislo.cislo+2], |
|
|
|
max_body = rnd.randint(1, 8) |
|
|
|
) |
|
|
|
p.zadani = " ".join([rnd.choice(sloveso), rnd.choice(koho), |
|
|
|
rnd.choice(ceho), rnd.choice(jmeno), rnd.choice(kde)]) |
|
|
|
|
|
|
|
#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() |
|
|
|
|
|
|
|
|
|
|
|
syn = syn.succ |
|
|
|
|
|
|
|
|
|
|
|
# vytvor text |
|
|
|
# vytvor TemaVCisleNode |
|
|
|
if (rnd.randint(1, 3) % 3 == 0): |
|
|
|
# vytvor mezicislo Node |
|
|
|
pass |
|
|
|
for cislo in slovnik_cisel: |
|
|
|
syn = cislo.CisloNode.first_child |
|
|
|
while syn != None: |
|
|
|
if type(syn) != TemaVCisleNode |
|
|
|
continue |
|
|
|
else: |
|
|
|
tema = syn.tema |
|
|
|
for i in range(1, rnd.randint(1, 4)) |
|
|
|
poc_op = rnd.randint(1, 4) |
|
|
|
poc_oboru = rnd.randint(1, 2) |
|
|
|
p = Uloha.objects.create( |
|
|
|
nazev=": ".join([tema.nazev, |
|
|
|
"úloha {}.".format(i)]), |
|
|
|
nadproblem=tema, |
|
|
|
stav=Problem.STAV_ZADANY, |
|
|
|
zamereni=tema.zamereni, |
|
|
|
autor=tema.autor, |
|
|
|
garant=tema.garant, |
|
|
|
opravovatele=rnd.sample(organizatori, poc_op), |
|
|
|
kod=str(i), |
|
|
|
cislo_zadani=cislo, |
|
|
|
cislo_reseni=slovnik_cisel[cislo.cislo+2], |
|
|
|
cislo_deadline=slovnik_cisel[cislo.cislo+2], |
|
|
|
max_body = rnd.randint(1, 8) |
|
|
|
) |
|
|
|
p.zadani = " ".join([rnd.choice(sloveso), rnd.choice(koho), |
|
|
|
rnd.choice(ceho), rnd.choice(jmeno), rnd.choice(kde)]) |
|
|
|
|
|
|
|
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.save() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
syn = syn.succ |
|
|
|
|
|
|
|
|
|
|
|
# vytvor text |
|
|
|
# vytvor TemaVCisleNode |
|
|
|
if (rnd.randint(1, 3) % 3 == 0): |
|
|
|
# vytvor mezicislo Node |
|
|
|
pass |
|
|
|
|
|
|
|
@transaction.atomic |
|
|
|
def create_test_data(size = 6, rnd = None): |
|
|
@ -482,11 +483,6 @@ def create_test_data(size = 6, rnd = None): |
|
|
|
# generování úloh k tématům ve všech číslech |
|
|
|
gen_ulohy_k_tematum(rocniky, slovnik_rocnik_cisla, slovnik_rocnik_temata) |
|
|
|
|
|
|
|
# nagenerovat k tématu úlohy a Nody pro vsechna cisla |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# FIXME: misto typu ruzne typy objektu a vnoreni do sebe |
|
|
|
# TODO: vytvorit temata s ruznymi vlakny |
|
|
|
# TODO: nagenerovat starsim rocnikum pohadku |
|
|
|