Should fix empty list bug see #6823.

1.9.x
Julio Montoya 11 years ago
parent b94efec340
commit 4a4c4286c9
  1. 152
      main/inc/lib/tracking.lib.php
  2. 43
      main/tracking/course_log_resources.php

@ -3502,10 +3502,12 @@ class Tracking
*/
class TrackingCourseLog
{
/**
* @return mixed
*/
public static function count_item_resources()
{
global $session_id;
$session_id = api_get_session_id();
$course_id = api_get_course_int_id();
$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
@ -3514,19 +3516,33 @@ class TrackingCourseLog
$sql = "SELECT count(tool) AS total_number_of_items
FROM $table_item_property track_resource, $table_user user
WHERE
track_resource.c_id = $course_id AND
track_resource.insert_user_id = user.user_id AND
id_session = $session_id ";
track_resource.c_id = $course_id AND
track_resource.insert_user_id = user.user_id AND
id_session = $session_id ";
if (isset($_GET['keyword'])) {
$keyword = Database::escape_string(trim($_GET['keyword']));
$sql .= " AND (user.username LIKE '%".$keyword."%' OR lastedit_type LIKE '%".$keyword."%' OR tool LIKE '%".$keyword."%')";
$sql .= " AND (
user.username LIKE '%".$keyword."%' OR
lastedit_type LIKE '%".$keyword."%' OR
tool LIKE '%".$keyword."%'
)";
}
$sql .= " AND tool IN ('document', 'learnpath', 'quiz', 'glossary', 'link', 'course_description', 'announcement', 'thematic', 'thematic_advance', 'thematic_plan')";
$sql .= " AND tool IN (
'document',
'learnpath',
'quiz',
'glossary',
'link',
'course_description',
'announcement',
'thematic',
'thematic_advance',
'thematic_plan'
)";
$res = Database::query($sql);
$obj = Database::fetch_object($res);
return $obj->total_number_of_items;
}
@ -3539,7 +3555,7 @@ class TrackingCourseLog
*/
public static function get_item_resources_data($from, $number_of_items, $column, $direction)
{
global $dateTimeFormatLong, $session_id;
$session_id = api_get_session_id();
$course_id = api_get_course_int_id();
$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
@ -3563,10 +3579,25 @@ class TrackingCourseLog
if (isset($_GET['keyword'])) {
$keyword = Database::escape_string(trim($_GET['keyword']));
$sql .= " AND (user.username LIKE '%".$keyword."%' OR lastedit_type LIKE '%".$keyword."%' OR tool LIKE '%".$keyword."%') ";
$sql .= " AND (
user.username LIKE '%".$keyword."%' OR
lastedit_type LIKE '%".$keyword."%' OR
tool LIKE '%".$keyword."%'
) ";
}
$sql .= " AND tool IN ('document', 'learnpath', 'quiz', 'glossary', 'link', 'course_description', 'announcement', 'thematic', 'thematic_advance', 'thematic_plan')";
$sql .= " AND tool IN (
'document',
'learnpath',
'quiz',
'glossary',
'link',
'course_description',
'announcement',
'thematic',
'thematic_advance',
'thematic_plan'
)";
if ($column == 0) {
$column = '0';
@ -3579,10 +3610,13 @@ class TrackingCourseLog
$sql .= " ORDER BY col5 DESC ";
}
$from = intval($from);
$number_of_items = intval($number_of_items);
$sql .= " LIMIT $from, $number_of_items ";
$res = Database::query($sql);
$resources = array ();
$resources = array();
$thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
while ($row = Database::fetch_array($res)) {
$ref = $row['ref'];
@ -3600,14 +3634,24 @@ class TrackingCourseLog
$row_thematic = Database::fetch_array($rs_thematic);
$thematic_id = $row_thematic['thematic_id'];
$query = "SELECT session.id, session.name, user.username FROM $tbl_thematic t, $table_session session, $table_user user" .
" WHERE t.c_id = $course_id AND t.session_id = session.id AND session.id_coach = user.user_id AND t.id = $thematic_id";
$recorset = Database::query($query);
$sql = "SELECT session.id, session.name, user.username
FROM $tbl_thematic t, $table_session session, $table_user user
WHERE
t.c_id = $course_id AND
t.session_id = session.id AND
session.id_coach = user.user_id AND
t.id = $thematic_id";
$recorset = Database::query($sql);
}
} else {
$query = "SELECT session.id, session.name, user.username FROM $table_tool tool, $table_session session, $table_user user
WHERE tool.c_id = $course_id AND tool.session_id = session.id AND session.id_coach = user.user_id AND tool.$id = $ref";
$recorset = Database::query($query);
$sql = "SELECT session.id, session.name, user.username
FROM $table_tool tool, $table_session session, $table_user user
WHERE
tool.c_id = $course_id AND
tool.session_id = session.id AND
session.id_coach = user.user_id AND
tool.$id = $ref";
$recorset = Database::query($sql);
}
if (!empty($recorset)) {
@ -3648,44 +3692,48 @@ class TrackingCourseLog
//@todo Improve this code please
switch ($table_name['table_name']) {
case 'document' :
$query_document = "SELECT tool.title as title FROM $table_tool tool WHERE c_id = $course_id AND id = $ref";
$rs_document = Database::query($query_document);
$sql = "SELECT tool.title as title FROM $table_tool tool
WHERE c_id = $course_id AND id = $ref";
$rs_document = Database::query($sql);
$obj_document = Database::fetch_object($rs_document);
$row[5] = $obj_document->title;
break;
case 'announcement':
$query_document = "SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref";
$rs_document = Database::query($query_document);
$sql = "SELECT title FROM $table_tool
WHERE c_id = $course_id AND id = $ref";
$rs_document = Database::query($sql);
$obj_document = Database::fetch_object($rs_document);
$row[5] = $obj_document->title;
break;
case 'glossary':
$query_document = "SELECT name FROM $table_tool WHERE c_id = $course_id AND glossary_id = $ref";
$rs_document = Database::query($query_document);
$sql = "SELECT name FROM $table_tool
WHERE c_id = $course_id AND glossary_id = $ref";
$rs_document = Database::query($sql);
$obj_document = Database::fetch_object($rs_document);
$row[5] = $obj_document->name;
break;
case 'lp':
$query_document = "SELECT name FROM $table_tool WHERE c_id = $course_id AND id = $ref";
$rs_document = Database::query($query_document);
$sql = "SELECT name
FROM $table_tool WHERE c_id = $course_id AND id = $ref";
$rs_document = Database::query($sql);
$obj_document = Database::fetch_object($rs_document);
$row[5] = $obj_document->name;
break;
case 'quiz':
$query_document = "SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref";
$rs_document = Database::query($query_document);
$sql = "SELECT title FROM $table_tool
WHERE c_id = $course_id AND id = $ref";
$rs_document = Database::query($sql);
$obj_document = Database::fetch_object($rs_document);
$row[5] = $obj_document->title;
break;
case 'course_description':
$query_document = "SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref";
$rs_document = Database::query($query_document);
$sql = "SELECT title FROM $table_tool
WHERE c_id = $course_id AND id = $ref";
$rs_document = Database::query($sql);
$obj_document = Database::fetch_object($rs_document);
$row[5] = $obj_document->title;
break;
case 'thematic':
$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
if (Database::num_rows($rs) > 0) {
@ -3707,7 +3755,6 @@ class TrackingCourseLog
$row[5] = $obj->title;
}
break;
default:
break;
}
@ -3717,16 +3764,19 @@ class TrackingCourseLog
$row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
}
$row[2] = $row2;
if (!empty($row['col3'])) {
$row['col3'] = Display::url($row['col3'],api_get_path(WEB_CODE_PATH).'user/userInfo.php?'.api_get_cidreq().'&origin=tracking&uInfo='.$row['user_id']);
$row[3] = $row['col3'];
if (!empty($row['col3'])) {
$row['col3'] = Display::url(
$row['col3'],
api_get_path(WEB_CODE_PATH).'user/userInfo.php?'.api_get_cidreq().'&origin=tracking&uInfo='.$row['user_id']
);
$row[3] = $row['col3'];
$ip = TrackingUserLog::get_ip_from_user_event($row['user_id'], $row['col5'], true);
if (empty($ip)) {
$ip = get_lang('Unknown');
}
$row[4] = $ip;
}
$ip = TrackingUserLog::get_ip_from_user_event($row['user_id'], $row['col5'], true);
if (empty($ip)) {
$ip = get_lang('Unknown');
}
$row[4] = $ip;
}
$resources[] = $row;
}
@ -3735,6 +3785,11 @@ class TrackingCourseLog
return $resources;
}
/**
* @param string $tool
*
* @return array
*/
public static function get_tool_name_table($tool)
{
switch ($tool) {
@ -3792,7 +3847,12 @@ class TrackingCourseLog
$table_name = $tool;
break;
}
return array('table_name' => $table_name,'link_tool' => $link_tool,'id_tool' => $id_tool);
return array(
'table_name' => $table_name,
'link_tool' => $link_tool,
'id_tool' => $id_tool
);
}
public static function display_additional_profile_fields()
@ -3800,7 +3860,6 @@ class TrackingCourseLog
// getting all the extra profile fields that are defined by the platform administrator
$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
// creating the form
$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
@ -4230,9 +4289,8 @@ class TrackingUserLog
*/
public function display_exercise_tracking_info($view, $user_id, $course_id)
{
global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
if(substr($view,1,1) == '1')
{
global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
if(substr($view,1,1) == '1') {
$new_view = substr_replace($view,'0',1,1);
echo "<tr>
<td valign='top'>

@ -15,13 +15,7 @@ $language_file = array('admin', 'tracking', 'scorm', 'exercice');
// Including the global initialization file
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_TRACKING;
$course_info = api_get_course_info(api_get_course_id());
if (!empty($course_info)) {
//api_protect_course_script();
}
$from_myspace = false;
$from = isset($_GET['from']) ? $_GET['from'] : null;
@ -60,6 +54,7 @@ $session_id = intval($_REQUEST['id_session']);
if ($export_csv) {
ob_start();
}
if (empty($session_id)) {
$session_id = api_get_session_id();
}
@ -79,9 +74,17 @@ Display::display_header($nameTools, 'Tracking');
/* MAIN CODE */
echo '<div class="actions">';
echo Display::url(Display::return_icon('user.png', get_lang('StudentsTracking'), array(), 32), api_get_path(WEB_CODE_PATH).'tracking/courseLog.php?'.api_get_cidreq());
echo Display::url(Display::return_icon('course.png', get_lang('CourseTracking'), array(), 32), api_get_path(WEB_CODE_PATH).'tracking/course_log_tools.php?'.api_get_cidreq());
echo Display::return_icon('tools_na.png', get_lang('ResourcesTracking'), array(), 32);
echo Display::url(
Display::return_icon('user.png', get_lang('StudentsTracking'), array(), ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'tracking/courseLog.php?'.api_get_cidreq()
);
echo Display::url(
Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'tracking/course_log_tools.php?'.api_get_cidreq()
);
echo Display::return_icon('tools_na.png', get_lang('ResourcesTracking'), array(), ICON_SIZE_MEDIUM);
echo '<span style="float:right; padding-top:0px;">';
echo '<a href="javascript: void(0);" onclick="javascript: window.print();">'.
Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).
@ -91,10 +94,12 @@ $addional_param = '';
if (isset($_GET['additional_profile_field'])) {
$addional_param ='additional_profile_field='.intval($_GET['additional_profile_field']);
}
$users_tracking_per_page = '';
if (isset($_GET['users_tracking_per_page'])) {
$users_tracking_per_page= '&users_tracking_per_page='.intval($_GET['users_tracking_per_page']);
}
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&export=csv&'.$addional_param.$users_tracking_per_page.'">
'.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a>';
@ -102,10 +107,19 @@ echo '</span>';
echo '</div>';
// Create a search-box.
$form = new FormValidator('search_simple', 'GET', api_get_path(WEB_CODE_PATH).'tracking/course_log_resources.php?'.api_get_cidreq(), '', array('class' => 'form-search'), false);
$form = new FormValidator(
'search_simple',
'GET',
api_get_path(WEB_CODE_PATH).'tracking/course_log_resources.php?'.api_get_cidreq().'&id_session'.$session_id,
'',
array('class' => 'form-search'),
false
);
$renderer = $form->defaultRenderer();
$renderer->setElementTemplate('<span>{element}</span>');
$form->addElement('text', 'keyword', get_lang('keyword'));
$form->addElement('hidden', 'cidReq', api_get_course_id());
$form->addElement('hidden', 'id_session', $session_id);
$form->addElement('style_submit_button', 'submit', get_lang('SearchUsers'), 'class="search"');
echo '<div class="actions">';
$form->display();
@ -119,11 +133,12 @@ $table = new SortableTable(
20,
'DESC'
);
$parameters = array();
if (isset($_GET['keyword'])) {
$parameters['keyword'] = Security::remove_XSS($_GET['keyword']);
}
$parameters = array(
'keyword' => Security::remove_XSS($_GET['keyword']),
'id_session' => $session_id,
'cidReq' => api_get_course_id()
);
$table->set_additional_parameters($parameters);
$table->set_header(0, get_lang('Tool'));

Loading…
Cancel
Save