Julio Montoya 15 years ago
parent
commit
e96fad74d4

+ 3 - 4
main/gradebook/gradebook_statistics.php

@@ -89,15 +89,14 @@ if (!$displayscore->is_custom()) {
 
 	$stattable= '<br><table class="data_table" cellspacing="0" cellpadding="3">';
 	$stattable .= '<tr><th colspan="4">' . get_lang('Statistics') . '</th></tr>';
-
 	$counter=0;
-	foreach ($keys as $key) {
-		$bar = ($nr_items[$key] / $highest_ratio) * 100;
+	foreach ($keys as $key) {				
+		$bar = ($highest_ratio > 0?($nr_items[$key] / $highest_ratio) * 100:0);
 		$stattable .= '<tr class="row_' . ($counter % 2 == 0 ? 'odd' : 'even') . '">';
 		$stattable .= '<td width="150">' . $key . '</td>';
 		$stattable .= '<td width="550"><img src="../img/bar_1u.gif" width="' . $bar . '%" height="10"/></td>';
 		$stattable .= '<td align="right">' . $nr_items[$key] . '</td>';
-		$stattable .= '<td align="right"> ' . round(($nr_items[$key] / $resultcount) * 100,2) . '%</td>';
+		$stattable .= '<td align="right"> ' . ($resultcount > 0 ?round(($nr_items[$key] / $resultcount) * 100,2):0) . '%</td>';		
 		$counter++;
 	}
 	$stattable .= '</tr></table>';

+ 4 - 2
main/inc/lib/course.lib.php

@@ -534,8 +534,9 @@ class CourseManager {
 	 */
 	public static function get_real_course_list() {
 		$sql_result = Database::query("SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE)." WHERE target_course_code IS NULL");
+		$real_course_list = array();
 		while ($result = Database::fetch_array($sql_result)) {
-			$real_course_list[] = $result;
+			$real_course_list[$result['code']] = $result;
 		}
 		return $real_course_list;
 	}
@@ -545,8 +546,9 @@ class CourseManager {
 	 */
 	public static function get_virtual_course_list() {
 		$sql_result = Database::query("SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE)." WHERE target_course_code IS NOT NULL");
+		$virtual_course_list = array();
 		while ($result = Database::fetch_array($sql_result)) {
-			$virtual_course_list[] = $result;
+			$virtual_course_list[$result['code']] = $result;
 		}
 		return $virtual_course_list;
 	}

+ 1 - 1
main/inc/lib/sessionmanager.lib.php

@@ -924,7 +924,7 @@ class SessionManager {
 		}
 		$sql_result = Database::query($sql_query);
 		while ($result = Database::fetch_array($sql_result)) {
-			$return_array[] = $result;
+			$return_array[$result['id']] = $result;
 		}
 		return $return_array;
 	}

+ 2 - 2
main/install/index.php

@@ -218,7 +218,7 @@ if ($_POST['step2_install'] || $_POST['step2_update_8'] || $_POST['step2_update_
 
 if ($installType == 'update' && in_array($my_old_version, $update_from_version_8)) {
 	// This is the main configuration file of the system before the upgrade.
-	include_once api_get_path(CONFIGURATION_PATH).'configuration.php';
+	include api_get_path(CONFIGURATION_PATH).'configuration.php'; // Don't change to include_once
 }
 
 if (!isset($_GET['running'])) {
@@ -709,7 +709,7 @@ if ($_POST['step2']) {
                 include 'update-files-1.8.6.1-1.8.6.2.inc.php';
             case '1.8.6.2':
                 include 'update-db-1.8.6.2-1.8.7.inc.php';
-                //include 'update-files-1.8.6.2-1.8.7.inc.php';
+                include 'update-files-1.8.6.2-1.8.7.inc.php';
 
                 // After database conversion to UTF-8, new encoding initialization is necessary
                 // to be used for the next (hypothetical) upgrade 1.8.7 -> 1.8.7.1.

+ 8 - 4
main/install/update-files-1.8.6.2-1.8.7.inc.php

@@ -17,6 +17,8 @@ if (defined('SYSTEM_INSTALLATION')) {
 	// Edit the configuration file
 	$file = file('../inc/conf/configuration.php');
 	$fh = fopen('../inc/conf/configuration.php', 'w');
+	$found_version_old = false;
+	$found_stable_old = false;
 	$found_version = false;
 	$found_stable = false;
 	$found_software_name = false;
@@ -24,14 +26,16 @@ if (defined('SYSTEM_INSTALLATION')) {
 	foreach ($file as $line) {
 		$ignore = false;
 		if (stripos($line, '$_configuration[\'dokeos_version\']') !== false) {
-			$found_version = true;
-			$line = '$_configuration[\'system_version\'] = \''.$new_version.'\';'."\r\n";
+			$found_version_old = true;
+			$line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
+			$ignore = true;
 		} elseif (stripos($line, '$_configuration[\'system_version\']') !== false) {
 			$found_version = true;
 			$line = '$_configuration[\'system_version\'] = \''.$new_version.'\';'."\r\n";
 		} elseif (stripos($line, '$_configuration[\'dokeos_stable\']') !== false) {
-			$found_stable = true;
-			$line = '$_configuration[\'system_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
+			$found_stable_old = true;
+			$line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
+			$ignore = true;
 		} elseif (stripos($line, '$_configuration[\'system_stable\']') !== false) {
 			$found_stable = true;
 			$line = '$_configuration[\'system_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";

+ 38 - 34
main/mySpace/course.php

@@ -111,7 +111,16 @@ if ($show_import_icon) {
 }
 
 if (!api_is_drh()) {	
-	$a_courses = Tracking :: get_courses_followed_by_coach($_user['user_id'], $id_session);
+	if (api_is_platform_admin()) {
+		if (empty($id_session)) {			
+			$courses = CourseManager::get_real_course_list();			
+		} else {
+			$courses = Tracking::get_courses_list_from_session($id_session);
+		}
+	} else {
+		$courses = Tracking::get_courses_followed_by_coach($_user['user_id'], $id_session);
+	}	
+	$a_courses = array_keys($courses);
 } 
 
 $nb_courses = count($a_courses);
@@ -143,49 +152,44 @@ $csv_header[] = array(
 if (is_array($a_courses)) {
 	foreach ($a_courses as $course_code) {
 		$nb_students_in_course = 0;
-		$a_students = array();
 		$course = CourseManager :: get_course_information($course_code);
 		$avg_assignments_in_course = $avg_messages_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = 0;
 
-		// students subscribed to the course throw a session
-		if (api_get_setting('use_session_mode') == 'true') {
-			$sql = 'SELECT id_user as user_id
-					FROM '.$tbl_session_course_user.'
-					WHERE course_code="'.Database :: escape_string($course_code).'"
-					AND id_session='.$id_session;
-			$rs = Database::query($sql);
-
-			while ($row = Database::fetch_array($rs)) {
-				if (!in_array($row['user_id'], $a_students)) {
-					$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_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_assignments_in_course += Tracking :: count_student_assignments ($row['user_id'], $course_code);
-					$a_students[] = $row['user_id'];
-				}
-			}
-		}
-		if ($nb_students_in_course > 0) {
+		// students directly subscribed to the course			
+		if (empty($session_id)) {
+			$sql = "SELECT user_id FROM $tbl_user_course as course_rel_user WHERE course_rel_user.status='5' AND course_rel_user.course_code='$course_code'";
+		} else {
+			$sql = "SELECT id_user as user_id FROM $tbl_session_course_user srcu WHERE  srcu. course_code='$course_code' AND id_session = '$id_session' AND srcu.status<>2";			
+		}						
+
+		$rs = Database::query($sql);			
+		$users = array();
+		while ($row = Database::fetch_array($rs)) { $users[] = $row['user_id']; }
+		
+		if (count($users) > 0) {
+			$nb_students_in_course = count($users);
+			// tracking datas
+			$avg_progress_in_course = Tracking :: get_avg_student_progress ($users, $course_code, array(), $id_session);
+			$avg_score_in_course = Tracking :: get_avg_student_score ($users, $course_code, array(), $id_session);
+			$avg_time_spent_in_course = Tracking :: get_time_spent_on_the_course ($users, $course_code, $id_session);
+			$messages_in_course = Tracking :: count_student_messages ($users, $course_code, $id_session);
+			$assignments_in_course = Tracking :: count_student_assignments ($users, $course_code, $id_session);
+			
 			$avg_time_spent_in_course = api_time_to_hms($avg_time_spent_in_course / $nb_students_in_course);
 			$avg_progress_in_course = round($avg_progress_in_course / $nb_students_in_course, 2);
 			$avg_score_in_course = round($avg_score_in_course / $nb_students_in_course, 2);
-			//$avg_messages_in_course = round($avg_messages_in_course / $nb_students_in_course, 2);
-			//$avg_assignments_in_course = round($avg_assignments_in_course / $nb_students_in_course, 2);
+			
 		} else {
 			$avg_time_spent_in_course = null;
 			$avg_progress_in_course = null;
 			$avg_score_in_course = null;
-			$avg_messages_in_course = null;
-			$avg_assignments_in_course = null;
+			$messages_in_course = null;
+			$assignments_in_course = null;
 		}
 		
 		$tematic_advance_progress = 0;
 		$course_description = new CourseDescription();
-		$course_description->set_session_id(0);
+		$course_description->set_session_id($id_session);
 		$tematic_advance = $course_description->get_data_by_description_type(8, $course_code);
 
 		if (!empty($tematic_advance)) {
@@ -202,8 +206,8 @@ if (is_array($a_courses)) {
 		$table_row[] = $tematic_advance_progress;
 		$table_row[] = is_null($avg_progress_in_course) ? '-' : $avg_progress_in_course.'%';
 		$table_row[] = is_null($avg_score_in_course) ? '-' : $avg_score_in_course.'%';
-		$table_row[] = is_null($avg_messages_in_course)?'-':$avg_messages_in_course;
-		$table_row[] = is_null($avg_assignments_in_course)?'-':$avg_assignments_in_course;
+		$table_row[] = is_null($messages_in_course)?'-':$messages_in_course;
+		$table_row[] = is_null($assignments_in_course)?'-':$assignments_in_course;
 		$table_row[] = '<a href="../tracking/courseLog.php?cidReq='.$course_code.'&studentlist=true&id_session='.$id_session.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>';
 
 		$csv_content[] = array (
@@ -213,8 +217,8 @@ if (is_array($a_courses)) {
 			$tematic_advance_csv,
 			is_null($avg_progress_in_course) ? null : $avg_progress_in_course.'%',
 			is_null($avg_score_in_course) ? null : $avg_score_in_course.'%',
-			$avg_messages_in_course,
-			$avg_assignments_in_course,
+			$messages_in_course,
+			$assignments_in_course,
 		);
 
 		$table -> addRow($table_row, 'align="right"');

+ 12 - 6
main/mySpace/session.php

@@ -103,8 +103,12 @@ if (api_is_drh()) {
 	}
 	echo '</div>';
 		
-} else {
-	$a_sessions = Tracking :: get_sessions_coached_by_user($id_coach);
+} else {		
+	if (api_is_platform_admin()) {
+		$a_sessions = SessionManager::get_sessions_list();
+	} else {
+		$a_sessions = Tracking :: get_sessions_coached_by_user($id_coach);
+	}	
 }
 
 $nb_sessions = count($a_sessions);
@@ -122,10 +126,10 @@ if ($nb_sessions > 0) {
 			  </div>';
 	}
 	$table = new SortableTable('tracking', 'count_sessions_coached');
-	$table -> set_header(0, get_lang('Title'));
-	//$table -> set_header(1, get_lang('Status'));
-	$table -> set_header(1, get_lang('Date'));
-	$table -> set_header(2, get_lang('Details'), false);
+	$table->set_header(0, get_lang('Title'));
+	$table->set_header(1, get_lang('Date'));
+	$table->set_header(2, get_lang('NbCoursesPerSession'));
+	$table->set_header(3, get_lang('Details'), false);
 
 	$all_data = array();
 	foreach ($a_sessions as $session) {
@@ -138,6 +142,8 @@ if ($nb_sessions > 0) {
 		} else {
 			$row[] = ' - ';
 		}
+		
+		$row[] = count(Tracking::get_courses_list_from_session($session['id']));
 
 		if ($export_csv) {
 			$csv_content[] = $row;

+ 1 - 1
plugin/dashboard/block_course/block_course.class.php

@@ -144,7 +144,7 @@ class BlockCourse extends Block {
 			}
 			if (count($users) > 0) {
 				$nb_students_in_course = count($users);
-				$avg_time_spent_in_course  = api_time_to_hms(Tracking::get_time_spent_on_the_course($users, $course_code));
+				$avg_time_spent_in_course  = api_time_to_hms(Tracking::get_time_spent_on_the_course($users, $course_code)/$nb_students_in_course);
 			} else {
 				$avg_time_spent_in_course = null;
 			}

+ 7 - 3
plugin/dashboard/block_session/block_session.class.php

@@ -86,7 +86,8 @@ class BlockSession extends Block {
 			$sessions_table = '<table class="data_table" width:"95%">';
  			$sessions_table .= '<tr>								
 									<th >'.get_lang('Title').'</th>
-									<th >'.get_lang('Date').'</th>								
+									<th >'.get_lang('Date').'</th>
+									<th width="100px">'.get_lang('NbCoursesPerSession').'</th>							
 								</tr>';
 			$i = 1;
 			foreach ($sessions as $session) {
@@ -99,12 +100,15 @@ class BlockSession extends Block {
 					$date = ' - ';
 				}
 	 			
+	 			$count_courses_in_session = count(Tracking::get_courses_list_from_session($session_id));
+	 			
 				if ($i%2 == 0) $class_tr = 'row_odd';
 	    		else $class_tr = 'row_even';
 
 				$sessions_table .= '<tr class="'.$class_tr.'">
-										<td align="right">'.$title.'</td>
-										<td align="right">'.$date.'</td>										
+										<td>'.$title.'</td>
+										<td align="center">'.$date.'</td>
+										<td align="center">'.$count_courses_in_session.'</td>										
 								   </tr>';
 				$i++;
 			}