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.         ];
  57.     }
  58.     public function getElearningPartnerCommission($commissionID)
  59.     {
  60.         return $this->elearning->getPartnerCommission($commissionID);
  61.     }
  62.     /**
  63.      * Total de la commission de l'enterprise sur sa formation.
  64.      * @param $uhc - UsersHasCourses
  65.      * @return mixed
  66.      */
  67.     public function getElearningEnterpriseCourseCommission($uhc)
  68.     {
  69.         return $this->elearning->getCourseEnterpriseCommission($uhc);
  70.     }
  71.     public function getElearningSimulationContract($pourcent,$montant)
  72.     {
  73.         return $this->elearning->getSimulationContract($pourcent,$montant);
  74.     }
  75.     /**
  76.      * Total des paiements d'une course.
  77.      * @param $uhc - UsersHasCourses
  78.      * @return mixed
  79.      */
  80.     public function getElearningCoursePayments($uhc)
  81.     {
  82.         return $this->elearning->getCoursePayments($uhc);
  83.     }
  84.     public function getElearningSubscriptionExpirationDate($agency)
  85.     {
  86.         return $this->elearning->getSubscriptionExpirationDate($agency);
  87.     }
  88.     public function getElearningLastMessageCourseUser($agency,$user)
  89.     {
  90.         return $this->elearning->getLastMessageCourseUser($agency,$user);
  91.     }
  92.     public function getElearningLastMessageCourse($uhc)
  93.     {
  94.         return $this->elearning->getLastMessage($uhc);
  95.     }
  96.     public function getElearningSidebarUser($userID)
  97.     {
  98.         return $this->elearning->getSidebarUser($userID);
  99.     }
  100.     public function getElearningEvaluationUser($uhcID)
  101.     {
  102.         return $this->elearning->getEvaluationUser($uhcID);
  103.     }
  104.     public function getElearningEvaluationChapters($uhcEntity)
  105.     {
  106.         return $this->elearning->getEvaluationChapters($uhcEntity);
  107.     }
  108.     public function getElearningEvaluationChapterUser($uhcID,$chapterID)
  109.     {
  110.         return $this->elearning->getEvaluationChapterUser($uhcID,$chapterID);
  111.     }
  112.     public function getElearningInfoChapter($uhgq,$chapter)
  113.     {
  114.         return $this->elearning->getInfoChapter($uhgq,$chapter);
  115.     }
  116.     public function getElearningGenerationTentativeChapter($uhgq,$chapter)
  117.     {
  118.         return $this->elearning->getGenerationTentativeChapter($uhgq,$chapter);
  119.     }
  120.     public function getQcmApplicationCountQuestionsChapter($chapter)
  121.     {
  122.         return $this->elearning->getQcmApplicationCountQuestionsChapter($chapter);
  123.     }
  124.     public function getQcmApplicationUserResponse($uhaq,$question)
  125.     {
  126.         return $this->elearning->getQcmApplicationUserResponse($uhaq,$question);
  127.     }
  128.     public function getQcmApplicationChapterQuestions($chapter)
  129.     {
  130.         return $this->elearning->getQcmApplicationChapterQuestions($chapter);
  131.     }
  132.     public function getQcmApplicationChapterQuestionResponses($question)
  133.     {
  134.         return $this->elearning->getQcmApplicationChapterQuestionResponses($question);
  135.     }
  136.     public function getElearningCategories()
  137.     {
  138.         return $this->elearning->getCategories();
  139.     }
  140.     public function getElearningCategoriesQCM()
  141.     {
  142.         return $this->elearning->getCategoriesQCM();
  143.     }
  144.     public function getElearningCategoriesItems($category)
  145.     {
  146.         return $this->elearning->getCategoriesHasItems($category);
  147.     }
  148.     public function getElearningTimeCourse($course)
  149.     {
  150.         return $this->elearning->getFormationCourseTime($course);
  151.     }
  152.     public function getElearningCountUserFormationsCertificat($user)
  153.     {
  154.         return $this->elearning->countUserFormationsCertificat($user);
  155.     }
  156.     public function getElearningCountUserFormationsTermined($user)
  157.     {
  158.         return $this->elearning->countUserFormationsTermined($user);
  159.     }
  160.     public function getElearningCountUserFormationsAvailable($user)
  161.     {
  162.         return $this->elearning->countUserFormationsAvailable($user);
  163.     }
  164.     public function getElearningCountUserFormations($user)
  165.     {
  166.         return $this->elearning->countUserFormations($user);
  167.     }
  168.     public function getElearningCountChapters($course)
  169.     {
  170.         return $this->elearning->countChapters($course);
  171.     }
  172.     public function getElearningPage($blockID)
  173.     {
  174.         return $this->elearning->getCoursesPage($blockID);
  175.     }
  176.     public function getElearningCourseChapters($courseID)
  177.     {
  178.         return $this->elearning->getCourseChapters($courseID);
  179.     }
  180.     public function getElearningQcmQuestionsResponses($questionID)
  181.     {
  182.         return $this->elearning->getQuestionsResponses($questionID);
  183.     }
  184.     public function getElearningQcmUserQuestionResponses($uhq,$questionID)
  185.     {
  186.         return $this->elearning->getUserQuestionResponse($uhq,$questionID);
  187.     }
  188.     public function getElearningChapterParts($chapterID)
  189.     {
  190.         return $this->elearning->getChapterParts($chapterID);
  191.     }
  192.     public function getElearningChapterPartTime($uhc,$partID)
  193.     {
  194.         return $this->elearning->getPartTime($uhc,$partID);
  195.     }
  196.     public function getElearningUserTime($uhc)
  197.     {
  198.         return $this->elearning->getUserTime($uhc);
  199.     }
  200.     public function getElearningCourseTime($uhc)
  201.     {
  202.         return $this->elearning->getCourseTime($uhc);
  203.     }
  204.     public function getElearningProgress($uhc)
  205.     {
  206.         return $this->elearning->getProgress($uhc);
  207.     }
  208.     public function heuresToSecondesMinutes($hours)
  209.     {
  210.         $sum $hours *60 60;
  211.         return $this->sec_en_hms($sum);
  212.     }
  213.     private function sec_en_hms($t)
  214.     {
  215.         $s=$t%60$t=($t-$s)/60;
  216.         $m=$t%60;
  217.         $h=($t-$m)/60;
  218.         $h round($h);
  219.         $m round($m);
  220.         $s round($s);
  221.         if($m<10){$m="0".$m;}
  222.         if($s<10){$s="0".$s;}
  223.         return $h.":".$m.":".$s;
  224.     }
  225.     public function getTimeFromDate($uht)
  226.     {
  227.         return $this->elearning->getTimeFromDate($uht);
  228.     }
  229. }