Commit 7a39920a authored by Martin Gregor's avatar Martin Gregor
Browse files

pridanie cislovania viet

parent 8d0ef60c
......@@ -20,11 +20,10 @@ class HomepagePresenter extends BasePresenter
{
if (!isset($_POST['sentence_id']))
{
$count = $this->db->table('sentences')->count("*");
$count = $this->db->table('sentences')->count("*");
if ($count)
{
$this->sentence_id = (time() % $count) + 1;
$current_sentence_id = $this->sentence_id;
$this->sentence_id = $this->db->query('SELECT id FROM sentences ORDER BY RAND() LIMIT 1')->fetch()->id;
$sentenceIdSession = $this->getSession('sentenceIdSession');
......@@ -35,14 +34,14 @@ class HomepagePresenter extends BasePresenter
}
// vyhladanie nezobrazenej vety
while (in_array($current_sentence_id,$sentenceIdSession->ids))
while (in_array($this->sentence_id,$sentenceIdSession->ids))
{
$current_sentence_id = mt_rand(1, $count);
$this->sentence_id = $this->db->query('SELECT id FROM sentences ORDER BY RAND() LIMIT 1')->fetch()->id;
}
// ulozenie id vybranej vety a ziskanie vety z db
$sentenceIdSession->ids[] = $current_sentence_id;
$sentence = $this->db->table('sentences')->get($current_sentence_id);
$sentenceIdSession->ids[] = $this->sentence_id;
$sentence = $this->db->table('sentences')->get($this->sentence_id);
// rozdelenie vety na slova a inicializacia pola duplicit
$this->words = explode(' ', $sentence->sentence);
......@@ -70,10 +69,11 @@ class HomepagePresenter extends BasePresenter
protected function createComponentTranslationForm()
{
$form = new Nette\Application\UI\Form();
foreach ($this->sentences as $id => $sentence)
{
$form->addGroup();
$label = \Nette\Utils\Html::el()->setHtml('<div class="well well-sm">'.$sentence[0].'</div>');
$label = \Nette\Utils\Html::el()->setHtml('<div class="well well-sm">#'.$id.' '.$sentence[0].'</div>');
$form->addRadioList('sentence'.$id,$label,['correct' => 'Správne','incorrect' => 'Nesprávne']);
foreach ($sentence[1] as $position => $word)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment