src/Repository/Educational/WorkListRepository.php line 766

Open in your IDE?
  1. <?php
  2. namespace App\Repository\Educational;
  3. use App\Entity\Educational\Domain;
  4. use App\Entity\Educational\Lesson\ArtWorkStudy;
  5. use App\Entity\Educational\Lesson\WorkList;
  6. use App\Entity\Educational\Lesson\WorkListLine;
  7. use App\Entity\Educational\Lesson\WorkListNode;
  8. use App\Entity\Educational\SchoolBag\ReviewProgram;
  9. use App\Entity\Educational\SchoolBag\ReviewProgramLesson;
  10. use Bo\MainBundle\Entity\PackBac;
  11. use Bo\MainBundle\Entity\StudentPackBac;
  12. use Bo\MediaBundle\Entity\Video;
  13. use App\Entity\Educational\Chapter;
  14. use App\Entity\Educational\Course;
  15. use App\Entity\Educational\Discipline;
  16. use App\Entity\Educational\Serie;
  17. use App\Entity\Users\User;
  18. use Doctrine\ORM\Query\Expr\Join;
  19. use Doctrine\ORM\QueryBuilder;
  20. use Doctrine\Persistence\ManagerRegistry;
  21. class WorkListRepository extends AbstractRepository
  22. {
  23.     public function __construct(ManagerRegistry $registry)
  24.     {
  25.         parent::__construct($registryWorkList::class);
  26.     }
  27.     public function scriptADeleteAfterSetup(){
  28.         return $this->createQueryBuilder('w')
  29.             ->andWhere('w.pictureMobileId is not null')
  30.             ->getQuery()->getResult();
  31.     }
  32.     public function getWorklistByWn($id,$domainId){
  33.         return $this->createQueryBuilder('w')
  34.                 ->select('wn.slug,w.title,w.pictureMobilePath')
  35.                 ->join(WorkListNode::class,'wn',Join::WITH,'wn.worklist =w.id ')
  36.                 ->andWhere('wn.domain =:domainId and wn.id != :id and w.e3c = 0 and w.boost = 0 and w.stage = 0 and w.packBac = 0 and w.packBrevet = 0')
  37.             ->setParameters(['domainId'=>$domainId,'id'=>$id])
  38.             ->setMaxResults(10)
  39.             ->getQuery()->getResult();
  40.     }
  41.     public function getWorkListDisplay(Course $course,?Discipline $discipline,?Chapter $chapter){
  42.         $parameters = ['course'=>$course->getId()];
  43.         $result $this->createQueryBuilder('w')
  44.             ->select('wn.id as wnodeId,wk.title as wtitle,wk.picture as wpicture,cha.title,cha.slug,d.picture as posterChapter,w.picture as posterW,dis.title as dtitle,dis.slug as dslug,wk.freeAccess,wk.pictureFreeAccess')
  45.             ->join(WorkListNode::class,'wn',Join::WITH,'wn.worklist = w.id')
  46.             ->join('wn.worklist','wk')
  47.             ->join('wn.domain','d')
  48.             ->join('d.chapter','cha')
  49.             ->join('d.discipline','dis')
  50.             ->join('d.serie','s')
  51.             ->where('d.course =:course');
  52.             if(!is_null($discipline)){
  53.                 $result$result->andWhere('dis.slug =:disslug');
  54.                 $parameters array_merge(['disslug'=>$discipline->getSlug()],$parameters);
  55.             }
  56.             if(!is_null($chapter)){
  57.                 $result$result->andWhere('cha.slug =:chaslug');
  58.                 $parameters array_merge(['chaslug'=>$chapter->getSlug()],$parameters);
  59.             }
  60.             $result $result->andWhere('s.id = 4 and d.online = 1 and wk.stage = 0 and wk.e3c = 0 and wk.packBac = 0 and wk.packBrevet = 0 and wk.boost = 0')->setParameters($parameters)
  61.             ->orderBy('dis.order','asc')
  62.             ->getQuery()->getResult();
  63.         $tab = [];
  64.         if(!empty($result)){
  65.             foreach ($result as $row){
  66.                 $tab[$row['dtitle']][$row['title']][] = [
  67.                     'chaSlug'=>$row['slug'],
  68.                     'chaTitle'=>$row['title'],
  69.                     'chaPoster'=>$row['posterChapter'],
  70.                     'picture'=> $row['posterW'],
  71.                     'dslug'=>$row['dslug'],
  72.                     'wTitle'=>$row['wtitle'],
  73.                     'wPicture'=>$row['wpicture'],
  74.                     'wnodeId'=>$row['wnodeId'],
  75.                     'freeAccess'=>$row['freeAccess'],
  76.                     'pictureFreeAccess'=>$row['pictureFreeAccess']
  77.                 ];
  78.             }
  79.         }
  80.         return $tab;
  81.     }
  82.     public function getWorkListByDomainForPopinProgram($slug,$user,$artwork = [])
  83.     {
  84.         if(is_null($slug)){
  85.             return [];
  86.         }
  87.         $parameters = [
  88.             'slug' => $slug,
  89.         ];
  90.         $qb $this->_em->createQueryBuilder();
  91.         $q  $this
  92.             ->createQueryBuilder('w')
  93.             ->select('count(wl.id) as nbr,w.title,wn.slug,rp.percentProgression as percent,w.pictureMobilePath,wlpicture.picture as pictureMobile,w.freeAccess')
  94.             ->join(WorkListNode::class,'wn',Join::WITH,'wn.worklist=w.id');
  95.             if(!empty($artwork)){
  96.                 $q $q->join('wn.worklist','wk')
  97.                 ->leftjoin(ArtWorkStudy::class,'aws',Join::WITH,'wk.objectStudy=aws.id')
  98.                     ->andWhere(" (aws.id in (${artwork}) or wk.objectStudy is null )");
  99.             }
  100.              $q=$q->leftjoin('w.workListPictureMobile','wlpicture')
  101.             ->leftJoin(ReviewProgramLesson::class,'rp',Join::WITH,$qb->expr()->andX(
  102.                 $qb->expr()->eq('rp.student',$user->getId()),
  103.                 $qb->expr()->eq('rp.workListNode','wn.id')))
  104.             ->leftjoin(WorkListLine::class,'wl',Join::WITH,'wl.worklist = w.id')
  105.             ->join('wn.domain','d')
  106.             ->groupBy('w.id')
  107.             ->andWhere('d.slug = :slug and wn.folderNode = 1 and wn.online = 1')
  108.             ->setParameters($parameters)
  109.             ->orderBy('wn.position''ASC')
  110.             ->getQuery()
  111.             ->getResult();
  112.         return $q;
  113.     }
  114.     /**
  115.      * @param \Doctrine\ORM\QueryBuilder $queryBuilder
  116.      * @param string                     $relationName
  117.      * @param string                     $relationAlias
  118.      * @param null                       $alias
  119.      */
  120.     public static function leftJoin(QueryBuilder $queryBuilder$relationName$relationAlias$alias null)
  121.     {
  122.         $queryBuilder->leftJoin(
  123.             sprintf('%s.%s'$alias$relationName),
  124.             $relationAlias,
  125.             \Doctrine\ORM\Query\Expr\Join::WITH,
  126.             sprintf('%s.%s is null'$relationAlias'stage')
  127.         );
  128.         $queryBuilder->addSelect($relationAlias);
  129.     }
  130.     public function getWorkListTableStatementLines($id)
  131.     {
  132.         $q1 $this->_em->createQueryBuilder()
  133.                         ->select('w')
  134.                         ->from('BoWorkListBundle:WorkListTableStatementLine''w')
  135.                         ->join('w.statementLines''s')
  136.                         ->where('s.id=:id')
  137.                         ->setParameter('id'$id);
  138.         return $q1->getQuery()->getResult();
  139.     }
  140.     public function getWorkListTableQuiz($id)
  141.     {
  142.         $q1 $this->_em->createQueryBuilder()
  143.                         ->select('w')
  144.                         ->from('BoWorkListBundle:WorklistTableObjectExercise''w')
  145.                         ->join('w.objectExercise''o')
  146.                         ->where('o.id=:id')
  147.                         ->setParameter('id'$id);
  148.         return $q1->getQuery()->getResult();
  149.     }
  150.     public function getWorkListTableVideo($id)
  151.     {
  152.         $q1 $this->_em->createQueryBuilder()
  153.                         ->select('w')
  154.                         ->from('BoWorkListBundle:WorkListTableVideo''w')
  155.                         ->join('w.video''v')
  156.                         ->where('v.id=:id')
  157.                         ->setParameter('id'$id);
  158.         return $q1->getQuery()->getResult();
  159.     }
  160.     public function getWorkListsByReviewProgramId($reviewProgramId)
  161.     {
  162.         return $this
  163.             ->createQueryBuilder('wl')
  164.             ->andWhere('wl.studentReviewProgram = :reviewProgramId')
  165.             ->setParameters(
  166.                 [
  167.                     'reviewProgramId' => $reviewProgramId,
  168.                 ]
  169.             )
  170.             ->orderBy('wl.studentReviewProgramPosition''ASC')
  171.             ->getQuery()
  172.             ->getResult();
  173.     }
  174.     public function unlinkWorkListBeforeFlush(WorkList $entity$type)
  175.     {
  176.         $workListTypes = [
  177.             WorkListType::TYPE_ID_EXAM,
  178.             WorkListType::TYPE_ID_ETE,
  179.             WorkListType::TYPE_ID_RENTRE,
  180.         ];
  181.         if (in_array($type$workListTypes)) {
  182.             $packExamId null;
  183.             foreach ($entity->getWorklistPackExams() as $wp) {
  184.                 $wp->setWorklist(null);
  185.                 $this->_em->remove($wp);
  186.             }
  187.             return true;
  188.         }
  189.         if ($type == WorkListType::TYPE_ID_STAGE) {
  190.             $pt $entity->getProgramTraining();
  191.             $trainingId $pt[0]->getPlanningTraining()->getTraining()->getId();
  192.             foreach ($pt as $v) {
  193.                 $v->setWorklist(null);
  194.             }
  195.             return true;
  196.         }
  197.         return false;
  198.     }
  199.     /**
  200.      * @param $cId
  201.      * @param $sId
  202.      * @param $packId
  203.      *
  204.      * @return array
  205.      * @deprecated
  206.      */
  207.     public function getWorkListPackExamsByPack($cId$sId$packId)
  208.     {
  209.         $worklists = [];
  210.         if ($packId == PackBac::ID_PACK_BAC_2017) {
  211.             $qb $this->_em->createQueryBuilder()
  212.                             ->select('wp.id''wp.date''d.title as title');
  213.         } else {
  214.             $qb $this->_em->createQueryBuilder()
  215.                             ->select('wp.id''w.id as wId''w.title as day''d.title as discipline');
  216.         }
  217.         $qb->from('WorkListPackBac''wp')
  218.            ->join('wp.worklist''w')
  219.            ->join('wp.discipline''d')
  220.            ->where('wp.course=:cId')
  221.            ->andWhere('wp.serie=:sId')
  222.            ->andWhere('wp.packExam=:pId')
  223.            ->setParameter('cId'$cId)
  224.            ->setParameter('sId'$sId)
  225.            ->setParameter('pId'$packId);
  226.         $result $qb->getQuery()->getResult();
  227.         if (count($result) > 0) {
  228.             if ($packId == PackBac::ID_PACK_BAC_2017) {
  229.                 foreach ($qb->getQuery()->getResult() as $wp) {
  230.                     $worklists[$wp['date']->format('d-m-Y')][$wp['id']] = $wp['title'];
  231.                 }
  232.             } else {
  233.                 foreach ($qb->getQuery()->getResult() as $wp) {
  234.                     $worklists[$wp['discipline']][$wp['id']] = ['wId' => $wp['wId'], 'day' => $wp['day']];
  235.                 }
  236.             }
  237.         }
  238.         return $worklists;
  239.     }
  240.     public function getSharedWorkListPackExam()
  241.     {
  242.         $query $this->_em->getConnection()->prepare(
  243.             'select worklist_id as wId, course_id as cId, serie_id as sId FROM WorkListPackExam where worklist_id in (select worklist_id FROM WorkListPackExam group by worklist_id having count(*) > 1)'
  244.         );
  245.         $query->execute();
  246.         $result $query->fetchAll();
  247.         return $result;
  248.     }
  249.     public function getWorklistByDomain(Domain $domainVideo $video)
  250.     {
  251.         foreach ($domain->getWorkListNode() as $wl) {
  252.             $w $wl->getWorkList();
  253.             foreach ($w->getWorkListlines() as $wll) {
  254.                 if ($wll->getAbstractWorkListTable() instanceof WorkListTableVideo && $wll->getAbstractWorkListTable(
  255.                     )->getVideo()->getId() == $video->getId()) {
  256.                     return $w;
  257.                 }
  258.             }
  259.         }
  260.         return ! is_null($domain->getWorkListNode()[0]) ? $domain->getWorkListNode()[0]->getWorkList() : null;
  261.     }
  262.     public function getWorklistByDomainId($id)
  263.     {
  264.         $query $this->_em->createQuery(
  265.             'SELECT wkl.id, wkl.title as worklist_title FROM BO\WorkListBundle\Entity\WorkListNode w JOIN w.worklist wkl WHERE w.domain = :id '
  266.         );
  267.         $query->setParameter('id'$id);
  268.         return $query->getArrayResult();
  269.     }
  270.     public function getWorklistDetailsForProgramByWorklistNodeId($worklist_node)
  271.     {
  272.         $query $this->_em->createQuery(
  273.             "SELECT CASE WHEN v.id is not null THEN v.title ELSE CASE WHEN obj.id is not null THEN obj.title ELSE 'Exercice sur feuille' end end as title_content,
  274. CASE WHEN v.id is not null THEN 'video' ELSE CASE WHEN obj.id is not null THEN 'exercise' ELSE 'homework' end end as type,
  275. wkl.id as worklist_id, wkl.title as worklist_title , wlwls.id as worklistline_id,wkt.id as worklist_type
  276.             FROM Bo\WorkListBundle\Entity\WorkListNode wln
  277.             JOIN wln.worklist wkl
  278.             JOIN wkl.workListType wkt
  279.             JOIN Bo\WorkListBundle\Entity\WorkListLine wlwls WITH wlwls.worklist  = wkl.id
  280.             LEFT JOIN Bo\WorkListBundle\Entity\WorkListTableVideo wv WITH wlwls.abstractWorkListTable = wv.id
  281.             LEFT JOIN wv.video v
  282.             LEFT JOIN Bo\WorkListBundle\Entity\WorklistTableObjectExercise woe WITH wlwls.abstractWorkListTable = woe.id
  283.             LEFT JOIN woe.objectExercise obj
  284.             LEFT JOIN Bo\WorkListBundle\Entity\WorkListTableStatementLine wts WITH wlwls.abstractWorkListTable = wts.id
  285.             WHERE  wln.id = :worklist_node
  286.             ORDER BY wlwls.position ASC"
  287.         );
  288.         $query->setParameter('worklist_node'$worklist_node);
  289.         return $query->getArrayResult();
  290.     }
  291.     public function getWorklistNodeDisciplineBySerieCourse($serie$course)
  292.     {
  293.         if (is_null($serie) || is_null($course)) {
  294.             return null;
  295.         }
  296.         $sql "select * from
  297.         (select w.id as id, ad.slug as domain_slug,ad.id as domain_id,s.id as serie_id, c.id as course_id, wn.id as worklist_node_id,ch.id as chapter_id, ch.title as chapter_title, ch.slug as chapter_slug, dis.title as discipline_title,dis.slug as discipline_slug,w.packBlanc as ispackblanc, w.id as worklist_id, w.title as worklist_title,w.workListType_id as worklist_type
  298.         from `WorkListNode` wn
  299.         inner join `new_worklist` w on wn.`worklist_id`=w.`id`
  300.         inner join admin_domain ad on ad.id = wn.`domain_id`
  301.         inner join admin_discipline dis on dis.id = ad.`disciplines_id`
  302.         inner join Course c on c.id = ad.course_id
  303.         inner join Chapter ch on ch.id = ad.`chapter_id`
  304.         inner join admin_serie s on s.id = ad.`serie_id`
  305.         where s.id = " $serie->getId() . " and ad.course_id = " $course->getId() . " and ad.online = 1 ORDER BY dis.order,ad.position,w.position ASC) t
  306.         left join
  307.         ( select w.id,coalesce(sum(discr = 'ObjectExercise'),0) exercice,coalesce(sum(discr = 'video'), 0) nbrVideo,coalesce(sum(discr = 'statementLines'), 0) statement
  308.         from new_worklist w
  309.         join WorkListLine wl on wl.`worklist_id`=w.id
  310.         join `AbstractWorkListTable` awt on awt.id=wl.`abstractWorkListTable_id` where w.id in (select distinct(wn.`worklist_id`) from `WorkListNode` wn join admin_domain ad where ad.serie_id = " $serie->getId(
  311.             ) . " and ad.course_id = " $course->getId() . ")
  312.          group by w.id)
  313.          h on t.id = h.id";
  314.         $stmt $this->_em->getConnection()->query($sql);
  315.         $all $stmt->fetchAll();
  316.         return $all;
  317.     }
  318.     /**
  319.      * @param WorkList $worklist
  320.      *
  321.      * @return mixed
  322.      * @throws \Doctrine\ORM\NoResultException
  323.      * @throws \Doctrine\ORM\NonUniqueResultException
  324.      */
  325.     public function getWorklisPackDiscipline(WorkList $worklist)
  326.     {
  327.         $qb $this->_em->createQueryBuilder();
  328.         $qb $qb->select('d')->from('BoReferencesBundle:Discipline''d')
  329.                  ->join(WorkListPackBac::class, 'wp'Join::WITH"wp.discipline = d.id")
  330.                  ->join(WorkList::class, 'w'Join::WITH"w.id = wp.worklist")
  331.                  ->where('w = :worklist')
  332.                  ->setParameter('worklist'$worklist);
  333.         $discipline $qb->getQuery()->getSingleResult();
  334.         return $discipline;
  335.     }
  336.     /**
  337.      * Recherche des packs
  338.      *
  339.      * @param StudentPackBac $studentPackBac
  340.      * @param \DateTime|null $date
  341.      * @param null           $limit
  342.      *
  343.      * @return array
  344.      * @throws \Doctrine\DBAL\DBALException
  345.      */
  346.     public function getWorklistsByPack(StudentPackBac $studentPackBac\DateTime $date null$limit null)
  347.     {
  348.         $list_disciplines = [];
  349.         foreach ($studentPackBac->getDisciplines() as $discipline) {
  350.             $list_disciplines[] = $discipline->getId();
  351.         }
  352.         foreach ($studentPackBac->getObjectStudy() as $objectStudy) {
  353.             $list_objectStudy[] = $objectStudy->getId();
  354.         }
  355.         if (! $date) {
  356.             $date = new \DateTime("now");
  357.         }
  358.         $serie $studentPackBac->getStudent()->getSerie();
  359.         $course $studentPackBac->getStudent()->getCourse();
  360.         if ($studentPackBac->getPack()->getType() == PackBac::TYPE_ETE) {
  361.             $serie $studentPackBac->getStudent()->getSerie();
  362.             $course $studentPackBac->getStudent()->getCourse();
  363.             $d [] = date_diff($date$studentPackBac->getStartDate())->days;
  364.             $dateNow = new \DateTime("now");
  365.             $per2days $dateNow->add(new \DateInterval('P2D'));
  366.             if ($studentPackBac->getPack()->getStart() <= $studentPackBac->getStartDate(
  367.                 ) && $date >= $studentPackBac->getStartDate()) {
  368.                 $subscriptionDay date_diff($date$studentPackBac->getStartDate())->days 1;
  369.             } else {
  370.                 $subscriptionDay 0;
  371.             }
  372.             $dateCondition "and wp.day_order <= $subscriptionDay ";
  373.         } else {
  374.             $subscriptionDate $studentPackBac->getCreated();
  375.             //$subscriptionDate->sub(new \DateInterval('P2D'));
  376.             //$dateCondition = "and wp.date >= '".$date->format('Y')."' and wp.date <= '" . $date->format('Y-m-d') ."' ";
  377.             $dateCondition "and wp.date <= '" $date->format(
  378.                     'Y-m-d 00:00:s'
  379.                 ) . "' or wp.date LIKE '" $subscriptionDate->format('Y-m-d') . "' ";
  380.             //$dateCondition = "and wp.date >= '2020-01-01'";
  381.         }
  382.         $sql "select * from
  383.         (select 
  384.         wp.date as worklist_date,
  385.         wp.day_order as worklist_day,
  386.         spb.start_date as start_date,
  387.         w.id as id,
  388.         ad.slug as domain_slug,
  389.         ad.id as domain_id,
  390.         s.id as serie_id, 
  391.         c.id as course_id, 
  392.         ch.id as chapter_id, 
  393.         ch.title as chapter_title, 
  394.         ch.slug as chapter_slug, 
  395.         dis.id as discipline_id,
  396.         dis.title as discipline_title,
  397.         dis.slug as discipline_slug,
  398.         w.packBlanc as ispackblanc, 
  399.         w.id as worklist_id, 
  400.         w.title as worklist_title,
  401.         w.workListType_id as worklist_type,
  402.         wn.id as worklist_node_id
  403.         from StudentPackBac spb
  404.         join WorkListPackBac wp on wp.packBac_id = spb.pack_id
  405.         join new_worklist w on w.id = wp.worklist_id
  406.         join admin_discipline dis on dis.id = wp.discipline_id 
  407.         
  408.         join Course c on c.id = wp.course_id 
  409.         join admin_serie s on s.id = wp.serie_id 
  410.         join ReviewProgram rp on rp.id = spb.pack_id    
  411.         left join admin_domain ad on ad.id = w.domain_id
  412.         left join WorkListNode wn on w.id = wn.worklist_id
  413.         left join Chapter ch on ch.id = ad.chapter_id
  414.         where dis.id IN (" implode(','$list_disciplines) . ") 
  415.        
  416.         and s.id = " $serie->getId() . "
  417.         and c.id = " $course->getId() . "
  418.         and spb.id = " $studentPackBac->getId() . "
  419.         $dateCondition
  420.         ORDER BY wp.day_order ASC, dis.order DESC) t
  421.         left join
  422.         ( select w.id,coalesce(sum(discr = 'ObjectExercise'),0) exercice,coalesce(sum(discr = 'video'), 0) nbrVideo,coalesce(sum(discr = 'statementLines'), 0) statement
  423.         from new_worklist w
  424.         join WorkListLine wl on wl.`worklist_id`=w.id
  425.         join `AbstractWorkListTable` awt on awt.id=wl.`abstractWorkListTable_id` where w.id in (select distinct(wn.`worklist_id`) from `WorkListNode` wn)
  426.          group by w.id)
  427.          h on t.id = h.id";
  428.         if ($limit) {
  429.             $sql .= " limit $limit";
  430.         }
  431.         $stmt $this->_em->getConnection()->query($sql);
  432.         $all $stmt->fetchAll();
  433.         return $all;
  434.     }
  435.     /**
  436.      * Recherche des packs
  437.      *
  438.      * @param StudentPackBac $studentPackBac
  439.      * @param \DateTime|null $date
  440.      * @param null           $limit
  441.      *
  442.      * @return array
  443.      * @throws \Doctrine\DBAL\DBALException
  444.      */
  445.     public function getWorklistsByPackNew(StudentPackBac $studentPackBac\DateTime $date null$limit null)
  446.     {
  447.         $list_disciplines = [];
  448.         foreach ($studentPackBac->getDisciplines() as $discipline) {
  449.             $list_disciplines[] = $discipline->getId();
  450.         }
  451.         $serie $studentPackBac->getStudent()->getSerie();
  452.         $course $studentPackBac->getStudent()->getCourse();
  453.         $date = new \DateTime("now");
  454.         /*
  455.         $q1 = $this->_em->createQueryBuilder()
  456.             ->select(
  457.                        'spb.startDate as start_date',
  458.                               's.id as id'
  459.             )
  460.             ->from('BoStudentBundle:ReviewProgram', 'rp')
  461.             ->join('rp.student', 's')
  462.             ->join('rp.worklist', 'w')
  463.             ->join('w.worklistPackExams', 'wPE')
  464.             ->join('rp.studentPackBac', 'spb ')
  465.             ->where('s.id = :studentId')
  466.             ->setParameter('studentId', $studentPackBac->getStudent()->getId())
  467.         ;
  468.         */
  469.         $dateCondition1 $date->format('Y-m-d');
  470.         $dateCondition2 "and r.playlistReady <= '" $date->format('Y-m-d') . "'";
  471.         $q1 $this->_em->createQueryBuilder()
  472.                         ->select(
  473.                             'r.day as  worklist_date',
  474.                             'pe.day as worklist_day',
  475.                             'spb.startDate as start_date',
  476.                             'r.playlistReady as playlist_ready',
  477.                             'w.id as id',
  478.                             'ad.slug as domain_slug',
  479.                             'ad.id as domain_id',
  480.                             's.id as serie_id',
  481.                             'c.id as course_id',
  482.                             'dis.id as discipline_id',
  483.                             'dis.title as discipline_title',
  484.                             'dis.slug as discipline_slug',
  485.                             'ch.id as chapter_id',
  486.                             'ch.title as chapter_title',
  487.                             'ch.slug as chapter_slug',
  488.                             'w.packBlanc as ispackblanc',
  489.                             'w.id as worklist_id',
  490.                             'w.title as worklist_title',
  491.                             'workListType.id as worklist_type',
  492.                             'wn.id as worklist_node_id'
  493.                         )
  494.                         ->from('BoMainBundle:StudentPackBac''spb')
  495.                         ->join('spb.student''student')
  496.                         ->join('spb.reviewProgram''r')
  497.                         ->join('r.worklist''w')
  498.                         ->join('w.programExam''pe')
  499.                         ->join('pe.discipline''dis')
  500.                         ->join('pe.planningExam''planningExam')
  501.                         ->join('w.workListType''workListType')
  502.                         ->innerJoin('planningExam.course''c')
  503.                         ->innerJoin('planningExam.serie''s')
  504.                         ->leftJoin('w.domain''ad')
  505.                         ->leftJoin('ad.chapter''ch')
  506.                         ->leftJoin('w.workListNode''wn')
  507.                         ->where('student.id = :studentId')
  508.                         ->andWhere("r.playlistReady <= '$dateCondition1' ")
  509.                         ->setParameter('studentId'$studentPackBac->getStudent()->getId())
  510.                         ->orderBy('pe.day''asc');
  511.         $all $q1->getQuery()->getResult();
  512.         /*
  513.             $sql = "select * from
  514.             (select
  515.             r.day as worklist_date,
  516.             pe.day as worklist_day,
  517.             spb.start_date as start_date,
  518.             r.playlistReady as playlist_ready,
  519.             w.id as id,
  520.             ad.slug as domain_slug,
  521.             ad.id as domain_id,
  522.             s.id as serie_id,
  523.             c.id as course_id,
  524.             ch.id as chapter_id,
  525.             ch.title as chapter_title,
  526.             ch.slug as chapter_slug,
  527.             dis.id as discipline_id,
  528.             dis.title as discipline_title,
  529.             dis.slug as discipline_slug,
  530.             w.packBlanc as ispackblanc,
  531.             w.id as worklist_id,
  532.             w.title as worklist_title,
  533.             workListType.id as worklist_type,
  534.             wn.id as worklist_node_id
  535.             from StudentPackBac spb
  536.             join aba_user student on student.id = spb.student_id
  537.             join ReviewProgram r on r.studentPackBac_id = spb.id
  538.             join new_worklist w on w.id = r.worklist_id
  539.             join ProgramExam pe on pe.worklist_id = w.id
  540.             join admin_discipline dis on dis.id = pe.discipline_id
  541.             join PlanningExam planningExam on planningExam.id = pe.planningExam_id
  542.             join WorkListType workListType on workListType.id = w.workListType_id
  543.             left join Course c on c.id = planningExam.course_id
  544.             left join admin_serie s on s.id = planningExam.serie_id
  545.             left join admin_domain ad on ad.id = w.domain_id
  546.             left join WorkListNode wn on wn.worklist_id  = w.id
  547.             left join Chapter ch on ch.id = ad.chapter_id
  548.             and spb.student_id = " . $studentPackBac->getStudent()->getId() . "
  549.             $dateCondition2
  550.             ORDER BY pe.day ASC, dis.order DESC ) t
  551.             left join
  552.             ( select w.id,coalesce(sum(discr = 'ObjectExercise'),0) exercice,coalesce(sum(discr = 'video'), 0) nbrVideo,coalesce(sum(discr = 'statementLines'), 0) statement
  553.             from new_worklist w
  554.             join WorkListLine wl on wl.`worklist_id`=w.id
  555.             join `AbstractWorkListTable` awt on awt.id=wl.`abstractWorkListTable_id` where w.id in (select distinct(wn.`worklist_id`) from `WorkListNode` wn)
  556.              group by w.id)
  557.              h on t.id = h.id";
  558.             if ($limit) {
  559.                 $sql .= " limit $limit";
  560.             }
  561.             $stmt = $this->_em->getConnection()->query($sql);
  562.             $all = $stmt->fetchAll();
  563.         */
  564.         return $all;
  565.     }
  566.     /**
  567.      * Recherche
  568.      *
  569.      * @param $wnIds
  570.      * @param $serie
  571.      * @param $course
  572.      *
  573.      * @return array
  574.      * @throws \Doctrine\DBAL\DBALException
  575.      */
  576.     public function getWorklistByIds($serie$course$wnIds)
  577.     {
  578.         $wnList implode(', '$wnIds);
  579.         $sql "select * from
  580.         (select w.id as id,ad.slug as domain_slug,ad.id as domain_id,s.id as serie_id, c.id as course_id, wn.id as worklist_node_id,ch.id as chapter_id, ch.title as chapter_title, ch.slug as chapter_slug, dis.title as discipline_title,dis.slug as discipline_slug,w.packBlanc as ispackblanc, w.id as worklist_id, w.title as worklist_title,w.workListType_id as worklist_type
  581.         from `WorkListNode` wn
  582.         left join `new_worklist` w on wn.`worklist_id`=w.`id`
  583.         left join admin_domain ad on ad.id = wn.`domain_id`
  584.         left join admin_discipline dis on dis.id = ad.`disciplines_id`
  585.         left join Course c on c.id = ad.course_id
  586.         left join Chapter ch on ch.id = ad.`chapter_id`
  587.         left join admin_serie s on s.id = ad.`serie_id`
  588.         where s.id = " $serie->getId() . " and ad.course_id = " $course->getId() . " and wn.id IN (" $wnList ") 
  589.         and w.stage = 0
  590.         and w.e3c = 0
  591.         ORDER BY dis.order ASC) t
  592.         left join
  593.         ( select w.id,coalesce(sum(discr = 'ObjectExercise'),0) exercice,coalesce(sum(discr = 'video'), 0) nbrVideo,coalesce(sum(discr = 'statementLines'), 0) statement
  594.         from new_worklist w
  595.         join WorkListLine wl on wl.`worklist_id`=w.id
  596.         join `AbstractWorkListTable` awt on awt.id=wl.`abstractWorkListTable_id` where w.id in (select distinct(wn.`worklist_id`) from `WorkListNode` wn join admin_domain ad where ad.serie_id = " $serie->getId(
  597.             ) . " and ad.course_id = " $course->getId() . ")
  598.         and w.stage = 0
  599.         and w.e3c = 0
  600.          group by w.id)
  601.          h on t.id = h.id";
  602.         $stmt $this->_em->getConnection()->query($sql);
  603.         $all $stmt->fetchAll();
  604.         return $all;
  605.     }
  606.     /**
  607.      * @param     $page
  608.      * @param int $max
  609.      *
  610.      * @return array
  611.      * @throws \Doctrine\DBAL\DBALException
  612.      */
  613.     public function getPaginatedWorklists($page$max 100)
  614.     {
  615.         $offset $max * ($page 1);
  616.         $sql "select * from
  617.         (select w.id as id,ad.slug as domain_slug,ad.id as domain_id,s.id as serie_id, c.id as course_id, wn.id as worklist_node_id,ch.id as chapter_id, ch.title as chapter_title, ch.slug as chapter_slug, dis.title as discipline_title,dis.slug as discipline_slug,w.packBlanc as ispackblanc, w.id as worklist_id, w.title as worklist_title,w.workListType_id as worklist_type
  618.         from `WorkListNode` wn
  619.         left join `new_worklist` w on wn.`worklist_id`=w.`id`
  620.         left join admin_domain ad on ad.id = wn.`domain_id`
  621.         left join admin_discipline dis on dis.id = ad.`disciplines_id`
  622.         left join Course c on c.id = ad.course_id
  623.         left join Chapter ch on ch.id = ad.`chapter_id`
  624.         left join admin_serie s on s.id = ad.`serie_id`
  625.         ORDER BY dis.order ASC
  626.         LIMIT $max OFFSET $offset) t
  627.         left join
  628.         ( select w.id,coalesce(sum(discr = 'ObjectExercise'),0) exercice,coalesce(sum(discr = 'video'), 0) nbrVideo,coalesce(sum(discr = 'statementLines'), 0) statement
  629.         from new_worklist w
  630.         join WorkListLine wl on wl.`worklist_id`=w.id
  631.         join `AbstractWorkListTable` awt on awt.id=wl.`abstractWorkListTable_id` where w.id in (select distinct(wn.`worklist_id`) from `WorkListNode` wn join admin_domain ad)
  632.          group by w.id)
  633.          h on t.id = h.id";
  634.         $stmt $this->_em->getConnection()->query($sql);
  635.         $all $stmt->fetchAll();
  636.         return $all;
  637.     }
  638.     /**
  639.      * Recherche
  640.      *
  641.      * @param $serie
  642.      * @param $course
  643.      * @param $discipline
  644.      * @param $search
  645.      *
  646.      * @return array
  647.      * @throws \Doctrine\DBAL\DBALException
  648.      */
  649.     public function getWorklistBySearch($serie$course$discipline null$search)
  650.     {
  651.         $list_words explode(" "$search);
  652.         $andWhere "";
  653.         foreach ($list_words as $key => $word) {
  654.             if ($key 0) {
  655.                 $andWhere .= " and ";
  656.             }
  657.             $word addslashes($word);
  658.             $andWhere .= " w.title LIKE '%$word%'";
  659.         }
  660.         if ($discipline !== null) {
  661.             $andWhereDiscipline ' and ad.disciplines_id = ' $discipline->getId() . ' ';
  662.         } else {
  663.             $andWhereDiscipline '';
  664.         }
  665.         $sql "select * from
  666.         (select w.id as id,ad.slug as domain_slug,ad.id as domain_id,s.id as serie_id, c.id as course_id, wn.id as worklist_node_id,ch.id as chapter_id, ch.title as chapter_title, ch.slug as chapter_slug, dis.title as discipline_title,dis.slug as discipline_slug,w.packBlanc as ispackblanc, w.id as worklist_id, w.title as worklist_title,w.workListType_id as worklist_type
  667.         , w.free_access, dis.id as discipline_id
  668.         from `WorkListNode` wn
  669.         left join `new_worklist` w on wn.`worklist_id`=w.`id`
  670.         left join admin_domain ad on ad.id = wn.`domain_id`
  671.         left join admin_discipline dis on dis.id = ad.`disciplines_id`
  672.         left join Course c on c.id = ad.course_id
  673.         left join Chapter ch on ch.id = ad.`chapter_id`
  674.         left join admin_serie s on s.id = ad.`serie_id`
  675.         where s.id = " $serie->getId() . " and ad.course_id = " $course->getId(
  676.             ) . " " $andWhereDiscipline " and " $andWhere 
  677.         and w.stage = 0
  678.         and w.e3c = 0
  679.         ORDER BY dis.order ASC
  680.         ) t
  681.         left join
  682.         ( select w.id,coalesce(sum(discr = 'ObjectExercise'),0) exercice,coalesce(sum(discr = 'video'), 0) nbrVideo,coalesce(sum(discr = 'statementLines'), 0) statement
  683.         from new_worklist w
  684.         join WorkListLine wl on wl.`worklist_id`=w.id
  685.         join `AbstractWorkListTable` awt on awt.id=wl.`abstractWorkListTable_id` where w.id in (select distinct(wn.`worklist_id`) from `WorkListNode` wn join admin_domain ad where ad.serie_id = " $serie->getId(
  686.             ) . " and ad.course_id = " $course->getId() . " " $andWhereDiscipline " and" $andWhere ")
  687.         and w.stage = 0
  688.         and w.e3c = 0
  689.          group by w.id)
  690.          h on t.id = h.id";
  691.         $stmt $this->_em->getConnection()->query($sql);
  692.         $all $stmt->fetchAll();
  693.         return $all;
  694.     }
  695.     public function getAllWorkListReviewProgram()
  696.     {
  697.         $q1 $this->_em->createQueryBuilder()
  698.                         ->select('w')
  699.                         ->from('BoWorkListBundle:Worklist''w')
  700.                         ->join('w.studentReviewProgram''s')
  701.                         ->where('w.studentReviewProgram is not null')
  702.                         ->andWhere('s.created > "2017-09-01 00:00:00"');
  703.         return $q1->getQuery()->getResult();
  704.     }
  705.     public function updatePictureMobileId(WorkList $worklist$id)
  706.     {
  707.         $queryBuilder $this->_em->createQueryBuilder()->update(WorkList::class, 'w')
  708.                                   ->set('w.pictureMobileId'':pictureMobileId')
  709.                                   ->where('w.id = :id')
  710.                                   ->setParameter('pictureMobileId'$id)
  711.                                   ->setParameter('id'$worklist->getId());
  712.         $queryBuilder->getQuery()->execute();
  713.     }
  714.     public function getWorklistNodeDisciplineByChapter($serie$course$discipiline$chapter)
  715.     {
  716.         if (is_null($serie) || is_null($course) || is_null($discipiline) || is_null($chapter)) {
  717.             return null;
  718.         }
  719.         $sql "select * from
  720.         (select w.id as id, ad.slug as domain_slug,ad.id as domain_id,s.id as serie_id, c.id as course_id, wn.id as worklist_node_id,ch.id as chapter_id, ch.title as chapter_title, ch.slug as chapter_slug, dis.title as discipline_title,dis.slug as discipline_slug,w.packBlanc as ispackblanc, w.id as worklist_id, w.title as worklist_title,w.workListType_id as worklist_type
  721.         from `WorkListNode` wn
  722.         left join `new_worklist` w on wn.`worklist_id`=w.`id`
  723.         left join admin_domain ad on ad.id = wn.`domain_id`
  724.         left join admin_discipline dis on dis.id = ad.`disciplines_id`
  725.         left join Course c on c.id = ad.course_id
  726.         left join Chapter ch on ch.id = ad.`chapter_id`
  727.         left join admin_serie s on s.id = ad.`serie_id`
  728.         where s.id = " $serie->getId() . " and ad.course_id = " $course->getId(
  729.             ) . " and dis.id = " $discipiline->getId() . " and ch.id = " $chapter->getId() . 
  730.         and w.stage = 0 and w.e3c = 0
  731.         ORDER BY dis.title,ad.position,w.position ASC) t
  732.         left join
  733.         ( select w.id,coalesce(sum(discr = 'ObjectExercise'),0) exercice,coalesce(sum(discr = 'video'), 0) nbrVideo,coalesce(sum(discr = 'statementLines'), 0) statement
  734.         from new_worklist w
  735.         join WorkListLine wl on wl.`worklist_id`=w.id
  736.         join `AbstractWorkListTable` awt on awt.id=wl.`abstractWorkListTable_id` where w.id in (select distinct(wn.`worklist_id`) from `WorkListNode` wn join admin_domain ad where ad.serie_id = " $serie->getId(
  737.             ) . " and ad.course_id = " $course->getId() . ")
  738.          and w.stage = 0 and w.e3c = 0
  739.          group by w.id)
  740.          h on t.id = h.id";
  741.         $stmt $this->_em->getConnection()->query($sql);
  742.         $all $stmt->fetchAll();
  743.         return $all;
  744.     }
  745.     public function getNumberElementSubQuery()
  746.     {
  747.         return '
  748.             (
  749.                 SELECT COUNT(wl.id)
  750.                 FROM ' $this->_em->getClassMetadata('BoWorkListBundle:WorkListLine')->getTableName() . ' wl
  751.                 INNER JOIN AbstractWorkListTable awlt ON awlt.id = wl.abstractWorkListTable_id
  752.                 INNER JOIN Video v ON v.id = awlt.video_id
  753.                 WHERE wl.worklist_id = w.id
  754.                 AND awlt.video_id IS NOT NULL
  755.             ) AS number_element_video,
  756.             (
  757.                 SELECT COUNT(wl.id)
  758.                 FROM ' $this->_em->getClassMetadata('BoWorkListBundle:WorkListLine')->getTableName() . ' wl
  759.                 INNER JOIN AbstractWorkListTable awlt ON awlt.id = wl.abstractWorkListTable_id
  760.                 INNER JOIN ObjectExercise o ON o.id = awlt.objectExercise_id
  761.                 WHERE wl.worklist_id = w.id
  762.                 AND awlt.objectExercise_id IS NOT NULL
  763.                 AND (
  764.                         SELECT COUNT(ans.id) 
  765.                         FROM qcm_question qq
  766.                         INNER JOIN Answer ans ON ans.question_id = qq.id
  767.                         WHERE qq.exercise_id = o.id
  768.                     ) > 1
  769.             ) AS number_element_qcm
  770.         ';
  771.     }
  772.     public function getAllByCourseSerieDisciplineChapterWithTotalLine(
  773.         Course $course,
  774.         Serie $serie,
  775.         Discipline $discipline,
  776.         Chapter $chapter
  777.     ) {
  778.         $stmt $this
  779.             ->_em
  780.             ->getConnection()
  781.             ->prepare(
  782.                 "
  783.                         SELECT w.id, w.title, free_access AS hasFreeAccess, ad.id AS domainId, w.picture_mobile_id,
  784.                         " $this->getNumberElementSubQuery() . "
  785.                         FROM " $this->_em->getClassMetadata('BoWorkListBundle:WorkListNode')->getTableName() . " wln
  786.                         INNER JOIN " $this->_em->getClassMetadata('BoDomainBundle:Domain')->getTableName() . " ad ON ad.id = wln.domain_id
  787.                         INNER JOIN " $this->_em->getClassMetadata('BoReferencesBundle:Chapter')->getTableName() . " c ON c.id = ad.chapter_id
  788.                         INNER JOIN " $this->_em->getClassMetadata('BoWorkListBundle:WorkList')->getTableName() . " w ON w.id = wln.worklist_id
  789.                         WHERE ad.chapter_id = " $chapter->getId() . "
  790.                         AND ad.course_id = " $course->getId() . "
  791.                         AND ad.serie_id = " $serie->getId() . "
  792.                         AND ad.disciplines_id = " $discipline->getId() . "
  793.                         AND ad.`online` = 1
  794.                         AND (w.packBlanc IS NULL OR w.packBlanc = 0)
  795.                         AND w.stage = 0
  796.                         AND w.e3c = 0
  797.                         ORDER BY wln.position
  798.                         "
  799.             );
  800.         $stmt->execute();
  801.         return $stmt->fetchAll();
  802.     }
  803.     public function getAllByUserWithTotalLineEnded(
  804.         User $user,
  805.         Course $course,
  806.         Serie $serie,
  807.         Discipline $discipline,
  808.         Chapter $chapter
  809.     ) {
  810.         $stmt $this
  811.             ->_em
  812.             ->getConnection()
  813.             ->prepare(
  814.                 "
  815.                 SELECT rp.worklist_id AS id, COUNT(*) as number_element
  816.                 FROM " $this->_em->getClassMetadata('BoStudentBundle:ReviewProgram')->getTableName() . " rp
  817.                 INNER JOIN " $this->_em->getClassMetadata('BoWorkListBundle:WorkList')->getTableName() . " w ON w.id = rp.worklist_id
  818.                 INNER JOIN " $this->_em->getClassMetadata('BoDomainBundle:Domain')->getTableName() . " ad ON ad.id = rp.domain_id
  819.                 INNER JOIN " $this->_em->getClassMetadata(
  820.                     'BoWorkListBundle:AbstractWorkListTableReviewProgramInformations'
  821.                 )->getTableName() . " awltrpi ON awltrpi.review_program_id = rp.id
  822.                 INNER JOIN " $this->_em->getClassMetadata('BoWorkListBundle:AbstractWorkListTable')->getTableName() . " awlt ON awlt.id = awltrpi.abstract_work_list_table_id
  823.                 WHERE rp.student_id = " $user->getId() . "
  824.                 AND awltrpi.ended = 1
  825.                 AND ad.chapter_id = " $chapter->getId() . "
  826.                 AND ad.course_id = " $course->getId() . "
  827.                 AND ad.serie_id = " $serie->getId() . "
  828.                 AND ad.disciplines_id = " $discipline->getId() . "
  829.                 AND ad.`online` = 1
  830.                 AND (w.packBlanc IS NULL OR w.packBlanc = 0)
  831.                 AND w.stage = 0
  832.                 AND w.e3c = 0
  833.                 AND (
  834.                     awlt.video_id IS NOT NULL OR 
  835.                     (awlt.objectExercise_id IS NOT NULL
  836.                         AND (
  837.                                 SELECT COUNT(ans.id) 
  838.                                 FROM qcm_question qq
  839.                                 INNER JOIN Answer ans ON ans.question_id = qq.id
  840.                                 WHERE qq.exercise_id = awlt.objectExercise_id
  841.                             ) > 1)
  842.                 )
  843.                 GROUP BY rp.worklist_id
  844.                         "
  845.             );
  846.         $stmt->execute();
  847.         return $stmt->fetchAll();
  848.     }
  849.     public function getAllWorklistVideo(WorkList $workListReviewProgram $reviewProgram)
  850.     {
  851.         $stmt $this
  852.             ->_em
  853.             ->getConnection()
  854.             ->prepare(
  855.                 "
  856.                 SELECT awlt.id, v.title, v.description, v.picture_mobile_id,
  857.                 (
  858.                   SELECT ended
  859.                   FROM " $this->_em->getClassMetadata(
  860.                     'BoWorkListBundle:AbstractWorkListTableReviewProgramInformations'
  861.                 )->getTableName() . " awltrpi 
  862.                   WHERE awltrpi.review_program_id = " $reviewProgram->getId() . "
  863.                   AND awltrpi.abstract_work_list_table_id = awlt.id
  864.                 ) AS isEnded
  865.                 FROM WorkListLine wl
  866.                 INNER JOIN AbstractWorkListTable awlt ON awlt.id = wl.abstractWorkListTable_id
  867.                 INNER JOIN Video v ON v.id = awlt.video_id
  868.                 WHERE wl.worklist_id = " $workList->getId() . "
  869.                 AND awlt.video_id IS NOT NULL 
  870.                 ORDER BY wl.position
  871.                         "
  872.             );
  873.         $stmt->execute();
  874.         return $stmt->fetchAll();
  875.     }
  876.     public function getAllWorklistQcm(WorkList $workListReviewProgram $reviewProgram)
  877.     {
  878.         $stmt $this
  879.             ->_em
  880.             ->getConnection()
  881.             ->prepare(
  882.                 "
  883.                 SELECT awlt.id, o.title,
  884.                 (
  885.                  SELECT ended
  886.                   FROM " $this->_em->getClassMetadata(
  887.                     'BoWorkListBundle:AbstractWorkListTableReviewProgramInformations'
  888.                 )->getTableName() . " awltrpi 
  889.                   WHERE awltrpi.review_program_id = " $reviewProgram->getId() . "
  890.                   AND awltrpi.abstract_work_list_table_id = awlt.id
  891.                 ) AS isEnded 
  892.                 FROM WorkListLine wl
  893.                 INNER JOIN AbstractWorkListTable awlt ON awlt.id = wl.abstractWorkListTable_id
  894.                 INNER JOIN ObjectExercise o ON o.id = awlt.objectExercise_id
  895.                 WHERE wl.worklist_id = " $workList->getId() . "
  896.                 AND o.display_mobile = 1
  897.                 AND awlt.objectExercise_id IS NOT NULL
  898.                 AND (
  899.                         SELECT COUNT(ans.id) 
  900.                         FROM qcm_question qq
  901.                         INNER JOIN Answer ans ON ans.question_id = qq.id
  902.                         WHERE qq.exercise_id = o.id
  903.                     ) > 1
  904.                 ORDER BY wl.position
  905.                         "
  906.             );
  907.         $stmt->execute();
  908.         return $stmt->fetchAll();
  909.     }
  910.     public function getWorklistVideoOrFiche(
  911.         WorkList $workList,
  912.         AbstractWorkListTable $abstractWorkListTable,
  913.         $type 'video'
  914.     ) {
  915.         switch ($type) {
  916.             case 'fiche':
  917.                 $complementSelect ', v.description, v.title AS videoTitle, v.picture_mobile_id';
  918.                 break;
  919.             default :
  920.                 $complementSelect ', v.poster AS picture';
  921.                 break;
  922.         }
  923.         $stmt $this
  924.             ->_em
  925.             ->getConnection()
  926.             ->prepare(
  927.                 "
  928.                 SELECT v.id, v.title, v.vimeo_file AS videoUrl " $complementSelect "
  929.                 FROM WorkListLine wl
  930.                 INNER JOIN AbstractWorkListTable awlt ON awlt.id = wl.abstractWorkListTable_id
  931.                 INNER JOIN Video v ON v.id = awlt.video_id
  932.                 WHERE wl.worklist_id = " $workList->getId() . "
  933.                 AND awlt.id = " $abstractWorkListTable->getId() . "
  934.                 AND awlt.video_id IS NOT NULL 
  935.                         "
  936.             );
  937.         $stmt->execute();
  938.         return $stmt->fetchAll();
  939.     }
  940.     public function getWorklistQcm(WorkList $workList$abstractWorkListTable)
  941.     {
  942.         if ($abstractWorkListTable instanceof AbstractWorkListTable) {
  943.             $andWhere " AND awlt.id = " $abstractWorkListTable->getId() . " ";
  944.         } elseif (is_array($abstractWorkListTable)) {
  945.             $andWhere " AND awlt.id IN (" implode(', '$abstractWorkListTable) . ") ";
  946.         }
  947.         $stmt $this
  948.             ->_em
  949.             ->getConnection()
  950.             ->prepare(
  951.                 "
  952.                 SELECT awlt.id, o.id as qcmId, o.title as qcmTitle, q.statement AS qcmInstruction, qq.id AS questionId, qq.position AS questionPosition, qq.statement AS questionText, a.id AS answerId, a.answer, a.valid
  953.                 FROM WorkListLine wl
  954.                 INNER JOIN AbstractWorkListTable awlt ON awlt.id = wl.abstractWorkListTable_id
  955.                 INNER JOIN " $this->_em->getClassMetadata('BoExerciseBundle:ObjectExercise')->getTableName() . " o ON o.id = awlt.objectExercise_id
  956.                 INNER JOIN " $this->_em->getClassMetadata('BoExerciseBundle:Quiz')->getTableName() . " q ON q.id = awlt.objectExercise_id
  957.                 INNER JOIN " $this->_em->getClassMetadata('BoExerciseBundle:QCMQuestion')->getTableName() . " qq ON qq.exercise_id = q.id
  958.                 INNER JOIN " $this->_em->getClassMetadata('BoExerciseBundle:Answer')->getTableName() . " a ON a.question_id = qq.id
  959.                 WHERE wl.worklist_id = " $workList->getId() . "
  960.                 " $andWhere "
  961.                 AND awlt.objectExercise_id IS NOT NULL
  962.                 ORDER BY qq.position
  963.                         "
  964.             );
  965.         $stmt->execute();
  966.         return $stmt->fetchAll();
  967.     }
  968.     /**
  969.      * @return array
  970.      */
  971.     public function searchWorkList()
  972.     {
  973.         $query $this->_em->createQueryBuilder();
  974.         $query->select('w.id''w.picture''w.pictureFreeAccess')
  975.             ->from('BoWorkListBundle:WorkList''w');
  976.         return $query->getQuery()->getResult();
  977.     }
  978. }