Kaynağa Gözat

Training reporting tool: Trimming whitespace from all source files.

Ivan Tcholakov 15 yıl önce
ebeveyn
işleme
f1466121dc

+ 9 - 9
main/mySpace/access_details.php

@@ -31,10 +31,10 @@
 * Calculates the time spent on the course
 * @param integer $user_id the user id
 * @param string $course_code the course code
-*	Funzione scritta da Mario per testare cose 
+*	Funzione scritta da Mario per testare cose
 */
 
-// 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');
 
 // including the global Dokeos file
@@ -55,10 +55,10 @@ $course_code = Security::remove_XSS($_REQUEST['course']);
 
 $connections = get_connections_to_course($user_id, $course_code);
 if (api_is_xml_http_request()) {
-	$type  = Security::remove_XSS($_GET['type']);	
+	$type  = Security::remove_XSS($_GET['type']);
 	$main_year = $main_month_year = $main_day = array();
 	// get last 8 days/months
-	$last_days = 8;	
+	$last_days = 8;
 	$last_months = 5;
 	for ($i = $last_days; $i >= 0; $i--) {
 		$main_day[date ('d-m-Y', mktime () - $i * 3600 * 24)] = 0;
@@ -98,13 +98,13 @@ if (api_is_xml_http_request()) {
 			$main_date = $main_date[$labels];
 		}
 
-		$data_set = new pData;	
+		$data_set = new pData;
 		$data_set->AddPoint($main_date, 'Q');
 		if (count($main_date)!= 1) {
 			$data_set->AddPoint($labels, 'Date');
 		}
-		$data_set->AddAllSeries();  
-		$data_set->RemoveSerie('Date');  
+		$data_set->AddAllSeries();
+		$data_set->RemoveSerie('Date');
 		$data_set->SetAbsciseLabelSerie('Date');
 		$data_set->SetYAxisName(get_lang('Minutes', ''));
 		$graph_id = api_get_user_id().'AccessDetails'.api_get_course_id();
@@ -142,7 +142,7 @@ if (api_is_xml_http_request()) {
 			$test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
 
 			if (count($main_date) == 1) {
-				//Draw a graph 
+				//Draw a graph
 				echo '<strong>'.$labels.'</strong><br/>';
 				$test->drawBarGraph($data_set->GetData(), $data_set->GetDataDescription(), TRUE);
 			} else {
@@ -258,7 +258,7 @@ 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 = Database::query($sql_query, __FILE__, __LINE__);
     $row_query = Database::fetch_array($result, 'ASSOC');

+ 2 - 2
main/mySpace/admin.php

@@ -6,7 +6,7 @@
 
 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', 'trad4all', 'tracking');
 $cidReset = true;
 
@@ -37,7 +37,7 @@ $tbl_admin				= Database :: get_main_table(TABLE_MAIN_ADMIN);
  */
 
 /*
- * liste nominative avec coordonnies 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'])) {

+ 3 - 3
main/mySpace/coaches.php

@@ -42,7 +42,7 @@ $tbl_track_login 					= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_
 /*
  ===============================================================================
  	FUNCTIONS
- ===============================================================================  
+ ===============================================================================
  */
 
 function is_coach() {
@@ -77,8 +77,8 @@ if (isset($_GET["id_student"])) {
 			WHERE id_coach=user_id".$order_clause;
 	} else {
 		$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"]."' 
+			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;
 	}
 }

+ 8 - 8
main/mySpace/course.php

@@ -4,7 +4,7 @@
  */
 ob_start();
 $nameTools = 'Cours';
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file = array ('admin', 'registration', 'index', 'trad4all', 'tracking');
 $cidReset = true;
 
@@ -48,23 +48,23 @@ if (api_get_setting('add_users_by_coach') == 'true') {
 		$sql = 'SELECT id_coach FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_session;
 		$rs = Database::query($sql, __FILE__, __LINE__);
 		if (Database::result($rs, 0, 0) != $_user['user_id']) {
-			api_not_allowed(true);  
+			api_not_allowed(true);
 		} else {
-			$show_import_icon=true;	
+			$show_import_icon=true;
 		}
 	}
 }
 
 Display :: display_header($nameTools);
 
-// Database Table Definitions 
+// Database Table Definitions
 $tbl_course 				= Database :: get_main_table(TABLE_MAIN_COURSE);
 $tbl_user_course 			= Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 $tbl_user 					= Database :: get_main_table(TABLE_MAIN_USER);
 $tbl_session_course 		= Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
 $tbl_session 				= Database :: get_main_table(TABLE_MAIN_SESSION);
 $tbl_session_course_user 	= Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
- 
+
 if (isset($_GET['action'])) {
 	if ($_GET['action'] == 'show_message') {
 		Display :: display_normal_message(stripslashes($_GET['message']), false);
@@ -73,7 +73,7 @@ if (isset($_GET['action'])) {
 	if ($_GET['action'] == 'error_message') {
 		Display :: display_error_message(stripslashes($_GET['message']), false);
 	}
-}			
+}
 
 if ($show_import_icon) {
 	echo "<div align=\"right\">";
@@ -120,7 +120,7 @@ if (is_array($a_courses)) {
 					WHERE course_code="'.Database :: escape_string($course_code).'"
 					AND id_session='.$id_session;
 			$rs = Database::query($sql, __FILE__, __LINE__);
-			
+
 			while ($row = Database::fetch_array($rs)) {
 				if (!in_array($row['user_id'], $a_students)) {
 					$nb_students_in_course++;
@@ -169,7 +169,7 @@ if (is_array($a_courses)) {
 			$avg_assignments_in_course,
 		);
 
-		$table -> addRow($table_row, 'align="right"');	
+		$table -> addRow($table_row, 'align="right"');
 	}
 
 	// $csv_content = array_merge($csv_header, $csv_content); // Before this statement you are allowed to sort (in different way) the array $csv_content.

+ 53 - 53
main/mySpace/index.php

@@ -3,8 +3,8 @@
 /**
  * @todo use constant for $this_section
  */
-// name of the language file that needs to be included 
-$language_file = array('registration', 'index', 'tracking');
+// name of the language file that needs to be included
+$language_file = array ('registration', 'index', 'tracking');
 
 // resetting the course id
 $cidReset = true;
@@ -94,7 +94,7 @@ if (api_is_allowed_to_create_course()) {
 			ORDER BY course.title";
 
 	if ($_configuration['multiple_access_urls'] == true) {
-		$tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);	
+		$tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
 		$access_url_id = api_get_current_access_url_id();
 		if ($access_url_id != -1) {
 			$sql_nb_cours = "	SELECT course_rel_user.course_code, course.title
@@ -102,13 +102,13 @@ if (api_is_allowed_to_create_course()) {
 				INNER JOIN $tbl_course as course
 					ON course.code = course_rel_user.course_code
 			  	INNER JOIN $tbl_course_rel_access_url course_rel_url
-					ON (course_rel_url.course_code= course.code)	  	
+					ON (course_rel_url.course_code= course.code)
 			  	WHERE access_url_id =  $access_url_id  AND course_rel_user.user_id='".$_user['user_id']."' AND course_rel_user.status='1'
-			  	ORDER BY course.title";	  			
+			  	ORDER BY course.title";
 		}
 	}
 
-	$result_nb_cours = Database::query($sql_nb_cours, __FILE__, __LINE__);	
+	$result_nb_cours = Database::query($sql_nb_cours, __FILE__, __LINE__);
 	$courses = api_store_result($result_nb_cours);
 
 	$nb_teacher_courses = count($courses);
@@ -177,7 +177,7 @@ if ($_user['status'] == DRH && $view == 'drh') {
 
 if ($is_coach && $view == 'coach') {
 	$students = Tracking :: get_student_followed_by_coach($_user['user_id']);
-	$courses = Tracking :: get_courses_followed_by_coach($_user['user_id']);	
+	$courses = Tracking :: get_courses_followed_by_coach($_user['user_id']);
 }
 
 if ($view == 'coach' || $view == 'drh') {
@@ -191,7 +191,7 @@ if ($view == 'coach' || $view == 'drh') {
 	$nb_posts = $nb_assignments = 0;
 	foreach ($students as $student_id) {
 		// inactive students
-		$last_connection_date = Tracking :: get_last_connection_date($student_id, true, true);		
+		$last_connection_date = Tracking :: get_last_connection_date($student_id, true, true);
 		if ($last_connection_date != false) {
 			/*
 			list($last_connection_date, $last_connection_hour) = explode(' ', $last_connection_date);
@@ -199,14 +199,14 @@ if ($view == 'coach' || $view == 'drh') {
 			$last_connection_hour = explode(':', $last_connection_hour);
 			$last_connection_hour[0];
 			$last_connection_time = mktime($last_connection_hour[0], $last_connection_hour[1], $last_connection_hour[2], $last_connection_date[1], $last_connection_date[2], $last_connection_date[0]);
-			*/			
+			*/
 			if (time() - (3600 * 24 * 7) > $last_connection_time) {
 				$nb_inactive_students++;
 			}
 		} else {
 			$nb_inactive_students++;
 		}
-		
+
 		$total_time_spent += Tracking :: get_time_spent_on_the_platform($student_id);
 		$total_courses += Tracking :: count_course_per_student($student_id);
 		$avg_student_progress = $avg_student_score = 0;
@@ -236,7 +236,7 @@ if ($view == 'coach' || $view == 'drh') {
 	if ($nb_students > 0) {
 		// average progress
 		$avg_total_progress = $avg_total_progress / $nb_students;
-		// average results to the tests	
+		// average results to the tests
 		$avg_results_to_exercises = $avg_results_to_exercises / $nb_students;
 		// average courses by student
 		$avg_courses_per_student = round($total_courses / $nb_students, 2);
@@ -271,7 +271,7 @@ if ($view == 'coach' || $view == 'drh') {
 		echo '
 		 <div class="report_section">
 			<h4>
-				<a href="student.php"><img src="'.api_get_path(WEB_IMG_PATH).'students.gif">&nbsp;'.get_lang('Probationers').' ('.$nb_students.')'.'</a> 
+				<a href="student.php"><img src="'.api_get_path(WEB_IMG_PATH).'students.gif">&nbsp;'.get_lang('Probationers').' ('.$nb_students.')'.'</a>
 			</h4>
 			<table class="data_table">
 				<tr>
@@ -348,9 +348,9 @@ if ($view == 'coach') {
 			$nb_sessions_current ++;
 		} else {
 			$date_start = explode('-', $session['date_start']);
-			$time_start = mktime(0, 0, 0, $date_start[1], $date_start[2], $date_start[0]);			
-			$date_end = explode('-', $session['date_end']);				
-			$time_end = mktime(0, 0, 0, $date_end[1], $date_end[2], $date_end[0]);			
+			$time_start = mktime(0, 0, 0, $date_start[1], $date_start[2], $date_start[0]);
+			$date_end = explode('-', $session['date_end']);
+			$time_end = mktime(0, 0, 0, $date_end[1], $date_end[2], $date_end[0]);
 			if ($time_start < time() && time() < $time_end) {
 				$nb_sessions_current++;
 			}
@@ -361,7 +361,7 @@ if ($view == 'coach') {
 				$nb_sessions_past++;
 			}
 		}
-		$courses = array_merge($courses, Tracking::get_courses_list_from_session($session['id']));		
+		$courses = array_merge($courses, Tracking::get_courses_list_from_session($session['id']));
 	}
 
 	if ($nb_sessions > 0) {
@@ -371,8 +371,8 @@ if ($view == 'coach') {
 		$nb_courses_per_session = null;
 		$nb_students_per_session = null;
 	}
-	
-	
+
+
 	if ($export_csv) {
 		//csv part
 		$csv_content[] = array(get_lang('Sessions', ''));
@@ -475,7 +475,7 @@ if (api_is_allowed_to_create_course() && $view == 'teacher') {
 
 			// students directly subscribed to the course
 			$sql = "SELECT user_id FROM $tbl_course_user as course_rel_user WHERE course_rel_user.status='5' AND course_rel_user.course_code='$course_code'";
-			$rs = Database::query($sql, __FILE__, __LINE__);	
+			$rs = Database::query($sql, __FILE__, __LINE__);
 			while ($row = Database::fetch_array($rs)) {
 				$nb_students_in_course++;
 
@@ -497,18 +497,18 @@ if (api_is_allowed_to_create_course() && $view == 'teacher') {
 				$rs = Database::query($sql, __FILE__, __LINE__);
 				while ($row = Database::fetch_array($rs)) {
 					if (!in_array($row['user_id'], $a_course_students)) {
-						$nb_students_in_course++;	
+						$nb_students_in_course++;
 
 						// tracking datas
 						$avg_progress_in_course += Tracking :: get_avg_student_progress ($row['user_id'], $course_code);
-						$avg_score_in_course += Tracking :: get_avg_student_score ($row['user_id'], $course_code);						
-						$avg_score_in_exercise += Tracking :: get_avg_student_exercise_score ($row['user_id'], $course_code);														
+						$avg_score_in_course += Tracking :: get_avg_student_score ($row['user_id'], $course_code);
+						$avg_score_in_exercise += Tracking :: get_avg_student_exercise_score ($row['user_id'], $course_code);
 						$avg_time_spent_in_course += Tracking :: get_time_spent_on_the_course ($row['user_id'], $course_code);
-						$avg_messages_in_course += Tracking :: count_student_messages ($row['user_id'], $course_code);						
+						$avg_messages_in_course += Tracking :: count_student_messages ($row['user_id'], $course_code);
 						$avg_assignments_in_course += Tracking :: count_student_assignments ($row['user_id'], $course_code);
 						$a_course_students[] = $row['user_id'];
 					}
-				}							
+				}
 			}
 
 			if ($nb_students_in_course > 0) {
@@ -536,7 +536,7 @@ if (api_is_allowed_to_create_course() && $view == 'teacher') {
 			$table_row[] = is_null($avg_score_in_exercise) ? '' : $avg_score_in_exercise.'%';
 			$table_row[] = $avg_messages_in_course;
 			$table_row[] = $avg_assignments_in_course;
-			//set the "from" value to know if I access the Reporting by the Dokeos tab or the course link 
+			//set the "from" value to know if I access the Reporting by the Dokeos tab or the course link
 			$table_row[] = '<center><a href="../tracking/courseLog.php?cidReq='.$course_code.'&studentlist=true&from=myspace"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></center>';
 
 			$csv_content[] = array(
@@ -626,22 +626,22 @@ if ($is_platform_admin && $view == 'admin') {
 
 		$tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
 
-		$sqlCoachs = "SELECT DISTINCT id_coach, user_id, lastname, firstname, MAX(login_date) as login_date 
-			FROM $tbl_user, $tbl_session_course, $tbl_track_login 
+		$sqlCoachs = "SELECT DISTINCT id_coach, user_id, lastname, firstname, MAX(login_date) as login_date
+			FROM $tbl_user, $tbl_session_course, $tbl_track_login
 			WHERE id_coach=user_id AND login_user_id=user_id
 			GROUP BY user_id ";
 		//	ORDER BY login_date ".$tracking_direction;
 
 		if ($_configuration['multiple_access_urls'] == true) {
-			$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);	
+			$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
 			$access_url_id = api_get_current_access_url_id();
 			if ($access_url_id != -1) {
-				$sqlCoachs = "SELECT DISTINCT id_coach, user_id, lastname, firstname, MAX(login_date) as login_date 
+				$sqlCoachs = "SELECT DISTINCT id_coach, user_id, lastname, firstname, MAX(login_date) as login_date
 					FROM $tbl_user, $tbl_session_course, $tbl_track_login , $tbl_session_rel_access_url session_rel_url
 					WHERE id_coach=user_id AND login_user_id=user_id AND access_url_id = $access_url_id AND session_rel_url.session_id=id_session
-					GROUP BY user_id ";			  			
+					GROUP BY user_id ";
 			}
-		}	
+		}
 
 		if (!empty($order[$tracking_column])) {
 			$sqlCoachs .= "ORDER BY ".$order[$tracking_column]." ".$tracking_direction;
@@ -662,7 +662,7 @@ if ($is_platform_admin && $view == 'admin') {
 			ORDER BY login_date '.$tracking_direction;
 
 		if ($_configuration['multiple_access_urls'] == true) {
-			$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);	
+			$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
 			$access_url_id = api_get_current_access_url_id();
 			if ($access_url_id != -1) {
 				$sql_session_coach = 'SELECT session.id_coach, user_id, lastname, firstname, MAX(login_date) as login_date
@@ -672,15 +672,15 @@ if ($is_platform_admin && $view == 'admin') {
 					ORDER BY login_date '.$tracking_direction;
 			}
 		}
-	
+
 		$result_sessions_coach = Database::query($sql_session_coach, __FILE__, __LINE__);
 		$total_no_coaches += Database::num_rows($result_sessions_coach);
 		while ($coach = Database::fetch_array($result_sessions_coach)) {
 			$global_coaches[$coach['user_id']] = $coach;
-		}	
-	
+		}
+
 		$all_datas = array();
-	
+
 		foreach ($global_coaches as $id_coach => $coaches) {
 
 			$time_on_platform = api_time_to_hms(Tracking :: get_time_spent_on_the_platform($coaches['user_id']));
@@ -816,7 +816,7 @@ function export_tracking_user_overview() {
 		$csv_row[] = get_lang('LastName', '');
 		$csv_row[] = get_lang('FirstName', '');
 	}
-	$csv_row[] = get_lang('LoginName');	
+	$csv_row[] = get_lang('LoginName');
 	$csv_row[] = get_lang('CourseCode');
 	// the additional user defined fields (only those that were selected to be exported)
 	require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
@@ -840,7 +840,7 @@ function export_tracking_user_overview() {
 	$csv_row[] = get_lang('FirstLogin', '');
 	$csv_row[] = get_lang('LatestLogin', '');
 	$csv_content[] = $csv_row;
-	
+
 	// the other lines (the data)
 	foreach ($user_data as $key => $user) {
 		// getting all the courses of the user
@@ -872,7 +872,7 @@ function export_tracking_user_overview() {
 			// student score
 			$csv_row[] = round(Tracking :: get_avg_student_score ($user[4], $row[0]), 2);
 			// student tes score
-			$csv_row[] = round(Tracking :: get_avg_student_exercise_score ($user[4], $row[0]), 2);			
+			$csv_row[] = round(Tracking :: get_avg_student_exercise_score ($user[4], $row[0]), 2);
 			// student messages
 			$csv_row[] = Tracking :: count_student_messages ($user[4], $row[0]);
 			// student assignments
@@ -882,7 +882,7 @@ function export_tracking_user_overview() {
 			$csv_row[] = $exercises_results['score_obtained'];
 			$csv_row[] = $exercises_results['score_possible'];
 			$csv_row[] = $exercises_results['questions_answered'];
-			$csv_row[] = $exercises_results['percentage'];			
+			$csv_row[] = $exercises_results['percentage'];
 			// first connection
 			$csv_row[] = Tracking :: get_first_connection_date_on_the_course ($user[4], $row[0]);
 			// last connection
@@ -905,7 +905,7 @@ function display_tracking_user_overview() {
 	display_user_overview_export_options();
 
 	$t_head .= '	<table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
-	$t_head .= '	<caption>'.get_lang('CourseInformation').'</caption>';			
+	$t_head .= '	<caption>'.get_lang('CourseInformation').'</caption>';
 	$t_head .=		'<tr>';
 	$t_head .= '		<th width="155px" style="border-left:0;border-bottom:0"><span>'.get_lang('Course').'</span></th>';
 	$t_head .= '		<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).'</span></th>';
@@ -924,7 +924,7 @@ function display_tracking_user_overview() {
 
 	$addparams = array('view' => 'admin', 'display' => 'useroverview');
 
-	$table = new SortableTable('tracking_user_overview', 'get_number_of_users_tracking_overview', 'get_user_data_tracking_overview', 0);	
+	$table = new SortableTable('tracking_user_overview', 'get_number_of_users_tracking_overview', 'get_user_data_tracking_overview', 0);
 	$table->additional_parameters = $addparams;
 
 	$table->set_header(0, get_lang('OfficialCode'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
@@ -945,7 +945,7 @@ function display_tracking_user_overview() {
  * get the numer of users of the platform
  *
  * @return integer
- * 
+ *
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
  * @version Dokeos 1.8.6
  * @since October 2008
@@ -964,7 +964,7 @@ function get_number_of_users_tracking_overview() {
 
 /**
  * get all the data for the sortable table of the reporting progress of all users and all the courses the user is subscribed to.
- * 
+ *
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
  * @version Dokeos 1.8.6
  * @since October 2008
@@ -989,7 +989,7 @@ function get_user_data_tracking_overview($from, $number_of_items, $column, $dire
 				").
 				"username		AS col3,
 				user_id 		AS col4
-			FROM 
+			FROM
 				$main_user_table
 			";
 	$sql .= " ORDER BY col$column $direction ";
@@ -1009,7 +1009,7 @@ function get_user_data_tracking_overview($from, $number_of_items, $column, $dire
  * @param array $url_params additonal url parameters
  * @param array $row the row information (the other columns)
  * @return html code
- * 
+ *
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
  * @version Dokeos 1.8.6
  * @since October 2008
@@ -1050,7 +1050,7 @@ function course_info_tracking_filter($user_id, $url_params, $row) {
 		// student score
 		$return .= '	<td><div>'.round(Tracking :: get_avg_student_score($user_id, $row[0]), 2).'</div></td>';
 		// student tes score
-		//$return .= '	<td><div style="width:40px">'.round(Tracking :: get_avg_student_exercise_score ($user_id, $row[0]),2).'%</div></td>';		
+		//$return .= '	<td><div style="width:40px">'.round(Tracking :: get_avg_student_exercise_score ($user_id, $row[0]),2).'%</div></td>';
 		// student messages
 		$return .= '	<td><div>'.Tracking :: count_student_messages($user_id, $row[0]).'</div></td>';
 		// student assignments
@@ -1080,7 +1080,7 @@ function course_info_tracking_filter($user_id, $url_params, $row) {
  *
  * @param integer $user_id the id of the user
  * @param string $course_code the course code
- * 
+ *
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
  * @version Dokeos 1.8.6
  * @since November 2008
@@ -1102,7 +1102,7 @@ function exercises_results($user_id, $course_code) {
 	}
 
 	if ($score_possible != 0) {
-		$percentage = round(($score_obtained / $score_possible * 100), 2);	
+		$percentage = round(($score_obtained / $score_possible * 100), 2);
 	} else {
 		$percentage = null;
 	}
@@ -1111,7 +1111,7 @@ function exercises_results($user_id, $course_code) {
 }
 
 /**
- * Displays a form with all the additionally defined user fields of the profile 
+ * Displays a form with all the additionally defined user fields of the profile
  * and give you the opportunity to include these in the CSV export
  *
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
@@ -1162,7 +1162,7 @@ function display_user_overview_export_options() {
 				foreach ($_SESSION['additional_export_fields'] as $key => $extra_field_export) {
 					$message .= '<li>'.$extrafields[$extra_field_export][3].'</li>';
 				}
-			}			
+			}
 
 			// Displaying a feedback message
 			if (!empty($_SESSION['additional_export_fields'])) {
@@ -1190,11 +1190,11 @@ function display_user_overview_export_options() {
 }
 
 /**
- * Get all information that the user with user_id = $user_data has 
+ * Get all information that the user with user_id = $user_data has
  * entered in the additionally defined profile fields
  *
  * @param integer $user_id the id of the user
- * 
+ *
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
  * @version Dokeos 1.8.6
  * @since November 2008

+ 6 - 6
main/mySpace/lp_tracking.php

@@ -5,7 +5,7 @@
  * Created on 26 mars 07 by Eric Marguin
  * Script to display the tracking of the students in the learning paths.
  */
- 
+
 $language_file = array ('registration', 'index', 'tracking', 'exercice', 'scorm', 'learnpath');
 //$cidReset = true;
 
@@ -110,7 +110,7 @@ div.description {
 	padding: 5px;
 	vertical-align: top;
 	border-bottom: 1px solid #b1b1b1;
-	border-right: 1px dotted #e1e1e1; 
+	border-right: 1px dotted #e1e1e1;
 	border-left: 1px dotted #e1e1e1;
 }
 
@@ -130,11 +130,11 @@ Display :: display_header($nameTools);
 
 $lp_id = intval($_GET['lp_id']);
 
-$sql = 'SELECT name 
+$sql = 'SELECT name
 	FROM '.Database::get_course_table(TABLE_LP_MAIN, $_course['db_name']).'
 	WHERE id='.Database::escape_string($lp_id);
 $rs = Database::query($sql, __FILE__, __LINE__);
-$lp_title = Database::result($rs, 0, 0);	
+$lp_title = Database::result($rs, 0, 0);
 
 echo '<div class ="actions"><div align="left" style="float:left;margin-top:2px;" ><strong>'.$_course['title'].' - '.$lp_title.' - '.$name.'</strong></div>
 	  <div  align="right">
@@ -145,8 +145,8 @@ echo '<div class ="actions"><div align="left" style="float:left;margin-top:2px;"
 
 $list = learnpath :: get_flat_ordered_items_list($lp_id);
 $origin = 'tracking';
-if ($export_csv) {	
-	include_once api_get_path(SYS_CODE_PATH).'newscorm/lp_stats.php';	
+if ($export_csv) {
+	include_once api_get_path(SYS_CODE_PATH).'newscorm/lp_stats.php';
 	//Export :: export_table_csv($csv_content, 'reporting_student');
 } else {
 	ob_start();

+ 24 - 24
main/mySpace/myStudents.php

@@ -6,7 +6,7 @@
  * @package dokeos.mySpace
  */
 
-// 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', 'exercice', 'admin');
 //$cidReset = true;
 
@@ -22,8 +22,8 @@ $htmlHeadXtra[] = '<script type="text/javascript">
 
 function show_image(image,width,height) {
 	width = parseInt(width) + 20;
-	height = parseInt(height) + 20;			
-	window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');		
+	height = parseInt(height) + 20;
+	window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');
 }
 
 </script>';
@@ -179,7 +179,7 @@ function is_teacher($course_code) {
 /*
  *===============================================================================
  *	MAIN CODE
- *===============================================================================  
+ *===============================================================================
  */
 // Database Table Definitions
 $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
@@ -329,7 +329,7 @@ if (!empty ($_GET['student'])) {
 	<a name="infosStudent"></a>
 				<table width="100%" border="0" >
 					<tr>
-						
+
 							<?php
 
 	$image_array = UserManager :: get_user_picture_path_by_id($info_user['user_id'], 'web', false, true);
@@ -354,9 +354,9 @@ if (!empty ($_GET['student'])) {
 
 	echo '</td>';
 ?>
-						
+
 			<td width="40%" valign="top">
-			
+
 				<table width="100%" class="data_table">
 								<tr>
 									<th>
@@ -425,7 +425,7 @@ if (!empty ($_GET['student'])) {
 							</table>
 						</td>
 						<td class="borderLeft" width="35%" valign="top">
-				
+
 				<table width="100%" class="data_table">
 								<tr>
 						<th colspan="2">
@@ -508,7 +508,7 @@ if (!empty ($_GET['student'])) {
 			$tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
 			$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
 
-			$sql = 'SELECT id_session 
+			$sql = 'SELECT id_session
 										FROM ' . $tbl_session_course_user . ' session_course_user
 										WHERE session_course_user.id_user = ' . intval($info_user['user_id']) . '
 										AND session_course_user.course_code = "' . Database :: escape_string($course_code_info) . '"
@@ -519,14 +519,14 @@ if (!empty ($_GET['student'])) {
 				$le_session_id = intval(Database :: result($rs, 0, 0));
 				if ($le_session_id > 0) {
 					// get session name and coach of the session
-					$sql = 'SELECT name, id_coach FROM ' . $tbl_session . ' 
+					$sql = 'SELECT name, id_coach FROM ' . $tbl_session . '
 														WHERE id=' . $le_session_id;
 					$rs = Database::query($sql, __FILE__, __LINE__);
 					$session_name = Database :: result($rs, 0, 'name');
 					$session_coach_id = intval(Database :: result($rs, 0, 'id_coach'));
 
 					// get coach of the course in the session
-					$sql = 'SELECT id_coach FROM ' . $tbl_session_course . ' 
+					$sql = 'SELECT id_coach FROM ' . $tbl_session_course . '
 														WHERE id_session=' . $le_session_id . '
 														AND course_code = "' . Database :: escape_string($_GET['course']) . '"';
 					$rs = Database::query($sql, __FILE__, __LINE__);
@@ -567,7 +567,7 @@ if (!empty ($_GET['student'])) {
 			</td>
 		</tr>
 	</table>
-		
+
 	<!-- line about learnpaths -->
 				<table class="data_table">
 					<tr>
@@ -663,7 +663,7 @@ if (!empty ($_GET['student'])) {
 				}
 
 				// calculates time
-				$sql = 'SELECT SUM(total_time) 
+				$sql = 'SELECT SUM(total_time)
 												FROM ' . $t_lpiv . ' AS item_view
 												INNER JOIN ' . $t_lpv . ' AS view
 													ON item_view.lp_view_id = view.id
@@ -678,7 +678,7 @@ if (!empty ($_GET['student'])) {
 				}
 
 				// calculates last connection time
-				$sql = 'SELECT MAX(start_time) 
+				$sql = 'SELECT MAX(start_time)
 												FROM ' . $t_lpiv . ' AS item_view
 												INNER JOIN ' . $t_lpv . ' AS view
 													ON item_view.lp_view_id = view.id
@@ -766,14 +766,14 @@ if (!empty ($_GET['student'])) {
 				}
 ?>
 						</td>
-					</tr>				
+					</tr>
 				<?php
 				$data_learnpath[$i][] = $learnpath['name'];
 				$data_learnpath[$i][] = $progress . '%';
 				$i++;
 			}
 		} else {
-			echo "	<tr>	
+			echo "	<tr>
 										<td colspan='6'>
 											" . get_lang('NoLearnpath') . "
 										</td>
@@ -832,7 +832,7 @@ if (!empty ($_GET['student'])) {
 															WHERE  ex.exe_cours_id = '" . $info_course['code'] . "'
 															AND ex.exe_exo_id = " . $exercices['id'] . "
 															AND orig_lp_id = 0
-															AND orig_lp_item_id = 0				
+															AND orig_lp_item_id = 0
 															AND exe_user_id='" . Database :: escape_string($is_student) . "'";
 					$result_essais = Database::query($sql_essais, __FILE__, __LINE__);
 					$essais = Database :: fetch_array($result_essais);
@@ -855,7 +855,7 @@ if (!empty ($_GET['student'])) {
 					}
 					$score_percentage = 0;
 					if ($weighting != 0) {
-						//i.e 10.50 
+						//i.e 10.50
 						$score_percentage = round(($score * 100) / $weighting, 2);
 					} else {
 						$score_percentage = null;
@@ -919,7 +919,7 @@ if (!empty ($_GET['student'])) {
 
 				}
 			} else {
-				echo "	<tr>	
+				echo "	<tr>
 												<td colspan='6'>
 													" . get_lang('NoExercise') . "
 												</td>
@@ -927,14 +927,14 @@ if (!empty ($_GET['student'])) {
 										 ";
 			}
 		} else {
-			echo "	<tr>	
+			echo "	<tr>
 										<td colspan='6'>
 											" . get_lang('NoExercise') . "
 										</td>
 									</tr>
 								 ";
 		}
-?>					
+?>
 					</table>
 
 	<!-- line about other tools -->
@@ -1075,7 +1075,7 @@ if (!empty ($_GET['student'])) {
 						$score
 					);
 					echo '
-										<tr>				
+										<tr>
 											<td align="right">
 												' . $course_info['title'] . '
 											</td>
@@ -1117,7 +1117,7 @@ if (!empty ($_GET['student'])) {
 
 	if (!empty ($_GET['details']) && $_GET['origin'] != 'tracking_course' && $_GET['origin'] != 'user_course') {
 ?>
-		
+
 		<br /><br />
 <?php
 
@@ -1160,7 +1160,7 @@ if (!empty ($_GET['student'])) {
 
 			echo "<a name='infosExe'></a>";
 
-			echo "	
+			echo "
 						<tr>
 							<td colspan='2'>
 								<strong>" . $exerciceDetails['question'] . ' /' . $exerciceDetails['ponderation'] . "</strong>

+ 2 - 2
main/mySpace/progression.php

@@ -27,11 +27,11 @@ $tbl_user 			= Database :: get_main_table(TABLE_MAIN_USER);
 $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
 $tbl_session 		= Database :: get_main_table(TABLE_MAIN_SESSION);
 $tbl_track_exercice = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
- 
+
 /*
 ===============================================================================
  	MAIN CODE
-===============================================================================  
+===============================================================================
 */
 $sql_course = "SELECT 	title,code
 	FROM $tbl_course as course

+ 3 - 3
main/mySpace/reussite.php

@@ -6,7 +6,7 @@
 // TODO: Is this file used?
 
 $nameTools = 'Reussite';
-// 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', 'trad4all', 'tracking');
 $cidReset = true;
 
@@ -18,7 +18,7 @@ api_block_anonymous_users();
 $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
 Display :: display_header($nameTools);
 
-// Database Table Definitions 
+// Database Table Definitions
 $tbl_course 		= Database :: get_main_table(TABLE_MAIN_COURSE);
 $tbl_user 			= Database :: get_main_table(TABLE_MAIN_USER);
 $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
@@ -28,7 +28,7 @@ $tbl_track_exercice = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EX
 /*
 ===============================================================================
 	MAIN CODE
-===============================================================================  
+===============================================================================
 */
 if (!empty($_GET['session'])) {
 	$sql_session = "SELECT name,id

+ 10 - 10
main/mySpace/session.php

@@ -18,7 +18,7 @@
 
 	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
 	Mail: info@dokeos.com
-	
+
 ==============================================================================
 */
 /*
@@ -27,7 +27,7 @@
  */
 ob_start();
 $nameTools= 'Sessions';
-// 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', 'trad4all', 'tracking');
 $cidReset = true;
 
@@ -43,7 +43,7 @@ api_block_anonymous_users();
 $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
 Display :: display_header($nameTools);
 
-// Database Table Definitions 
+// Database Table Definitions
 $tbl_course_user 		= Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 $tbl_sessions 			= Database :: get_main_table(TABLE_MAIN_SESSION);
 $tbl_session_course 	= Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
@@ -52,16 +52,16 @@ $tbl_course 			= Database :: get_main_table(TABLE_MAIN_COURSE);
 $export_csv = false;
 
 if (isset($_GET['export']) && $_GET['export'] == 'csv') {
-	$export_csv = true; 
+	$export_csv = true;
 }
 
 
 /*
 ===============================================================================
 	FUNCTION
-===============================================================================  
+===============================================================================
 */
- 
+
 function count_sessions_coached() {
 	global $nb_sessions;
 	return $nb_sessions;
@@ -89,7 +89,7 @@ function rsort_sessions($a, $b) {
 /*
 ===============================================================================
 	MAIN CODE
-===============================================================================  
+===============================================================================
 */
 
 if (isset($_GET['id_coach']) && $_GET['id_coach'] != '') {
@@ -116,7 +116,7 @@ if ($nb_sessions > 0) {
 	$table -> set_header(2, get_lang('Date'));
 	$table -> set_header(3, get_lang('Details'), false);
 
-	$all_data = array();	
+	$all_data = array();
 	foreach ($a_sessions as $session) {
 		$row = array();
 		$row[] = $session['name'];
@@ -159,10 +159,10 @@ if ($nb_sessions > 0) {
 	}
 
 	$table -> setColAttributes(3, array('align' => 'center'));
-	$table -> display();	
+	$table -> display();
 
 	if ($export_csv) {
-		ob_end_clean();		
+		ob_end_clean();
 		Export :: export_table_csv($csv_content, 'reporting_student_list');
 	}
 } else {

+ 6 - 6
main/mySpace/student.php

@@ -4,7 +4,7 @@
  * Created on 28 juil. 2006 by Elixir Interactive http://www.elixir-interactive.com
  */
 
- // 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');
 $cidReset = true;
 
@@ -62,7 +62,7 @@ $tbl_session_rel_user 		= Database :: get_main_table(TABLE_MAIN_SESSION_USER);
 /*
  ===============================================================================
  	FUNCTION
- ===============================================================================  
+ ===============================================================================
  */
 
 function count_student_coached() {
@@ -92,8 +92,8 @@ function rsort_users($a, $b)
 /*
  ===============================================================================
  	MAIN CODE
- ===============================================================================  
- */ 
+ ===============================================================================
+ */
 
 if ($isCoach || api_is_platform_admin() || $_user['status'] == DRH) {
 
@@ -146,7 +146,7 @@ if ($isCoach || api_is_platform_admin() || $_user['status'] == DRH) {
 		}
 		$table -> set_header(2, get_lang('Time'), false);
 		$table -> set_header(3, get_lang('Progress'), false);
-		$table -> set_header(4, get_lang('Score'), false);	
+		$table -> set_header(4, get_lang('Score'), false);
 		$table -> set_header(5, get_lang('Student_publication'), false);
 		$table -> set_header(6, get_lang('Messages'), false);
 		$table -> set_header(7, get_lang('FirstLogin'), false);
@@ -255,7 +255,7 @@ if ($isCoach || api_is_platform_admin() || $_user['status'] == DRH) {
 		}
 
 		foreach ($all_datas as $row) {
-			$table -> addRow($row, 'align="right"');	
+			$table -> addRow($row, 'align="right"');
 		}
 		$table -> updateColAttributes(0, array('align' => 'left'));
 		$table -> updateColAttributes(1, array('align' => 'left'));

+ 2 - 2
main/mySpace/teachers.php

@@ -3,7 +3,7 @@
 /*
  * Created on 18 October 2006 by Elixir Interactive http://www.elixir-interactive.com
  */
- 
+
 ob_start();
 
 // names of the language file that needs to be included
@@ -85,7 +85,7 @@ if (Database::num_rows($result_formateurs) > 0) {
 
 		if ($i % 2 == 0) {
 			$css_class = "row_odd";
-			
+
 			if ($i % 20 == 0 && $i != 0) {
 				if ($is_western_name_order) {
 					echo '<tr><th>'.get_lang('FirstName').'</th><th>'.get_lang('LastName').'</th><th>'.get_lang('Email').'</th><th>'.get_lang('AdminCourses').'</th><th>'.get_lang('Students').'</th></tr>';

+ 20 - 20
main/mySpace/user_add.php

@@ -63,7 +63,7 @@ function display_drh_list(){
 		document.getElementById("drh_list").style.display="block";
 	}
 	else
-	{ 
+	{
 		document.getElementById("drh_list").style.display="none";
 		document.getElementById("drh_select").options[0].selected="selected";
 	}
@@ -78,8 +78,8 @@ if (!empty($_GET['message'])) {
 
 $id_session='';
 if (isset($_GET["id_session"]) && $_GET["id_session"] != "") {
- 	$id_session = Security::remove_XSS($_GET["id_session"]); 	
-	//$interbreadcrumb[] = array ("url" => "session.php", "name" => get_lang('Sessions')); 
+ 	$id_session = Security::remove_XSS($_GET["id_session"]);
+	//$interbreadcrumb[] = array ("url" => "session.php", "name" => get_lang('Sessions'));
 	//$interbreadcrumb[] = array ("url" => "course.php?id_session=".$_GET["id_session"]."", "name" => get_lang('Cours'));
 }
 
@@ -171,14 +171,14 @@ if (api_is_session_admin()) {
 	$where = 'WHERE session_admin_id='.intval(api_get_user_id());
 	$where .= ' AND ( (session.date_start <= CURDATE() AND session.date_end >= CURDATE()) OR session.date_start="0000-00-00" ) ';
 	$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
-	$result = Database::query("SELECT id,name,nbr_courses,date_start,date_end 
-		FROM $tbl_session 					
+	$result = Database::query("SELECT id,name,nbr_courses,date_start,date_end
+		FROM $tbl_session
 		$where
 		ORDER BY name",__FILE__,__LINE__);
-	$a_sessions = api_store_result($result);		
-	$session_list = array();	
+	$a_sessions = api_store_result($result);
+	$session_list = array();
 	$session_list[0] = get_lang('SelectSession');
-	if (is_array($a_sessions)) {	
+	if (is_array($a_sessions)) {
 		foreach ($a_sessions as $session) {
 			$session_list[$session['id']]=$session['name'];
 		}
@@ -189,7 +189,7 @@ if (api_is_session_admin()) {
 	api_natsort($session_list);
 
 	$form->addElement('select', 'session_id', get_lang('Session'), $session_list);
-}		
+}
 
 
 // EXTRA FIELDS
@@ -220,7 +220,7 @@ foreach ($extra as $id => $field_details) {
 			foreach ($field_details[9] as $option_id => $option_details) {
 				$options[$option_details[1]] = $option_details[2];
 			}
-			$form->addElement('select', 'extra_'.$field_details[1], $field_details[3], $options, '');			
+			$form->addElement('select', 'extra_'.$field_details[1], $field_details[3], $options, '');
 			break;
 		case USER_FIELD_TYPE_SELECT_MULTIPLE:
 			$options = array();
@@ -316,7 +316,7 @@ if ($form->validate()) {
 		//create user
 		$user_id = UserManager::create_user($firstname, $lastname, $status, $email, $username, $password, $official_code, api_get_setting('platformLanguage'), $phone, $picture_uri, $auth_source, $expiration_date, $active, $hr_dept_id);
 
-		//adding to the session		
+		//adding to the session
 		if (api_is_session_admin()) {
 			$tbl_session_rel_course				= Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
 			$tbl_session_rel_course_rel_user	= Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
@@ -327,19 +327,19 @@ if ($form->validate()) {
 			if ($id_session != 0) {
 				$result = Database::query("SELECT course_code FROM $tbl_session_rel_course WHERE id_session='$id_session'",__FILE__,__LINE__);
 
-				$CourseList=array();	
+				$CourseList=array();
 				while ($row = Database::fetch_array($result)) {
 					$CourseList[] = $row['course_code'];
 				}
 
 				foreach ($CourseList as $enreg_course) {
 					Database::query("INSERT INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user) VALUES('$id_session','$enreg_course','$user_id')",__FILE__,__LINE__);
-					// updating the total				
+					// updating the total
 					$sql = "SELECT COUNT(id_user) as nbUsers FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code='$enreg_course'";
 					$rs = Database::query($sql, __FILE__, __LINE__);
 					list($nbr_users) = Database::fetch_array($rs);
-					Database::query("UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'",__FILE__,__LINE__);				
-				}		
+					Database::query("UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'",__FILE__,__LINE__);
+				}
 
 				Database::query("INSERT INTO $tbl_session_rel_user(id_session, id_user) VALUES('$id_session','$user_id')", __FILE__, __LINE__);
 
@@ -349,9 +349,9 @@ if ($form->validate()) {
 
 				Database::query("UPDATE $tbl_session SET nbr_users= $nbr_users WHERE id='$id_session' ", __FILE__, __LINE__);
 			}
-		}		
-			
-		
+		}
+
+
 		$extras = array();
 		foreach ($user as $key => $value) {
 			if (substr($key, 0, 6) == 'extra_') {
@@ -372,12 +372,12 @@ if ($form->validate()) {
 
 			$portal_url = $_configuration['root_web'];
 			if ($_configuration['multiple_access_urls']==true) {
-				$access_url_id = api_get_current_access_url_id();				
+				$access_url_id = api_get_current_access_url_id();
 				if ($access_url_id != -1) {
 					$url = api_get_access_url($access_url_id);
 					$portal_url = $url['url'];
 				}
-			}			
+			}
 			$emailbody=get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".get_lang('YouAreReg')." ". api_get_setting('siteName') ." ".get_lang('Settings')." ". $username ."\n". get_lang('Pass')." : ".stripslashes($password)."\n\n" .get_lang('Address') ." ". api_get_setting('siteName') ." ". get_lang('Is') ." : ".$portal_url."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n". get_lang('Manager'). " ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('emailAdministrator');
 			@api_send_mail($emailto, $emailsubject, $emailbody, $emailheaders);
 		}

+ 59 - 59
main/mySpace/user_import.php

@@ -24,18 +24,18 @@
 ==============================================================================
 *   This tool allows platform admins to add users by uploading a CSV or XML file
 *   This code is inherited from admin/user_import.php
-*   Created on 26 julio 2008  by Julio Montoya gugli100@gmail.com 
+*   Created on 26 julio 2008  by Julio Montoya gugli100@gmail.com
 ==============================================================================
 */
 
 /**
-Checks if a username exist in the DB otherwise it create a "double" 
+Checks if a username exist in the DB otherwise it create a "double"
 ie. if we look into for jmontoya but the user's name already exist we create the user jmontoya2
 the return array will be array(username=>'jmontoya', sufix='2')
 @param string firstname
 @param string lastname
 @param string username
-@return array with the username, the sufix 
+@return array with the username, the sufix
 @author Julio Montoya Armas
 */
 function make_username($firstname, $lastname, $username, $language = null, $encoding = null) {
@@ -69,7 +69,7 @@ function make_username($firstname, $lastname, $username, $language = null, $enco
 Checks if there are repeted users in a given array
 
 @param  array $usernames list of the usernames in the uploaded file
-@param  array $user_array['username'] and $user_array['sufix'] where sufix is the number part in a login i.e -> jmontoya2 
+@param  array $user_array['username'] and $user_array['sufix'] where sufix is the number part in a login i.e -> jmontoya2
 @return array with the $usernames array and the $user_array array
 @author Julio Montoya Armas
 */
@@ -90,22 +90,22 @@ function check_user_in_array($usernames, $user_array) {
 /** checks if the username is already subscribed in a session
  * @param string a given username
  * @param array  the array with the course list codes
- * @param the session id 
- * @return 0 if the user is not subscribed  otherwise it returns the user_id of the given username 
+ * @param the session id
+ * @return 0 if the user is not subscribed  otherwise it returns the user_id of the given username
  * @author Julio Montoya Armas
  */
 function user_available_in_session($username, $course_list, $id_session) {
 	$table_user = Database::get_main_table(TABLE_MAIN_USER);
-	$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);		
+	$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
 
 	foreach($course_list as $enreg_course) {
 		$sql_select = "SELECT u.user_id FROM $tbl_session_rel_course_rel_user rel INNER JOIN $table_user u
 		on (rel.id_user=u.user_id)
-		WHERE rel.id_session='$id_session' AND u.status='5' AND u.username ='$username' AND rel.course_code='$enreg_course'";	
+		WHERE rel.id_session='$id_session' AND u.status='5' AND u.username ='$username' AND rel.course_code='$enreg_course'";
 		//echo "<br>";
 		$rs = Database::query($sql_select, __FILE__, __LINE__);
 		if (Database::num_rows($rs) > 0) {
-			return Database::result($rs, 0, 0); 
+			return Database::result($rs, 0, 0);
 		} else {
 			return 0;
 		}
@@ -113,10 +113,10 @@ function user_available_in_session($username, $course_list, $id_session) {
 }
 
 /**
-This function checks if the users in the uploaded file are not repeted and creates the username if necesary
-i.e if in the file there are an user repeted twice (Julio Montoya / Julio Montoya) and the username fields are empty. IN this case,
-this function will create the usernames based in the first and last name. The users will be jmontoya and jmontoya2
-but if in the database there is a user with a name jmontoya the users registered will be jmontoya2 and jmontoya3.
+This function checks whether some users in the uploaded file repeated and creates unique usernames if necesary.
+A case: Within the file there is an user repeted twice (Julio Montoya / Julio Montoya) and the username fields are empty.
+Then, this function would create unique usernames based on the first and the last name. Two users wiould be created - jmontoya and jmontoya2.
+Of course, if in the database there is a user with the name jmontoya, the newly created two users registered would be jmontoya2 and jmontoya3.
 @param $users list of users
 @author Julio Montoya Armas
 */
@@ -166,7 +166,7 @@ function check_all_usernames($users, $course_list, $id_session) {
  * This functions checks if there are users that are already registered in the DB by other creator than the current coach.
  * @param string a given username
  * @param array  the array with the course list codes
- * @param the session id 
+ * @param the session id
  * @author Julio Montoya Armas
  */
 function get_user_creator($users, $course_list, $id_session) {
@@ -182,7 +182,7 @@ function get_user_creator($users, $course_list, $id_session) {
 		$rs = Database::query($sql, __FILE__, __LINE__);
 		$creator_id = Database::result($rs, 0, 0);
 		// check if we are the creators or not
-		if ($creator_id != '') {	
+		if ($creator_id != '') {
 			if ($creator_id != api_get_user_id()) {
 				$user['error'] = get_lang('UserAlreadyRegisteredByOtherCreator');
 				$errors[] = $user;
@@ -195,7 +195,7 @@ function get_user_creator($users, $course_list, $id_session) {
 
 /**
  * validate the imported data
- * @param list of users 
+ * @param list of users
  */
 function validate_data($users, $id_session = null) {
 	$errors = array();
@@ -252,10 +252,10 @@ function save_data($users, $course_list, $id_session) {
 
 	$sendMail = $_POST['sendMail'] ? 1 : 0;
 
-	// adding users to the platform	
+	// adding users to the platform
 	$new_users = array();
 	foreach ($users as $index => $user) {
-		$user = complete_missing_data($user);		
+		$user = complete_missing_data($user);
 		// coach only will registered users
 		$default_status = '5';
 		if ($user['create'] == '1') {
@@ -267,16 +267,16 @@ function save_data($users, $course_list, $id_session) {
 		}
 		$new_users[] = $user;
 	}
-	//update users list 
+	//update users list
 	$users = $new_users;
-	
+
 	// inserting users
 	$super_list = array();
 	foreach ($course_list as $enreg_course) {
-		$nbr_users = 0;	
-		$new_users = array();	
+		$nbr_users = 0;
+		$new_users = array();
 		foreach ($users as $index => $user) {
-			$userid = $user['id'];		
+			$userid = $user['id'];
 			$sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user) VALUES('$id_session','$enreg_course','$userid')";
 			//echo "<br>";
 			$course_session = array('course' => $enreg_course, 'added' => 1);
@@ -285,25 +285,25 @@ function save_data($users, $course_list, $id_session) {
 			if (Database::affected_rows()) {
 				$nbr_users++;
 			}
-			$new_users[] = $user;	
-		}		
+			$new_users[] = $user;
+		}
 		$super_list[] = $new_users;
 
 		//update the nbr_users field
 		$sql_select = "SELECT COUNT(id_user) as nbUsers FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code='$enreg_course'";
 		$rs = Database::query($sql_select, __FILE__, __LINE__);
 		list($nbr_users) = Database::fetch_array($rs);
-		$sql_update = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'";		
+		$sql_update = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'";
 		Database::query($sql_update , __FILE__, __LINE__);
 
 		$sql_update = "UPDATE $tbl_session SET nbr_users= '$nbr_users' WHERE id='$id_session'";
-		Database::query($sql_update, __FILE__, __LINE__);		
-	}	
-	// we dont delete the users (thoughts while dreaming) 
+		Database::query($sql_update, __FILE__, __LINE__);
+	}
+	// we dont delete the users (thoughts while dreaming)
 	//$sql_delete = "DELETE FROM $tbl_session_rel_user WHERE id_session = '$id_session'";
 	//Database::query($sql_delete,__FILE__, __LINE__);
 
-	$new_users = array();		
+	$new_users = array();
 	foreach ($users as $index => $user) {
 		$userid = $user['id'];
 		$sql_insert = "INSERT IGNORE INTO $tbl_session_rel_user(id_session, id_user) VALUES('$id_session','$userid')";
@@ -312,21 +312,21 @@ function save_data($users, $course_list, $id_session) {
 		$new_users[] = $user;
 	}
 
-	$users = $new_users;	
+	$users = $new_users;
 	$registered_users = get_lang('FileImported').'<br /> Import file results : <br />';
 	// sending the email
 	$addedto = '';
-	if ($sendMail) {					
-		$i = 0;			
-		foreach ($users as $index => $user) {				
+	if ($sendMail) {
+		$i = 0;
+		foreach ($users as $index => $user) {
 			$emailto = api_get_person_name($user['FirstName'], $user['LastName'], null, PERSON_NAME_EMAIL_ADDRESS).' <'.$user['Email'].'>';
 			$emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');
 			$emailbody = get_lang('Dear').' '.api_get_person_name($user['FirstName'], $user['LastName']).",\n\n".get_lang('YouAreReg')." ".api_get_setting('siteName')." ".get_lang('Settings')." $user[UserName]\n".get_lang('Pass')." : $user[Password]\n\n".get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is')." : ".api_get_path('WEB_PATH')." \n\n".get_lang('Problem')."\n\n".get_lang('Formula').",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n".get_lang('Manager')." ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n".get_lang('Email')." : ".api_get_setting('emailAdministrator')."";
 			$emailheaders = 'From: '.api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS).' <'.api_get_setting('emailAdministrator').">\n";
-			$emailheaders .= 'Reply-To: '.api_get_setting('emailAdministrator');		
+			$emailheaders .= 'Reply-To: '.api_get_setting('emailAdministrator');
 			@api_send_mail($emailto, $emailsubject, $emailbody, $emailheaders);
 
-			if (($user['added_at_platform'] == 1  && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) {				
+			if (($user['added_at_platform'] == 1  && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) {
 				if ($user['added_at_platform'] == 1) {
 					$addedto = get_lang('UserCreatedPlatform');
 				} else  {
@@ -335,17 +335,17 @@ function save_data($users, $course_list, $id_session) {
 
 				if ($user['added_at_session'] == 1) {
 					$addedto .= get_lang('UserInSession');
-				}			
+				}
 				$registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />';
 			} else {
-				$addedto = get_lang('UserNotAdded');				
-				$registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />';				
+				$addedto = get_lang('UserNotAdded');
+				$registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />';
 			}
 		}
-	} else {	
-		$i = 0;			
-		foreach ($users as $index => $user) {				
-			if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) {				
+	} else {
+		$i = 0;
+		foreach ($users as $index => $user) {
+			if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) {
 				if ($user['added_at_platform'] == 1) {
 					$addedto = get_lang('UserCreatedPlatform');
 				} else {
@@ -358,10 +358,10 @@ function save_data($users, $course_list, $id_session) {
 
 				$registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />';
 			} else {
-				$addedto = get_lang('UserNotAdded');				
-				$registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />';				
-			}								
-		}		
+				$addedto = get_lang('UserNotAdded');
+				$registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />';
+			}
+		}
 	}
 
 	header('Location: course.php?id_session='.$id_session.'&action=show_message&message='.urlencode($registered_users));
@@ -370,7 +370,7 @@ function save_data($users, $course_list, $id_session) {
 	//header('Location: resume_session.php?id_session='.$id_session);
 }
 /**
- * Read the CSV-file 
+ * Read the CSV-file
  * @param string $file Path to the CSV-file
  * @return array All userinformation read from the file
  */
@@ -407,7 +407,7 @@ function element_end($parser, $data) {
 	global $current_value;
 	$user[$data] = $current_value;
 	switch ($data) {
-		case 'Contact' :			
+		case 'Contact' :
 			$users[] = $user;
 			break;
 		default :
@@ -462,8 +462,8 @@ api_block_anonymous_users();
 $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
 $id_session = '';
 if (isset($_GET["id_session"]) && $_GET["id_session"] != "") {
- 	$id_session = Security::remove_XSS($_GET["id_session"]); 	
-	$interbreadcrumb[] = array ("url" => "session.php", "name" => get_lang('Sessions')); 
+ 	$id_session = Security::remove_XSS($_GET["id_session"]);
+	$interbreadcrumb[] = array ("url" => "session.php", "name" => get_lang('Sessions'));
 	$interbreadcrumb[] = array ("url" => "course.php?id_session=".$_GET["id_session"]."", "name" => get_lang('Course'));
 }
 
@@ -481,28 +481,28 @@ if (api_get_setting('add_users_by_coach') == 'true') {
 			$sql = 'SELECT id_coach FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_session;
 			$rs = Database::query($sql, __FILE__, __LINE__);
 			if (Database::result($rs, 0, 0) != $_user['user_id']) {
-				api_not_allowed(true);  
+				api_not_allowed(true);
 			}
 		} else {
-			api_not_allowed(true);  
-		}	
+			api_not_allowed(true);
+		}
 	}
 } else {
-	api_not_allowed(true);  
+	api_not_allowed(true);
 }
 
 set_time_limit(0);
 
-if ($_POST['formSent'] && $_FILES['import_file']['size'] !== 0) {		
+if ($_POST['formSent'] && $_FILES['import_file']['size'] !== 0) {
 	$file_type = $_POST['file_type'];
 	$id_session = $_POST['id_session'];
 	if ($file_type == 'csv') {
 		$users = parse_csv_data($_FILES['import_file']['tmp_name']);
 	} else {
-		$users = parse_xml_data($_FILES['import_file']['tmp_name']);		
+		$users = parse_xml_data($_FILES['import_file']['tmp_name']);
 	}
 	if (count($users) > 0) {
-		$results = validate_data($users);		
+		$results = validate_data($users);
 		$errors = $results['errors'];
 		$users = $results['users'];
 
@@ -588,7 +588,7 @@ $form->display();
         <b>&lt;FirstName&gt;Julio&lt;/FirstName&gt;</b>
         <b>&lt;Email&gt;info@localhost&lt;/Email&gt;</b>
         &lt;UserName&gt;jmontoya&lt;/UserName&gt;
-        &lt;Password&gt;123456&lt;/Password&gt;        
+        &lt;Password&gt;123456&lt;/Password&gt;
         &lt;OfficialCode&gt;code1&lt;/OfficialCode&gt;
         &lt;PhoneNumber&gt;3141516&lt;/PhoneNumber&gt;
     &lt;/Contact&gt;