/**
  * @param $result
  * @return IHolder
  */
 public function populate($result)
 {
     $holder = new \App\Holder\Results\Base\Respondent();
     if (isset($result["respondent_id_respondent"])) {
         $holder->setRespondent(Service::populateEntity($result, \App\Model\Respondent::getClassName(), "respondent"));
     }
     if (isset($result["total_questions"])) {
         $holder->setTotalQuestions((int) $result["total_questions"]);
     }
     if (isset($result["total_subquestions"])) {
         $holder->setTotalSubquestions((int) $result["total_subquestions"]);
     }
     if (isset($result["total_correct_subquestions"])) {
         $holder->setTotalCorrectSubquestions((int) $result["total_correct_subquestions"]);
     }
     if (isset($result["total_wrong_subquestions"])) {
         $holder->setTotalWrongSubquestions((int) $result["total_wrong_subquestions"]);
     }
     if (isset($result["total_almost_subquestions"])) {
         $holder->setTotalAlmostSubquestions((int) $result["total_almost_subquestions"]);
     }
     if (isset($result["total_unknown_subquestions"])) {
         $holder->setTotalUnknownSubquestions((int) $result["total_unknown_subquestions"]);
     }
     if (isset($result["total_disqualified_subquestions"])) {
         $holder->setTotalDisqualifiedSubquestions((int) $result["total_disqualified_subquestions"]);
     }
     if (isset($result["total_correct_subquestions_percents"])) {
         $holder->setTotalCorrectSubquestionsPercents((double) $result["total_correct_subquestions_percents"]);
     }
     return $holder;
 }
 /**
  * @param $result
  * @return IHolder
  */
 public function populate($result)
 {
     $holder = new \App\Holder\Highscore();
     if (isset($result["respondent_id_respondent"])) {
         $holder->setRespondent(Service::populateEntity($result, \App\Model\Respondent::getClassName(), "respondent"));
     }
     if (isset($result["date"])) {
         $holder->setDate(new DateTime($result["date"]));
     }
     if (isset($result["count_questions"])) {
         $holder->setTotalQuestions((int) $result["count_questions"]);
     }
     if (isset($result["count_correct"])) {
         $holder->setTotalCorrect((int) $result["count_correct"]);
     }
     if (isset($result["score"])) {
         $holder->setScore((double) $result["score"]);
     }
     return $holder;
 }
 /**
  * @param $result
  * @return IHolder
  */
 public function populate($result)
 {
     $holder = new \App\Holder\Results\Base\Question();
     if (isset($result["question_id_question"])) {
         $holder->setQuestion(Service::populateEntity($result, \App\Model\Question::getClassName(), "question"));
     }
     if (isset($result["subquestion_id_subquestion"])) {
         $holder->setSubquestion(Service::populateEntity($result, \App\Model\Subquestion::getClassName(), "subquestion"));
     }
     if (isset($result["page_id_page"])) {
         $holder->setPage(Service::populateEntity($result, \App\Model\Page::getClassName(), "page"));
     }
     if (isset($result["website_id_website"])) {
         $holder->setWebsite(Service::populateEntity($result, \App\Model\Website::getClassName(), "website"));
     }
     if (isset($result["respondent_id_respondent"])) {
         $holder->setRespondent(Service::populateEntity($result, \App\Model\Respondent::getClassName(), "respondent"));
     }
     if (isset($result["respondentwebsite_id_respondent_website"])) {
         $holder->setRespondentWebsite(Service::populateEntity($result, \App\Model\RespondentWebsite::getClassName(), "respondentwebsite"));
     }
     return $holder;
 }
 /**
  * @param \App\Filter\Results\Subquestions $filter
  * @return \App\Holder\Results\Base\Question[]
  */
 public function getResultsSubquestion($filter = null)
 {
     $query = $this->entityManager->getRepository($this->repositoryName)->createQueryBuilder();
     $query->select("subquestion");
     $query->addSelect("question");
     $query->from(Model\Subquestion::getClassName(), "subquestion");
     $query->join(Model\Question::getClassName(), "question", Join::WITH, "subquestion.id_question = question.id_question")->addSelect("question");
     $query->join(Model\Page::getClassName(), "page", Join::WITH, "question.id_page = page.id_page")->addSelect("page");
     $query->join(Model\Website::getClassName(), "website", Join::WITH, "page.id_website = website.id_website")->addSelect("website");
     $query->join(Model\Respondent::getClassName(), "respondent", Join::WITH, "question.id_respondent = respondent.id_respondent")->addSelect("respondent");
     $query->leftJoin(Model\RespondentWebsite::getClassName(), "respondentwebsite", Join::WITH, $query->expr()->andX($query->expr()->eq('respondent.id_respondent', 'respondentwebsite.id_respondent'), $query->expr()->eq('website.id_website', 'respondentwebsite.id_website')))->addSelect("respondentwebsite");
     if ($filter !== null) {
         $this->createNumberCondition($filter->getIdRespondents(), $query, "respondent.id_respondent");
         $this->createNumberCondition($filter->getIdWireframe(), $query, "subquestion.id_wireframe");
         $this->createNumberCondition($filter->getSeconds(), $query, "subquestion.seconds");
         $this->createNumberCondition($filter->getTypes(), $query, "subquestion.question_type");
         $this->createNumberCondition($filter->getState(), $query, "subquestion.state");
         $this->createNumberCondition($filter->getKnowns(), $query, "respondentwebsite.period");
         $this->createNumberCondition($filter->getPages(), $query, "page.id_page");
         $this->createNumberCondition($filter->getWebsites(), $query, "website.id_website");
         $this->createNumberCondition($filter->getDatetimes(), $query, "subquestion.datetime");
         $this->createNumberCondition($filter->getIds(), $query, "subquestion.id_subquestion");
         $this->createNumberCondition($filter->getIdsQuestions(), $query, "question.id_question");
         $this->createStringCondition($filter->getAnswer(), $query, "subquestion.answer", "subquestion.answer");
         $this->createStringCondition($filter->getReason(), $query, "subquestion.reason", "subquestion.answer");
     }
     if (is_array($filter->getOrderBy()) && count($filter->getOrderBy()) > 0) {
         $this->createOrders($filter->getOrderBy(), $query);
     } else {
         $query->orderBy("subquestion.id_subquestion", "desc");
     }
     return $this->getHolders($query, new \App\Holder\Mapper\Results\Base\Question());
 }
 /**
  * @param $id_respondent
  * @return \App\Holder\Results\Respondent\Base
  */
 public function getResultsRespondentDetail($id_respondent)
 {
     $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->addSelect("avg(subquestion.seconds) avg_seconds");
     $query->addSelect("sum(subquestion.seconds) total_seconds");
     $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");
     $query->where($query->expr()->eq("respondent.id_respondent", $id_respondent));
     return $this->getHolder($query, new \App\Holder\Mapper\Results\Respondent\Base());
 }