Example #1
0
				$("#id_confirmation_message").html(message);
				$("#id_confirmation_message").show();
			}
		});
	});
});

</script>';
// The section for the tabs
$this_section = SECTION_COURSES;
$user_id = api_get_user_id();
$course_code = api_get_course_id();
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
$show_message = '';
if (api_is_invitee()) {
    $isInASession = $sessionId > 0;
    $isSubscribed = CourseManager::is_user_subscribed_in_course($user_id, $course_code, $isInASession, $sessionId);
    if (!$isSubscribed) {
        api_not_allowed(true);
    }
}
//Deleting group session
Session::erase('toolgroup');
Session::erase('_gid');
$isSpecialCourse = CourseManager::isSpecialCourse($courseId);
if ($isSpecialCourse) {
    if (isset($_GET['autoreg'])) {
        $autoRegistration = Security::remove_XSS($_GET['autoreg']);
        if ($autoRegistration == 1) {
            if (CourseManager::subscribe_user($user_id, $course_code, STUDENT)) {
Example #2
0
// Set flag to ensure lp_header.php is loaded by this script (flag is unset in lp_header.php).
Session::write('loaded_lp_view', true);
$display_none = '';
$margin_left = '340px';
//Media player code
$display_mode = $learnPath->mode;
$scorm_css_header = true;
$lp_theme_css = $learnPath->get_theme();
// Setting up the CSS theme if exists.
if (!empty($lp_theme_css) && !empty($mycourselptheme) && $mycourselptheme != -1 && $mycourselptheme == 1) {
    global $lp_theme_css;
} else {
    $lp_theme_css = $my_style;
}
$progress_bar = "";
if (!api_is_invitee()) {
    $progress_bar = $learnPath->getProgressBar();
}
$navigation_bar = $learnPath->get_navigation_bar();
$navigation_bar_bottom = $learnPath->get_navigation_bar("control-bottom", "display:none");
$mediaplayer = $learnPath->get_mediaplayer($autostart);
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$show_audioplayer = false;
// Getting all the information about the item.
$sql = "SELECT audio FROM " . $tbl_lp_item . "\n        WHERE c_id = {$course_id} AND lp_id = '" . $learnPath->lp_id . "'";
$res_media = Database::query($sql);
if (Database::num_rows($res_media) > 0) {
    while ($row_media = Database::fetch_array($res_media)) {
        if (!empty($row_media['audio'])) {
            $show_audioplayer = true;
            break;
Example #3
0
$is_allowed_to_edit = api_is_allowed_to_edit();
$course_id = api_get_course_int_id();
$user_id = api_get_user_id();
$userInfo = api_get_user_info();
$session_id = api_get_session_id();
$course_info = api_get_course_info();
$course_code = $course_info['code'];
$group_id = api_get_group_id();
if (empty($work_id)) {
    api_not_allowed(true);
}
protectWork($course_info, $work_id);
$workInfo = get_work_data_by_id($work_id);
$is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course($user_id, $course_id, $session_id);
$is_course_member = $is_course_member || api_is_platform_admin();
if ($is_course_member == false || api_is_invitee()) {
    api_not_allowed(true);
}
$check = Security::check_token('post');
$token = Security::get_token();
$student_can_edit_in_session = api_is_allowed_to_session_edit(false, true);
//  @todo add an option to allow/block multiple attempts.
/*
if (!empty($workInfo) && !empty($workInfo['qualification'])) {
    $count =  get_work_count_by_student($user_id, $work_id);
    if ($count >= 1) {
        Display::display_header();
        if (api_get_course_setting('student_delete_own_publication') == '1') {
            Display::display_warning_message(get_lang('CantUploadDeleteYourPaperFirst'));
        } else {
            Display::display_warning_message(get_lang('YouAlreadySentAPaperYouCantUpload'));
Example #4
0
/**
 * Check whether the user type should be exclude.
 * Such as invited or anonymous users
 * @param boolean $checkDB Optional. Whether check the user status
 * @param int $userId Options. The user id
 *
 * @return boolean
 */
function api_is_excluded_user_type($checkDB = false, $userId = 0)
{
    if ($checkDB) {
        $userId = empty($userId) ? api_get_user_id() : intval($userId);
        if ($userId == 0) {
            return true;
        }
        $userInfo = api_get_user_info($userId);
        switch ($userInfo['status']) {
            case INVITEE:
                //no break;
            //no break;
            case ANONYMOUS:
                return true;
            default:
                return false;
        }
    }
    $isInvited = api_is_invitee();
    $isAnonymous = api_is_anonymous();
    if ($isInvited || $isAnonymous) {
        return true;
    }
    return false;
}
Example #5
0
echo '<div class="actions">';
if ($origin != 'learnpath') {
    if ($origin == 'group') {
        echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'group/group_space.php?' . api_get_cidreq() . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('Groups'), '', ICON_SIZE_MEDIUM) . '</a>';
    } else {
        echo '<span style="float:right;">' . search_link() . '</span>';
        echo '<a href="' . $forumUrl . 'index.php?' . api_get_cidreq() . '">' . Display::return_icon('back.png', get_lang('BackToForumOverview'), '', ICON_SIZE_MEDIUM) . '</a>';
    }
}
// The link should appear when
// 1. the course admin is here
// 2. the course member is here and new threads are allowed
// 3. a visitor is here and new threads AND allowed AND  anonymous posts are allowed
if (api_is_allowed_to_edit(false, true) || $current_forum['allow_new_threads'] == 1 && isset($_user['user_id']) || $current_forum['allow_new_threads'] == 1 && !isset($_user['user_id']) && $current_forum['allow_anonymous'] == 1) {
    if ($current_forum['locked'] != 1 and $current_forum['locked'] != 1) {
        if (!api_is_anonymous() && !api_is_invitee()) {
            if ($my_forum == strval(intval($my_forum))) {
                echo '<a href="' . $forumUrl . 'newthread.php?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($my_forum) . $origin_string . '">' . Display::return_icon('new_thread.png', get_lang('NewTopic'), '', ICON_SIZE_MEDIUM) . '</a>';
            } else {
                $my_forum = strval(intval($my_forum));
                echo '<a href="' . $forumUrl . 'newthread.php?' . api_get_cidreq() . '&forum=' . $my_forum . $origin_string . '">' . Display::return_icon('new_thread.png', get_lang('NewTopic'), '', ICON_SIZE_MEDIUM) . '</a>';
            }
        }
    } else {
        echo get_lang('ForumLocked');
    }
}
echo '</div>';
/* Display */
$titleForum = $current_forum['forum_title'];
$descriptionForum = $current_forum['forum_comment'];
 /**
  * Saves the last item seen's ID only in case
  */
 public function save_last()
 {
     $course_id = api_get_course_int_id();
     if ($this->debug > 0) {
         error_log('New LP - In learnpath::save_last()', 0);
     }
     $session_condition = api_get_session_condition(api_get_session_id(), true, false);
     $table = Database::get_course_table(TABLE_LP_VIEW);
     if (isset($this->current) && !api_is_invitee()) {
         if ($this->debug > 2) {
             error_log('New LP - Saving current item (' . $this->current . ') for later review', 0);
         }
         $sql = "UPDATE {$table} SET\n                        last_item = " . intval($this->get_current_item_id()) . "\n                    WHERE\n                        c_id = {$course_id} AND\n                        lp_id = " . $this->get_id() . " AND\n                        user_id = " . $this->get_user_id() . " " . $session_condition;
         if ($this->debug > 2) {
             error_log('New LP - Saving last item seen : ' . $sql, 0);
         }
         Database::query($sql);
     }
     if (!api_is_invitee()) {
         // Save progress.
         list($progress, $text) = $this->get_progress_bar_text('%');
         if ($progress >= 0 && $progress <= 100) {
             $progress = (int) $progress;
             $sql = "UPDATE {$table} SET\n                            progress = {$progress}\n                        WHERE\n                            c_id = " . $course_id . " AND\n                            lp_id = " . $this->get_id() . " AND\n                            user_id = " . $this->get_user_id() . " " . $session_condition;
             // Ignore errors as some tables might not have the progress field just yet.
             Database::query($sql);
             $this->progress_db = $progress;
         }
     }
 }
Example #7
0
 /**
  * Returns an array with the hottest courses
  * @param   int $days number of days
  * @param   int $limit number of hottest courses
  * @return array
  */
 public static function return_hot_courses($days = 30, $limit = 5)
 {
     global $_configuration;
     if (api_is_invitee()) {
         return array();
     }
     $limit = intval($limit);
     // Getting my courses
     $my_course_list = CourseManager::get_courses_list_by_user_id(api_get_user_id());
     $my_course_code_list = array();
     foreach ($my_course_list as $course) {
         $my_course_code_list[$course['real_id']] = $course['real_id'];
     }
     if (api_is_drh()) {
         $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
         foreach ($courses as $course) {
             $my_course_code_list[$course['real_id']] = $course['real_id'];
         }
     }
     $table_course_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
     $table_course = Database::get_main_table(TABLE_MAIN_COURSE);
     $table_course_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
     //@todo all dates in the tracking_course_access, last_access are in the DB time (NOW) not UTC
     /*
             $today                    = api_get_utc_datetime();
             $today_diff                = time() -intval($days)*24*60*60;
             $today_diff                = api_get_utc_datetime($today_diff);
              * */
     //WHERE login_course_date <= '$today' AND login_course_date >= '$today_diff'
     //$table_course_access table uses the now() and interval ...
     $now = api_get_utc_datetime(time());
     $sql = "SELECT COUNT(course_access_id) course_count, a.c_id, visibility\n                FROM {$table_course} c\n                INNER JOIN {$table_course_access} a\n                ON (c.id = a.c_id)\n                INNER JOIN {$table_course_url} u\n                ON u.c_id = c.id\n                WHERE\n                    u.access_url_id = " . api_get_current_access_url_id() . " AND\n                    login_course_date <= '{$now}' AND\n                    login_course_date > DATE_SUB(now(), INTERVAL {$days} DAY) AND\n                    visibility <> '" . COURSE_VISIBILITY_CLOSED . "' AND visibility <> '" . COURSE_VISIBILITY_HIDDEN . "'\n                GROUP BY a.c_id\n                ORDER BY course_count DESC\n                LIMIT {$limit}\n            ";
     $result = Database::query($sql);
     $courses = array();
     if (Database::num_rows($result)) {
         $courses = Database::store_result($result, 'ASSOC');
         $courses = self::process_hot_course_item($courses, $my_course_code_list);
     }
     return $courses;
 }
Example #8
0
            }
            $hideScormPdfLink = api_get_setting('hide_scorm_pdf_link');
            if ($hideScormPdfLink === 'true') {
                $export_icon = null;
            }
            $listData[] = ['learnpath_icon' => $icon_learnpath, 'url_start' => $url_start_lp, 'title' => $my_title, 'session_image' => $session_img, 'extra' => $extra, 'start_time' => $start_time, 'end_time' => $end_time, 'dsp_progress' => $dsp_progress, 'action_build' => $dsp_build, 'action_edit' => $dsp_edit_lp, 'action_visible' => $dsp_visible, 'action_publish' => $dsp_publish, 'action_reinit' => $dsp_reinit, 'action_default_view' => $dsp_default_view, 'action_debug' => $dsp_debug, 'action_export' => $dsp_disk, 'action_copy' => $copy, 'action_auto_launch' => $lp_auto_launch_icon, 'action_pdf' => $export_icon, 'action_delete' => $dsp_delete, 'action_order' => $dsp_order, 'action_serious_game' => $actionSeriousGame, 'action_subscribe_users' => $subscribeUsers];
            $lpIsShown = true;
            //counter for number of elements treated
            $current++;
        }
        // end foreach ($flat_list)
    }
    $data[] = ['category' => $item, 'lp_list' => $listData];
}
$template = new Template($nameTools);
$template->assign('is_allowed_to_edit', $is_allowed_to_edit);
$template->assign('is_invitee', api_is_invitee());
$template->assign('actions', $actions);
$template->assign('message', $message);
$template->assign('introduction_section', $introductionSection);
$template->assign('data', $data);
$template->assign('lp_is_shown', $lpIsShown);
$content = $template->fetch('default/learnpath/list.tpl');
$template->assign('content', $content);
$template->display_one_col_template();
$course_info = api_get_course_info();
learnpath::generate_learning_path_folder($course_info);
// Deleting the objects
Session::erase('oLP');
Session::erase('lpobject');
DocumentManager::removeGeneratedAudioTempFile();
Example #9
0
                $copy = null;
            }
            $hideScormPdfLink = api_get_setting('course.hide_scorm_pdf_link');
            if ($hideScormPdfLink === 'true') {
                $export_icon = null;
            }
            $listData[] = ['learnpath_icon' => $icon_learnpath, 'url_start' => $url_start_lp, 'title' => $my_title, 'session_image' => $session_img, 'extra' => $extra, 'start_time' => $start_time, 'end_time' => $end_time, 'dsp_progress' => $dsp_progress, 'action_build' => $dsp_build, 'action_edit' => $dsp_edit_lp, 'action_tracking' => $trackingAction, 'action_visible' => $dsp_visible, 'action_publish' => $dsp_publish, 'action_reinit' => $dsp_reinit, 'action_default_view' => $dsp_default_view, 'action_debug' => $dsp_debug, 'action_export' => $dsp_disk, 'action_copy' => $copy, 'action_auto_launch' => $lp_auto_launch_icon, 'action_pdf' => $export_icon, 'action_delete' => $dsp_delete, 'action_order' => $dsp_order, 'action_serious_game' => $actionSeriousGame, 'action_subscribe_users' => $subscribeUsers];
            $lpIsShown = true;
            //counter for number of elements treated
            $current++;
        }
        // end foreach ($flat_list)
    }
    $data[] = ['category' => $item, 'lp_list' => $listData];
}
$template = \Chamilo\CoreBundle\Framework\Container::getTwig();
$template->addGlobal('is_allowed_to_edit', $is_allowed_to_edit);
$template->addGlobal('is_invitee', api_is_invitee());
$template->addGlobal('actions', $actions);
$template->addGlobal('message', $message);
$template->addGlobal('introduction_section', $introductionSection);
$template->addGlobal('data', $data);
$template->addGlobal('lp_is_shown', $lpIsShown);
$content = $template->render('@template_style/learnpath/list.html.twig');
echo $content;
$course_info = api_get_course_info();
learnpath::generate_learning_path_folder($course_info);
// Deleting the objects
Session::erase('oLP');
Session::erase('lpobject');
DocumentManager::removeGeneratedAudioTempFile();