diff --git a/main/course_info/download.php b/main/course_info/download.php index f173f692b9..a2958e36ca 100644 --- a/main/course_info/download.php +++ b/main/course_info/download.php @@ -24,29 +24,29 @@ session_cache_limiter('public'); -include('../inc/global.inc.php'); -$this_section=SECTION_COURSES; +require '../inc/global.inc.php'; +$this_section = SECTION_COURSES; -include_once(api_get_path(LIBRARY_PATH).'fileManage.lib.php'); +require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; -$archivePath = api_get_path(SYS_PATH).$archiveDirName.'/'; -$archiveFile = $_GET['archive']; +$archive_path = api_get_path(SYS_ARCHIVE_PATH); +$archive_file = $_GET['archive']; -$archiveFile = str_replace(array('..', '/', '\\'), '', $archiveFile); +$archive_file = str_replace(array('..', '/', '\\'), '', $archive_file); -list($extension) = getextension($archiveFile); +list($extension) = getextension($archive_file); -if (empty($extension) || !file_exists($archivePath.$archiveFile)) { +if (empty($extension) || !file_exists($archive_path.$archive_file)) { exit(); } $content_type = ''; if (in_array(strtolower($extension), array('xml','csv')) && api_is_platform_admin(true)) { - $content_type='application/force-download'; + $content_type = 'application/force-download'; } elseif (strtolower($extension) == 'zip' && $_cid && $is_courseAdmin) { - $content_type='application/force-download'; + $content_type = 'application/force-download'; } if (empty($content_type)) { @@ -59,8 +59,7 @@ header('Cache-Control: public'); header('Pragma: no-cache'); header('Content-Type: '.$content_type); -header('Content-Length: '.filesize($archivePath.$archiveFile)); -header('Content-Disposition: attachment; filename='.$archiveFile); +header('Content-Length: '.filesize($archive_path.$archive_file)); +header('Content-Disposition: attachment; filename='.$archive_file); -readfile($archivePath.$archiveFile); -?> \ No newline at end of file +readfile($archive_path.$archive_file); diff --git a/main/mySpace/access_details.php b/main/mySpace/access_details.php index 7bf3742cf6..c072fecff0 100644 --- a/main/mySpace/access_details.php +++ b/main/mySpace/access_details.php @@ -5,7 +5,7 @@ Dokeos - elearning and course management software Copyright (c) 2009 Dokeos SPRL - Copyright (c) 2008 Furio Petrossi + Copyright (c) 2008 Furio Petrossi For a full list of contributors, see "credits.txt". The full license can be read in "license.txt". @@ -38,12 +38,12 @@ $language_file = array ('registration', 'index', 'tracking'); // including the global Dokeos file -require_once '../inc/global.inc.php'; +require '../inc/global.inc.php'; // including additional libraries -include_once api_get_path(LIBRARY_PATH).'pchart/pData.class.php'; -include_once api_get_path(LIBRARY_PATH).'pchart/pChart.class.php'; -include_once api_get_path(LIBRARY_PATH).'pchart/pCache.class.php'; +require_once api_get_path(LIBRARY_PATH).'pchart/pData.class.php'; +require_once api_get_path(LIBRARY_PATH).'pchart/pChart.class.php'; +require_once api_get_path(LIBRARY_PATH).'pchart/pCache.class.php'; // the section (for the tabs) $this_section = "session_my_space"; @@ -59,116 +59,112 @@ if (api_is_xml_http_request()) { $main_year = $main_month_year = $main_day = array(); // get last 8 days/months $last_days = 8; - $last_months = 5; + $last_months = 5; for ($i = $last_days; $i >= 0; $i--) { - $main_day[date ('d-m-Y', mktime () - $i * 3600 * 24)] = 0; - } + $main_day[date ('d-m-Y', mktime () - $i * 3600 * 24)] = 0; + } for ($i = $last_months; $i >= 0; $i--) { - $main_month_year[date ('m-Y', mktime () - $i*30 * 3600 * 24)] = 0; - } + $main_month_year[date ('m-Y', mktime () - $i * 30 * 3600 * 24)] = 0; + } $i = 0; if (is_array($connections) && count($connections) > 0) { - foreach ($connections as $key => $data) { - //creating the main array - //$main_year[date('Y', $data['login'])] += calculHours($data['logout'] - $data['login']) * 60; - //$main_month_year[date('m-Y', $data['login'])] += calculHours($data['logout'] - $data['login']) * 60; + foreach ($connections as $key => $data) { + //creating the main array $main_month_year[date('m-Y', $data['login'])] += float_format(($data['logout'] - $data['login']) / 60, 0); - //$main_day[date('d-m-Y', $data['login'])] += calculHours($data['logout'] - $data['login']) * 60; $main_day[date('d-m-Y', $data['login'])] += float_format(($data['logout'] - $data['login']) / 60, 0); - if ($i > 500) { - break; + if ($i > 500) { + break; + } + $i++; } - $i++; - } - //var_dump($main_month_year); - switch ($type) { - case 'day': - $main_date = $main_day; - break; - case 'month': - $main_date = $main_month_year ; - break; - case 'year': - $main_date = $main_year; - break; - } - //echo '
'; print_r($main_date);
 
-	// the nice graphics :D
-	$labels = array_keys($main_date);
-	if (count($main_date) == 1) {
-		$labels = $labels[0];
-		$main_date = $main_date[$labels];
-	}
+		switch ($type) {
+			case 'day':
+				$main_date = $main_day;
+				break;
+			case 'month':
+				$main_date = $main_month_year;
+				break;
+			case 'year':
+				$main_date = $main_year;
+				break;
+		}
 
-	$DataSet = new pData;	
-	$DataSet->AddPoint($main_date, 'Q');
-	if (count($main_date)!= 1) {
-		$DataSet->AddPoint($labels, 'Date');
-	}
-	$DataSet->AddAllSeries();  
-	$DataSet->RemoveSerie('Date');  
-	$DataSet->SetAbsciseLabelSerie('Date');
-	$DataSet->SetYAxisName(get_lang('Minutes'));
-	$graph_id = api_get_user_id().'AccessDetails'.api_get_course_id();
-	$DataSet->AddAllSeries();
-
-	$Cache = new pCache();
-	// the graph id
-	$data = $DataSet->GetData();
-
-	if ($Cache->IsInCache($graph_id, $DataSet->GetData())) {
-	//if (0) {
-		//if we already created the img
-		//	echo 'in cache';
-		$img_file = $Cache->GetHash($graph_id, $DataSet->GetData());
-	} else  {
-		// if the image does not exist in the archive/ folder
-		// Initialise the graph  
-		$Test = new pChart(760, 230);
-
-		//which schema of color will be used
-		$quant_resources = count($data[0]) - 1;					
-		// Adding the color schemma
-		$Test->loadColorPalette(api_get_path(LIBRARY_PATH)."pchart/palette/default.txt");
-
-	  	$Test->setFontProperties(api_get_path(LIBRARY_PATH)."pchart/fonts/tahoma.ttf", 8);
-	  	$Test->setGraphArea(70, 30, 680, 200);
-	  	$Test->drawFilledRoundedRectangle(7, 7, 693, 223, 5, 240, 240, 240);
-	  	$Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230);
-	  	$Test->drawGraphArea(255, 255, 255, TRUE);
-	  	$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_START0, 150, 150, 150, TRUE, 0, 0);
-	  	$Test->drawGrid(4, TRUE, 230, 230, 230, 50);
-	    $Test->setLineStyle(2);
-		// Draw the 0 line
-		$Test->setFontProperties(api_get_path(LIBRARY_PATH)."pchart/fonts/tahoma.ttf", 6);
-		$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
-		
-	  	if (count($main_date) == 1) {
-			//Draw a graph 
-			echo ''.$labels.'
'; - $Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE); - } else { - //Draw the line graph - $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription()); - $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255); - } - - // Finish the graph - $Test->setFontProperties(api_get_path(LIBRARY_PATH)."pchart/fonts/tahoma.ttf", 8); - - $Test->setFontProperties(api_get_path(LIBRARY_PATH)."pchart/fonts/tahoma.ttf", 10); - $Test->drawTitle(60, 22, get_lang('AccessDetails'), 50, 50, 50, 585); - - //------------------ - //echo 'not in cache'; - $Cache->WriteToCache($graph_id,$DataSet->GetData(),$Test); - ob_start(); - $Test->Stroke(); - ob_end_clean(); - $img_file = $Cache->GetHash($graph_id,$DataSet->GetData()); - } + // the nice graphics :D + $labels = array_keys($main_date); + if (count($main_date) == 1) { + $labels = $labels[0]; + $main_date = $main_date[$labels]; + } + + $DataSet = new pData; + $DataSet->AddPoint($main_date, 'Q'); + if (count($main_date)!= 1) { + $DataSet->AddPoint($labels, 'Date'); + } + $DataSet->AddAllSeries(); + $DataSet->RemoveSerie('Date'); + $DataSet->SetAbsciseLabelSerie('Date'); + $DataSet->SetYAxisName(get_lang('Minutes')); + $graph_id = api_get_user_id().'AccessDetails'.api_get_course_id(); + $DataSet->AddAllSeries(); + + $Cache = new pCache(); + // the graph id + $data = $DataSet->GetData(); + + if ($Cache->IsInCache($graph_id, $DataSet->GetData())) { + //if (0) { + //if we already created the img + // echo 'in cache'; + $img_file = $Cache->GetHash($graph_id, $DataSet->GetData()); + } else { + // if the image does not exist in the archive/ folder + // Initialise the graph + $Test = new pChart(760, 230); + + //which schema of color will be used + $quant_resources = count($data[0]) - 1; + // Adding the color schemma + $Test->loadColorPalette(api_get_path(LIBRARY_PATH).'pchart/palette/default.txt'); + + $Test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf', 8); + $Test->setGraphArea(70, 30, 680, 200); + $Test->drawFilledRoundedRectangle(7, 7, 693, 223, 5, 240, 240, 240); + $Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230); + $Test->drawGraphArea(255, 255, 255, TRUE); + $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_START0, 150, 150, 150, TRUE, 0, 0); + $Test->drawGrid(4, TRUE, 230, 230, 230, 50); + $Test->setLineStyle(2); + // Draw the 0 line + $Test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf', 6); + $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE); + + if (count($main_date) == 1) { + //Draw a graph + echo ''.$labels.'
'; + $Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE); + } else { + //Draw the line graph + $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription()); + $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255); + } + + // Finish the graph + $Test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf', 8); + + $Test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf', 10); + $Test->drawTitle(60, 22, get_lang('AccessDetails'), 50, 50, 50, 585); + + //------------------ + //echo 'not in cache'; + $Cache->WriteToCache($graph_id, $DataSet->GetData(), $Test); + ob_start(); + $Test->Stroke(); + ob_end_clean(); + $img_file = $Cache->GetHash($graph_id,$DataSet->GetData()); + } echo ''; } else { Display::display_warning_message (get_lang('GraphicNotAvailable')); @@ -176,7 +172,7 @@ if (api_is_xml_http_request()) { exit; } -$nameTools= get_lang('AccessDetails'); +$nameTools = get_lang('AccessDetails'); //StudentDetails if (isset($_GET['origin']) && strcmp($_GET['origin'], 'tracking_course') === 0) { @@ -197,10 +193,10 @@ $htmlHeadXtra[] = ' $(function() { - $("#container-9").tabs({ remote: true}); + $("#container-9").tabs({ remote: true}); }); - -' ; + +'; Display :: display_header(''); $TBL_USERINFO_DEF = Database :: get_course_table(TABLE_USER_INFO); @@ -209,8 +205,8 @@ $mainUserInfo = api_get_user_info($user_id); $result_to_print = ''; $main_date_array = array(); -foreach ($connections as $key => $data) { - $result_to_print .= '  '.date('d-m-Y (H:i:s)', $data['login']).' - '.calculHours($data['logout'] - $data['login']).'
'."\n"; +foreach ($connections as $key => $data) { + $result_to_print .= '  '.date('d-m-Y (H:i:s)', $data['login']).' - '.api_time_to_hms($data['logout'] - $data['login']).'
'."\n"; } api_display_tool_title(get_lang('DetailsStudentInCourse')); echo '
'; @@ -218,11 +214,11 @@ echo ''.get_lang('User').': '.api_get_person_name($mainUserInfo['firstNa ?>
-
';?> +
'; ?> $data) { - echo ("".date("d-m-Y (H:i:s)",$data['login'])."".date("d-m-Y (H:i:s)",$data['logout']).""); + echo ("".date("d-m-Y (H:i:s)", $data['login'])."".date("d-m-Y (H:i:s)", $data['logout']).""); } */ /* foreach ($connections as $key => $data) { - echo ("".date("d-m-Y (H:i:s)",$data['login'])."".calculHours($data['logout']-$data['login']).""); + echo ("".date("d-m-Y (H:i:s)", $data['login'])."".api_time_to_hms($data['logout'] - $data['login']).""); } echo (""); */ + Display:: display_footer(); @@ -264,10 +261,10 @@ function get_connections_to_course($user_id, $course_code) { $sql_query = 'SELECT visual_code as course_code FROM '.$tbl_main.' c WHERE code="'.Database::escape_string($course_code).'";'; $result = Database::query($sql_query, __FILE__, __LINE__); - $row_query = Database::fetch_array($result,'ASSOC'); + $row_query = Database::fetch_array($result, 'ASSOC'); $course_true = isset($row_query['course_code']) ? $row_query['course_code']: $course_code; - $sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . ' + $sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . ' WHERE user_id = ' . intval($user_id) . ' AND course_code="' . Database::escape_string($course_true) . '" ORDER BY login_course_date ASC'; @@ -307,44 +304,19 @@ function get_connections_to_course_by_time($user_id, $course_code, $year = '', $ $row_query = Database::fetch_array($result,'ASSOC'); $course_true = isset($row_query['course_code']) ? $row_query['course_code']: $course_code; - $sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . ' + $sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . ' WHERE user_id = ' . intval($user_id) . ' - AND course_code="' . Database::escape_string($course_true) . '" + AND course_code="' . Database::escape_string($course_true) . '" ORDER BY login_course_date DESC'; $rs = Database::query($sql, __FILE__, __LINE__); - $connections = array(); - while ($a_connections = Database::fetch_array($rs)) { + $connections = array(); + while ($a_connections = Database::fetch_array($rs)) { $s_login_date = $a_connections['login_course_date']; - $s_logout_date = $a_connections['logout_course_date']; + $s_logout_date = $a_connections['logout_course_date']; $i_timestamp_login_date = strtotime($s_login_date); - $i_timestamp_logout_date = strtotime($s_logout_date); - $connections[] = array('login' => $i_timestamp_login_date, 'logout' => $i_timestamp_logout_date); - } + $i_timestamp_logout_date = strtotime($s_logout_date); + $connections[] = array('login' => $i_timestamp_login_date, 'logout' => $i_timestamp_logout_date); + } return $connections; } - -/** - * Transforms seconds into a time format - * - * @param unknown_type $seconds - * @return unknown - */ -function calculHours($seconds) { - //How many hours ? - $hours = floor($seconds / 3600); - - //How many minutes ? - $min = floor(($seconds - ($hours * 3600)) / 60); - if ($min < 10) { - $min = '0'.$min; - } - - //How many seconds - $sec = $seconds - ($hours * 3600) - ($min * 60); - if ($sec < 10) { - $sec = '0'.$sec; - } - - return $hours.get_lang('HourShort').' '.$min.':'.$sec; -} diff --git a/main/mySpace/admin.php b/main/mySpace/admin.php index 979fc630fa..de14ecd1e1 100644 --- a/main/mySpace/admin.php +++ b/main/mySpace/admin.php @@ -7,9 +7,11 @@ ob_start(); // name of the language file that needs to be included -$language_file = array ('registration', 'index','trad4all', 'tracking'); +$language_file = array ('registration', 'index', 'trad4all', 'tracking'); $cidReset = true; + require '../inc/global.inc.php'; +require_once api_get_path(SYS_CODE_PATH).'mySpace/myspace.lib.php'; $this_section = "session_my_space"; @@ -30,56 +32,12 @@ $tbl_session_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_USER); $tbl_admin = Database :: get_main_table(TABLE_MAIN_ADMIN); -/* - =============================================================================== - FUNCTION - =============================================================================== - */ - -function exportCsv($a_header, $a_data) { - global $archiveDirName; - - $fileName = 'administrators.csv'; - $archivePath = api_get_path(SYS_ARCHIVE_PATH); - $archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive='; - - if (!$open = fopen($archivePath.$fileName, 'w+')) { - $message = get_lang('noOpen'); - } else { - $info = ''; - - foreach ($a_header as $header) { - $info .= $header.';'; - } - $info .= "\r\n"; - - foreach ($a_data as $data) { - foreach ($data as $infos) { - $info .= $infos.';'; - } - $info .= "\r\n"; - } - - fwrite($open, $info); - fclose($open); - $perm = api_get_setting('permissions_for_new_files'); - $perm = octdec(!empty($perm) ? $perm : '0660'); - chmod($fileName, $perm); - - header("Location:".$archiveURL.$fileName); - } - return $message; -} - - /** * MAIN PART */ /* - * liste nominative avec coordonn�es et lien vers les cours et -les stagiaires dont il est le -responsable. + * liste nominative avec coordonnies et lien vers les cours et les stagiaires dont il est le responsable. */ if (isset($_POST['export'])) { @@ -87,10 +45,10 @@ if (isset($_POST['export'])) { } else { $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname'; } -$sqlAdmins = "SELECT user.user_id,lastname,firstname,email +$sql_admins = "SELECT user.user_id,lastname,firstname,email FROM $tbl_user as user, $tbl_admin as admin WHERE admin.user_id=user.user_id".$order_clause; -$resultAdmins = Database::query($sqlAdmins, __FILE__, __LINE__); +$result_admins = Database::query($sql_admins, __FILE__, __LINE__); if (api_is_western_name_order()) { echo ''; @@ -99,24 +57,24 @@ if (api_is_western_name_order()) { } if (api_is_western_name_order(PERSON_NAME_DATA_EXPORT)) { - $a_header[] = get_lang('FirstName', ''); - $a_header[] = get_lang('LastName', ''); + $header[] = get_lang('FirstName', ''); + $header[] = get_lang('LastName', ''); } else { - $a_header[] = get_lang('LastName', ''); - $a_header[] = get_lang('FirstName', ''); + $header[] = get_lang('LastName', ''); + $header[] = get_lang('FirstName', ''); } -$a_header[] = get_lang('Email', ''); +$header[] = get_lang('Email', ''); -if (Database::num_rows($resultAdmins) > 0) { - while ($a_admins = Database::fetch_array($resultAdmins)) { +if (Database::num_rows($result_admins) > 0) { + while ($admins = Database::fetch_array($result_admins)) { - $i_user_id = $a_admins["user_id"]; - $s_lastname = $a_admins["lastname"]; - $s_firstname = $a_admins["firstname"]; - $s_email = $a_admins["email"]; + $user_id = $admins["user_id"]; + $lastname = $admins["lastname"]; + $firstname = $admins["firstname"]; + $email = $admins["email"]; if ($i % 2 == 0) { - $s_css_class = "row_odd"; + $css_class = "row_odd"; if ($i % 20 == 0 && $i != 0) { if (api_is_western_name_order()) { echo ''; @@ -125,36 +83,34 @@ if (Database::num_rows($resultAdmins) > 0) { } } } else { - $s_css_class = "row_even"; + $css_class = "row_even"; } $i++; if (api_is_western_name_order()) { - echo ""; + echo ""; } else { - echo ""; + echo ""; } if (api_is_western_name_order(PERSON_NAME_DATA_EXPORT)) { - $a_data[$i_user_id]["firstname"] = $s_firstname; - $a_data[$i_user_id]["lastname"] = $s_lastname; + $data[$user_id]["firstname"] = $firstname; + $data[$user_id]["lastname"] = $lastname; } else { - $a_data[$i_user_id]["lastname"] = $s_lastname; - $a_data[$i_user_id]["firstname"] = $s_firstname; + $data[$user_id]["lastname"] = $lastname; + $data[$user_id]["firstname"] = $firstname; } - $a_data[$i_user_id]["email"] = $s_email; + $data[$user_id]["email"] = $email; } -} - -//No results -else { - echo ''; +} else { + // No results + echo ''; } echo '
'.get_lang('FirstName').''.get_lang('LastName').''.get_lang('Email').'
'.get_lang('FirstName').''.get_lang('LastName').''.get_lang('Email').'
$s_firstname$s_lastname$s_email
$firstname$lastname$email
$s_lastname$s_firstname$s_email
$lastname$firstname$email
'.get_lang("NoResults").'
'.get_lang('NoResults').'
'; if (isset($_POST['export'])) { - exportCsv($a_header, $a_data); + export_csv($header, $data, 'administrators.csv'); } echo "

"; diff --git a/main/mySpace/coaches.php b/main/mySpace/coaches.php index 234d5a8aa4..a2836d7b38 100644 --- a/main/mySpace/coaches.php +++ b/main/mySpace/coaches.php @@ -4,12 +4,14 @@ * Created on 18 October 2006 by Elixir Interactive http://www.elixir-interactive.com */ -ob_start(); +ob_start(); -// name of the language file that needs to be included +// name of the language file that needs to be included $language_file = array ('registration', 'index', 'tracking', 'admin'); $cidReset = true; + require '../inc/global.inc.php'; +require_once api_get_path(SYS_CODE_PATH).'mySpace/myspace.lib.php'; $this_section = "session_my_space"; @@ -39,71 +41,16 @@ $tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ /* =============================================================================== - FUNCTION + FUNCTIONS =============================================================================== */ - -function exportCsv($a_header, $a_data) { - global $archiveDirName; - - $fileName = 'coaches.csv'; - $archivePath = api_get_path(SYS_ARCHIVE_PATH); - $archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive='; - - if (!$open = fopen($archivePath.$fileName, 'w+')) { - $message = get_lang('noOpen'); - } else { - $info = ''; - - foreach ($a_header as $header) { - $info .= $header.';'; - } - $info .= "\r\n"; - - foreach ($a_data as $data) { - foreach ($data as $infos) { - $info .= $infos.';'; - } - $info .= "\r\n"; - } - - fwrite($open, $info); - fclose($open); - $perm = api_get_setting('permissions_for_new_files'); - $perm = octdec(!empty($perm) ? $perm : '0660'); - chmod($fileName, $perm); - - header("Location:".$archiveURL.$fileName); - } - return $message; -} - -function calculHours($seconds) { - //combien d'heures ? - $hours = floor($seconds / 3600); - - //combien de minutes ? - $min = floor(($seconds - ($hours * 3600)) / 60); - if ($min < 10) { - $min = "0".$min; - } - - //combien de secondes - $sec = $seconds - ($hours * 3600) - ($min * 60); - if ($sec < 10) { - $sec = "0".$sec; - } - - //echo $hours."h".$min."m".$sec."s"; - return $hours."h".$min."m".$sec."s" ; -} function is_coach() { global $tbl_session_course; $sql = "SELECT course_code FROM $tbl_session_course WHERE id_coach='".$_SESSION["_uid"]."'"; $result = Database::query($sql, __FILE__, __LINE__); if (Database::num_rows($result) > 0) { - return true; + return true; } return false; } @@ -119,23 +66,23 @@ if (isset($_POST['export'])) { $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname'; } if (isset($_GET["id_student"])) { - $i_id_student=$_GET["id_student"]; - $sqlCoachs = "SELECT DISTINCT src.id_coach " . + $id_student = $_GET["id_student"]; + $sql_coachs = "SELECT DISTINCT src.id_coach " . "FROM $tbl_session_rel_course as src, $tbl_session_rel_course_rel_user as srcru " . - "WHERE src.id_coach<>'0' AND src.course_code=srcru.course_code AND srcru.id_user='$i_id_student' AND srcru.id_session=src.id_session"; + "WHERE src.id_coach<>'0' AND src.course_code=srcru.course_code AND srcru.id_user='$id_student' AND srcru.id_session=src.id_session"; } else { if (api_is_platform_admin()) { - $sqlCoachs = "SELECT DISTINCT id_coach, user_id, lastname, firstname + $sql_coachs = "SELECT DISTINCT id_coach, user_id, lastname, firstname FROM $tbl_user, $tbl_session_rel_course WHERE id_coach=user_id".$order_clause; } else { - $sqlCoachs = "SELECT DISTINCT id_coach, $tbl_user.user_id, lastname, firstname + $sql_coachs = "SELECT DISTINCT id_coach, $tbl_user.user_id, lastname, firstname FROM $tbl_user as user, $tbl_session_rel_course as session_rel_course, $tbl_course_user as course_rel_user WHERE course_rel_user.course_code=session_rel_course.course_code AND course_rel_user.status='1' AND course_rel_user.user_id='".$_SESSION["_uid"]."' AND session_rel_course.id_coach=user.user_id".$order_clause; } } -$resultCoachs = Database::query($sqlCoachs, __FILE__, __LINE__); +$result_coachs = Database::query($sql_coachs, __FILE__, __LINE__); if (api_is_western_name_order()) { echo ''; @@ -144,47 +91,48 @@ if (api_is_western_name_order()) { } if (api_is_western_name_order(PERSON_NAME_DATA_EXPORT)) { - $a_header[] = get_lang('FirstName', ''); - $a_header[] = get_lang('LastName', ''); + $header[] = get_lang('FirstName', ''); + $header[] = get_lang('LastName', ''); } else { - $a_header[] = get_lang('LastName', ''); - $a_header[] = get_lang('FirstName', ''); + $header[] = get_lang('LastName', ''); + $header[] = get_lang('FirstName', ''); } -$a_header[] = get_lang('ConnectionTime', ''); +$header[] = get_lang('ConnectionTime', ''); -if (Database::num_rows($resultCoachs) > 0) { - while ($a_coachs = Database::fetch_array($resultCoachs)) { - $i_id_coach = $a_coachs["id_coach"]; +if (Database::num_rows($result_coachs) > 0) { + while ($coachs = Database::fetch_array($result_coachs)) { + $id_coach = $coachs["id_coach"]; if (isset($_GET["id_student"])) { - $sql_infos_coach = "SELECT lastname, firstname FROM $tbl_user WHERE user_id='$i_id_coach'"; - $resultCoachsInfos = Database::query($sql_infos_coach, __FILE__, __LINE__); - $s_lastname = Database::result($resultCoachsInfos, 0, "lastname"); - $s_firstname = Database::result($resultCoachsInfos, 0, "firstname"); + $sql_infos_coach = "SELECT lastname, firstname FROM $tbl_user WHERE user_id='$id_coach'"; + $result_coachs_infos = Database::query($sql_infos_coach, __FILE__, __LINE__); + $lastname = Database::result($result_coachs_infos, 0, "lastname"); + $firstname = Database::result($result_coachs_infos, 0, "firstname"); } else { - $s_lastname = $a_coachs["lastname"]; - $s_firstname = $a_coachs["firstname"]; + $lastname = $coachs["lastname"]; + $firstname = $coachs["firstname"]; } - $s_sql_connection_time = "SELECT login_date, logout_date FROM $tbl_track_login WHERE login_user_id ='$i_id_coach' AND logout_date <> 'null'"; - $q_result_connection_time = Database::query($s_sql_connection_time, __FILE__, __LINE__); + $sql_connection_time = "SELECT login_date, logout_date FROM $tbl_track_login WHERE login_user_id ='$id_coach' AND logout_date <> 'null'"; + $result_connection_time = Database::query($sql_connection_time, __FILE__, __LINE__); - $i_nb_seconds = 0; - while ($a_connections = Database::fetch_array($q_result_connection_time)) { - $s_login_date = $a_connections["login_date"]; - $s_logout_date = $a_connections["logout_date"]; - $i_timestamp_login_date = strtotime($s_login_date); - $i_timestamp_logout_date = strtotime($s_logout_date); - $i_nb_seconds += ($i_timestamp_logout_date - $i_timestamp_login_date); + $nb_seconds = 0; + while ($connections = Database::fetch_array($result_connection_time)) { + $login_date = $connections["login_date"]; + $logout_date = $connections["logout_date"]; + $timestamp_login_date = strtotime($login_date); + $timestamp_logout_date = strtotime($logout_date); + $nb_seconds += ($timestamp_logout_date - $timestamp_login_date); } - $s_connection_time = calculHours($i_nb_seconds); - if ($s_connection_time == "0h00m00s") { - $s_connection_time = ""; + if ($nb_seconds == 0) { + $s_connection_time = ''; + } else { + $s_connection_time = api_time_to_hms($nb_seconds); } if ($i % 2 == 0) { - $s_css_class = "row_odd"; + $css_class = "row_odd"; if ($i % 20 == 0 && $i != 0) { if (api_is_western_name_order()) { echo ''; @@ -193,36 +141,34 @@ if (Database::num_rows($resultCoachs) > 0) { } } } else { - $s_css_class = "row_even"; + $css_class = "row_even"; } $i++; if (api_is_western_name_order()) { - echo ''; + echo ''; } else { - echo ''; + echo ''; } if (api_is_western_name_order(PERSON_NAME_DATA_EXPORT)) { - $a_data[$i_id_coach]["firstname"] = $s_firstname; - $a_data[$i_id_coach]["lastname"] = $s_lastname; + $data[$id_coach]["firstname"] = $firstname; + $data[$id_coach]["lastname"] = $lastname; } else { - $a_data[$i_id_coach]["lastname"] = $s_lastname; - $a_data[$i_id_coach]["firstname"] = $s_firstname; + $data[$id_coach]["lastname"] = $lastname; + $data[$id_coach]["firstname"] = $firstname; } - $a_data[$i_id_coach]["connection_time"] = $s_connection_time; + $data[$id_coach]["connection_time"] = $s_connection_time; } -} - -//No results -else { +} else { + // No results echo ''; } echo '
'.get_lang('FirstName').''.get_lang('LastName').''.get_lang('ConnectionTime').''.get_lang('AdminCourses').''.get_lang('Students').'
'.get_lang('FirstName').''.get_lang('LastName').''.get_lang('ConnectionTime').''.get_lang('AdminCourses').''.get_lang('Students').'
'.$s_firstname.''.$s_lastname.''.$s_connection_time.'
'.$firstname.''.$lastname.''.$s_connection_time.'
'.$s_lastname.''.$s_firstname.''.$s_connection_time.'
'.$lastname.''.$firstname.''.$s_connection_time.'
'.get_lang("NoResult").'
'; if (isset($_POST['export'])){ - exportCsv($a_header, $a_data); + export_csv($header, $data, 'coaches.csv'); } echo "

"; diff --git a/main/mySpace/course.php b/main/mySpace/course.php index 5f35584b4d..707e614300 100644 --- a/main/mySpace/course.php +++ b/main/mySpace/course.php @@ -7,6 +7,7 @@ $nameTools = 'Cours'; // name of the language file that needs to be included $language_file = array ('admin', 'registration', 'index', 'trad4all', 'tracking'); $cidReset = true; + require '../inc/global.inc.php'; require_once api_get_path(LIBRARY_PATH).'tracking.lib.php'; require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php'; diff --git a/main/mySpace/lp_tracking.php b/main/mySpace/lp_tracking.php index 1a514b1cf3..e0b1272297 100644 --- a/main/mySpace/lp_tracking.php +++ b/main/mySpace/lp_tracking.php @@ -9,7 +9,7 @@ $language_file = array ('registration', 'index', 'tracking', 'exercice', 'scorm', 'learnpath'); //$cidReset = true; -include '../inc/global.inc.php'; +require '../inc/global.inc.php'; $from_myspace = false; $from_link = ''; diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php index c47095e9a4..e271341e5b 100644 --- a/main/mySpace/myStudents.php +++ b/main/mySpace/myStudents.php @@ -8,13 +8,15 @@ // name of the language file that needs to be included $language_file = array('registration', 'index', 'tracking', 'exercice', 'admin'); -//$cidReset=true; +//$cidReset = true; + require '../inc/global.inc.php'; -require_once api_get_path(LIBRARY_PATH) . 'tracking.lib.php'; -require_once api_get_path(LIBRARY_PATH) . 'export.lib.inc.php'; -require_once api_get_path(LIBRARY_PATH) . 'usermanager.lib.php'; -require_once api_get_path(LIBRARY_PATH) . 'course.lib.php'; -require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php'; +require_once api_get_path(LIBRARY_PATH).'tracking.lib.php'; +require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php'; +require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; +require_once api_get_path(LIBRARY_PATH).'course.lib.php'; +require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php'; +require_once api_get_path(SYS_CODE_PATH).'mySpace/myspace.lib.php'; $htmlHeadXtra[] = '