public function render() { $pages = $this->page_service->getResultsPages($this->filter); $template = $this->prepareTemplate(); $template->pages = $pages; $template->count = count($pages); $template->render(); }
/** * @param Form $form */ public function colorSelectFormSubmitted(Form $form) { $values = $form->getValues(); $subquestion = $this->subquestion_service->saveBaseProperties($values); // rekonstrukce puvodnich id_pages $id_page = $this->question_service->get($subquestion->id_question)->id_page; $options = array(); if ($subquestion->id_page_related !== null) { $related = $this->page_service->getRelatedPagesByFilter(new PageRelated(array(PageRelated::IDS_PAGE_RELATED => array($subquestion->id_page_related), \App\Base\Filter::GROUP_BY => true))); if (count($related) === 1 && $related[0] !== null) { $pages = $related[0]->getPagesRelatedAsArray(); $options = array($pages[0]->getPage()->id_page => "", $pages[1]->getPage()->id_page => ""); } } // $pages = $this->page_service->getRelatedPages($id_page); // $options = array($id_page=>"",$pages[0]->id_page); $form->getComponent("id_pages")->setItems($options); $values = $form->getValues(); $subquestion->state = $values->id_pages === (int) $id_page ? \App\Model\Subquestion::STATE_CORRECT : \App\Model\Subquestion::STATE_WRONG; $subquestion->answer = $values->id_pages; $this->subquestion_service->save($subquestion); if ($form['cancel']->isSubmittedBy()) { $this->redirect("Survey:final"); } if ($this->sessionSection->id_respondent === null) { $this->sessionSection->id_question = $subquestion->id_question; $this->redirect("Survey:personal"); } else { $this->redirect("Survey:question"); } }
/** * @param int $id_respondent * @return \App\Holder\PageRelated[] */ public function getDuelsPagesByIdRespondent($id_respondent) { $subquestions = $this->database->getSubquestionHoldersByIdRespondent($id_respondent); $ids_page_related = array(); foreach ($subquestions as $subquestion) { if ($subquestion->getSubquestion()->id_page_related !== null && !in_array($subquestion->getSubquestion()->id_page_related, $ids_page_related)) { $ids_page_related[] = $subquestion->getSubquestion()->id_page_related; } } if (count($ids_page_related) === 0) { $ids_page_related[] = null; } return $this->page_service->getRelatedPagesByFilter(new PageRelated(array(PageRelated::DUEL => true, PageRelated::IDS_PAGE_RELATED => $ids_page_related, Filter::GROUP_BY => true))); }
protected function createComponentFilterForm() { $websites_arr = array(); foreach ($this->website_service->getAll() as $website) { $websites_arr[$website->id_website] = $website->name; } $pages_arr = array(); foreach ($this->page_service->getBasePageHolders() as $pageHolder) { $pages_arr[$pageHolder->getPage()->id_page] = $pageHolder->getWebsite()->name . " - " . $pageHolder->getPage()->name; } $form = new \Nette\Application\UI\Form(); $form->addGroup('Filtrování'); $form->addText('id', 'Id'); $form->addText('id_question', 'Rodič'); $input_respondent = $form->addText('id_respondent', 'Respondent'); if ($this->id_respondent !== null) { $input_respondent->setDefaultValue($this->id_respondent); } $form->addText('wireframe', 'Wireframe'); $form->addText('datetime', 'Čas'); $form->addCheckboxList('state', 'Stav', array(\App\Model\Subquestion::STATE_CORRECT => "OK", \App\Model\Subquestion::STATE_ALMOST => "téměř", \App\Model\Subquestion::STATE_WRONG => "NE", \App\Model\Subquestion::STATE_DISQUALIFIED => "nepočítat")); $form->addText('answer', 'Odpověď'); $form->addText('reason', 'Důvod'); $form->addText('type', 'Typ'); $form->addText('seconds', 'Sekundy'); $form->addCheckboxList('know', 'Zná?', array("null" => "nevyplněno", RespondentWebsite::PERIOD_DONT_KNOW => 'neznám', RespondentWebsite::PERIOD_KNOW_THAT_EXISTS => 'vím, že existuje', RespondentWebsite::PERIOD_KNOW_AND_VISIT => 'znám a navštěvuji')); $websites = $form->addDynamic("id_website", function (Container $website) use($websites_arr) { $website->addSelect("id_website", "Web", $websites_arr); $website->addSubmit('removeWebsite', 'Odstranit')->setAttribute("class", "ajax btn btn-xs")->setValidationScope(FALSE)->onClick[] = array($this, 'removeItem'); }); $websites->addSubmit('addWebsite', 'Přidat web')->setValidationScope(FALSE)->setAttribute("class", "ajax btn btn-xs")->onClick[] = array($this, 'addItem'); $pages = $form->addDynamic("id_page", function (Container $website) use($pages_arr) { $website->addSelect("id_page", "Stránka", $pages_arr); $website->addSubmit('removePage', 'Odstranit')->setAttribute("class", "ajax btn btn-xs")->setValidationScope(FALSE)->onClick[] = array($this, 'removeItem'); }); $pages->addSubmit('addPage', 'Přidat stránku')->setValidationScope(FALSE)->setAttribute("class", "ajax btn btn-xs")->onClick[] = array($this, 'addItem'); $this->addOrder($form, array('subquestion.id_subquestion' => "id", 'question.id_question' => "rodič", 'subquestion.seconds' => 'sekundy', 'question.id_respondent' => 'respondent', 'subquestion.datetime' => 'čas')); $form->onSuccess[] = $this->filterFormSubmited; $form->addGroup(); $form->addSubmit('filter', 'Filtrovat')->setAttribute("class", "btn btn-primary ajax"); return $form; }
public function renderDefault() { $this->template->base = $this->respondent_service->getResultsBase(); $this->template->base_respondents = $this->respondent_service->getResultsRespondentsBase(); $this->template->pages = $this->page_service->getResultsPages(); }