本文整理汇总了PHP中learnpath::is_lp_visible_for_student方法的典型用法代码示例。如果您正苦于以下问题:PHP learnpath::is_lp_visible_for_student方法的具体用法?PHP learnpath::is_lp_visible_for_student怎么用?PHP learnpath::is_lp_visible_for_student使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类learnpath
的用法示例。
在下文中一共展示了learnpath::is_lp_visible_for_student方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: api_not_allowed
api_not_allowed(true);
}
if ($debug > 0) {
error_log('New LP - export action triggered', 0);
}
if (!$lp_found) {
error_log('New LP - No learnpath given for export', 0);
require 'lp_list.php';
} else {
$_SESSION['oLP']->scorm_export();
exit;
//require 'lp_list.php';
}
break;
case 'export_to_pdf':
if (!learnpath::is_lp_visible_for_student($_SESSION['oLP']->lp_id, api_get_user_id())) {
api_not_allowed();
}
if ($debug > 0) {
error_log('New LP - export action triggered', 0);
}
if (!$lp_found) {
error_log('New LP - No learnpath given for export_to_pdf', 0);
require 'lp_list.php';
} else {
$result = $_SESSION['oLP']->scorm_export_to_pdf($_GET['lp_id']);
if (!$result) {
require 'lp_list.php';
}
exit;
}
示例2: api_protect_course_script
<?php
/* For licensing terms, see /license.txt */
/**
*
* @package chamilo.learnpath
*/
require_once '../inc/global.inc.php';
$_SESSION['whereami'] = 'lp/impress';
$this_section = SECTION_COURSES;
//To prevent the template class
$show_learnpath = true;
api_protect_course_script();
$lp_id = intval($_GET['lp_id']);
// Check if the learning path is visible for student - (LP requisites)
if (!api_is_allowed_to_edit(null, true) && !learnpath::is_lp_visible_for_student($lp_id, api_get_user_id())) {
api_not_allowed();
}
//Checking visibility (eye icon)
$visibility = api_get_item_visibility(api_get_course_info(), TOOL_LEARNPATH, $lp_id, $action, api_get_user_id(), api_get_session_id());
if (!api_is_allowed_to_edit(null, true) && intval($visibility) == 0) {
api_not_allowed();
}
if (empty($_SESSION['oLP'])) {
api_not_allowed(true);
}
$debug = 0;
if ($debug) {
error_log('------ Entering lp_impress.php -------');
}
$course_code = api_get_course_id();
示例3: session_cache_limiter
session_cache_limiter('none');
require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;
// Protection
api_protect_course_script();
if (!isset($_course)) {
api_not_allowed(true);
}
// If LP obj exists
if (isset($_SESSION['oLP'])) {
$obj = $_SESSION['oLP'];
} else {
api_not_allowed();
}
//If is visible for the current user
if (!learnpath::is_lp_visible_for_student($obj->get_id(), api_get_user_id())) {
api_not_allowed();
}
$doc_url = isset($_GET['doc_url']) ? $_GET['doc_url'] : null;
// Change the '&' that got rewritten to '///' by mod_rewrite back to '&'
$doc_url = str_replace('///', '&', $doc_url);
// Still a space present? it must be a '+' (that got replaced by mod_rewrite)
$doc_url = str_replace(' ', '+', $doc_url);
$doc_url = str_replace(array('../', '\\..', '\\0', '..\\'), array('', '', '', ''), $doc_url);
//echo $doc_url;
if (strpos($doc_url, '../') or strpos($doc_url, '/..')) {
$doc_url = '';
}
$sys_course_path = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/scorm';
//var_dump($sys_course_path);
if (is_dir($sys_course_path . $doc_url)) {
示例4: is_visible
/**
* Checks if the exercise is visible due a lot of conditions - visibility, time limits, student attempts
* @return bool true if is active
*/
public function is_visible($lp_id = 0, $lp_item_id = 0, $lp_item_view_id = 0, $filter_by_admin = true)
{
// 1. By default the exercise is visible
$is_visible = true;
$message = null;
// 1.1 Admins and teachers can access to the exercise
if ($filter_by_admin) {
if (api_is_platform_admin() || api_is_course_admin()) {
return array('value' => true, 'message' => '');
}
}
// Deleted exercise.
if ($this->active == -1) {
return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false));
}
// Checking visibility in the item_property table.
$visibility = api_get_item_visibility(api_get_course_info(), TOOL_QUIZ, $this->id, api_get_session_id());
if ($visibility == 0 || $visibility == 2) {
$this->active = 0;
}
// 2. If the exercise is not active.
if (empty($lp_id)) {
// 2.1 LP is OFF
if ($this->active == 0) {
return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false));
}
} else {
// 2.1 LP is loaded
if ($this->active == 0 && !learnpath::is_lp_visible_for_student($lp_id, api_get_user_id())) {
return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false));
}
}
//3. We check if the time limits are on
$limit_time_exists = !empty($this->start_time) && $this->start_time != '0000-00-00 00:00:00' || !empty($this->end_time) && $this->end_time != '0000-00-00 00:00:00' ? true : false;
if ($limit_time_exists) {
$time_now = time();
if (!empty($this->start_time) && $this->start_time != '0000-00-00 00:00:00') {
$is_visible = $time_now - api_strtotime($this->start_time, 'UTC') > 0 ? true : false;
}
if ($is_visible == false) {
$message = sprintf(get_lang('ExerciseAvailableFromX'), api_convert_and_format_date($this->start_time));
}
if ($is_visible == true) {
if ($this->end_time != '0000-00-00 00:00:00') {
$is_visible = (api_strtotime($this->end_time, 'UTC') > $time_now) > 0 ? true : false;
if ($is_visible == false) {
$message = sprintf(get_lang('ExerciseAvailableUntilX'), api_convert_and_format_date($this->end_time));
}
}
}
if ($is_visible == false && $this->start_time != '0000-00-00 00:00:00' && $this->end_time != '0000-00-00 00:00:00') {
$message = sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_convert_and_format_date($this->start_time), api_convert_and_format_date($this->end_time));
}
}
// 4. We check if the student have attempts
$exerciseAttempts = $this->selectAttempts();
if ($is_visible) {
if ($exerciseAttempts > 0) {
$attempt_count = Event::get_attempt_count_not_finished(api_get_user_id(), $this->id, $lp_id, $lp_item_id, $lp_item_view_id);
if ($attempt_count >= $exerciseAttempts) {
$message = sprintf(get_lang('ReachedMaxAttempts'), $this->name, $exerciseAttempts);
$is_visible = false;
}
}
}
if (!empty($message)) {
$message = Display::return_message($message, 'warning', false);
}
return array('value' => $is_visible, 'message' => $message);
}
示例5: show_notification
/**
* Returns the "what's new" icon notifications
*
* The general logic of this function is to track the last time the user
* entered the course and compare to what has changed inside this course
* since then, based on the item_property table inside this course. Note that,
* if the user never entered the course before, he will not see notification
* icons. This function takes session ID into account (if any) and only shows
* the corresponding notifications.
* @param array Course information array, containing at least elements 'db' and 'k'
* @return string The HTML link to be shown next to the course
*/
public static function show_notification($course_info)
{
$t_track_e_access = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$tool_edit_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$course_code = Database::escape_string($course_info['code']);
$user_id = api_get_user_id();
$course_id = $course_info['real_id'];
$course_info['id_session'] = intval($course_info['id_session']);
// Get the user's last access dates to all tools of this course
$sql = "SELECT *\n FROM {$t_track_e_access} USE INDEX (access_cours_code, access_user_id)\n WHERE\n access_cours_code = '" . $course_code . "' AND\n access_user_id = '{$user_id}' AND\n access_session_id ='" . $course_info['id_session'] . "'";
$resLastTrackInCourse = Database::query($sql);
$oldestTrackDate = $oldestTrackDateOrig = '3000-01-01 00:00:00';
while ($lastTrackInCourse = Database::fetch_array($resLastTrackInCourse)) {
$lastTrackInCourseDate[$lastTrackInCourse['access_tool']] = $lastTrackInCourse['access_date'];
if ($oldestTrackDate > $lastTrackInCourse['access_date']) {
$oldestTrackDate = $lastTrackInCourse['access_date'];
}
}
if ($oldestTrackDate == $oldestTrackDateOrig) {
//if there was no connexion to the course ever, then take the
// course creation date as a reference
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "SELECT course.creation_date " . "FROM {$course_table} course " . "WHERE course.code = '" . $course_code . "'";
$res = Database::query($sql);
if ($res && Database::num_rows($res) > 0) {
$row = Database::fetch_array($res);
}
$oldestTrackDate = $row['creation_date'];
}
// Get the last edits of all tools of this course.
$sql = "SELECT\n tet.*,\n tet.lastedit_date last_date,\n tet.tool tool,\n tet.ref ref,\n tet.lastedit_type type,\n tet.to_group_id group_id,\n ctt.image image,\n ctt.link link\n FROM {$tool_edit_table} tet, {$course_tool_table} ctt\n WHERE\n tet.c_id = {$course_id} AND\n ctt.c_id = {$course_id} AND\n tet.lastedit_date > '{$oldestTrackDate}' " . " AND (ctt.name = tet.tool OR (ctt.name = 'student_publication' AND tet.tool = 'work')) " . " AND ctt.visibility = '1' " . " AND tet.lastedit_user_id != {$user_id} AND tet.id_session = '" . $course_info['id_session'] . "'\n ORDER BY tet.lastedit_date";
$res = Database::query($sql);
// Get the group_id's with user membership.
$group_ids = GroupManager::get_group_ids($course_info['real_id'], $user_id);
$group_ids[] = 0;
//add group 'everyone'
$notifications = array();
// Filter all last edits of all tools of the course
while ($res && ($item_property = Database::fetch_array($res))) {
// First thing to check is if the user never entered the tool
// or if his last visit was earlier than the last modification.
if ((!isset($lastTrackInCourseDate[$item_property['tool']]) || $lastTrackInCourseDate[$item_property['tool']] < $item_property['lastedit_date']) && (in_array($item_property['to_group_id'], $group_ids) && ($item_property['tool'] != TOOL_DROPBOX && $item_property['tool'] != TOOL_NOTEBOOK && $item_property['tool'] != TOOL_CHAT)) && ($item_property['visibility'] == '1' || $course_info['status'] == '1' && $item_property['visibility'] == '0' || !isset($item_property['visibility']))) {
if ($course_info['real_id'] == 1) {
// var_dump($item_property);
}
// Also drop announcements and events that are not for the user or his group.
if (($item_property['tool'] == TOOL_ANNOUNCEMENT || $item_property['tool'] == TOOL_CALENDAR_EVENT) && ($item_property['to_user_id'] != $user_id && (!isset($item_property['to_group_id']) || !in_array($item_property['to_group_id'], $group_ids)))) {
continue;
}
// If it's a survey, make sure the user's invited. Otherwise drop it.
if ($item_property['tool'] == TOOL_SURVEY) {
$survey_info = survey_manager::get_survey($item_property['ref'], 0, $course_code);
if (!empty($survey_info)) {
$invited_users = SurveyUtil::get_invited_users($survey_info['code'], $course_code);
if (!in_array($user_id, $invited_users['course_users'])) {
continue;
}
}
}
// If it's a learning path, ensure it is currently visible to the user
if ($item_property['tool'] == TOOL_LEARNPATH) {
require_once api_get_path(SYS_CODE_PATH) . 'newscorm/learnpath.class.php';
if (!learnpath::is_lp_visible_for_student($item_property['ref'], $user_id, $course_code)) {
continue;
}
}
if ($item_property['tool'] == 'work' && $item_property['type'] == 'DirectoryCreated') {
$item_property['lastedit_type'] = 'WorkAdded';
}
$notifications[$item_property['tool']] = $item_property;
}
}
// Show all tool icons where there is something new.
$retvalue = ' ';
while (list($key, $notification) = each($notifications)) {
$lastDate = date('d/m/Y H:i', convert_sql_date($notification['lastedit_date']));
$type = $notification['lastedit_type'];
if (empty($course_info['id_session'])) {
$my_course['id_session'] = 0;
} else {
$my_course['id_session'] = $course_info['id_session'];
}
$label = get_lang('TitleNotification') . ": " . get_lang($type) . " ({$lastDate})";
$retvalue .= '<a href="' . api_get_path(WEB_CODE_PATH) . $notification['link'] . '?cidReq=' . $course_code . '&ref=' . $notification['ref'] . '&gidReq=' . $notification['to_group_id'] . '&id_session=' . $my_course['id_session'] . '">' . Display::return_icon($notification['image'], $label) . '</a> ';
}
return $retvalue;
}
示例6: str_replace
$doc_url = str_replace(' ', '+', $doc_url);
$doc_url = str_replace(array('../', '\\..', '\\0', '..\\'), array('', '', '', ''), $doc_url);
//echo $doc_url;
if (strpos($doc_url, '../') or strpos($doc_url, '/..')) {
$doc_url = '';
}
$sys_course_path = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/scorm';
$user_id = api_get_user_id();
/** @var learnpath $learnPath */
$learnPath = Session::read('oLP');
if ($learnPath) {
$lp_id = $learnPath->get_id();
$lp_item_id = $learnPath->current;
$lp_item_info = new learnpathItem($lp_item_id);
if (!empty($lp_item_info)) {
//if (basename($lp_item_info->path) == basename($doc_url)) {
$visible = learnpath::is_lp_visible_for_student($lp_id, $user_id);
if ($visible) {
Event::event_download($doc_url);
if (Security::check_abs_path($sys_course_path . $doc_url, $sys_course_path . '/')) {
$full_file_name = $sys_course_path . $doc_url;
DocumentManager::file_send_for_download($full_file_name);
exit;
}
}
//}
}
}
Display::display_error_message(get_lang('ProtectedDocument'));
//api_not_allowed backbutton won't work.
exit;
示例7: show_tools_category
/**
* Displays the tools of a certain category.
* @param array $all_tools_list List of tools as returned by get_tools_category()
* @param bool $rows
*
* @return void
*/
public static function show_tools_category($all_tools_list, $rows = false)
{
$_user = api_get_user_info();
$theme = api_get_setting('homepage_view');
if ($theme == 'vertical_activity') {
//ordering by get_lang name
$order_tool_list = array();
if (is_array($all_tools_list) && count($all_tools_list) > 0) {
foreach ($all_tools_list as $key => $new_tool) {
$tool_name = self::translate_tool_name($new_tool);
$order_tool_list[$key] = $tool_name;
}
natsort($order_tool_list);
$my_temp_tool_array = array();
foreach ($order_tool_list as $key => $new_tool) {
$my_temp_tool_array[] = $all_tools_list[$key];
}
$all_tools_list = $my_temp_tool_array;
} else {
$all_tools_list = array();
}
}
$web_code_path = api_get_path(WEB_CODE_PATH);
$session_id = api_get_session_id();
$is_platform_admin = api_is_platform_admin();
if ($session_id == 0) {
$is_allowed_to_edit = api_is_allowed_to_edit(null, true) && api_is_course_admin();
} else {
$is_allowed_to_edit = api_is_allowed_to_edit(null, true) && !api_is_coach();
}
$i = 0;
$items = array();
$app_plugin = new AppPlugin();
if (isset($all_tools_list)) {
$lnk = '';
foreach ($all_tools_list as &$tool) {
$item = array();
$studentview = false;
$tool['original_link'] = $tool['link'];
if ($tool['image'] == 'scormbuilder.gif') {
// check if the published learnpath is visible for student
$published_lp_id = self::get_published_lp_id_from_link($tool['link']);
if (api_is_allowed_to_edit(null, true)) {
$studentview = true;
}
if (!api_is_allowed_to_edit(null, true) && !learnpath::is_lp_visible_for_student($published_lp_id, api_get_user_id(), api_get_course_id(), api_get_session_id())) {
continue;
}
}
if ($session_id != 0 && in_array($tool['name'], array('course_setting'))) {
continue;
}
// This part displays the links to hide or remove a tool.
// These links are only visible by the course manager.
unset($lnk);
$item['extra'] = null;
$toolAdmin = isset($tool['admin']) ? $tool['admin'] : '';
if ($is_allowed_to_edit) {
if (empty($session_id)) {
if (isset($tool['id'])) {
if ($tool['visibility'] == '1' && $toolAdmin != '1') {
$link['name'] = Display::return_icon('visible.png', get_lang('Deactivate'), array('id' => 'linktool_' . $tool['id']), ICON_SIZE_SMALL, false);
$link['cmd'] = 'hide=yes';
$lnk[] = $link;
}
if ($tool['visibility'] == '0' && $toolAdmin != '1') {
$link['name'] = Display::return_icon('invisible.png', get_lang('Activate'), array('id' => 'linktool_' . $tool['id']), ICON_SIZE_SMALL, false);
$link['cmd'] = 'restore=yes';
$lnk[] = $link;
}
}
}
if (!empty($tool['adminlink'])) {
$item['extra'] = '<a href="' . $tool['adminlink'] . '">' . Display::return_icon('edit.gif', get_lang('Edit')) . '</a>';
}
}
// Both checks are necessary as is_platform_admin doesn't take student view into account
if ($is_platform_admin && $is_allowed_to_edit) {
if ($toolAdmin != '1') {
$link['cmd'] = 'hide=yes';
}
}
$item['visibility'] = null;
if (isset($lnk) && is_array($lnk)) {
foreach ($lnk as $this_link) {
if (empty($tool['adminlink'])) {
$item['visibility'] .= '<a class="make_visible_and_invisible" href="' . api_get_self() . '?' . api_get_cidreq() . '&id=' . $tool['id'] . '&' . $this_link['cmd'] . '">' . $this_link['name'] . '</a>';
}
}
} else {
$item['visibility'] .= '';
}
// NOTE : Table contains only the image file name, not full path
//.........这里部分代码省略.........
示例8: is_visible
/**
* Checks if the exercise is visible due a lot of conditions
* visibility, time limits, student attempts
* Return associative array
* value : true if execise visible
* message : HTML formated message
* rawMessage : text message
* @param int $lpId
* @param int $lpItemId
* @param int $lpItemViewId
* @param bool $filterByAdmin
* @return array
*/
public function is_visible($lpId = 0, $lpItemId = 0, $lpItemViewId = 0, $filterByAdmin = true)
{
// 1. By default the exercise is visible
$is_visible = true;
$message = null;
// 1.1 Admins and teachers can access to the exercise
if ($filterByAdmin) {
if (api_is_platform_admin() || api_is_course_admin()) {
return array('value' => true, 'message' => '');
}
}
// Deleted exercise.
if ($this->active == -1) {
return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false), 'rawMessage' => get_lang('ExerciseNotFound'));
}
// Checking visibility in the item_property table.
$visibility = api_get_item_visibility(api_get_course_info(), TOOL_QUIZ, $this->id, api_get_session_id());
if ($visibility == 0 || $visibility == 2) {
$this->active = 0;
}
// 2. If the exercise is not active.
if (empty($lpId)) {
// 2.1 LP is OFF
if ($this->active == 0) {
return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false), 'rawMessage' => get_lang('ExerciseNotFound'));
}
} else {
// 2.1 LP is loaded
if ($this->active == 0 && !learnpath::is_lp_visible_for_student($lpId, api_get_user_id())) {
return array('value' => false, 'message' => Display::return_message(get_lang('ExerciseNotFound'), 'warning', false), 'rawMessage' => get_lang('ExerciseNotFound'));
}
}
//3. We check if the time limits are on
if (!empty($this->start_time) && $this->start_time != '0000-00-00 00:00:00' || !empty($this->end_time) && $this->end_time != '0000-00-00 00:00:00') {
$limitTimeExists = true;
} else {
$limitTimeExists = false;
}
if ($limitTimeExists) {
$timeNow = time();
$existsStartDate = false;
$nowIsAfterStartDate = true;
$existsEndDate = false;
$nowIsBeforeEndDate = true;
if (!empty($this->start_time) && $this->start_time != '0000-00-00 00:00:00') {
$existsStartDate = true;
}
if (!empty($this->end_time) && $this->end_time != '0000-00-00 00:00:00') {
$existsEndDate = true;
}
// check if we are before-or-after end-or-start date
if ($existsStartDate && $timeNow < api_strtotime($this->start_time, 'UTC')) {
$nowIsAfterStartDate = false;
}
if ($existsEndDate & $timeNow >= api_strtotime($this->end_time, 'UTC')) {
$nowIsBeforeEndDate = false;
}
// lets check all cases
if ($existsStartDate && !$existsEndDate) {
// exists start date and dont exists end date
if ($nowIsAfterStartDate) {
// after start date, no end date
$isVisible = true;
$message = sprintf(get_lang('ExerciseAvailableSinceX'), api_convert_and_format_date($this->start_time));
} else {
// before start date, no end date
$isVisible = false;
$message = sprintf(get_lang('ExerciseAvailableFromX'), api_convert_and_format_date($this->start_time));
}
} else {
if (!$existsStartDate && $existsEndDate) {
// doesnt exist start date, exists end date
if ($nowIsBeforeEndDate) {
// before end date, no start date
$isVisible = true;
$message = sprintf(get_lang('ExerciseAvailableUntilX'), api_convert_and_format_date($this->end_time));
} else {
// after end date, no start date
$isVisible = false;
$message = sprintf(get_lang('ExerciseAvailableUntilX'), api_convert_and_format_date($this->end_time));
}
} elseif ($existsStartDate && $existsEndDate) {
// exists start date and end date
if ($nowIsAfterStartDate) {
if ($nowIsBeforeEndDate) {
// after start date and before end date
$isVisible = true;
//.........这里部分代码省略.........
示例9: api_protect_course_script
require_once 'back_compat.inc.php';
require_once 'learnpath.class.php';
require_once 'learnpathItem.class.php';
//To prevent the template class
$show_learnpath = true;
api_protect_course_script();
$lp_id = intval($_GET['lp_id']);
// Check if the learning path is visible for student - (LP requisites)
if (!api_is_platform_admin()) {
if (!api_is_allowed_to_edit(null, true) &&
!learnpath::is_lp_visible_for_student($lp_id, api_get_user_id())
) {
api_not_allowed(true);
}
}
// Checking visibility (eye icon)
$visibility = api_get_item_visibility(
api_get_course_info(),
TOOL_LEARNPATH,
$lp_id,
$action,
api_get_user_id(),
api_get_session_id()
);
if (!api_is_allowed_to_edit(false, true, false, false) && intval($visibility) == 0) {
示例10: show_notification
/**
* Returns the "what's new" icon notifications
*
* The general logic of this function is to track the last time the user
* entered the course and compare to what has changed inside this course
* since then, based on the item_property table inside this course. Note that,
* if the user never entered the course before, he will not see notification
* icons. This function takes session ID into account (if any) and only shows
* the corresponding notifications.
* @param array Course information array, containing at least elements 'db' and 'k'
* @return string The HTML link to be shown next to the course
*/
public static function show_notification($course_info)
{
if (empty($course_info)) {
return '';
}
$t_track_e_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$tool_edit_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$course_code = Database::escape_string($course_info['code']);
$user_id = api_get_user_id();
$course_id = intval($course_info['real_id']);
$sessionId = intval($course_info['id_session']);
// Get the user's last access dates to all tools of this course
$sql = "SELECT *\n FROM {$t_track_e_access}\n WHERE\n c_id = {$course_id} AND\n access_user_id = '{$user_id}' AND\n access_session_id ='" . $sessionId . "'";
$resLastTrackInCourse = Database::query($sql);
$oldestTrackDate = $oldestTrackDateOrig = '3000-01-01 00:00:00';
while ($lastTrackInCourse = Database::fetch_array($resLastTrackInCourse)) {
$lastTrackInCourseDate[$lastTrackInCourse['access_tool']] = $lastTrackInCourse['access_date'];
if ($oldestTrackDate > $lastTrackInCourse['access_date']) {
$oldestTrackDate = $lastTrackInCourse['access_date'];
}
}
if ($oldestTrackDate == $oldestTrackDateOrig) {
//if there was no connexion to the course ever, then take the
// course creation date as a reference
$oldestTrackDate = $course_info['creation_date'];
}
$sessionCondition = api_get_session_condition($sessionId, true, false, 'tet.session_id');
// Get the last edits of all tools of this course.
$sql = "SELECT\n tet.*,\n tet.lastedit_date last_date,\n tet.tool tool,\n tet.ref ref,\n tet.lastedit_type type,\n tet.to_group_id group_id,\n ctt.image image,\n ctt.link link\n FROM {$tool_edit_table} tet\n INNER JOIN {$course_tool_table} ctt\n ON tet.c_id = ctt.c_id\n WHERE\n tet.c_id = {$course_id} AND\n tet.lastedit_date > '{$oldestTrackDate}' " . " AND (ctt.name = tet.tool OR (ctt.name = 'student_publication' AND tet.tool = 'work'))\n AND ctt.visibility = '1'\n AND tet.lastedit_user_id != {$user_id} {$sessionCondition}\n ORDER BY tet.lastedit_date";
$res = Database::query($sql);
// Get the group_id's with user membership.
$group_ids = GroupManager::get_group_ids($course_info['real_id'], $user_id);
$group_ids[] = 0;
//add group 'everyone'
$notifications = array();
// Filter all last edits of all tools of the course
while ($res && ($item_property = Database::fetch_array($res, 'ASSOC'))) {
// First thing to check is if the user never entered the tool
// or if his last visit was earlier than the last modification.
if ((!isset($lastTrackInCourseDate[$item_property['tool']]) || $lastTrackInCourseDate[$item_property['tool']] < $item_property['lastedit_date']) && (in_array($item_property['to_group_id'], $group_ids) && ($item_property['tool'] != TOOL_NOTEBOOK && $item_property['tool'] != TOOL_CHAT)) && ($item_property['visibility'] == '1' || $course_info['status'] == '1' && $item_property['visibility'] == '0' || !isset($item_property['visibility']))) {
// Also drop announcements and events that are not for the user or his group.
if (($item_property['tool'] == TOOL_ANNOUNCEMENT || $item_property['tool'] == TOOL_CALENDAR_EVENT) && ($item_property['to_user_id'] != $user_id && (!isset($item_property['to_group_id']) || !in_array($item_property['to_group_id'], $group_ids)))) {
continue;
}
// If it's a survey, make sure the user's invited. Otherwise drop it.
if ($item_property['tool'] == TOOL_SURVEY) {
$survey_info = SurveyManager::get_survey($item_property['ref'], 0, $course_code);
if (!empty($survey_info)) {
$invited_users = SurveyUtil::get_invited_users($survey_info['code'], $course_code);
if (!in_array($user_id, $invited_users['course_users'])) {
continue;
}
}
}
// If it's a learning path, ensure it is currently visible to the user
if ($item_property['tool'] == TOOL_LEARNPATH) {
if (!learnpath::is_lp_visible_for_student($item_property['ref'], $user_id, $course_code)) {
continue;
}
}
if ($item_property['tool'] == TOOL_DROPBOX) {
$item_property['link'] = 'dropbox/dropbox_download.php?id=' . $item_property['ref'];
}
if ($item_property['tool'] == 'work' && $item_property['type'] == 'DirectoryCreated') {
$item_property['lastedit_type'] = 'WorkAdded';
}
$notifications[$item_property['tool']] = $item_property;
}
}
// Show all tool icons where there is something new.
$return = ' ';
foreach ($notifications as $notification) {
$lastDate = date('d/m/Y H:i', convert_sql_date($notification['lastedit_date']));
$type = $notification['lastedit_type'];
$label = get_lang('TitleNotification') . ": " . get_lang($type) . " ({$lastDate})";
if (strpos($notification['link'], '?') === false) {
$notification['link'] = $notification['link'] . '?notification=1';
} else {
$notification['link'] = $notification['link'] . '¬ification=1';
}
$return .= Display::url(Display::return_icon($notification['image'], $label), api_get_path(WEB_CODE_PATH) . $notification['link'] . '&cidReq=' . $course_code . '&ref=' . $notification['ref'] . '&gidReq=' . $notification['to_group_id'] . '&id_session=' . $sessionId) . ' ';
}
return $return;
}
示例11: show_tools_category
/**
* Displays the tools of a certain category.
* @param Symfony\Component\Routing\RouterInterface $urlGenerator
* @param array List of tools as returned by get_tools_category()
* @param bool rows
* @return string
*/
public static function show_tools_category($urlGenerator, $toolList, $rows = false)
{
$rowDiv = '<div class="row">';
$theme = api_get_setting('homepage_view');
if ($theme == 'vertical_activity') {
//ordering by get_lang name
$order_tool_list = array();
if (is_array($toolList) && count($toolList) > 0) {
foreach ($toolList as $key => $new_tool) {
$tool_name = self::translate_tool_name($new_tool);
$order_tool_list[$key] = $tool_name;
}
natsort($order_tool_list);
$my_temp_tool_array = array();
foreach ($order_tool_list as $key => $new_tool) {
$my_temp_tool_array[] = $toolList[$key];
}
$toolList = $my_temp_tool_array;
} else {
$toolList = array();
}
}
$courseInfo = api_get_course_info();
$web_code_path = api_get_path(WEB_CODE_PATH);
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$is_platform_admin = api_is_platform_admin();
$session_id = api_get_session_id();
$items = array();
$app_plugin = new AppPlugin();
if (isset($toolList)) {
$lnk = '';
foreach ($toolList as &$tool) {
$item = array();
$tool['admin'] = isset($tool['admin']) ? $tool['admin'] : null;
$tool['id'] = isset($tool['id']) ? $tool['id'] : null;
$tool['target'] = isset($tool['target']) ? $tool['target'] : null;
if (isset($tool['link_id'])) {
$tool['original_link'] = api_get_path(WEB_CODE_PATH) . 'link/link_goto.php?link_id=' . $tool['link_id'] . '&' . api_get_cidreq();
$tool['link'] = $tool['original_link'];
} else {
$tool['original_link'] = $tool['link'];
}
// Re-writing URL for new tools
$newTools = array(TOOL_CURRICULUM);
$toolName = isset($tool['name']) ? $tool['name'] : null;
if (in_array($toolName, $newTools)) {
$tool['link'] = $courseInfo['course_web_public_url'] . $tool['name'] . '/';
}
if ($tool['image'] == 'scormbuilder.gif') {
// Check if the published learnpath is visible for student
$published_lp_id = self::get_published_lp_id_from_link($tool['link']);
if (!api_is_allowed_to_edit(null, true) && !learnpath::is_lp_visible_for_student($published_lp_id, api_get_user_id())) {
continue;
}
}
if ($session_id != 0 && in_array($tool['name'], array('course_maintenance', 'course_setting'))) {
continue;
}
if ($tool['name'] == 'course_description') {
$tool['link'] = 'course_description/index.php';
}
// This part displays the links to hide or remove a tool.
// These links are only visible by the course manager.
unset($lnk);
$item['extra'] = null;
if ($is_allowed_to_edit && !api_is_coach()) {
if (empty($session_id)) {
if ($tool['visibility'] == '1' && $tool['admin'] != '1') {
$link['name'] = Display::return_icon('visible.gif', get_lang('Deactivate'), array('id' => 'linktool_' . $tool['id']), ICON_SIZE_MEDIUM, false);
if (!empty($tool['id'])) {
$link['cmd'] = $urlGenerator->generate('course_home.controller:hideIconAction', array('course' => api_get_course_id(), 'iconId' => $tool['id']));
}
$lnk[] = $link;
}
if ($tool['visibility'] == '0' && $tool['admin'] != '1') {
$link['name'] = Display::return_icon('invisible.gif', get_lang('Activate'), array('id' => 'linktool_' . $tool['id']), ICON_SIZE_MEDIUM, false);
if (!empty($tool['id'])) {
$link['cmd'] = $urlGenerator->generate('course_home.controller:showIconAction', array('course' => api_get_course_id(), 'iconId' => $tool['id']));
}
$lnk[] = $link;
}
}
if (!empty($tool['adminlink'])) {
$item['extra'] = '<a href="' . $tool['adminlink'] . '">' . Display::return_icon('edit.gif', get_lang('Edit')) . '</a>';
}
}
// Both checks are necessary as is_platform_admin doesn't take student view into account
if ($is_platform_admin && $is_allowed_to_edit) {
if ($tool['admin'] != '1') {
$link['cmd'] = 'hide=yes';
}
}
$item['visibility'] = null;
//.........这里部分代码省略.........
示例12: array
}
$counter++;
if (($counter % 2) == 0) {
$oddclass = 'row_odd';
} else {
$oddclass = 'row_even';
}
$url_start_lp = 'lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$id;
$name = Security::remove_XSS($details['lp_name']);
$extra = null;
if ($is_allowed_to_edit) {
$url_start_lp .= '&isStudentView=true';
$studentVisibility = learnpath::is_lp_visible_for_student($id, $userId);
$dsp_desc = '<em>'.$details['lp_maker'].'</em> '.( $studentVisibility ? '' : ' - ('.get_lang('LPNotVisibleToStudent').')');
$extra = '<div class ="lp_content_type_label">'.$dsp_desc.'</div>';
}
$my_title = $name;
$icon_learnpath = Display::return_icon('learnpath.png', get_lang('LPName'), '', ICON_SIZE_SMALL);
if ($details['lp_visibility'] == 0) {
$my_title = Display::tag('font', $name, array('class' => 'invisible'));
$icon_learnpath = Display::return_icon('learnpath_na.png', get_lang('LPName'), '', ICON_SIZE_SMALL);
}
$dsp_line = '<tr align="center" class="'.$oddclass.'">'.
'<td align="left" valign="top">'.$icon_learnpath.'
<a href="'.$url_start_lp.'">'.$my_title.'</a>'.$session_img.$extra."</td>";
示例13: api_convert_and_format_date
}
if (!empty($details['expired_on'])) {
$end_time = api_convert_and_format_date($details['expired_on'], DATE_TIME_FORMAT_LONG);
}
}
$counter++;
if ($counter % 2 == 0) {
$oddclass = 'row_odd';
} else {
$oddclass = 'row_even';
}
$url_start_lp = 'lp_controller.php?' . api_get_cidreq() . '&action=view&lp_id=' . $id;
$name = Security::remove_XSS($details['lp_name']);
if ($is_allowed_to_edit) {
$url_start_lp .= '&isStudentView=true';
$dsp_desc = '<em>' . $details['lp_maker'] . '</em> ' . (learnpath::is_lp_visible_for_student($id, api_get_user_id()) ? '' : ' - (' . get_lang('LPNotVisibleToStudent') . ')');
$extra = '<div class ="lp_content_type_label">' . $dsp_desc . '</div>';
}
/*$image = '<img src="../img/icons/22/learnpath.png" border="0" align="absmiddle" alt="' . $name . '">';
<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_lp.'">' .
$image . '</a></div>*/
$my_title = $name;
if ($details['lp_visibility'] == 0) {
$my_title = Display::tag('font', $name, array('style' => 'color:grey'));
}
$dsp_line = '<tr align="center" class="' . $oddclass . '">' . '<td align="left" valign="top">' . Display::return_icon('learnpath.png', get_lang('LPName'), '', ICON_SIZE_SMALL) . '
<a href="' . $url_start_lp . '">' . $my_title . '</a>' . $session_img . $extra . "</td>";
$dsp_desc = '';
$dsp_export = '';
$dsp_edit = '';
$dsp_build = '';