src/Twig/ElearningExtension.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Twig;
  3. use App\Services\Elearning;
  4. use Twig\Extension\AbstractExtension;
  5. use Twig\TwigFilter;
  6. use Twig\TwigFunction;
  7. class ElearningExtension extends AbstractExtension
  8. {
  9.     public function __construct(Elearning $elearning)
  10.     {
  11.         $this->elearning $elearning;
  12.     }
  13.     /**
  14.      * {@inheritdoc}
  15.      */
  16.     public function getFunctions(): array
  17.     {
  18.         return [
  19.             new  TwigFunction('getElearningChapterParts', [$this'getElearningChapterParts']),
  20.             new  TwigFunction('getElearningChapterPartTime', [$this'getElearningChapterPartTime']),
  21.             new  TwigFunction('getElearningProgress', [$this'getElearningProgress']),
  22.             new  TwigFunction('getElearningQcmQuestionsResponses', [$this'getElearningQcmQuestionsResponses']),
  23.             new  TwigFunction('getElearningQcmUserQuestionResponses', [$this'getElearningQcmUserQuestionResponses']),
  24.             new  TwigFunction('heuresToSecondesMinutes', [$this'heuresToSecondesMinutes']),
  25.             new  TwigFunction('getTimeFromDate', [$this'getTimeFromDate']),
  26.             new  TwigFunction('getElearningPage', [$this'getElearningPage']),
  27.             new  TwigFunction('getElearningCourseChapters', [$this'getElearningCourseChapters']),
  28.             new  TwigFunction('getElearningCountChapters', [$this'getElearningCountChapters']),
  29.             new  TwigFunction('getElearningCountUserFormations', [$this'getElearningCountUserFormations']),
  30.             new  TwigFunction('getElearningCountUserFormationsTermined', [$this'getElearningCountUserFormationsTermined']),
  31.             new  TwigFunction('getElearningCountUserFormationsAvailable', [$this'getElearningCountUserFormationsAvailable']),
  32.             new  TwigFunction('getElearningCountUserFormationsCertificat', [$this'getElearningCountUserFormationsCertificat']),
  33.             new  TwigFunction('getElearningTimeCourse', [$this'getElearningTimeCourse']),
  34.             new  TwigFunction('getElearningCategoriesQCM', [$this'getElearningCategoriesQCM']),
  35.             new  TwigFunction('getElearningCategories', [$this'getElearningCategories']),
  36.             new  TwigFunction('getElearningCategoriesItems', [$this'getElearningCategoriesItems']),
  37.             new  TwigFunction('getQcmApplicationChapterQuestions', [$this'getQcmApplicationChapterQuestions']),
  38.             new  TwigFunction('getQcmApplicationChapterQuestionResponses', [$this'getQcmApplicationChapterQuestionResponses']),
  39.             new  TwigFunction('getQcmApplicationUserResponse', [$this'getQcmApplicationUserResponse']),
  40.             new  TwigFunction('getQcmApplicationCountQuestionsChapter', [$this'getQcmApplicationCountQuestionsChapter']),
  41.             new  TwigFunction('getElearningGenerationTentativeChapter', [$this'getElearningGenerationTentativeChapter']),
  42.             new  TwigFunction('getElearningInfoChapter', [$this'getElearningInfoChapter']),
  43.             new  TwigFunction('getElearningEvaluationChapterUser', [$this'getElearningEvaluationChapterUser']),
  44.             new  TwigFunction('getElearningEvaluationUser', [$this'getElearningEvaluationUser']),
  45.             new  TwigFunction('getElearningEvaluationChapters', [$this'getElearningEvaluationChapters']),
  46.             new  TwigFunction('getElearningSidebarUser', [$this'getElearningSidebarUser']),
  47.             new  TwigFunction('getElearningUserTime', [$this'getElearningUserTime']),
  48.             new  TwigFunction('getElearningCourseTime', [$this'getElearningCourseTime']),
  49.             new  TwigFunction('getElearningLastMessageCourse', [$this'getElearningLastMessageCourse']),
  50.             new  TwigFunction('getElearningLastMessageCourseUser', [$this'getElearningLastMessageCourseUser']),
  51.             new  TwigFunction('getElearningSubscriptionExpirationDate', [$this'getElearningSubscriptionExpirationDate']),
  52.             new  TwigFunction('getElearningCoursePayments', [$this'getElearningCoursePayments']),
  53.             new  TwigFunction('getElearningEnterpriseCourseCommission', [$this'getElearningEnterpriseCourseCommission']),
  54.             new  TwigFunction('getElearningPartnerCommission', [$this'getElearningPartnerCommission']),
  55.             new  TwigFunction('getElearningSimulationContract', [$this'getElearningSimulationContract']),
  56.             new  TwigFunction('getElearningEvaluationRecruteur', [$this'getElearningEvaluationRecruteur']),
  57.         ];
  58.     }
  59.     public function getElearningEvaluationRecruteur($mail)
  60.     {
  61.         return $this->elearning->getEvaluationRecruteur($mail);
  62.     }
  63.     public function getElearningPartnerCommission($commissionID)
  64.     {
  65.         return $this->elearning->getPartnerCommission($commissionID);
  66.     }
  67.     /**
  68.      * Total de la commission de l'enterprise sur sa formation.
  69.      * @param $uhc - UsersHasCourses
  70.      * @return mixed
  71.      */
  72.     public function getElearningEnterpriseCourseCommission($uhc)
  73.     {
  74.         return $this->elearning->getCourseEnterpriseCommission($uhc);
  75.     }
  76.     public function getElearningSimulationContract($pourcent,$montant)
  77.     {
  78.         return $this->elearning->getSimulationContract($pourcent,$montant);
  79.     }
  80.     /**
  81.      * Total des paiements d'une course.
  82.      * @param $uhc - UsersHasCourses
  83.      * @return mixed
  84.      */
  85.     public function getElearningCoursePayments($uhc)
  86.     {
  87.         return $this->elearning->getCoursePayments($uhc);
  88.     }
  89.     public function getElearningSubscriptionExpirationDate($agency)
  90.     {
  91.         return $this->elearning->getSubscriptionExpirationDate($agency);
  92.     }
  93.     public function getElearningLastMessageCourseUser($agency,$user)
  94.     {
  95.         return $this->elearning->getLastMessageCourseUser($agency,$user);
  96.     }
  97.     public function getElearningLastMessageCourse($uhc)
  98.     {
  99.         return $this->elearning->getLastMessage($uhc);
  100.     }
  101.     public function getElearningSidebarUser($userID)
  102.     {
  103.         return $this->elearning->getSidebarUser($userID);
  104.     }
  105.     public function getElearningEvaluationUser($uhcID)
  106.     {
  107.         return $this->elearning->getEvaluationUser($uhcID);
  108.     }
  109.     public function getElearningEvaluationChapters($uhcEntity)
  110.     {
  111.         return $this->elearning->getEvaluationChapters($uhcEntity);
  112.     }
  113.     public function getElearningEvaluationChapterUser($uhcID,$chapterID)
  114.     {
  115.         return $this->elearning->getEvaluationChapterUser($uhcID,$chapterID);
  116.     }
  117.     public function getElearningInfoChapter($uhgq,$chapter)
  118.     {
  119.         return $this->elearning->getInfoChapter($uhgq,$chapter);
  120.     }
  121.     public function getElearningGenerationTentativeChapter($uhgq,$chapter)
  122.     {
  123.         return $this->elearning->getGenerationTentativeChapter($uhgq,$chapter);
  124.     }
  125.     public function getQcmApplicationCountQuestionsChapter($chapter)
  126.     {
  127.         return $this->elearning->getQcmApplicationCountQuestionsChapter($chapter);
  128.     }
  129.     public function getQcmApplicationUserResponse($uhaq,$question)
  130.     {
  131.         return $this->elearning->getQcmApplicationUserResponse($uhaq,$question);
  132.     }
  133.     public function getQcmApplicationChapterQuestions($chapter)
  134.     {
  135.         return $this->elearning->getQcmApplicationChapterQuestions($chapter);
  136.     }
  137.     public function getQcmApplicationChapterQuestionResponses($question)
  138.     {
  139.         return $this->elearning->getQcmApplicationChapterQuestionResponses($question);
  140.     }
  141.     public function getElearningCategories()
  142.     {
  143.         return $this->elearning->getCategories();
  144.     }
  145.     public function getElearningCategoriesQCM()
  146.     {
  147.         return $this->elearning->getCategoriesQCM();
  148.     }
  149.     public function getElearningCategoriesItems($category)
  150.     {
  151.         return $this->elearning->getCategoriesHasItems($category);
  152.     }
  153.     public function getElearningTimeCourse($course)
  154.     {
  155.         return $this->elearning->getFormationCourseTime($course);
  156.     }
  157.     public function getElearningCountUserFormationsCertificat($user)
  158.     {
  159.         return $this->elearning->countUserFormationsCertificat($user);
  160.     }
  161.     public function getElearningCountUserFormationsTermined($user)
  162.     {
  163.         return $this->elearning->countUserFormationsTermined($user);
  164.     }
  165.     public function getElearningCountUserFormationsAvailable($user)
  166.     {
  167.         return $this->elearning->countUserFormationsAvailable($user);
  168.     }
  169.     public function getElearningCountUserFormations($user)
  170.     {
  171.         return $this->elearning->countUserFormations($user);
  172.     }
  173.     public function getElearningCountChapters($course)
  174.     {
  175.         return $this->elearning->countChapters($course);
  176.     }
  177.     public function getElearningPage($blockID)
  178.     {
  179.         return $this->elearning->getCoursesPage($blockID);
  180.     }
  181.     public function getElearningCourseChapters($courseID)
  182.     {
  183.         return $this->elearning->getCourseChapters($courseID);
  184.     }
  185.     public function getElearningQcmQuestionsResponses($questionID)
  186.     {
  187.         return $this->elearning->getQuestionsResponses($questionID);
  188.     }
  189.     public function getElearningQcmUserQuestionResponses($uhq,$questionID)
  190.     {
  191.         return $this->elearning->getUserQuestionResponse($uhq,$questionID);
  192.     }
  193.     public function getElearningChapterParts($chapterID)
  194.     {
  195.         return $this->elearning->getChapterParts($chapterID);
  196.     }
  197.     public function getElearningChapterPartTime($uhc,$partID)
  198.     {
  199.         return $this->elearning->getPartTime($uhc,$partID);
  200.     }
  201.     public function getElearningUserTime($uhc)
  202.     {
  203.         return $this->elearning->getUserTime($uhc);
  204.     }
  205.     public function getElearningCourseTime($uhc)
  206.     {
  207.         return $this->elearning->getCourseTime($uhc);
  208.     }
  209.     public function getElearningProgress($uhc)
  210.     {
  211.         return $this->elearning->getProgress($uhc);
  212.     }
  213.     public function heuresToSecondesMinutes($hours)
  214.     {
  215.         $sum $hours *60 60;
  216.         return $this->sec_en_hms($sum);
  217.     }
  218.     private function sec_en_hms($t)
  219.     {
  220.         $s=$t%60$t=($t-$s)/60;
  221.         $m=$t%60;
  222.         $h=($t-$m)/60;
  223.         $h round($h);
  224.         $m round($m);
  225.         $s round($s);
  226.         if($m<10){$m="0".$m;}
  227.         if($s<10){$s="0".$s;}
  228.         return $h.":".$m.":".$s;
  229.     }
  230.     public function getTimeFromDate($uht)
  231.     {
  232.         return $this->elearning->getTimeFromDate($uht);
  233.     }
  234. }