Esempio n. 1
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);
 }