<?php
namespace App\Twig;
use App\Services\Elearning;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
class ElearningExtension extends AbstractExtension
{
public function __construct(Elearning $elearning)
{
$this->elearning = $elearning;
}
/**
* {@inheritdoc}
*/
public function getFunctions(): array
{
return [
new TwigFunction('getElearningChapterParts', [$this, 'getElearningChapterParts']),
new TwigFunction('getElearningChapterPartTime', [$this, 'getElearningChapterPartTime']),
new TwigFunction('getElearningProgress', [$this, 'getElearningProgress']),
new TwigFunction('getElearningQcmQuestionsResponses', [$this, 'getElearningQcmQuestionsResponses']),
new TwigFunction('getElearningQcmUserQuestionResponses', [$this, 'getElearningQcmUserQuestionResponses']),
new TwigFunction('heuresToSecondesMinutes', [$this, 'heuresToSecondesMinutes']),
new TwigFunction('getTimeFromDate', [$this, 'getTimeFromDate']),
new TwigFunction('getElearningPage', [$this, 'getElearningPage']),
new TwigFunction('getElearningCourseChapters', [$this, 'getElearningCourseChapters']),
new TwigFunction('getElearningCountChapters', [$this, 'getElearningCountChapters']),
new TwigFunction('getElearningCountUserFormations', [$this, 'getElearningCountUserFormations']),
new TwigFunction('getElearningCountUserFormationsTermined', [$this, 'getElearningCountUserFormationsTermined']),
new TwigFunction('getElearningCountUserFormationsAvailable', [$this, 'getElearningCountUserFormationsAvailable']),
new TwigFunction('getElearningCountUserFormationsCertificat', [$this, 'getElearningCountUserFormationsCertificat']),
new TwigFunction('getElearningTimeCourse', [$this, 'getElearningTimeCourse']),
new TwigFunction('getElearningCategoriesQCM', [$this, 'getElearningCategoriesQCM']),
new TwigFunction('getElearningCategories', [$this, 'getElearningCategories']),
new TwigFunction('getElearningCategoriesItems', [$this, 'getElearningCategoriesItems']),
new TwigFunction('getQcmApplicationChapterQuestions', [$this, 'getQcmApplicationChapterQuestions']),
new TwigFunction('getQcmApplicationChapterQuestionResponses', [$this, 'getQcmApplicationChapterQuestionResponses']),
new TwigFunction('getQcmApplicationUserResponse', [$this, 'getQcmApplicationUserResponse']),
new TwigFunction('getQcmApplicationCountQuestionsChapter', [$this, 'getQcmApplicationCountQuestionsChapter']),
new TwigFunction('getElearningGenerationTentativeChapter', [$this, 'getElearningGenerationTentativeChapter']),
new TwigFunction('getElearningInfoChapter', [$this, 'getElearningInfoChapter']),
new TwigFunction('getElearningEvaluationChapterUser', [$this, 'getElearningEvaluationChapterUser']),
new TwigFunction('getElearningEvaluationUser', [$this, 'getElearningEvaluationUser']),
new TwigFunction('getElearningEvaluationChapters', [$this, 'getElearningEvaluationChapters']),
new TwigFunction('getElearningSidebarUser', [$this, 'getElearningSidebarUser']),
new TwigFunction('getElearningUserTime', [$this, 'getElearningUserTime']),
new TwigFunction('getElearningCourseTime', [$this, 'getElearningCourseTime']),
new TwigFunction('getElearningLastMessageCourse', [$this, 'getElearningLastMessageCourse']),
new TwigFunction('getElearningLastMessageCourseUser', [$this, 'getElearningLastMessageCourseUser']),
new TwigFunction('getElearningSubscriptionExpirationDate', [$this, 'getElearningSubscriptionExpirationDate']),
new TwigFunction('getElearningCoursePayments', [$this, 'getElearningCoursePayments']),
new TwigFunction('getElearningEnterpriseCourseCommission', [$this, 'getElearningEnterpriseCourseCommission']),
new TwigFunction('getElearningPartnerCommission', [$this, 'getElearningPartnerCommission']),
new TwigFunction('getElearningSimulationContract', [$this, 'getElearningSimulationContract']),
];
}
public function getElearningPartnerCommission($commissionID)
{
return $this->elearning->getPartnerCommission($commissionID);
}
/**
* Total de la commission de l'enterprise sur sa formation.
* @param $uhc - UsersHasCourses
* @return mixed
*/
public function getElearningEnterpriseCourseCommission($uhc)
{
return $this->elearning->getCourseEnterpriseCommission($uhc);
}
public function getElearningSimulationContract($pourcent,$montant)
{
return $this->elearning->getSimulationContract($pourcent,$montant);
}
/**
* Total des paiements d'une course.
* @param $uhc - UsersHasCourses
* @return mixed
*/
public function getElearningCoursePayments($uhc)
{
return $this->elearning->getCoursePayments($uhc);
}
public function getElearningSubscriptionExpirationDate($agency)
{
return $this->elearning->getSubscriptionExpirationDate($agency);
}
public function getElearningLastMessageCourseUser($agency,$user)
{
return $this->elearning->getLastMessageCourseUser($agency,$user);
}
public function getElearningLastMessageCourse($uhc)
{
return $this->elearning->getLastMessage($uhc);
}
public function getElearningSidebarUser($userID)
{
return $this->elearning->getSidebarUser($userID);
}
public function getElearningEvaluationUser($uhcID)
{
return $this->elearning->getEvaluationUser($uhcID);
}
public function getElearningEvaluationChapters($uhcEntity)
{
return $this->elearning->getEvaluationChapters($uhcEntity);
}
public function getElearningEvaluationChapterUser($uhcID,$chapterID)
{
return $this->elearning->getEvaluationChapterUser($uhcID,$chapterID);
}
public function getElearningInfoChapter($uhgq,$chapter)
{
return $this->elearning->getInfoChapter($uhgq,$chapter);
}
public function getElearningGenerationTentativeChapter($uhgq,$chapter)
{
return $this->elearning->getGenerationTentativeChapter($uhgq,$chapter);
}
public function getQcmApplicationCountQuestionsChapter($chapter)
{
return $this->elearning->getQcmApplicationCountQuestionsChapter($chapter);
}
public function getQcmApplicationUserResponse($uhaq,$question)
{
return $this->elearning->getQcmApplicationUserResponse($uhaq,$question);
}
public function getQcmApplicationChapterQuestions($chapter)
{
return $this->elearning->getQcmApplicationChapterQuestions($chapter);
}
public function getQcmApplicationChapterQuestionResponses($question)
{
return $this->elearning->getQcmApplicationChapterQuestionResponses($question);
}
public function getElearningCategories()
{
return $this->elearning->getCategories();
}
public function getElearningCategoriesQCM()
{
return $this->elearning->getCategoriesQCM();
}
public function getElearningCategoriesItems($category)
{
return $this->elearning->getCategoriesHasItems($category);
}
public function getElearningTimeCourse($course)
{
return $this->elearning->getFormationCourseTime($course);
}
public function getElearningCountUserFormationsCertificat($user)
{
return $this->elearning->countUserFormationsCertificat($user);
}
public function getElearningCountUserFormationsTermined($user)
{
return $this->elearning->countUserFormationsTermined($user);
}
public function getElearningCountUserFormationsAvailable($user)
{
return $this->elearning->countUserFormationsAvailable($user);
}
public function getElearningCountUserFormations($user)
{
return $this->elearning->countUserFormations($user);
}
public function getElearningCountChapters($course)
{
return $this->elearning->countChapters($course);
}
public function getElearningPage($blockID)
{
return $this->elearning->getCoursesPage($blockID);
}
public function getElearningCourseChapters($courseID)
{
return $this->elearning->getCourseChapters($courseID);
}
public function getElearningQcmQuestionsResponses($questionID)
{
return $this->elearning->getQuestionsResponses($questionID);
}
public function getElearningQcmUserQuestionResponses($uhq,$questionID)
{
return $this->elearning->getUserQuestionResponse($uhq,$questionID);
}
public function getElearningChapterParts($chapterID)
{
return $this->elearning->getChapterParts($chapterID);
}
public function getElearningChapterPartTime($uhc,$partID)
{
return $this->elearning->getPartTime($uhc,$partID);
}
public function getElearningUserTime($uhc)
{
return $this->elearning->getUserTime($uhc);
}
public function getElearningCourseTime($uhc)
{
return $this->elearning->getCourseTime($uhc);
}
public function getElearningProgress($uhc)
{
return $this->elearning->getProgress($uhc);
}
public function heuresToSecondesMinutes($hours)
{
$sum = $hours *60 * 60;
return $this->sec_en_hms($sum);
}
private function sec_en_hms($t)
{
$s=$t%60; $t=($t-$s)/60;
$m=$t%60;
$h=($t-$m)/60;
$h = round($h);
$m = round($m);
$s = round($s);
if($m<10){$m="0".$m;}
if($s<10){$s="0".$s;}
return $h.":".$m.":".$s;
}
public function getTimeFromDate($uht)
{
return $this->elearning->getTimeFromDate($uht);
}
}