Exemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $container = $this->getContainer();
     $em = $container->get('doctrine')->getManager();
     $project = $em->getRepository('LearningMainBundle:Project')->findOneById(1);
     $course = $em->getRepository('LearningMainBundle:Course')->findOneById(43);
     $modulesIds = $em->getRepository('LearningMainBundle:Course')->modulesIdsOfCourse($course->getId());
     //		var_dump($project->getUserAccess());
     //		exit;
     foreach ($project->getUserAccess() as $userId) {
         if ($userId->getId() != 995) {
             continue;
         }
         $user = $em->getRepository('LearningMainBundle:User')->findOneById($userId->getId());
         $output->writeln('Курс добавлен к ' . $user->getUsername());
         $userCourse = new UserCourse();
         $userCourse->setUser($user);
         $userCourse->setCourse($course);
         $userCourse->setBallsRoh(0);
         $userCourse->setCountModules(count($modulesIds));
         $userCourse->setModules($modulesIds);
         //			em->persist($userCourse);
         //			$em->flush();
         $user = $userCourse->getUser();
         $container->get('email.service')->send($user->getUsername(), array('LearningMainBundle:Email:course_approved.html.twig', array('user' => $user, 'userCourse' => $userCourse, 'course' => $userCourse->getCourse())), 'Заявка на курс одобрена');
     }
 }
Exemplo n.º 2
0
 /**
  * Прохождение ДЕМО курса на конкретном этапе
  * @Route("/demostudy/{position}", name = "demoStudy", options={"expose"=true}, requirements={ "position":"\d+"})
  * @Template("LearningMainBundle:Education:demo_study.html.twig")
  */
 public function demoStudyAction($position = 1)
 {
     $em = $this->getDoctrine()->getManager();
     $data = new \DateTime();
     $userCourse = new UserCourse();
     $userCourse->setBallsRoh(0);
     $userCourse->setCourse($this->getDoctrine()->getRepository('LearningMainBundle:Course')->findOneById(47));
     $userCourse->setModules(array(0 => 71, 1 => 80));
     $userCourse->setCountModules(2);
     $userCourse->setPosition($position);
     $userCourse->setBallsRoh(0);
     $userCourse->setPassed(false);
     $userCourse->setStarts(new \DateTime());
     $userCourse->setEnds(new \DateTime('+ 1 Month'));
     #$this->checkAccessUserCourse($userCourse);
     $course = $userCourse->getCourse();
     $userCoursePosition = $userCourse->getPosition();
     $position = (int) $position;
     $now = new \DateTime();
     if ($position > $userCoursePosition || $position < 1) {
         $position = $userCoursePosition;
     }
     $courseModules = $em->getRepository('LearningMainBundle:CourseModule')->byIds($userCourse->getModules());
     $module = $courseModules[$position - 1];
     # получаем ответы модуля теста и группируем их по вопросам
     $questions = $passedTest = null;
     if ($module->getType() == 'test') {
         $moduleId = $module->getId();
         $answers = $em->getRepository('LearningMainBundle:CourseAnswer')->ofModule($moduleId);
         $questions = array();
         foreach ($answers as $answer) {
             $questions[$answer['questionTitle']][] = $answer;
         }
     }
     return array('module' => $module, 'courseModules' => $courseModules, 'userCourse' => $userCourse, 'course' => $course, 'position' => $position, 'positionTo' => $position + 1, 'questions' => $questions);
 }
Exemplo n.º 3
0
 public function getSertificate(UserCourse $userCourse)
 {
     $userCourse->setBallsRoh(24);
     $user = $userCourse->getUser();
     $course = $userCourse->getCourse();
     $rest = $userCourse->getBallsRoh() ? $userCourse->getBallsRoh() % 10 : 0;
     if (in_array($userCourse->getBallsRoh(), array(11, 12, 13, 14, 15, 16, 17, 18, 19))) {
         $ballsRohString = 'баллов';
     } else {
         switch ($rest) {
             case 1:
                 $ballsRohString = 'балл';
                 break;
             case 2:
             case 3:
             case 4:
                 $ballsRohString = 'балла';
                 break;
             default:
                 $ballsRohString = 'баллов';
                 break;
         }
     }
     switch ($userCourse->getPassed()->format('m')) {
         case 1:
             $month = 'января';
             break;
         case 2:
             $month = 'февраля';
             break;
         case 3:
             $month = 'марта';
             break;
         case 4:
             $month = 'апреля';
             break;
         case 5:
             $month = 'мая';
             break;
         case 6:
             $month = 'июня';
             break;
         case 7:
             $month = 'июля';
             break;
         case 8:
             $month = 'августа';
             break;
         case 9:
             $month = 'сентября';
             break;
         case 10:
             $month = 'октября';
             break;
         case 11:
             $month = 'ноября';
             break;
         case 12:
             $month = 'декабря';
             break;
     }
     $date = $userCourse->getPassed()->format('d') . ' ' . $month . ' ' . $userCourse->getPassed()->format('Y');
     //        $mpdfService = $this->$mpdf;
     $mpdfService = $this->container->get('tfox.mpdfport');
     $engine = $this->container->get('templating');
     $html = $engine->render('LearningMainBundle::certificate.html.twig', array('user' => $user, 'course' => $course, 'userCourse' => $userCourse, 'ballsRohString' => $ballsRohString, 'date' => $date));
     $arguments = array('constructorArgs' => array('utf-8', 'A4-L', 5, 5, 5, 5, 5), 'writeHtmlMode' => null, 'writeHtmlInitialise' => null, 'writeHtmlClose' => null, 'outputFilename' => null, 'outputDest' => null);
     $mpdfService->generatePdfResponse($html, $arguments);
 }