/** * @param Form $form */ public function filterFormSubmited(Form $form) { $values = $form->getValues(); if ($values->id) { $this->filter->setIdsPages(Filter::createFilterArray($values->id)); } if ($values->subquestions) { $this->filter->setSubquestions(Filter::createFilterArray($values->subquestions)); } if ($values->correct) { $this->filter->setCorrect(Filter::createFilterArray($values->correct)); } if ($values->almost) { $this->filter->setAlmost(Filter::createFilterArray($values->almost)); } if ($values->wrong) { $this->filter->setWrong(Filter::createFilterArray($values->wrong)); } if ($values->disqualified) { $this->filter->setDisqualified(Filter::createFilterArray($values->disqualified)); } if ($values->percentages) { $this->filter->setPercentages(Filter::createFilterArray($values->percentages)); } if ($values->order) { $order_arr = array(); foreach ($values->order as $item) { if ($item->by && $item->dir) { $order_arr[$item->by] = $item->dir; } } if (count($order_arr) > 0) { $this->filter->setOrderBy($order_arr); } } $this->redrawControl(); }
/** * @param Form $form */ public function filterFormSubmited(Form $form) { $values = $form->getValues(); if ($values->id) { $this->filter->setRespondents(Filter::createFilterArray($values->id)); } if ($values->percentages) { $this->filter->setPercentages(Filter::createFilterArray($values->percentages)); } if ($values->questions) { $this->filter->setQuestions(Filter::createFilterArray($values->questions)); } if ($values->subquestions) { $this->filter->setSubquestions(Filter::createFilterArray($values->subquestions)); } if ($values->correct) { $this->filter->setCorrects(Filter::createFilterArray($values->correct)); } if ($values->wrong) { $this->filter->setWrongs(Filter::createFilterArray($values->wrong)); } if ($values->almost) { $this->filter->setAlmosts(Filter::createFilterArray($values->almost)); } if ($values->unknown) { $this->filter->setUnknowns(Filter::createFilterArray($values->unknown)); } if ($values->disqualified) { $this->filter->setDisqualified(Filter::createFilterArray($values->disqualified)); } if ($values->websites) { $this->filter->setWebsites($values->websites); } if ($values->datetime) { $this->filter->setDatetimes(Filter::createFilterArray($values->datetime)); } if ($values->age) { $this->filter->setAges(Filter::createFilterArray($values->age)); } if ($values->devices) { $this->filter->setDevices(Filter::createFilterArray($values->devices)); } if ($values->device_most) { $this->filter->setDevicesMost(Filter::createFilterArray($values->device_most)); } if ($values->gender) { $this->filter->setGenders(Filter::createFilterArray($values->gender)); } if ($values->english) { $this->filter->setEnglishes(Filter::createFilterArray($values->english)); } if ($values->it) { $this->filter->setIts(Filter::createFilterArray($values->it)); } if ($values->order) { $order_arr = array(); foreach ($values->order as $item) { if ($item->by && $item->dir) { $order_arr[$item->by] = $item->dir; } } if (count($order_arr) > 0) { $this->filter->setOrderBy($order_arr); } } $this->redrawControl(); }
/** * @param \App\Filter\Results\Respondents $filter * @return \App\Holder\Results\Base\Respondent[] */ public function getResultsRespondent($filter = null) { $query = $this->entityManager->getRepository($this->repositoryName)->createQueryBuilder(); $query->select("respondent"); $query->addSelect("count(distinct question.id_question) as total_questions"); $query->addSelect("count(distinct subquestion.id_subquestion) as total_subquestions"); $query->addSelect("countif('state','=','1') as total_correct_subquestions"); $query->addSelect("countif('state','=','0') as total_wrong_subquestions"); $query->addSelect("countif('state','=','2') as total_almost_subquestions"); $query->addSelect("countif('state','=','3') as total_disqualified_subquestions"); $query->addSelect("countif('state','is','null') as total_unknown_subquestions"); $query->addSelect("round((countif('state','=','1') / (countif('state','=','0') + countif('state','=','1') + countif('state','=','2')))*100,2) as total_correct_subquestions_percents"); $query->from(Model\Respondent::getClassName(), "respondent"); $query->leftJoin(Model\Question::getClassName(), "question", Join::WITH, "question.id_respondent = respondent.id_respondent"); $query->leftJoin(Model\Subquestion::getClassName(), "subquestion", Join::WITH, "subquestion.id_question = question.id_question"); if ($filter !== null) { $this->createNumberCondition($filter->getRespondents(), $query, "respondent.id_respondent"); $this->createNumberCondition($filter->getPercentages(), $query, "round((countif('state','=','1') / (countif('state','=','0') + countif('state','=','1') + countif('state','=','2')))*100,2)", true); $this->createNumberCondition($filter->getQuestions(), $query, "count(distinct question.id_question)", true); $this->createNumberCondition($filter->getSubquestions(), $query, "count(distinct subquestion.id_subquestion)", true); $this->createNumberCondition($filter->getCorrects(), $query, "countif('state','=','1')", true); $this->createNumberCondition($filter->getWrongs(), $query, "countif('state','=','0')", true); $this->createNumberCondition($filter->getAlmosts(), $query, "countif('state','=','2')", true); $this->createNumberCondition($filter->getDisqualified(), $query, "countif('state','=','3')", true); $this->createNumberCondition($filter->getUnknowns(), $query, "countif('state','is','null')", true); $this->createNumberCondition($filter->getDatetimes(), $query, "date(respondent.datetime)"); $this->createNumberCondition($filter->getAges(), $query, "respondent.age"); $this->createNumberCondition($filter->getDevicesMost(), $query, "respondent.device_most"); $this->createNumberCondition($filter->getGenders(), $query, "respondent.gender"); $this->createNumberCondition($filter->getEnglishes(), $query, "respondent.english"); $this->createNumberCondition($filter->getIts(), $query, "respondent.it"); $this->createStringCondition($filter->getWebsites(), $query, "respondent.sites"); if ($filter->getDevices() !== null) { $exprs = array(); foreach ($filter->getDevices() as $device) { switch ($device) { case Model\Respondent::DEVICE_COMPUTER: $exprs[] = "respondent.device_computer = 1"; break; case Model\Respondent::DEVICE_PHONE: $exprs[] = "respondent.device_phone = 1"; break; case Model\Respondent::DEVICE_TABLET: $exprs[] = "respondent.device_tablet = 1"; break; } } if (count($exprs) > 0) { $query->andWhere(implode(" or ", $exprs)); } } if (is_array($filter->getOrderBy()) && count($filter->getOrderBy()) > 0) { $this->createOrders($filter->getOrderBy(), $query); } else { $query->orderBy("respondent.id_respondent", "desc"); } } $query->groupBy("respondent.id_respondent"); return $this->getHolders($query, new \App\Holder\Mapper\Results\Base\Respondent()); }