ソースを参照

[svn r21626] bugfix for tabs
small refactoring

Patrick Cool 15 年 前
コミット
2084152af9

+ 121 - 86
main/mySpace/access_details.php

@@ -33,102 +33,28 @@
 * @param string $course_code the course code
 *	Funzione scritta da Mario per testare cose 
 */
-$language_file = array ('registration', 'index', 'tracking');
-require_once('../inc/global.inc.php');
-
-
-/**
- * Gets the connections to a course as an array of login and logout time
- */	 
-function get_connections_to_course($user_id, $course_code) {
-    $course_code = Database::escape_string($course_code);
-    
-    $tbl_track_course = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
-    $tbl_main=Database::get_main_table(TABLE_MAIN_COURSE);
-    $sql_query='SELECT visual_code as course_code FROM '.$tbl_main.' c WHERE code="'.$course_code.'";';
-    $result=api_sql_query($sql_query,__FILE__,__LINE__);
-    $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 . ' 
-    				WHERE user_id = ' . intval($user_id) . '
-    				AND course_code="' . $course_true . '" ORDER BY login_course_date ASC';
-
-    $rs = api_sql_query($sql);
-    $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'];
-        
-        $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);
-        
-    }
-    
-    return $connections;
-}
-
-
-function get_connections_to_course_by_time($user_id, $course_code, $year='', $month='', $day='') {
-    $course_code = Database::escape_string($course_code);    
-    $tbl_track_course = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
-    $tbl_main=Database::get_main_table(TABLE_MAIN_COURSE);
-    $sql_query='SELECT visual_code as course_code FROM '.$tbl_main.' c WHERE code="'.$course_code.'";';
-    $result=api_sql_query($sql_query,__FILE__,__LINE__);
-    $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 . ' 
-    				WHERE user_id = ' . intval($user_id) . '
-    				AND course_code="' . $course_true . '"    				 
-    				ORDER BY login_course_date DESC';
-    
-    $rs = api_sql_query($sql);
-    $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'];        
-        $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);        
-    }    
-    return $connections;
-}
+// name of the language file that needs to be included 
+$language_file = array ('registration', 'index', 'tracking');
 
-	
-/**
- * Transforms seconds into a time format
- */
-function calculHours($seconds)
-{	
-  //How many hours ?
-  $hours = floor($seconds / 3600);
+// including the global Dokeos file
+require_once('../inc/global.inc.php');
 
-  //How many minutes ?
-  $min = floor(($seconds - ($hours * 3600)) / 60);
-  if ($min < 10)
-    $min = '0'.$min;
+// 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');
 
-  //How many seconds
-  $sec = $seconds - ($hours * 3600) - ($min * 60);
-  if ($sec < 10)
-    $sec = '0'.$sec;
+// the section (for the tabs)
+$this_section = "session_my_space";
 
-  return $hours.get_lang('HourShort').' '.$min.':'.$sec;
 
-}
 
 /* MAIN */
 $user_id = Security::remove_XSS($_REQUEST['student']);
 $course_code=Security::remove_XSS($_REQUEST['course']);
 
-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');
+
 $connections = get_connections_to_course($user_id, $course_code);	
 if (api_is_xml_http_request()) {
 	$type  = Security::remove_XSS($_GET['type']);	
@@ -320,4 +246,113 @@ foreach ($connections as $key=>$data)
 echo ("</table>");
 */
 Display:: display_footer();
-?>
+
+
+/*
+-----------------------------------------------------------
+	Functions
+-----------------------------------------------------------
+*/
+
+/**
+ * Gets the connections to a course as an array of login and logout time
+ *
+ * @param unknown_type $user_id
+ * @param unknown_type $course_code
+ * @return unknown
+ */
+function get_connections_to_course($user_id, $course_code) {
+	// Database table definitions
+    $tbl_track_course 	= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
+    $tbl_main			= Database :: get_main_table(TABLE_MAIN_COURSE);
+    
+    $sql_query='SELECT visual_code as course_code FROM '.$tbl_main.' c WHERE code="'.Database::escape_string($course_code).'";';
+    $result=api_sql_query($sql_query,__FILE__,__LINE__);
+    $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 . ' 
+    				WHERE user_id = ' . intval($user_id) . '
+    				AND course_code="' . Database::escape_string($course_true) . '" ORDER BY login_course_date ASC';
+
+    $rs = api_sql_query($sql);
+    $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'];
+        
+        $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);
+        
+    }
+    
+    return $connections;
+}
+
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $user_id
+ * @param unknown_type $course_code
+ * @param unknown_type $year
+ * @param unknown_type $month
+ * @param unknown_type $day
+ * @return unknown
+ */
+function get_connections_to_course_by_time($user_id, $course_code, $year='', $month='', $day='') {
+	// Database table definitions
+    $tbl_track_course 		= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
+    $tbl_main				= Database :: get_main_table(TABLE_MAIN_COURSE);
+    
+    $sql_query='SELECT visual_code as course_code FROM '.$tbl_main.' c WHERE code="'.Database :: escape_string($course_code).'";';
+    $result=api_sql_query($sql_query,__FILE__,__LINE__);
+    $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 . ' 
+    				WHERE user_id = ' . intval($user_id) . '
+    				AND course_code="' . Database::escape_string($course_true) . '"    				 
+    				ORDER BY login_course_date DESC';
+    
+    $rs = api_sql_query($sql);
+    $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'];        
+        $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);        
+    }    
+    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;
+
+}
+?>

+ 9 - 1
main/mySpace/index.php

@@ -27,20 +27,28 @@
  */
 // name of the language file that needs to be included 
 $language_file = array ('registration', 'index','tracking');
+
+// resetting the course id
 $cidReset=true;
 
+// including the global Dokeos file
 require ('../inc/global.inc.php');
+
+// including additional libraries
 require (api_get_path(LIBRARY_PATH).'tracking.lib.php');
 require_once(api_get_path(LIBRARY_PATH).'course.lib.php');
 require_once(api_get_path(LIBRARY_PATH).'export.lib.inc.php');
 
+// the section (for the tabs)
+$this_section = "session_my_space";
+
 ob_start();
 
 $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
 $csv_content = array();
 
 $nameTools= get_lang("MySpace");
-$this_section = "session_my_space";
+
  
 // access control
 api_block_anonymous_users();

+ 8 - 1
main/tracking/courseLog.php

@@ -21,15 +21,22 @@ $language_file[] = 'admin';
 $language_file[] = 'tracking';
 $language_file[] = 'scorm';
 
+// including the global Dokeos file
 require '../inc/global.inc.php';
+
+// the section (for the tabs)
+$this_section = "session_my_space";
+
+
 $is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin;
 
 if (!$is_allowedToTrack) {
 	Display :: display_header(null);
 	api_not_allowed();
 	Display :: display_footer();
+	exit;
 }
-//includes for SCORM and LP
+// including additional libraries
 require_once '../newscorm/learnpath.class.php';
 require_once '../newscorm/learnpathItem.class.php';
 require_once '../newscorm/learnpathList.class.php';

+ 7 - 10
main/tracking/userLog.php

@@ -1,4 +1,4 @@
-<?php // $Id: userLog.php 21097 2009-05-29 21:36:26Z juliomontoya $
+<?php // $Id: userLog.php 21626 2009-06-26 12:19:41Z pcool $
 /*
 ==============================================================================
 	Dokeos - elearning and course management software
@@ -36,23 +36,20 @@
 */
 $uInfo = $_REQUEST['uInfo'];
 $view  = $_REQUEST['view'];
+
 // name of the language file that needs to be included 
 $language_file = 'tracking';
 
+// including the global Dokeos file
 include('../inc/global.inc.php');
 
-// Roles and rights system
+// the section (for the tabs)
+$this_section = "session_my_space";
+
+// variables
 $user_id = api_get_user_id();
 $course_id = api_get_course_id();
 
-/*
-$role_id = RolesRights::get_local_user_role_id($user_id, $course_id);
-$location_id = RolesRights::get_course_tool_location_id($course_id, TOOL_TRACKING);
-$is_allowed = RolesRights::is_allowed_which_rights($role_id, $location_id);
-
-//block users without view right
-RolesRights::protect_location($role_id, $location_id);
-*/
 //YW Hack security to quick fix RolesRights bug
 $is_allowed = true;
 /*