/** * @Route("/courses/{cidReq}/{sessionId}") * @Method({"GET"}) * * @param string $cidReq * @param int $id_session * @return Response */ public function indexAction($cidReq, $id_session = null) { $courseCode = api_get_course_id(); $sessionId = api_get_session_id(); $userId = $this->getUser()->getUserId(); $coursesAlreadyVisited = $this->getRequest()->getSession()->get('coursesAlreadyVisited'); $result = $this->autolaunch(); $showAutoLaunchLpWarning = $result['show_autolaunch_lp_warning']; $showAutoLaunchExerciseWarning = $result['show_autolaunch_exercise_warning']; if ($showAutoLaunchLpWarning) { $this->getTemplate()->assign('lp_warning', Display::return_message(get_lang('TheLPAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificLP'), 'warning')); } if ($showAutoLaunchExerciseWarning) { $this->getTemplate()->assign('exercise_warning', Display::return_message(get_lang('TheExerciseAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificExercise'), 'warning')); } if ($this->isCourseTeacher()) { $editIcons = Display::url(Display::return_icon('edit.png'), $this->generateUrl('course_home.controller:iconListAction', array('course' => api_get_course_id()))); $this->getTemplate()->assign('edit_icons', $editIcons); } if (!isset($coursesAlreadyVisited[$courseCode])) { event_access_course(); $coursesAlreadyVisited[$courseCode] = 1; $this->getRequest()->getSession()->set('coursesAlreadyVisited', $coursesAlreadyVisited); } $this->getRequest()->getSession()->remove('toolgroup'); $this->getRequest()->getSession()->remove('_gid'); $isSpecialCourse = \CourseManager::is_special_course($courseCode); if ($isSpecialCourse) { $autoreg = $this->getRequest()->get('autoreg'); if ($autoreg == 1) { \CourseManager::subscribe_user($userId, $courseCode, STUDENT); } } $script = 'activity.php'; if (api_get_setting('homepage_view') == 'activity' || api_get_setting('homepage_view') == 'activity_big') { $script = 'activity.php'; } elseif (api_get_setting('homepage_view') == '2column') { $script = '2column.php'; } elseif (api_get_setting('homepage_view') == '3column') { $script = '3column.php'; } elseif (api_get_setting('homepage_view') == 'vertical_activity') { $script = 'vertical_activity.php'; } $result = (require_once api_get_path(SYS_CODE_PATH) . 'course_home/' . $script); $toolList = $result['tool_list']; $this->getTemplate()->assign('icons', $result['content']); $introduction = Display::return_introduction_section($this->get('url_generator'), TOOL_COURSE_HOMEPAGE, $toolList); $this->getTemplate()->assign('introduction_text', $introduction); if (api_get_setting('show_session_data') == 'true' && $sessionId) { $sessionInfo = \CourseHome::show_session_data($sessionId); $this->getTemplate()->assign('session_info', $sessionInfo); } $response = $this->get('template')->render_template($this->getTemplatePath() . 'index.tpl'); return new Response($response, 200, array()); }
/** * @Route("/", name="course_home") * @Route("/index.php") * @Method({"GET"}) * @return Response */ public function indexAction(Request $request) { $course = $this->getCourse(); $session = $this->getSession(); // Already added in the listener. /*if (false === $this->isGranted('view', $course)) { throw new AccessDeniedException('Unauthorised access!'); }*/ $courseCode = $course->getId(); $sessionId = api_get_session_id(); $sessionHandler = $request->getSession(); $coursesAlreadyVisited = $sessionHandler->get('coursesAlreadyVisited'); $result = $this->autolaunch(); $showAutoLaunchLpWarning = $result['show_autolaunch_lp_warning']; $showAutoLaunchExerciseWarning = $result['show_autolaunch_exercise_warning']; if ($showAutoLaunchLpWarning) { $this->addFlash('warning', 'TheLPAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificLP'); } if ($showAutoLaunchExerciseWarning) { $this->addFlash('warning', 'TheExerciseAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificExercise'); } if (true) { $editIcons = Display::url(Display::return_icon('edit.png'), $this->generateUrl('chamilo_course_home_home_iconlist', array('course' => api_get_course_id()))); } // Course access events $dispatcher = $this->container->get('event_dispatcher'); $dispatcher->dispatch('chamilo_course.course.access', new CourseAccess($this->getUser(), $course)); if (!isset($coursesAlreadyVisited[$courseCode])) { $dispatcher = $this->container->get('event_dispatcher'); if (empty($sessionId)) { $dispatcher->dispatch('chamilo_course.course.access', new CourseAccess($this->getUser(), $course)); } else { $dispatcher->dispatch('chamilo_course.course.access', new SessionAccess($this->getUser(), $course, $session)); } $coursesAlreadyVisited[$courseCode] = 1; $sessionHandler->set('coursesAlreadyVisited', $coursesAlreadyVisited); } $sessionHandler->remove('toolgroup'); $sessionHandler->remove('_gid'); $isSpecialCourse = \CourseManager::is_special_course($courseCode); if ($isSpecialCourse) { $user = $this->getUser(); if (!empty($user)) { $userId = $this->getUser()->getId(); $autoreg = $this->getRequest()->get('autoreg'); if ($autoreg == 1) { \CourseManager::subscribe_user($userId, $courseCode, STUDENT); } } } $homeView = api_get_setting('course.homepage_view'); $homeView = 'activity_big'; if ($homeView == 'activity' || $homeView == 'activity_big') { $result = $this->renderActivityView(); } elseif ($homeView == '2column') { $result = $this->render2ColumnView(); } elseif ($homeView == '3column') { $result = $this->render3ColumnView(); } elseif ($homeView == 'vertical_activity') { $result = $this->renderVerticalActivityView(); } $toolList = $result['tool_list']; $introduction = Display::return_introduction_section($this->get('router'), TOOL_COURSE_HOMEPAGE, $toolList); $sessionInfo = null; if (api_get_setting('session.show_session_data') == 'true' && $sessionId) { $sessionInfo = CourseHome::show_session_data($sessionId); } /*$response = $this->render( 'ChamiloCoreBundle:Tool:Home/index.html.twig', array( 'session_info' => $sessionInfo, 'icons' => $result['content'], 'edit_icons' => $editIcons, 'introduction_text' => $introduction, 'exercise_warning' => null, 'lp_warning' => null ) ); return new Response($response, 200, array());*/ return $this->render('ChamiloCourseBundle:Home:index.html.twig', array('course' => $course, 'session_info' => $sessionInfo, 'icons' => $result['content'], 'edit_icons' => $editIcons, 'introduction_text' => $introduction, 'exercise_warning' => null, 'lp_warning' => null)); }
define('TOOL_AUTHORING', 'toolauthoring'); define('TOOL_INTERACTION', 'toolinteraction'); define('TOOL_COURSE_PLUGIN', 'toolcourseplugin'); //all plugins that can be enabled in courses define('TOOL_ADMIN', 'tooladmin'); define('TOOL_ADMIN_PLATFORM', 'tooladminplatform'); define('TOOL_DRH', 'tool_drh'); define('TOOL_STUDENT_VIEW', 'toolstudentview'); define('TOOL_ADMIN_VISIBLE', 'tooladminvisible'); $user_id = api_get_user_id(); $course_code = api_get_course_id(); $show_message = ''; // Deleting group session Session::erase('toolgroup'); Session::erase('_gid'); $is_speacialcourse = CourseManager::is_special_course($course_code); if ($is_speacialcourse) { $autoreg = Security::remove_XSS($_GET['autoreg']); if ($autoreg == 1) { if (CourseManager::subscribe_user($user_id, $course_code, $status = STUDENT)) { Session::write('is_allowed_in_course', true); } } } if (isset($_GET['action']) && $_GET['action'] == 'subscribe') { if (Security::check_token('get')) { Security::clear_token(); $auth = new Auth(); $msg = $auth->subscribe_user($course_code); if (!empty($msg)) { $show_message .= Display::return_message(get_lang($msg));