Minor - format code.

1.9.x
Julio Montoya 11 years ago
parent 5e410a7ffe
commit 43190f4b11
  1. 72
      main/course_home/activity.php
  2. 19
      main/exercice/savescores.php
  3. 212
      main/inc/lib/course_home.lib.php
  4. 7
      main/inc/lib/sessionmanager.lib.php
  5. 22
      main/inc/lib/system/session.class.php
  6. 4
      main/newscorm/learnpath.class.php
  7. 183
      main/newscorm/learnpathItem.class.php
  8. 2
      main/newscorm/lp_ajax_save_item.php
  9. 2
      main/newscorm/lp_view.php

@ -20,37 +20,37 @@ $session_id = api_get_session_id();
// MAIN CODE
if (api_is_allowed_to_edit(null, true)) {
// HIDE
if (!empty($_GET['hide'])) {
$sql = "UPDATE $tool_table SET visibility=0 WHERE c_id = $course_id AND id=".$id;
Database::query($sql);
$show_message = Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
} elseif (!empty($_GET['restore'])) {
// visibility 0,2 -> 1
// REACTIVATE
$sql = "UPDATE $tool_table SET visibility=1 WHERE c_id = $course_id AND id=".$id;
Database::query($sql);
//$show_message = Display::return_message(get_lang('ToolIsNowVisible'),'confirmation');
}
// HIDE
if (!empty($_GET['hide'])) {
$sql = "UPDATE $tool_table SET visibility=0 WHERE c_id = $course_id AND id=".$id;
Database::query($sql);
$show_message = Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
} elseif (!empty($_GET['restore'])) {
// visibility 0,2 -> 1
// REACTIVATE
$sql = "UPDATE $tool_table SET visibility=1 WHERE c_id = $course_id AND id=".$id;
Database::query($sql);
//$show_message = Display::return_message(get_lang('ToolIsNowVisible'),'confirmation');
}
}
// Work with data post askable by admin of course
if (api_is_platform_admin()) {
// Show message to confirm that a tool it to be hidden from available tools
// visibility 0,1->2
if (!empty($_GET['askDelete'])) {
// Show message to confirm that a tool it to be hidden from available tools
// visibility 0,1->2
if (!empty($_GET['askDelete'])) {
$content .='<div id="toolhide">'.get_lang('DelLk').'<br />&nbsp;&nbsp;&nbsp;
<a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;
<a href="'.api_get_self().'?delete=yes&id='.$id.'">'.get_lang('Yes').'</a>
</div>';
} elseif (isset($_GET['delete']) && $_GET['delete']) {
} elseif (isset($_GET['delete']) && $_GET['delete']) {
/*
* Process hiding a tools from available tools.
*/
//where $id is set?
$id = intval($id);
Database::query("DELETE FROM $tool_table WHERE c_id = $course_id AND id='$id' AND added_tool=1");
}
//where $id is set?
$id = intval($id);
Database::query("DELETE FROM $tool_table WHERE c_id = $course_id AND id='$id' AND added_tool=1");
}
}
// Course legal
@ -67,25 +67,25 @@ if ($enabled == 'true') {
// Start of tools for CourseAdmins (teachers/tutors)
if ($session_id == 0 && api_is_course_admin() && api_is_allowed_to_edit(null, true)) {
$content .= '<div class="courseadminview" style="border:0px; margin-top: 0px;padding:0px;">
$content .= '<div class="courseadminview" style="border:0px; margin-top: 0px;padding:0px;">
<div class="normal-message" id="id_normal_message" style="display:none">';
$content .= '<img src="'.api_get_path(WEB_PATH).'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
$content .= get_lang('PleaseStandBy');
$content .= '</div>
$content .= '<img src="'.api_get_path(WEB_PATH).'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
$content .= get_lang('PleaseStandBy');
$content .= '</div>
<div class="confirmation-message" id="id_confirmation_message" style="display:none"></div>
</div>';
$content .= $pluginExtra;
if (api_get_setting('show_session_data') == 'true' && $session_id > 0) {
if (api_get_setting('show_session_data') == 'true' && $session_id > 0) {
$content .= '<div class="courseadminview">
<span class="viewcaption">'.get_lang('SessionData').'</span>
<table class="course_activity_home">'.CourseHome::show_session_data($session_id).'
</table>
</div>';
}
}
$my_list = CourseHome::get_tools_category(TOOL_AUTHORING);
$items = CourseHome::show_tools_category($my_list);
$items = CourseHome::show_tools_category($my_list);
$content .= return_block(get_lang('Authoring'), $items, 'course-tools-author');
$my_list = CourseHome::get_tools_category(TOOL_INTERACTION);
@ -101,13 +101,13 @@ if ($session_id == 0 && api_is_course_admin() && api_is_allowed_to_edit(null, tr
} elseif (api_is_coach()) {
$content .= $pluginExtra;
if (api_get_setting('show_session_data') == 'true' && $session_id > 0) {
$content .= '<div class="row">
if (api_get_setting('show_session_data') == 'true' && $session_id > 0) {
$content .= '<div class="row">
<span class="viewcaption">'.get_lang('SessionData').'</span>
<table class="course_activity_home">';
$content .= CourseHome::show_session_data($session_id);
$content .= '</table></div>';
}
$content .= CourseHome::show_session_data($session_id);
$content .= '</table></div>';
}
$content .= '<div class="row">';
$my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
@ -127,18 +127,18 @@ if ($session_id == 0 && api_is_course_admin() && api_is_allowed_to_edit(null, tr
$onlyMaintenanceList[] = $item;
}
}
$items = CourseHome::show_tools_category($onlyMaintenanceList);
$content .= return_block(get_lang('Administration'), $items);
}
}
} else {
$my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
if (count($my_list) > 0) {
$my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
if (count($my_list) > 0) {
$content .= '<div class="row">';
$content .= CourseHome::show_tools_category($my_list);
$content .= '</div>';
}
}
}
function return_block($title, $content, $class) {

@ -6,9 +6,7 @@
* @author
* @version $Id: savescores.php 15602 2008-06-18 08:52:24Z pcool $
*/
/**
* Code
*/
// name of the language file that needs to be included
$language_file = 'learnpath';
@ -22,9 +20,12 @@ if (isset($_GET['origin']) && $_GET['origin'] == 'learnpath') {
}
require_once '../inc/global.inc.php';
$courseInfo = api_get_course_info();
$_user = api_get_user_info();
$this_section = SECTION_COURSES;
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
$documentPath = api_get_path(SYS_COURSE_PATH).$courseInfo['path']."/document";
$test = $_REQUEST['test'];
$full_file_path = $documentPath.$test;
@ -39,8 +40,7 @@ $_cid = api_get_course_id();
$score = $_REQUEST['score'];
$origin = $_REQUEST['origin'];
$learnpath_item_id = intval($_REQUEST['learnpath_item_id']);
$course_info = api_get_course_info();
$course_id = $course_info['real_id'];
$course_id = $courseInfo['real_id'];
$jscript2run = '';
/**
@ -103,9 +103,10 @@ if ($origin != 'learnpath') {
} else {
$htmlHeadXtra[] = $jscript2run;
Display::display_reduced_header();
$update_sql = "UPDATE $TABLE_LP_ITEM_VIEW SET status = 'completed'
WHERE c_id = $course_id AND lp_item_id= $learnpath_item_id";
Database::query($update_sql);
$sql = "UPDATE $TABLE_LP_ITEM_VIEW SET
status = 'completed'
WHERE c_id = $course_id AND lp_item_id= $learnpath_item_id";
Database::query($sql);
Display::display_confirmation_message(get_lang('HotPotatoesFinished'));
Display::display_footer();
}

@ -4,12 +4,16 @@
define('SHORTCUTS_HORIZONTAL', 0);
define('SHORTCUTS_VERTICAL', 1);
/**
* Class CourseHome
*/
class CourseHome
{
/**
* Gets the html content to show in the 3 column view
*/
public static function show_tool_3column($cat) {
public static function show_tool_3column($cat)
{
global $_user;
$TBL_ACCUEIL = Database :: get_course_table(TABLE_TOOL_LIST);
$TABLE_TOOLS = Database :: get_main_table(TABLE_MAIN_COURSE_MODULE);
@ -60,7 +64,6 @@ class CourseHome
$course_id = api_get_course_int_id();
// Grabbing all the links that have the property on_homepage set to 1
if ($cat == 'External') {
$tbl_link = Database :: get_course_table(TABLE_LINK);
@ -107,7 +110,13 @@ class CourseHome
// 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(), api_get_course_id(), api_get_session_id())) {
!learnpath::is_lp_visible_for_student(
$published_lp_id,
api_get_user_id(),
api_get_course_id(),
api_get_session_id()
)
) {
continue;
}
}
@ -170,7 +179,11 @@ class CourseHome
}
$lnk = array();
if (api_is_allowed_to_edit(null, true) && $cat != "courseAdmin" && !strpos($tool['link'], 'learnpath_handler.php?learnpath_id') && !api_is_coach()) {
if (api_is_allowed_to_edit(null, true) &&
$cat != "courseAdmin" &&
!strpos($tool['link'], 'learnpath_handler.php?learnpath_id') &&
!api_is_coach()
) {
if ($tool['visibility']) {
$link['name'] = Display::return_icon('remove.gif', get_lang('Deactivate'), array('style' => 'vertical-align: middle;'));
$link['cmd'] = "hide=yes";
@ -183,7 +196,8 @@ class CourseHome
if (is_array($lnk)) {
foreach ($lnk as & $this_lnk) {
if ($tool['adminlink']) {
$cell_content .= '<a href="'.$properties['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
$cell_content .= '<a href="'.$properties['adminlink'].'">'.
Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
} else {
$cell_content .= '<a href="'.api_get_self().'?id='.$tool['id'].'&amp;'.$this_lnk['cmd'].'">'.$this_lnk['name'].'</a>';
}
@ -194,6 +208,7 @@ class CourseHome
$table->updateCellAttributes($cell_number / $numcols, ($cell_number) % $numcols, 'width="32%" height="42"');
$cell_number++;
}
return $table->toHtml();
}
@ -204,7 +219,8 @@ class CourseHome
* @param string $course_tool_category contains the category of tools to display:
* "Public", "PublicButHide", "courseAdmin", "claroAdmin"
*/
public static function show_tool_2column($course_tool_category) {
public static function show_tool_2column($course_tool_category)
{
$html = '';
$web_code_path = api_get_path(WEB_CODE_PATH);
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
@ -290,12 +306,20 @@ class CourseHome
$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(), api_get_course_id(), api_get_session_id())) {
!learnpath::is_lp_visible_for_student(
$published_lp_id,
api_get_user_id(),
api_get_course_id(),
api_get_session_id()
)
) {
continue;
}
}
if (api_get_session_id() != 0 && in_array($tool['name'], array('course_maintenance', 'course_setting'))) {
if (api_get_session_id() != 0 &&
in_array($tool['name'], array('course_maintenance', 'course_setting'))
) {
continue;
}
@ -304,7 +328,10 @@ class CourseHome
}
// NOTE : Table contains only the image file name, not full path
if (stripos($tool['link'], 'http://') === false && stripos($tool['link'], 'https://') === false && stripos($tool['link'], 'ftp://') === false) {
if (stripos($tool['link'], 'http://') === false &&
stripos($tool['link'], 'https://') === false &&
stripos($tool['link'], 'ftp://') === false
) {
$tool['link'] = $web_code_path.$tool['link'];
}
if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN) {
@ -324,13 +351,18 @@ class CourseHome
}
$tool_name = self::translate_tool_name($tool);
$html .= Display::return_icon($tool['image'], $tool_name, array(), null, ICON_SIZE_MEDIUM).'&nbsp;'.$tool_name.'</a>';
$html .= Display::return_icon(
$tool['image'],
$tool_name,
array(),
null,
ICON_SIZE_MEDIUM
) . '&nbsp;' . $tool_name . '</a>';
// This part displays the links to hide or remove a tool.
// These links are only visible by the course manager.
unset($lnk);
if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
if ($tool['visibility'] == '1' || $tool['name'] == TOOL_TRACKING) {
$link['name'] = Display::return_icon('remove.gif', get_lang('Deactivate'));
$link['cmd'] = 'hide=yes';
@ -391,6 +423,7 @@ class CourseHome
if ($i % 2) {
$html .= "<td width=\"50%\">&nbsp;</td></tr>";
}
return $html;
}
@ -422,29 +455,38 @@ class CourseHome
$col_link = "##003399";
break;
case TOOL_AUTHORING:
$sql = "SELECT * FROM $course_tool_table WHERE category = 'authoring' AND c_id = $course_id $condition_session ORDER BY id";
$sql = "SELECT * FROM $course_tool_table
WHERE category = 'authoring' AND c_id = $course_id $condition_session
ORDER BY id";
$result = Database::query($sql);
$col_link = "##003399";
break;
case TOOL_INTERACTION:
$sql = "SELECT * FROM $course_tool_table WHERE category = 'interaction' AND c_id = $course_id $condition_session ORDER BY id";
$sql = "SELECT * FROM $course_tool_table
WHERE category = 'interaction' AND c_id = $course_id $condition_session
ORDER BY id";
$result = Database::query($sql);
$col_link = "##003399";
break;
case TOOL_ADMIN_VISIBLE:
$sql = "SELECT * FROM $course_tool_table WHERE category = 'admin' AND visibility ='1' AND c_id = $course_id $condition_session ORDER BY id";
$sql = "SELECT * FROM $course_tool_table
WHERE category = 'admin' AND visibility ='1' AND c_id = $course_id $condition_session
ORDER BY id";
$result = Database::query($sql);
$col_link = "##003399";
break;
case TOOL_ADMIN_PLATFORM:
$sql = "SELECT * FROM $course_tool_table WHERE category = 'admin' AND c_id = $course_id $condition_session ORDER BY id";
$sql = "SELECT * FROM $course_tool_table
WHERE category = 'admin' AND c_id = $course_id $condition_session ORDER BY id";
$result = Database::query($sql);
$col_link = "##003399";
break;
case TOOL_COURSE_PLUGIN:
//Other queries recover id, name, link, image, visibility, admin, address, added_tool, target, category and session_id
// but plugins are not present in the tool table, only globally and inside the course_settings table once configured
$sql = "SELECT * FROM $course_tool_table WHERE category = 'plugin' AND c_id = $course_id $condition_session ORDER BY id";
$sql = "SELECT * FROM $course_tool_table
WHERE category = 'plugin' AND c_id = $course_id $condition_session
ORDER BY id";
$result = Database::query($sql);
break;
}
@ -479,8 +521,12 @@ class CourseHome
if ($temp_row['image'] == 'scormbuilder.gif') {
$lp_id = self::get_published_lp_id_from_link($temp_row['link']);
$lp = new learnpath(api_get_course_id(), $lp_id, api_get_user_id());
$path = $lp->get_preview_image_path(64);
$lp = new learnpath(
api_get_course_id(),
$lp_id,
api_get_user_id()
);
$path = $lp->get_preview_image_path(ICON_SIZE_BIG);
$add = $lp->is_lp_visible_for_student(
$lp_id,
api_get_user_id(),
@ -505,10 +551,12 @@ class CourseHome
case TOOL_AUTHORING:
$sql_links = "SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.c_id = $course_id AND
tip.c_id = $course_id AND
tl.on_homepage='1' $condition_session";
LEFT JOIN $course_item_property_table tip
ON tip.tool='link' AND tip.ref=tl.id
WHERE
tl.c_id = $course_id AND
tip.c_id = $course_id AND
tl.on_homepage='1' $condition_session";
break;
case TOOL_INTERACTION:
$sql_links = null;
@ -523,17 +571,19 @@ class CourseHome
$sql_links = "SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.c_id = $course_id AND
tip.c_id = $course_id AND
tl.on_homepage ='1' $condition_session";
WHERE
tl.c_id = $course_id AND
tip.c_id = $course_id AND
tl.on_homepage ='1' $condition_session";
break;
case TOOL_ADMIN:
$sql_links = "SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
WHERE tl.c_id = $course_id AND
tip.c_id = $course_id AND
tl.on_homepage='1' $condition_session";
WHERE
tl.c_id = $course_id AND
tip.c_id = $course_id AND
tl.on_homepage='1' $condition_session";
break;
default:
$sql_links = null;
@ -570,9 +620,11 @@ class CourseHome
// Get blog members
if ($is_platform_admin) {
$sql_blogs = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user WHERE blog_id =".$blog_id;
$sql_blogs = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user
WHERE blog_id =".$blog_id;
} else {
$sql_blogs = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user WHERE blog_id =".$blog_id." AND user_id = ".api_get_user_id();
$sql_blogs = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user
WHERE blog_id =".$blog_id." AND user_id = ".api_get_user_id();
}
$result_blogs = Database::query($sql_blogs);
@ -584,16 +636,19 @@ class CourseHome
}
}
}
return $all_tools_list;
}
/**
* Displays the tools of a certain category.
* @param array List of tools as returned by get_tools_category()
* @param int rows
* @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) {
public static function show_tools_category($all_tools_list, $rows = false)
{
global $_user;
$theme = api_get_setting('homepage_view');
if ($theme == 'vertical_activity') {
@ -643,7 +698,13 @@ class CourseHome
$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())) {
!learnpath::is_lp_visible_for_student(
$published_lp_id,
api_get_user_id(),
api_get_course_id(),
api_get_session_id()
)
) {
continue;
}
}
@ -697,7 +758,10 @@ class CourseHome
}
// NOTE : Table contains only the image file name, not full path
if (stripos($tool['link'], 'http://') === false && stripos($tool['link'], 'https://') === false && stripos($tool['link'], 'ftp://') === false) {
if (stripos($tool['link'], 'http://') === false &&
stripos($tool['link'], 'https://') === false &&
stripos($tool['link'], 'ftp://') === false
) {
$tool['link'] = $web_code_path.$tool['link'];
}
if ($tool['visibility'] == '0' && $tool['admin'] != '1') {
@ -840,6 +904,7 @@ class CourseHome
$i++;
}
}
return $html;
}
@ -849,7 +914,8 @@ class CourseHome
* @param id session id
* @return string session data
*/
public static function show_session_data($id_session) {
public static function show_session_data($id_session)
{
$session_table = Database::get_main_table(TABLE_MAIN_SESSION);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$session_category_table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
@ -860,17 +926,32 @@ class CourseHome
$id_session = intval($id_session);
}
$sql = 'SELECT name, nbr_courses, nbr_users, nbr_classes, DATE_FORMAT(date_start,"%d-%m-%Y") as date_start, DATE_FORMAT(date_end,"%d-%m-%Y") as date_end, lastname, firstname, username, session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end, session_category_id, visibility
FROM '.$session_table.'
$sql = 'SELECT
name,
nbr_courses,
nbr_users,
nbr_classes,
DATE_FORMAT(date_start,"%d-%m-%Y") as date_start,
DATE_FORMAT(date_end,"%d-%m-%Y") as date_end,
lastname,
firstname,
username,
session_admin_id,
nb_days_access_before_beginning,
nb_days_access_after_end,
session_category_id,
visibility
FROM '.$session_table.'
LEFT JOIN '.$user_table.'
ON id_coach = user_id
ON id_coach = user_id
WHERE '.$session_table.'.id='.$id_session;
$rs = Database::query($sql);
$session = Database::store_result($rs);
$session = $session[0];
$sql_category = 'SELECT name FROM '.$session_category_table.' WHERE id = "'.intval($session['session_category_id']).'"';
$sql_category = 'SELECT name FROM '.$session_category_table.'
WHERE id = "'.intval($session['session_category_id']).'"';
$rs_category = Database::query($sql_category);
$session_category = '';
if (Database::num_rows($rs_category) > 0) {
@ -890,7 +971,8 @@ class CourseHome
$output .= '<tr><td>'.get_lang('SessionCategory').': '.'<b>'.$session_category.'</b></td></tr>';
}
$output .= '<tr><td style="width:50%">'.get_lang('SessionName').': '.'<b>'.$session['name'].'</b></td><td>'.get_lang('GeneralCoach').': '.'<b>'.$session['lastname'].' '.$session['firstname'].' ('.$session['username'].')'.'</b></td></tr>';
$output .= '<tr><td>'.get_lang('SessionIdentifier').': '.Display::return_icon('star.png', ' ', array('align' => 'absmiddle')).'</td><td>'.get_lang('Date').': '.'<b>'.$msg_date.'</b></td></tr>';
$output .= '<tr><td>'.get_lang('SessionIdentifier').': '.
Display::return_icon('star.png', ' ', array('align' => 'absmiddle')).'</td><td>'.get_lang('Date').': '.'<b>'.$msg_date.'</b></td></tr>';
return $output;
}
@ -900,16 +982,17 @@ class CourseHome
* @param array $tool The input record.
* @return string Returns the name of the corresponding tool.
*/
public static function translate_tool_name(& $tool) {
public static function translate_tool_name(& $tool)
{
static $already_translated_icons = array(
'file_html.gif',
'file_html_na.gif',
'scormbuilder.gif',
'scormbuilder_na.gif',
'blog.gif',
'blog_na.gif',
'external.gif',
'external_na.gif'
'file_html.gif',
'file_html_na.gif',
'scormbuilder.gif',
'scormbuilder_na.gif',
'blog.gif',
'blog_na.gif',
'external.gif',
'external_na.gif'
);
if (in_array($tool['image'], $already_translated_icons)) {
@ -939,7 +1022,8 @@ class CourseHome
* @param string Link to published lp
* @return int Learning path id
*/
public static function get_published_lp_id_from_link($published_lp_link) {
public static function get_published_lp_id_from_link($published_lp_link)
{
$lp_id = 0;
$param_lp_id = strstr($published_lp_link, 'lp_id=');
if (!empty($param_lp_id)) {
@ -951,7 +1035,12 @@ class CourseHome
return $lp_id;
}
static function get_navigation_items($include_admin_tools = false) {
/**
* @param bool $include_admin_tools
* @return array
*/
static function get_navigation_items($include_admin_tools = false)
{
$navigation_items = array();
$course_id = api_get_course_int_id();
@ -965,7 +1054,9 @@ class CourseHome
$navigation_items['home']['link'] = api_get_path(REL_COURSE_PATH).Security::remove_XSS($_SESSION['_course']['path']).'/index.php';
$navigation_items['home']['name'] = get_lang('CourseHomepageLink');
$sql_menu_query = "SELECT * FROM $course_tools_table WHERE c_id = $course_id AND visibility='1' and admin='0' ORDER BY id ASC";
$sql_menu_query = "SELECT * FROM $course_tools_table
WHERE c_id = $course_id AND visibility='1' and admin='0'
ORDER BY id ASC";
$sql_result = Database::query($sql_menu_query);
while ($row = Database::fetch_array($sql_result)) {
$navigation_items[$row['id']] = $row;
@ -1012,7 +1103,8 @@ class CourseHome
/**
* Show a navigation menu
*/
static function show_navigation_menu() {
public static function show_navigation_menu()
{
$navigation_items = self::get_navigation_items(true);
$course_id = api_get_course_id();
@ -1031,7 +1123,9 @@ class CourseHome
$url_item = parse_url($navigation_item['link']);
$url_current = parse_url($_SERVER['REQUEST_URI']);
if (strpos($navigation_item['link'], 'chat') !== false && api_get_course_setting('allow_open_chat_window', $course_id)) {
if (strpos($navigation_item['link'], 'chat') !== false &&
api_get_course_setting('allow_open_chat_window', $course_id)
) {
$html .= '<a href="javascript: void(0);" onclick="javascript: window.open(\''.$navigation_item['link'].'\',\'window_chat'.$_SESSION['_cid'].'\',config=\'height=\'+600+\', width=\'+825+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="'.$navigation_item['target'].'"';
} else {
$html .= '<a href="'.$navigation_item['link'].'" target="_top" ';
@ -1061,7 +1155,8 @@ class CourseHome
/**
* Show a toolbar with shortcuts to the course tool
*/
static function show_navigation_tool_shortcuts($orientation = SHORTCUTS_HORIZONTAL) {
public static function show_navigation_tool_shortcuts($orientation = SHORTCUTS_HORIZONTAL)
{
$navigation_items = self::get_navigation_items(false);
$html = '';
if (!empty($navigation_items)) {
@ -1073,7 +1168,9 @@ class CourseHome
$html .= '<div id="'.$style_id.'">';
foreach ($navigation_items as $key => $navigation_item) {
if (strpos($navigation_item['link'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
if (strpos($navigation_item['link'], 'chat') !== false &&
api_get_course_setting('allow_open_chat_window')
) {
$html .= '<a href="javascript: void(0);" onclick="javascript: window.open(\''.$navigation_item['link'].'\',\'window_chat'.$_SESSION['_cid'].'\',config=\'height=\'+600+\', width=\'+825+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="'.$navigation_item['target'].'"';
} else {
$html .= '<a href="'.$navigation_item['link'].'"';
@ -1092,5 +1189,4 @@ class CourseHome
}
return $html;
}
}

@ -17,16 +17,16 @@ class SessionManager
public static $_debug = false;
/**
*
* Constructor
*/
public function __construct()
{
}
/**
* Fetches a session from the database
* @param int Session ID
* @param int $id Session Id
*
* @return array Session details
*/
public static function fetch($id)
@ -40,6 +40,7 @@ class SessionManager
if (Database::num_rows($r) != 1) {
return array();
}
return Database::fetch_array($r, 'ASSOC');
}

@ -4,7 +4,7 @@ namespace System;
/**
* Session Management
*
*
* @see ChamiloSession
*
* @license see /license.txt
@ -36,8 +36,8 @@ class Session implements \ArrayAccess
/**
* Returns true if session has variable set up, false otherwise.
*
* @param string $variable
*
* @param string $variable
*/
static function has($variable)
{
@ -57,7 +57,7 @@ class Session implements \ArrayAccess
$_SESSION = array();
session_destroy();
}
/*
* ArrayAccess
*/
@ -70,7 +70,7 @@ class Session implements \ArrayAccess
/**
* It it exists returns the value stored at the specified offset.
* If offset does not exists returns null. Do not trigger a warning.
*
*
* @param string $offset
* @return any
*/
@ -88,10 +88,10 @@ class Session implements \ArrayAccess
{
unset($_SESSION[$offset]);
}
/**
* Magical methods
*
*
*/
public function __unset($name)
@ -107,10 +107,10 @@ class Session implements \ArrayAccess
/**
* It it exists returns the value stored at the specified offset.
* If offset does not exists returns null. Do not trigger a warning.
*
*
* @param string $name
* @return any
*
*
*/
function __get($name)
{
@ -120,11 +120,11 @@ class Session implements \ArrayAccess
/**
*
* @param string $name
* @param any $value
* @param any $value
*/
function __set($name, $value)
{
self::write($name, $value);
}
}
}

@ -322,7 +322,8 @@ class learnpath
// Get last viewing vars.
$lp_item_view_table = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
// This query should only return one or zero result.
$sql = "SELECT lp_item_id, status FROM $lp_item_view_table
$sql = "SELECT lp_item_id, status
FROM $lp_item_view_table
WHERE
c_id = $course_id AND
lp_view_id = ".$this->lp_view_id." AND
@ -2391,6 +2392,7 @@ class learnpath
}
}
}
return $is_visible;
}

@ -2,6 +2,7 @@
/* For licensing terms, see /license.txt */
/**
* Class learnpathItem
* lp_item defines items belonging to a learnpath. Each item has a name,
* a score, a use time and additional information that enables tracking a user's
* progress in a learning path
@ -148,7 +149,10 @@ class learnpathItem
// Load children list
$sql = "SELECT id FROM $items_table
WHERE c_id = $course_id AND lp_id = ".$this->lp_id." AND parent_item_id = $id";
WHERE
c_id = $course_id AND
lp_id = ".$this->lp_id." AND
parent_item_id = $id";
$res = Database::query($sql);
if (Database::num_rows($res) < 1) {
// Nothing to do (no children)
@ -311,12 +315,12 @@ class learnpathItem
$course_id = api_get_course_int_id();
$sql_del_view = "DELETE FROM $lp_item_view
WHERE c_id = $course_id AND lp_item_id = " . $this->db_id;
$sql = "DELETE FROM $lp_item_view
WHERE c_id = $course_id AND lp_item_id = " . $this->db_id;
if (self::debug > 0) {
error_log('Deleting from lp_item_view: ' . $sql_del_view, 0);
error_log('Deleting from lp_item_view: ' . $sql, 0);
}
Database::query($sql_del_view);
Database::query($sql);
$sql = "SELECT * FROM $lp_item
WHERE c_id = $course_id AND id = " . $this->db_id;
@ -329,7 +333,7 @@ class learnpathItem
WHERE c_id = $course_id AND id = " . $this->db_id;
Database::query($sql);
if (self::debug > 0) {
error_log('Deleting from lp_item: ' . $sql_del_view);
error_log('Deleting from lp_item: ' . $sql);
}
if (api_get_setting('search_enabled') == 'true') {
@ -344,7 +348,7 @@ class learnpathItem
/**
* Drops a child from the children array
* @param string index of child item to drop
* @param string $item index of child item to drop
* @return void
*/
public function drop_child($item)
@ -520,9 +524,10 @@ class learnpathItem
case TOOL_DOCUMENT:
$table_doc = Database::get_course_table(TABLE_DOCUMENT);
$sql = 'SELECT path
FROM ' . $table_doc . '
WHERE c_id = ' . $course_id . '
AND id = ' . $path;
FROM ' . $table_doc . '
WHERE
c_id = ' . $course_id . ' AND
id = ' . $path;
$res = Database::query($sql);
$row = Database::fetch_array($res);
$real_path = 'document' . $row['path'];
@ -545,7 +550,7 @@ class learnpathItem
/**
* Gets the DB ID
* @return integer Database ID for the current item
* @return integer Database ID for the current item
*/
public function get_id()
{
@ -570,10 +575,12 @@ class learnpathItem
$this->interactions = array();
$course_id = api_get_course_int_id();
$tbl = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$sql = "SELECT id FROM $tbl " .
"WHERE c_id = $course_id AND lp_item_id = " . $this->db_id . " " .
"AND lp_view_id = " . $this->view_id . " " .
"AND view_count = " . $this->attempt_id;
$sql = "SELECT id FROM $tbl
WHERE
c_id = $course_id AND
lp_item_id = " . $this->db_id . " AND
lp_view_id = " . $this->view_id . " AND
view_count = " . $this->attempt_id;
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$row = Database::fetch_array($res);
@ -950,7 +957,7 @@ class learnpathItem
$sql = "SELECT seriousgame_mode
FROM $table
WHERE c_id = $course_id AND id = " . $this->lp_id;
$res = @Database::query($sql);
$res = Database::query($sql);
if (Database::num_rows($res) < 1) {
$this->error = "Could not find parent learnpath in learnpath table";
if (self::debug > 2) {
@ -1014,8 +1021,7 @@ class learnpathItem
}
if (!isset($abs_path)) {
$path = $this->get_file_path();
$abs_path = api_get_path(SYS_COURSE_PATH) . api_get_course_path(
) . '/' . $path;
$abs_path = api_get_path(SYS_COURSE_PATH) . api_get_course_path() . '/' . $path;
//echo "Abs path coming from item : ".$abs_path."<br />\n";
}
/*
@ -1032,12 +1038,10 @@ class learnpathItem
case TOOL_QUIZ:
case 'sco':
// Get the document and, if HTML, open it.
if (is_file($abs_path)) {
// for now, read the whole file in one go (that's gonna be
// a problem when the file is too big).
$info = pathinfo($abs_path);
$ext = $info['extension'];
switch (strtolower($ext)) {
@ -1641,8 +1645,7 @@ class learnpathItem
default: // Ignore.
break;
}
//error_log(str_repeat(' ', $recursivity), 'found files '.print_r($files_list, true), 0);
//return $files_list;
$checked_files_list = array();
$checked_array_list = array();
foreach ($files_list as $idx => $file) {
@ -1680,9 +1683,9 @@ class learnpathItem
/**
* Gets the item status
* @param boolean $check_db Do or don't check into the database for the latest value. Optional. Default is true
* @param boolean $update_local Do or don't update the local attribute value with what's been found in DB
* @return string Current status or 'Not attempted' if no status set yet
* @param boolean $check_db Do or don't check into the database for the latest value. Optional. Default is true
* @param boolean $update_local Do or don't update the local attribute value with what's been found in DB
* @return string Current status or 'Not attempted' if no status set yet
*/
public function get_status($check_db = true, $update_local = false)
{
@ -1812,8 +1815,9 @@ class learnpathItem
}
if ($query_db === true) {
$table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$sql = "SELECT start_time, total_time FROM $table
WHERE
$sql = "SELECT start_time, total_time
FROM $table
WHERE
c_id = $course_id AND
id = '" . $this->db_item_view_id . "' AND
view_count = '" . $this->get_attempt_id() . "'";
@ -1879,8 +1883,10 @@ class learnpathItem
{
$lp_item = Database::get_course_table(TABLE_LP_ITEM);
$course_id = api_get_course_int_id();
$sql = "SELECT * FROM $lp_item WHERE c_id = $course_id
AND id='" . Database::escape_string($this->db_id) . "'";
$sql = "SELECT * FROM $lp_item
WHERE
c_id = $course_id AND
id='" . Database::escape_string($this->db_id) . "'";
$res = Database::query($sql);
$row = Database::fetch_array($res);
return $row['terms'];
@ -2029,7 +2035,7 @@ class learnpathItem
/**
* Tells if a restart is allowed (take it from $this->prevent_reinit and $this->status)
* @return integer -1 if retaking the sco another time for credit is not allowed,
* @return integer -1 if retaking the sco another time for credit is not allowed,
* 0 if it is not allowed but the item has to be finished
* 1 if it is allowed. Defaults to 1
*/
@ -2104,7 +2110,7 @@ class learnpathItem
* Outputs the item contents
* @return string HTML file (displayable in an <iframe>) or empty string if no path defined
*/
function output()
public function output()
{
if (self::debug > 0) {
error_log('learnpathItem::output()', 0);
@ -3848,10 +3854,12 @@ class learnpathItem
}
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$check = "SELECT * FROM $item_view_table " .
"WHERE c_id = $course_id AND lp_item_id = " . $this->db_id . " " .
"AND lp_view_id = " . $this->view_id . " " .
"AND view_count = " . $this->get_attempt_id();
$check = "SELECT * FROM $item_view_table
WHERE
c_id = $course_id AND
lp_item_id = " . $this->db_id . " AND
lp_view_id = " . $this->view_id . " AND
view_count = " . $this->get_attempt_id();
if (self::debug > 2) {
error_log(
'learnpathItem::write_to_db() - Querying item_view: ' . $check,
@ -3897,36 +3905,31 @@ class learnpathItem
} else {
$sql = '';
if ($this->type == 'hotpotatoes') {
$sql = "UPDATE $item_view_table " .
"SET total_time = " . $this->get_total_time() . ", " .
" start_time = " . $this->get_current_start_time(
) . ", " .
" score = " . $this->get_score() . ", " .
" status = '" . $this->get_status(false) . "'," .
" max_score = '" . $this->get_max() . "'," .
" suspend_data = '" . Database::escape_string(
$this->current_data
) . "'," .
" lesson_location = '" . $this->lesson_location . "' " .
"WHERE c_id = $course_id AND lp_item_id = " . $this->db_id . " " .
"AND lp_view_id = " . $this->view_id . " " .
"AND view_count = " . $this->get_attempt_id();
$sql = "UPDATE $item_view_table SET
total_time = " . $this->get_total_time() . ",
start_time = " . $this->get_current_start_time() . ",
score = " . $this->get_score() . ",
status = '" . $this->get_status(false) . "',
max_score = '" . $this->get_max() . "',
suspend_data = '" . Database::escape_string($this->current_data) . "',
lesson_location = '" . $this->lesson_location . "'
WHERE
c_id = $course_id AND
lp_item_id = " . $this->db_id . " AND
lp_view_id = " . $this->view_id . " AND
view_count = " . $this->get_attempt_id();
} else {
// For all other content types...
if ($this->type == 'quiz') {
$my_status = ' ';
$total_time = ' ';
if (!empty($_REQUEST['exeId'])) {
$TBL_TRACK_EXERCICES = Database::get_statistic_table(
TABLE_STATISTIC_TRACK_E_EXERCICES
);
$TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$safe_exe_id = Database::escape_string(
$_REQUEST['exeId']
);
$sql = 'SELECT start_date,exe_date
FROM ' . $TBL_TRACK_EXERCICES . '
WHERE exe_id = ' . (int)$safe_exe_id;
$safe_exe_id = intval($_REQUEST['exeId']);
$sql = "SELECT start_date,exe_date
FROM $TBL_TRACK_EXERCICES
WHERE exe_id = $safe_exe_id";
$res = Database::query($sql);
$row_dates = Database::fetch_array($res);
@ -3960,7 +3963,8 @@ class learnpathItem
c_id = ' . $course_id . ' AND
lp_item_id="' . $this->db_id . '" AND
lp_view_id="' . $this->view_id . '" AND
view_count="' . $this->get_attempt_id() . '" ;';
view_count="' . $this->get_attempt_id() . '"
';
$rs_verified = Database::query($sql);
$row_verified = Database::fetch_array($rs_verified);
@ -4038,32 +4042,35 @@ class learnpathItem
if ($this->type == 'sco') {
//IF scorm scorm_update_time has already updated total_time in db
$sql = "UPDATE $item_view_table " .
" SET " . //start_time = ".$this->get_current_start_time().", " .
//scorm_init_time does it
" score = " . $this->get_score() . ", " .
$my_status .
" max_score = '" . $this->get_max() . "'," .
" suspend_data = '" . Database::escape_string($this->current_data) . "'," .
//" max_time_allowed = '".$this->get_max_time_allowed()."'," .
" lesson_location = '" . $this->lesson_location . "' " .
"WHERE c_id = $course_id AND lp_item_id = " . $this->db_id . " " .
"AND lp_view_id = " . $this->view_id . " " .
"AND view_count = " . $this->get_attempt_id();
//" . //start_time = ".$this->get_current_start_time().", " . //scorm_init_time does it
////" max_time_allowed = '".$this->get_max_time_allowed()."'," .
$sql = "UPDATE $item_view_table SET
score = " . $this->get_score() . ",
$my_status
max_score = '" . $this->get_max() . "',
suspend_data = '" . Database::escape_string($this->current_data) . "',
lesson_location = '" . $this->lesson_location . "'
WHERE
c_id = $course_id AND
lp_item_id = " . $this->db_id . "AND
lp_view_id = " . $this->view_id . " AND
view_count = " . $this->get_attempt_id();
} else {
$sql = "UPDATE $item_view_table " .
"SET " . $total_time .
" start_time = " . $this->get_current_start_time() . ", " .
" score = " . $this->get_score() . ", " .
$my_status .
" max_score = '" . $this->get_max() . "'," .
" suspend_data = '" . Database::escape_string($this->current_data) . "'," .
//" max_time_allowed = '".$this->get_max_time_allowed()."'," .
" lesson_location = '" . $this->lesson_location . "' " .
"WHERE c_id = $course_id AND lp_item_id = " . $this->db_id . " " .
"AND lp_view_id = " . $this->view_id . " " .
"AND view_count = " . $this->get_attempt_id();
//" max_time_allowed = '".$this->get_max_time_allowed()."'," .
$sql = "UPDATE $item_view_table SET
$total_time
start_time = " . $this->get_current_start_time() . ",
score = " . $this->get_score() . ",
$my_status
max_score = '" . $this->get_max() . "',
suspend_data = '" . Database::escape_string($this->current_data) . "',
lesson_location = '" . $this->lesson_location . "'
WHERE
c_id = $course_id AND
lp_item_id = " . $this->db_id . " AND
lp_view_id = " . $this->view_id . " AND
view_count = " . $this->get_attempt_id();
}
$this->current_start_time = time();
}
@ -4079,10 +4086,12 @@ class learnpathItem
if (is_array($this->interactions) && count($this->interactions) > 0) {
// Save interactions.
$tbl = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$sql = "SELECT id FROM $tbl " .
"WHERE c_id = $course_id AND lp_item_id = " . $this->db_id . " " .
"AND lp_view_id = " . $this->view_id . " " .
"AND view_count = " . $this->get_attempt_id();
$sql = "SELECT id FROM $tbl
WHERE
c_id = $course_id AND
lp_item_id = " . $this->db_id . " AND
lp_view_id = " . $this->view_id . " AND
view_count = " . $this->get_attempt_id();
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$row = Database::fetch_array($res);

@ -98,6 +98,7 @@ function save_item(
if ($debug > 0) {
error_log("item #$item_id not found in the items array: ".print_r($myLP->items, 1));
}
return false;
}
@ -110,6 +111,7 @@ function save_item(
if ($debug) {
error_log("prereq_check: ".intval($prerequisitesCheck));
}
return $return;
} else {
if ($debug > 1) {

@ -156,8 +156,6 @@ if (!isset($src)) {
$_SESSION['oLP']->stop_previous_item();
$htmlHeadXtra[] = '<script src="scorm_api.php" type="text/javascript" language="javascript"></script>';
$prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id);
if ($prereq_check === true) {
$src = $_SESSION['oLP']->get_link('http', $lp_item_id, $get_toc_list);

Loading…
Cancel
Save