Fixing sql query

skala
Julio Montoya 14 years ago
parent 0225e010fa
commit b23652ddf1
  1. 7
      main/inc/lib/banner.lib.php
  2. 41
      main/inc/lib/tracking.lib.php
  3. 27
      main/tracking/courseLog.php

@ -477,6 +477,7 @@ function show_header_4($interbreadcrumb, $language_file, $nameTools) {
// hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb
$my_session_name = is_null($session_name) ? '' : ' ('.$session_name.')';
if (!empty($_course) && !isset($_GET['hide_course_breadcrumb'])) {
$navigation_item['url'] = $web_course_path . $_course['path'].'/index.php'.(!empty($session_id) ? '?id_session='.$session_id : '');
switch (api_get_setting('breadcrumbs_course_homepage')) {
case 'get_lang':
@ -496,6 +497,12 @@ function show_header_4($interbreadcrumb, $language_file, $nameTools) {
}
break;
}
/*
* @todo could be useful adding the My courses in the breadcrumb
$navigation_item_my_courses['title'] = get_lang('MyCourses');
$navigation_item_my_courses['url'] = api_get_path(WEB_PATH).'user_portal.php';
$navigation[] = $navigation_item_my_courses;
*/
$navigation[] = $navigation_item;
}
// part 2: Interbreadcrumbs. If there is an array $interbreadcrumb defined then these have to appear before the last breadcrumb (which is the tool itself)

@ -2840,7 +2840,7 @@ class TrackingCourseLog {
$sql .= " ORDER BY col5 DESC ";
}
$sql .= " LIMIT $from, $number_of_items ";
$sql .= " LIMIT $from, $number_of_items ";
$res = Database::query($sql);
$resources = array ();
@ -2851,31 +2851,35 @@ class TrackingCourseLog {
$table_tool = Database :: get_course_table($table_name['table_name']);
$id = $table_name['id_tool'];
if ($row['col0'] == 'thematic_plan' || $row['col0'] == 'thematic_advance') {
$recorset = false;
if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
$rs_thematic = Database::query("SELECT thematic_id FROM $table_tool WHERE id=$ref");
$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.session_id = session.id AND session.id_coach = user.user_id AND t.id = $thematic_id";
$sql = "SELECT thematic_id FROM $table_tool WHERE id = $ref";
$rs_thematic = Database::query($sql);
if (Database::num_rows($rs_thematic)) {
$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.session_id = session.id AND session.id_coach = user.user_id AND t.id = $thematic_id";
$recorset = Database::query($query);
}
} else {
$query = "SELECT session.id, session.name, user.username FROM $table_tool tool, $table_session session, $table_user user" .
" WHERE tool.session_id = session.id AND session.id_coach = user.user_id AND tool.$id = $ref";
$recorset = Database::query($query);
}
$recorset = Database::query($query);
if (!empty($recorset)) {
$obj = Database::fetch_object($recorset);
$obj = Database::fetch_object($recorset);
$name_session = '';
$coach_name = '';
if (!empty($obj)) {
$name_session = $obj->name;
$coach_name = $obj->username;
$coach_name = $obj->username;
}
$url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
@ -2895,22 +2899,22 @@ class TrackingCourseLog {
$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
} else {
$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&'.$obj->id.'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
}
} else {
$row[0] = api_ucfirst($row['col0']);
}
$row[1] = get_lang($row[1]);
$row[5] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
$row[4] = '';
//@todo Improve this code please
switch ($table_name['table_name']) {
case 'document' :
$query_document = "SELECT tool.title as title FROM $table_tool tool" .
" WHERE id = $ref";
$query_document = "SELECT tool.title as title FROM $table_tool tool WHERE id = $ref";
$rs_document = Database::query($query_document);
$obj_document = Database::fetch_object($rs_document);
$row[4] = $obj_document->title;
break;
case 'announcement':
$query_document = "SELECT title FROM $table_tool " .
@ -2980,7 +2984,6 @@ class TrackingCourseLog {
$row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
}
$row[2] = $row2;
$resources[] = $row;
}
}

@ -19,9 +19,11 @@ $language_file[] = 'scorm';
require_once '../inc/global.inc.php';
$from_myspace = false;
if (isset($_GET['from']) && $_GET['from'] == 'myspace') {
$from = isset($_GET['from']) ? $_GET['from'] : null;
if ($from == 'myspace') {
$from_myspace = true;
$this_section = "session_my_space";
$this_section = "session_my_space";
} else {
$this_section = SECTION_COURSES;
}
@ -186,7 +188,7 @@ if ($_GET['studentlist'] == '' || $_GET['studentlist'] == 'true') {
$renderer =& $form_search->defaultRenderer();
$renderer->setElementTemplate('<span>{element}</span>');
$form_search->addElement('hidden', 'studentlist', 'true');
$form_search->addElement('hidden', 'from', Security::remove_XSS($_GET['from']));
$form_search->addElement('hidden', 'from', Security::remove_XSS($from));
$form_search->addElement('hidden', 'session_id', api_get_session_id());
$form_search->addElement('text', 'user_keyword');
$form_search->addElement('style_submit_button', 'submit', get_lang('SearchUsers'), 'class="search"');
@ -194,12 +196,6 @@ if ($_GET['studentlist'] == '' || $_GET['studentlist'] == 'true') {
echo '</div>';
}
/*if (empty($session_id))
echo ' | <a href="exams.php?'.api_get_cidreq().'">'.get_lang('ExamTracking').'</a>&nbsp;';
*/
if ($_GET['studentlist'] == 'false') {
$course_code = api_get_course_id();
@ -210,7 +206,8 @@ if ($_GET['studentlist'] == 'false') {
<h2>'.Display::return_icon('scorms.gif',get_lang('AverageProgressInLearnpath')).get_lang('AverageProgressInLearnpath').'</h2>
<table class="data_table">';
$list = new LearnpathList($student, $course_code, $session_id);
$list = new LearnpathList('', $course_code, $session_id);
$flat_list = $list->get_flat_list();
if ($export_csv) {
@ -253,10 +250,11 @@ if ($_GET['studentlist'] == 'false') {
}
echo '</table></div>';
echo '<div class="clear"></div>';
//hiding detail for exercises
//&nbsp;-&nbsp;<a href="../exercice/exercice.php?'.api_get_cidreq().'&show=result">'.get_lang('SeeDetail').'</a>
// Exercices tracking.
echo '<div class="report_section">
<h2>'.Display::return_icon('quiz.gif',get_lang('AverageResultsToTheExercices')).get_lang('AverageResultsToTheExercices').'&nbsp;-&nbsp;<a href="../exercice/exercice.php?'.api_get_cidreq().'&show=result">'.get_lang('SeeDetail').'</a></h2>
<h2>'.Display::return_icon('quiz.gif',get_lang('AverageResultsToTheExercices')).get_lang('AverageResultsToTheExercices').'</h2>
<table class="data_table">';
$sql = "SELECT id, title
@ -338,6 +336,7 @@ if ($_GET['studentlist'] == 'false') {
<table class="data_table">';
$tools_most_used = Tracking::get_tools_most_used_by_course($course_code, $session_id);
if ($export_csv) {
$temp = array(get_lang('ToolsMostUsed'), '');
@ -361,7 +360,7 @@ if ($_GET['studentlist'] == 'false') {
echo '<div class="clear"></div>';
// Documents tracking.
if ($_GET['num'] == 0 or empty($_GET['num'])) {
if (!isset($_GET['num']) || empty($_GET['num'])) {
$num = 3;
$link = '&nbsp;-&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&studentlist=false&num=1#documents_tracking">'.get_lang('SeeDetail').'</a>';
} else {
@ -515,7 +514,7 @@ if ($_GET['studentlist'] == 'false') {
$parameters['cidReq'] = Security::remove_XSS($_GET['cidReq']);
$parameters['id_session'] = $session_id;
$parameters['studentlist'] = Security::remove_XSS($_GET['studentlist']);
$parameters['from'] = Security::remove_XSS($_GET['myspace']);
$parameters['from'] = isset($_GET['myspace']) ? Security::remove_XSS($_GET['myspace']) : null;
$table->set_additional_parameters($parameters);

Loading…
Cancel
Save