Эх сурвалжийг харах

added course progress tool - partial BT#578

Cristian Fasanando 15 жил өмнө
parent
commit
a215d192e1

+ 0 - 1
main/attendance/attendance_list.php

@@ -17,7 +17,6 @@ if (api_is_allowed_to_edit(null, true)) {
 	}
 	echo '<div class="actions" style="margin-bottom:30px">';
 	echo '<a href="index.php?'.api_get_cidreq().$param_gradebook.'&action=attendance_add">'.Display::return_icon('adherir.png',get_lang('CreateANewAttendance')).' '.get_lang('CreateANewAttendance').'</a>';	
-	echo '<a href="index.php?'.api_get_cidreq().$param_gradebook.'&action=thematic_details">'.Display::return_icon('defaut.gif',get_lang('ThematicControl')).' '.get_lang('ThematicControl').'</a>';
 	echo '</div>';
 }
 $table = new SortableTable('attendance_list', array('Attendance', 'get_number_of_attendances'), array('Attendance', 'get_attendance_data'), $default_column);

+ 2 - 1
main/course_info/infocours.php

@@ -235,7 +235,8 @@ if (is_settings_editable()) {
 // THEMATIC SETTINGS
 $form->addElement('html', '<div class="sectiontitle" style="margin-top: 40px;"><a href="#header" style="float:right;">'.Display::return_icon('top.gif', get_lang('Top')).'</a><a name="chatsettings" id="chatsettings"></a>'.Display::return_icon('attendance.gif', get_lang('ConfigChat')).' '.get_lang('ThematicAdvanceConfiguration').'</div>');
 $form->addElement('radio', 'display_info_advance_inside_homecourse', get_lang('InfoAboutAdvanceInsideHomeCourse'), get_lang('DisplayAboutLastDoneAdvance'), 1);
-$form->addElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DisplayAboutNextAdvanceNotDone'), 0);
+$form->addElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DisplayAboutNextAdvanceNotDone'), 2);
+$form->addElement('radio', 'display_info_advance_inside_homecourse', null, get_lang('DoNotDisplayAnyAdvance'), 0);
 
 
 $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');

+ 217 - 0
main/course_progress/index.php

@@ -0,0 +1,217 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+* Template (front controller in MVC pattern) used for distpaching to the controllers depend on the current action  
+* @author Christian Fasanando <christian1827@gmail.com>
+* @package chamilo.course_progress
+*/
+
+// name of the language file that needs to be included
+$language_file = array ('course_description', 'pedaSuggest', 'userInfo', 'admin');
+
+// including files 
+require_once '../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'attendance.lib.php';
+require_once api_get_path(LIBRARY_PATH).'thematic.lib.php';
+require_once api_get_path(LIBRARY_PATH).'app_view.php';
+//require_once 'attendance_controller.php';
+require_once 'thematic_controller.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(LIBRARY_PATH).'sortabletable.class.php';
+require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
+//require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
+
+// current section
+$this_section = SECTION_COURSES;
+
+// protect a course script
+api_protect_course_script(true);
+
+
+// defining constants
+define('ADD_THEMATIC_PLAN', 6);
+
+// get actions
+$actions = array('thematic_details', 'thematic_list', 'thematic_add', 'thematic_edit', 'thematic_delete', 'moveup', 'movedown', 
+				 'thematic_plan_list', 'thematic_plan_add', 'thematic_plan_edit', 'thematic_plan_delete', 
+				 'thematic_advance_list', 'thematic_advance_add', 'thematic_advance_edit', 'thematic_advance_delete');
+
+$action  = 'thematic_details';
+if (isset($_GET['action']) && in_array($_GET['action'],$actions)) {
+	$action = $_GET['action'];
+}
+
+if (isset($_POST['action']) && $_POST['action'] == 'thematic_delete_select') {
+	$action = 'thematic_delete_select';
+}
+
+if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
+	$action = 'thematic_details';
+}
+
+if ($action == 'thematic_details' || $action == 'thematic_list') {
+	$_SESSION['thematic_control'] = $action;
+}
+
+// get thematic id
+if (isset($_GET['thematic_id'])) {
+	$thematic_id = intval($_GET['thematic_id']);
+}
+
+// get thematic plan description type
+if (isset($_GET['description_type'])) {
+	$description_type = intval($_GET['description_type']);
+}
+
+// instance thematic object for using like library here
+$thematic = new Thematic();
+
+// thematic controller object
+$thematic_controller = new ThematicController();
+
+if (!empty($thematic_id)) {
+	// thematic data by id
+	$thematic_data = $thematic->get_thematic_list($thematic_id);
+}
+
+// get default thematic plan title
+$default_thematic_plan_title = $thematic->get_default_thematic_plan_title();
+
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>';
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.js" type="text/javascript" language="javascript"></script>';
+$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css" type="text/css" media="projection, screen">';
+$htmlHeadXtra[] = '<script language="javascript">
+		
+		function datetime_by_attendance(selected_value) {
+			$.ajax({
+				contentType: "application/x-www-form-urlencoded",
+				beforeSend: function(objeto) {},
+				type: "POST",
+				url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=get_datetime_by_attendance",
+				data: "attendance_id="+selected_value,
+				success: function(datos) {
+				 $("#div_datetime_attendance").html(datos);
+				}
+			});
+		}
+		
+		function update_done_thematic_advance(selected_value) {
+			$.ajax({
+				contentType: "application/x-www-form-urlencoded",
+				beforeSend: function(objeto) {},
+				type: "GET",
+				url: "'.api_get_path(WEB_AJAX_PATH).'thematic.ajax.php?a=update_done_thematic_advance&thematic_advance_id="+selected_value,
+				data: "thematic_advance_id="+selected_value,
+				success: function(datos) {
+				 $("#div_result").html(datos);
+				}
+			});
+			
+			// clean all radios
+			for (var i=0; i<$("input[@name=\'done_thematic\']").length;i++) {
+				var id_radio_thematic = $("input[@name=\'done_thematic\']").get(i).id;								
+				$("#td_"+id_radio_thematic).css({"background-color":"#FFF"});				
+			}
+			
+			// set background to previous radios 
+			for (var i=0; i<$("input[@name=\'done_thematic\']").length;i++) {
+				var id_radio_thematic = $("input[@name=\'done_thematic\']").get(i).id;								
+				$("#td_"+id_radio_thematic).css({"background-color":"#E5EDF9"});
+				if ($("input[@name=\'done_thematic\']").get(i).value == selected_value) {
+					break;
+				}
+			}		
+
+		}
+				
+		function check_per_attendance(obj) {	
+			if (obj.checked == true) {
+				document.getElementById(\'div_datetime_by_attendance\').style.display=\'block\';
+				document.getElementById(\'div_custom_datetime\').style.display=\'none\';
+			} else {
+				document.getElementById(\'div_datetime_by_attendance\').style.display=\'none\';
+				document.getElementById(\'div_custom_datetime\').style.display=\'block\';
+			}			
+		}
+
+		function check_per_custom_date(obj) {
+			if (obj.checked == true) {
+				document.getElementById(\'div_custom_datetime\').style.display=\'block\';
+				document.getElementById(\'div_datetime_by_attendance\').style.display=\'none\';
+			} else {
+				document.getElementById(\'div_custom_datetime\').style.display=\'none\';
+				document.getElementById(\'div_datetime_by_attendance\').style.display=\'block\';
+			}			
+		}
+
+		</script>';
+
+
+// interbreadcrumbs
+//$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_details'.$param_gradebook.$student_param, 'name' => get_lang('ToolAttendance'));
+//if ($action == 'attendance_add') {
+	//$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('CreateANewAttendance'));
+//}
+if ($action == 'thematic_list') {
+	$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));
+}
+if ($action == 'thematic_add') {
+	$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
+	$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicSection'));	
+}
+if ($action == 'thematic_edit') {
+	$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
+	$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('EditThematicSection'));	
+}
+if ($action == 'thematic_details') {
+	$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('ThematicControl'));	
+} 
+if ($action == 'thematic_plan_list' || $action == 'thematic_plan_delete') {	
+	$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));	
+	$interbreadcrumb[] = array ('url' => '#', 'name' => $thematic_data['title'].':'.get_lang('ThematicPlan'));	
+}
+if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
+	$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
+	$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$thematic_id, 'name' => $thematic_data['title'].':'.get_lang('ThematicPlan'));	
+	if ($description_type >= ADD_THEMATIC_PLAN) {
+		$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewBloc'));
+	} else {
+		$interbreadcrumb[] = array ('url' => '#', 'name' => $default_thematic_plan_title[$description_type]);	
+	}
+}
+if ($action == 'thematic_advance_list') {
+	$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
+	$interbreadcrumb[] = array ('url' => '#', 'name' => $thematic_data['title'].':'.get_lang('ThematicAdvance'));
+}
+if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
+	$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action='.$_SESSION['thematic_control'], 'name' => get_lang('ThematicControl'));
+	$interbreadcrumb[] = array ('url' => 'index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$thematic_id, 'name' => $thematic_data['title'].':'.get_lang('ThematicAdvance'));
+	$interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('NewThematicAdvance'));
+}
+
+// distpacher actions to controller
+switch ($action) {		
+	case 'thematic_add'				:
+	case 'thematic_edit'			:
+	case 'thematic_delete'			:	
+	case 'thematic_delete_select'	:
+	case 'thematic_details'			:
+	case 'moveup'					:
+	case 'movedown'					:
+	case 'thematic_list'			:	$thematic_controller->thematic($action);
+										break;
+	case 'thematic_plan_list'		:
+	case 'thematic_plan_add'		:
+	case 'thematic_plan_edit'		:	
+	case 'thematic_plan_delete'		:	$thematic_controller->thematic_plan($action);
+										break;
+	case 'thematic_advance_list'	:
+	case 'thematic_advance_add'		:
+	case 'thematic_advance_edit'	:
+	case 'thematic_advance_delete'	:	$thematic_controller->thematic_advance($action);
+										break;
+}
+
+?>

+ 29 - 0
main/course_progress/layout.php

@@ -0,0 +1,29 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+* Layout (principal view) used for structuring other views  
+* @author Christian Fasanando <christian1827@gmail.com>
+* @package chamilo.course_progress
+*/
+
+// protect a course script
+api_protect_course_script(true);
+
+// Header
+$tool = TOOL_COURSE_PROGRESS;
+Display :: display_header('');
+
+// Introduction section
+Display::display_introduction_section($tool);
+
+// Tracking
+event_access_tool($tool);
+
+// Display
+echo $content;
+
+// Footer
+Display :: display_footer();
+
+?>

+ 173 - 0
main/course_progress/thematic.php

@@ -0,0 +1,173 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+* View (MVC patter) for thematic control 
+* @author Christian Fasanando <christian1827@gmail.com>
+* @package chamilo.course_progress
+*/
+
+// protect a course script
+api_protect_course_script(true);
+
+if (api_is_allowed_to_edit(null, true)) {
+	echo '<div class="actions" style="margin-bottom:30px">';
+	echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_details">'.Display::return_icon('view_table.gif',get_lang('ThematicDetails')).' '.get_lang('ThematicDetails').'</a>';	
+	echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_list">'.Display::return_icon('view_list.gif',get_lang('ThematicList')).' '.get_lang('ThematicList').'</a>';
+	if ($action == 'thematic_list') {
+		echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add">'.Display::return_icon('introduction_add.gif',get_lang('NewThematicSection')).' '.get_lang('NewThematicSection').'</a>';
+	}
+	echo '</div>';
+}
+
+if ($action == 'thematic_list') {
+	
+	$table = new SortableTable('thematic_list', array('Thematic', 'get_number_of_thematics'), array('Thematic', 'get_thematic_data'));
+	$table->set_additional_parameters($parameters);
+	$table->set_header(0, '', false, array('style'=>'width:20px;'));
+	$table->set_header(1, get_lang('Title'), false );	
+	if (api_is_allowed_to_edit(null, true)) {
+		$table->set_header(2, get_lang('Actions'), false,array('style'=>'text-align:center;width:40%;'));
+		$table->set_form_actions(array ('thematic_delete_select' => get_lang('DeleteAllThematics')));	
+	}
+	
+	echo '<div><strong>'.get_lang('ThematicList').'</strong></div><br />';	
+	$table->display();
+	
+} else if ($action == 'thematic_details') {
+
+	// display title
+	if (!empty($thematic_id)) {
+		echo '<div><strong>'.$thematic_data[$thematic_id]['title'].': '.get_lang('Details').'</strong></div><br />';							
+	} else {
+		echo '<div><strong>'.get_lang('ThematicDetails').'</strong></div><br />';	
+		// display information
+		$message = '<strong>'.get_lang('Information').'</strong><br />';
+		$message .= get_lang('ThematicDetailsDescription');	
+		Display::display_normal_message($message, false);
+		echo '<br />';			
+	}
+	
+	// display thematic data
+	if (!empty($thematic_data)) {
+		
+		// display progress
+		if (!empty($thematic_id)) {
+			echo '<div style="text-align:right;">'.get_lang('Progress').': <strong>'.$total_average_of_advances.'</strong>%</div><br />';
+		} else {
+			echo '<div style="text-align:right;">'.get_lang('Progress').': <strong><span id="div_result">'.$total_average_of_advances.'</span></strong>%</div><br />';
+		}
+		
+		echo '<table width="100%" class="data_table">';	
+		echo '<tr><th width="35%">'.get_lang('Thematic').'</th><th width="30%">'.get_lang('ThematicPlan').'</th><th width="25%">'.get_lang('ThematicAdvance').'</th></tr>';
+	
+			foreach ($thematic_data as $thematic) {			
+				echo '<tr>';
+				
+				// display thematic data		
+				echo '<td><div><strong>'.$thematic['title'].'</strong></div><div>'.$thematic['content'].'</div></td>';
+				
+				// display thematic plan data
+				echo '<td>';					
+					if (api_is_allowed_to_edit(null, true)) {
+						echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&origin=thematic_details&action=thematic_plan_list&thematic_id='.$thematic['id'].'">'.Display::return_icon('lp_quiz.png',get_lang('EditThematicPlan'),array('style'=>'vertical-align:middle')).'</a></div><br />';
+					}
+					if (!empty($thematic_plan_data[$thematic['id']])) {
+						foreach ($thematic_plan_data[$thematic['id']] as $thematic_plan) {
+							echo '<div><strong>'.$thematic_plan['title'].'</strong></div><div>'.$thematic_plan['description'].'</div>'; 
+						}
+					} else {
+						echo '<div><em>'.get_lang('StillDoNotHaveAThematicPlan').'</em></div>';
+					}				
+				echo '</td>';
+				
+				// display thematic advance data
+				echo '<td>';					
+					if (api_is_allowed_to_edit(null, true)) {
+						echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&origin=thematic_details&action=thematic_advance_list&thematic_id='.$thematic['id'].'">'.Display::return_icon('lp_quiz.png',get_lang('EditThematicAdvance'),array('style'=>'vertical-align:middle')).'</a></div><br />';
+					}					
+					echo '<table width="100%">';
+						if (!empty($thematic_advance_data[$thematic['id']])) {						
+							foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) {
+								echo '<tr>';
+								echo '<td width="90%">';
+									echo '<div><strong>'.api_convert_and_format_date($thematic_advance['start_date'], DATE_TIME_FORMAT_LONG, date_default_timezone_get()).'</strong></div>';
+									echo '<div>'.$thematic_advance['content'].'</div>';
+									echo '<div>'.get_lang('DurationInHours').' : '.$thematic_advance['duration'].'</div>';
+								echo '</td>';
+								if (empty($thematic_id) && api_is_allowed_to_edit(null, true)) {
+									$checked = '';
+									if ($last_done_thematic_advance == $thematic_advance['id']) {
+										$checked = 'checked';
+									}
+									$style = '';
+									if ($thematic_advance['done_advance'] == 1) {
+										$style = ' style="background-color:#E5EDF9" ';
+									} else {
+										$style = ' style="background-color:#fff" ';
+									}														
+									echo '<td id="td_done_thematic_'.$thematic_advance['id'].'" '.$style.'><center><input type="radio" id="done_thematic_'.$thematic_advance['id'].'" name="done_thematic" value="'.$thematic_advance['id'].'" '.$checked.' onclick="update_done_thematic_advance(this.value)"></center></td>';									
+								} else {
+									if ($thematic_advance['done_advance'] == 1) {
+										echo '<td><center>'.get_lang('Done').'</center></td>';	
+									} else {
+										echo '<td><center>-</center></td>';
+									}									
+								}
+								echo '</tr>';							 
+							}
+						} else {
+							echo '<tr><td width="90%"><div><em>'.get_lang('StillDoNotHaveAThematicAdvance').'</em></div></td><td>&nbsp;</td>';
+						}									
+					echo '</table>';							
+				echo '</td>';				
+				echo '</tr>';				
+			}
+		echo '</table>';
+	} else {
+		echo '<div><em>'.get_lang('ThereIsStillAthematicSection').'</em></div>';
+	}
+	
+} else if ($action == 'thematic_add' || $action == 'thematic_edit') {
+
+	if (!$error) {
+		$token = md5(uniqid(rand(),TRUE));
+		$_SESSION['thematic_token'] = $token;
+	}
+	
+	$header_form = get_lang('NewThematicSection');
+	if ($action == 'thematic_edit') {
+		$header_form = get_lang('EditThematicSection');	
+	}
+	
+	// display form
+	$form = new FormValidator('thematic_add','POST','index.php?action=thematic_list&'.api_get_cidreq(),'','style="width: 100%;"');
+	
+	$form->addElement('header', '', $header_form);	
+	$form->addElement('hidden', 'thematic_token',$token);
+	$form->addElement('hidden', 'action', $action);
+	
+	if (!empty($thematic_id)) {
+		$form->addElement('hidden', 'thematic_id',$thematic_id);
+	}
+		
+	$form->add_textfield('title', get_lang('Title'), true, array('size'=>'50'));
+	$form->add_html_editor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '250'));	
+	$form->addElement('html','<div class="clear" style="margin-top:50px;"></div>');
+	$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
+	
+	if (!empty($thematic_data)) {
+		// set default values
+		$default['title'] = $thematic_data['title'];
+		$default['content'] = $thematic_data['content'];	
+		$form->setDefaults($default);
+	}
+	
+	// error messages
+	if ($error) {	
+		Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);	
+	}
+	$form->display();
+		
+} 
+?>

+ 136 - 0
main/course_progress/thematic_advance.php

@@ -0,0 +1,136 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+* View (MVC patter) for thematic advance 
+* @author Christian Fasanando <christian1827@gmail.com>
+* @package chamilo.course_progress
+*/
+
+// protect a course script
+api_protect_course_script(true);
+
+if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') {
+
+	$header_form = get_lang('NewThematicAdvance');
+	if ($action == 'thematic_advance_edit') {
+		$header_form = get_lang('EditThematicAdvance');
+	}
+
+	if (!$error) {
+		$token = md5(uniqid(rand(),TRUE));
+		$_SESSION['thematic_advance_token'] = $token;
+	}
+
+	// display form
+	$form = new FormValidator('thematic_advance','POST','index.php?action=thematic_advance_list&thematic_id='.$thematic_id.'&'.api_get_cidreq(),'','style="width: 100%;"');
+	$form->addElement('header', '', $header_form);	
+	$form->addElement('hidden', 'thematic_advance_token',$token);
+	$form->addElement('hidden', 'action', $action);
+	
+	if (!empty($thematic_advance_id)) {
+		$form->addElement('hidden', 'thematic_advance_id',$thematic_advance_id);
+	}
+	if (!empty($thematic_id)) {
+		$form->addElement('hidden', 'thematic_id',$thematic_id);
+	}
+		
+	$radios = array();
+	$radios[] = FormValidator::createElement('radio', 'start_date_type', null, get_lang('StartDateFromAnAttendance'),'1',array('onclick' => 'check_per_attendance(this)', 'id'=>'from_attendance'));
+	$radios[] = FormValidator::createElement('radio', 'start_date_type', null, get_lang('StartDateCustom'),'2',array('onclick' => 'check_per_custom_date(this)', 'id'=>'custom_date'));
+	$form->addGroup($radios, null, get_lang('StartDateOptions'));
+
+	if (isset($thematic_advance_data['attendance_id']) && $thematic_advance_data['attendance_id'] == 0) {
+		$form->addElement('html', '<div id="div_custom_datetime" style="display:block">');				
+	} else { 
+		$form->addElement('html', '<div id="div_custom_datetime" style="display:none">');
+	}	
+	
+	$form->addElement('datepicker', 'custom_start_date', get_lang('StartDate'), array('form_name'=>'thematic_advance'));		
+	$form->addElement('html', '</div>');	
+	
+	if (isset($thematic_advance_data['attendance_id']) && $thematic_advance_data['attendance_id'] == 0) {
+		$form->addElement('html', '<div id="div_datetime_by_attendance" style="display:none">');	
+	} else {
+		$form->addElement('html', '<div id="div_datetime_by_attendance" style="display:block">');	
+	}
+
+	if (count($attendance_select) > 1) {	
+		$form->addElement('select', 'attendance_select', get_lang('Attendances'), $attendance_select, array('id' => 'id_attendance_select', 'onchange' => 'datetime_by_attendance(this.value)'));
+	} else {
+		$form->addElement('html', '<div class="row"><div class="label">'.get_lang('Attendances').'</div><div class="formw"><strong><em>'.get_lang('ThereAreNoAttendancesInsideCourse').'</em></strong></div></div>');
+	}
+	
+	$form->addElement('html', '<div id="div_datetime_attendance">');
+		if (!empty($calendar_select)) {
+			$form->addElement('select', 'start_date_by_attendance', get_lang('StartDate'), $calendar_select);
+		}
+	$form->addElement('html', '</div>');
+		
+	$form->addElement('html', '</div>');
+
+	$form->add_textfield('duration_in_hours', get_lang('DurationInHours'), false, array('size'=>'3'));
+	
+	$form->add_html_editor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '150'));	
+	$form->addElement('html','<div class="clear" style="margin-top:50px;"></div>');
+	$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
+	
+	$default['start_date_type'] = 1;	
+	$default['custom_start_date'] = date('d-F-Y 00:00');
+	if (!empty($thematic_advance_data)) {
+
+		// set default values
+		$default['content'] = $thematic_advance_data['content'];
+		$default['duration_in_hours'] = $thematic_advance_data['duration'];
+		if (empty($thematic_advance_data['attendance_id'])) {
+			$default['start_date_type'] = 2;
+			$default['custom_start_date'] = date('d-F-Y H:i', api_strtotime(api_get_local_time($thematic_advance_data['start_date'])));
+		} else {
+			$default['start_date_type'] = 1;			
+			if (!empty($calendar_select)) {
+				$default['start_date_by_attendance'] = $thematic_advance_data['start_date'];	
+			}			
+			$default['attendance_select'] = $thematic_advance_data['attendance_id'];
+		}		
+	}
+	$form->setDefaults($default);
+	
+	// error messages
+	$msg_error = '';
+	if ($start_date_error) {	
+		$msg_error .= get_lang('YouMustSelectAtleastAStartDate').'<br />';		
+	}
+	if ($duration_error) {	
+		$msg_error .= get_lang('DurationInHoursMustBeNumeric');		
+	}
+	
+	if (!empty($msg_error)) {
+		Display::display_error_message($msg_error,false);	
+	}
+
+	$form->display();
+	
+} else if ($action == 'thematic_advance_list') {
+	
+	if (api_is_allowed_to_edit(null, true)) {		
+		echo '<div class="actions" style="margin-bottom:30px">';
+		echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_add&thematic_id='.$thematic_id.'">'.Display::return_icon('template_add.gif',get_lang('NewThematicAdvance')).' '.get_lang('NewThematicAdvance').'</a>';			
+		echo '</div>';
+	}
+	
+	// thematic advance list		
+	$table = new SortableTable('thematic_advance_list', array('Thematic', 'get_number_of_thematic_advances'), array('Thematic', 'get_thematic_advance_data'));
+	$table->set_additional_parameters($parameters);
+	$table->set_header(0, '', false, array('style'=>'width:20px;'));
+	$table->set_header(1, get_lang('StartDate'), true );
+	$table->set_header(2, get_lang('DurationInHours'), true, array('style'=>'width:80px;'));
+	$table->set_header(3, get_lang('Content'), true);
+	
+	if (api_is_allowed_to_edit(null, true)) {
+		$table->set_header(4, get_lang('Actions'), false,array('style'=>'text-align:center'));	
+	}
+	
+	$table->display();	
+}
+
+?>

+ 327 - 0
main/course_progress/thematic_controller.php

@@ -0,0 +1,327 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+ * This file contains class used like controller for thematic, it should be included inside a dispatcher file (e.g: index.php)
+ * 
+ * !!! WARNING !!! : ALL DATES IN THIS MODULE ARE STORED IN UTC ! DO NOT CONVERT DURING THE TRANSITION FROM CHAMILO 1.8.x TO 2.0
+ * 
+ * @author Christian Fasanando <christian1827@gmail.com>
+ * @package chamilo.course_progress
+ */
+
+/**
+ * Thematic Controller script. Prepares the common background variables to give to the scripts corresponding to
+ * the requested action
+ * @package chamilo.course_progress 
+ */
+
+class ThematicController
+{
+	
+	/**
+	 * Constructor
+	 */
+	public function __construct() {		
+		$this->toolname = 'course_progress';
+		$this->view = new View($this->toolname);			
+	}
+	
+	/**
+	 * This method is used for thematic control (update, insert or listing)
+	 * @param 	string	Action
+	 * render to thematic.php 
+	 */	
+	public function thematic($action) {
+		
+		$thematic= new Thematic();		        
+		$data = array();		
+		$error = false;
+		
+		// insert or update a thematic		
+		if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {																
+			if (isset($_POST['action']) && ($_POST['action'] == 'thematic_add' || $_POST['action'] == 'thematic_edit')) {
+				if (!empty($_POST['title'])) {
+		    		if ($_POST['thematic_token'] == $_SESSION['thematic_token']) {				    						    			
+		    			$id = $_POST['thematic_id'];
+		    			$title = $_POST['title'];
+		    			$content = $_POST['content'];
+		    			$session_id = api_get_session_id();
+		    			$thematic->set_thematic_attributes($id, $title, $content, $session_id);	    			
+						$affected_rows = $thematic->thematic_save();
+						$action = 'thematic_list';				    			
+			        	unset($_SESSION['thematic_token']);	        			        			
+		    		}
+				} else {					
+					$error = true;
+					$data['error'] = $error;	
+					$data['action'] = $_POST['action'];	
+					$data['thematic_id'] = $_POST['thematic_id'];
+					// render to the view
+					$this->view->set_data($data);
+					$this->view->set_layout('layout'); 
+					$this->view->set_template('thematic');		       
+					$this->view->render();					    						    									
+				}
+			}				    		
+		}								
+
+		// delete many thematics
+		if ($action == 'thematic_delete_select') {
+			if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {				
+				$thematic_ids = $_POST['id'];
+				$affected_rows = $thematic->thematic_destroy($thematic_ids);
+				$action = 'thematic_list';
+			}
+		}
+		
+		$thematic_id = isset($_GET['thematic_id'])?intval($_GET['thematic_id']):null;
+
+		if (isset($thematic_id)) {	
+			
+			// delete a thematic					
+			if ($action == 'thematic_delete') {
+				$affected_rows = $thematic->thematic_destroy($thematic_id);
+				$action = 'thematic_list';
+			}	
+			
+			// move thematic
+			if ($action == 'moveup') {
+				$thematic->move_thematic('up', $thematic_id);
+				$action = 'thematic_list';
+			} else if ($action == 'movedown') {
+				$thematic->move_thematic('down', $thematic_id);
+				$action = 'thematic_list';
+			}
+					
+			$data['thematic_data'] = $thematic->get_thematic_list($thematic_id);				
+			$data['thematic_id'] = $thematic_id;										
+		}
+
+		if ($action == 'thematic_details') {
+			
+			if (isset($thematic_id)) {
+				$thematic_data[$thematic_id] = $thematic->get_thematic_list($thematic_id);
+				$data['total_average_of_advances'] = $thematic->get_average_of_advances_by_thematic($thematic_id);				
+			} else {
+				$thematic_data = $thematic->get_thematic_list();	
+				$data['last_done_thematic_advance'] = $thematic->get_last_done_thematic_advance();				
+				$data['total_average_of_advances'] = $thematic->get_total_average_of_thematic_advances();
+			}
+
+			$thematic_plan_data = $thematic->get_thematic_plan_data();
+			$thematic_advance_data = $thematic->get_thematic_advance_list();
+			$data['thematic_plan_data'] = $thematic_plan_data;
+			$data['thematic_advance_data'] = $thematic_advance_data;
+			$data['thematic_data'] = $thematic_data;
+		}
+
+		$data['action'] = $action;		
+		// render to the view
+		$this->view->set_data($data);
+		$this->view->set_layout('layout'); 
+		$this->view->set_template('thematic');		       
+		$this->view->render();
+		
+	}
+	
+	/**
+	 * This method is used for thematic plan control (update, insert or listing)
+	 * @param 	string	Action
+	 * render to thematic_plan.php 
+	 */	
+	public function thematic_plan($action) {
+		$thematic= new Thematic();		        
+		$data = array();
+		$error = false;
+		
+		if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {   		
+    		if (isset($_POST['action']) && ($_POST['action'] == 'thematic_plan_add' || $_POST['action'] == 'thematic_plan_edit')) {	    			
+    			if (!empty($_POST['title'])) {
+    				if ($_POST['thematic_plan_token'] == $_SESSION['thematic_plan_token']) {						    						    				    			
+		    			$thematic_id = $_POST['thematic_id'];
+		    			$title = $_POST['title'];
+		    			$description = $_POST['description'];
+		    			$description_type = $_POST['description_type'];
+		    			$thematic->set_thematic_plan_attributes($thematic_id, $title, $description, $description_type);	    			
+						$affected_rows = $thematic->thematic_plan_save();			        	
+						unset($_SESSION['thematic_plan_token']);	        
+			        	$action = 'thematic_plan_list';		
+		    		}
+    			} else {	   					
+						$error = true;
+						$action = $_POST['action'];
+						$data['error'] = $error;						
+						$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($_POST['thematic_id'], $_POST['description_type']);
+						$data['thematic_id'] = $_POST['thematic_id'];
+						$data['description_type'] = $_POST['description_type'];
+						$data['action'] = $action;
+						$data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title();
+						$data['default_thematic_plan_icon'] = $thematic->get_default_thematic_plan_icon();
+						$data['default_thematic_plan_question'] = $thematic->get_default_question();
+						$data['next_description_type'] = $thematic->get_next_description_type($_POST['thematic_id']);
+								
+						// render to the view
+						$this->view->set_data($data);
+						$this->view->set_layout('layout'); 
+						$this->view->set_template('thematic_plan');		       
+						$this->view->render();									    															
+    			}	    			
+    		}
+		}		
+																		
+		if ($action == 'thematic_plan_list') {
+			$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
+		}
+				
+		$thematic_id = intval($_GET['thematic_id']);
+		$description_type = intval($_GET['description_type']);
+
+		if (!empty($thematic_id) && !empty($description_type)) {
+			if ($action == 'thematic_plan_delete') {
+				$affected_rows = $thematic->thematic_plan_destroy($thematic_id, $description_type);				
+				$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
+				$action = 'thematic_plan_list';
+			} else {
+				$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id, $description_type);	
+			}											
+			$data['thematic_id'] = $thematic_id;
+			$data['description_type'] = $description_type;							
+		} else if (!empty($thematic_id) && $action == 'thematic_plan_list') {
+			$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
+			$data['thematic_id'] = $thematic_id;
+		}
+		
+		$data['thematic_id'] = $thematic_id;
+		$data['action'] = $action;
+		$data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title();
+		$data['default_thematic_plan_icon'] = $thematic->get_default_thematic_plan_icon();		
+		$data['next_description_type'] = $thematic->get_next_description_type($thematic_id);		
+		$data['default_thematic_plan_question'] = $thematic->get_default_question();
+				
+		// render to the view
+		$this->view->set_data($data);
+		$this->view->set_layout('layout'); 
+		$this->view->set_template('thematic_plan');		       
+		$this->view->render();
+	}
+	
+	/**
+	 * This method is used for thematic advance control (update, insert or listing)
+	 * @param 	string	Action
+	 * render to thematic_advance.php 
+	 */	
+	public function thematic_advance($action) {
+		
+		$thematic= new Thematic();	
+		$attendance = new Attendance();
+		$data = array();
+				
+		// get data for attendance input select		
+		$attendance_list = $attendance->get_attendances_list();		
+		$attendance_select = array();
+		$attendance_select[0] = get_lang('SelectAnAttendance');
+		foreach ($attendance_list as $attendance_id => $attendance_data) {
+			$attendance_select[$attendance_id] = $attendance_data['name'];
+		}
+
+		if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {				
+			if (isset($_POST['action']) && ($_POST['action'] == 'thematic_advance_add' || $_POST['action'] == 'thematic_advance_edit')) {
+	    		if (($_POST['start_date_type'] == 1 && empty($_POST['start_date_by_attendance'])) || (!empty($_POST['duration_in_hours']) && !is_numeric($_POST['duration_in_hours'])) ) {	    			
+	    			
+	    			if ($_POST['start_date_type'] == 1 && empty($_POST['start_date_by_attendance'])) {
+	    				$start_date_error = true;
+						$data['start_date_error'] = $start_date_error;	
+	    			} 
+	    			
+	    			if (!empty($_POST['duration_in_hours']) && !is_numeric($_POST['duration_in_hours'])) {
+	    				$duration_error = true;
+						$data['duration_error'] = $duration_error;	
+	    			}
+
+					$data['action'] = $_POST['action'];	
+					$data['thematic_id'] = $_POST['thematic_id'];				
+					$data['attendance_select'] = $attendance_select;					
+					if (isset($_POST['thematic_advance_id'])) {
+						$data['thematic_advance_id'] = $_POST['thematic_advance_id'];
+						$thematic_advance_data = $thematic->get_thematic_advance_list($_POST['thematic_advance_id']);
+						$data['thematic_advance_data'] = $thematic_advance_data;		
+					}	
+					// render to the view
+					$this->view->set_data($data);
+					$this->view->set_layout('layout'); 
+					$this->view->set_template('thematic_advance');		       
+					$this->view->render();	    			
+	    		} else {	
+		    		if ($_POST['thematic_advance_token'] == $_SESSION['thematic_advance_token']) {						    						    			
+		    			$thematic_advance_id = $_POST['thematic_advance_id'];
+		    			$thematic_id 	= $_POST['thematic_id'];	    			
+		    			$content 		= $_POST['content'];		    			
+		    			$duration		= $_POST['duration_in_hours'];
+		    			if (isset($_POST['start_date_type']) && $_POST['start_date_type'] == 2) {
+		    				$start_date 	= $thematic->build_datetime_from_array($_POST['custom_start_date']);
+		    				$attendance_id 	= 0;	
+		    			} else {
+		    				$start_date 	= $_POST['start_date_by_attendance'];
+		    				$attendance_id 	= $_POST['attendance_select'];
+		    			}		    			
+		    			$thematic->set_thematic_advance_attributes($thematic_advance_id, $thematic_id,  $attendance_id, $content, $start_date, $duration);	    				    								
+						$affected_rows = $thematic->thematic_advance_save();			        	
+			        	if ($affected_rows) {
+			        		// get last done thematic advance before move thematic list
+							$last_done_thematic_advance = $thematic->get_last_done_thematic_advance();
+							// update done advances with de current thematic list
+							if (!empty($last_done_thematic_advance)) {
+								$update_done_advances = $thematic->update_done_thematic_advances($last_done_thematic_advance);
+							}
+			        	}			        	
+						unset($_SESSION['thematic_advance_token']);	        
+			        	$action = 'thematic_advance_list';		
+		    		}
+	    		}	    		
+			}	    		
+		}		
+		
+		$thematic_id = intval($_GET['thematic_id']);
+		$thematic_advance_id = intval($_GET['thematic_advance_id']);
+		$thematic_advance_data = array();
+		if (!empty($thematic_advance_id)) {			
+			if ($action == 'thematic_advance_delete') {
+				$affected_rows = $thematic->thematic_advance_destroy($thematic_advance_id);
+				$action = 'thematic_advance_list';				
+			} else {
+				$thematic_advance_data = $thematic->get_thematic_advance_list($thematic_advance_id);	
+			}									
+		}
+		
+		// get calendar select by attendance id
+		$calendar_select = array();
+		if (!empty($thematic_advance_data)) {			
+			if (!empty($thematic_advance_data['attendance_id'])) {
+				$attendance_calendar = $attendance->get_attendance_calendar($thematic_advance_data['attendance_id']);				
+				if (!empty($attendance_calendar)) {								
+					foreach ($attendance_calendar as $calendar) {
+						$calendar_select[$calendar['date_time']] = $calendar['date_time'];	
+					}					
+				}
+			}			
+		}
+		
+		$data['action'] = $action;
+		$data['thematic_id'] = $thematic_id;
+		$data['thematic_advance_id'] = $thematic_advance_id;
+		$data['attendance_select'] = $attendance_select;
+		$data['thematic_advance_data'] = $thematic_advance_data;
+		$data['calendar_select'] = $calendar_select;
+		
+		// render to the view
+		$this->view->set_data($data);
+		$this->view->set_layout('layout'); 
+		$this->view->set_template('thematic_advance');		       
+		$this->view->render();
+		
+	}
+	
+}
+
+?>

+ 108 - 0
main/course_progress/thematic_plan.php

@@ -0,0 +1,108 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+* View (MVC patter) for thematic plan 
+* @author Christian Fasanando <christian1827@gmail.com>
+* @package chamilo.course_progress
+*/
+
+// actions menu
+$categories = array ();
+foreach ($default_thematic_plan_title as $id => $title) {
+	$categories[$id] = $title;
+}
+$categories[ADD_THEMATIC_PLAN] = get_lang('NewBloc');
+
+$i=1;
+echo '<div class="actions" style="margin-bottom:30px">';
+ksort($categories);
+foreach ($categories as $id => $title) {
+	if ($i == ADD_THEMATIC_PLAN) {
+		echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_plan_add&thematic_id='.$thematic_id.'&description_type='.$next_description_type.'">'.Display::return_icon($default_thematic_plan_icon[$id], $title, array('height'=>'22')).' '.$title.'</a>';
+		break;
+	} else {
+		echo '<a href="index.php?action=thematic_plan_edit&'.api_get_cidreq().'&description_type='.$id.'&thematic_id='.$thematic_id.'">'.Display::return_icon($default_thematic_plan_icon[$id], $title, array('height'=>'22')).' '.$title.'</a>&nbsp;&nbsp;';
+		$i++;
+	}
+}
+echo '</div>';
+
+if ($action == 'thematic_plan_list') {
+
+	if (isset($thematic_plan_data) && count($thematic_plan_data) > 0) {
+		foreach ($thematic_plan_data as $thematic_plan) {	
+			echo '<div class="sectiontitle">';			
+				//delete
+				echo '<a href="'.api_get_self().'?cidReq='.api_get_course_id().'&thematic_id='.$thematic_plan['thematic_id'].'&action=thematic_plan_delete&description_type='.$thematic_plan['description_type'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">';
+				echo Display::return_icon('delete.gif', get_lang('Delete'), array('style' => 'vertical-align:middle;float:right;'));
+				echo '</a> ';								
+				//edit
+				echo '<a href="'.api_get_self().'?cidReq='.api_get_course_id().'&thematic_id='.$thematic_plan['thematic_id'].'&action=thematic_plan_edit&description_type='.$thematic_plan['description_type'].'">';
+				echo Display::return_icon('edit.gif', get_lang('Edit'), array('style' => 'vertical-align:middle;float:right; padding-right:4px;'));
+				echo '</a> ';
+				echo $thematic_plan['title'];	
+			echo '</div>';
+			echo '<div class="sectioncomment">';
+			echo text_filter($thematic_plan['description']);
+			echo '</div>';
+		}
+	} else {
+		echo '<em>'.get_lang('ThisCourseDescriptionIsEmpty').'</em>';
+	}
+	
+} else if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
+
+	if ($description_type >= ADD_THEMATIC_PLAN) {
+		$header_form = get_lang('NewBloc');
+	} else {
+		$header_form = $default_thematic_plan_title[$description_type];		
+	}	
+	if (!$error) {
+		$token = md5(uniqid(rand(),TRUE));
+		$_SESSION['thematic_plan_token'] = $token;
+	}
+
+	// display form
+	$form = new FormValidator('thematic_plan_add','POST','index.php?action=thematic_plan_list&thematic_id='.$thematic_id.'&'.api_get_cidreq().$param_gradebook,'','style="width: 100%;"');
+	$form->addElement('header', '', $header_form);
+	$form->addElement('hidden', 'action', $action);
+	$form->addElement('hidden', 'thematic_plan_token', $token);
+	
+	if (!empty($thematic_id)) {
+		$form->addElement('hidden', 'thematic_id', $thematic_id);	
+	}
+	if (!empty($description_type)) {
+		$form->addElement('hidden', 'description_type', $description_type);	
+	}
+
+	$form->add_textfield('title', get_lang('Title'), true, array('size'=>'50'));
+	$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200'));	
+	$form->addElement('html','<div class="clear" style="margin-top:50px;"></div>');
+	$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
+	
+	if ($description_type < ADD_THEMATIC_PLAN) {
+		$default['title'] = $default_thematic_plan_title[$description_type];
+	}
+	if (!empty($thematic_plan_data)) {
+		// set default values
+		$default['title'] = $thematic_plan_data[0]['title'];
+		$default['description'] = $thematic_plan_data[0]['description'];		
+	}	
+	$form->setDefaults($default);
+	
+	if (isset($default_thematic_plan_question[$description_type])) {
+		$message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
+		$message .= $default_thematic_plan_question[$description_type];
+		Display::display_normal_message($message, false);
+	}
+
+	// error messages
+	if ($error) { 	
+		Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);	
+	}
+	
+	$form->display();		
+}
+
+?>

+ 4 - 4
main/inc/introductionSection.inc.php

@@ -159,12 +159,12 @@ $thematic_description_html = '';
 
 if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
 
-	$thematic = new Thematic();	
-	if (api_get_course_setting('display_info_advance_inside_homecourse')) {
+	$thematic = new Thematic();
+	if (api_get_course_setting('display_info_advance_inside_homecourse') == '1') {
 		$information_title = get_lang('InfoAboutLastDoneAdvance');
 		$last_done_advance =  $thematic->get_last_done_thematic_advance();
 		$thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance);
-	} else {
+	} else if(api_get_course_setting('display_info_advance_inside_homecourse') == '2') {
 		$information_title = get_lang('InfoAboutNextAdvanceNotDone');
 		$next_advance_not_done = $thematic->get_next_thematic_advance_not_done();
 		$thematic_advance_info = $thematic->get_thematic_advance_list($next_advance_not_done);
@@ -185,7 +185,7 @@ if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
 		$thematic_description_html .= '<h3>'.$thematic_advance.'</h3>';	
 		$thematic_description_html .= '<h4>'.$information_title.'</h4>';						  								
 		$thematic_description_html .= '<div><strong>'.$thematic_info['title'].'</strong></div>';			
-		$thematic_description_html .= '<div><strong>'.api_get_local_time($thematic_advance_info['start_date']).'</strong></div>';
+		$thematic_description_html .= '<div><strong>'.api_convert_and_format_date($thematic_advance_info['start_date'], DATE_TIME_FORMAT_LONG, date_default_timezone_get()).'</strong></div>';
 		$thematic_description_html .= '<div>'.$thematic_advance_info['content'].'</div>';
 		$thematic_description_html .= '<div>'.get_lang('DurationInHours').' : '.$thematic_advance_info['duration'].'</div>';
 		$thematic_description_html .= '<br />';								  	

+ 2 - 0
main/inc/lib/add_course.lib.inc.php

@@ -2163,6 +2163,8 @@ function fill_Db_course($courseDbName, $courseRepository, $language,$default_doc
 	Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_GLOSSARY."','glossary/index.php','glossary.gif','".string2binary(api_get_setting('course_create_active_tools', 'glossary')). "','0','squaregrey.gif','NO','_self','authoring','0')");
 	Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_NOTEBOOK."','notebook/index.php','notebook.gif','".string2binary(api_get_setting('course_create_active_tools', 'notebook'))."','0','squaregrey.gif','NO','_self','interaction','0')");
 	Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_ATTENDANCE."','attendance/index.php','attendance.gif','".string2binary(api_get_setting('course_create_active_tools', 'attendances'))."','0','squaregrey.gif','NO','_self','authoring','0')");
+	Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_COURSE_PROGRESS."','course_progress/index.php','course_progress.gif','".string2binary(api_get_setting('course_create_active_tools', 'course_progress'))."','0','squaregrey.gif','NO','_self','authoring','0')");
+	
 	if(api_get_setting('service_visio','active')=='true')
 	{
 		$mycheck = api_get_setting('service_visio','visio_host');

+ 10 - 9
main/inc/lib/main_api.lib.php

@@ -97,6 +97,7 @@ define('TOOL_GLOSSARY','glossary');
 define('TOOL_GRADEBOOK','gradebook');
 define('TOOL_NOTEBOOK','notebook');
 define('TOOL_ATTENDANCE','attendance');
+define('TOOL_COURSE_PROGRESS','course_progress');
 
 // CONSTANTS defining Chamilo interface sections
 define('SECTION_CAMPUS', 'mycampus');
@@ -4184,15 +4185,15 @@ function api_calculate_image_size($image_width, $image_height, $target_width, $t
  */
 function api_get_tools_lists($my_tool = null) {
 	$tools_list = array(
-		TOOL_DOCUMENT,TOOL_THUMBNAIL,TOOL_HOTPOTATOES,
-		TOOL_CALENDAR_EVENT,TOOL_LINK,TOOL_COURSE_DESCRIPTION,TOOL_SEARCH,
-		TOOL_LEARNPATH,TOOL_ANNOUNCEMENT,TOOL_FORUM,TOOL_THREAD,TOOL_POST,
-		TOOL_DROPBOX,TOOL_QUIZ,TOOL_USER,TOOL_GROUP,TOOL_BLOGS,TOOL_CHAT,
-		TOOL_CONFERENCE,TOOL_STUDENTPUBLICATION,TOOL_TRACKING,TOOL_HOMEPAGE_LINK,
-		TOOL_COURSE_SETTING,TOOL_BACKUP,TOOL_COPY_COURSE_CONTENT,TOOL_RECYCLE_COURSE,
-		TOOL_COURSE_HOMEPAGE,TOOL_COURSE_RIGHTS_OVERVIEW,TOOL_UPLOAD,TOOL_COURSE_MAINTENANCE,
-		TOOL_VISIO,TOOL_VISIO_CONFERENCE,TOOL_VISIO_CLASSROOM,TOOL_SURVEY,TOOL_WIKI,
-		TOOL_GLOSSARY,TOOL_GRADEBOOK,TOOL_NOTEBOOK,TOOL_ATTENDANCE
+		TOOL_DOCUMENT, TOOL_THUMBNAIL, TOOL_HOTPOTATOES,
+		TOOL_CALENDAR_EVENT, TOOL_LINK, TOOL_COURSE_DESCRIPTION, TOOL_SEARCH,
+		TOOL_LEARNPATH, TOOL_ANNOUNCEMENT, TOOL_FORUM, TOOL_THREAD, TOOL_POST,
+		TOOL_DROPBOX, TOOL_QUIZ, TOOL_USER, TOOL_GROUP, TOOL_BLOGS, TOOL_CHAT,
+		TOOL_CONFERENCE, TOOL_STUDENTPUBLICATION, TOOL_TRACKING, TOOL_HOMEPAGE_LINK,
+		TOOL_COURSE_SETTING, TOOL_BACKUP, TOOL_COPY_COURSE_CONTENT, TOOL_RECYCLE_COURSE,
+		TOOL_COURSE_HOMEPAGE, TOOL_COURSE_RIGHTS_OVERVIEW, TOOL_UPLOAD, TOOL_COURSE_MAINTENANCE,
+		TOOL_VISIO, TOOL_VISIO_CONFERENCE, TOOL_VISIO_CLASSROOM, TOOL_SURVEY, TOOL_WIKI,
+		TOOL_GLOSSARY, TOOL_GRADEBOOK, TOOL_NOTEBOOK, TOOL_ATTENDANCE, TOOL_COURSE_PROGRESS
 	);
 	if (empty($my_tool)) {
 		return $tools_list;

+ 5 - 3
main/install/db_main.sql

@@ -288,7 +288,8 @@ INSERT INTO course_module VALUES
 (26,'gradebook','gradebook/index.php','gradebook.gif',2,2,'basic'),
 (27,'glossary','glossary/index.php','glossary.gif',2,1,'basic'),
 (28,'notebook','notebook/index.php','notebook.gif',2,1,'basic'),
-(29,'attendance','attendance/index.php','attendance.gif',2,1,'basic');
+(29,'attendance','attendance/index.php','attendance.gif',2,1,'basic'),
+(30,'course_progress','course_progress/index.php','course_progress.gif',2,1,'basic');
 UNLOCK TABLES;
 /*!40000 ALTER TABLE course_module ENABLE KEYS */;
 
@@ -724,7 +725,8 @@ VALUES
 ('course_create_active_tools','survey','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Survey', 0),
 ('course_create_active_tools','glossary','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Glossary', 0),
 ('course_create_active_tools','notebook','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Notebook', 0),
-('course_create_active_tools','attendances','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Attendances', 0),
+('course_create_active_tools','attendances','checkbox','Tools','false','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Attendances', 0),
+('course_create_active_tools','course_progress','checkbox','Tools','false','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'CourseProgress', 0),
 ('advanced_filemanager',NULL,'radio','Editor','false','AdvancedFileManagerTitle','AdvancedFileManagerComment',NULL,NULL, 0),
 ('allow_reservation', NULL, 'radio', 'Tools', 'false', 'AllowReservationTitle', 'AllowReservationComment', NULL, NULL, 0),
 ('profile','apikeys','checkbox','User','false','ProfileChangesTitle','ProfileChangesComment',NULL,'ApiKeys', 0),
@@ -757,7 +759,7 @@ VALUES
 ('show_tabs', 'dashboard', 'checkbox', 'Platform', 'true', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsDashboard', 1),
 ('use_users_timezone', 'timezones', 'radio', 'Timezones', 'true', 'UseUsersTimezoneTitle','UseUsersTimezoneComment',NULL,'Timezones', 1),
 ('timezone_value', 'timezones', 'select', 'Timezones', '', 'TimezoneValueTitle','TimezoneValueComment',NULL,'Timezones', 1),
-('dokeos_database_version', NULL, 'textfield', NULL,'1.8.7.11140','DokeosDatabaseVersion','',NULL,NULL,0);
+('dokeos_database_version', NULL, 'textfield', NULL,'1.8.7.11182','DokeosDatabaseVersion','',NULL,NULL,0);
 
 
 UNLOCK TABLES;

+ 6 - 3
main/install/migrate-db-1.8.6.2-1.8.7-pre.sql

@@ -63,16 +63,18 @@ ALTER TABLE gradebook_result_log CHANGE date_log created_at DATETIME NOT NULL de
 
 INSERT INTO user_field(field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES(11, 'timezone', 'Timezone', 0, 0);
 
-INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_create_active_tools','attendances','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Attendances', 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_create_active_tools','attendances','checkbox','Tools','false','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Attendances', 0);
 
 ALTER TABLE user_field_values CHANGE id id BIGINT NOT NULL AUTO_INCREMENT;
 ALTER TABLE user_field_values ADD INDEX (user_id, field_id);
 
-UPDATE settings_current SET selected_value = '1.8.7.11140' WHERE variable = 'dokeos_database_version';
+UPDATE settings_current SET selected_value = '1.8.7.11182' WHERE variable = 'dokeos_database_version';
 
 ALTER TABLE course_rel_user DROP PRIMARY KEY, ADD PRIMARY KEY (course_code, user_id, relation_type);
 ALTER TABLE session_rel_user DROP PRIMARY KEY, ADD PRIMARY KEY (id_session, id_user, relation_type);
 
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_create_active_tools','course_progress','checkbox','Tools','false','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'CourseProgress', 0);
+
 -- xxSTATSxx
 CREATE TABLE track_e_item_property(id int NOT NULL auto_increment PRIMARY KEY, course_id int NOT NULL, item_property_id int NOT NULL, title varchar(255), content text, progress int NOT NULL default 0, lastedit_date datetime NOT NULL default '0000-00-00 00:00:00', lastedit_user_id int  NOT NULL, session_id int NOT NULL default 0);
 ALTER TABLE track_e_item_property ADD INDEX (course_id, item_property_id, session_id);
@@ -124,4 +126,5 @@ CREATE TABLE thematic_plan (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, thematic
 ALTER TABLE thematic_plan ADD INDEX (thematic_id, description_type); 
 CREATE TABLE thematic_advance (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, thematic_id INT NOT NULL, attendance_id INT NOT NULL DEFAULT 0, content TEXT NOT NULL, start_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', duration INT NOT NULL DEFAULT 0, done_advance tinyint NOT NULL DEFAULT 0);
 ALTER TABLE thematic_advance ADD INDEX (thematic_id);
-INSERT INTO course_setting (variable,value,category) VALUES ('display_info_advance_inside_homecourse',1,'thematic_advance');
+INSERT INTO course_setting (variable,value,category) VALUES ('display_info_advance_inside_homecourse',1,'thematic_advance');
+INSERT INTO tool(name, link, image, visibility, admin, address, added_tool, target, category) VALUES ('course_progress','course_progress/index.php','course_progress.gif',0,'0','squaregrey.gif',0,'_self','authoring');