コード例 #1
0
 /**
  * @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());
 }
コード例 #2
0
}
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));
        }
    }
}
/*	Is the user allowed here? */
api_protect_course_script(true);
/*  STATISTICS */
if (!isset($coursesAlreadyVisited[$course_code])) {
    event_access_course();
    $coursesAlreadyVisited[$course_code] = 1;
    Session::write('coursesAlreadyVisited', $coursesAlreadyVisited);
}
/*Auto launch code */
$show_autolunch_lp_warning = false;
$auto_launch = api_get_course_setting('enable_lp_auto_launch');
if (!empty($auto_launch)) {
    $session_id = api_get_session_id();
    if ($auto_launch == 2) {
        //LP list
        if (api_is_platform_admin() || api_is_allowed_to_edit()) {
            $show_autolunch_lp_warning = true;
        } else {
            $session_key = 'lp_autolunch_' . $session_id . '_' . api_get_course_int_id() . '_' . api_get_user_id();
            if (!isset($_SESSION[$session_key])) {